Loading media/libstagefright/AwesomePlayer.cpp +42 −14 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ #include <cutils/properties.h> #define USE_SURFACE_ALLOC 1 #define FRAME_DROP_FREQ 0 namespace android { Loading Loading @@ -1523,14 +1524,29 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) { } if (mVideoSource != NULL) { const char *componentName; CHECK(mVideoSource->getFormat() ->findCString(kKeyDecoderComponent, &componentName)); { Mutex::Autolock autoLock(mStatsLock); TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); const char *component; CHECK(mVideoSource->getFormat() ->findCString(kKeyDecoderComponent, &component)); stat->mDecoderName = componentName; } stat->mDecoderName = component; 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; Loading Loading @@ -1710,6 +1726,7 @@ void AwesomePlayer::onVideoEvent() { if (mFlags & FIRST_FRAME) { modifyFlags(FIRST_FRAME, CLEAR); mSinceLastDropped = 0; mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs; } Loading Loading @@ -1756,8 +1773,17 @@ 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); if (!(mFlags & SLOW_DECODER_HACK) || mSinceLastDropped > FRAME_DROP_FREQ) { LOGV("we're late by %lld us (%.2f secs) dropping " "one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped); mSinceLastDropped = 0; mVideoBuffer->release(); mVideoBuffer = NULL; Loading @@ -1769,6 +1795,7 @@ void AwesomePlayer::onVideoEvent() { postVideoEvent_l(); return; } } if (latenessUs < -10000) { // We're more than 10ms early. Loading @@ -1786,6 +1813,7 @@ void AwesomePlayer::onVideoEvent() { } if (mVideoRenderer != NULL) { mSinceLastDropped++; mVideoRenderer->render(mVideoBuffer); } Loading media/libstagefright/include/AwesomePlayer.h +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,8 @@ private: TEXT_RUNNING = 0x10000, TEXTPLAYER_STARTED = 0x20000, SLOW_DECODER_HACK = 0x40000, }; mutable Mutex mLock; Loading Loading @@ -181,6 +183,7 @@ private: uint32_t mFlags; uint32_t mExtractorFlags; uint32_t mSinceLastDropped; int64_t mTimeSourceDeltaUs; int64_t mVideoTimeUs; Loading Loading
media/libstagefright/AwesomePlayer.cpp +42 −14 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ #include <cutils/properties.h> #define USE_SURFACE_ALLOC 1 #define FRAME_DROP_FREQ 0 namespace android { Loading Loading @@ -1523,14 +1524,29 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) { } if (mVideoSource != NULL) { const char *componentName; CHECK(mVideoSource->getFormat() ->findCString(kKeyDecoderComponent, &componentName)); { Mutex::Autolock autoLock(mStatsLock); TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); const char *component; CHECK(mVideoSource->getFormat() ->findCString(kKeyDecoderComponent, &component)); stat->mDecoderName = componentName; } stat->mDecoderName = component; 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; Loading Loading @@ -1710,6 +1726,7 @@ void AwesomePlayer::onVideoEvent() { if (mFlags & FIRST_FRAME) { modifyFlags(FIRST_FRAME, CLEAR); mSinceLastDropped = 0; mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs; } Loading Loading @@ -1756,8 +1773,17 @@ 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); if (!(mFlags & SLOW_DECODER_HACK) || mSinceLastDropped > FRAME_DROP_FREQ) { LOGV("we're late by %lld us (%.2f secs) dropping " "one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped); mSinceLastDropped = 0; mVideoBuffer->release(); mVideoBuffer = NULL; Loading @@ -1769,6 +1795,7 @@ void AwesomePlayer::onVideoEvent() { postVideoEvent_l(); return; } } if (latenessUs < -10000) { // We're more than 10ms early. Loading @@ -1786,6 +1813,7 @@ void AwesomePlayer::onVideoEvent() { } if (mVideoRenderer != NULL) { mSinceLastDropped++; mVideoRenderer->render(mVideoBuffer); } Loading
media/libstagefright/include/AwesomePlayer.h +3 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,8 @@ private: TEXT_RUNNING = 0x10000, TEXTPLAYER_STARTED = 0x20000, SLOW_DECODER_HACK = 0x40000, }; mutable Mutex mLock; Loading Loading @@ -181,6 +183,7 @@ private: uint32_t mFlags; uint32_t mExtractorFlags; uint32_t mSinceLastDropped; int64_t mTimeSourceDeltaUs; int64_t mVideoTimeUs; Loading