Shaka Packager SDK
Loading...
Searching...
No Matches
ac4_parser.h
1// Copyright 2018 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#ifndef PACKAGER_MEDIA_CODECS_AC4_PARSER_H_
8#define PACKAGER_MEDIA_CODECS_AC4_PARSER_H_
9
10#include <cstdint>
11#include <cstdlib>
12
13namespace shaka {
14namespace media {
15
16class BitReader;
17
18class AC4Parser {
19 public:
21 int b_multiplier = 0;
22 int multiplier_bit = 0;
23 int dsi_frame_rate_multiply_info = 0;
24 };
25
27 int b_frame_rate_fraction = 0;
28 int b_frame_rate_fraction_is_4 = 0;
29 };
30
31 struct EmdfInfo {
32 int emdf_version = 0;
33 int key_id = 0;
34 int b_emdf_payloads_substream_info = 0;
35 int substream_index = 0;
36 // indent for emdf_protection
37 int protection_length_primary = 0;
38 int protection_length_secondary = 0;
39 uint8_t protection_bits_primary[16];
40 uint8_t protection_bits_secondary[16];
41 };
42
44 int b_default_screen_size_ratio = 0;
45 int master_screen_size_ratio_code = 0;
46 int b_bed_object_chan_distribute = 0;
47 int b_additional_data = 0;
48 int add_data_bytes = 0;
49 int add_data_bytes_minus1 = 0;
50 // skip bed_render_info
51 };
52
54 int channel_mode = 0;
55 int b_4_back_channels_present = 0;
56 int b_centre_present = 0;
57 int top_channels_present = 0;
58 int b_sf_multiplier = 0;
59 int sf_multiplier = 0;
60 int b_bitrate_info = 0;
61 int bitrate_indicator = 0;
62 int add_ch_base = 0;
63 int b_audio_ndot = 0;
64 int substream_index = 0;
65 };
66
68 int b_lfe = 0;
69 int b_static_dmx = 0;
70 int n_fullband_dmx_signals = 0;
71 int n_fullband_dmx_signals_minus1 = 0;
72 // indent bed_dyn_obj_assignment
73 int b_dyn_objects_only = 0;
74 int b_isf = 0;
75 int isf_config = 0;
76 int b_ch_assign_code = 0;
77 int bed_chan_assign_code = 0;
78 int b_chan_assign_mask = 0;
79 int b_nonstd_bed_channel_assignment = 0;
80 int nonstd_bed_channel_assignment_mask = 0;
81 int std_bed_channel_assignment_mask = 0;
82 int n_bed_signals = 0;
83 int n_bed_signals_minus1 = 0;
84 int nonstd_bed_channel_assignment = 0;
85 int b_oamd_common_data_present = 0;
86 OamdCommonData oamd_common_data;
87 int n_fullband_upmix_signals_minus1 = 0;
88 int b_sf_multiplier = 0;
89 int sf_multiplier = 0;
90 int b_bitrate_info = 0;
91 int bitrate_indicator = 0;
92 int b_audio_ndot = 0;
93 int substream_index = 0;
94 };
95
97 int n_objects_code = 0;
98 int b_dynamic_objects = 0;
99 int b_lfe = 0;
100 int b_bed_objects = 0;
101 int b_bed_start = 0;
102 int b_ch_assign_code = 0;
103 int bed_chan_assign_code = 0;
104 int b_nonstd_bed_channel_assignment = 0;
105 int nonstd_bed_channel_assignment_mask = 0;
106 int std_bed_channel_assignment_mask = 0;
107 int b_isf = 0;
108 int b_isf_start = 0;
109 int isf_config = 0;
110 int b_sf_multiplier = 0;
111 int sf_multiplier = 0;
112 int b_bitrate_info = 0;
113 int bitrate_indicator = 0;
114 int b_audio_ndot = 0;
115 int substream_index = 0;
116 };
117
119 int b_single_substream_group = 0;
120 int presentation_config = 0;
121 int presentation_version = 0;
122 int mdcompat = 0;
123 int b_presentation_id = 0;
124 FrameRateMultiplyInfo frame_rate_multiply_info;
125 FrameRateFractionsInfo frame_rate_fractions_info;
126 EmdfInfo emdf_info;
127 int b_presentation_filter = 0;
128 int b_enable_presentation = 0;
129 int b_multi_pid = 0;
130 // indent for ac4_sgi_specifier
131 int group_index[16] = {0};
132 int n_substream_groups = 0;
133 int n_substream_groups_minus2 = 0;
134 int b_pre_virtualized = 0;
135 int b_add_emdf_substreams = 0;
136 int n_add_emdf_substreams = 0;
137 // indent for ac4_presentation_substream_info
138 int b_alternative = 0;
139 int b_pres_ndot = 0;
140 int substream_index = 0;
141 EmdfInfo* emdf_infos;
142 };
143
145 int b_substreams_present = 0;
146 int b_hsf_ext = 0;
147 int b_single_substream = 0;
148 int n_lf_substreams = 0;
149 int n_lf_substreams_minus2 = 0;
150 int b_channel_coded = 0;
151 int sus_ver = 0;
152 Ac4SubstreamInfoChan* substream_info_chan;
153 // ac4_hsf_ext_substream_info
154 int substream_index;
155 int b_oamd_substream = 0;
156 // oamd_substream_info
157 int b_oamd_ndot = 0;
158 int b_ajoc = 0;
159 Ac4SubstreamInfoAjoc* substream_info_ajoc;
160 Ac4SubstreamInfoObj* substream_info_obj;
161 int b_content_type = 0;
162 int content_classifier = 0;
163 int b_language_indicator = 0;
164 int b_serialized_language_tag = 0;
165 int b_start_tag = 0;
166 int language_tag_chunk = 0;
167 int n_language_tag_bytes = 0;
168 int language_tag_bytes[64] = {0};
169 };
170
171 struct Ac4Toc {
172 int bitstream_version;
173 int sequence_counter;
174 int b_wait_frames;
175 int wait_frames;
176 int br_code;
177 int fs_index;
178 int frame_rate_index;
179 int b_iframe_global;
180 int b_single_presentation;
181 int b_more_presentations;
182 int b_payload_base;
183 int payload_base_minus1;
184 int b_program_id;
185 int short_program_id;
186 int b_program_uuid_present;
187 int program_uuid;
188 int n_presentations;
189 int total_n_substream_groups;
190 Ac4PresentationV1Info* presentation_v1_infos;
191 Ac4SubstreamGroupInfo* substream_group_infos;
192 };
193
194 AC4Parser();
195 virtual ~AC4Parser();
196
197 virtual bool Parse(const uint8_t* data, size_t data_size);
198 int GetAc4TocSize() { return toc_size; };
199
200 private:
201 AC4Parser(const AC4Parser&) = delete;
202 AC4Parser& operator=(const AC4Parser&) = delete;
203
204 bool ParseAc4Toc(BitReader* reader);
205 bool ParseAc4PresentationV1Info(
206 BitReader* reader,
207 Ac4PresentationV1Info& ac4_presentation_v1_info,
208 int& max_group_index);
209 bool ParseFrameRateMultiplyInfo(BitReader* reader);
210 bool ParseFrameRateFractionsInfo(BitReader* reader);
211 bool ParseEmdfInfo(BitReader* reader);
212 bool ParseAc4PresentationSubstreamInfo(BitReader* reader);
213 int ParseAc4SgiSpecifier(BitReader* reader);
214 bool ParsePresentationConfigExtInfo(BitReader* reader);
215 bool ParseAc4SubstreamGroupInfo(
216 BitReader* reader,
217 Ac4SubstreamGroupInfo& ac4_substream_group_info,
218 int substream_group_index);
219 bool ParseContentType(BitReader* reader,
220 Ac4SubstreamGroupInfo& ac4_substream_group_info);
221 bool ParseOamdSubstreamInfo(BitReader* reader,
222 Ac4SubstreamGroupInfo& ac4_substream_group_info);
223 bool ParseAc4HsfExtSubstreamInfo(
224 BitReader* reader,
225 Ac4SubstreamGroupInfo& ac4_substream_group_info);
226 bool ParseAc4SubstreamInfoChan(BitReader* reader,
227 int presentation_version,
228 int fs_index,
229 int frame_rate_factor,
230 int b_substreams_present);
231 int ParseChannelMode(BitReader* reader, int presentation_version);
232 bool ParseAc4SubstreamInfoAjoc(BitReader* reader,
233 int fs_index,
234 int frame_rate_factor,
235 int b_substreams_present);
236 bool ParseBedDynObjAssignment(BitReader* reader,
237 int n_signals,
238 Ac4SubstreamInfoAjoc& ac4_substream_info_ajoc);
239 bool ParseOamdCommonData(BitReader* reader);
240 bool ParseAc4SubstreamInfoObj(BitReader* reader,
241 int fs_index,
242 int frame_rate_factor,
243 int b_substreams_present);
244 int GetPresentationIdx(int substream_group_index);
245 int GetPresentationVersion(int substream_group_index);
246 bool ByteAlignment(BitReader* reader);
247
248 int toc_size;
249 Ac4Toc ac4_toc;
250};
251
252} // namespace media
253} // namespace shaka
254
255#endif // PACKAGER_MEDIA_CODECS_AC4_PARSER_H_
A class to read bit streams.
Definition bit_reader.h:19
All the methods that are virtual are virtual for mocking.