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

Unified Diff: media/base/mime_util_internal.cc

Issue 1624703002: Implement support for vp9 in ISO-BMFF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « media/base/mime_util_internal.h ('k') | media/base/mime_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/mime_util_internal.cc
diff --git a/media/base/mime_util_internal.cc b/media/base/mime_util_internal.cc
index a0ce3c4951698d5f3f101f1d0cb4f866b4ca7ac3..fcc9df3694ae646cb477e484c1fb666b9366ddb8 100644
--- a/media/base/mime_util_internal.cc
+++ b/media/base/mime_util_internal.cc
@@ -45,6 +45,7 @@ struct MediaFormat {
// avc1.42E0xx - H.264 Baseline
// avc1.4D40xx - H.264 Main
// avc1.6400xx - H.264 High
+// vp09.... - VP9
static const char kMP4AudioCodecsExpression[] =
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
@@ -66,6 +67,11 @@ static const char kMP4VideoCodecsExpression[] =
// are parsed and mapped to MimeUtil::Codec enum values.
"hev1.1.6.L93.B0,"
#endif
+#if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+ // This is not a complete list of supported vp9 codecs. Similar to avc1
ddorwin 2016/04/06 01:43:42 FYI, this code has changed significantly this week
kqyang 2016/04/18 22:23:14 Done. Thanks.
+ // comments above.
+ "vp09.00.00.08.00.01.00.00,"
+#endif
"mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
#if BUILDFLAG(ENABLE_AC3_EAC3_AUDIO_DEMUXING)
// Only one variant each of ac3 and eac3 codec string is sufficient here,
@@ -127,6 +133,8 @@ static const CodecIDMappings kUnambiguousCodecStringMap[] = {
{"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
// avc1/avc3.XXXXXX may be unambiguous; handled by ParseAVCCodecId().
// hev1/hvc1.XXXXXX may be unambiguous; handled by ParseHEVCCodecID().
+ // vp9, vp9.0, vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by
+ // ParseVp9CodecID().
{"mp3", MimeUtil::MP3},
{"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
{"mp4a.67", MimeUtil::MPEG2_AAC_LC},
@@ -156,8 +164,6 @@ static const CodecIDMappings kUnambiguousCodecStringMap[] = {
{"opus", MimeUtil::OPUS},
{"vp8", MimeUtil::VP8},
{"vp8.0", MimeUtil::VP8},
- {"vp9", MimeUtil::VP9},
- {"vp9.0", MimeUtil::VP9},
{"theora", MimeUtil::THEORA}};
// List of codec IDs that are ambiguous and don't provide
@@ -267,6 +273,84 @@ static bool ParseHEVCCodecID(const std::string& codec_id,
}
#endif
+// Handle parsing of vp9 codec IDs.
+static bool ParseVp9CodecID(const std::string& mime_type_lower_case,
+ const std::string& codec_id,
+ MimeUtil::Codec* codec) {
+ if (mime_type_lower_case == "video/webm") {
+ if (codec_id == "vp9" || codec_id == "vp9.0") {
+ *codec = MimeUtil::VP9;
+ return true;
+ }
+ // TODO(kqyang): Should we support new codec string in WebM?
+ return false;
+ } else if (mime_type_lower_case == "audio/webm") {
+ return false;
+ }
+
+#if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+ std::vector<std::string> fields = base::SplitString(
+ codec_id, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
+ if (fields.size() < 1)
+ return false;
+
+ if (fields[0] == "vp09") {
+ *codec = MimeUtil::VP9;
+ } else {
+ return false;
+ }
+
+ if (fields.size() > 8)
+ return false;
+
+ std::vector<int> values;
+ for (size_t i = 1; i < fields.size(); ++i) {
+ // Missing value is not allowed.
+ if (fields[i] == "")
+ return false;
+ int value;
+ if (!base::StringToInt(fields[i], &value))
+ return false;
+ if (value < 0)
+ return false;
+ values.push_back(value);
+ }
+
+ // The spec specifies 8 fields (7 values excluding the first codec field).
+ // We do not allow missing fields.
+ if (values.size() < 7)
+ return false;
+
+ const int profile = values[0];
+ if (profile > 3)
+ return false;
+
+ const int bit_depth = values[2];
+ if (bit_depth != 8 && bit_depth != 10 && bit_depth != 12)
+ return false;
+
+ const int color_space = values[3];
+ if (color_space > 7)
+ return false;
+
+ const int chroma_subsampling = values[4];
+ if (chroma_subsampling > 3)
+ return false;
+
+ const int transfer_function = values[5];
+ if (transfer_function > 1)
+ return false;
+
+ const int video_full_range_flag = values[6];
+ if (video_full_range_flag > 1)
+ return false;
+
+ return true;
+#else
+ return false;
+#endif // #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+}
+
MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
#if defined(OS_ANDROID)
platform_info_.is_unified_media_pipeline_enabled =
@@ -301,7 +385,7 @@ SupportsType MimeUtil::AreSupportedCodecs(
for (size_t i = 0; i < codecs.size(); ++i) {
bool is_ambiguous = true;
Codec codec = INVALID_CODEC;
- if (!StringToCodec(codecs[i], &codec, &is_ambiguous))
+ if (!StringToCodec(mime_type_lower_case, codecs[i], &codec, &is_ambiguous))
return IsNotSupported;
if (!IsCodecSupported(codec, mime_type_lower_case, is_encrypted) ||
@@ -342,7 +426,8 @@ void MimeUtil::InitializeMimeTypeMaps() {
for (size_t j = 0; j < mime_type_codecs.size(); ++j) {
Codec codec = INVALID_CODEC;
bool is_ambiguous = true;
- CHECK(StringToCodec(mime_type_codecs[j], &codec, &is_ambiguous));
+ CHECK(StringToCodec(kFormatCodecMappings[i].mime_type,
+ mime_type_codecs[j], &codec, &is_ambiguous));
DCHECK(!is_ambiguous);
codecs.insert(codec);
}
@@ -544,15 +629,23 @@ bool MimeUtil::IsCodecSupportedOnPlatform(
if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled)
return true;
- // Otherwise, platform support is required.
- return platform_info.supports_vp9;
+ if (!platform_info.supports_vp9)
+ return false;
+
+ // Encrypted content is demuxed so the container is irrelevant.
+ if (is_encrypted)
+ return true;
+
+ // MediaPlayer only supports VP9 in WebM.
+ return mime_type_lower_case == "video/webm";
}
}
return false;
}
-bool MimeUtil::StringToCodec(const std::string& codec_id,
+bool MimeUtil::StringToCodec(const std::string& mime_type_lower_case,
+ const std::string& codec_id,
Codec* codec,
bool* is_ambiguous) const {
StringToCodecMappings::const_iterator itr =
@@ -584,6 +677,11 @@ bool MimeUtil::StringToCodec(const std::string& codec_id,
return true;
}
+ if (ParseVp9CodecID(mime_type_lower_case, codec_id, codec)) {
+ *is_ambiguous = false;
+ return true;
+ }
+
DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id;
return false;
}
« no previous file with comments | « media/base/mime_util_internal.h ('k') | media/base/mime_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698