diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 19:29:53 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 19:29:53 +0000 |
commit | 26997934da78f15792ee179b58f97025d3d67c1d (patch) | |
tree | 4ab397128009e236f842463583c2b4f305bd949c /media/video | |
parent | 2639e1ff9e5d9d6905467abdb9da80681c68585b (diff) | |
download | chromium_src-26997934da78f15792ee179b58f97025d3d67c1d.zip chromium_src-26997934da78f15792ee179b58f97025d3d67c1d.tar.gz chromium_src-26997934da78f15792ee179b58f97025d3d67c1d.tar.bz2 |
Fix support for yuv_422 pixel format.
Added pix_fmt field to the VideoDecoderConfig class. The pixel format is passed to the
codec_context_ and used to correctly initialize VideoFrames.
Patch by shadi@chromium.org:
http://codereview.chromium.org/8052002/
BUG=95642
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r-- | media/video/ffmpeg_video_decode_engine.cc | 17 | ||||
-rw-r--r-- | media/video/ffmpeg_video_decode_engine_unittest.cc | 9 |
2 files changed, 14 insertions, 12 deletions
diff --git a/media/video/ffmpeg_video_decode_engine.cc b/media/video/ffmpeg_video_decode_engine.cc index 8d547b9..46c02d9 100644 --- a/media/video/ffmpeg_video_decode_engine.cc +++ b/media/video/ffmpeg_video_decode_engine.cc @@ -55,9 +55,7 @@ void FFmpegVideoDecodeEngine::Initialize( // Initialize AVCodecContext structure. codec_context_ = avcodec_alloc_context(); - - // TODO(scherkus): should video format get passed in via VideoDecoderConfig? - codec_context_->pix_fmt = PIX_FMT_YUV420P; + 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(); @@ -110,11 +108,11 @@ void FFmpegVideoDecodeEngine::Initialize( // Create output buffer pool when direct rendering is not used. for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { scoped_refptr<VideoFrame> video_frame = - VideoFrame::CreateFrame(VideoFrame::YV12, - config.visible_rect().width(), - config.visible_rect().height(), - kNoTimestamp, - kNoTimestamp); + VideoFrame::CreateFrame(PixelFormatToVideoFormat(codec_context_->pix_fmt), + config.visible_rect().width(), + config.visible_rect().height(), + kNoTimestamp, + kNoTimestamp); frame_queue_available_.push_back(video_frame); } @@ -244,7 +242,8 @@ void FFmpegVideoDecodeEngine::DecodeFrame(scoped_refptr<Buffer> buffer) { // output, meaning the data is only valid until the next // avcodec_decode_video() call. int y_rows = codec_context_->height; - int uv_rows = codec_context_->height / 2; + int uv_rows = video_frame->rows(VideoFrame::kUPlane); + CopyYPlane(av_frame_->data[0], av_frame_->linesize[0], y_rows, video_frame); CopyUPlane(av_frame_->data[1], av_frame_->linesize[1], uv_rows, video_frame); CopyVPlane(av_frame_->data[2], av_frame_->linesize[2], uv_rows, video_frame); diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc index 581fb3d..b4ce626 100644 --- a/media/video/ffmpeg_video_decode_engine_unittest.cc +++ b/media/video/ffmpeg_video_decode_engine_unittest.cc @@ -22,6 +22,7 @@ using ::testing::StrictMock; namespace media { +static const VideoFrame::Format kVideoFormat = VideoFrame::YV12; static const gfx::Size kCodedSize(320, 240); static const gfx::Rect kVisibleRect(320, 240); static const gfx::Size kNaturalSize(522, 288); @@ -36,7 +37,7 @@ class FFmpegVideoDecodeEngineTest public VideoDecodeEngine::EventHandler { public: FFmpegVideoDecodeEngineTest() - : config_(kCodecVP8, kCodedSize, kVisibleRect, + : config_(kCodecVP8, kVideoFormat, kCodedSize, kVisibleRect, kFrameRate.num, kFrameRate.den, NULL, 0) { CHECK(FFmpegGlue::GetInstance()); @@ -142,7 +143,8 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) { } TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { - VideoDecoderConfig config(kUnknownVideoCodec, kCodedSize, kVisibleRect, + VideoDecoderConfig config(kUnknownVideoCodec, kVideoFormat, + kCodedSize, kVisibleRect, kFrameRate.num, kFrameRate.den, NULL, 0); @@ -153,7 +155,8 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) { TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) { // Specify Theora w/o extra data so that avcodec_open() fails. - VideoDecoderConfig config(kCodecTheora, kCodedSize, kVisibleRect, + VideoDecoderConfig config(kCodecTheora, kVideoFormat, + kCodedSize, kVisibleRect, kFrameRate.num, kFrameRate.den, NULL, 0); EXPECT_CALL(*this, OnInitializeComplete(false)); |