diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2014-08-08 21:05:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-08 16:09:03 +0000 |
commit | ddabe554e95940891c5df9a7f092798351b5f75e (patch) | |
tree | 5e58b35801c040a48b95c071a454a1b8bb35d7ee | |
parent | 15ff76c99482eab01934cf0f55c815a85cf06f35 (diff) | |
parent | 8045853d03649f43ea2f7107e7d2dbb9b2d20855 (diff) | |
download | frameworks_av-ddabe554e95940891c5df9a7f092798351b5f75e.zip frameworks_av-ddabe554e95940891c5df9a7f092798351b5f75e.tar.gz frameworks_av-ddabe554e95940891c5df9a7f092798351b5f75e.tar.bz2 |
Merge "AAC decoder: add support for controlling presentation parameters" into lmp-dev
-rw-r--r-- | include/media/stagefright/ACodec.h | 11 | ||||
-rw-r--r-- | media/libstagefright/ACodec.cpp | 50 | ||||
-rw-r--r-- | media/libstagefright/codecs/aacdec/SoftAAC2.cpp | 66 |
3 files changed, 121 insertions, 6 deletions
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 3dd34ce..3a6bb9e 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -252,10 +252,19 @@ private: int32_t width, int32_t height, OMX_VIDEO_CODINGTYPE compressionFormat); + typedef struct drcParams { + int32_t drcCut; + int32_t drcBoost; + int32_t heavyCompression; + int32_t targetRefLevel; + int32_t encodedTargetLevel; + } drcParams_t; + status_t setupAACCodec( bool encoder, int32_t numChannels, int32_t sampleRate, int32_t bitRate, - int32_t aacProfile, bool isADTS, int32_t sbrMode); + int32_t aacProfile, bool isADTS, int32_t sbrMode, + int32_t maxOutputChannelCount, const drcParams_t& drc); status_t setupAC3Codec(bool encoder, int32_t numChannels, int32_t sampleRate); diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 524e201..503ce81 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1332,6 +1332,8 @@ status_t ACodec::configureCodec( } else { int32_t isADTS, aacProfile; int32_t sbrMode; + int32_t maxOutputChannelCount; + drcParams_t drc; if (!msg->findInt32("is-adts", &isADTS)) { isADTS = 0; } @@ -1342,9 +1344,33 @@ status_t ACodec::configureCodec( sbrMode = -1; } + if (!msg->findInt32("aac-max-output-channel_count", &maxOutputChannelCount)) { + maxOutputChannelCount = -1; + } + if (!msg->findInt32("aac-encoded-target-level", &drc.encodedTargetLevel)) { + // value is unknown + drc.encodedTargetLevel = -1; + } + if (!msg->findInt32("aac-drc-cut-level", &drc.drcCut)) { + // value is unknown + drc.drcCut = -1; + } + if (!msg->findInt32("aac-drc-boost-level", &drc.drcBoost)) { + // value is unknown + drc.drcBoost = -1; + } + if (!msg->findInt32("aac-drc-heavy-compression", &drc.heavyCompression)) { + // value is unknown + drc.heavyCompression = -1; + } + if (!msg->findInt32("aac-target-ref-level", &drc.targetRefLevel)) { + // value is unknown + drc.targetRefLevel = -1; + } + err = setupAACCodec( encoder, numChannels, sampleRate, bitRate, aacProfile, - isADTS != 0, sbrMode); + isADTS != 0, sbrMode, maxOutputChannelCount, drc); } } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) { err = setupAMRCodec(encoder, false /* isWAMR */, bitRate); @@ -1506,7 +1532,8 @@ status_t ACodec::selectAudioPortFormat( status_t ACodec::setupAACCodec( bool encoder, int32_t numChannels, int32_t sampleRate, - int32_t bitRate, int32_t aacProfile, bool isADTS, int32_t sbrMode) { + int32_t bitRate, int32_t aacProfile, bool isADTS, int32_t sbrMode, + int32_t maxOutputChannelCount, const drcParams_t& drc) { if (encoder && isADTS) { return -EINVAL; } @@ -1629,8 +1656,23 @@ status_t ACodec::setupAACCodec( ? OMX_AUDIO_AACStreamFormatMP4ADTS : OMX_AUDIO_AACStreamFormatMP4FF; - return mOMX->setParameter( - mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); + OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE presentation; + presentation.nMaxOutputChannels = maxOutputChannelCount; + presentation.nDrcCut = drc.drcCut; + presentation.nDrcBoost = drc.drcBoost; + presentation.nHeavyCompression = drc.heavyCompression; + presentation.nTargetReferenceLevel = drc.targetRefLevel; + presentation.nEncodedTargetLevel = drc.encodedTargetLevel; + + status_t res = mOMX->setParameter(mNode, OMX_IndexParamAudioAac, &profile, sizeof(profile)); + if (res == OK) { + // optional parameters, will not cause configuration failure + mOMX->setParameter(mNode, (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacPresentation, + &presentation, sizeof(presentation)); + } else { + ALOGW("did not set AudioAndroidAacPresentation due to error %d when setting AudioAac", res); + } + return res; } status_t ACodec::setupAC3Codec( diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp index ab30865..09c6e69 100644 --- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp +++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp @@ -19,6 +19,8 @@ #include <utils/Log.h> #include "SoftAAC2.h" +#include <OMX_AudioExt.h> +#include <OMX_IndexExt.h> #include <cutils/properties.h> #include <media/stagefright/foundation/ADebug.h> @@ -119,6 +121,7 @@ void SoftAAC2::initPorts() { } status_t SoftAAC2::initDecoder() { + ALOGV("initDecoder()"); status_t status = UNKNOWN_ERROR; mAACDecoder = aacDecoder_Open(TT_MP4_ADIF, /* num layers */ 1); if (mAACDecoder != NULL) { @@ -275,7 +278,7 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter( OMX_ERRORTYPE SoftAAC2::internalSetParameter( OMX_INDEXTYPE index, const OMX_PTR params) { - switch (index) { + switch ((int)index) { case OMX_IndexParamStandardComponentRole: { const OMX_PARAM_COMPONENTROLETYPE *roleParams = @@ -311,6 +314,67 @@ OMX_ERRORTYPE SoftAAC2::internalSetParameter( return OMX_ErrorNone; } + case OMX_IndexParamAudioAndroidAacPresentation: + { + const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *aacPresParams = + (const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *)params; + // for the following parameters of the OMX_AUDIO_PARAM_AACPROFILETYPE structure, + // a value of -1 implies the parameter is not set by the application: + // nMaxOutputChannels uses default platform properties, see configureDownmix() + // nDrcCut uses default platform properties, see initDecoder() + // nDrcBoost idem + // nHeavyCompression idem + // nTargetReferenceLevel idem + // nEncodedTargetLevel idem + if (aacPresParams->nMaxOutputChannels >= 0) { + int max; + if (aacPresParams->nMaxOutputChannels >= 8) { max = 8; } + else if (aacPresParams->nMaxOutputChannels >= 6) { max = 6; } + else if (aacPresParams->nMaxOutputChannels >= 2) { max = 2; } + else { + // -1 or 0: disable downmix, 1: mono + max = aacPresParams->nMaxOutputChannels; + } + ALOGV("set nMaxOutputChannels=%d", max); + aacDecoder_SetParam(mAACDecoder, AAC_PCM_MAX_OUTPUT_CHANNELS, max); + } + bool updateDrcWrapper = false; + if (aacPresParams->nDrcBoost >= 0) { + ALOGV("set nDrcBoost=%d", aacPresParams->nDrcBoost); + mDrcWrap.setParam(DRC_PRES_MODE_WRAP_DESIRED_BOOST_FACTOR, + aacPresParams->nDrcBoost); + updateDrcWrapper = true; + } + if (aacPresParams->nDrcCut >= 0) { + ALOGV("set nDrcCut=%d", aacPresParams->nDrcCut); + mDrcWrap.setParam(DRC_PRES_MODE_WRAP_DESIRED_ATT_FACTOR, aacPresParams->nDrcCut); + updateDrcWrapper = true; + } + if (aacPresParams->nHeavyCompression >= 0) { + ALOGV("set nHeavyCompression=%d", aacPresParams->nHeavyCompression); + mDrcWrap.setParam(DRC_PRES_MODE_WRAP_DESIRED_HEAVY, + aacPresParams->nHeavyCompression); + updateDrcWrapper = true; + } + if (aacPresParams->nTargetReferenceLevel >= 0) { + ALOGV("set nTargetReferenceLevel=%d", aacPresParams->nTargetReferenceLevel); + mDrcWrap.setParam(DRC_PRES_MODE_WRAP_DESIRED_TARGET, + aacPresParams->nTargetReferenceLevel); + updateDrcWrapper = true; + } + if (aacPresParams->nEncodedTargetLevel >= 0) { + ALOGV("set nEncodedTargetLevel=%d", aacPresParams->nEncodedTargetLevel); + mDrcWrap.setParam(DRC_PRES_MODE_WRAP_ENCODER_TARGET, + aacPresParams->nEncodedTargetLevel); + updateDrcWrapper = true; + } + if (updateDrcWrapper) { + mDrcWrap.update(); + } + + return OMX_ErrorNone; + } + case OMX_IndexParamAudioPcm: { const OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams = |