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