History

binkaudio: convert to lavu/tx

Lynne committed 3 years ago

Commit ca8aaf21 parent a56d7e02 files · +23 −23Browse files

Unified · Split

2 files
  1. configure +2 −2
  2. libavcodec/binkaudio.c +21 −21
configure+2−2
@@ -2772,8 +2772,8 @@ asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp" · 2771 unmodified lines
27722772 atrac1_decoder_select="sinewin"
27732773 av1_decoder_select="av1_frame_split_bsf cbs_av1"
27742774 bink_decoder_select="blockdsp hpeldsp"
2775−binkaudio_dct_decoder_select="dct wma_freqs"
2776−binkaudio_rdft_decoder_select="rdft wma_freqs"
2775+binkaudio_dct_decoder_select="wma_freqs"
2776+binkaudio_rdft_decoder_select="wma_freqs"
27772777 cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
27782778 clearvideo_decoder_select="idctdsp"
27792779 cllc_decoder_select="bswapdsp"
libavcodec/binkaudio.c+21−21
@@ -33,15 +33,14 @@ · 32 unmodified lines
3333 #include "libavutil/channel_layout.h"
3434 #include "libavutil/intfloat.h"
3535 #include "libavutil/mem_internal.h"
36+#include "libavutil/tx.h"
3637
3738 #define BITSTREAM_READER_LE
3839 #include "avcodec.h"
39−#include "dct.h"
4040 #include "decode.h"
4141 #include "get_bits.h"
4242 #include "codec_internal.h"
4343 #include "internal.h"
44−#include "rdft.h"
4544 #include "wma_freqs.h"
4645
4746 #define MAX_DCT_CHANNELS 6
@@ -63,10 +62,8 @@ typedef struct BinkAudioContext { · 15 unmodified lines
6362 float previous[MAX_DCT_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block
6463 float quant_table[96];
6564 AVPacket *pkt;
66− union {
67− RDFTContext rdft;
68− DCTContext dct;
69− } trans;
65+ AVTXContext *tx;
66+ av_tx_fn tx_fn;
7067 } BinkAudioContext;
7168
7269
@@ -138,12 +135,15 @@ static av_cold int decode_init(AVCodecContext *avctx) · 65 unmodified lines
138135
139136 s->first = 1;
140137
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 {
146145 av_assert0(0);
146+ }
147147 if (ret < 0)
148148 return ret;
149149
@@ -177,13 +177,12 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 27 unmodified lines
177177 float q, quant[25];
178178 int width, coeff;
179179 GetBitContext *gb = &s->gb;
180+ LOCAL_ALIGNED_32(float, coeffs, [4098]);
180181
181182 if (use_dct)
182183 skip_bits(gb, 2);
183184
184185 for (ch = 0; ch < channels; ch++) {
185− FFTSample *coeffs = out[ch + ch_offset];
186−
187186 if (s->version_b) {
188187 if (get_bits_left(gb) < 64)
189188 return AVERROR_INVALIDDATA;
@@ -251,10 +250,15 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 61 unmodified lines
251250
252251 if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
253252 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));
255261 }
256− else if (CONFIG_BINKAUDIO_RDFT_DECODER)
257− s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs);
258262 }
259263
260264 for (ch = 0; ch < channels; ch++) {
@@ -278,11 +282,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct, · 17 unmodified lines
278282 static av_cold int decode_end(AVCodecContext *avctx)
279283 {
280284 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);
286286 return 0;
287287 }
288288

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t