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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 113611: Handle end of stream for media... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
Index: media/filters/ffmpeg_video_decoder.cc
===================================================================
--- media/filters/ffmpeg_video_decoder.cc (revision 17376)
+++ media/filters/ffmpeg_video_decoder.cc (working copy)
@@ -87,12 +87,6 @@
avcodec_flush_buffers(codec_context_);
}
- // Queue the incoming timestamp.
- TimeTuple times;
- times.timestamp = buffer->GetTimestamp();
- times.duration = buffer->GetDuration();
- time_queue_.push(times);
-
// Create a packet for input data.
// Due to FFmpeg API changes we no longer have const read-only pointers.
AVPacket packet;
@@ -121,9 +115,26 @@
// Check for a decoded frame instead of checking the return value of
// avcodec_decode_video(). We don't need to stop the pipeline on
// decode errors.
- if (!decoded)
+ if (decoded == 0) {
+ // Three conditions to meet to declare end of stream for this decoder:
+ // 1. FFmpeg didn't read anything.
+ // 2. FFmpeg didn't output anything.
+ // 3. An end of stream buffer is received.
+ if (result == 0 && buffer->IsEndOfStream()) {
+ // Create an empty video frame and queue it.
+ scoped_refptr<VideoFrame> video_frame;
+ VideoFrameImpl::CreateEmptyFrame(&video_frame);
+ EnqueueResult(video_frame);
+ }
return;
+ }
+ // Queue the incoming timestamp only if we can decode the frame successfully.
+ TimeTuple times;
+ times.timestamp = buffer->GetTimestamp();
+ times.duration = buffer->GetDuration();
+ time_queue_.push(times);
+
// J (Motion JPEG) versions of YUV are full range 0..255.
// Regular (MPEG) YUV is 16..240.
// For now we will ignore the distinction and treat them the same.

Powered by Google App Engine
This is Rietveld 408576698