Bug 1131638 - Record invalid frames as dropped for video playback stats. r=ajones, a=lmandel
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 12 Mar 2015 22:14:04 +1300
changeset 250406 f88fcb8ccc27
parent 250405 297e2e626fe9
child 250407 edb24ca59d13
push id4577
push usermwoodrow@mozilla.com
push date2015-03-17 01:11 +0000
treeherdermozilla-beta@edb24ca59d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersajones, lmandel
bugs1131638
milestone37.0
Bug 1131638 - Record invalid frames as dropped for video playback stats. r=ajones, a=lmandel
dom/media/MediaDecoder.h
dom/media/MediaDecoderStateMachine.cpp
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -933,17 +933,18 @@ public:
   class FrameStatistics {
   public:
 
     FrameStatistics() :
         mReentrantMonitor("MediaDecoder::FrameStats"),
         mParsedFrames(0),
         mDecodedFrames(0),
         mPresentedFrames(0),
-        mDroppedFrames(0) {}
+        mDroppedFrames(0),
+        mCorruptFrames(0) {}
 
     // Returns number of frames which have been parsed from the media.
     // Can be called on any thread.
     uint32_t GetParsedFrames() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mParsedFrames;
     }
 
@@ -960,17 +961,23 @@ public:
     uint32_t GetPresentedFrames() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mPresentedFrames;
     }
 
     // Number of frames that have been skipped because they have missed their
     // compoisition deadline.
     uint32_t GetDroppedFrames() {
-      return mDroppedFrames;
+      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+      return mDroppedFrames + mCorruptFrames;
+    }
+
+    uint32_t GetCorruptedFrames() {
+      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+      return mCorruptFrames;
     }
 
     // Increments the parsed and decoded frame counters by the passed in counts.
     // Can be called on any thread.
     void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
                              uint32_t aDropped) {
       if (aParsed == 0 && aDecoded == 0 && aDropped == 0)
         return;
@@ -982,16 +989,21 @@ public:
 
     // Increments the presented frame counters.
     // Can be called on any thread.
     void NotifyPresentedFrame() {
       ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       ++mPresentedFrames;
     }
 
+    void NotifyCorruptFrame() {
+      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
+      ++mCorruptFrames;
+    }
+
   private:
 
     // ReentrantMonitor to protect access of playback statistics.
     ReentrantMonitor mReentrantMonitor;
 
     // Number of frames parsed and demuxed from media.
     // Access protected by mReentrantMonitor.
     uint32_t mParsedFrames;
@@ -1000,16 +1012,18 @@ public:
     // Access protected by mReentrantMonitor.
     uint32_t mDecodedFrames;
 
     // Number of decoded frames which were actually sent down the rendering
     // pipeline to be painted ("presented"). Access protected by mReentrantMonitor.
     uint32_t mPresentedFrames;
 
     uint32_t mDroppedFrames;
+
+    uint32_t mCorruptFrames;
   };
 
   // Return the frame decode/paint related statistics.
   FrameStatistics& GetFrameStatistics() { return mFrameStats; }
 
   // Increments the parsed and decoded frame counters by the passed in counts.
   // Can be called on any thread.
   virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded,
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2998,16 +2998,20 @@ void MediaDecoderStateMachine::RenderVid
   }
 
   VERBOSE_LOG("playing video frame %lld (queued=%i, state-machine=%i, decoder-queued=%i)",
               aData->mTime, VideoQueue().GetSize() + mReader->SizeOfVideoQueueInFrames(),
               VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames());
 
   VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
   if (container) {
+    if (aData->mImage && !aData->mImage->IsValid()) {
+      MediaDecoder::FrameStatistics& frameStats = mDecoder->GetFrameStatistics();
+      frameStats.NotifyCorruptFrame();
+    }
     container->SetCurrentFrame(ThebesIntSize(aData->mDisplay), aData->mImage,
                                aTarget);
     MOZ_ASSERT(container->GetFrameDelay() >= 0 || IsRealTime());
   }
 }
 
 void MediaDecoderStateMachine::ResyncAudioClock()
 {