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

Function decode_var_block_data

libavcodec/alsdec.c:822–926  ·  view source on GitHub ↗

Decodes the block data for a non-constant block */

Source from the content-addressed store, hash-verified

820/** Decodes the block data for a non-constant block
821 */
822static int decode_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
823{
824 ALSSpecificConfig *sconf = &ctx->sconf;
825 unsigned int block_length = bd->block_length;
826 unsigned int smp = 0;
827 unsigned int k;
828 int opt_order = bd->opt_order;
829 int sb;
830 int64_t y;
831 int32_t *quant_cof = bd->quant_cof;
832 int32_t *lpc_cof = bd->lpc_cof;
833 int32_t *raw_samples = bd->raw_samples;
834 int32_t *raw_samples_end = bd->raw_samples + bd->block_length;
835 int32_t *lpc_cof_reversed = ctx->lpc_cof_reversed_buffer;
836
837 // reverse long-term prediction
838 if (*bd->use_ltp) {
839 int ltp_smp;
840
841 for (ltp_smp = FFMAX(*bd->ltp_lag - 2, 0); ltp_smp < block_length; ltp_smp++) {
842 int center = ltp_smp - *bd->ltp_lag;
843 int begin = FFMAX(0, center - 2);
844 int end = center + 3;
845 int tab = 5 - (end - begin);
846 int base;
847
848 y = 1 << 6;
849
850 for (base = begin; base < end; base++, tab++)
851 y += MUL64(bd->ltp_gain[tab], raw_samples[base]);
852
853 raw_samples[ltp_smp] += y >> 7;
854 }
855 }
856
857 // reconstruct all samples from residuals
858 if (bd->ra_block) {
859 for (smp = 0; smp < opt_order; smp++) {
860 y = 1 << 19;
861
862 for (sb = 0; sb < smp; sb++)
863 y += MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
864
865 *raw_samples++ -= y >> 20;
866 parcor_to_lpc(smp, quant_cof, lpc_cof);
867 }
868 } else {
869 for (k = 0; k < opt_order; k++)
870 parcor_to_lpc(k, quant_cof, lpc_cof);
871
872 // store previous samples in case that they have to be altered
873 if (bd->store_prev_samples)
874 memcpy(bd->prev_raw_samples, raw_samples - sconf->max_order,
875 sizeof(*bd->prev_raw_samples) * sconf->max_order);
876
877 // reconstruct difference signal for prediction (joint-stereo)
878 if (bd->js_blocks && bd->raw_other) {
879 int32_t *left, *right;

Callers 1

decode_blockFunction · 0.85

Calls 2

parcor_to_lpcFunction · 0.85
MUL64Function · 0.50

Tested by

no test coverage detected