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 <cstdint>
10#include <string>
11#include <vector>
12
13#include <absl/strings/str_format.h>
14
15#include <packager/media/base/bit_reader.h>
16#include <packager/media/base/fourccs.h>
17#include <packager/media/base/rcheck.h>
18
19namespace shaka {
20namespace media {
21
22bool DOVIDecoderConfigurationRecord::Parse(const std::vector<uint8_t>& data) {
23 BitReader reader(data.data(), data.size());
24
25 // Dolby Vision Streams Within the ISO Base Media File Format Version 2.0:
26 // https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.0.pdf
27 uint8_t major_version = 0;
28 uint8_t minor_version = 0;
29 RCHECK(reader.ReadBits(8, &major_version) && major_version == 1 &&
30 reader.ReadBits(8, &minor_version) && minor_version == 0 &&
31 reader.ReadBits(7, &profile_) && reader.ReadBits(6, &level_) &&
32 reader.SkipBits(3) &&
33 reader.ReadBits(4, &bl_signal_compatibility_id_));
34 return true;
35}
36
38 FourCC codec_fourcc) const {
39 // Dolby Vision Streams within the HTTP Live Streaming format Version 2.0:
40 // https://www.dolby.com/us/en/technologies/dolby-vision/dolby-vision-streams-within-the-http-live-streaming-format-v2.0.pdf
41 return absl::StrFormat("%s.%02d.%02d", FourCCToString(codec_fourcc).c_str(),
42 profile_, level_);
43}
44
46 const uint8_t transfer_characteristics) const {
47 // Dolby Vision Streams within the ISO Base Media File Format Version 2.4:
48 switch (bl_signal_compatibility_id_) {
49 case 1:
50 return FOURCC_db1p;
51 case 2:
52 return FOURCC_db2g;
53 case 4:
54 if (transfer_characteristics == 14) {
55 return FOURCC_db4g;
56 }
57 // transfer_characteristics == 18
58 return FOURCC_db4h;
59 default:
60 return FOURCC_NULL;
61 }
62}
63
64} // namespace media
65} // namespace shaka
A class to read bit streams.
Definition bit_reader.h:19
bool SkipBits(size_t num_bits)
Definition bit_reader.cc:28
bool ReadBits(size_t num_bits, T *out)
Definition bit_reader.h:37
FourCC GetDoViCompatibleBrand(const uint8_t transfer_characteristics) const
All the methods that are virtual are virtual for mocking.