#define SAMPLES_PER_FRAME 1024
#define MDCT_SIZE 512
+#define ATRAC3_VLC_BITS 8
+
typedef struct GainBlock {
AtracGainInfo g_block[4];
} GainBlock;
AtracGCContext gainc_ctx;
FFTContext mdct_ctx;
- AVFloatDSPContext *fdsp;
+ void (*vector_fmul)(float *dst, const float *src0, const float *src1,
+ int len);
} ATRAC3Context;
static DECLARE_ALIGNED(32, float, mdct_window)[MDCT_SIZE];
-static VLC_TYPE atrac3_vlc_table[4096][2];
+static VLC_TYPE atrac3_vlc_table[7 * 1 << ATRAC3_VLC_BITS][2];
static VLC spectral_coeff_tab[7];
/**
q->mdct_ctx.imdct_calc(&q->mdct_ctx, output, input);
/* Perform windowing on the output. */
- q->fdsp->vector_fmul(output, output, mdct_window, MDCT_SIZE);
+ q->vector_fmul(output, output, mdct_window, MDCT_SIZE);
}
/*
av_freep(&q->units);
av_freep(&q->decoded_bytes_buffer);
- av_freep(&q->fdsp);
ff_mdct_end(&q->mdct_ctx);
if (selector != 1) {
for (i = 0; i < num_codes; i++) {
huff_symb = get_vlc2(gb, spectral_coeff_tab[selector-1].table,
- spectral_coeff_tab[selector-1].bits, 3);
+ ATRAC3_VLC_BITS, 1);
huff_symb += 1;
code = huff_symb >> 1;
if (huff_symb & 1)
} else {
for (i = 0; i < num_codes; i++) {
huff_symb = get_vlc2(gb, spectral_coeff_tab[selector - 1].table,
- spectral_coeff_tab[selector - 1].bits, 3);
+ ATRAC3_VLC_BITS, 1);
mantissas[i * 2 ] = mantissa_vlc_tab[huff_symb * 2 ];
mantissas[i * 2 + 1] = mantissa_vlc_tab[huff_symb * 2 + 1];
}
static av_cold void atrac3_init_static_data(void)
{
+ VLC_TYPE (*table)[2] = atrac3_vlc_table;
int i;
init_imdct_window();
/* Initialize the VLC tables. */
for (i = 0; i < 7; i++) {
- spectral_coeff_tab[i].table = &atrac3_vlc_table[atrac3_vlc_offs[i]];
- spectral_coeff_tab[i].table_allocated = atrac3_vlc_offs[i + 1] -
- atrac3_vlc_offs[i ];
- init_vlc(&spectral_coeff_tab[i], 9, huff_tab_sizes[i],
+ spectral_coeff_tab[i].table = table;
+ spectral_coeff_tab[i].table_allocated = 256;
+ init_vlc(&spectral_coeff_tab[i], ATRAC3_VLC_BITS, huff_tab_sizes[i],
huff_bits[i], 1, 1,
huff_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
+ table += 256;
}
}
int version, delay, samples_per_frame, frame_factor;
const uint8_t *edata_ptr = avctx->extradata;
ATRAC3Context *q = avctx->priv_data;
+ AVFloatDSPContext *fdsp;
if (avctx->channels < MIN_CHANNELS || avctx->channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
return AVERROR_INVALIDDATA;
}
- if (avctx->block_align > 1024 || avctx->block_align <= 0)
+ if (avctx->block_align > 4096 || avctx->block_align <= 0)
return AVERROR(EINVAL);
q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
}
ff_atrac_init_gain_compensation(&q->gainc_ctx, 4, 3);
- q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!fdsp)
+ return AVERROR(ENOMEM);
+ q->vector_fmul = fdsp->vector_fmul;
+ av_free(fdsp);
q->units = av_mallocz_array(avctx->channels, sizeof(*q->units));
- if (!q->units || !q->fdsp) {
+ if (!q->units)
return AVERROR(ENOMEM);
- }
return 0;
}