summaryrefslogtreecommitdiffstats
path: root/media/ffmpeg
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 05:12:18 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-13 05:12:18 +0000
commite1d69d7692a834914973d274b9752fc7b904f50b (patch)
tree8b677849f2e6cec5ede9508445f51a0d2653f26d /media/ffmpeg
parent4d2f2709a295f51550237e6038debebb66d77d31 (diff)
downloadchromium_src-e1d69d7692a834914973d274b9752fc7b904f50b.zip
chromium_src-e1d69d7692a834914973d274b9752fc7b904f50b.tar.gz
chromium_src-e1d69d7692a834914973d274b9752fc7b904f50b.tar.bz2
<video> decode in hardware!
This uses the GpuVideoDecodeAccelerator machinery (already written to enable ppapi to take advantage of OpenMAX HW where available) to decode <video> data. This increases idle CPU from 20% to 45% on one particularly large (internal) test video (red0.mp4), on an ARM crosbook. HW decode is done on a best-effort basis; if the GPU code doesn't know how to deal with a codec/profile we still fall back to ffmpeg for decode. Because the vast majority of chrome installs will be on HW with no video decode support (yet) we only attempt HW video decode on platforms we know have a shot at it. This is a copy of http://codereview.chromium.org/8686010/ PS#13 to work around rietveld losing the "status" for some files in the patch. BUG=104579 TEST=manual testing w/ video test matrix, trybots. Review URL: http://codereview.chromium.org/8922010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ffmpeg')
-rw-r--r--media/ffmpeg/ffmpeg_common.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
index 396ee03..4f3dd0f 100644
--- a/media/ffmpeg/ffmpeg_common.cc
+++ b/media/ffmpeg/ffmpeg_common.cc
@@ -127,6 +127,52 @@ static CodecID VideoCodecToCodecID(VideoCodec video_codec) {
return CODEC_ID_NONE;
}
+static VideoCodecProfile ProfileIDToVideoCodecProfile(int profile) {
+ // Clear out the CONSTRAINED & INTRA flags which are strict subsets of the
+ // corresponding profiles with which they're used.
+ profile &= ~FF_PROFILE_H264_CONSTRAINED;
+ profile &= ~FF_PROFILE_H264_INTRA;
+ switch (profile) {
+ case FF_PROFILE_H264_BASELINE:
+ return H264PROFILE_BASELINE;
+ case FF_PROFILE_H264_MAIN:
+ return H264PROFILE_MAIN;
+ case FF_PROFILE_H264_EXTENDED:
+ return H264PROFILE_EXTENDED;
+ case FF_PROFILE_H264_HIGH:
+ return H264PROFILE_HIGH;
+ case FF_PROFILE_H264_HIGH_10:
+ return H264PROFILE_HIGH10PROFILE;
+ case FF_PROFILE_H264_HIGH_422:
+ return H264PROFILE_HIGH422PROFILE;
+ case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
+ return H264PROFILE_HIGH444PREDICTIVEPROFILE;
+ default:
+ return VIDEO_CODEC_PROFILE_UNKNOWN;
+ }
+}
+
+static int VideoCodecProfileToProfileID(VideoCodecProfile profile) {
+ switch (profile) {
+ case H264PROFILE_BASELINE:
+ return FF_PROFILE_H264_BASELINE;
+ case H264PROFILE_MAIN:
+ return FF_PROFILE_H264_MAIN;
+ case H264PROFILE_EXTENDED:
+ return FF_PROFILE_H264_EXTENDED;
+ case H264PROFILE_HIGH:
+ return FF_PROFILE_H264_HIGH;
+ case H264PROFILE_HIGH10PROFILE:
+ return FF_PROFILE_H264_HIGH_10;
+ case H264PROFILE_HIGH422PROFILE:
+ return FF_PROFILE_H264_HIGH_422;
+ case H264PROFILE_HIGH444PREDICTIVEPROFILE:
+ return FF_PROFILE_H264_HIGH_444_PREDICTIVE;
+ default:
+ return FF_PROFILE_UNKNOWN;
+ }
+}
+
void AVCodecContextToAudioDecoderConfig(
const AVCodecContext* codec_context,
AudioDecoderConfig* config) {
@@ -204,6 +250,7 @@ void AVStreamToVideoDecoderConfig(
aspect_ratio = stream->codec->sample_aspect_ratio;
config->Initialize(CodecIDToVideoCodec(stream->codec->codec_id),
+ ProfileIDToVideoCodecProfile(stream->codec->profile),
PixelFormatToVideoFormat(stream->codec->pix_fmt),
coded_size, visible_rect,
stream->r_frame_rate.num,
@@ -219,6 +266,7 @@ void VideoDecoderConfigToAVCodecContext(
AVCodecContext* codec_context) {
codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
codec_context->codec_id = VideoCodecToCodecID(config.codec());
+ codec_context->profile = VideoCodecProfileToProfileID(config.profile());
codec_context->coded_width = config.coded_size().width();
codec_context->coded_height = config.coded_size().height();
codec_context->pix_fmt = VideoFormatToPixelFormat(config.format());