diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp | 233 | ||||
-rw-r--r-- | media/libeffects/lvm/wrapper/Bundle/EffectBundle.h | 15 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/GenericSource.cpp | 8 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 4 | ||||
-rw-r--r-- | media/libstagefright/ACodec.cpp | 16 | ||||
-rw-r--r-- | media/libstagefright/MediaCodecList.cpp | 13 | ||||
-rw-r--r-- | media/libstagefright/data/media_codecs_google_audio.xml | 3 | ||||
-rw-r--r-- | media/libstagefright/httplive/LiveSession.cpp | 4 |
8 files changed, 187 insertions, 109 deletions
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp index 3ddeb4e..6aeb919 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp @@ -766,6 +766,122 @@ int LvmBundle_process(LVM_INT16 *pIn, return 0; } /* end LvmBundle_process */ + +//---------------------------------------------------------------------------- +// EqualizerUpdateActiveParams() +//---------------------------------------------------------------------------- +// Purpose: Update ActiveParams for Equalizer +// +// Inputs: +// pContext: effect engine context +// +// Outputs: +// +//---------------------------------------------------------------------------- +void EqualizerUpdateActiveParams(EffectContext *pContext) { + LVM_ControlParams_t ActiveParams; /* Current control Parameters */ + LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ + + /* Get the current settings */ + LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerUpdateActiveParams") + //ALOGV("\tEqualizerUpdateActiveParams Succesfully returned from LVM_GetControlParameters\n"); + //ALOGV("\tEqualizerUpdateActiveParams just Got -> %d\n", + // ActiveParams.pEQNB_BandDefinition[band].Gain); + + + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; + ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; + ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i]; + } + + /* Activate the initial settings */ + LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerUpdateActiveParams") + //ALOGV("\tEqualizerUpdateActiveParams just Set -> %d\n", + // ActiveParams.pEQNB_BandDefinition[band].Gain); + +} + +//---------------------------------------------------------------------------- +// LvmEffect_limitLevel() +//---------------------------------------------------------------------------- +// Purpose: limit the overall level to a value less than 0 dB preserving +// the overall EQ band gain and BassBoost relative levels. +// +// Inputs: +// pContext: effect engine context +// +// Outputs: +// +//---------------------------------------------------------------------------- +void LvmEffect_limitLevel(EffectContext *pContext) { + LVM_ControlParams_t ActiveParams; /* Current control Parameters */ + LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ + + /* Get the current settings */ + LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_limitLevel") + //ALOGV("\tLvmEffect_limitLevel Succesfully returned from LVM_GetControlParameters\n"); + //ALOGV("\tLvmEffect_limitLevel just Got -> %d\n", + // ActiveParams.pEQNB_BandDefinition[band].Gain); + + int gainCorrection = 0; + //Count the energy contribution per band for EQ and BassBoost only if they are active. + float energyContribution = 0; + + //EQ contribution + if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) { + for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { + float bandEnergy = (pContext->pBundledContext->bandGaindB[i] * + LimitLevel_bandEnergyContribution[i])/15.0; + if (bandEnergy > 0) + energyContribution += bandEnergy; + } + } + + //BassBoost contribution + if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) { + float bandEnergy = (pContext->pBundledContext->BassStrengthSaved * + LimitLevel_bassBoostEnergyContribution)/1000.0; + if (bandEnergy > 0) + energyContribution += bandEnergy; + } + + //Virtualizer contribution + if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) { + energyContribution += LimitLevel_virtualizerContribution; + } + + //roundoff + int maxLevelRound = (int)(energyContribution + 0.99); + if (maxLevelRound + pContext->pBundledContext->volume > 0) { + gainCorrection = maxLevelRound + pContext->pBundledContext->volume; + } + + ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection; + if (ActiveParams.VC_EffectLevel < -96) { + ActiveParams.VC_EffectLevel = -96; + } + ALOGV("\tVol:%d, GainCorrection: %d, Actual vol: %d", pContext->pBundledContext->volume, + gainCorrection, ActiveParams.VC_EffectLevel); + + /* Activate the initial settings */ + LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_limitLevel") + //ALOGV("\tLvmEffect_limitLevel just Set -> %d\n", + // ActiveParams.pEQNB_BandDefinition[band].Gain); + + //ALOGV("\tLvmEffect_limitLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); + if (pContext->pBundledContext->firstVolume == LVM_TRUE){ + LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); + LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") + ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); + pContext->pBundledContext->firstVolume = LVM_FALSE; + } +} + //---------------------------------------------------------------------------- // LvmEffect_enable() //---------------------------------------------------------------------------- @@ -814,6 +930,7 @@ int LvmEffect_enable(EffectContext *pContext){ //ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n"); //ALOGV("\tLvmEffect_enable end"); + LvmEffect_limitLevel(pContext); return 0; } @@ -864,6 +981,7 @@ int LvmEffect_disable(EffectContext *pContext){ //ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n"); //ALOGV("\tLvmEffect_disable end"); + LvmEffect_limitLevel(pContext); return 0; } @@ -1099,6 +1217,8 @@ void BassSetStrength(EffectContext *pContext, uint32_t strength){ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength") //ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n"); + + LvmEffect_limitLevel(pContext); } /* end BassSetStrength */ //---------------------------------------------------------------------------- @@ -1159,13 +1279,14 @@ void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){ /* Virtualizer parameters */ ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000); - //ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); - //ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); + ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength ); + ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel ); /* Activate the initial settings */ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength") //ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n"); + LvmEffect_limitLevel(pContext); } /* end setStrength */ //---------------------------------------------------------------------------- @@ -1343,104 +1464,6 @@ audio_devices_t VirtualizerGetVirtualizationMode(EffectContext *pContext) { } //---------------------------------------------------------------------------- -// EqualizerLimitBandLevels() -//---------------------------------------------------------------------------- -// Purpose: limit all EQ band gains to a value less than 0 dB while -// preserving the relative band levels. -// -// Inputs: -// pContext: effect engine context -// -// Outputs: -// -//---------------------------------------------------------------------------- -void EqualizerLimitBandLevels(EffectContext *pContext) { - LVM_ControlParams_t ActiveParams; /* Current control Parameters */ - LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */ - - /* Get the current settings */ - LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); - LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerLimitBandLevels") - //ALOGV("\tEqualizerLimitBandLevels Succesfully returned from LVM_GetControlParameters\n"); - //ALOGV("\tEqualizerLimitBandLevels just Got -> %d\n", - // ActiveParams.pEQNB_BandDefinition[band].Gain); - - // Apply a volume correction to avoid clipping in the EQ based on 2 factors: - // - the maximum EQ band gain: the volume correction is such that the total of volume + max - // band gain is <= 0 dB - // - the average gain in all bands weighted by their proximity to max gain band. - int maxGain = 0; - int avgGain = 0; - int avgCount = 0; - for (int i = 0; i < FIVEBAND_NUMBANDS; i++) { - if (pContext->pBundledContext->bandGaindB[i] >= maxGain) { - int tmpMaxGain = pContext->pBundledContext->bandGaindB[i]; - int tmpAvgGain = 0; - int tmpAvgCount = 0; - for (int j = 0; j < FIVEBAND_NUMBANDS; j++) { - int gain = pContext->pBundledContext->bandGaindB[j]; - // skip current band and gains < 0 dB - if (j == i || gain < 0) - continue; - // no need to continue if one band not processed yet has a higher gain than current - // max - if (gain > tmpMaxGain) { - // force skipping "if (tmpAvgGain >= avgGain)" below as tmpAvgGain is not - // meaningful in this case - tmpAvgGain = -1; - break; - } - - int weight = 1; - if (j < (i + 2) && j > (i - 2)) - weight = 4; - tmpAvgGain += weight * gain; - tmpAvgCount += weight; - } - if (tmpAvgGain >= avgGain) { - maxGain = tmpMaxGain; - avgGain = tmpAvgGain; - avgCount = tmpAvgCount; - } - } - ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i]; - ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i]; - ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i]; - } - - int gainCorrection = 0; - if (maxGain + pContext->pBundledContext->volume > 0) { - gainCorrection = maxGain + pContext->pBundledContext->volume; - } - if (avgCount) { - gainCorrection += avgGain/avgCount; - } - - ALOGV("EqualizerLimitBandLevels() gainCorrection %d maxGain %d avgGain %d avgCount %d", - gainCorrection, maxGain, avgGain, avgCount); - - ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection; - if (ActiveParams.VC_EffectLevel < -96) { - ActiveParams.VC_EffectLevel = -96; - } - - /* Activate the initial settings */ - LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams); - LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerLimitBandLevels") - //ALOGV("\tEqualizerLimitBandLevels just Set -> %d\n", - // ActiveParams.pEQNB_BandDefinition[band].Gain); - - //ALOGV("\tEqualizerLimitBandLevels just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel ); - if(pContext->pBundledContext->firstVolume == LVM_TRUE){ - LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams); - LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process") - ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks"); - pContext->pBundledContext->firstVolume = LVM_FALSE; - } -} - - -//---------------------------------------------------------------------------- // EqualizerGetBandLevel() //---------------------------------------------------------------------------- // Purpose: Retrieve the gain currently being used for the band passed in @@ -1482,7 +1505,8 @@ void EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){ pContext->pBundledContext->bandGaindB[band] = gainRounded; pContext->pBundledContext->CurPreset = PRESET_CUSTOM; - EqualizerLimitBandLevels(pContext); + EqualizerUpdateActiveParams(pContext); + LvmEffect_limitLevel(pContext); } //---------------------------------------------------------------------------- @@ -1617,7 +1641,8 @@ void EqualizerSetPreset(EffectContext *pContext, int preset){ EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS]; } - EqualizerLimitBandLevels(pContext); + EqualizerUpdateActiveParams(pContext); + LvmEffect_limitLevel(pContext); //ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n"); return; @@ -1672,7 +1697,7 @@ int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){ pContext->pBundledContext->volume = level / 100; } - EqualizerLimitBandLevels(pContext); + LvmEffect_limitLevel(pContext); return 0; } /* end VolumeSetVolumeLevel */ @@ -1721,7 +1746,7 @@ int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){ pContext->pBundledContext->volume = pContext->pBundledContext->levelSaved; } - EqualizerLimitBandLevels(pContext); + LvmEffect_limitLevel(pContext); return 0; } /* end setMute */ diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h index 420f973..b3071f4 100644 --- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h +++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h @@ -142,6 +142,7 @@ static const uint32_t bandFreqRange[FIVEBAND_NUMBANDS][2] = { {1800001, 7000000}, {7000001, 1}}; +//Note: If these frequencies change, please update LimitLevel values accordingly. static const LVM_UINT16 EQNB_5BandPresetsFrequencies[] = { 60, /* Frequencies in Hz */ 230, @@ -192,6 +193,20 @@ static const PresetConfig gEqualizerPresets[] = { {"Pop"}, {"Rock"}}; +/* The following tables have been computed using the actual levels measured by the output of + * white noise or pink noise (IEC268-1) for the EQ and BassBoost Effects. These are estimates of + * the actual energy that 'could' be present in the given band. + * If the frequency values in EQNB_5BandPresetsFrequencies change, these values might need to be + * updated. + */ + +static const float LimitLevel_bandEnergyContribution[FIVEBAND_NUMBANDS] = { + 5.0, 6.5, 6.45, 4.8, 1.7 }; + +static const float LimitLevel_bassBoostEnergyContribution = 6.7; + +static const float LimitLevel_virtualizerContribution = 1.9; + #if __cplusplus } // extern "C" #endif diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 1af2713..dd79b50 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -173,6 +173,14 @@ status_t NuPlayer::GenericSource::initFromDataSource() { if (mFileMeta->findCString(kKeyMIMEType, &fileMime) && !strncasecmp(fileMime, "video/wvm", 9)) { mIsWidevine = true; + if (!mUri.empty()) { + // streaming, but the app forgot to specify widevine:// url + mWVMExtractor = static_cast<WVMExtractor *>(extractor.get()); + mWVMExtractor->setAdaptiveStreamingMode(true); + if (mUIDValid) { + mWVMExtractor->setUID(mUID); + } + } } } } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 080cd52..a28591e 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -1667,6 +1667,10 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) { sp<NuPlayerDriver> driver = mDriver.promote(); if (driver != NULL) { + if ((flags & NuPlayer::Source::FLAG_CAN_SEEK) == 0) { + driver->notifyListener( + MEDIA_INFO, MEDIA_INFO_NOT_SEEKABLE, 0); + } driver->notifyFlagsChanged(flags); } diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 653d16c..dfb0101 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -1302,7 +1302,21 @@ status_t ACodec::configureCodec( return err; } - inputFormat->setInt32("adaptive-playback", true); + int32_t maxWidth = 0, maxHeight = 0; + if (msg->findInt32("max-width", &maxWidth) && + msg->findInt32("max-height", &maxHeight)) { + + err = mOMX->prepareForAdaptivePlayback( + mNode, kPortIndexOutput, OMX_TRUE, maxWidth, maxHeight); + if (err != OK) { + ALOGW("[%s] prepareForAdaptivePlayback failed w/ err %d", + mComponentName.c_str(), err); + } else { + inputFormat->setInt32("max-width", maxWidth); + inputFormat->setInt32("max-height", maxHeight); + inputFormat->setInt32("adaptive-playback", true); + } + } } else { ALOGV("Configuring CPU controlled video playback."); mTunneled = false; diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp index 5b8be46..cf6e937 100644 --- a/media/libstagefright/MediaCodecList.cpp +++ b/media/libstagefright/MediaCodecList.cpp @@ -62,6 +62,14 @@ static Mutex sRemoteInitMutex; sp<IMediaCodecList> MediaCodecList::sRemoteList; +sp<MediaCodecList::BinderDeathObserver> MediaCodecList::sBinderDeathObserver; + +void MediaCodecList::BinderDeathObserver::binderDied(const wp<IBinder> &who __unused) { + Mutex::Autolock _l(sRemoteInitMutex); + sRemoteList.clear(); + sBinderDeathObserver.clear(); +} + // static sp<IMediaCodecList> MediaCodecList::getInstance() { Mutex::Autolock _l(sRemoteInitMutex); @@ -72,8 +80,11 @@ sp<IMediaCodecList> MediaCodecList::getInstance() { interface_cast<IMediaPlayerService>(binder); if (service.get() != NULL) { sRemoteList = service->getCodecList(); + if (sRemoteList != NULL) { + sBinderDeathObserver = new BinderDeathObserver(); + binder->linkToDeath(sBinderDeathObserver.get()); + } } - if (sRemoteList == NULL) { // if failed to get remote list, create local list sRemoteList = getLocalInstance(); diff --git a/media/libstagefright/data/media_codecs_google_audio.xml b/media/libstagefright/data/media_codecs_google_audio.xml index 85f6615..a06684b 100644 --- a/media/libstagefright/data/media_codecs_google_audio.xml +++ b/media/libstagefright/data/media_codecs_google_audio.xml @@ -65,7 +65,8 @@ <Encoders> <MediaCodec name="OMX.google.aac.encoder" type="audio/mp4a-latm"> <Limit name="channel-count" max="6" /> - <Limit name="sample-rate" ranges="11025,12000,16000,22050,24000,32000,44100,48000" /> + <Limit name="sample-rate" ranges="8000,11025,12000,16000,22050,24000,32000,44100,48000" /> + <!-- also may support 64000, 88200 and 96000 Hz --> <Limit name="bitrate" range="8000-960000" /> </MediaCodec> <MediaCodec name="OMX.google.amrnb.encoder" type="audio/3gpp"> diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 6522ad7..04005bd 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -1110,11 +1110,11 @@ status_t LiveSession::onSeek(const sp<AMessage> &msg) { } status_t LiveSession::getDuration(int64_t *durationUs) const { - int64_t maxDurationUs = 0ll; + int64_t maxDurationUs = -1ll; for (size_t i = 0; i < mFetcherInfos.size(); ++i) { int64_t fetcherDurationUs = mFetcherInfos.valueAt(i).mDurationUs; - if (fetcherDurationUs >= 0ll && fetcherDurationUs > maxDurationUs) { + if (fetcherDurationUs > maxDurationUs) { maxDurationUs = fetcherDurationUs; } } |