Skip to content

Commit

Permalink
Add 4 VP9 profiles to the media::VideoCodecProfile enum.
Browse files Browse the repository at this point in the history
Currently media/ code doesn't handle any of the VP9 profiles, it just
ignores the existence of different VP9 bitstream profiles and bundles
them all together under VP9PROFILE_ANY.
We know that there are actually 4 different VP9 profiles (see enum
BITSTREAM_PROFILE definition in vp9_enums.h). So at the very least we
should provide 4 values in the media::VideoCodecProfile enum to be able
to distinguish different VP9 profiles.

BUG=592074
CQ_INCLUDE_TRYBOTS=tryserver.chromium.win:win_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel

Review URL: https://codereview.chromium.org/1769593002

Cr-Commit-Position: refs/heads/master@{#384464}
  • Loading branch information
servolk authored and Commit bot committed Apr 1, 2016
1 parent a8c1784 commit dca5e25
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 44 deletions.
10 changes: 8 additions & 2 deletions chromecast/media/cma/base/decoder_config_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ VideoProfile ToVideoProfile(const ::media::VideoCodecProfile codec_profile) {
return kH264MultiviewHigh;
case ::media::VP8PROFILE_ANY:
return kVP8ProfileAny;
case ::media::VP9PROFILE_ANY:
return kVP9ProfileAny;
case ::media::VP9PROFILE_PROFILE0:
return kVP9Profile0;
case ::media::VP9PROFILE_PROFILE1:
return kVP9Profile1;
case ::media::VP9PROFILE_PROFILE2:
return kVP9Profile2;
case ::media::VP9PROFILE_PROFILE3:
return kVP9Profile3;
default:
LOG(INFO) << "Unsupported video codec profile " << codec_profile;
}
Expand Down
5 changes: 4 additions & 1 deletion chromecast/public/media/decoder_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ enum VideoProfile : int {
kH264Stereohigh,
kH264MultiviewHigh,
kVP8ProfileAny,
kVP9ProfileAny,
kVP9Profile0,
kVP9Profile1,
kVP9Profile2,
kVP9Profile3,
kDolbyVisionCompatible_EL_MD,
kDolbyVisionCompatible_BL_EL_MD,
kDolbyVisionNonCompatible_BL_MD,
Expand Down
8 changes: 7 additions & 1 deletion content/common/gpu/media/android_video_decode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,6 @@ AndroidVideoDecodeAccelerator::GetCapabilities(
}

if (media::PlatformHasVp9Support()) {
profile.profile = media::VP9PROFILE_ANY;
profile.min_resolution.SetSize(0, 0);
profile.max_resolution.SetSize(1920, 1088);
// If we know MediaCodec will just create a software codec, prefer our
Expand All @@ -1159,6 +1158,13 @@ AndroidVideoDecodeAccelerator::GetCapabilities(
// the buffers and let us use our internal software decoders.
profile.encrypted_only = media::VideoCodecBridge::IsKnownUnaccelerated(
media::kCodecVP9, media::MEDIA_CODEC_DECODER);
profile.profile = media::VP9PROFILE_PROFILE0;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE1;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE2;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE3;
profiles.push_back(profile);
}

Expand Down
10 changes: 8 additions & 2 deletions content/common/gpu/media/dxva_video_decode_accelerator_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ static const media::VideoCodecProfile kSupportedProfiles[] = {
media::H264PROFILE_MAIN,
media::H264PROFILE_HIGH,
media::VP8PROFILE_ANY,
media::VP9PROFILE_ANY
media::VP9PROFILE_PROFILE0,
media::VP9PROFILE_PROFILE1,
media::VP9PROFILE_PROFILE2,
media::VP9PROFILE_PROFILE3
};

CreateDXGIDeviceManager DXVAVideoDecodeAccelerator::create_dxgi_device_manager_
Expand Down Expand Up @@ -1406,7 +1409,10 @@ bool DXVAVideoDecodeAccelerator::InitDecoder(media::VideoCodecProfile profile) {
clsid = __uuidof(CMSH264DecoderMFT);
} else if (enable_accelerated_vpx_decode_ &&
(profile == media::VP8PROFILE_ANY ||
profile == media::VP9PROFILE_ANY)) {
profile == media::VP9PROFILE_PROFILE0 ||
profile == media::VP9PROFILE_PROFILE1 ||
profile == media::VP9PROFILE_PROFILE2 ||
profile == media::VP9PROFILE_PROFILE3)) {
int program_files_key = base::DIR_PROGRAM_FILES;
if (base::win::OSInfo::GetInstance()->wow64_status() ==
base::win::OSInfo::WOW64_ENABLED) {
Expand Down
5 changes: 4 additions & 1 deletion content/common/gpu/media/gpu_video_accelerator_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ STATIC_ASSERT_ENUM_MATCH(H264PROFILE_SCALABLEHIGH);
STATIC_ASSERT_ENUM_MATCH(H264PROFILE_STEREOHIGH);
STATIC_ASSERT_ENUM_MATCH(H264PROFILE_MULTIVIEWHIGH);
STATIC_ASSERT_ENUM_MATCH(VP8PROFILE_ANY);
STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_ANY);
STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE0);
STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE1);
STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE2);
STATIC_ASSERT_ENUM_MATCH(VP9PROFILE_PROFILE3);
STATIC_ASSERT_ENUM_MATCH(VIDEO_CODEC_PROFILE_MAX);

