OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/video/ffmpeg_video_decode_engine.h" | 5 #include "media/video/ffmpeg_video_decode_engine.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
11 #include "media/base/limits.h" | 11 #include "media/base/limits.h" |
12 #include "media/base/media_switches.h" | 12 #include "media/base/media_switches.h" |
13 #include "media/base/pipeline.h" | 13 #include "media/base/pipeline.h" |
14 #include "media/base/video_util.h" | 14 #include "media/base/video_util.h" |
15 #include "media/ffmpeg/ffmpeg_common.h" | 15 #include "media/ffmpeg/ffmpeg_common.h" |
16 #include "media/filters/ffmpeg_demuxer.h" | |
17 | 16 |
18 namespace media { | 17 namespace media { |
19 | 18 |
20 FFmpegVideoDecodeEngine::FFmpegVideoDecodeEngine() | 19 FFmpegVideoDecodeEngine::FFmpegVideoDecodeEngine() |
21 : codec_context_(NULL), | 20 : codec_context_(NULL), |
22 event_handler_(NULL), | 21 event_handler_(NULL), |
23 frame_rate_numerator_(0), | 22 frame_rate_numerator_(0), |
24 frame_rate_denominator_(0), | 23 frame_rate_denominator_(0), |
25 pending_input_buffers_(0), | 24 pending_input_buffers_(0), |
26 pending_output_buffers_(0), | 25 pending_output_buffers_(0), |
27 output_eos_reached_(false), | 26 output_eos_reached_(false), |
28 flush_pending_(false) { | 27 flush_pending_(false) { |
29 } | 28 } |
30 | 29 |
31 FFmpegVideoDecodeEngine::~FFmpegVideoDecodeEngine() { | 30 FFmpegVideoDecodeEngine::~FFmpegVideoDecodeEngine() { |
32 if (codec_context_) { | 31 if (codec_context_) { |
33 av_free(codec_context_->extradata); | 32 av_free(codec_context_->extradata); |
34 avcodec_close(codec_context_); | 33 avcodec_close(codec_context_); |
35 av_free(codec_context_); | 34 av_free(codec_context_); |
36 } | 35 } |
37 } | 36 } |
38 | 37 |
39 void FFmpegVideoDecodeEngine::Initialize( | 38 void FFmpegVideoDecodeEngine::Initialize( |
40 MessageLoop* message_loop, | |
41 VideoDecodeEngine::EventHandler* event_handler, | 39 VideoDecodeEngine::EventHandler* event_handler, |
42 VideoDecodeContext* context, | |
43 const VideoDecoderConfig& config) { | 40 const VideoDecoderConfig& config) { |
44 frame_rate_numerator_ = config.frame_rate_numerator(); | 41 frame_rate_numerator_ = config.frame_rate_numerator(); |
45 frame_rate_denominator_ = config.frame_rate_denominator(); | 42 frame_rate_denominator_ = config.frame_rate_denominator(); |
46 | 43 |
47 // Always try to use three threads for video decoding. There is little reason | 44 // Always try to use three threads for video decoding. There is little reason |
48 // not to since current day CPUs tend to be multi-core and we measured | 45 // not to since current day CPUs tend to be multi-core and we measured |
49 // performance benefits on older machines such as P4s with hyperthreading. | 46 // performance benefits on older machines such as P4s with hyperthreading. |
50 // | 47 // |
51 // Handling decoding on separate threads also frees up the pipeline thread to | 48 // Handling decoding on separate threads also frees up the pipeline thread to |
52 // continue processing. Although it'd be nice to have the option of a single | 49 // continue processing. Although it'd be nice to have the option of a single |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 DCHECK_EQ(output_eos_reached_, false); | 285 DCHECK_EQ(output_eos_reached_, false); |
289 pending_input_buffers_++; | 286 pending_input_buffers_++; |
290 event_handler_->ProduceVideoSample(NULL); | 287 event_handler_->ProduceVideoSample(NULL); |
291 } | 288 } |
292 | 289 |
293 } // namespace media | 290 } // namespace media |
294 | 291 |
295 // Disable refcounting for this object because this object only lives | 292 // Disable refcounting for this object because this object only lives |
296 // on the video decoder thread and there's no need to refcount it. | 293 // on the video decoder thread and there's no need to refcount it. |
297 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::FFmpegVideoDecodeEngine); | 294 DISABLE_RUNNABLE_METHOD_REFCOUNT(media::FFmpegVideoDecodeEngine); |
OLD | NEW |