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

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, 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 a0ce3c4951698d5f3f101f1d0cb4f866b4ca7ac3..3e24dd363fc5ecbc4f318169e8c9e35b0a5b4dca 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
+ // 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().
+ // vp09.xx.xx.xx.xx.xx.xx.xx may be unambiguous; handled by
+ // ParseVpxCodecID().
ddorwin 2016/02/29 23:57:34 s/x/9/
kqyang 2016/03/01 01:18:52 Done.
{"mp3", MimeUtil::MP3},
{"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
{"mp4a.67", MimeUtil::MPEG2_AAC_LC},
@@ -267,6 +275,72 @@ static bool ParseHEVCCodecID(const std::string& codec_id,
}
#endif
+#if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+// Handle parsing of vp9 codec IDs.
+static bool ParseVp9CodecID(const std::string& codec_id,
+ MimeUtil::Codec* codec,
+ bool* is_ambiguous) {
ddorwin 2016/03/01 00:21:40 Since there are no ambiguous VPx strings (ignoring
kqyang 2016/03/01 01:18:52 Done.
+ 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)
ddorwin 2016/02/29 23:57:34 We'll need to actually check whether platform supp
+ 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;
+
+ *is_ambiguous = false;
+ return true;
+}
+#endif // #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+
MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
#if defined(OS_ANDROID)
platform_info_.is_unified_media_pipeline_enabled =
@@ -309,6 +383,16 @@ SupportsType MimeUtil::AreSupportedCodecs(
return IsNotSupported;
}
+#if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+ // VP9 is supported in mp4, but the old style codec string is not supported.
+ if ((mime_type_lower_case == "video/x-m4v" ||
+ mime_type_lower_case == "video/mp4") &&
+ codec == MimeUtil::VP9) {
ddorwin 2016/03/01 00:21:40 Check the enum first. As we discussed, should be m
kqyang 2016/03/01 01:18:52 No longer needed. Removed.
+ if (!ParseVp9CodecID(codecs[i], &codec, &is_ambiguous))
+ return IsNotSupported;
+ }
+#endif
+
if (is_ambiguous)
result = MayBeSupported;
}
@@ -584,6 +668,12 @@ bool MimeUtil::StringToCodec(const std::string& codec_id,
return true;
}
+#if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
+ if (ParseVp9CodecID(codec_id, codec, is_ambiguous)) {
+ return true;
+ }
+#endif
+
DVLOG(4) << __FUNCTION__ << ": Unrecognized codec id " << codec_id;
return false;
}

Powered by Google App Engine
This is Rietveld 408576698