Don't link with audio codecs that we don't use
We used to link with all audio codecs unconditionally (except Opus); this patch makes gyp and gn only link to the ones that are used. This unfortunately fails to have a measurable impact on Chromium binary size, at least on x86_64 Linux; it turns out that iLBC and iSAC fix were already being excluded from Chromium by some other means, likely just the linker omitting compilation units with no incoming references. (This was previously landed as revisions 10046 and 10060, and got reverted because it broke several of the Chromium FYI bots.) BUG=webrtc:4557 Review URL: https://codereview.webrtc.org/1368843003 Cr-Commit-Position: refs/heads/master@{#10127}
This commit is contained in:
@ -13,11 +13,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef AUDIO_DECODER_UNITTEST
|
||||
// If this is compiled as a part of the audio_deoder_unittest, the codec
|
||||
// selection is made in the gypi file instead of in engine_configurations.h.
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#endif
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_decoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h"
|
||||
|
||||
@ -475,7 +475,6 @@ class AudioDecoderOpusStereoTest : public AudioDecoderOpusTest {
|
||||
TEST_F(AudioDecoderPcmUTest, EncodeDecode) {
|
||||
int tolerance = 251;
|
||||
double mse = 1734.0;
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCMu));
|
||||
EncodeDecodeTest(data_length_, tolerance, mse);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -502,7 +501,6 @@ TEST_F(AudioDecoderPcmUTest, SetTargetBitrate) {
|
||||
TEST_F(AudioDecoderPcmATest, EncodeDecode) {
|
||||
int tolerance = 308;
|
||||
double mse = 1931.0;
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCMa));
|
||||
EncodeDecodeTest(data_length_, tolerance, mse);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -515,10 +513,6 @@ TEST_F(AudioDecoderPcmATest, SetTargetBitrate) {
|
||||
TEST_F(AudioDecoderPcm16BTest, EncodeDecode) {
|
||||
int tolerance = 0;
|
||||
double mse = 0.0;
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16B));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz));
|
||||
EncodeDecodeTest(2 * data_length_, tolerance, mse);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -533,7 +527,6 @@ TEST_F(AudioDecoderIlbcTest, EncodeDecode) {
|
||||
int tolerance = 6808;
|
||||
double mse = 2.13e6;
|
||||
int delay = 80; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderILBC));
|
||||
EncodeDecodeTest(500, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_TRUE(decoder_->HasDecodePlc());
|
||||
@ -548,7 +541,6 @@ TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) {
|
||||
int tolerance = 3399;
|
||||
double mse = 434951.0;
|
||||
int delay = 48; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISAC));
|
||||
EncodeDecodeTest(0, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -562,7 +554,6 @@ TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) {
|
||||
int tolerance = 19757;
|
||||
double mse = 8.18e6;
|
||||
int delay = 160; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISACswb));
|
||||
EncodeDecodeTest(0, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -582,7 +573,6 @@ TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) {
|
||||
int tolerance = 11034;
|
||||
double mse = 3.46e6;
|
||||
int delay = 54; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISAC));
|
||||
#ifdef WEBRTC_ANDROID
|
||||
static const int kEncodedBytes = 685;
|
||||
#else
|
||||
@ -601,7 +591,6 @@ TEST_F(AudioDecoderG722Test, EncodeDecode) {
|
||||
int tolerance = 6176;
|
||||
double mse = 238630.0;
|
||||
int delay = 22; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderG722));
|
||||
EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -611,16 +600,11 @@ TEST_F(AudioDecoderG722Test, SetTargetBitrate) {
|
||||
TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000);
|
||||
}
|
||||
|
||||
TEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) {
|
||||
EXPECT_TRUE(CodecSupported(kDecoderG722_2ch));
|
||||
}
|
||||
|
||||
TEST_F(AudioDecoderG722StereoTest, EncodeDecode) {
|
||||
int tolerance = 6176;
|
||||
int channel_diff_tolerance = 0;
|
||||
double mse = 238630.0;
|
||||
int delay = 22; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderG722_2ch));
|
||||
EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -634,7 +618,6 @@ TEST_F(AudioDecoderOpusTest, EncodeDecode) {
|
||||
int tolerance = 6176;
|
||||
double mse = 238630.0;
|
||||
int delay = 22; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderOpus));
|
||||
EncodeDecodeTest(0, tolerance, mse, delay);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -659,7 +642,6 @@ TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) {
|
||||
int channel_diff_tolerance = 0;
|
||||
double mse = 238630.0;
|
||||
int delay = 22; // Delay from input to output.
|
||||
EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch));
|
||||
EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance);
|
||||
ReInitTest();
|
||||
EXPECT_FALSE(decoder_->HasDecodePlc());
|
||||
@ -669,15 +651,43 @@ TEST_F(AudioDecoderOpusStereoTest, SetTargetBitrate) {
|
||||
TestOpusSetTargetBitrates(audio_encoder_.get());
|
||||
}
|
||||
|
||||
namespace {
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
const bool has_ilbc = true;
|
||||
#else
|
||||
const bool has_ilbc = false;
|
||||
#endif
|
||||
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
|
||||
const bool has_isac = true;
|
||||
#else
|
||||
const bool has_isac = false;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
const bool has_isac_swb = true;
|
||||
#else
|
||||
const bool has_isac_swb = false;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_G722
|
||||
const bool has_g722 = true;
|
||||
#else
|
||||
const bool has_g722 = false;
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_OPUS
|
||||
const bool has_opus = true;
|
||||
#else
|
||||
const bool has_opus = false;
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
TEST(AudioDecoder, CodecSampleRateHz) {
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu_2ch));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa_2ch));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderILBC));
|
||||
EXPECT_EQ(16000, CodecSampleRateHz(kDecoderISAC));
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACswb));
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACfb));
|
||||
EXPECT_EQ(has_ilbc ? 8000 : -1, CodecSampleRateHz(kDecoderILBC));
|
||||
EXPECT_EQ(has_isac ? 16000 : -1, CodecSampleRateHz(kDecoderISAC));
|
||||
EXPECT_EQ(has_isac_swb ? 32000 : -1, CodecSampleRateHz(kDecoderISACswb));
|
||||
EXPECT_EQ(has_isac_swb ? 32000 : -1, CodecSampleRateHz(kDecoderISACfb));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B));
|
||||
EXPECT_EQ(16000, CodecSampleRateHz(kDecoderPCM16Bwb));
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz));
|
||||
@ -687,15 +697,15 @@ TEST(AudioDecoder, CodecSampleRateHz) {
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz_2ch));
|
||||
EXPECT_EQ(48000, CodecSampleRateHz(kDecoderPCM16Bswb48kHz_2ch));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B_5ch));
|
||||
EXPECT_EQ(16000, CodecSampleRateHz(kDecoderG722));
|
||||
EXPECT_EQ(16000, CodecSampleRateHz(kDecoderG722_2ch));
|
||||
EXPECT_EQ(has_g722 ? 16000 : -1, CodecSampleRateHz(kDecoderG722));
|
||||
EXPECT_EQ(has_g722 ? 16000 : -1, CodecSampleRateHz(kDecoderG722_2ch));
|
||||
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderRED));
|
||||
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderAVT));
|
||||
EXPECT_EQ(8000, CodecSampleRateHz(kDecoderCNGnb));
|
||||
EXPECT_EQ(16000, CodecSampleRateHz(kDecoderCNGwb));
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb32kHz));
|
||||
EXPECT_EQ(48000, CodecSampleRateHz(kDecoderOpus));
|
||||
EXPECT_EQ(48000, CodecSampleRateHz(kDecoderOpus_2ch));
|
||||
EXPECT_EQ(has_opus ? 48000 : -1, CodecSampleRateHz(kDecoderOpus));
|
||||
EXPECT_EQ(has_opus ? 48000 : -1, CodecSampleRateHz(kDecoderOpus_2ch));
|
||||
// TODO(tlegrand): Change 32000 to 48000 below once ACM has 48 kHz support.
|
||||
EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb48kHz));
|
||||
EXPECT_EQ(-1, CodecSampleRateHz(kDecoderArbitrary));
|
||||
@ -706,10 +716,10 @@ TEST(AudioDecoder, CodecSupported) {
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCMa));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCMu_2ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCMa_2ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderILBC));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISAC));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISACswb));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderISACfb));
|
||||
EXPECT_EQ(has_ilbc, CodecSupported(kDecoderILBC));
|
||||
EXPECT_EQ(has_isac, CodecSupported(kDecoderISAC));
|
||||
EXPECT_EQ(has_isac_swb, CodecSupported(kDecoderISACswb));
|
||||
EXPECT_EQ(has_isac_swb, CodecSupported(kDecoderISACfb));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16B));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz));
|
||||
@ -719,8 +729,8 @@ TEST(AudioDecoder, CodecSupported) {
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz_2ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz_2ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderPCM16B_5ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderG722));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderG722_2ch));
|
||||
EXPECT_EQ(has_g722, CodecSupported(kDecoderG722));
|
||||
EXPECT_EQ(has_g722, CodecSupported(kDecoderG722_2ch));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderRED));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderAVT));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderCNGnb));
|
||||
@ -728,8 +738,8 @@ TEST(AudioDecoder, CodecSupported) {
|
||||
EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderArbitrary));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderOpus));
|
||||
EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch));
|
||||
EXPECT_EQ(has_opus, CodecSupported(kDecoderOpus));
|
||||
EXPECT_EQ(has_opus, CodecSupported(kDecoderOpus_2ch));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -172,8 +172,14 @@ TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
|
||||
#define IF_ISAC(x) x
|
||||
#else
|
||||
#define IF_ISAC(x) DISABLED_##x
|
||||
#endif
|
||||
|
||||
// Test the methods for setting and getting active speech and CNG decoders.
|
||||
TEST(DecoderDatabase, ActiveDecoders) {
|
||||
TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) {
|
||||
DecoderDatabase db;
|
||||
// Load payload types.
|
||||
ASSERT_EQ(DecoderDatabase::kOK, db.RegisterPayload(0, kDecoderPCMu));
|
||||
|
||||
@ -11,10 +11,6 @@
|
||||
'codecs': [
|
||||
'cng',
|
||||
'g711',
|
||||
'g722',
|
||||
'ilbc',
|
||||
'isac',
|
||||
'isac_fix',
|
||||
'pcm16b',
|
||||
],
|
||||
'neteq_defines': [],
|
||||
@ -23,6 +19,23 @@
|
||||
'codecs': ['webrtc_opus',],
|
||||
'neteq_defines': ['WEBRTC_CODEC_OPUS',],
|
||||
}],
|
||||
['build_with_mozilla==0', {
|
||||
'conditions': [
|
||||
['target_arch=="arm"', {
|
||||
'codecs': ['isac_fix',],
|
||||
'neteq_defines': ['WEBRTC_CODEC_ISACFX',],
|
||||
}, {
|
||||
'codecs': ['isac',],
|
||||
'neteq_defines': ['WEBRTC_CODEC_ISAC',],
|
||||
}],
|
||||
],
|
||||
'codecs': ['g722',],
|
||||
'neteq_defines': ['WEBRTC_CODEC_G722',],
|
||||
}],
|
||||
['build_with_mozilla==0 and build_with_chromium==0', {
|
||||
'codecs': ['ilbc',],
|
||||
'neteq_defines': ['WEBRTC_CODEC_ILBC',],
|
||||
}],
|
||||
],
|
||||
'neteq_dependencies': [
|
||||
'<@(codecs)',
|
||||
@ -120,6 +133,10 @@
|
||||
'type': '<(gtest_target_type)',
|
||||
'dependencies': [
|
||||
'<@(codecs)',
|
||||
'g722',
|
||||
'ilbc',
|
||||
'isac',
|
||||
'isac_fix',
|
||||
'audio_decoder_interface',
|
||||
'neteq_unittest_tools',
|
||||
'<(DEPTH)/testing/gtest.gyp:gtest',
|
||||
@ -127,11 +144,6 @@
|
||||
'<(webrtc_root)/test/test.gyp:test_support_main',
|
||||
],
|
||||
'defines': [
|
||||
'AUDIO_DECODER_UNITTEST',
|
||||
'WEBRTC_CODEC_G722',
|
||||
'WEBRTC_CODEC_ILBC',
|
||||
'WEBRTC_CODEC_ISACFX',
|
||||
'WEBRTC_CODEC_ISAC',
|
||||
'<@(neteq_defines)',
|
||||
],
|
||||
'sources': [
|
||||
|
||||
@ -307,18 +307,20 @@ void NetEqDecodingTest::LoadDecoders() {
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderPCMu, 0));
|
||||
// Load PCMa.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderPCMa, 8));
|
||||
#ifndef WEBRTC_ANDROID
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
// Load iLBC.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderILBC, 102));
|
||||
#endif // WEBRTC_ANDROID
|
||||
#endif
|
||||
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
|
||||
// Load iSAC.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderISAC, 103));
|
||||
#ifndef WEBRTC_ANDROID
|
||||
#endif
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
// Load iSAC SWB.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderISACswb, 104));
|
||||
// Load iSAC FB.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderISACfb, 105));
|
||||
#endif // WEBRTC_ANDROID
|
||||
#endif
|
||||
// Load PCM16B nb.
|
||||
ASSERT_EQ(0, neteq_->RegisterPayloadType(kDecoderPCM16B, 93));
|
||||
// Load PCM16B wb.
|
||||
@ -441,8 +443,15 @@ void NetEqDecodingTest::PopulateCng(int frame_index,
|
||||
*payload_len = 1; // Only noise level, no spectral parameters.
|
||||
}
|
||||
|
||||
#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISAC)) && \
|
||||
defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
|
||||
#define IF_ALL_CODECS(x) x
|
||||
#else
|
||||
#define IF_ALL_CODECS(x) DISABLED_##x
|
||||
#endif
|
||||
|
||||
TEST_F(NetEqDecodingTest,
|
||||
DISABLED_ON_IOS(DISABLED_ON_ANDROID(TestBitExactness))) {
|
||||
DISABLED_ON_IOS(DISABLED_ON_ANDROID(IF_ALL_CODECS(TestBitExactness)))) {
|
||||
const std::string input_rtp_file = webrtc::test::ProjectRootPath() +
|
||||
"resources/audio_coding/neteq_universal_new.rtp";
|
||||
// Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm
|
||||
@ -820,7 +829,13 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) {
|
||||
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
|
||||
}
|
||||
|
||||
TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(DecoderError)) {
|
||||
#if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
|
||||
#define IF_ISAC(x) x
|
||||
#else
|
||||
#define IF_ISAC(x) DISABLED_##x
|
||||
#endif
|
||||
|
||||
TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) {
|
||||
const size_t kPayloadBytes = 100;
|
||||
uint8_t payload[kPayloadBytes] = {0};
|
||||
WebRtcRTPHeader rtp_info;
|
||||
@ -1051,7 +1066,7 @@ TEST_F(NetEqBgnTestFade, RunTest) {
|
||||
CheckBgn(32000);
|
||||
}
|
||||
|
||||
TEST_F(NetEqDecodingTest, SyncPacketInsert) {
|
||||
TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) {
|
||||
WebRtcRTPHeader rtp_info;
|
||||
uint32_t receive_timestamp = 0;
|
||||
// For the readability use the following payloads instead of the defaults of
|
||||
|
||||
Reference in New Issue
Block a user