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

Side by Side Diff: media/base/mime_util.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <map> 5 #include <map>
6 6
7 #include "base/containers/hash_tables.h" 7 #include "base/containers/hash_tables.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still 316 // Special handling for old, pre-RFC 6381 format avc1 strings, which are still
317 // being used by some HLS apps to preserve backward compatibility with older 317 // being used by some HLS apps to preserve backward compatibility with older
318 // iOS devices. The old format was avc1.<profile>.<level> 318 // iOS devices. The old format was avc1.<profile>.<level>
319 // Where <profile> is H.264 profile_idc encoded as a decimal number, i.e. 319 // Where <profile> is H.264 profile_idc encoded as a decimal number, i.e.
320 // 66 is baseline profile (0x42) 320 // 66 is baseline profile (0x42)
321 // 77 is main profile (0x4d) 321 // 77 is main profile (0x4d)
322 // 100 is high profile (0x64) 322 // 100 is high profile (0x64)
323 // And <level> is H.264 level multiplied by 10, also encoded as decimal number 323 // And <level> is H.264 level multiplied by 10, also encoded as decimal number
324 // E.g. <level> 31 corresponds to H.264 level 3.1 324 // E.g. <level> 31 corresponds to H.264 level 3.1
325 // See, for example, http://qtdevseed.apple.com/qadrift/testcases/tc-0133.php 325 // See, for example, http://qtdevseed.apple.com/qadrift/testcases/tc-0133.php
326 uint32 level_start = 0; 326 uint32_t level_start = 0;
327 std::string result; 327 std::string result;
328 if (base::StartsWith(codec_id, "avc1.66.", base::CompareCase::SENSITIVE)) { 328 if (base::StartsWith(codec_id, "avc1.66.", base::CompareCase::SENSITIVE)) {
329 level_start = 8; 329 level_start = 8;
330 result = "avc1.4200"; 330 result = "avc1.4200";
331 } else if (base::StartsWith(codec_id, "avc1.77.", 331 } else if (base::StartsWith(codec_id, "avc1.77.",
332 base::CompareCase::SENSITIVE)) { 332 base::CompareCase::SENSITIVE)) {
333 level_start = 8; 333 level_start = 8;
334 result = "avc1.4D00"; 334 result = "avc1.4D00";
335 } else if (base::StartsWith(codec_id, "avc1.100.", 335 } else if (base::StartsWith(codec_id, "avc1.100.",
336 base::CompareCase::SENSITIVE)) { 336 base::CompareCase::SENSITIVE)) {
337 level_start = 9; 337 level_start = 9;
338 result = "avc1.6400"; 338 result = "avc1.6400";
339 } 339 }
340 340
341 uint32 level = 0; 341 uint32_t level = 0;
342 if (level_start > 0 && 342 if (level_start > 0 &&
343 base::StringToUint(codec_id.substr(level_start), &level) && level < 256) { 343 base::StringToUint(codec_id.substr(level_start), &level) && level < 256) {
344 // This is a valid legacy avc1 codec id - return the codec id translated 344 // This is a valid legacy avc1 codec id - return the codec id translated
345 // into RFC 6381 format. 345 // into RFC 6381 format.
346 result.push_back(IntToHex(level >> 4)); 346 result.push_back(IntToHex(level >> 4));
347 result.push_back(IntToHex(level & 0xf)); 347 result.push_back(IntToHex(level & 0xf));
348 return result; 348 return result;
349 } 349 }
350 350
351 // This is not a valid legacy avc1 codec id - return the original codec id. 351 // This is not a valid legacy avc1 codec id - return the original codec id.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 489 }
490 490
491 void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() { 491 void MimeUtil::RemoveProprietaryMediaTypesAndCodecsForTests() {
492 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i) 492 for (size_t i = 0; i < arraysize(kFormatCodecMappings); ++i)
493 if (kFormatCodecMappings[i].format_type == PROPRIETARY) 493 if (kFormatCodecMappings[i].format_type == PROPRIETARY)
494 media_format_map_.erase(kFormatCodecMappings[i].mime_type); 494 media_format_map_.erase(kFormatCodecMappings[i].mime_type);
495 allow_proprietary_codecs_ = false; 495 allow_proprietary_codecs_ = false;
496 } 496 }
497 497
498 static bool IsValidH264Level(const std::string& level_str) { 498 static bool IsValidH264Level(const std::string& level_str) {
499 uint32 level; 499 uint32_t level;
500 if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level)) 500 if (level_str.size() != 2 || !base::HexStringToUInt(level_str, &level))
501 return false; 501 return false;
502 502
503 // Valid levels taken from Table A-1 in ISO-14496-10. 503 // Valid levels taken from Table A-1 in ISO-14496-10.
504 // Essentially |level_str| is toHex(10 * level). 504 // Essentially |level_str| is toHex(10 * level).
505 return ((level >= 10 && level <= 13) || 505 return ((level >= 10 && level <= 13) ||
506 (level >= 20 && level <= 22) || 506 (level >= 20 && level <= 22) ||
507 (level >= 30 && level <= 32) || 507 (level >= 30 && level <= 32) ||
508 (level >= 40 && level <= 42) || 508 (level >= 40 && level <= 42) ||
509 (level >= 50 && level <= 51)); 509 (level >= 50 && level <= 51));
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 std::vector<std::string>* codecs_out, 695 std::vector<std::string>* codecs_out,
696 const bool strip) { 696 const bool strip) {
697 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); 697 g_media_mime_util.Get().ParseCodecString(codecs, codecs_out, strip);
698 } 698 }
699 699
700 void RemoveProprietaryMediaTypesAndCodecsForTests() { 700 void RemoveProprietaryMediaTypesAndCodecsForTests() {
701 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests(); 701 g_media_mime_util.Get().RemoveProprietaryMediaTypesAndCodecsForTests();
702 } 702 }
703 703
704 } // namespace media 704 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698