Shaka Packager SDK
Loading...
Searching...
No Matches
dovi_decoder_configuration_record.cc
1// Copyright 2019 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#include <packager/media/codecs/dovi_decoder_configuration_record.h>
8
9#include <absl/strings/str_format.h>
10
11#include <packager/media/base/bit_reader.h>
12#include <packager/media/base/rcheck.h>
13
14namespace shaka {
15namespace media {
16
17bool DOVIDecoderConfigurationRecord::Parse(const std::vector<uint8_t>& data) {
18 BitReader reader(data.data(), data.size());
19
20 // Dolby Vision Streams Within the ISO Base Media File Format Version 2.0:
21 // https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.0.pdf
22 uint8_t major_version = 0;
23 uint8_t minor_version = 0;
24 RCHECK(reader.ReadBits(8, &major_version) && major_version == 1 &&
25 reader.ReadBits(8, &minor_version) && minor_version == 0 &&
26 reader.ReadBits(7, &profile_) && reader.ReadBits(6, &level_) &&
27 reader.SkipBits(3) &&
28 reader.ReadBits(4, &bl_signal_compatibility_id_));
29 return true;
30}
31
33 FourCC codec_fourcc) const {
34 // Dolby Vision Streams within the HTTP Live Streaming format Version 2.0:
35 // https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-streams-within-the-http-live-streaming-format-v2.0.pdf
36 return absl::StrFormat("%s.%02d.%02d", FourCCToString(codec_fourcc).c_str(),
37 profile_, level_);
38}
39
41 const uint8_t transfer_characteristics) const {
42 // Dolby Vision Streams within the ISO Base Media File Format Version 2.4:
43 switch (bl_signal_compatibility_id_) {
44 case 1:
45 return FOURCC_db1p;
46 case 2:
47 return FOURCC_db2g;
48 case 4:
49 if (transfer_characteristics == 14) {
50 return FOURCC_db4g;
51 }
52 // transfer_characteristics == 18
53 return FOURCC_db4h;
54 default:
55 return FOURCC_NULL;
56 }
57}
58
59} // namespace media
60} // namespace shaka
A class to read bit streams.
Definition bit_reader.h:20
bool SkipBits(size_t num_bits)
Definition bit_reader.cc:26
bool ReadBits(size_t num_bits, T *out)
Definition bit_reader.h:38
FourCC GetDoViCompatibleBrand(const uint8_t transfer_characteristics) const
All the methods that are virtual are virtual for mocking.