Chromium Code Reviews| Index: media/base/video_codecs.cc |
| diff --git a/media/base/video_codecs.cc b/media/base/video_codecs.cc |
| index d1b9b6974e4c9073110a05f11db08fe4146d3f23..3534c604a1c3f2e91e836c6ad02ffc49b1a816a4 100644 |
| --- a/media/base/video_codecs.cc |
| +++ b/media/base/video_codecs.cc |
| @@ -32,6 +32,8 @@ std::string GetCodecName(VideoCodec codec) { |
| return "vp8"; |
| case kCodecVP9: |
| return "vp9"; |
| + case kCodecDolbyVision: |
|
wolenetz
2017/01/25 23:42:41
nit: these cases are already not in sequence with
erickung1
2017/02/03 18:18:31
Done.
|
| + return "dolbyvision"; |
| } |
| NOTREACHED(); |
| return ""; |
| @@ -79,6 +81,14 @@ std::string GetProfileName(VideoCodecProfile profile) { |
| return "vp9 profile2"; |
| case VP9PROFILE_PROFILE3: |
| return "vp9 profile3"; |
| + case DOLBYVISION_PROFILE0: |
| + return "dolby vision profile 0"; |
| + case DOLBYVISION_PROFILE4: |
| + return "dolby vision profile 4"; |
| + case DOLBYVISION_PROFILE5: |
| + return "dolby vision profile 5"; |
| + case DOLBYVISION_PROFILE7: |
| + return "dolby vision profile 7"; |
| } |
| NOTREACHED(); |
| return ""; |
| @@ -370,6 +380,77 @@ bool ParseHEVCCodecId(const std::string& codec_id, |
| } |
| #endif |
| +#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| +// The specification for Dolby Vision codec id strings can be found in Dolby |
| +// Vision streams within the MPEG-DASH format. |
| +bool ParseDolbyVisionCodecId(const std::string& codec_id, |
| + VideoCodecProfile* profile, |
| + uint8_t* level_idc) { |
| + if (!base::StartsWith(codec_id, "dvh1.", base::CompareCase::SENSITIVE) && |
| + !base::StartsWith(codec_id, "dvhe.", base::CompareCase::SENSITIVE) && |
| + !base::StartsWith(codec_id, "dva1.", base::CompareCase::SENSITIVE) && |
| + !base::StartsWith(codec_id, "dvav.", base::CompareCase::SENSITIVE)) { |
| + return false; |
| + } |
| + |
| + const int kMaxDvCodecIdLength = 5 // FOURCC string |
| + + 1 // delimiting period |
| + + 2 // profile id as 2 digit string |
| + + 1 // delimiting period |
| + + 2; // level id as 2 digit string. |
| + |
| + if (codec_id.size() > kMaxDvCodecIdLength) { |
| + DVLOG(4) << __func__ << ": Codec id is too long (" << codec_id << ")"; |
| + return false; |
| + } |
| + |
| + std::vector<std::string> elem = base::SplitString( |
| + codec_id, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| + DCHECK(elem[0] == "dvh1" || elem[0] == "dvhe" || elem[0] == "dva1" || |
| + elem[0] == "dvav"); |
| + |
| + if (elem.size() != 3) { |
| + DVLOG(4) << __func__ << ": invalid dolby vision codec id " << codec_id; |
| + return false; |
| + } |
| + |
| + unsigned profile_id = 0; |
| + if (!base::StringToUint(elem[1], &profile_id) || profile_id > 7) { |
| + DVLOG(4) << __func__ << ": invalid profile_id=" << elem[1]; |
| + return false; |
| + } |
| + |
| + // Only profile 0, 4 ,5 and 7 are valid. |
|
wolenetz
2017/01/25 23:42:41
nit: s/profile/profiles/ and s/4 ,/4, /
erickung1
2017/02/03 18:18:31
Done.
|
| + switch (profile_id) { |
| + case 0: |
| + *profile = DOLBYVISION_PROFILE0; |
| + break; |
| + case 4: |
| + *profile = DOLBYVISION_PROFILE4; |
| + break; |
| + case 5: |
| + *profile = DOLBYVISION_PROFILE5; |
| + break; |
| + case 7: |
| + *profile = DOLBYVISION_PROFILE7; |
| + break; |
| + default: |
| + DVLOG(4) << __func__ << ": depecrated profile_id=" << profile_id; |
|
wolenetz
2017/01/25 23:42:41
nit: s/deprecated/deprecated and not supported/ ?
erickung1
2017/02/03 18:18:31
Done.
|
| + return false; |
| + } |
| + |
| + unsigned level_id = 0; |
| + if (!base::StringToUint(elem[2], &level_id) || level_id > 9 || level_id < 1) { |
| + DVLOG(4) << __func__ << ": invalid level_id=" << elem[2]; |
| + return false; |
| + } |
| + |
| + *level_idc = level_id; |
| + |
| + return true; |
| +} |
| +#endif |
| + |
| VideoCodec StringToVideoCodec(const std::string& codec_id) { |
| std::vector<std::string> elem = base::SplitString( |
| codec_id, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| @@ -391,6 +472,10 @@ VideoCodec StringToVideoCodec(const std::string& codec_id) { |
| if (ParseHEVCCodecId(codec_id, &profile, &level)) |
| return kCodecHEVC; |
| #endif |
| +#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING) |
| + if (ParseDolbyVisionCodecId(codec_id, &profile, &level)) |
| + return kCodecDolbyVision; |
| +#endif |
| return kUnknownVideoCodec; |
| } |