mirror of https://git.ffmpeg.org/ffmpeg.git
dca: K&R formatting cosmetics
Signed-off-by: Diego Biurrun <diego@biurrun.de>
This commit is contained in:
parent
2e70b2de58
commit
f37b4efe03
156
libavcodec/dca.c
156
libavcodec/dca.c
|
@ -127,7 +127,6 @@ static const int dca_ext_audio_descr_mask[] = {
|
||||||
* OV -> center back
|
* OV -> center back
|
||||||
* All 2 channel configurations -> AV_CH_LAYOUT_STEREO
|
* All 2 channel configurations -> AV_CH_LAYOUT_STEREO
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const uint64_t dca_core_channel_layout[] = {
|
static const uint64_t dca_core_channel_layout[] = {
|
||||||
AV_CH_FRONT_CENTER, ///< 1, A
|
AV_CH_FRONT_CENTER, ///< 1, A
|
||||||
AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
|
AV_CH_LAYOUT_STEREO, ///< 2, A + B (dual mono)
|
||||||
|
@ -138,13 +137,31 @@ static const uint64_t dca_core_channel_layout[] = {
|
||||||
AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S
|
AV_CH_LAYOUT_STEREO | AV_CH_BACK_CENTER, ///< 3, L + R + S
|
||||||
AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S
|
AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 4, C + L + R + S
|
||||||
AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR
|
AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 4, L + R + SL + SR
|
||||||
AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 5, C + L + R+ SL+SR
|
|
||||||
AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
|
AV_CH_LAYOUT_STEREO | AV_CH_FRONT_CENTER | AV_CH_SIDE_LEFT |
|
||||||
AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT|AV_CH_FRONT_CENTER|AV_CH_BACK_CENTER, ///< 6, C + L + R+ LR + RR + OV
|
AV_CH_SIDE_RIGHT, ///< 5, C + L + R + SL + SR
|
||||||
AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 6, CF+ CR+LF+ RF+LR + RR
|
|
||||||
AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
|
AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
|
||||||
AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2+ SR1 + SR2
|
AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER, ///< 6, CL + CR + L + R + SL + SR
|
||||||
AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_BACK_CENTER|AV_CH_SIDE_RIGHT, ///< 8, CL + C+ CR + L + R + SL + S+ SR
|
|
||||||
|
AV_CH_LAYOUT_STEREO | AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT |
|
||||||
|
AV_CH_FRONT_CENTER | AV_CH_BACK_CENTER, ///< 6, C + L + R + LR + RR + OV
|
||||||
|
|
||||||
|
AV_CH_FRONT_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
|
||||||
|
AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_BACK_CENTER |
|
||||||
|
AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 6, CF + CR + LF + RF + LR + RR
|
||||||
|
|
||||||
|
AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
|
||||||
|
AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
|
||||||
|
AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT, ///< 7, CL + C + CR + L + R + SL + SR
|
||||||
|
|
||||||
|
AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER |
|
||||||
|
AV_CH_LAYOUT_STEREO | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT |
|
||||||
|
AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT, ///< 8, CL + CR + L + R + SL1 + SL2 + SR1 + SR2
|
||||||
|
|
||||||
|
AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_CENTER |
|
||||||
|
AV_CH_FRONT_RIGHT_OF_CENTER | AV_CH_LAYOUT_STEREO |
|
||||||
|
AV_CH_SIDE_LEFT | AV_CH_BACK_CENTER | AV_CH_SIDE_RIGHT, ///< 8, CL + C + CR + L + R + SL + S + SR
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int8_t dca_lfe_index[] = {
|
static const int8_t dca_lfe_index[] = {
|
||||||
|
@ -254,9 +271,11 @@ static BitAlloc dca_tmode; ///< transition mode VLCs
|
||||||
static BitAlloc dca_scalefactor; ///< scalefactor VLCs
|
static BitAlloc dca_scalefactor; ///< scalefactor VLCs
|
||||||
static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
|
static BitAlloc dca_smpl_bitalloc[11]; ///< samples VLCs
|
||||||
|
|
||||||
static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, int idx)
|
static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba,
|
||||||
|
int idx)
|
||||||
{
|
{
|
||||||
return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) + ba->offset;
|
return get_vlc2(gb, ba->vlc[idx].table, ba->vlc[idx].bits, ba->wrap) +
|
||||||
|
ba->offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -417,11 +436,13 @@ static av_cold void dca_init_vlcs(void)
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
for (j = 0; j < 7; j++) {
|
for (j = 0; j < 7; j++) {
|
||||||
if (!bitalloc_codes[i][j]) break;
|
if (!bitalloc_codes[i][j])
|
||||||
|
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[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 = dca_vlc_offs[c + 1] - 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],
|
||||||
bitalloc_bits[i][j], 1, 1,
|
bitalloc_bits[i][j], 1, 1,
|
||||||
|
@ -495,16 +516,21 @@ static int dca_parse_audio_coding_header(DCAContext * s, int base_channel)
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
|
av_log(s->avctx, AV_LOG_DEBUG, "subframes: %i\n", s->subframes);
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
|
av_log(s->avctx, AV_LOG_DEBUG, "prim channels: %i\n", s->prim_channels);
|
||||||
for (i = base_channel; i < s->prim_channels; i++) {
|
for (i = base_channel; i < s->prim_channels; i++) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n", s->subband_activity[i]);
|
av_log(s->avctx, AV_LOG_DEBUG, "subband activity: %i\n",
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n", s->vq_start_subband[i]);
|
s->subband_activity[i]);
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n", s->joint_intensity[i]);
|
av_log(s->avctx, AV_LOG_DEBUG, "vq start subband: %i\n",
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n", s->transient_huffman[i]);
|
s->vq_start_subband[i]);
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n", s->scalefactor_huffman[i]);
|
av_log(s->avctx, AV_LOG_DEBUG, "joint intensity: %i\n",
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n", s->bitalloc_huffman[i]);
|
s->joint_intensity[i]);
|
||||||
|
av_log(s->avctx, AV_LOG_DEBUG, "transient mode codebook: %i\n",
|
||||||
|
s->transient_huffman[i]);
|
||||||
|
av_log(s->avctx, AV_LOG_DEBUG, "scale factor codebook: %i\n",
|
||||||
|
s->scalefactor_huffman[i]);
|
||||||
|
av_log(s->avctx, AV_LOG_DEBUG, "bit allocation quantizer: %i\n",
|
||||||
|
s->bitalloc_huffman[i]);
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
|
av_log(s->avctx, AV_LOG_DEBUG, "quant index huff:");
|
||||||
for (j = 0; j < 11; j++)
|
for (j = 0; j < 11; j++)
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, " %i",
|
av_log(s->avctx, AV_LOG_DEBUG, " %i", s->quant_index_huffman[i][j]);
|
||||||
s->quant_index_huffman[i][j]);
|
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "\n");
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
|
av_log(s->avctx, AV_LOG_DEBUG, "scalefac adj:");
|
||||||
for (j = 0; j < 11; j++)
|
for (j = 0; j < 11; j++)
|
||||||
|
@ -565,7 +591,8 @@ static int dca_parse_frame_header(DCAContext * s)
|
||||||
|
|
||||||
/* FIXME: channels mixing levels */
|
/* FIXME: channels mixing levels */
|
||||||
s->output = s->amode;
|
s->output = s->amode;
|
||||||
if (s->lfe) s->output |= DCA_LFE;
|
if (s->lfe)
|
||||||
|
s->output |= DCA_LFE;
|
||||||
|
|
||||||
#ifdef TRACE
|
#ifdef TRACE
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type);
|
av_log(s->avctx, AV_LOG_DEBUG, "frame type: %i\n", s->frame_type);
|
||||||
|
@ -693,7 +720,8 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
|
||||||
const uint32_t *scale_table;
|
const uint32_t *scale_table;
|
||||||
int scale_sum;
|
int scale_sum;
|
||||||
|
|
||||||
memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2);
|
memset(s->scale_factor[j], 0,
|
||||||
|
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 = scale_factor_quant7;
|
||||||
|
@ -811,9 +839,11 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRACE
|
#ifdef TRACE
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n", s->subsubframes[s->current_subframe]);
|
av_log(s->avctx, AV_LOG_DEBUG, "subsubframes: %i\n",
|
||||||
|
s->subsubframes[s->current_subframe]);
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
|
av_log(s->avctx, AV_LOG_DEBUG, "partial samples: %i\n",
|
||||||
s->partial_samples[s->current_subframe]);
|
s->partial_samples[s->current_subframe]);
|
||||||
|
|
||||||
for (j = base_channel; j < s->prim_channels; j++) {
|
for (j = base_channel; j < s->prim_channels; j++) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
|
av_log(s->avctx, AV_LOG_DEBUG, "prediction mode:");
|
||||||
for (k = 0; k < s->subband_activity[j]; k++)
|
for (k = 0; k < s->subband_activity[j]; k++)
|
||||||
|
@ -863,8 +893,10 @@ static int dca_subframe_header(DCAContext * s, int base_channel, int block_index
|
||||||
if (!base_channel && s->prim_channels > 2 && s->downmix) {
|
if (!base_channel && s->prim_channels > 2 && s->downmix) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "Downmix coeffs:\n");
|
||||||
for (j = 0; j < s->prim_channels; j++) {
|
for (j = 0; j < s->prim_channels; j++) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "Channel 0,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][0]]);
|
av_log(s->avctx, AV_LOG_DEBUG, "Channel 0, %d = %f\n", j,
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "Channel 1,%d = %f\n", j, dca_downmix_coeffs[s->downmix_coef[j][1]]);
|
dca_downmix_coeffs[s->downmix_coef[j][0]]);
|
||||||
|
av_log(s->avctx, AV_LOG_DEBUG, "Channel 1, %d = %f\n", j,
|
||||||
|
dca_downmix_coeffs[s->downmix_coef[j][1]]);
|
||||||
}
|
}
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "\n");
|
av_log(s->avctx, AV_LOG_DEBUG, "\n");
|
||||||
}
|
}
|
||||||
|
@ -916,11 +948,11 @@ static void qmf_32_subbands(DCAContext * s, int chans,
|
||||||
}
|
}
|
||||||
|
|
||||||
s->synth.synth_filter_float(&s->imdct,
|
s->synth.synth_filter_float(&s->imdct,
|
||||||
s->subband_fir_hist[chans], &s->hist_index[chans],
|
s->subband_fir_hist[chans],
|
||||||
|
&s->hist_index[chans],
|
||||||
s->subband_fir_noidea[chans], prCoeff,
|
s->subband_fir_noidea[chans], prCoeff,
|
||||||
samples_out, s->raXin, scale);
|
samples_out, s->raXin, scale);
|
||||||
samples_out += 32;
|
samples_out += 32;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,8 +982,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
|
||||||
}
|
}
|
||||||
/* Interpolation */
|
/* Interpolation */
|
||||||
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
|
for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
|
||||||
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor,
|
s->dcadsp.lfe_fir(samples_out, samples_in, prCoeff, decifactor, scale);
|
||||||
scale);
|
|
||||||
samples_in++;
|
samples_in++;
|
||||||
samples_out += 2 * decifactor;
|
samples_out += 2 * decifactor;
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1155,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
|
||||||
} else {
|
} else {
|
||||||
/* Deal with transients */
|
/* Deal with transients */
|
||||||
int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
|
int sfi = s->transition_mode[k][l] && subsubframe >= s->transition_mode[k][l];
|
||||||
float rscale = quant_step_size * s->scale_factor[k][l][sfi] * s->scalefactor_adj[k][sel];
|
float rscale = quant_step_size * s->scale_factor[k][l][sfi] *
|
||||||
|
s->scalefactor_adj[k][sel];
|
||||||
|
|
||||||
if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
|
if (abits >= 11 || !dca_smpl_bitalloc[abits].vlc[sel].table) {
|
||||||
if (abits <= 7) {
|
if (abits <= 7) {
|
||||||
|
@ -1151,7 +1183,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
|
||||||
} else {
|
} else {
|
||||||
/* Huffman coded */
|
/* Huffman coded */
|
||||||
for (m = 0; m < 8; m++)
|
for (m = 0; m < 8; m++)
|
||||||
block[m] = get_bitalloc(&s->gb, &dca_smpl_bitalloc[abits], sel);
|
block[m] = get_bitalloc(&s->gb,
|
||||||
|
&dca_smpl_bitalloc[abits], sel);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
|
s->fmt_conv.int32_to_float_fmul_scalar(subband_samples[k][l],
|
||||||
|
@ -1172,8 +1205,7 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
|
||||||
else if (s->predictor_history)
|
else if (s->predictor_history)
|
||||||
subband_samples[k][l][m] +=
|
subband_samples[k][l][m] +=
|
||||||
(adpcm_vb[s->prediction_vq[k][l]][n - 1] *
|
(adpcm_vb[s->prediction_vq[k][l]][n - 1] *
|
||||||
s->subband_samples_hist[k][l][m - n +
|
s->subband_samples_hist[k][l][m - n + 4] / 8192);
|
||||||
4] / 8192);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1219,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
|
||||||
int hfvq = s->high_freq_vq[k][l];
|
int hfvq = s->high_freq_vq[k][l];
|
||||||
|
|
||||||
if (!s->debug_flag & 0x01) {
|
if (!s->debug_flag & 0x01) {
|
||||||
av_log(s->avctx, AV_LOG_DEBUG, "Stream with high frequencies VQ coding\n");
|
av_log(s->avctx, AV_LOG_DEBUG,
|
||||||
|
"Stream with high frequencies VQ coding\n");
|
||||||
s->debug_flag |= 0x01;
|
s->debug_flag |= 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1211,7 +1244,8 @@ static int dca_subsubframe(DCAContext * s, int base_channel, int block_index)
|
||||||
/* Backup predictor history for adpcm */
|
/* Backup predictor history for adpcm */
|
||||||
for (k = base_channel; k < s->prim_channels; k++)
|
for (k = base_channel; k < s->prim_channels; k++)
|
||||||
for (l = 0; l < s->vq_start_subband[k]; l++)
|
for (l = 0; l < s->vq_start_subband[k]; l++)
|
||||||
memcpy(s->subband_samples_hist[k][l], &subband_samples[k][l][4],
|
memcpy(s->subband_samples_hist[k][l],
|
||||||
|
&subband_samples[k][l][4],
|
||||||
4 * sizeof(subband_samples[0][0][0]));
|
4 * sizeof(subband_samples[0][0][0]));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1224,9 +1258,10 @@ static int dca_filter_channels(DCAContext * s, int block_index)
|
||||||
|
|
||||||
/* 32 subbands QMF */
|
/* 32 subbands QMF */
|
||||||
for (k = 0; k < s->prim_channels; k++) {
|
for (k = 0; k < s->prim_channels; k++) {
|
||||||
/* static float pcm_to_double[8] =
|
/* static float pcm_to_double[8] = { 32768.0, 32768.0, 524288.0, 524288.0,
|
||||||
{32768.0, 32768.0, 524288.0, 524288.0, 0, 8388608.0, 8388608.0};*/
|
0, 8388608.0, 8388608.0 };*/
|
||||||
qmf_32_subbands(s, k, subband_samples[k], &s->samples[256 * s->channel_order_tab[k]],
|
qmf_32_subbands(s, k, subband_samples[k],
|
||||||
|
&s->samples[256 * s->channel_order_tab[k]],
|
||||||
M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */);
|
M_SQRT1_2 * s->scale_bias /* pcm_to_double[s->source_pcm_res] */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1372,18 +1407,16 @@ static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * ds
|
||||||
static int dca_exss_mask2count(int mask)
|
static int dca_exss_mask2count(int mask)
|
||||||
{
|
{
|
||||||
/* count bits that mean speaker pairs twice */
|
/* count bits that mean speaker pairs twice */
|
||||||
return av_popcount(mask)
|
return av_popcount(mask) +
|
||||||
+ av_popcount(mask & (
|
av_popcount(mask & (DCA_EXSS_CENTER_LEFT_RIGHT |
|
||||||
DCA_EXSS_CENTER_LEFT_RIGHT
|
DCA_EXSS_FRONT_LEFT_RIGHT |
|
||||||
| DCA_EXSS_FRONT_LEFT_RIGHT
|
DCA_EXSS_FRONT_HIGH_LEFT_RIGHT |
|
||||||
| DCA_EXSS_FRONT_HIGH_LEFT_RIGHT
|
DCA_EXSS_WIDE_LEFT_RIGHT |
|
||||||
| DCA_EXSS_WIDE_LEFT_RIGHT
|
DCA_EXSS_SIDE_LEFT_RIGHT |
|
||||||
| DCA_EXSS_SIDE_LEFT_RIGHT
|
DCA_EXSS_SIDE_HIGH_LEFT_RIGHT |
|
||||||
| DCA_EXSS_SIDE_HIGH_LEFT_RIGHT
|
DCA_EXSS_SIDE_REAR_LEFT_RIGHT |
|
||||||
| DCA_EXSS_SIDE_REAR_LEFT_RIGHT
|
DCA_EXSS_REAR_LEFT_RIGHT |
|
||||||
| DCA_EXSS_REAR_LEFT_RIGHT
|
DCA_EXSS_REAR_HIGH_LEFT_RIGHT));
|
||||||
| DCA_EXSS_REAR_HIGH_LEFT_RIGHT
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1544,7 +1577,8 @@ static int dca_exss_parse_asset_header(DCAContext *s)
|
||||||
if (!(extensions_mask & DCA_EXT_CORE))
|
if (!(extensions_mask & DCA_EXT_CORE))
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
|
av_log(s->avctx, AV_LOG_WARNING, "DTS core detection mismatch.\n");
|
||||||
if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask)
|
if ((extensions_mask & DCA_CORE_EXTS) != s->core_ext_mask)
|
||||||
av_log(s->avctx, AV_LOG_WARNING, "DTS extensions detection mismatch (%d, %d)\n",
|
av_log(s->avctx, AV_LOG_WARNING,
|
||||||
|
"DTS extensions detection mismatch (%d, %d)\n",
|
||||||
extensions_mask & DCA_CORE_EXTS, s->core_ext_mask);
|
extensions_mask & DCA_CORE_EXTS, s->core_ext_mask);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1721,7 +1755,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
|
|
||||||
s->core_ext_mask |= DCA_EXT_XCH;
|
s->core_ext_mask |= DCA_EXT_XCH;
|
||||||
|
|
||||||
/* extension amode should == 1, number of channels in extension */
|
/* extension amode(number of channels in extension) should be 1 */
|
||||||
/* AFAIK XCh is not used for more channels */
|
/* AFAIK XCh is not used for more channels */
|
||||||
if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
|
if ((ext_amode = get_bits(&s->gb, 4)) != 1) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
|
av_log(avctx, AV_LOG_ERROR, "XCh extension amode %d not"
|
||||||
|
@ -1732,12 +1766,11 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
/* much like core primary audio coding header */
|
/* much like core primary audio coding header */
|
||||||
dca_parse_audio_coding_header(s, s->xch_base_channel);
|
dca_parse_audio_coding_header(s, s->xch_base_channel);
|
||||||
|
|
||||||
for (i = 0; i < (s->sample_blocks / 8); i++) {
|
for (i = 0; i < (s->sample_blocks / 8); i++)
|
||||||
if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {
|
if ((ret = dca_decode_block(s, s->xch_base_channel, i))) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n");
|
av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
s->xch_present = 1;
|
s->xch_present = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -1754,7 +1787,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
|
if (s->frame_size != (get_bits_count(&s->gb) >> 3) - 4 + fsize96)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n", get_bits_count(&s->gb));
|
av_log(avctx, AV_LOG_DEBUG, "X96 extension found at %d bits\n",
|
||||||
|
get_bits_count(&s->gb));
|
||||||
skip_bits(&s->gb, 12);
|
skip_bits(&s->gb, 12);
|
||||||
av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
|
av_log(avctx, AV_LOG_DEBUG, "FSIZE96 = %d bytes\n", fsize96);
|
||||||
av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
|
av_log(avctx, AV_LOG_DEBUG, "REVNO = %d\n", get_bits(&s->gb, 4));
|
||||||
|
@ -1766,7 +1800,6 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
|
|
||||||
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
|
skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* no supported extensions, skip the rest of the core substream */
|
/* no supported extensions, skip the rest of the core substream */
|
||||||
skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));
|
skip_bits_long(&s->gb, core_ss_end - get_bits_count(&s->gb));
|
||||||
|
@ -1778,8 +1811,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
s->profile = FF_PROFILE_DTS_ES;
|
s->profile = FF_PROFILE_DTS_ES;
|
||||||
|
|
||||||
/* check for ExSS (HD part) */
|
/* check for ExSS (HD part) */
|
||||||
if (s->dca_buffer_size - s->frame_size > 32
|
if (s->dca_buffer_size - s->frame_size > 32 &&
|
||||||
&& get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
|
get_bits_long(&s->gb, 32) == DCA_HD_MARKER)
|
||||||
dca_exss_parse_header(s);
|
dca_exss_parse_header(s);
|
||||||
|
|
||||||
avctx->profile = s->profile;
|
avctx->profile = s->profile;
|
||||||
|
@ -1875,9 +1908,8 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,
|
||||||
|
|
||||||
/* update lfe history */
|
/* update lfe history */
|
||||||
lfe_samples = 2 * s->lfe * (s->sample_blocks / 8);
|
lfe_samples = 2 * s->lfe * (s->sample_blocks / 8);
|
||||||
for (i = 0; i < 2 * s->lfe * 4; i++) {
|
for (i = 0; i < 2 * s->lfe * 4; i++)
|
||||||
s->lfe_data[i] = s->lfe_data[i + lfe_samples];
|
s->lfe_data[i] = s->lfe_data[i + lfe_samples];
|
||||||
}
|
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *) data = s->frame;
|
*(AVFrame *) data = s->frame;
|
||||||
|
@ -1956,8 +1988,8 @@ AVCodec ff_dca_decoder = {
|
||||||
.close = dca_decode_end,
|
.close = dca_decode_end,
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
|
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
|
||||||
.capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
|
.capabilities = CODEC_CAP_CHANNEL_CONF | CODEC_CAP_DR1,
|
||||||
.sample_fmts = (const enum AVSampleFormat[]) {
|
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
||||||
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
|
AV_SAMPLE_FMT_S16,
|
||||||
},
|
AV_SAMPLE_FMT_NONE },
|
||||||
.profiles = NULL_IF_CONFIG_SMALL(profiles),
|
.profiles = NULL_IF_CONFIG_SMALL(profiles),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue