| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/filters/ffmpeg_video_decoder.h" | 5 #include "media/filters/ffmpeg_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 message_loop_->PostTask(FROM_HERE, base::Bind( | 214 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 215 &FFmpegVideoDecoder::DoDecodeBuffer, this, buffer)); | 215 &FFmpegVideoDecoder::DoDecodeBuffer, this, buffer)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void FFmpegVideoDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& buffer) { | 218 void FFmpegVideoDecoder::DoDecodeBuffer(const scoped_refptr<Buffer>& buffer) { |
| 219 DCHECK_EQ(MessageLoop::current(), message_loop_); | 219 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 220 DCHECK_NE(state_, kUninitialized); | 220 DCHECK_NE(state_, kUninitialized); |
| 221 DCHECK_NE(state_, kDecodeFinished); | 221 DCHECK_NE(state_, kDecodeFinished); |
| 222 DCHECK(!read_cb_.is_null()); | 222 DCHECK(!read_cb_.is_null()); |
| 223 | 223 |
| 224 if (!buffer) { |
| 225 DeliverFrame(NULL); |
| 226 return; |
| 227 } |
| 228 |
| 224 // During decode, because reads are issued asynchronously, it is possible to | 229 // During decode, because reads are issued asynchronously, it is possible to |
| 225 // receive multiple end of stream buffers since each read is acked. When the | 230 // receive multiple end of stream buffers since each read is acked. When the |
| 226 // first end of stream buffer is read, FFmpeg may still have frames queued | 231 // first end of stream buffer is read, FFmpeg may still have frames queued |
| 227 // up in the decoder so we need to go through the decode loop until it stops | 232 // up in the decoder so we need to go through the decode loop until it stops |
| 228 // giving sensible data. After that, the decoder should output empty | 233 // giving sensible data. After that, the decoder should output empty |
| 229 // frames. There are three states the decoder can be in: | 234 // frames. There are three states the decoder can be in: |
| 230 // | 235 // |
| 231 // kNormal: This is the starting state. Buffers are decoded. Decode errors | 236 // kNormal: This is the starting state. Buffers are decoded. Decode errors |
| 232 // are discarded. | 237 // are discarded. |
| 233 // kFlushCodec: There isn't any more input data. Call avcodec_decode_video2 | 238 // kFlushCodec: There isn't any more input data. Call avcodec_decode_video2 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { | 406 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { |
| 402 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); | 407 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); |
| 403 size_t width = codec_context_->width; | 408 size_t width = codec_context_->width; |
| 404 size_t height = codec_context_->height; | 409 size_t height = codec_context_->height; |
| 405 | 410 |
| 406 return VideoFrame::CreateFrame(format, width, height, | 411 return VideoFrame::CreateFrame(format, width, height, |
| 407 kNoTimestamp(), kNoTimestamp()); | 412 kNoTimestamp(), kNoTimestamp()); |
| 408 } | 413 } |
| 409 | 414 |
| 410 } // namespace media | 415 } // namespace media |
| OLD | NEW |