Commit 32e06ae2 authored by Chris Cunningham's avatar Chris Cunningham Committed by Commit Bot

Map codec profiles for "simple" video mime types

All supported video streams types should map to some VideoCodecProfile.
This should be true even for "simple" codecs strings (e.g. VP8 and
Theora) that only have one profile (or no formal notion of profile).

This allows all codecs to be described simply by the VideoCodecProfile.
For instance, media capabilities storage/querying of decode statistics
is keyed by VideoCodecProfile.

This change adds a profile entry for Theora and ensures that mime
parsing code correctly maps to a profile for VP8 and Theora.

BUG=695264
TEST=unit test

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I7b48dfc6ab97d436820dae57606a4cf53d92af31
Reviewed-on: https://chromium-review.googlesource.com/658408Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501512}
parent 6d5912a3
...@@ -56,7 +56,10 @@ enum VideoCodecProfile { ...@@ -56,7 +56,10 @@ enum VideoCodecProfile {
DOLBYVISION_PROFILE5 = 21, DOLBYVISION_PROFILE5 = 21,
DOLBYVISION_PROFILE7 = 22, DOLBYVISION_PROFILE7 = 22,
DOLBYVISION_MAX = DOLBYVISION_PROFILE7, DOLBYVISION_MAX = DOLBYVISION_PROFILE7,
VIDEO_CODEC_PROFILE_MAX = DOLBYVISION_MAX, THEORAPROFILE_MIN = 23,
THEORAPROFILE_ANY = THEORAPROFILE_MIN,
THEORAPROFILE_MAX = THEORAPROFILE_ANY,
VIDEO_CODEC_PROFILE_MAX = THEORAPROFILE_ANY,
}; };
// Specification of an encoding profile supported by an encoder. // Specification of an encoding profile supported by an encoder.
......
...@@ -113,6 +113,9 @@ CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE4); ...@@ -113,6 +113,9 @@ CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE4);
CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE5); CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE5);
CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE7); CHECK_PROFILE_ENUM(DOLBYVISION_PROFILE7);
CHECK_PROFILE_ENUM(DOLBYVISION_MAX); CHECK_PROFILE_ENUM(DOLBYVISION_MAX);
CHECK_PROFILE_ENUM(THEORAPROFILE_MIN);
CHECK_PROFILE_ENUM(THEORAPROFILE_ANY);
CHECK_PROFILE_ENUM(THEORAPROFILE_MAX);
CHECK_PROFILE_ENUM(VIDEO_CODEC_PROFILE_MAX); CHECK_PROFILE_ENUM(VIDEO_CODEC_PROFILE_MAX);
#undef CHECK_PROFILE_ENUM #undef CHECK_PROFILE_ENUM
...@@ -153,6 +156,7 @@ bool EnumTraits<arc::mojom::VideoCodecProfile, media::VideoCodecProfile>:: ...@@ -153,6 +156,7 @@ bool EnumTraits<arc::mojom::VideoCodecProfile, media::VideoCodecProfile>::
case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE4: case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE4:
case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE5: case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE5:
case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7: case arc::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7:
case arc::mojom::VideoCodecProfile::THEORAPROFILE_ANY:
*output = static_cast<media::VideoCodecProfile>(input); *output = static_cast<media::VideoCodecProfile>(input);
return true; return true;
} }
......
...@@ -66,7 +66,8 @@ enum VideoCodecProfile { ...@@ -66,7 +66,8 @@ enum VideoCodecProfile {
DOLBYVISION_PROFILE4, DOLBYVISION_PROFILE4,
DOLBYVISION_PROFILE5, DOLBYVISION_PROFILE5,
DOLBYVISION_PROFILE7, DOLBYVISION_PROFILE7,
VIDEO_CODEC_PROFILE_MAX = DOLBYVISION_PROFILE7, THEORAPROFILE_ANY,
VIDEO_CODEC_PROFILE_MAX = THEORAPROFILE_ANY,
}; };
// Specification of a decoding profile supported by a hardware decoder. // Specification of a decoding profile supported by a hardware decoder.
......
...@@ -53,6 +53,7 @@ enum VideoCodecProfile { ...@@ -53,6 +53,7 @@ enum VideoCodecProfile {
DOLBYVISION_PROFILE4, DOLBYVISION_PROFILE4,
DOLBYVISION_PROFILE5, DOLBYVISION_PROFILE5,
DOLBYVISION_PROFILE7, DOLBYVISION_PROFILE7,
THEORAPROFILE_ANY,
}; };
// gpu::VideoDecodeAcceleratorSupportedProfile // gpu::VideoDecodeAcceleratorSupportedProfile
......
...@@ -114,6 +114,8 @@ EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::ToMojom( ...@@ -114,6 +114,8 @@ EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::ToMojom(
return gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE5; return gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE5;
case gpu::VideoCodecProfile::DOLBYVISION_PROFILE7: case gpu::VideoCodecProfile::DOLBYVISION_PROFILE7:
return gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7; return gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7;
case gpu::VideoCodecProfile::THEORAPROFILE_ANY:
return gpu::mojom::VideoCodecProfile::THEORAPROFILE_ANY;
} }
NOTREACHED() << "Invalid VideoCodecProfile:" << video_codec_profile; NOTREACHED() << "Invalid VideoCodecProfile:" << video_codec_profile;
return gpu::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN; return gpu::mojom::VideoCodecProfile::VIDEO_CODEC_PROFILE_UNKNOWN;
...@@ -196,6 +198,9 @@ bool EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>:: ...@@ -196,6 +198,9 @@ bool EnumTraits<gpu::mojom::VideoCodecProfile, gpu::VideoCodecProfile>::
case gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7: case gpu::mojom::VideoCodecProfile::DOLBYVISION_PROFILE7:
*out = gpu::VideoCodecProfile::DOLBYVISION_PROFILE7; *out = gpu::VideoCodecProfile::DOLBYVISION_PROFILE7;
return true; return true;
case gpu::mojom::VideoCodecProfile::THEORAPROFILE_ANY:
*out = gpu::VideoCodecProfile::THEORAPROFILE_ANY;
return true;
} }
NOTREACHED() << "Invalid VideoCodecProfile: " << input; NOTREACHED() << "Invalid VideoCodecProfile: " << input;
return false; return false;
......
...@@ -738,6 +738,21 @@ bool MimeUtil::ParseCodecHelper(const std::string& mime_type_lower_case, ...@@ -738,6 +738,21 @@ bool MimeUtil::ParseCodecHelper(const std::string& mime_type_lower_case,
GetStringToCodecMap().find(codec_id); GetStringToCodecMap().find(codec_id);
if (itr != GetStringToCodecMap().end()) { if (itr != GetStringToCodecMap().end()) {
out_result->codec = itr->second; out_result->codec = itr->second;
// Even "simple" video codecs should have an associated profile.
if (MimeUtilToVideoCodec(out_result->codec) != kUnknownVideoCodec) {
switch (out_result->codec) {
case Codec::VP8:
out_result->video_profile = VP8PROFILE_ANY;
break;
case Codec::THEORA:
out_result->video_profile = THEORAPROFILE_ANY;
break;
default:
NOTREACHED();
}
}
return true; return true;
} }
......
...@@ -370,6 +370,43 @@ TEST(MimeUtilTest, ParseAudioCodecString) { ...@@ -370,6 +370,43 @@ TEST(MimeUtilTest, ParseAudioCodecString) {
&out_codec)); &out_codec));
} }
// These codecs really only have one profile. Ensure that |out_profile| is
// correctly mapped.
TEST(MimeUtilTest, ParseVideoCodecString_SimpleCodecsHaveProfiles) {
bool out_is_ambiguous;
VideoCodec out_codec;
VideoCodecProfile out_profile;
uint8_t out_level;
VideoColorSpace out_colorspace;
// Valid VP8 string.
EXPECT_TRUE(ParseVideoCodecString("video/webm", "vp8", &out_is_ambiguous,
&out_codec, &out_profile, &out_level,
&out_colorspace));
EXPECT_FALSE(out_is_ambiguous);
EXPECT_EQ(kCodecVP8, out_codec);
EXPECT_EQ(VP8PROFILE_ANY, out_profile);
EXPECT_EQ(0, out_level);
EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace);
// Valid Theora string.
#if defined(OS_ANDROID)
// Theora not supported on Android.
EXPECT_FALSE(ParseVideoCodecString("video/ogg", "theora", &out_is_ambiguous,
&out_codec, &out_profile, &out_level,
&out_colorspace));
#else
EXPECT_TRUE(ParseVideoCodecString("video/ogg", "theora", &out_is_ambiguous,
&out_codec, &out_profile, &out_level,
&out_colorspace));
EXPECT_FALSE(out_is_ambiguous);
EXPECT_EQ(kCodecTheora, out_codec);
EXPECT_EQ(THEORAPROFILE_ANY, out_profile);
EXPECT_EQ(0, out_level);
EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace);
#endif
}
TEST(IsCodecSupportedOnAndroidTest, EncryptedCodecsFailWithoutPlatformSupport) { TEST(IsCodecSupportedOnAndroidTest, EncryptedCodecsFailWithoutPlatformSupport) {
// Vary all parameters except |has_platform_decoders|. // Vary all parameters except |has_platform_decoders|.
MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); MimeUtil::PlatformInfo states_to_vary = VaryAllFields();
......
...@@ -90,6 +90,8 @@ std::string GetProfileName(VideoCodecProfile profile) { ...@@ -90,6 +90,8 @@ std::string GetProfileName(VideoCodecProfile profile) {
return "dolby vision profile 5"; return "dolby vision profile 5";
case DOLBYVISION_PROFILE7: case DOLBYVISION_PROFILE7:
return "dolby vision profile 7"; return "dolby vision profile 7";
case THEORAPROFILE_ANY:
return "theora";
} }
NOTREACHED(); NOTREACHED();
return ""; return "";
......
...@@ -85,7 +85,10 @@ enum VideoCodecProfile { ...@@ -85,7 +85,10 @@ enum VideoCodecProfile {
DOLBYVISION_PROFILE5 = 21, DOLBYVISION_PROFILE5 = 21,
DOLBYVISION_PROFILE7 = 22, DOLBYVISION_PROFILE7 = 22,
DOLBYVISION_MAX = DOLBYVISION_PROFILE7, DOLBYVISION_MAX = DOLBYVISION_PROFILE7,
VIDEO_CODEC_PROFILE_MAX = DOLBYVISION_MAX, THEORAPROFILE_MIN = 23,
THEORAPROFILE_ANY = THEORAPROFILE_MIN,
THEORAPROFILE_MAX = THEORAPROFILE_ANY,
VIDEO_CODEC_PROFILE_MAX = THEORAPROFILE_ANY,
}; };
struct CodecProfileLevel { struct CodecProfileLevel {
......
...@@ -45,6 +45,8 @@ VideoCodec VideoCodecProfileToVideoCodec(VideoCodecProfile profile) { ...@@ -45,6 +45,8 @@ VideoCodec VideoCodecProfileToVideoCodec(VideoCodecProfile profile) {
case DOLBYVISION_PROFILE5: case DOLBYVISION_PROFILE5:
case DOLBYVISION_PROFILE7: case DOLBYVISION_PROFILE7:
return kCodecDolbyVision; return kCodecDolbyVision;
case THEORAPROFILE_ANY:
return kCodecTheora;
} }
NOTREACHED(); NOTREACHED();
return kUnknownVideoCodec; return kUnknownVideoCodec;
......
...@@ -471,6 +471,8 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream, ...@@ -471,6 +471,8 @@ bool AVStreamToVideoDecoderConfig(const AVStream* stream,
// TODO(servolk): Find a way to obtain actual VP9 profile from FFmpeg. // TODO(servolk): Find a way to obtain actual VP9 profile from FFmpeg.
// crbug.com/592074 // crbug.com/592074
profile = VP9PROFILE_PROFILE0; profile = VP9PROFILE_PROFILE0;
else if (codec == kCodecTheora)
profile = THEORAPROFILE_ANY;
else else
profile = ProfileIDToVideoCodecProfile(codec_context->profile); profile = ProfileIDToVideoCodecProfile(codec_context->profile);
......
...@@ -276,6 +276,7 @@ base::Optional<VideoCodecProfile> ToMediaVideoCodecProfile( ...@@ -276,6 +276,7 @@ base::Optional<VideoCodecProfile> ToMediaVideoCodecProfile(
CASE_RETURN_OTHER(DOLBYVISION_PROFILE4); CASE_RETURN_OTHER(DOLBYVISION_PROFILE4);
CASE_RETURN_OTHER(DOLBYVISION_PROFILE5); CASE_RETURN_OTHER(DOLBYVISION_PROFILE5);
CASE_RETURN_OTHER(DOLBYVISION_PROFILE7); CASE_RETURN_OTHER(DOLBYVISION_PROFILE7);
CASE_RETURN_OTHER(THEORAPROFILE_ANY);
} }
return base::nullopt; // Not a 'default' to ensure compile-time checks. return base::nullopt; // Not a 'default' to ensure compile-time checks.
} }
...@@ -309,6 +310,7 @@ ToProtoVideoDecoderConfigProfile(VideoCodecProfile value) { ...@@ -309,6 +310,7 @@ ToProtoVideoDecoderConfigProfile(VideoCodecProfile value) {
CASE_RETURN_OTHER(DOLBYVISION_PROFILE4); CASE_RETURN_OTHER(DOLBYVISION_PROFILE4);
CASE_RETURN_OTHER(DOLBYVISION_PROFILE5); CASE_RETURN_OTHER(DOLBYVISION_PROFILE5);
CASE_RETURN_OTHER(DOLBYVISION_PROFILE7); CASE_RETURN_OTHER(DOLBYVISION_PROFILE7);
CASE_RETURN_OTHER(THEORAPROFILE_ANY);
} }
return base::nullopt; // Not a 'default' to ensure compile-time checks. return base::nullopt; // Not a 'default' to ensure compile-time checks.
} }
......
...@@ -181,6 +181,7 @@ message VideoDecoderConfig { ...@@ -181,6 +181,7 @@ message VideoDecoderConfig {
DOLBYVISION_PROFILE4 = 20; DOLBYVISION_PROFILE4 = 20;
DOLBYVISION_PROFILE5 = 21; DOLBYVISION_PROFILE5 = 21;
DOLBYVISION_PROFILE7 = 22; DOLBYVISION_PROFILE7 = 22;
THEORAPROFILE_ANY = 23;
}; };
// Proto version of media::VideoPixelFormat. // Proto version of media::VideoPixelFormat.
......
...@@ -39363,6 +39363,7 @@ Called by update_traffic_annotation_histograms.py.--> ...@@ -39363,6 +39363,7 @@ Called by update_traffic_annotation_histograms.py.-->
<int value="20" label="DolbyVision profile4"/> <int value="20" label="DolbyVision profile4"/>
<int value="21" label="DolbyVision profile5"/> <int value="21" label="DolbyVision profile5"/>
<int value="22" label="DolbyVision profile7"/> <int value="22" label="DolbyVision profile7"/>
<int value="23" label="Theora"/>
</enum> </enum>
<enum name="VideoDecodeAcceleratorError"> <enum name="VideoDecodeAcceleratorError">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment