OSDN Git Service

AwesomePlayer: Improve performance on high-fps clips
authorLajos Molnar <lajos@google.com>
Wed, 23 Oct 2013 22:19:47 +0000 (15:19 -0700)
committerLajos Molnar <lajos@google.com>
Wed, 13 Nov 2013 01:40:38 +0000 (17:40 -0800)
- Immediately retry rendering next frame after frame skip.
- Schedule next videoEvent based on the timestamp of the
  next frame.

Change-Id: Ia106382c4c225321b682c1f7c2d126d7eab7d56d
Signed-off-by: Lajos Molnar <lajos@google.com>
Bug: 11159147

media/libstagefright/AwesomePlayer.cpp

index e1f6563..87ed96a 100644 (file)
@@ -1932,7 +1932,7 @@ void AwesomePlayer::onVideoEvent() {
                     ++mStats.mNumVideoFramesDropped;
                 }
 
-                postVideoEvent_l();
+                postVideoEvent_l(0);
                 return;
             }
         }
@@ -1972,6 +1972,41 @@ void AwesomePlayer::onVideoEvent() {
         return;
     }
 
+    /* get next frame time */
+    if (wasSeeking == NO_SEEK) {
+        MediaSource::ReadOptions options;
+        for (;;) {
+            status_t err = mVideoSource->read(&mVideoBuffer, &options);
+            if (err != OK) {
+                // deal with any errors next time
+                CHECK(mVideoBuffer == NULL);
+                postVideoEvent_l(0);
+                return;
+            }
+
+            if (mVideoBuffer->range_length() != 0) {
+                break;
+            }
+
+            // Some decoders, notably the PV AVC software decoder
+            // return spurious empty buffers that we just want to ignore.
+
+            mVideoBuffer->release();
+            mVideoBuffer = NULL;
+        }
+
+        {
+            Mutex::Autolock autoLock(mStatsLock);
+            ++mStats.mNumVideoFramesDecoded;
+        }
+
+        int64_t nextTimeUs;
+        CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &nextTimeUs));
+        int64_t delayUs = nextTimeUs - ts->getRealTimeUs() + mTimeSourceDeltaUs;
+        postVideoEvent_l(delayUs > 10000 ? 10000 : delayUs < 0 ? 0 : delayUs);
+        return;
+    }
+
     postVideoEvent_l();
 }