Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Unified Diff: webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added more fixes for override hiding in AudioEncoder implementations. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
diff --git a/webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc b/webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
index 5ab55ba9e80262feca10b3ffecd3aa5c843c18b8..baa0d67aded47da5080feca0891d32bebf5a3bfe 100644
--- a/webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
+++ b/webrtc/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
@@ -104,7 +104,7 @@ class NetEqOpusQualityTest : public NetEqQualityTest {
void SetUp() override;
void TearDown() override;
virtual int EncodeBlock(int16_t* in_data, size_t block_size_samples,
- uint8_t* payload, size_t max_bytes);
+ rtc::Buffer* payload, size_t max_bytes);
private:
WebRtcOpusEncInst* opus_encoder_;
OpusRepacketizer* repacketizer_;
@@ -175,25 +175,33 @@ void NetEqOpusQualityTest::TearDown() {
int NetEqOpusQualityTest::EncodeBlock(int16_t* in_data,
size_t block_size_samples,
- uint8_t* payload, size_t max_bytes) {
+ rtc::Buffer* payload, size_t max_bytes) {
EXPECT_EQ(block_size_samples, sub_block_size_samples_ * sub_packets_);
int16_t* pointer = in_data;
int value;
opus_repacketizer_init(repacketizer_);
for (int idx = 0; idx < sub_packets_; idx++) {
- value = WebRtcOpus_Encode(opus_encoder_, pointer, sub_block_size_samples_,
- max_bytes, payload);
- Log() << "Encoded a frame with Opus mode "
- << (value == 0 ? 0 : payload[0] >> 3)
- << std::endl;
- if (OPUS_OK != opus_repacketizer_cat(repacketizer_, payload, value)) {
+ payload->AppendData(max_bytes, [&] (rtc::ArrayView<uint8_t> payload) {
+ value = WebRtcOpus_Encode(opus_encoder_,
+ pointer, sub_block_size_samples_,
+ max_bytes, payload.data());
+
+ Log() << "Encoded a frame with Opus mode "
+ << (value == 0 ? 0 : payload[0] >> 3)
+ << std::endl;
+
+ return (value >= 0) ? static_cast<size_t>(value) : 0;
+ });
+
+ if (OPUS_OK != opus_repacketizer_cat(repacketizer_,
+ payload->data(), value)) {
opus_repacketizer_init(repacketizer_);
// If the repacketization fails, we discard this frame.
return 0;
}
pointer += sub_block_size_samples_ * channels_;
}
- value = opus_repacketizer_out(repacketizer_, payload,
+ value = opus_repacketizer_out(repacketizer_, payload->data(),
static_cast<opus_int32>(max_bytes));
EXPECT_GE(value, 0);
return value;

Powered by Google App Engine
This is Rietveld 408576698