Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: media/cast/sender/vp8_encoder.cc

Issue 1146723002: New FRAME_DURATION VideoFrameMetadata, with Cast Streaming use case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expanded comments for VideoFrameMetadata::FRAME_DURATION. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_frame_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/sender/vp8_encoder.cc
diff --git a/media/cast/sender/vp8_encoder.cc b/media/cast/sender/vp8_encoder.cc
index 4d397b65decca820cf9a77847027c81d0e2d7062..b68935c36f0cc499549e0759d06b755f60d530e9 100644
--- a/media/cast/sender/vp8_encoder.cc
+++ b/media/cast/sender/vp8_encoder.cc
@@ -215,20 +215,26 @@ void Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame,
// The frame duration given to the VP8 codec affects a number of important
// behaviors, including: per-frame bandwidth, CPU time spent encoding,
// temporal quality trade-offs, and key/golden/alt-ref frame generation
- // intervals. Use the actual amount of time between the current and previous
- // frames as a prediction for the next frame's duration, but bound the
- // prediction to account for the fact that the frame rate can be highly
- // variable, including long pauses in the video stream.
+ // intervals. Bound the prediction to account for the fact that the frame
+ // rate can be highly variable, including long pauses in the video stream.
const base::TimeDelta minimum_frame_duration =
base::TimeDelta::FromSecondsD(1.0 / cast_config_.max_frame_rate);
const base::TimeDelta maximum_frame_duration =
base::TimeDelta::FromSecondsD(static_cast<double>(kRestartFramePeriods) /
cast_config_.max_frame_rate);
- const base::TimeDelta last_frame_duration =
- video_frame->timestamp() - last_frame_timestamp_;
- const base::TimeDelta predicted_frame_duration =
+ base::TimeDelta predicted_frame_duration;
+ if (!video_frame->metadata()->GetTimeDelta(
+ media::VideoFrameMetadata::FRAME_DURATION,
+ &predicted_frame_duration) ||
+ predicted_frame_duration <= base::TimeDelta()) {
+ // The source of the video frame did not provide the frame duration. Use
+ // the actual amount of time between the current and previous frame as a
+ // prediction for the next frame's duration.
+ predicted_frame_duration = video_frame->timestamp() - last_frame_timestamp_;
+ }
+ predicted_frame_duration =
std::max(minimum_frame_duration,
- std::min(maximum_frame_duration, last_frame_duration));
+ std::min(maximum_frame_duration, predicted_frame_duration));
last_frame_timestamp_ = video_frame->timestamp();
// Encode the frame. The presentation time stamp argument here is fixed to
« no previous file with comments | « media/base/video_frame_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698