Run Opus with lower complexity setting on Android, iOS and/or ARM

This CL includes a call to Opus to set a lower complexity figure, if we are compiling for Android, iOS, or ARM (e.g. ChromeOS on ARM), where we know the devices are not powerful enough to run on higher complexity setting.

BUG=3093
R=minyue@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/10489004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5760 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2014-03-24 14:38:36 +00:00
parent 3c412b24d9
commit 92c0e29963
2 changed files with 23 additions and 0 deletions

View File

@ -140,6 +140,20 @@ int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codec_params) {
// Store bitrate.
bitrate_ = codec_params->codec_inst.rate;
// TODO(tlegrand): Remove this code when we have proper APIs to set the
// complexity at a higher level.
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM)
// If we are on Android, iOS and/or ARM, use a lower complexity setting as
// default, to save encoder complexity.
const int kOpusComplexity5 = 5;
WebRtcOpus_SetComplexity(encoder_inst_ptr_, kOpusComplexity5);
if (ret < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_,
"Setting complexity failed for Opus");
return ret;
}
#endif
return 0;
}

View File

@ -227,6 +227,15 @@ void OpusTest::Run(TestPackStereo* channel, int channels, int bitrate,
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_mono_encoder_, bitrate));
EXPECT_EQ(0, WebRtcOpus_SetBitRate(opus_stereo_encoder_, bitrate));
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM)
// If we are on Android, iOS and/or ARM, use a lower complexity setting as
// default.
const int kOpusComplexity5 = 5;
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_mono_encoder_, kOpusComplexity5));
EXPECT_EQ(0, WebRtcOpus_SetComplexity(opus_stereo_encoder_,
kOpusComplexity5));
#endif
// Make sure the runtime is less than 60 seconds to pass Android test.
for (size_t audio_length = 0; audio_length < 10000; audio_length += 10) {
bool lost_packet = false;