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

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

Issue 816353010: Implemented HEVC video demuxing and parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjusted inclusion of hevc source files in gyp/gn Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
ddorwin 2015/02/23 20:00:49 If you intend to support MSE, there may be other c
servolk 2015/02/24 02:15:13 There is also some changes in stream_parser_factor
ddorwin 2015/02/24 18:07:32 Acknowledged.
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 <algorithm> 5 #include <algorithm>
6 #include <iterator> 6 #include <iterator>
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
(...skipping 26 matching lines...) Expand all
38 MPEG2_AAC_MAIN, 38 MPEG2_AAC_MAIN,
39 MPEG2_AAC_SSR, 39 MPEG2_AAC_SSR,
40 MPEG4_AAC_LC, 40 MPEG4_AAC_LC,
41 MPEG4_AAC_SBR_v1, 41 MPEG4_AAC_SBR_v1,
42 MPEG4_AAC_SBR_PS_v2, 42 MPEG4_AAC_SBR_PS_v2,
43 VORBIS, 43 VORBIS,
44 OPUS, 44 OPUS,
45 H264_BASELINE, 45 H264_BASELINE,
46 H264_MAIN, 46 H264_MAIN,
47 H264_HIGH, 47 H264_HIGH,
48 HEVC_MAIN,
48 VP8, 49 VP8,
49 VP9, 50 VP9,
50 THEORA 51 THEORA
51 }; 52 };
52 53
53 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, 54 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext,
54 std::string* mime_type) const; 55 std::string* mime_type) const;
55 56
56 bool GetMimeTypeFromFile(const base::FilePath& file_path, 57 bool GetMimeTypeFromFile(const base::FilePath& file_path,
57 std::string* mime_type) const; 58 std::string* mime_type) const;
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 case MimeUtil::MPEG4_AAC_LC: 458 case MimeUtil::MPEG4_AAC_LC:
458 case MimeUtil::MPEG4_AAC_SBR_v1: 459 case MimeUtil::MPEG4_AAC_SBR_v1:
459 case MimeUtil::MPEG4_AAC_SBR_PS_v2: 460 case MimeUtil::MPEG4_AAC_SBR_PS_v2:
460 case MimeUtil::H264_BASELINE: 461 case MimeUtil::H264_BASELINE:
461 case MimeUtil::H264_MAIN: 462 case MimeUtil::H264_MAIN:
462 case MimeUtil::H264_HIGH: 463 case MimeUtil::H264_HIGH:
463 case MimeUtil::VP8: 464 case MimeUtil::VP8:
464 case MimeUtil::VORBIS: 465 case MimeUtil::VORBIS:
465 return true; 466 return true;
466 467
468 case MimeUtil::HEVC_MAIN:
469 return false;
470
467 case MimeUtil::MPEG2_AAC_LC: 471 case MimeUtil::MPEG2_AAC_LC:
468 case MimeUtil::MPEG2_AAC_MAIN: 472 case MimeUtil::MPEG2_AAC_MAIN:
469 case MimeUtil::MPEG2_AAC_SSR: 473 case MimeUtil::MPEG2_AAC_SSR:
470 // MPEG-2 variants of AAC are not supported on Android. 474 // MPEG-2 variants of AAC are not supported on Android.
471 return false; 475 return false;
472 476
473 case MimeUtil::VP9: 477 case MimeUtil::VP9:
474 // VP9 is supported only in KitKat+ (API Level 19). 478 // VP9 is supported only in KitKat+ (API Level 19).
475 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; 479 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
476 480
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) 520 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS)
517 // 521 //
518 // avc1.42E0xx - H.264 Baseline 522 // avc1.42E0xx - H.264 Baseline
519 // avc1.4D40xx - H.264 Main 523 // avc1.4D40xx - H.264 Main
520 // avc1.6400xx - H.264 High 524 // avc1.6400xx - H.264 High
521 static const char kMP4AudioCodecsExpression[] = 525 static const char kMP4AudioCodecsExpression[] =
522 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 526 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
523 "mp4a.40.05,mp4a.40.29"; 527 "mp4a.40.05,mp4a.40.29";
524 static const char kMP4VideoCodecsExpression[] = 528 static const char kMP4VideoCodecsExpression[] =
525 "avc1.42E00A,avc1.4D400A,avc1.64000A," 529 "avc1.42E00A,avc1.4D400A,avc1.64000A,"
530 #if defined(ENABLE_HEVC_DEMUXING)
ddorwin 2015/02/21 02:09:21 "DEMUXING" is not really accurate. This enables su
servolk 2015/02/23 19:16:16 No, I believe this is accurate. What exactly do yo
ddorwin 2015/02/23 20:00:49 The primary "support" it enables is advertising su
servolk 2015/02/24 02:15:13 Yes, this does enable hevc support via canPlayType
ddorwin 2015/02/24 18:07:33 Agreed. My point is that this flag enables HEVC, n
531 "hev1,hvc1,"
ddorwin 2015/02/21 02:09:21 See below.
ddorwin 2015/02/23 20:00:49 See some of the comments about how avc1 is handled
ddorwin 2015/02/23 20:12:43 Note that you must have an unambiguous string or y
servolk 2015/02/24 02:15:13 Wait, I don't understand - even in that CL we have
ddorwin 2015/02/24 18:07:33 I didn't change anything in that CL, I just explai
532 #endif
526 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 533 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
527 "mp4a.40.05,mp4a.40.29"; 534 "mp4a.40.05,mp4a.40.29";
528 535
529 static const MediaFormatStrict format_codec_mappings[] = { 536 static const MediaFormatStrict format_codec_mappings[] = {
530 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, 537 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" },
531 { "audio/webm", "opus,vorbis" }, 538 { "audio/webm", "opus,vorbis" },
532 { "audio/wav", "1" }, 539 { "audio/wav", "1" },
533 { "audio/x-wav", "1" }, 540 { "audio/x-wav", "1" },
534 { "video/ogg", "opus,theora,vorbis" }, 541 { "video/ogg", "opus,theora,vorbis" },
535 { "audio/ogg", "opus,vorbis" }, 542 { "audio/ogg", "opus,vorbis" },
(...skipping 13 matching lines...) Expand all
549 const char* const codec_id; 556 const char* const codec_id;
550 MimeUtil::Codec codec; 557 MimeUtil::Codec codec;
551 }; 558 };
552 559
553 // List of codec IDs that provide enough information to determine the 560 // List of codec IDs that provide enough information to determine the
554 // codec and profile being requested. 561 // codec and profile being requested.
555 // 562 //
556 // The "mp4a" strings come from RFC 6381. 563 // The "mp4a" strings come from RFC 6381.
557 static const CodecIDMappings kUnambiguousCodecIDs[] = { 564 static const CodecIDMappings kUnambiguousCodecIDs[] = {
558 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. 565 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
566 #if defined(ENABLE_HEVC_DEMUXING)
567 {"hev1", MimeUtil::HEVC_MAIN},
ddorwin 2015/02/21 02:09:21 I don't think we should support these extension-le
ddorwin 2015/02/21 02:44:40 To clarify, this may not have been so much a mista
servolk 2015/02/23 19:16:16 As far as I know the difference between hev1 and h
ddorwin 2015/02/23 20:00:50 Thanks for the exmplanation of "hev" vs. "hvc". I
ddorwin 2015/02/23 20:12:43 Oops, strike that. Because we do not want to suppo
568 {"hvc1", MimeUtil::HEVC_MAIN},
569 #endif
559 {"mp3", MimeUtil::MP3}, 570 {"mp3", MimeUtil::MP3},
560 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, 571 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
561 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, 572 {"mp4a.67", MimeUtil::MPEG2_AAC_LC},
562 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, 573 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR},
563 {"mp4a.69", MimeUtil::MP3}, 574 {"mp4a.69", MimeUtil::MP3},
564 {"mp4a.6B", MimeUtil::MP3}, 575 {"mp4a.6B", MimeUtil::MP3},
565 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, 576 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC},
566 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, 577 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC},
567 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, 578 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1},
568 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, 579 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1},
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 Codec* codec, 1012 Codec* codec,
1002 bool* is_ambiguous) const { 1013 bool* is_ambiguous) const {
1003 StringToCodecMappings::const_iterator itr = 1014 StringToCodecMappings::const_iterator itr =
1004 string_to_codec_map_.find(codec_id); 1015 string_to_codec_map_.find(codec_id);
1005 if (itr != string_to_codec_map_.end()) { 1016 if (itr != string_to_codec_map_.end()) {
1006 *codec = itr->second.codec; 1017 *codec = itr->second.codec;
1007 *is_ambiguous = itr->second.is_ambiguous; 1018 *is_ambiguous = itr->second.is_ambiguous;
1008 return true; 1019 return true;
1009 } 1020 }
1010 1021
1022 #if defined(ENABLE_HEVC_DEMUXING)
ddorwin 2015/02/23 20:00:49 Move this code to ParseHEVCCodecID or something li
1023 if (StartsWithASCII(codec_id, "hev1.", true) ||
ddorwin 2015/02/21 02:09:21 Once the other issues are addressed, you'll need t
servolk 2015/02/23 19:16:16 Ok, yeah, once we have more clarity here we'll try
ddorwin 2015/02/23 20:00:49 You should add at least some basic tests soon. Thi
servolk 2015/02/24 02:15:13 Sure, I will add some tests. In fact I've already
ddorwin 2015/02/24 18:07:32 I think we have pipeline tests and content and chr
1024 StartsWithASCII(codec_id, "hvc1.", true)) {
1025 // TODO(servolk): Implement parsing of hevc codec ids as described in
ddorwin 2015/02/21 02:09:21 Our avc1 string handling is a mess. Similar to my
servolk 2015/02/23 19:16:16 I understand your concerns, but we are in the earl
ddorwin 2015/02/23 20:00:49 Can we at least check for valid values, similar to
servolk 2015/02/24 02:15:13 Yep, will do
1026 // ETSI TS 126 244 standard section A.2.2, but for now allow any
1027 // HEVC tiers/profiles and let decoder decide if it can handle that.
1028 *codec = MimeUtil::HEVC_MAIN;
1029 *is_ambiguous = false;
ddorwin 2015/02/21 02:09:21 This should be true since you do no verification.
servolk 2015/02/23 19:16:16 yep, that's a good point, I'll change this.
1030 return true;
1031 }
1032 #endif
1033
1011 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is 1034 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
1012 // an H.264 codec ID because currently those are the only ones that can't be 1035 // an H.264 codec ID because currently those are the only ones that can't be
1013 // stored in the |string_to_codec_map_| and require parsing. 1036 // stored in the |string_to_codec_map_| and require parsing.
1014 return ParseH264CodecID(codec_id, codec, is_ambiguous); 1037 return ParseH264CodecID(codec_id, codec, is_ambiguous);
1015 } 1038 }
1016 1039
1017 bool MimeUtil::IsCodecSupported(Codec codec) const { 1040 bool MimeUtil::IsCodecSupported(Codec codec) const {
1018 DCHECK_NE(codec, INVALID_CODEC); 1041 DCHECK_NE(codec, INVALID_CODEC);
1019 1042
1020 #if defined(OS_ANDROID) 1043 #if defined(OS_ANDROID)
(...skipping 10 matching lines...) Expand all
1031 case MP3: 1054 case MP3:
1032 case MPEG2_AAC_LC: 1055 case MPEG2_AAC_LC:
1033 case MPEG2_AAC_MAIN: 1056 case MPEG2_AAC_MAIN:
1034 case MPEG2_AAC_SSR: 1057 case MPEG2_AAC_SSR:
1035 case MPEG4_AAC_LC: 1058 case MPEG4_AAC_LC:
1036 case MPEG4_AAC_SBR_v1: 1059 case MPEG4_AAC_SBR_v1:
1037 case MPEG4_AAC_SBR_PS_v2: 1060 case MPEG4_AAC_SBR_PS_v2:
1038 case H264_BASELINE: 1061 case H264_BASELINE:
1039 case H264_MAIN: 1062 case H264_MAIN:
1040 case H264_HIGH: 1063 case H264_HIGH:
1064 case HEVC_MAIN:
1041 return true; 1065 return true;
1042 1066
1043 case PCM: 1067 case PCM:
1044 case VORBIS: 1068 case VORBIS:
1045 case OPUS: 1069 case OPUS:
1046 case VP8: 1070 case VP8:
1047 case VP9: 1071 case VP9:
1048 case THEORA: 1072 case THEORA:
1049 return false; 1073 return false;
1050 } 1074 }
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 post_data->append("\r\n" + value + "\r\n"); 1403 post_data->append("\r\n" + value + "\r\n");
1380 } 1404 }
1381 1405
1382 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1406 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1383 std::string* post_data) { 1407 std::string* post_data) {
1384 DCHECK(post_data); 1408 DCHECK(post_data);
1385 post_data->append("--" + mime_boundary + "--\r\n"); 1409 post_data->append("--" + mime_boundary + "--\r\n");
1386 } 1410 }
1387 1411
1388 } // namespace net 1412 } // namespace net
OLDNEW
« media/filters/stream_parser_factory.cc ('K') | « media/test/data/bear-hevc-frag.mp4 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698