MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / dca_parse_params

Function dca_parse_params

libavcodec/dca_parser.c:194–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194static int dca_parse_params(DCAParseContext *pc1, const uint8_t *buf,
195 int buf_size, int *duration, int *sample_rate,
196 int *profile)
197{
198 DCAExssAsset *asset = &pc1->exss.assets[0];
199 GetBitContext gb;
200 DCACoreFrameHeader h;
201 uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
202 int ret, frame_size;
203
204 if (buf_size < DCA_CORE_FRAME_HEADER_SIZE)
205 return AVERROR_INVALIDDATA;
206
207 if (AV_RB32(buf) == DCA_SYNCWORD_SUBSTREAM) {
208 if ((ret = ff_dca_exss_parse(&pc1->exss, buf, buf_size)) < 0)
209 return ret;
210
211 if (asset->extension_mask & DCA_EXSS_LBR) {
212 if ((ret = init_get_bits8(&gb, buf + asset->lbr_offset, asset->lbr_size)) < 0)
213 return ret;
214
215 if (get_bits_long(&gb, 32) != DCA_SYNCWORD_LBR)
216 return AVERROR_INVALIDDATA;
217
218 switch (get_bits(&gb, 8)) {
219 case DCA_LBR_HEADER_DECODER_INIT:
220 pc1->sr_code = get_bits(&gb, 8);
221 case DCA_LBR_HEADER_SYNC_ONLY:
222 break;
223 default:
224 return AVERROR_INVALIDDATA;
225 }
226
227 if (pc1->sr_code >= FF_ARRAY_ELEMS(ff_dca_sampling_freqs))
228 return AVERROR_INVALIDDATA;
229
230 *sample_rate = ff_dca_sampling_freqs[pc1->sr_code];
231 *duration = 1024 << ff_dca_freq_ranges[pc1->sr_code];
232 *profile = AV_PROFILE_DTS_EXPRESS;
233 return 0;
234 }
235
236 if (asset->extension_mask & DCA_EXSS_XLL) {
237 int nsamples_log2;
238
239 if ((ret = init_get_bits8(&gb, buf + asset->xll_offset, asset->xll_size)) < 0)
240 return ret;
241
242 if (get_bits_long(&gb, 32) != DCA_SYNCWORD_XLL)
243 return AVERROR_INVALIDDATA;
244
245 if (get_bits(&gb, 4))
246 return AVERROR_INVALIDDATA;
247
248 skip_bits(&gb, 8);
249 skip_bits_long(&gb, get_bits(&gb, 5) + 1);
250 skip_bits(&gb, 4);
251 nsamples_log2 = get_bits(&gb, 4) + get_bits(&gb, 4);

Callers 1

dca_parseFunction · 0.85

Calls 8

ff_dca_exss_parseFunction · 0.85
init_get_bits8Function · 0.85
get_bits_longFunction · 0.85
skip_bitsFunction · 0.85
skip_bits_longFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected