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