Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r=jesup, a=jcristau
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 25 Jan 2017 07:10:00 -0500
changeset 366657 df261e5fa4e88700ad510a51fadf8c27833330e7
parent 366656 a19f845ef02553eb3c21a7977be4ffdf295f977f
child 366658 a6cb4268d7b4b8fcd2f0f446024349beab5fe3a2
push id6826
push userryanvm@gmail.com
push dateWed, 25 Jan 2017 17:02:21 +0000
treeherdermozilla-beta@e8e90b0da7c4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, jcristau
bugs1332619
milestone52.0
Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r=jesup, a=jcristau
dom/media/encoder/VP8TrackEncoder.cpp
--- a/dom/media/encoder/VP8TrackEncoder.cpp
+++ b/dom/media/encoder/VP8TrackEncoder.cpp
@@ -617,20 +617,23 @@ VP8TrackEncoder::GetEncodedTrack(Encoded
           return NS_ERROR_FAILURE;
         }
         // Get the encoded data from VP8 encoder.
         GetEncodedPartitions(aData);
       } else {
         // SKIP_FRAME
         // Extend the duration of the last encoded data in aData
         // because this frame will be skip.
-        RefPtr<EncodedFrame> last = nullptr;
-        last = aData.GetEncodedFrames().LastElement();
+        RefPtr<EncodedFrame> last = aData.GetEncodedFrames().LastElement();
         if (last) {
-          last->SetDuration(last->GetDuration() + encodedDuration);
+          CheckedInt64 skippedDuration = FramesToUsecs(chunk.mDuration, mTrackRate);
+          if (skippedDuration.isValid() && skippedDuration.value() > 0) {
+            last->SetDuration(last->GetDuration() +
+                              (static_cast<uint64_t>(skippedDuration.value())));
+          }
         }
       }
       // Move forward the mEncodedTimestamp.
       mEncodedTimestamp += encodedDuration;
       totalProcessedDuration += durationCopied;
       // Calculate mRemainingTicks for next target frame.
       mRemainingTicks = CalculateRemainingTicks(durationCopied,
                                                 encodedDuration);