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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 11993002: Tighten up media::DecoderBuffer API contract for end of stream buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index d7bbf82d28bebec52aee5d782be414e627f61bf7..04598338bb3505a4943ff4d680a3001e198d8c57 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -309,7 +309,7 @@ void FFmpegVideoDecoder::DecodeBuffer(
}
// Any successful decode counts!
- if (buffer->GetDataSize()) {
+ if (!buffer->IsEndOfStream() && buffer->GetDataSize() > 0) {
PipelineStatistics statistics;
statistics.video_bytes_decoded = buffer->GetDataSize();
statistics_cb_.Run(statistics);
@@ -336,22 +336,27 @@ bool FFmpegVideoDecoder::Decode(
scoped_refptr<VideoFrame>* video_frame) {
DCHECK(video_frame);
+ // Reset frame to default values.
+ avcodec_get_frame_defaults(av_frame_);
+
// Create a packet for input data.
// Due to FFmpeg API changes we no longer have const read-only pointers.
AVPacket packet;
av_init_packet(&packet);
- packet.data = const_cast<uint8*>(buffer->GetData());
- packet.size = buffer->GetDataSize();
-
- // Let FFmpeg handle presentation timestamp reordering.
- codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds();
+ if (buffer->IsEndOfStream()) {
+ packet.data = NULL;
+ packet.size = 0;
+ } else {
+ packet.data = const_cast<uint8*>(buffer->GetData());
+ packet.size = buffer->GetDataSize();
- // Reset frame to default values.
- avcodec_get_frame_defaults(av_frame_);
+ // Let FFmpeg handle presentation timestamp reordering.
+ codec_context_->reordered_opaque = buffer->GetTimestamp().InMicroseconds();
- // This is for codecs not using get_buffer to initialize
- // |av_frame_->reordered_opaque|
- av_frame_->reordered_opaque = codec_context_->reordered_opaque;
+ // This is for codecs not using get_buffer to initialize
+ // |av_frame_->reordered_opaque|
+ av_frame_->reordered_opaque = codec_context_->reordered_opaque;
+ }
int frame_decoded = 0;
int result = avcodec_decode_video2(codec_context_,
@@ -360,10 +365,7 @@ bool FFmpegVideoDecoder::Decode(
&packet);
// Log the problem if we can't decode a video frame and exit early.
if (result < 0) {
- LOG(ERROR) << "Error decoding a video frame with timestamp: "
- << buffer->GetTimestamp().InMicroseconds() << " us, duration: "
- << buffer->GetDuration().InMicroseconds() << " us, packet size: "
- << buffer->GetDataSize() << " bytes";
+ LOG(ERROR) << "Error decoding video: " << buffer->AsHumanReadableString();
*video_frame = NULL;
return false;
}
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698