Loading media/libstagefright/ACodec.cpp +22 −3 Original line number Diff line number Diff line Loading @@ -2144,6 +2144,10 @@ status_t ACodec::configureCodec( // value is unknown drc.targetRefLevel = -1; } if (!msg->findInt32("aac-drc-effect-type", &drc.effectType)) { // value is unknown drc.effectType = -2; // valid values are -1 and over } err = setupAACCodec( encoder, numChannels, sampleRate, bitrate, aacProfile, Loading Loading @@ -2778,7 +2782,7 @@ status_t ACodec::setupAACCodec( ? OMX_AUDIO_AACStreamFormatMP4ADTS : OMX_AUDIO_AACStreamFormatMP4FF; OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE presentation; OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE presentation; InitOMXParams(&presentation); presentation.nMaxOutputChannels = maxOutputChannelCount; presentation.nDrcCut = drc.drcCut; Loading @@ -2787,14 +2791,29 @@ status_t ACodec::setupAACCodec( presentation.nTargetReferenceLevel = drc.targetRefLevel; presentation.nEncodedTargetLevel = drc.encodedTargetLevel; presentation.nPCMLimiterEnable = pcmLimiterEnable; presentation.nDrcEffectType = drc.effectType; status_t res = mOMXNode->setParameter( OMX_IndexParamAudioAac, &profile, sizeof(profile)); if (res == OK) { // optional parameters, will not cause configuration failure mOMXNode->setParameter( if (mOMXNode->setParameter( (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacDrcPresentation, &presentation, sizeof(presentation)) == ERROR_UNSUPPORTED) { // prior to 9.0 we used a different config structure and index OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE presentation8; InitOMXParams(&presentation8); presentation8.nMaxOutputChannels = presentation.nMaxOutputChannels; presentation8.nDrcCut = presentation.nDrcCut; presentation8.nDrcBoost = presentation.nDrcBoost; presentation8.nHeavyCompression = presentation.nHeavyCompression; presentation8.nTargetReferenceLevel = presentation.nTargetReferenceLevel; presentation8.nEncodedTargetLevel = presentation.nEncodedTargetLevel; presentation8.nPCMLimiterEnable = presentation.nPCMLimiterEnable; (void)mOMXNode->setParameter( (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacPresentation, &presentation, sizeof(presentation)); &presentation8, sizeof(presentation8)); } } else { ALOGW("did not set AudioAndroidAacPresentation due to error %d when setting AudioAac", res); } Loading media/libstagefright/Utils.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ static void parseAacProfileFromCsd(const sp<ABuffer> &csd, sp<AMessage> &format) { 23, OMX_AUDIO_AACObjectLD }, { 29, OMX_AUDIO_AACObjectHE_PS }, { 39, OMX_AUDIO_AACObjectELD }, { 42, OMX_AUDIO_AACObjectXHE }, }; OMX_AUDIO_AACPROFILETYPE profile; Loading Loading @@ -1610,6 +1611,7 @@ static const struct aac_format_conv_t profileLookup[] = { { OMX_AUDIO_AACObjectLD, AUDIO_FORMAT_AAC_LD}, { OMX_AUDIO_AACObjectHE_PS, AUDIO_FORMAT_AAC_HE_V2}, { OMX_AUDIO_AACObjectELD, AUDIO_FORMAT_AAC_ELD}, { OMX_AUDIO_AACObjectXHE, AUDIO_FORMAT_AAC_XHE}, { OMX_AUDIO_AACObjectNull, AUDIO_FORMAT_AAC}, }; Loading media/libstagefright/codecs/aacdec/DrcPresModeWrap.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ //#define DRC_PRES_MODE_WRAP_DEBUG #define GPM_ENCODER_TARGET_LEVEL 64 #define MAX_TARGET_LEVEL 64 #define MAX_TARGET_LEVEL 40 CDrcPresModeWrapper::CDrcPresModeWrapper() { Loading Loading @@ -164,7 +164,7 @@ CDrcPresModeWrapper::update() if (mDataUpdate) { // sanity check if (mDesTarget < MAX_TARGET_LEVEL){ mDesTarget = MAX_TARGET_LEVEL; // limit target level to -16 dB or below mDesTarget = MAX_TARGET_LEVEL; // limit target level to -10 dB or below newTarget = MAX_TARGET_LEVEL; } Loading media/libstagefright/codecs/aacdec/SoftAAC2.cpp +20 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #define DRC_DEFAULT_MOBILE_DRC_CUT 127 /* maximum compression of dynamic range for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_BOOST 127 /* maximum compression of dynamic range for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_HEAVY 1 /* switch for heavy compression for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_EFFECT 3 /* MPEG-D DRC effect type; 3 => Limited playback range */ #define DRC_DEFAULT_MOBILE_ENC_LEVEL (-1) /* encoder target level; -1 => the value is unknown, otherwise dB step value (e.g. 64 for -16 dB) */ #define MAX_CHANNEL_COUNT 8 /* maximum number of audio channels that can be decoded */ // names of properties that can be used to override the default DRC settings Loading @@ -44,6 +45,7 @@ #define PROP_DRC_OVERRIDE_BOOST "aac_drc_boost" #define PROP_DRC_OVERRIDE_HEAVY "aac_drc_heavy" #define PROP_DRC_OVERRIDE_ENC_LEVEL "aac_drc_enc_target_level" #define PROP_DRC_OVERRIDE_EFFECT "aac_drc_effect_type" namespace android { Loading Loading @@ -207,6 +209,17 @@ status_t SoftAAC2::initDecoder() { } else { mDrcWrap.setParam(DRC_PRES_MODE_WRAP_ENCODER_TARGET, DRC_DEFAULT_MOBILE_ENC_LEVEL); } // AAC_UNIDRC_SET_EFFECT int32_t effectType = DRC_DEFAULT_MOBILE_DRC_EFFECT; // FIXME can't read default property for DRC effect type //int32_t effectType = // property_get_int32(PROP_DRC_OVERRIDE_EFFECT, DRC_DEFAULT_MOBILE_DRC_EFFECT); if (effectType < -1 || effectType > 8) { effectType = DRC_DEFAULT_MOBILE_DRC_EFFECT; } ALOGV("AAC decoder using MPEG-D DRC effect type %d (default=%d)", effectType, DRC_DEFAULT_MOBILE_DRC_EFFECT); aacDecoder_SetParam(mAACDecoder, AAC_UNIDRC_SET_EFFECT, effectType); // By default, the decoder creates a 5.1 channel downmix signal. // For seven and eight channel input streams, enable 6.1 and 7.1 channel output Loading Loading @@ -414,10 +427,10 @@ OMX_ERRORTYPE SoftAAC2::internalSetParameter( return OMX_ErrorNone; } case OMX_IndexParamAudioAndroidAacPresentation: case OMX_IndexParamAudioAndroidAacDrcPresentation: { const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *aacPresParams = (const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *)params; const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *aacPresParams = (const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *)params; if (!isValidOMXParam(aacPresParams)) { return OMX_ErrorBadParameter; Loading @@ -443,6 +456,10 @@ OMX_ERRORTYPE SoftAAC2::internalSetParameter( ALOGV("set nMaxOutputChannels=%d", max); aacDecoder_SetParam(mAACDecoder, AAC_PCM_MAX_OUTPUT_CHANNELS, max); } if (aacPresParams->nDrcEffectType >= -1) { ALOGV("set nDrcEffectType=%d", aacPresParams->nDrcEffectType); aacDecoder_SetParam(mAACDecoder, AAC_UNIDRC_SET_EFFECT, aacPresParams->nDrcEffectType); } bool updateDrcWrapper = false; if (aacPresParams->nDrcBoost >= 0) { ALOGV("set nDrcBoost=%d", aacPresParams->nDrcBoost); Loading media/libstagefright/include/media/stagefright/ACodec.h +1 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,7 @@ private: int32_t heavyCompression; int32_t targetRefLevel; int32_t encodedTargetLevel; int32_t effectType; } drcParams_t; status_t setupAACCodec( Loading Loading
media/libstagefright/ACodec.cpp +22 −3 Original line number Diff line number Diff line Loading @@ -2144,6 +2144,10 @@ status_t ACodec::configureCodec( // value is unknown drc.targetRefLevel = -1; } if (!msg->findInt32("aac-drc-effect-type", &drc.effectType)) { // value is unknown drc.effectType = -2; // valid values are -1 and over } err = setupAACCodec( encoder, numChannels, sampleRate, bitrate, aacProfile, Loading Loading @@ -2778,7 +2782,7 @@ status_t ACodec::setupAACCodec( ? OMX_AUDIO_AACStreamFormatMP4ADTS : OMX_AUDIO_AACStreamFormatMP4FF; OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE presentation; OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE presentation; InitOMXParams(&presentation); presentation.nMaxOutputChannels = maxOutputChannelCount; presentation.nDrcCut = drc.drcCut; Loading @@ -2787,14 +2791,29 @@ status_t ACodec::setupAACCodec( presentation.nTargetReferenceLevel = drc.targetRefLevel; presentation.nEncodedTargetLevel = drc.encodedTargetLevel; presentation.nPCMLimiterEnable = pcmLimiterEnable; presentation.nDrcEffectType = drc.effectType; status_t res = mOMXNode->setParameter( OMX_IndexParamAudioAac, &profile, sizeof(profile)); if (res == OK) { // optional parameters, will not cause configuration failure mOMXNode->setParameter( if (mOMXNode->setParameter( (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacDrcPresentation, &presentation, sizeof(presentation)) == ERROR_UNSUPPORTED) { // prior to 9.0 we used a different config structure and index OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE presentation8; InitOMXParams(&presentation8); presentation8.nMaxOutputChannels = presentation.nMaxOutputChannels; presentation8.nDrcCut = presentation.nDrcCut; presentation8.nDrcBoost = presentation.nDrcBoost; presentation8.nHeavyCompression = presentation.nHeavyCompression; presentation8.nTargetReferenceLevel = presentation.nTargetReferenceLevel; presentation8.nEncodedTargetLevel = presentation.nEncodedTargetLevel; presentation8.nPCMLimiterEnable = presentation.nPCMLimiterEnable; (void)mOMXNode->setParameter( (OMX_INDEXTYPE)OMX_IndexParamAudioAndroidAacPresentation, &presentation, sizeof(presentation)); &presentation8, sizeof(presentation8)); } } else { ALOGW("did not set AudioAndroidAacPresentation due to error %d when setting AudioAac", res); } Loading
media/libstagefright/Utils.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,7 @@ static void parseAacProfileFromCsd(const sp<ABuffer> &csd, sp<AMessage> &format) { 23, OMX_AUDIO_AACObjectLD }, { 29, OMX_AUDIO_AACObjectHE_PS }, { 39, OMX_AUDIO_AACObjectELD }, { 42, OMX_AUDIO_AACObjectXHE }, }; OMX_AUDIO_AACPROFILETYPE profile; Loading Loading @@ -1610,6 +1611,7 @@ static const struct aac_format_conv_t profileLookup[] = { { OMX_AUDIO_AACObjectLD, AUDIO_FORMAT_AAC_LD}, { OMX_AUDIO_AACObjectHE_PS, AUDIO_FORMAT_AAC_HE_V2}, { OMX_AUDIO_AACObjectELD, AUDIO_FORMAT_AAC_ELD}, { OMX_AUDIO_AACObjectXHE, AUDIO_FORMAT_AAC_XHE}, { OMX_AUDIO_AACObjectNull, AUDIO_FORMAT_AAC}, }; Loading
media/libstagefright/codecs/aacdec/DrcPresModeWrap.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ //#define DRC_PRES_MODE_WRAP_DEBUG #define GPM_ENCODER_TARGET_LEVEL 64 #define MAX_TARGET_LEVEL 64 #define MAX_TARGET_LEVEL 40 CDrcPresModeWrapper::CDrcPresModeWrapper() { Loading Loading @@ -164,7 +164,7 @@ CDrcPresModeWrapper::update() if (mDataUpdate) { // sanity check if (mDesTarget < MAX_TARGET_LEVEL){ mDesTarget = MAX_TARGET_LEVEL; // limit target level to -16 dB or below mDesTarget = MAX_TARGET_LEVEL; // limit target level to -10 dB or below newTarget = MAX_TARGET_LEVEL; } Loading
media/libstagefright/codecs/aacdec/SoftAAC2.cpp +20 −3 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #define DRC_DEFAULT_MOBILE_DRC_CUT 127 /* maximum compression of dynamic range for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_BOOST 127 /* maximum compression of dynamic range for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_HEAVY 1 /* switch for heavy compression for mobile conf */ #define DRC_DEFAULT_MOBILE_DRC_EFFECT 3 /* MPEG-D DRC effect type; 3 => Limited playback range */ #define DRC_DEFAULT_MOBILE_ENC_LEVEL (-1) /* encoder target level; -1 => the value is unknown, otherwise dB step value (e.g. 64 for -16 dB) */ #define MAX_CHANNEL_COUNT 8 /* maximum number of audio channels that can be decoded */ // names of properties that can be used to override the default DRC settings Loading @@ -44,6 +45,7 @@ #define PROP_DRC_OVERRIDE_BOOST "aac_drc_boost" #define PROP_DRC_OVERRIDE_HEAVY "aac_drc_heavy" #define PROP_DRC_OVERRIDE_ENC_LEVEL "aac_drc_enc_target_level" #define PROP_DRC_OVERRIDE_EFFECT "aac_drc_effect_type" namespace android { Loading Loading @@ -207,6 +209,17 @@ status_t SoftAAC2::initDecoder() { } else { mDrcWrap.setParam(DRC_PRES_MODE_WRAP_ENCODER_TARGET, DRC_DEFAULT_MOBILE_ENC_LEVEL); } // AAC_UNIDRC_SET_EFFECT int32_t effectType = DRC_DEFAULT_MOBILE_DRC_EFFECT; // FIXME can't read default property for DRC effect type //int32_t effectType = // property_get_int32(PROP_DRC_OVERRIDE_EFFECT, DRC_DEFAULT_MOBILE_DRC_EFFECT); if (effectType < -1 || effectType > 8) { effectType = DRC_DEFAULT_MOBILE_DRC_EFFECT; } ALOGV("AAC decoder using MPEG-D DRC effect type %d (default=%d)", effectType, DRC_DEFAULT_MOBILE_DRC_EFFECT); aacDecoder_SetParam(mAACDecoder, AAC_UNIDRC_SET_EFFECT, effectType); // By default, the decoder creates a 5.1 channel downmix signal. // For seven and eight channel input streams, enable 6.1 and 7.1 channel output Loading Loading @@ -414,10 +427,10 @@ OMX_ERRORTYPE SoftAAC2::internalSetParameter( return OMX_ErrorNone; } case OMX_IndexParamAudioAndroidAacPresentation: case OMX_IndexParamAudioAndroidAacDrcPresentation: { const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *aacPresParams = (const OMX_AUDIO_PARAM_ANDROID_AACPRESENTATIONTYPE *)params; const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *aacPresParams = (const OMX_AUDIO_PARAM_ANDROID_AACDRCPRESENTATIONTYPE *)params; if (!isValidOMXParam(aacPresParams)) { return OMX_ErrorBadParameter; Loading @@ -443,6 +456,10 @@ OMX_ERRORTYPE SoftAAC2::internalSetParameter( ALOGV("set nMaxOutputChannels=%d", max); aacDecoder_SetParam(mAACDecoder, AAC_PCM_MAX_OUTPUT_CHANNELS, max); } if (aacPresParams->nDrcEffectType >= -1) { ALOGV("set nDrcEffectType=%d", aacPresParams->nDrcEffectType); aacDecoder_SetParam(mAACDecoder, AAC_UNIDRC_SET_EFFECT, aacPresParams->nDrcEffectType); } bool updateDrcWrapper = false; if (aacPresParams->nDrcBoost >= 0) { ALOGV("set nDrcBoost=%d", aacPresParams->nDrcBoost); Loading
media/libstagefright/include/media/stagefright/ACodec.h +1 −0 Original line number Diff line number Diff line Loading @@ -446,6 +446,7 @@ private: int32_t heavyCompression; int32_t targetRefLevel; int32_t encodedTargetLevel; int32_t effectType; } drcParams_t; status_t setupAACCodec( Loading