1
0

binkaudio: convert to lavu/tx

This commit is contained in:
Lynne 2022-11-20 04:57:00 +01:00
parent a56d7e0ca3
commit ca8aaf24df
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 23 additions and 23 deletions

4
configure vendored
View File

@ -2772,8 +2772,8 @@ asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
atrac1_decoder_select="sinewin"
av1_decoder_select="av1_frame_split_bsf cbs_av1"
bink_decoder_select="blockdsp hpeldsp"
binkaudio_dct_decoder_select="dct wma_freqs"
binkaudio_rdft_decoder_select="rdft wma_freqs"
binkaudio_dct_decoder_select="wma_freqs"
binkaudio_rdft_decoder_select="wma_freqs"
cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
clearvideo_decoder_select="idctdsp"
cllc_decoder_select="bswapdsp"

View File

@ -33,15 +33,14 @@
#include "libavutil/channel_layout.h"
#include "libavutil/intfloat.h"
#include "libavutil/mem_internal.h"
#include "libavutil/tx.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#include "dct.h"
#include "decode.h"
#include "get_bits.h"
#include "codec_internal.h"
#include "internal.h"
#include "rdft.h"
#include "wma_freqs.h"
#define MAX_DCT_CHANNELS 6
@ -63,10 +62,8 @@ typedef struct BinkAudioContext {
float previous[MAX_DCT_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block
float quant_table[96];
AVPacket *pkt;
union {
RDFTContext rdft;
DCTContext dct;
} trans;
AVTXContext *tx;
av_tx_fn tx_fn;
} BinkAudioContext;
@ -138,12 +135,15 @@ static av_cold int decode_init(AVCodecContext *avctx)
s->first = 1;
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
ret = ff_rdft_init(&s->trans.rdft, frame_len_bits, DFT_C2R);
else if (CONFIG_BINKAUDIO_DCT_DECODER)
ret = ff_dct_init(&s->trans.dct, frame_len_bits, DCT_III);
else
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT) {
float scale = 0.5;
ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_RDFT, 1, 1 << frame_len_bits, &scale, 0);
} else if (CONFIG_BINKAUDIO_DCT_DECODER) {
float scale = 1.0 / (1 << frame_len_bits);
ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_DCT, 1, 1 << (frame_len_bits - 1), &scale, 0);
} else {
av_assert0(0);
}
if (ret < 0)
return ret;
@ -177,13 +177,12 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
float q, quant[25];
int width, coeff;
GetBitContext *gb = &s->gb;
LOCAL_ALIGNED_32(float, coeffs, [4098]);
if (use_dct)
skip_bits(gb, 2);
for (ch = 0; ch < channels; ch++) {
FFTSample *coeffs = out[ch + ch_offset];
if (s->version_b) {
if (get_bits_left(gb) < 64)
return AVERROR_INVALIDDATA;
@ -251,10 +250,15 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
coeffs[0] /= 0.5;
s->trans.dct.dct_calc(&s->trans.dct, coeffs);
s->tx_fn(s->tx, out[ch + ch_offset], coeffs, sizeof(float));
} else if (CONFIG_BINKAUDIO_RDFT_DECODER) {
for (int i = 2; i < s->frame_len; i += 2)
coeffs[i + 1] *= -1;
coeffs[s->frame_len + 0] = coeffs[1];
coeffs[s->frame_len + 1] = coeffs[1] = 0;
s->tx_fn(s->tx, out[ch + ch_offset], coeffs, sizeof(AVComplexFloat));
}
else if (CONFIG_BINKAUDIO_RDFT_DECODER)
s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs);
}
for (ch = 0; ch < channels; ch++) {
@ -278,11 +282,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
static av_cold int decode_end(AVCodecContext *avctx)
{
BinkAudioContext * s = avctx->priv_data;
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
ff_rdft_end(&s->trans.rdft);
else if (CONFIG_BINKAUDIO_DCT_DECODER)
ff_dct_end(&s->trans.dct);
av_tx_uninit(&s->tx);
return 0;
}