Commit 6471a6bf authored by owenlin's avatar owenlin Committed by Commit bot

rendering_helper - Drop frames if the decoder cannot catch up.

Originally, we delayed the rendering and waited for the late coming frames. However, when play with audio, the late coming frame should be just dropped to keep the AV sync. So we change to drop a frame if it comes too late.

BUG=411123
TEST=Run vda_unittest on peach_pit.

Review URL: https://codereview.chromium.org/562173003

Cr-Commit-Position: refs/heads/master@{#294992}
parent bd700c84
......@@ -75,7 +75,7 @@ VideoFrameTexture::~VideoFrameTexture() {
}
RenderingHelper::RenderedVideo::RenderedVideo()
: last_frame_rendered(false), is_flushing(false) {
: last_frame_rendered(false), is_flushing(false), frames_to_drop(0) {
}
RenderingHelper::RenderedVideo::~RenderedVideo() {
......@@ -398,6 +398,11 @@ void RenderingHelper::QueueVideoFrame(
RenderedVideo* video = &videos_[window_id];
DCHECK(!video->is_flushing);
if (video->frames_to_drop > 0) {
--video->frames_to_drop;
return;
}
// Pop the last frame if it has been rendered.
if (video->last_frame_rendered) {
// When last_frame_rendered is true, we should have only one pending frame.
......@@ -525,6 +530,9 @@ void RenderingHelper::RenderContent() {
GLSetViewPort(video->render_area);
RenderTexture(frame->texture_target(), frame->texture_id());
if (video->last_frame_rendered)
++video->frames_to_drop;
if (video->pending_frames.size() > 1 || video->is_flushing) {
frames_to_be_returned.push_back(video->pending_frames.front());
video->pending_frames.pop();
......
......@@ -134,6 +134,9 @@ class RenderingHelper {
// True if there won't be any new video frames comming.
bool is_flushing;
// The number of frames need to be dropped to catch up the rendering.
int frames_to_drop;
// The video frames pending for rendering.
std::queue<scoped_refptr<VideoFrameTexture> > pending_frames;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment