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/audio_decoder_unittest.cc

Issue 1184313002: Add AudioEncoder::GetTargetBitrate (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing GN compile Created 5 years, 6 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
« no previous file with comments | « webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
index 1850807783a9852e0b4b0aa538e95b7441b26ca4..d54fbe9099a50a86b427b0fcecc8b6b26df8ec56 100644
--- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
+++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc
@@ -485,6 +485,24 @@ TEST_F(AudioDecoderPcmUTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+namespace {
+int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) {
+ audio_encoder->SetTargetBitrate(rate);
+ return audio_encoder->GetTargetBitrate();
+}
+void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder,
+ int fixed_rate) {
+ EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, 32000));
+ EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate - 1));
+ EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate));
+ EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate + 1));
+}
+} // namespace
+
+TEST_F(AudioDecoderPcmUTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000);
+}
+
TEST_F(AudioDecoderPcmATest, EncodeDecode) {
int tolerance = 308;
double mse = 1931.0;
@@ -494,6 +512,10 @@ TEST_F(AudioDecoderPcmATest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderPcmATest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000);
+}
+
TEST_F(AudioDecoderPcm16BTest, EncodeDecode) {
int tolerance = 0;
double mse = 0.0;
@@ -506,6 +528,11 @@ TEST_F(AudioDecoderPcm16BTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderPcm16BTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(),
+ codec_input_rate_hz_ * 16);
+}
+
TEST_F(AudioDecoderIlbcTest, EncodeDecode) {
int tolerance = 6808;
double mse = 2.13e6;
@@ -517,6 +544,10 @@ TEST_F(AudioDecoderIlbcTest, EncodeDecode) {
DecodePlcTest();
}
+TEST_F(AudioDecoderIlbcTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 13333);
+}
+
TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) {
int tolerance = 3399;
double mse = 434951.0;
@@ -527,6 +558,10 @@ TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderIsacFloatTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000);
+}
+
TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
int tolerance = 19757;
double mse = 8.18e6;
@@ -537,6 +572,10 @@ TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderIsacSwbTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000);
+}
+
// Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4198
#if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64)
#define MAYBE_EncodeDecode DISABLED_EncodeDecode
@@ -558,6 +597,10 @@ TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderIsacFixTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000);
+}
+
TEST_F(AudioDecoderG722Test, EncodeDecode) {
int tolerance = 6176;
double mse = 238630.0;
@@ -568,6 +611,10 @@ TEST_F(AudioDecoderG722Test, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderG722Test, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000);
+}
+
TEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) {
EXPECT_TRUE(CodecSupported(kDecoderG722_2ch));
}
@@ -583,6 +630,10 @@ TEST_F(AudioDecoderG722StereoTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderG722StereoTest, SetTargetBitrate) {
+ TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 128000);
+}
+
TEST_F(AudioDecoderOpusTest, EncodeDecode) {
int tolerance = 6176;
double mse = 238630.0;
@@ -593,6 +644,20 @@ TEST_F(AudioDecoderOpusTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+namespace {
+void TestOpusSetTargetBitrates(AudioEncoder* audio_encoder) {
+ EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 499));
+ EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 500));
+ EXPECT_EQ(32000, SetAndGetTargetBitrate(audio_encoder, 32000));
+ EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 512000));
+ EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 513000));
+}
+} // namespace
+
+TEST_F(AudioDecoderOpusTest, SetTargetBitrate) {
+ TestOpusSetTargetBitrates(audio_encoder_.get());
+}
+
TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) {
int tolerance = 6176;
int channel_diff_tolerance = 0;
@@ -604,6 +669,10 @@ TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) {
EXPECT_FALSE(decoder_->HasDecodePlc());
}
+TEST_F(AudioDecoderOpusStereoTest, SetTargetBitrate) {
+ TestOpusSetTargetBitrates(audio_encoder_.get());
+}
+
TEST(AudioDecoder, CodecSampleRateHz) {
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu));
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa));
« no previous file with comments | « webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698