Bug 1285883: Limit how many frames we will parse to detect HE-AAC. r=kamidphish

MozReview-Commit-ID: JJEGomJZLio

--HG--
extra : rebase_source : d9b1f1770f3e2a345cc3709ee33efddd00e115f6
This commit is contained in:
Jean-Yves Avenard 2016-10-07 13:49:42 +11:00
parent 798404cf65
commit 02a3f88827
2 changed files with 6 additions and 1 deletions

View File

@ -28,6 +28,7 @@ AppleATDecoder::AppleATDecoder(const AudioInfo& aConfig,
, mConverter(nullptr)
, mStream(nullptr)
, mIsFlushing(false)
, mParsedFramesForAACMagicCookie(0)
{
MOZ_COUNT_CTOR(AppleATDecoder);
LOG("Creating Apple AudioToolbox decoder");
@ -534,15 +535,18 @@ nsresult
AppleATDecoder::SetupDecoder(MediaRawData* aSample)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
static const uint32_t MAX_FRAMES = 2;
if (mFormatID == kAudioFormatMPEG4AAC &&
mConfig.mExtendedProfile == 2) {
mConfig.mExtendedProfile == 2 &&
mParsedFramesForAACMagicCookie < MAX_FRAMES) {
// Check for implicit SBR signalling if stream is AAC-LC
// This will provide us with an updated magic cookie for use with
// GetInputAudioDescription.
if (NS_SUCCEEDED(GetImplicitAACMagicCookie(aSample)) &&
!mMagicCookie.Length()) {
// nothing found yet, will try again later
mParsedFramesForAACMagicCookie++;
return NS_ERROR_NOT_INITIALIZED;
}
// An error occurred, fallback to using default stream description

View File

@ -68,6 +68,7 @@ private:
nsresult SetupDecoder(MediaRawData* aSample);
nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample);
nsresult SetupChannelLayout();
uint32_t mParsedFramesForAACMagicCookie;
};
} // namespace mozilla