Commit 3a651f59 authored by Diego Biurrun's avatar Diego Biurrun

dca: Move data tables from a header to an object file

This allows sharing them with the DCA XLL extension w/o duplication.
parent 65df9904
...@@ -157,7 +157,8 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o ...@@ -157,7 +157,8 @@ OBJS-$(CONFIG_COMFORTNOISE_ENCODER) += cngenc.o
OBJS-$(CONFIG_CSCD_DECODER) += cscd.o OBJS-$(CONFIG_CSCD_DECODER) += cscd.o
OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o
OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \ OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o \
dca_exss.o synth_filter.o dcadata.o dca_exss.o \
synth_filter.o
OBJS-$(CONFIG_DFA_DECODER) += dfa.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o
OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o
OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -168,8 +168,8 @@ static av_cold void dca_init_vlcs(void) ...@@ -168,8 +168,8 @@ static av_cold void dca_init_vlcs(void)
dca_bitalloc_index.offset = 1; dca_bitalloc_index.offset = 1;
dca_bitalloc_index.wrap = 2; dca_bitalloc_index.wrap = 2;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
dca_bitalloc_index.vlc[i].table = &dca_table[dca_vlc_offs[i]]; dca_bitalloc_index.vlc[i].table = &dca_table[ff_dca_vlc_offs[i]];
dca_bitalloc_index.vlc[i].table_allocated = dca_vlc_offs[i + 1] - dca_vlc_offs[i]; dca_bitalloc_index.vlc[i].table_allocated = ff_dca_vlc_offs[i + 1] - ff_dca_vlc_offs[i];
init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12, init_vlc(&dca_bitalloc_index.vlc[i], bitalloc_12_vlc_bits[i], 12,
bitalloc_12_bits[i], 1, 1, bitalloc_12_bits[i], 1, 1,
bitalloc_12_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); bitalloc_12_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
...@@ -177,8 +177,8 @@ static av_cold void dca_init_vlcs(void) ...@@ -177,8 +177,8 @@ static av_cold void dca_init_vlcs(void)
dca_scalefactor.offset = -64; dca_scalefactor.offset = -64;
dca_scalefactor.wrap = 2; dca_scalefactor.wrap = 2;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
dca_scalefactor.vlc[i].table = &dca_table[dca_vlc_offs[i + 5]]; dca_scalefactor.vlc[i].table = &dca_table[ff_dca_vlc_offs[i + 5]];
dca_scalefactor.vlc[i].table_allocated = dca_vlc_offs[i + 6] - dca_vlc_offs[i + 5]; dca_scalefactor.vlc[i].table_allocated = ff_dca_vlc_offs[i + 6] - ff_dca_vlc_offs[i + 5];
init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129, init_vlc(&dca_scalefactor.vlc[i], SCALES_VLC_BITS, 129,
scales_bits[i], 1, 1, scales_bits[i], 1, 1,
scales_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); scales_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
...@@ -186,8 +186,8 @@ static av_cold void dca_init_vlcs(void) ...@@ -186,8 +186,8 @@ static av_cold void dca_init_vlcs(void)
dca_tmode.offset = 0; dca_tmode.offset = 0;
dca_tmode.wrap = 1; dca_tmode.wrap = 1;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
dca_tmode.vlc[i].table = &dca_table[dca_vlc_offs[i + 10]]; dca_tmode.vlc[i].table = &dca_table[ff_dca_vlc_offs[i + 10]];
dca_tmode.vlc[i].table_allocated = dca_vlc_offs[i + 11] - dca_vlc_offs[i + 10]; dca_tmode.vlc[i].table_allocated = ff_dca_vlc_offs[i + 11] - ff_dca_vlc_offs[i + 10];
init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4, init_vlc(&dca_tmode.vlc[i], tmode_vlc_bits[i], 4,
tmode_bits[i], 1, 1, tmode_bits[i], 1, 1,
tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); tmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC);
...@@ -199,8 +199,8 @@ static av_cold void dca_init_vlcs(void) ...@@ -199,8 +199,8 @@ static av_cold void dca_init_vlcs(void)
break; break;
dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i]; dca_smpl_bitalloc[i + 1].offset = bitalloc_offsets[i];
dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4); dca_smpl_bitalloc[i + 1].wrap = 1 + (j > 4);
dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[dca_vlc_offs[c]]; dca_smpl_bitalloc[i + 1].vlc[j].table = &dca_table[ff_dca_vlc_offs[c]];
dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = dca_vlc_offs[c + 1] - dca_vlc_offs[c]; dca_smpl_bitalloc[i + 1].vlc[j].table_allocated = ff_dca_vlc_offs[c + 1] - ff_dca_vlc_offs[c];
init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j], init_vlc(&dca_smpl_bitalloc[i + 1].vlc[j], bitalloc_maxbits[i][j],
bitalloc_sizes[i], bitalloc_sizes[i],
...@@ -293,7 +293,7 @@ static int dca_parse_frame_header(DCAContext *s) ...@@ -293,7 +293,7 @@ static int dca_parse_frame_header(DCAContext *s)
if (!s->sample_rate) if (!s->sample_rate)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
s->bit_rate_index = get_bits(&s->gb, 5); s->bit_rate_index = get_bits(&s->gb, 5);
s->bit_rate = dca_bit_rates[s->bit_rate_index]; s->bit_rate = ff_dca_bit_rates[s->bit_rate_index];
if (!s->bit_rate) if (!s->bit_rate)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -428,10 +428,10 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) ...@@ -428,10 +428,10 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
if (s->scalefactor_huffman[j] == 6) { if (s->scalefactor_huffman[j] == 6) {
scale_table = scale_factor_quant7; scale_table = ff_dca_scale_factor_quant7;
log_size = 7; log_size = 7;
} else { } else {
scale_table = scale_factor_quant6; scale_table = ff_dca_scale_factor_quant6;
log_size = 6; log_size = 6;
} }
...@@ -520,7 +520,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index) ...@@ -520,7 +520,7 @@ static int dca_subframe_header(DCAContext *s, int base_channel, int block_index)
/* Scale factor index */ /* Scale factor index */
skip_bits(&s->gb, 1); skip_bits(&s->gb, 1);
s->lfe_scale_factor = scale_factor_quant7[get_bits(&s->gb, 7)]; s->lfe_scale_factor = ff_dca_scale_factor_quant7[get_bits(&s->gb, 7)];
/* Quantization step size * scale factor */ /* Quantization step size * scale factor */
lfe_scale = 0.035 * s->lfe_scale_factor; lfe_scale = 0.035 * s->lfe_scale_factor;
...@@ -544,9 +544,9 @@ static void qmf_32_subbands(DCAContext *s, int chans, ...@@ -544,9 +544,9 @@ static void qmf_32_subbands(DCAContext *s, int chans,
/* Select filter */ /* Select filter */
if (!s->multirate_inter) /* Non-perfect reconstruction */ if (!s->multirate_inter) /* Non-perfect reconstruction */
prCoeff = fir_32bands_nonperfect; prCoeff = ff_dca_fir_32bands_nonperfect;
else /* Perfect reconstruction */ else /* Perfect reconstruction */
prCoeff = fir_32bands_perfect; prCoeff = ff_dca_fir_32bands_perfect;
s->dcadsp.qmf_32_subbands(samples_in, sb_act, &s->synth, &s->imdct, s->dcadsp.qmf_32_subbands(samples_in, sb_act, &s->synth, &s->imdct,
s->subband_fir_hist[chans], s->subband_fir_hist[chans],
...@@ -574,10 +574,10 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select, ...@@ -574,10 +574,10 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
/* Select decimation filter */ /* Select decimation filter */
if (decimation_select == 1) { if (decimation_select == 1) {
idx = 1; idx = 1;
prCoeff = lfe_fir_128; prCoeff = ff_dca_lfe_fir_128;
} else { } else {
idx = 0; idx = 0;
prCoeff = lfe_fir_64; prCoeff = ff_dca_lfe_fir_64;
} }
/* Interpolation */ /* Interpolation */
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) { for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
...@@ -661,8 +661,8 @@ static void dca_downmix(float **samples, int srcfmt, int lfe_present, ...@@ -661,8 +661,8 @@ static void dca_downmix(float **samples, int srcfmt, int lfe_present,
break; break;
} }
if (lfe_present) { if (lfe_present) {
int lf_buf = dca_lfe_index[srcfmt]; int lf_buf = ff_dca_lfe_index[srcfmt];
int lf_idx = dca_channels[srcfmt]; int lf_idx = ff_dca_channels[srcfmt];
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0]; samples[0][i] += samples[lf_buf][i] * coef[lf_idx][0];
samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1]; samples[1][i] += samples[lf_buf][i] * coef[lf_idx][1];
...@@ -714,9 +714,9 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) ...@@ -714,9 +714,9 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
/* Select quantization step size table */ /* Select quantization step size table */
if (s->bit_rate_index == 0x1f) if (s->bit_rate_index == 0x1f)
quant_step_table = lossless_quant_d; quant_step_table = ff_dca_lossless_quant_d;
else else
quant_step_table = lossy_quant_d; quant_step_table = ff_dca_lossy_quant_d;
for (k = base_channel; k < s->prim_channels; k++) { for (k = base_channel; k < s->prim_channels; k++) {
float rscale[DCA_SUBBANDS]; float rscale[DCA_SUBBANDS];
...@@ -793,24 +793,24 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) ...@@ -793,24 +793,24 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
if (s->prediction_mode[k][l]) { if (s->prediction_mode[k][l]) {
int n; int n;
if (s->predictor_history) if (s->predictor_history)
subband_samples[k][l][0] += (adpcm_vb[s->prediction_vq[k][l]][0] * subband_samples[k][l][0] += (ff_dca_adpcm_vb[s->prediction_vq[k][l]][0] *
s->subband_samples_hist[k][l][3] + s->subband_samples_hist[k][l][3] +
adpcm_vb[s->prediction_vq[k][l]][1] * ff_dca_adpcm_vb[s->prediction_vq[k][l]][1] *
s->subband_samples_hist[k][l][2] + s->subband_samples_hist[k][l][2] +
adpcm_vb[s->prediction_vq[k][l]][2] * ff_dca_adpcm_vb[s->prediction_vq[k][l]][2] *
s->subband_samples_hist[k][l][1] + s->subband_samples_hist[k][l][1] +
adpcm_vb[s->prediction_vq[k][l]][3] * ff_dca_adpcm_vb[s->prediction_vq[k][l]][3] *
s->subband_samples_hist[k][l][0]) * s->subband_samples_hist[k][l][0]) *
(1.0f / 8192); (1.0f / 8192);
for (m = 1; m < 8; m++) { for (m = 1; m < 8; m++) {
float sum = adpcm_vb[s->prediction_vq[k][l]][0] * float sum = ff_dca_adpcm_vb[s->prediction_vq[k][l]][0] *
subband_samples[k][l][m - 1]; subband_samples[k][l][m - 1];
for (n = 2; n <= 4; n++) for (n = 2; n <= 4; n++)
if (m >= n) if (m >= n)
sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] * sum += ff_dca_adpcm_vb[s->prediction_vq[k][l]][n - 1] *
subband_samples[k][l][m - n]; subband_samples[k][l][m - n];
else if (s->predictor_history) else if (s->predictor_history)
sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] * sum += ff_dca_adpcm_vb[s->prediction_vq[k][l]][n - 1] *
s->subband_samples_hist[k][l][m - n + 4]; s->subband_samples_hist[k][l][m - n + 4];
subband_samples[k][l][m] += sum * 1.0f / 8192; subband_samples[k][l][m] += sum * 1.0f / 8192;
} }
...@@ -827,7 +827,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index) ...@@ -827,7 +827,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
s->debug_flag |= 0x01; s->debug_flag |= 0x01;
} }
s->dcadsp.decode_hf(subband_samples[k], s->high_freq_vq[k], s->dcadsp.decode_hf(subband_samples[k], s->high_freq_vq[k],
high_freq_vq, subsubframe * 8, ff_dca_high_freq_vq, subsubframe * 8,
s->scale_factor[k], s->vq_start_subband[k], s->scale_factor[k], s->vq_start_subband[k],
s->subband_activity[k]); s->subband_activity[k]);
} }
...@@ -866,7 +866,7 @@ static int dca_filter_channels(DCAContext *s, int block_index) ...@@ -866,7 +866,7 @@ static int dca_filter_channels(DCAContext *s, int block_index)
if (s->lfe) { if (s->lfe) {
lfe_interpolation_fir(s, s->lfe, 2 * s->lfe, lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
s->lfe_data + 2 * s->lfe * (block_index + 4), s->lfe_data + 2 * s->lfe * (block_index + 4),
s->samples_chanptr[dca_lfe_index[s->amode]]); s->samples_chanptr[ff_dca_lfe_index[s->amode]]);
/* Outputs 20bits pcm samples */ /* Outputs 20bits pcm samples */
} }
...@@ -947,7 +947,7 @@ static int dca_subframe_footer(DCAContext *s, int base_channel) ...@@ -947,7 +947,7 @@ static int dca_subframe_footer(DCAContext *s, int base_channel)
am); am);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
for (out = 0; out < dca_channels[s->core_downmix_amode]; out++) { for (out = 0; out < ff_dca_channels[s->core_downmix_amode]; out++) {
for (in = 0; in < s->prim_channels + !!s->lfe; in++) { for (in = 0; in < s->prim_channels + !!s->lfe; in++) {
uint16_t tmp = get_bits(&s->gb, 9); uint16_t tmp = get_bits(&s->gb, 9);
if ((tmp & 0xFF) > 241) { if ((tmp & 0xFF) > 241) {
...@@ -1029,7 +1029,7 @@ static float dca_dmix_code(unsigned code) ...@@ -1029,7 +1029,7 @@ static float dca_dmix_code(unsigned code)
{ {
int sign = (code >> 8) - 1; int sign = (code >> 8) - 1;
code &= 0xff; code &= 0xff;
return ((dca_dmixtable[code] ^ sign) - sign) * (1.0 / (1U << 15)); return ((ff_dca_dmixtable[code] ^ sign) - sign) * (1.0 / (1U << 15));
} }
/** /**
...@@ -1207,18 +1207,18 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -1207,18 +1207,18 @@ FF_ENABLE_DEPRECATION_WARNINGS
avctx->channel_layout |= AV_CH_BACK_CENTER; avctx->channel_layout |= AV_CH_BACK_CENTER;
if (s->lfe) { if (s->lfe) {
avctx->channel_layout |= AV_CH_LOW_FREQUENCY; avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
s->channel_order_tab = dca_channel_reorder_lfe_xch[s->amode]; s->channel_order_tab = ff_dca_channel_reorder_lfe_xch[s->amode];
} else { } else {
s->channel_order_tab = dca_channel_reorder_nolfe_xch[s->amode]; s->channel_order_tab = ff_dca_channel_reorder_nolfe_xch[s->amode];
} }
} else { } else {
channels = num_core_channels + !!s->lfe; channels = num_core_channels + !!s->lfe;
s->xch_present = 0; /* disable further xch processing */ s->xch_present = 0; /* disable further xch processing */
if (s->lfe) { if (s->lfe) {
avctx->channel_layout |= AV_CH_LOW_FREQUENCY; avctx->channel_layout |= AV_CH_LOW_FREQUENCY;
s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; s->channel_order_tab = ff_dca_channel_reorder_lfe[s->amode];
} else } else
s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; s->channel_order_tab = ff_dca_channel_reorder_nolfe[s->amode];
} }
if (channels > !!s->lfe && if (channels > !!s->lfe &&
...@@ -1246,20 +1246,20 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -1246,20 +1246,20 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->output = s->core_downmix_amode; s->output = s->core_downmix_amode;
} else { } else {
int am = s->amode & DCA_CHANNEL_MASK; int am = s->amode & DCA_CHANNEL_MASK;
if (am >= FF_ARRAY_ELEMS(dca_default_coeffs)) { if (am >= FF_ARRAY_ELEMS(ff_dca_default_coeffs)) {
av_log(s->avctx, AV_LOG_ERROR, av_log(s->avctx, AV_LOG_ERROR,
"Invalid channel mode %d\n", am); "Invalid channel mode %d\n", am);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (num_core_channels + !!s->lfe > if (num_core_channels + !!s->lfe >
FF_ARRAY_ELEMS(dca_default_coeffs[0])) { FF_ARRAY_ELEMS(ff_dca_default_coeffs[0])) {
avpriv_request_sample(s->avctx, "Downmixing %d channels", avpriv_request_sample(s->avctx, "Downmixing %d channels",
s->prim_channels + !!s->lfe); s->prim_channels + !!s->lfe);
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
for (i = 0; i < num_core_channels + !!s->lfe; i++) { for (i = 0; i < num_core_channels + !!s->lfe; i++) {
s->downmix_coef[i][0] = dca_default_coeffs[am][i][0]; s->downmix_coef[i][0] = ff_dca_default_coeffs[am][i][0];
s->downmix_coef[i][1] = dca_default_coeffs[am][i][1]; s->downmix_coef[i][1] = ff_dca_default_coeffs[am][i][1];
} }
} }
av_dlog(s->avctx, "Stereo downmix coeffs:\n"); av_dlog(s->avctx, "Stereo downmix coeffs:\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment