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

Function parse_subframe_audio

libavcodec/dca_core.c:627–762  ·  view source on GitHub ↗

5.5 - Primary audio data arrays

Source from the content-addressed store, hash-verified

625
626// 5.5 - Primary audio data arrays
627static int parse_subframe_audio(DCACoreDecoder *s, int sf, enum HeaderType header,
628 int xch_base, int *sub_pos, int *lfe_pos)
629{
630 int32_t audio[16], scale;
631 int n, ssf, ofs, ch, band;
632
633 // Check number of subband samples in this subframe
634 int nsamples = s->nsubsubframes[sf] * DCA_SUBBAND_SAMPLES;
635 if (*sub_pos + nsamples > s->npcmblocks) {
636 av_log(s->avctx, AV_LOG_ERROR, "Subband sample buffer overflow\n");
637 return AVERROR_INVALIDDATA;
638 }
639
640 if (get_bits_left(&s->gb) < 0)
641 return AVERROR_INVALIDDATA;
642
643 // VQ encoded subbands
644 for (ch = xch_base; ch < s->nchannels; ch++) {
645 int32_t vq_index[DCA_SUBBANDS];
646
647 for (band = s->subband_vq_start[ch]; band < s->nsubbands[ch]; band++)
648 // Extract the VQ address from the bit stream
649 vq_index[band] = get_bits(&s->gb, 10);
650
651 if (s->subband_vq_start[ch] < s->nsubbands[ch]) {
652 s->dcadsp->decode_hf(s->subband_samples[ch], vq_index,
653 ff_dca_high_freq_vq, s->scale_factors[ch],
654 s->subband_vq_start[ch], s->nsubbands[ch],
655 *sub_pos, nsamples);
656 }
657 }
658
659 // Low frequency effect data
660 if (s->lfe_present && header == HEADER_CORE) {
661 unsigned int index;
662
663 // Determine number of LFE samples in this subframe
664 int nlfesamples = 2 * s->lfe_present * s->nsubsubframes[sf];
665 av_assert1((unsigned int)nlfesamples <= FF_ARRAY_ELEMS(audio));
666
667 // Extract LFE samples from the bit stream
668 get_array(&s->gb, audio, nlfesamples, 8);
669
670 // Extract scale factor index from the bit stream
671 index = get_bits(&s->gb, 8);
672 if (index >= FF_ARRAY_ELEMS(ff_dca_scale_factor_quant7)) {
673 av_log(s->avctx, AV_LOG_ERROR, "Invalid LFE scale factor index\n");
674 return AVERROR_INVALIDDATA;
675 }
676
677 // Look up the 7-bit root square quantization table
678 scale = ff_dca_scale_factor_quant7[index];
679
680 // Account for quantizer step size which is 0.035
681 scale = mul23(4697620 /* 0.035 * (1 << 27) */, scale);
682
683 // Scale and take the LFE samples
684 for (n = 0, ofs = *lfe_pos; n < nlfesamples; n++, ofs++)

Callers 1

parse_frame_dataFunction · 0.85

Calls 9

av_logFunction · 0.85
get_bits_leftFunction · 0.85
mul23Function · 0.85
clip23Function · 0.85
extract_audioFunction · 0.85
ff_dca_core_dequantizeFunction · 0.85
inverse_adpcmFunction · 0.85
get_bitsFunction · 0.70
get_arrayFunction · 0.70

Tested by

no test coverage detected