X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fimc.c;h=70ad5b1dbdcdc398e8c2bba2be98c54886a6e322;hb=6a2defd7d8edc79115a2231de80d357e02e4a3ca;hp=82a908160a4ea8d403eec0bd14a5e32125744c8a;hpb=47e12966b75490cfa5fb8ed65a48a9a3d84a7bce;p=ffmpeg diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 82a908160a4..70ad5b1dbdc 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -95,7 +95,7 @@ typedef struct IMCContext { GetBitContext gb; BswapDSPContext bdsp; - AVFloatDSPContext *fdsp; + void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len); FFTContext fft; DECLARE_ALIGNED(32, FFTComplex, samples)[COEFFS / 2]; float *out_samples; @@ -110,6 +110,7 @@ typedef struct IMCContext { static VLC huffman_vlc[4][4]; +#define IMC_VLC_BITS 9 #define VLC_TABLES_SIZE 9512 static const int vlc_offsets[17] = { @@ -179,6 +180,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) { int i, j, ret; IMCContext *q = avctx->priv_data; + AVFloatDSPContext *fdsp; double r1, r2; if (avctx->codec_id == AV_CODEC_ID_IAC && avctx->sample_rate > 96000) { @@ -237,7 +239,7 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) for (j = 0; j < 4; j++) { huffman_vlc[i][j].table = &vlc_tables[vlc_offsets[i * 4 + j]]; huffman_vlc[i][j].table_allocated = vlc_offsets[i * 4 + j + 1] - vlc_offsets[i * 4 + j]; - init_vlc(&huffman_vlc[i][j], 9, imc_huffman_sizes[i], + init_vlc(&huffman_vlc[i][j], IMC_VLC_BITS, imc_huffman_sizes[i], imc_huffman_lens[i][j], 1, 1, imc_huffman_bits[i][j], 2, 2, INIT_VLC_USE_NEW_STATIC); } @@ -252,17 +254,16 @@ static av_cold int imc_decode_init(AVCodecContext *avctx) memcpy(q->weights2, imc_weights2, sizeof(imc_weights2)); } + fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); + if (!fdsp) + return AVERROR(ENOMEM); + q->butterflies_float = fdsp->butterflies_float; + av_free(fdsp); if ((ret = ff_fft_init(&q->fft, 7, 1))) { av_log(avctx, AV_LOG_INFO, "FFT init failed\n"); return ret; } ff_bswapdsp_init(&q->bdsp); - q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT); - if (!q->fdsp) { - ff_fft_end(&q->fft); - - return AVERROR(ENOMEM); - } avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO @@ -348,7 +349,7 @@ static void imc_read_level_coeffs(IMCContext *q, int stream_format_code, levlCoeffs[0] = get_bits(&q->gb, 7); for (i = start; i < BANDS; i++) { levlCoeffs[i] = get_vlc2(&q->gb, hufftab[cb_sel[i]]->table, - hufftab[cb_sel[i]]->bits, 2); + IMC_VLC_BITS, 2); if (levlCoeffs[i] == 17) levlCoeffs[i] += get_bits(&q->gb, 4); } @@ -1050,8 +1051,8 @@ static int imc_decode_frame(AVCodecContext *avctx, void *data, } if (avctx->channels == 2) { - q->fdsp->butterflies_float((float *)frame->extended_data[0], - (float *)frame->extended_data[1], COEFFS); + q->butterflies_float((float *)frame->extended_data[0], + (float *)frame->extended_data[1], COEFFS); } *got_frame_ptr = 1; @@ -1064,7 +1065,6 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) IMCContext *q = avctx->priv_data; ff_fft_end(&q->fft); - av_freep(&q->fdsp); return 0; }