From 8bd4d16aa5636e98522c07ae31236420788aa749 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Fri, 10 Jan 2014 17:36:57 -0800 Subject: Cap pts gap between adjacent frames to specified value - In the scenario of cast mirroring, encoding could be suspended for prolonged periods. Limiting the pts gap to workaround the problem where encoder's rate control logic produces huge frames after a long period of suspension. - Repeat last frame a couple more times to get better quality on static scenes. - Fix the timestamp on repeat frames (it was not set) Bug: 11971963 Change-Id: I1d68ab3d269874bf3921aa429a985c5f63e428c7 (cherry picked from commit 94ee4b708acfa941581160b267afb79192b1d816) --- media/libstagefright/ACodec.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/ACodec.cpp') diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 3810ac1..9276818 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -371,7 +371,8 @@ ACodec::ACodec() mDequeueCounter(0), mStoreMetaDataInOutputBuffers(false), mMetaDataBuffersToSubmit(0), - mRepeatFrameDelayUs(-1ll) { + mRepeatFrameDelayUs(-1ll), + mMaxPtsGapUs(-1l) { mUninitializedState = new UninitializedState(this); mLoadedState = new LoadedState(this); mLoadedToIdleState = new LoadedToIdleState(this); @@ -1109,6 +1110,10 @@ status_t ACodec::configureCodec( &mRepeatFrameDelayUs)) { mRepeatFrameDelayUs = -1ll; } + + if (!msg->findInt64("max-pts-gap-to-encoder", &mMaxPtsGapUs)) { + mMaxPtsGapUs = -1l; + } } // Always try to enable dynamic output buffers on native surface @@ -3855,6 +3860,21 @@ void ACodec::LoadedState::onCreateInputSurface( } } + if (err == OK && mCodec->mMaxPtsGapUs > 0l) { + err = mCodec->mOMX->setInternalOption( + mCodec->mNode, + kPortIndexInput, + IOMX::INTERNAL_OPTION_MAX_TIMESTAMP_GAP, + &mCodec->mMaxPtsGapUs, + sizeof(mCodec->mMaxPtsGapUs)); + + if (err != OK) { + ALOGE("[%s] Unable to configure max timestamp gap (err %d)", + mCodec->mComponentName.c_str(), + err); + } + } + if (err == OK) { notify->setObject("input-surface", new BufferProducerWrapper(bufferProducer)); -- cgit v1.1