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

Unified Diff: net/base/mime_util.cc

Issue 626163002: MSE: Relax H.264 Baseline mimetype profile recognition (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: net/base/mime_util.cc
diff --git a/net/base/mime_util.cc b/net/base/mime_util.cc
index 37e630fb031a1c0b2fa1eff1f29bc79c919a7000..8f7b51422aa95202197dbbe9656a5d77b6215e4e 100644
--- a/net/base/mime_util.cc
+++ b/net/base/mime_util.cc
@@ -924,6 +924,20 @@ void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
allow_proprietary_codecs_ = false;
}
+// Returns true iff |profile_str| conforms to hex string "42y0": y >= 8. Taken
DaleCurtis 2014/10/03 21:54:07 Since this is just 8,9 -- why not explicitly enume
wolenetz 2014/10/03 22:27:52 (replying again, in context): This is actually 8,9
DaleCurtis 2014/10/03 22:33:56 Ahh, sorry the CL description makes it clear, but
wolenetz 2014/10/03 22:42:10 Done.
xhwang 2014/10/03 23:08:06 It's hex, so it can be 'c', 'e' etc.
+// from Annex A and constraint_set0 in ISO-14496-10.
xhwang 2014/10/03 23:08:06 Can you mention 7.3.2.1 and 7.4.2.1 in the spec.
wolenetz 2014/10/04 01:36:40 Done.
+static bool IsValidH264BaselineProfile(const std::string& profile_str) {
+ uint32 constraint_set_bits;
+ if (profile_str.size() != 4 ||
+ profile_str.substr(0, 2) != "42" ||
+ profile_str.substr(3, 1) != "0" ||
xhwang 2014/10/03 23:08:06 The substr is a bit overkill; will this work? ret
xhwang 2014/10/03 23:10:28 Sorry, you still need to convert string to int, fo
wolenetz 2014/10/03 23:51:04 Masking with 0xF1 instead of 0xFF means that we wo
wolenetz 2014/10/04 01:36:40 I'm keeping to just >= 8 (which requires constrain
+ !base::HexStringToUInt(profile_str.substr(2, 1), &constraint_set_bits)) {
+ return false;
+ }
+
+ return (constraint_set_bits & 0x8);
DaleCurtis 2014/10/03 22:33:56 Just use >= 8. Let the compiler handle such an opt
wolenetz 2014/10/03 22:42:10 Done.
+}
+
static bool IsValidH264Level(const std::string& level_str) {
uint32 level;
if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level))
@@ -939,9 +953,9 @@ static bool IsValidH264Level(const std::string& level_str) {
}
// Handle parsing H.264 codec IDs as outlined in RFC 6381
xhwang 2014/10/03 23:08:06 The suffix strings are really defined in ISO-14496
wolenetz 2014/10/04 01:36:40 Done.
-// avc1.42E0xx - H.264 Baseline
-// avc1.4D40xx - H.264 Main
-// avc1.6400xx - H.264 High
+// avc1.42y0xx, y >= 8 - H.264 Baseline
+// avc1.4D40xx - H.264 Main
+// avc1.6400xx - H.264 High
//
// avc1.xxxxxx & avc3.xxxxxx are considered ambiguous forms that
// are trying to signal H.264 Baseline.
@@ -956,7 +970,7 @@ static bool ParseH264CodecID(const std::string& codec_id,
}
std::string profile = StringToUpperASCII(codec_id.substr(5, 4));
- if (profile == "42E0") {
+ if (IsValidH264BaselineProfile(profile)) {
*codec = MimeUtil::H264_BASELINE;
} else if (profile == "4D40") {
*codec = MimeUtil::H264_MAIN;

Powered by Google App Engine
This is Rietveld 408576698