diff options
author | James Dong <jdong@google.com> | 2011-08-11 17:38:35 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-08-18 11:43:34 -0700 |
commit | 5bc53035bde27cd886dd7b31e6a07107422a723d (patch) | |
tree | 02dac8000c23507f3f5e9d9df8e0c1c8dbf5a147 /media | |
parent | d1106fc9bff66ac4f93f9d6291f0d0136bb544e7 (diff) | |
download | frameworks_base-5bc53035bde27cd886dd7b31e6a07107422a723d.zip frameworks_base-5bc53035bde27cd886dd7b31e6a07107422a723d.tar.gz frameworks_base-5bc53035bde27cd886dd7b31e6a07107422a723d.tar.bz2 |
Some decoders require more gentle treatment
We sacrifice A/V sync to some extent to enable the decoder to recover from
temporary bottlenecks.
Change-Id: I16195091ad752bfad4c70869cdd7e9f28ca3a118
related-to-bug: 5180142
Diffstat (limited to 'media')
-rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 56 | ||||
-rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 3 |
2 files changed, 45 insertions, 14 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 99242ab..161a6ce 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -59,6 +59,7 @@ #include <cutils/properties.h> #define USE_SURFACE_ALLOC 1 +#define FRAME_DROP_FREQ 0 namespace android { @@ -1518,14 +1519,29 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) { } if (mVideoSource != NULL) { - Mutex::Autolock autoLock(mStatsLock); - TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); - - const char *component; + const char *componentName; CHECK(mVideoSource->getFormat() - ->findCString(kKeyDecoderComponent, &component)); + ->findCString(kKeyDecoderComponent, &componentName)); - stat->mDecoderName = component; + { + Mutex::Autolock autoLock(mStatsLock); + TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); + + stat->mDecoderName = componentName; + } + + static const char *kPrefix = "OMX.Nvidia."; + static const char *kSuffix = ".decode"; + static const size_t kSuffixLength = strlen(kSuffix); + + size_t componentNameLength = strlen(componentName); + + if (!strncmp(componentName, kPrefix, strlen(kPrefix)) + && componentNameLength >= kSuffixLength + && !strcmp(&componentName[ + componentNameLength - kSuffixLength], kSuffix)) { + modifyFlags(SLOW_DECODER_HACK, SET); + } } return mVideoSource != NULL ? OK : UNKNOWN_ERROR; @@ -1705,6 +1721,7 @@ void AwesomePlayer::onVideoEvent() { if (mFlags & FIRST_FRAME) { modifyFlags(FIRST_FRAME, CLEAR); + mSinceLastDropped = 0; mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs; } @@ -1751,18 +1768,28 @@ void AwesomePlayer::onVideoEvent() { if (latenessUs > 40000) { // We're more than 40ms late. - LOGV("we're late by %lld us (%.2f secs), dropping frame", + LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6); - mVideoBuffer->release(); - mVideoBuffer = NULL; + if (!(mFlags & SLOW_DECODER_HACK) + || mSinceLastDropped > FRAME_DROP_FREQ) { - Mutex::Autolock autoLock(mStatsLock); - ++mStats.mNumVideoFramesDropped; - } + LOGV("we're late by %lld us (%.2f secs) dropping " + "one after %d frames", + latenessUs, latenessUs / 1E6, mSinceLastDropped); - postVideoEvent_l(); - return; + mSinceLastDropped = 0; + mVideoBuffer->release(); + mVideoBuffer = NULL; + + { + Mutex::Autolock autoLock(mStatsLock); + ++mStats.mNumVideoFramesDropped; + } + + postVideoEvent_l(); + return; + } } if (latenessUs < -10000) { @@ -1781,6 +1808,7 @@ void AwesomePlayer::onVideoEvent() { } if (mVideoRenderer != NULL) { + mSinceLastDropped++; mVideoRenderer->render(mVideoBuffer); } diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index 95f2ae8..14476d3 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -141,6 +141,8 @@ private: TEXT_RUNNING = 0x10000, TEXTPLAYER_STARTED = 0x20000, + + SLOW_DECODER_HACK = 0x40000, }; mutable Mutex mLock; @@ -181,6 +183,7 @@ private: uint32_t mFlags; uint32_t mExtractorFlags; + uint32_t mSinceLastDropped; int64_t mTimeSourceDeltaUs; int64_t mVideoTimeUs; |