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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 160005: Implemented proper pause-then-seek behaviour for the media pipeline. (Closed)
Patch Set: yay Created 11 years, 5 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_video_decoder.h ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | 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 ab91ec9c13718b9341645edda3c4d6a056a5a0c1..ef6456295a478b6ff6ed3774de3305bc487d9e63 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -95,11 +95,17 @@ void FFmpegVideoDecoder::OnSeek(base::TimeDelta time) {
// Everything in the presentation time queue is invalid, clear the queue.
while (!pts_queue_.empty())
pts_queue_.pop();
+
+ // We're back where we started. It should be completely safe to flush here
+ // since DecoderBase uses |expecting_discontinuous_| to verify that the next
+ // time OnDecode() is called we will have a discontinuous buffer.
+ state_ = kNormal;
+ avcodec_flush_buffers(codec_context_);
}
void FFmpegVideoDecoder::OnDecode(Buffer* buffer) {
// During decode, because reads are issued asynchronously, it is possible to
- // recieve multiple end of stream buffers since each read is acked. When the
+ // receive multiple end of stream buffers since each read is acked. When the
// first end of stream buffer is read, FFmpeg may still have frames queued
// up in the decoder so we need to go through the decode loop until it stops
// giving sensible data. After that, the decoder should output empty
@@ -120,6 +126,8 @@ void FFmpegVideoDecoder::OnDecode(Buffer* buffer) {
// A catastrophic failure occurs, and decoding needs to stop.
// kFlushCodec -> kDecodeFinished:
// When avcodec_decode_video2() returns 0 data or errors out.
+ // (any state) -> kNormal:
+ // Any time buffer->IsDiscontinuous() is true.
//
// If the decoding is finished, we just always return empty frames.
if (state_ == kDecodeFinished) {
@@ -240,12 +248,6 @@ void FFmpegVideoDecoder::EnqueueEmptyFrame() {
bool FFmpegVideoDecoder::DecodeFrame(const Buffer& buffer,
AVCodecContext* codec_context,
AVFrame* yuv_frame) {
- // Check for discontinuous buffer. If we receive a discontinuous buffer here,
- // flush the internal buffer of FFmpeg.
- if (buffer.IsDiscontinuous()) {
- avcodec_flush_buffers(codec_context);
- }
-
// Create a packet for input data.
// Due to FFmpeg API changes we no longer have const read-only pointers.
AVPacket packet;
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698