mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-28 12:32:17 +02:00
ac3dec: cosmetics: pretty-printing
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
This commit is contained in:
parent
a4e21baa74
commit
541d083a40
@ -44,7 +44,6 @@
|
||||
*/
|
||||
static uint8_t ungroup_3_in_7_bits_tab[128][3];
|
||||
|
||||
|
||||
/** tables for ungrouping mantissas */
|
||||
static int b1_mantissas[32][3];
|
||||
static int b2_mantissas[128][3];
|
||||
@ -167,7 +166,6 @@ static av_cold void ac3_tables_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AVCodec initialization
|
||||
*/
|
||||
@ -357,7 +355,8 @@ static void set_downmix_coeffs(AC3DecodeContext *s)
|
||||
|
||||
if (s->output_mode == AC3_CHMODE_MONO) {
|
||||
for (i = 0; i < s->fbw_channels; i++)
|
||||
s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] + s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB;
|
||||
s->downmix_coeffs[i][0] = (s->downmix_coeffs[i][0] +
|
||||
s->downmix_coeffs[i][1]) * LEVEL_MINUS_3DB;
|
||||
}
|
||||
}
|
||||
|
||||
@ -414,7 +413,8 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s)
|
||||
if (s->channel_in_cpl[ch]) {
|
||||
int cpl_coord = s->cpl_coords[ch][band] << 5;
|
||||
for (bin = band_start; bin < band_end; bin++) {
|
||||
s->fixed_coeffs[ch][bin] = MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord);
|
||||
s->fixed_coeffs[ch][bin] =
|
||||
MULH(s->fixed_coeffs[CPL_CH][bin] << 4, cpl_coord);
|
||||
}
|
||||
if (ch == 2 && s->phase_flags[band]) {
|
||||
for (bin = band_start; bin < band_end; bin++)
|
||||
@ -467,8 +467,7 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma
|
||||
if (m->b1) {
|
||||
m->b1--;
|
||||
mantissa = m->b1_mant[m->b1];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
int bits = get_bits(gbc, 5);
|
||||
mantissa = b1_mantissas[bits][0];
|
||||
m->b1_mant[1] = b1_mantissas[bits][1];
|
||||
@ -480,8 +479,7 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma
|
||||
if (m->b2) {
|
||||
m->b2--;
|
||||
mantissa = m->b2_mant[m->b2];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
int bits = get_bits(gbc, 7);
|
||||
mantissa = b2_mantissas[bits][0];
|
||||
m->b2_mant[1] = b2_mantissas[bits][1];
|
||||
@ -496,8 +494,7 @@ static void ac3_decode_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, ma
|
||||
if (m->b4) {
|
||||
m->b4 = 0;
|
||||
mantissa = m->b4_mant;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
int bits = get_bits(gbc, 7);
|
||||
mantissa = b4_mantissas[bits][0];
|
||||
m->b4_mant = b4_mantissas[bits][1];
|
||||
@ -626,13 +623,15 @@ static inline void do_imdct(AC3DecodeContext *s, int channels)
|
||||
for (i = 0; i < 128; i++)
|
||||
x[i] = s->transform_coeffs[ch][2 * i];
|
||||
s->imdct_256.imdct_half(&s->imdct_256, s->tmp_output, x);
|
||||
s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
|
||||
s->dsp.vector_fmul_window(s->output[ch - 1], s->delay[ch - 1],
|
||||
s->tmp_output, s->window, 128);
|
||||
for (i = 0; i < 128; i++)
|
||||
x[i] = s->transform_coeffs[ch][2 * i + 1];
|
||||
s->imdct_256.imdct_half(&s->imdct_256, s->delay[ch - 1], x);
|
||||
} else {
|
||||
s->imdct_512.imdct_half(&s->imdct_512, s->tmp_output, s->transform_coeffs[ch]);
|
||||
s->dsp.vector_fmul_window(s->output[ch-1], s->delay[ch-1], s->tmp_output, s->window, 128);
|
||||
s->dsp.vector_fmul_window(s->output[ch - 1], s->delay[ch - 1],
|
||||
s->tmp_output, s->window, 128);
|
||||
memcpy(s->delay[ch - 1], s->tmp_output + 128, 128 * sizeof(float));
|
||||
}
|
||||
}
|
||||
@ -641,7 +640,8 @@ static inline void do_imdct(AC3DecodeContext *s, int channels)
|
||||
/**
|
||||
* Downmix the output to mono or stereo.
|
||||
*/
|
||||
void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len)
|
||||
void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2],
|
||||
int out_ch, int in_ch, int len)
|
||||
{
|
||||
int i, j;
|
||||
float v0, v1;
|
||||
@ -881,7 +881,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
bandsize = s->spx_band_sizes[bnd];
|
||||
nratio = ((float)((bin + (bandsize >> 1))) / s->spx_dst_end_freq) - spx_blend;
|
||||
nratio = av_clipf(nratio, 0.0f, 1.0f);
|
||||
nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3) to give unity variance
|
||||
nblend = sqrtf(3.0f * nratio); // noise is scaled by sqrt(3)
|
||||
// to give unity variance
|
||||
sblend = sqrtf(1.0f - nratio);
|
||||
bin += bandsize;
|
||||
|
||||
@ -965,7 +966,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
}
|
||||
} else if (!s->eac3) {
|
||||
if (!blk) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must be present in block 0\n");
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must "
|
||||
"be present in block 0\n");
|
||||
return -1;
|
||||
} else {
|
||||
s->cpl_in_use[blk] = s->cpl_in_use[blk-1];
|
||||
@ -994,7 +996,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord);
|
||||
}
|
||||
} else if (!blk) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must be present in block 0\n");
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must "
|
||||
"be present in block 0\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
@ -1022,7 +1025,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
for (bnd = 0; bnd < s->num_rematrixing_bands; bnd++)
|
||||
s->rematrixing_flags[bnd] = get_bits1(gbc);
|
||||
} else if (!blk) {
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Warning: new rematrixing strategy not present in block 0\n");
|
||||
av_log(s->avctx, AV_LOG_WARNING, "Warning: "
|
||||
"new rematrixing strategy not present in block 0\n");
|
||||
s->num_rematrixing_bands = 0;
|
||||
}
|
||||
}
|
||||
@ -1090,7 +1094,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
for (ch = !cpl_in_use; ch <= s->channels; ch++)
|
||||
bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2);
|
||||
} else if (!blk) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must be present in block 0\n");
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must "
|
||||
"be present in block 0\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1159,7 +1164,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
s->bit_alloc_params.cpl_fast_leak = fl;
|
||||
s->bit_alloc_params.cpl_slow_leak = sl;
|
||||
} else if (!s->eac3 && !blk) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must be present in block 0\n");
|
||||
av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must "
|
||||
"be present in block 0\n");
|
||||
return -1;
|
||||
}
|
||||
s->first_cpl_leak = 0;
|
||||
@ -1253,7 +1259,8 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
} else {
|
||||
gain *= s->dynamic_range[0];
|
||||
}
|
||||
s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch], s->fixed_coeffs[ch], gain, 256);
|
||||
s->fmt_conv.int32_to_float_fmul_scalar(s->transform_coeffs[ch],
|
||||
s->fixed_coeffs[ch], gain, 256);
|
||||
}
|
||||
|
||||
/* apply spectral extension to high frequency bins */
|
||||
@ -1278,16 +1285,19 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
|
||||
do_imdct(s, s->channels);
|
||||
|
||||
if (downmix_output) {
|
||||
s->dsp.ac3_downmix(s->output, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256);
|
||||
s->dsp.ac3_downmix(s->output, s->downmix_coeffs,
|
||||
s->out_channels, s->fbw_channels, 256);
|
||||
}
|
||||
} else {
|
||||
if (downmix_output) {
|
||||
s->dsp.ac3_downmix(s->transform_coeffs+1, s->downmix_coeffs, s->out_channels, s->fbw_channels, 256);
|
||||
s->dsp.ac3_downmix(s->transform_coeffs + 1, s->downmix_coeffs,
|
||||
s->out_channels, s->fbw_channels, 256);
|
||||
}
|
||||
|
||||
if (downmix_output && !s->downmixed) {
|
||||
s->downmixed = 1;
|
||||
s->dsp.ac3_downmix(s->delay, s->downmix_coeffs, s->out_channels, s->fbw_channels, 128);
|
||||
s->dsp.ac3_downmix(s->delay, s->downmix_coeffs, s->out_channels,
|
||||
s->fbw_channels, 128);
|
||||
}
|
||||
|
||||
do_imdct(s, s->out_channels);
|
||||
@ -1344,7 +1354,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
||||
/* skip frame if CRC is ok. otherwise use error concealment. */
|
||||
/* TODO: add support for substreams and dependent frames */
|
||||
if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT || s->substreamid) {
|
||||
av_log(avctx, AV_LOG_ERROR, "unsupported frame type : skipping frame\n");
|
||||
av_log(avctx, AV_LOG_ERROR, "unsupported frame type : "
|
||||
"skipping frame\n");
|
||||
*got_frame_ptr = 0;
|
||||
return s->frame_size;
|
||||
} else {
|
||||
@ -1362,7 +1373,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
|
||||
err = AAC_AC3_PARSE_ERROR_FRAME_SIZE;
|
||||
} else if (avctx->err_recognition & AV_EF_CRCCHECK) {
|
||||
/* check for crc mismatch */
|
||||
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) {
|
||||
if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2],
|
||||
s->frame_size - 2)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n");
|
||||
err = AAC_AC3_PARSE_ERROR_CRC;
|
||||
}
|
||||
@ -1474,9 +1486,9 @@ AVCodec ff_ac3_decoder = {
|
||||
.decode = ac3_decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"),
|
||||
.sample_fmts = (const enum AVSampleFormat[]) {
|
||||
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
|
||||
},
|
||||
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
AV_SAMPLE_FMT_NONE },
|
||||
.priv_class = &ac3_decoder_class,
|
||||
};
|
||||
|
||||
@ -1487,6 +1499,7 @@ static const AVClass eac3_decoder_class = {
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
AVCodec ff_eac3_decoder = {
|
||||
.name = "eac3",
|
||||
.type = AVMEDIA_TYPE_AUDIO,
|
||||
@ -1497,9 +1510,9 @@ AVCodec ff_eac3_decoder = {
|
||||
.decode = ac3_decode_frame,
|
||||
.capabilities = CODEC_CAP_DR1,
|
||||
.long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"),
|
||||
.sample_fmts = (const enum AVSampleFormat[]) {
|
||||
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE
|
||||
},
|
||||
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
||||
AV_SAMPLE_FMT_S16,
|
||||
AV_SAMPLE_FMT_NONE },
|
||||
.priv_class = &eac3_decoder_class,
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user