summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
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);