Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: media/base/mime_util_internal.cc

Issue 2723833002: WebM support for new multipart VP9 string. (Closed)
Patch Set: Use latest ordering (9 parts), Plumb eotf to media client Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/mime_util_internal.cc
diff --git a/media/base/mime_util_internal.cc b/media/base/mime_util_internal.cc
index 2172a63ca365f04a8c3d43710779172b596868fb..07325ba9ab1ed0f59c525257bcaf9be83d8a3ad3 100644
--- a/media/base/mime_util_internal.cc
+++ b/media/base/mime_util_internal.cc
@@ -85,15 +85,21 @@ const std::map<std::string, MimeUtil::Codec>& GetStringToCodecMap() {
static bool ParseVp9CodecID(const std::string& mime_type_lower_case,
const std::string& codec_id,
VideoCodecProfile* out_profile,
- uint8_t* out_level) {
+ uint8_t* out_level,
+ gfx::ColorSpace::TransferID* out_eotf) {
+ LOG(ERROR) << __func__;
if (mime_type_lower_case == "video/mp4") {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableVp9InMp4)) {
- return ParseNewStyleVp9CodecID(codec_id, out_profile, out_level);
+ // Only new style is allowed for mp4.
+ return ParseNewStyleVp9CodecID(codec_id, out_profile, out_level,
+ out_eotf);
}
} else if (mime_type_lower_case == "video/webm") {
- // Only legacy codec strings are supported in WebM.
- // TODO(kqyang): Should we support new codec string in WebM?
+ // Both styles allowed for WebM.
+ if (ParseNewStyleVp9CodecID(codec_id, out_profile, out_level, out_eotf))
+ return true;
+
return ParseLegacyVp9CodecID(codec_id, out_profile, out_level);
}
return false;
@@ -163,9 +169,10 @@ SupportsType MimeUtil::AreSupportedCodecs(
Codec codec = INVALID_CODEC;
VideoCodecProfile video_profile = VIDEO_CODEC_PROFILE_UNKNOWN;
uint8_t video_level = 0;
+ gfx::ColorSpace::TransferID eotf = gfx::ColorSpace::TransferID::INVALID;
if (!ParseCodecString(mime_type_lower_case, codecs[i], &codec,
- &ambiguous_codec_string, &video_profile,
- &video_level)) {
+ &ambiguous_codec_string, &video_profile, &video_level,
+ &eotf)) {
return IsNotSupported;
}
@@ -189,8 +196,9 @@ SupportsType MimeUtil::AreSupportedCodecs(
}
// Check platform support.
- SupportsType result = IsCodecSupported(
- mime_type_lower_case, codec, video_profile, video_level, is_encrypted);
+ SupportsType result =
+ IsCodecSupported(mime_type_lower_case, codec, video_profile,
+ video_level, eotf, is_encrypted);
if (result == IsNotSupported)
return IsNotSupported;
@@ -546,7 +554,8 @@ bool MimeUtil::ParseCodecString(const std::string& mime_type_lower_case,
Codec* codec,
bool* ambiguous_codec_string,
VideoCodecProfile* out_profile,
- uint8_t* out_level) const {
+ uint8_t* out_level,
+ gfx::ColorSpace::TransferID* out_eotf) const {
DCHECK_EQ(base::ToLowerASCII(mime_type_lower_case), mime_type_lower_case);
DCHECK(codec);
DCHECK(out_profile);
@@ -557,6 +566,11 @@ bool MimeUtil::ParseCodecString(const std::string& mime_type_lower_case,
*out_profile = VIDEO_CODEC_PROFILE_UNKNOWN;
*out_level = 0;
+ // Most codec strings do not yet specify EOTF. We choose 709 as default color
+ // space elsewhere, so defaulting to 709 EOTF as well. See here for context:
+ // https://crrev.com/1221903003/
+ *out_eotf = gfx::ColorSpace::TransferID::BT709;
+
std::map<std::string, Codec>::const_iterator itr =
GetStringToCodecMap().find(codec_id);
if (itr != GetStringToCodecMap().end()) {
@@ -583,7 +597,9 @@ bool MimeUtil::ParseCodecString(const std::string& mime_type_lower_case,
// either VP9, H.264 or HEVC/H.265 codec ID because currently those are the
// only ones that are not added to the |kStringToCodecMap| and require
// parsing.
- if (ParseVp9CodecID(mime_type_lower_case, codec_id, out_profile, out_level)) {
+
+ if (ParseVp9CodecID(mime_type_lower_case, codec_id, out_profile, out_level,
+ out_eotf)) {
*codec = MimeUtil::VP9;
return true;
}
@@ -614,9 +630,9 @@ SupportsType MimeUtil::IsSimpleCodecSupported(
// be specified. There is no "default" video codec for a given container.
DCHECK_EQ(MimeUtilToVideoCodec(codec), kUnknownVideoCodec);
- SupportsType result =
- IsCodecSupported(mime_type_lower_case, codec, VIDEO_CODEC_PROFILE_UNKNOWN,
- 0 /* video_level */, is_encrypted);
+ SupportsType result = IsCodecSupported(
+ mime_type_lower_case, codec, VIDEO_CODEC_PROFILE_UNKNOWN,
+ 0 /* video_level */, gfx::ColorSpace::TransferID::INVALID, is_encrypted);
// Platform support should never be ambiguous for simple codecs (no range of
// profiles to consider).
@@ -628,6 +644,7 @@ SupportsType MimeUtil::IsCodecSupported(const std::string& mime_type_lower_case,
Codec codec,
VideoCodecProfile video_profile,
uint8_t video_level,
+ gfx::ColorSpace::TransferID eotf,
bool is_encrypted) const {
DCHECK_EQ(base::ToLowerASCII(mime_type_lower_case), mime_type_lower_case);
DCHECK_NE(codec, INVALID_CODEC);
@@ -677,7 +694,7 @@ SupportsType MimeUtil::IsCodecSupported(const std::string& mime_type_lower_case,
if (GetMediaClient() && video_codec != kUnknownVideoCodec &&
!GetMediaClient()->IsSupportedVideoConfig(video_codec, video_profile,
- video_level)) {
+ video_level, eotf)) {
return IsNotSupported;
}

Powered by Google App Engine
This is Rietveld 408576698