Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r=jesup, a=jcristau
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 20 Jan 2017 15:47:04 +0100
changeset 375642 da4eb01b22b11f8daadf96db554908c2475b9c1f
parent 375641 78cdaba206c0d571596e3b776b492e6f8979e93d
child 375643 ad823ff1774b9eebc6e7edab303891c4ad81309a
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, jcristau
bugs1332619
milestone53.0a2
Bug 1332619 - Fix missed duration when skipping a frame in VP8TrackEncoder. r=jesup, a=jcristau MozReview-Commit-ID: GpXUHfUj5v2
dom/media/encoder/VP8TrackEncoder.cpp
--- a/dom/media/encoder/VP8TrackEncoder.cpp
+++ b/dom/media/encoder/VP8TrackEncoder.cpp
@@ -548,21 +548,25 @@ VP8TrackEncoder::GetEncodedTrack(Encoded
                            VPX_DL_REALTIME)) {
         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.
+      // because this frame will be skipped.
       VP8LOG(LogLevel::Warning, "MediaRecorder lagging behind. Skipping a frame.");
       RefPtr<EncodedFrame> last = aData.GetEncodedFrames().LastElement();
       if (last) {
-        last->SetDuration(last->GetDuration() + chunk.GetDuration());
+        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 += chunk.GetDuration();
     totalProcessedDuration += chunk.GetDuration();
 
     // Check what to do next.