Chromium Code Reviews| Index: media/filters/video_renderer_base.cc |
| diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc |
| index df7350c23d6b640df37cb2101c18a0fe12b30b52..38f67bfbfeab0706620995a143e6bd4cc64435e2 100644 |
| --- a/media/filters/video_renderer_base.cc |
| +++ b/media/filters/video_renderer_base.cc |
| @@ -336,8 +336,6 @@ void VideoRendererBase::PutCurrentFrame(scoped_refptr<VideoFrame> frame) { |
| } |
| void VideoRendererBase::FrameReady(scoped_refptr<VideoFrame> frame) { |
| - DCHECK(frame); |
| - |
| base::AutoLock auto_lock(lock_); |
| DCHECK_NE(state_, kUninitialized); |
| DCHECK_NE(state_, kStopped); |
| @@ -352,41 +350,45 @@ void VideoRendererBase::FrameReady(scoped_refptr<VideoFrame> frame) { |
| return; |
| } |
| - // Discard frames until we reach our desired seek timestamp. |
| - if (state_ == kSeeking && !frame->IsEndOfStream() && |
| - (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { |
| - AttemptRead_Locked(); |
| - return; |
| - } |
| - |
| - // Adjust the incoming frame if its rendering stop time is past the duration |
| - // of the video itself. This is typically the last frame of the video and |
| - // occurs if the container specifies a duration that isn't a multiple of the |
| - // frame rate. Another way for this to happen is for the container to state a |
| - // smaller duration than the largest packet timestamp. |
| - if (!frame->IsEndOfStream()) { |
| - if (frame->GetTimestamp() > host()->GetDuration()) |
| - frame->SetTimestamp(host()->GetDuration()); |
| - if ((frame->GetTimestamp() + frame->GetDuration()) > host()->GetDuration()) |
| - frame->SetDuration(host()->GetDuration() - frame->GetTimestamp()); |
| - } |
| - |
| - // This one's a keeper! Place it in the ready queue. |
| - ready_frames_.push_back(frame); |
| - DCHECK_LE(NumFrames_Locked(), limits::kMaxVideoFrames); |
| - frame_available_.Signal(); |
| + if (frame) { |
|
Ami GONE FROM CHROMIUM
2012/01/27 23:44:58
reverse test & early-return?
acolwell GONE FROM CHROMIUM
2012/01/29 03:00:41
Done.
|
| + // Discard frames until we reach our desired seek timestamp. |
| + if (state_ == kSeeking && !frame->IsEndOfStream() && |
| + (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { |
| + AttemptRead_Locked(); |
| + return; |
| + } |
| - PipelineStatistics statistics; |
| - statistics.video_frames_decoded = 1; |
| - statistics_callback_.Run(statistics); |
| + // Adjust the incoming frame if its rendering stop time is past the duration |
| + // of the video itself. This is typically the last frame of the video and |
| + // occurs if the container specifies a duration that isn't a multiple of the |
| + // frame rate. Another way for this to happen is for the container to state |
| + // a smaller duration than the largest packet timestamp. |
| + if (!frame->IsEndOfStream()) { |
| + base::TimeDelta duration = host()->GetDuration(); |
|
Ami GONE FROM CHROMIUM
2012/01/27 23:44:58
IMO this is a worsening of readability, since ther
acolwell GONE FROM CHROMIUM
2012/01/29 03:00:41
Done.
|
| + if (frame->GetTimestamp() > duration) |
| + frame->SetTimestamp(duration); |
| + if ((frame->GetTimestamp() + frame->GetDuration()) > duration) |
| + frame->SetDuration(duration - frame->GetTimestamp()); |
| + } |
| - // Always request more decoded video if we have capacity. This serves two |
| - // purposes: |
| - // 1) Prerolling while paused |
| - // 2) Keeps decoding going if video rendering thread starts falling behind |
| - if (NumFrames_Locked() < limits::kMaxVideoFrames && !frame->IsEndOfStream()) { |
| - AttemptRead_Locked(); |
| - return; |
| + // This one's a keeper! Place it in the ready queue. |
| + ready_frames_.push_back(frame); |
| + DCHECK_LE(NumFrames_Locked(), limits::kMaxVideoFrames); |
| + frame_available_.Signal(); |
| + |
| + PipelineStatistics statistics; |
| + statistics.video_frames_decoded = 1; |
| + statistics_callback_.Run(statistics); |
| + |
| + // Always request more decoded video if we have capacity. This serves two |
| + // purposes: |
| + // 1) Prerolling while paused |
| + // 2) Keeps decoding going if video rendering thread starts falling behind |
| + if (NumFrames_Locked() < limits::kMaxVideoFrames && |
| + !frame->IsEndOfStream()) { |
| + AttemptRead_Locked(); |
| + return; |
| + } |
| } |
| // If we're at capacity or end of stream while seeking we need to transition |