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/ffmpeg | |
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/ffmpeg')
-rw-r--r-- | media/ffmpeg/ffmpeg_common.cc | 24 | ||||
-rw-r--r-- | media/ffmpeg/ffmpeg_common.h | 6 |
2 files changed, 30 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc index f1835ce..7807d3f 100644 --- a/media/ffmpeg/ffmpeg_common.cc +++ b/media/ffmpeg/ffmpeg_common.cc @@ -215,6 +215,30 @@ ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, } } +VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format) { + switch (pixel_format) { + case PIX_FMT_YUV422P: + return VideoFrame::YV16; + case PIX_FMT_YUV420P: + return VideoFrame::YV12; + default: + NOTREACHED() << "Unsupported PixelFormat: " << pixel_format; + } + return VideoFrame::INVALID; +} + +PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format) { + switch (video_format) { + case VideoFrame::YV16: + return PIX_FMT_YUV422P; + case VideoFrame::YV12: + return PIX_FMT_YUV420P; + default: + NOTREACHED() << "Unsupported VideoFrame Format: " << video_format; + } + return PIX_FMT_NONE; +} + base::TimeDelta GetFrameDuration(AVStream* stream) { AVRational time_base = { stream->r_frame_rate.den, stream->r_frame_rate.num }; return ConvertFromTimeBase(time_base, 1); diff --git a/media/ffmpeg/ffmpeg_common.h b/media/ffmpeg/ffmpeg_common.h index cc15e58..8808f45 100644 --- a/media/ffmpeg/ffmpeg_common.h +++ b/media/ffmpeg/ffmpeg_common.h @@ -83,6 +83,12 @@ CodecID VideoCodecToCodecID(VideoCodec video_codec); ChannelLayout ChannelLayoutToChromeChannelLayout(int64_t layout, int channels); +// Converts FFmpeg's pixel formats to its corresponding supported video format. +VideoFrame::Format PixelFormatToVideoFormat(PixelFormat pixel_format); + +// Converts video formats to its corresponding FFmpeg's pixel formats. +PixelFormat VideoFormatToPixelFormat(VideoFrame::Format video_format); + // Calculates duration of one frame in the |stream| based on its frame rate. base::TimeDelta GetFrameDuration(AVStream* stream); |