// static
Expand Down
8 changes: 7 additions & 1 deletion content/common/gpu/media/v4l2_video_encode_accelerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,13 @@ V4L2VideoEncodeAccelerator::GetSupportedProfiles() {
profiles.push_back(profile);
break;
case V4L2_PIX_FMT_VP9:
profile.profile = media::VP9PROFILE_ANY;
profile.profile = media::VP9PROFILE_PROFILE0;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE1;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE2;
profiles.push_back(profile);
profile.profile = media::VP9PROFILE_PROFILE3;
profiles.push_back(profile);
break;
}
Expand Down
4 changes: 3 additions & 1 deletion content/common/gpu/media/vaapi_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ static const ProfileMap kProfileMap[] = {
// media::H264PROFILE_HIGH*.
{media::H264PROFILE_HIGH, VAProfileH264High},
{media::VP8PROFILE_ANY, VAProfileVP8Version0_3},
{media::VP9PROFILE_ANY, VAProfileVP9Profile0},
// TODO(servolk): Need to add VP9 profiles 1,2,3 here after rolling
// third_party/libva to 1.7. crbug.com/598118
{media::VP9PROFILE_PROFILE0, VAProfileVP9Profile0},
};

static std::vector<VAConfigAttrib> GetRequiredAttribs(
Expand Down
5 changes: 4 additions & 1 deletion content/renderer/pepper/content_decryptor_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ PP_VideoCodecProfile MediaVideoCodecProfileToPpVideoCodecProfile(
media::VideoCodecProfile profile) {
switch (profile) {
case media::VP8PROFILE_ANY:
case media::VP9PROFILE_ANY:
case media::VP9PROFILE_PROFILE0:
case media::VP9PROFILE_PROFILE1:
case media::VP9PROFILE_PROFILE2:
case media::VP9PROFILE_PROFILE3:
return PP_VIDEOCODECPROFILE_NOT_NEEDED;
case media::H264PROFILE_BASELINE:
return PP_VIDEOCODECPROFILE_H264_BASELINE;
Expand Down
2 changes: 1 addition & 1 deletion content/renderer/pepper/pepper_video_decoder_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ media::VideoCodecProfile PepperToMediaVideoProfile(PP_VideoProfile profile) {
case PP_VIDEOPROFILE_VP8_ANY:
return media::VP8PROFILE_ANY;
case PP_VIDEOPROFILE_VP9_ANY:
return media::VP9PROFILE_ANY;
return media::VP9PROFILE_PROFILE0;
// No default case, to catch unhandled PP_VideoProfile values.
}

Expand Down
9 changes: 7 additions & 2 deletions content/renderer/pepper/pepper_video_encoder_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ media::VideoCodecProfile PP_ToMediaVideoProfile(PP_VideoProfile profile) {
case PP_VIDEOPROFILE_VP8_ANY:
return media::VP8PROFILE_ANY;
case PP_VIDEOPROFILE_VP9_ANY:
return media::VP9PROFILE_ANY;
return media::VP9PROFILE_PROFILE0;
// No default case, to catch unhandled PP_VideoProfile values.
}
return media::VIDEO_CODEC_PROFILE_UNKNOWN;
Expand Down Expand Up @@ -112,7 +112,7 @@ PP_VideoProfile PP_FromMediaVideoProfile(media::VideoCodecProfile profile) {
return PP_VIDEOPROFILE_H264MULTIVIEWHIGH;
case media::VP8PROFILE_ANY:
return PP_VIDEOPROFILE_VP8_ANY;
case media::VP9PROFILE_ANY:
case media::VP9PROFILE_PROFILE0:
return PP_VIDEOPROFILE_VP9_ANY;
default:
NOTREACHED();
Expand Down Expand Up @@ -454,6 +454,11 @@ void PepperVideoEncoderHost::GetSupportedProfiles(
profiles = GpuVideoAcceleratorUtil::ConvertGpuToMediaEncodeProfiles(
channel_->gpu_info().video_encode_accelerator_supported_profiles);
for (media::VideoEncodeAccelerator::SupportedProfile profile : profiles) {
if (profile.profile == media::VP9PROFILE_PROFILE1 ||
profile.profile == media::VP9PROFILE_PROFILE2 ||
profile.profile == media::VP9PROFILE_PROFILE3) {
continue;
}
pp_profiles->push_back(
PP_FromVideoEncodeAcceleratorSupportedProfile(profile, PP_TRUE));
}
Expand Down
18 changes: 13 additions & 5 deletions content/renderer/pepper/video_encoder_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ void GetVpxCodecParameters(media::VideoCodecProfile codec,
*max_quantizer = kVp8DefaultMaxQuantizer;
*cpu_used = kVp8DefaultCpuUsed;
break;
case media::VP9PROFILE_ANY:
// Only VP9 profile 0 is supported by PPAPI at the moment. VP9 profiles 1-3
// are not supported due to backward compatibility.
case media::VP9PROFILE_PROFILE0:
*vpx_codec = vpx_codec_vp9_cx();
*min_quantizer = kVp9DefaultMinQuantizer;
*max_quantizer = kVp9DefaultMaxQuantizer;
Expand Down Expand Up @@ -165,6 +167,12 @@ void VideoEncoderShim::EncoderImpl::Initialize(
gfx::Size coded_size =
media::VideoFrame::PlaneSize(input_format, 0, input_visible_size);

// Only VP9 profile 0 is supported by PPAPI at the moment. VP9 profiles 1-3
// are not supported due to backward compatibility.
DCHECK_NE(output_profile, media::VP9PROFILE_PROFILE1);
DCHECK_NE(output_profile, media::VP9PROFILE_PROFILE2);
DCHECK_NE(output_profile, media::VP9PROFILE_PROFILE3);

vpx_codec_iface_t* vpx_codec;
int32_t min_quantizer, max_quantizer, cpu_used;
GetVpxCodecParameters(output_profile, &vpx_codec, &min_quantizer,
Expand Down Expand Up @@ -196,7 +204,7 @@ void VideoEncoderShim::EncoderImpl::Initialize(
// Use Q/CQ mode if no target bitrate is given. Note that in the VP8/CQ case
// the meaning of rc_target_bitrate changes to target maximum rate.
if (initial_bitrate == 0) {
if (output_profile == media::VP9PROFILE_ANY) {
if (output_profile == media::VP9PROFILE_PROFILE0) {
config_.rc_end_usage = VPX_Q;
} else if (output_profile == media::VP8PROFILE_ANY) {
config_.rc_end_usage = VPX_CQ;
Expand All @@ -223,7 +231,7 @@ void VideoEncoderShim::EncoderImpl::Initialize(
return;
}

if (output_profile == media::VP9PROFILE_ANY) {
if (output_profile == media::VP9PROFILE_PROFILE0) {
if (vpx_codec_control(&encoder_, VP9E_SET_AQ_MODE,
kVp9AqModeCyclicRefresh) != VPX_CODEC_OK) {
NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
Expand Down Expand Up @@ -389,10 +397,10 @@ VideoEncoderShim::GetSupportedProfiles() {
ret = vpx_codec_enc_config_default(vpx_codec_vp9_cx(), &config, 0);
if (ret == VPX_CODEC_OK) {
media::VideoEncodeAccelerator::SupportedProfile profile;
profile.profile = media::VP9PROFILE_ANY;
profile.max_resolution = gfx::Size(kMaxWidth, kMaxHeight);
profile.max_framerate_numerator = config.g_timebase.den;
profile.max_framerate_denominator = config.g_timebase.num;
profile.profile = media::VP9PROFILE_PROFILE0;
profiles.push_back(profile);
}

Expand All @@ -412,7 +420,7 @@ bool VideoEncoderShim::Initialize(
return false;

if (output_profile != media::VP8PROFILE_ANY &&
output_profile != media::VP9PROFILE_ANY)
output_profile != media::VP9PROFILE_PROFILE0)
return false;

media_task_runner_->PostTask(
Expand Down
29 changes: 16 additions & 13 deletions gpu/config/gpu_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,22 @@ enum VideoCodecProfile {
VIDEO_CODEC_PROFILE_UNKNOWN = -1,
VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
H264PROFILE_BASELINE = 0,
H264PROFILE_MAIN = 1,
H264PROFILE_EXTENDED = 2,
H264PROFILE_HIGH = 3,
H264PROFILE_HIGH10PROFILE = 4,
H264PROFILE_HIGH422PROFILE = 5,
H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
H264PROFILE_SCALABLEBASELINE = 7,
H264PROFILE_SCALABLEHIGH = 8,
H264PROFILE_STEREOHIGH = 9,
H264PROFILE_MULTIVIEWHIGH = 10,
VP8PROFILE_ANY = 11,
VP9PROFILE_ANY = 12,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_ANY,
H264PROFILE_MAIN,
H264PROFILE_EXTENDED,
H264PROFILE_HIGH,
H264PROFILE_HIGH10PROFILE,
H264PROFILE_HIGH422PROFILE,
H264PROFILE_HIGH444PREDICTIVEPROFILE,
H264PROFILE_SCALABLEBASELINE,
H264PROFILE_SCALABLEHIGH,
H264PROFILE_STEREOHIGH,
H264PROFILE_MULTIVIEWHIGH,
VP8PROFILE_ANY,
VP9PROFILE_PROFILE0,
VP9PROFILE_PROFILE1,
VP9PROFILE_PROFILE2,
VP9PROFILE_PROFILE3,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_PROFILE3,
};

// Specification of a decoding profile supported by a hardware decoder.
Expand Down
10 changes: 8 additions & 2 deletions media/base/video_codecs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ std::string GetProfileName(VideoCodecProfile profile) {
return "h264 multiview high";
case VP8PROFILE_ANY:
return "vp8";
case VP9PROFILE_ANY:
return "vp9";
case VP9PROFILE_PROFILE0:
return "vp9 profile0";
case VP9PROFILE_PROFILE1:
return "vp9 profile1";
case VP9PROFILE_PROFILE2:
return "vp9 profile2";
case VP9PROFILE_PROFILE3:
return "vp9 profile3";
}
NOTREACHED();
return "";
Expand Down
7 changes: 5 additions & 2 deletions media/base/video_codecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ enum VideoCodecProfile {
VP8PROFILE_ANY = VP8PROFILE_MIN,
VP8PROFILE_MAX = VP8PROFILE_ANY,
VP9PROFILE_MIN = 12,
VP9PROFILE_ANY = VP9PROFILE_MIN,
VP9PROFILE_MAX = VP9PROFILE_ANY,
VP9PROFILE_PROFILE0 = VP9PROFILE_MIN,
VP9PROFILE_PROFILE1 = 13,
VP9PROFILE_PROFILE2 = 14,
VP9PROFILE_PROFILE3 = 15,
VP9PROFILE_MAX = VP9PROFILE_PROFILE3,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_MAX,
};

Expand Down
5 changes: 4 additions & 1 deletion media/base/video_decoder_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ VideoCodec VideoCodecProfileToVideoCodec(VideoCodecProfile profile) {
return kCodecH264;
case VP8PROFILE_ANY:
return kCodecVP8;
case VP9PROFILE_ANY:
case VP9PROFILE_PROFILE0:
case VP9PROFILE_PROFILE1:
case VP9PROFILE_PROFILE2:
case VP9PROFILE_PROFILE3:
return kCodecVP9;
}
NOTREACHED();
Expand Down
9 changes: 8 additions & 1 deletion media/cdm/cdm_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ cdm::VideoDecoderConfig::VideoCodecProfile ToCdmVideoCodecProfile(
VideoCodecProfile profile) {
switch (profile) {
case VP8PROFILE_ANY:
case VP9PROFILE_ANY:
// TODO(servolk): See crbug.com/592074. We'll need to update this code to
// handle different VP9 profiles properly after adding VP9 profiles in
// media/cdm/api/content_decryption_module.h in a separate CL.
// For now return kProfileNotNeeded to avoid breaking unit tests.
case VP9PROFILE_PROFILE0:
case VP9PROFILE_PROFILE1:
case VP9PROFILE_PROFILE2:
case VP9PROFILE_PROFILE3:
return cdm::VideoDecoderConfig::kProfileNotNeeded;
case H264PROFILE_BASELINE:
return cdm::VideoDecoderConfig::kH264ProfileBaseline;
Expand Down
4 changes: 3 additions & 1 deletion media/ffmpeg/ffmpeg_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
if (codec == kCodecVP8)
profile = VP8PROFILE_ANY;
else if (codec == kCodecVP9)
profile = VP9PROFILE_ANY;
// TODO(servolk): Find a way to obtain actual VP9 profile from FFmpeg.
// crbug.com/592074
profile = VP9PROFILE_PROFILE0;
else
profile = ProfileIDToVideoCodecProfile(stream->codec->profile);

Expand Down
4 changes: 3 additions & 1 deletion media/formats/webm/webm_video_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ bool WebMVideoClient::InitializeConfig(
profile = VP8PROFILE_ANY;
} else if (codec_id == "V_VP9") {
video_codec = kCodecVP9;
profile = VP9PROFILE_ANY;
// TODO(servolk): Find a way to read actual VP9 profile from WebM.
// crbug.com/592074
profile = VP9PROFILE_PROFILE0;
} else {
MEDIA_LOG(ERROR, media_log_) << "Unsupported video codec_id " << codec_id;
return false;
Expand Down
5 changes: 4 additions & 1 deletion media/mojo/common/media_type_converters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_MIN);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_ANY);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP8PROFILE_MAX);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_MIN);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_ANY);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_PROFILE0);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_PROFILE1);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_PROFILE2);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_PROFILE3);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VP9PROFILE_MAX);
ASSERT_ENUM_EQ(VideoCodecProfile, , , VIDEO_CODEC_PROFILE_MAX);

Expand Down
9 changes: 6 additions & 3 deletions media/mojo/interfaces/media_types.mojom
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ enum VideoCodecProfile {
VP8PROFILE_MIN = 11,
VP8PROFILE_ANY = VP8PROFILE_MIN,
VP8PROFILE_MAX = VP8PROFILE_ANY,
VP9PROFILE_MIN = 12,
VP9PROFILE_ANY = VP9PROFILE_MIN,
VP9PROFILE_MAX = VP9PROFILE_ANY,
VP9PROFILE_MIN,
VP9PROFILE_PROFILE0 = VP9PROFILE_MIN,
VP9PROFILE_PROFILE1,
VP9PROFILE_PROFILE2,
VP9PROFILE_PROFILE3,
VP9PROFILE_MAX = VP9PROFILE_PROFILE3,
VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_MAX,
};

Expand Down
5 changes: 4 additions & 1 deletion tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84647,7 +84647,10 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="9" label="H.264 StereoHigh"/>
<int value="10" label="H.264 MultiviewHigh"/>
<int value="11" label="VP8"/>
<int value="12" label="VP9"/>
<int value="12" label="VP9 Profile0"/>
<int value="13" label="VP9 Profile1"/>
<int value="14" label="VP9 Profile2"/>
<int value="15" label="VP9 Profile3"/>
</enum>

<enum name="VideoDecodeAcceleratorError" type="int">
Expand Down

0 comments on commit dca5e25

Please sign in to comment.