summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 00:43:19 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 00:43:19 +0000
commitfbf03889bb066ffa0b99c58b60680ff73acdebda (patch)
treefba6df9c448e2309e9828b5e9a1b5a3991cbd062 /media/video
parent137e0863a23adcf500ecb9c7de67d83adbd6f747 (diff)
downloadchromium_src-fbf03889bb066ffa0b99c58b60680ff73acdebda.zip
chromium_src-fbf03889bb066ffa0b99c58b60680ff73acdebda.tar.gz
chromium_src-fbf03889bb066ffa0b99c58b60680ff73acdebda.tar.bz2
Remove DemuxerStream::GetAVStream() once and for all.
We now use AudioDecoderConfig and VideoDecoderConfig to pass decoder initialization information. Review URL: http://codereview.chromium.org/8341033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r--media/video/ffmpeg_video_decode_engine.cc22
-rw-r--r--media/video/ffmpeg_video_decode_engine_unittest.cc7
2 files changed, 10 insertions, 19 deletions
diff --git a/media/video/ffmpeg_video_decode_engine.cc b/media/video/ffmpeg_video_decode_engine.cc
index 0fe4810..05af31f 100644
--- a/media/video/ffmpeg_video_decode_engine.cc
+++ b/media/video/ffmpeg_video_decode_engine.cc
@@ -41,6 +41,9 @@ void FFmpegVideoDecodeEngine::Initialize(
VideoDecodeEngine::EventHandler* event_handler,
VideoDecodeContext* context,
const VideoDecoderConfig& config) {
+ frame_rate_numerator_ = config.frame_rate_numerator();
+ frame_rate_denominator_ = config.frame_rate_denominator();
+
// Always try to use three threads for video decoding. There is little reason
// not to since current day CPUs tend to be multi-core and we measured
// performance benefits on older machines such as P4s with hyperthreading.
@@ -55,24 +58,7 @@ void FFmpegVideoDecodeEngine::Initialize(
// Initialize AVCodecContext structure.
codec_context_ = avcodec_alloc_context();
- codec_context_->pix_fmt = VideoFormatToPixelFormat(config.format());
- codec_context_->codec_type = AVMEDIA_TYPE_VIDEO;
- codec_context_->codec_id = VideoCodecToCodecID(config.codec());
- codec_context_->coded_width = config.coded_size().width();
- codec_context_->coded_height = config.coded_size().height();
-
- frame_rate_numerator_ = config.frame_rate_numerator();
- frame_rate_denominator_ = config.frame_rate_denominator();
-
- if (config.extra_data() != NULL) {
- codec_context_->extradata_size = config.extra_data_size();
- codec_context_->extradata = reinterpret_cast<uint8_t*>(
- av_malloc(config.extra_data_size() + FF_INPUT_BUFFER_PADDING_SIZE));
- memcpy(codec_context_->extradata, config.extra_data(),
- config.extra_data_size());
- memset(codec_context_->extradata + config.extra_data_size(), '\0',
- FF_INPUT_BUFFER_PADDING_SIZE);
- }
+ VideoDecoderConfigToAVCodecContext(config, codec_context_);
// Enable motion vector search (potentially slow), strong deblocking filter
// for damaged macroblocks, and set our error detection sensitivity.
diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc
index b4ce626..c5469b4 100644
--- a/media/video/ffmpeg_video_decode_engine_unittest.cc
+++ b/media/video/ffmpeg_video_decode_engine_unittest.cc
@@ -27,6 +27,7 @@ static const gfx::Size kCodedSize(320, 240);
static const gfx::Rect kVisibleRect(320, 240);
static const gfx::Size kNaturalSize(522, 288);
static const AVRational kFrameRate = { 100, 1 };
+static const AVRational kAspectRatio = { 1, 1 };
ACTION_P2(DemuxComplete, engine, buffer) {
engine->ConsumeVideoSample(buffer);
@@ -38,7 +39,9 @@ class FFmpegVideoDecodeEngineTest
public:
FFmpegVideoDecodeEngineTest()
: config_(kCodecVP8, kVideoFormat, kCodedSize, kVisibleRect,
- kFrameRate.num, kFrameRate.den, NULL, 0) {
+ kFrameRate.num, kFrameRate.den,
+ kAspectRatio.num, kAspectRatio.den,
+ NULL, 0) {
CHECK(FFmpegGlue::GetInstance());
// Setup FFmpeg structures.
@@ -146,6 +149,7 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat,
kCodedSize, kVisibleRect,
kFrameRate.num, kFrameRate.den,
+ kAspectRatio.num, kAspectRatio.den,
NULL, 0);
// Test avcodec_find_decoder() returning NULL.
@@ -158,6 +162,7 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
VideoDecoderConfig config(kCodecTheora, kVideoFormat,
kCodedSize, kVisibleRect,
kFrameRate.num, kFrameRate.den,
+ kAspectRatio.num, kAspectRatio.den,
NULL, 0);
EXPECT_CALL(*this, OnInitializeComplete(false));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config);