| 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/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
| 12 #include "media/base/decoder_buffer.h" | 12 #include "media/base/decoder_buffer.h" |
| 13 #include "media/base/demuxer_stream.h" | 13 #include "media/base/demuxer_stream.h" |
| 14 #include "media/base/limits.h" | 14 #include "media/base/limits.h" |
| 15 #include "media/base/media_switches.h" | 15 #include "media/base/media_switches.h" |
| 16 #include "media/base/pipeline.h" | 16 #include "media/base/pipeline.h" |
| 17 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
| 18 #include "media/base/video_frame.h" | 18 #include "media/base/video_frame.h" |
| 19 #include "media/base/video_util.h" | 19 #include "media/base/video_util.h" |
| 20 #include "media/crypto/decryptor.h" |
| 20 #include "media/ffmpeg/ffmpeg_common.h" | 21 #include "media/ffmpeg/ffmpeg_common.h" |
| 21 | 22 |
| 22 namespace media { | 23 namespace media { |
| 23 | 24 |
| 24 // Always try to use three threads for video decoding. There is little reason | 25 // Always try to use three threads for video decoding. There is little reason |
| 25 // not to since current day CPUs tend to be multi-core and we measured | 26 // not to since current day CPUs tend to be multi-core and we measured |
| 26 // performance benefits on older machines such as P4s with hyperthreading. | 27 // performance benefits on older machines such as P4s with hyperthreading. |
| 27 // | 28 // |
| 28 // Handling decoding on separate threads also frees up the pipeline thread to | 29 // Handling decoding on separate threads also frees up the pipeline thread to |
| 29 // continue processing. Although it'd be nice to have the option of a single | 30 // continue processing. Although it'd be nice to have the option of a single |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 167 |
| 167 ReleaseFFmpegResources(); | 168 ReleaseFFmpegResources(); |
| 168 state_ = kUninitialized; | 169 state_ = kUninitialized; |
| 169 closure.Run(); | 170 closure.Run(); |
| 170 } | 171 } |
| 171 | 172 |
| 172 const gfx::Size& FFmpegVideoDecoder::natural_size() { | 173 const gfx::Size& FFmpegVideoDecoder::natural_size() { |
| 173 return natural_size_; | 174 return natural_size_; |
| 174 } | 175 } |
| 175 | 176 |
| 176 void FFmpegVideoDecoder::set_decryptor(AesDecryptor* decryptor) { | 177 void FFmpegVideoDecoder::set_decryptor(Decryptor* decryptor) { |
| 177 DCHECK_EQ(state_, kUninitialized); | 178 DCHECK_EQ(state_, kUninitialized); |
| 178 decryptor_ = decryptor; | 179 decryptor_ = decryptor; |
| 179 } | 180 } |
| 180 | 181 |
| 181 FFmpegVideoDecoder::~FFmpegVideoDecoder() { | 182 FFmpegVideoDecoder::~FFmpegVideoDecoder() { |
| 182 ReleaseFFmpegResources(); | 183 ReleaseFFmpegResources(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) { | 186 void FFmpegVideoDecoder::DoRead(const ReadCB& read_cb) { |
| 186 DCHECK_EQ(MessageLoop::current(), message_loop_); | 187 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { | 426 scoped_refptr<VideoFrame> FFmpegVideoDecoder::AllocateVideoFrame() { |
| 426 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); | 427 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context_->pix_fmt); |
| 427 size_t width = codec_context_->width; | 428 size_t width = codec_context_->width; |
| 428 size_t height = codec_context_->height; | 429 size_t height = codec_context_->height; |
| 429 | 430 |
| 430 return VideoFrame::CreateFrame(format, width, height, | 431 return VideoFrame::CreateFrame(format, width, height, |
| 431 kNoTimestamp(), kNoTimestamp()); | 432 kNoTimestamp(), kNoTimestamp()); |
| 432 } | 433 } |
| 433 | 434 |
| 434 } // namespace media | 435 } // namespace media |
| OLD | NEW |