| @@ -33,15 +33,14 @@ · 32 unmodified lines |
| 33 | 33 | #include "libavutil/channel_layout.h" |
| 34 | 34 | #include "libavutil/intfloat.h" |
| 35 | 35 | #include "libavutil/mem_internal.h" |
| 36 | +#include "libavutil/tx.h" |
| 36 | 37 | |
| 37 | 38 | #define BITSTREAM_READER_LE |
| 38 | 39 | #include "avcodec.h" |
| 39 | | −#include "dct.h" |
| 40 | 40 | #include "decode.h" |
| 41 | 41 | #include "get_bits.h" |
| 42 | 42 | #include "codec_internal.h" |
| 43 | 43 | #include "internal.h" |
| 44 | | −#include "rdft.h" |
| 45 | 44 | #include "wma_freqs.h" |
| 46 | 45 | |
| 47 | 46 | #define MAX_DCT_CHANNELS 6 |
| @@ -63,10 +62,8 @@ typedef struct BinkAudioContext { · 15 unmodified lines |
| 63 | 62 | float previous[MAX_DCT_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block |
| 64 | 63 | float quant_table[96]; |
| 65 | 64 | AVPacket *pkt; |
| 66 | | − union { |
| 67 | | − RDFTContext rdft; |
| 68 | | − DCTContext dct; |
| 69 | | − } trans; |
| 65 | + AVTXContext *tx; |
| 66 | + av_tx_fn tx_fn; |
| 70 | 67 | } BinkAudioContext; |
| 71 | 68 | |
| 72 | 69 | |
| @@ -138,12 +135,15 @@ static av_cold int decode_init(AVCodecContext *avctx) · 65 unmodified lines |
| 138 | 135 | |
| 139 | 136 | s->first = 1; |
| 140 | 137 | |
| 141 | | − if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) |
| 142 | | − ret = ff_rdft_init(&s->trans.rdft, frame_len_bits, DFT_C2R); |
| 143 | | − else if (CONFIG_BINKAUDIO_DCT_DECODER) |
| 144 | | − ret = ff_dct_init(&s->trans.dct, frame_len_bits, DCT_III); |
| 145 | | − else |
| 138 | + if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) { |
| 139 | + float scale = 0.5; |
| 140 | + ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_RDFT, 1, 1 << frame_len_bits, &scale, 0); |
| 141 | + } else if (CONFIG_BINKAUDIO_DCT_DECODER) { |
| 142 | + float scale = 1.0 / (1 << frame_len_bits); |
| 143 | + ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_DCT, 1, 1 << (frame_len_bits - 1), &scale, 0); |
| 144 | + } else { |
| 146 | 145 | av_assert0(0); |
| 146 | + } |
| 147 | 147 | if (ret < 0) |
| 148 | 148 | return ret; |
| 149 | 149 | |
| @@ -177,13 +177,12 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 27 unmodified lines |
| 177 | 177 | float q, quant[25]; |
| 178 | 178 | int width, coeff; |
| 179 | 179 | GetBitContext *gb = &s->gb; |
| 180 | + LOCAL_ALIGNED_32(float, coeffs, [4098]); |
| 180 | 181 | |
| 181 | 182 | if (use_dct) |
| 182 | 183 | skip_bits(gb, 2); |
| 183 | 184 | |
| 184 | 185 | for (ch = 0; ch < channels; ch++) { |
| 185 | | − FFTSample *coeffs = out[ch + ch_offset]; |
| 186 | | − |
| 187 | 186 | if (s->version_b) { |
| 188 | 187 | if (get_bits_left(gb) < 64) |
| 189 | 188 | return AVERROR_INVALIDDATA; |
| @@ -251,10 +250,15 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 61 unmodified lines |
| 251 | 250 | |
| 252 | 251 | if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) { |
| 253 | 252 | coeffs[0] /= 0.5; |
| 254 | | − s->trans.dct.dct_calc(&s->trans.dct, coeffs); |
| 253 | + s->tx_fn(s->tx, out[ch + ch_offset], coeffs, sizeof(float)); |
| 254 | + } else if (CONFIG_BINKAUDIO_RDFT_DECODER) { |
| 255 | + for (int i = 2; i < s->frame_len; i += 2) |
| 256 | + coeffs[i + 1] *= -1; |
| 257 | + |
| 258 | + coeffs[s->frame_len + 0] = coeffs[1]; |
| 259 | + coeffs[s->frame_len + 1] = coeffs[1] = 0; |
| 260 | + s->tx_fn(s->tx, out[ch + ch_offset], coeffs, sizeof(AVComplexFloat)); |
| 255 | 261 | } |
| 256 | | − else if (CONFIG_BINKAUDIO_RDFT_DECODER) |
| 257 | | − s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs); |
| 258 | 262 | } |
| 259 | 263 | |
| 260 | 264 | for (ch = 0; ch < channels; ch++) { |
| @@ -278,11 +282,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 17 unmodified lines |
| 278 | 282 | static av_cold int decode_end(AVCodecContext *avctx) |
| 279 | 283 | { |
| 280 | 284 | BinkAudioContext * s = avctx->priv_data; |
| 281 | | − if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) |
| 282 | | − ff_rdft_end(&s->trans.rdft); |
| 283 | | − else if (CONFIG_BINKAUDIO_DCT_DECODER) |
| 284 | | − ff_dct_end(&s->trans.dct); |
| 285 | | − |
| 285 | + av_tx_uninit(&s->tx); |
| 286 | 286 | return 0; |
| 287 | 287 | } |
| 288 | 288 | |