binkaudio: convert to lavu/tx
This commit is contained in:
parent
a56d7e0ca3
commit
ca8aaf24df
4
configure
vendored
4
configure
vendored
@ -2772,8 +2772,8 @@ asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
|
|||||||
atrac1_decoder_select="sinewin"
|
atrac1_decoder_select="sinewin"
|
||||||
av1_decoder_select="av1_frame_split_bsf cbs_av1"
|
av1_decoder_select="av1_frame_split_bsf cbs_av1"
|
||||||
bink_decoder_select="blockdsp hpeldsp"
|
bink_decoder_select="blockdsp hpeldsp"
|
||||||
binkaudio_dct_decoder_select="dct wma_freqs"
|
binkaudio_dct_decoder_select="wma_freqs"
|
||||||
binkaudio_rdft_decoder_select="rdft wma_freqs"
|
binkaudio_rdft_decoder_select="wma_freqs"
|
||||||
cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
|
cavs_decoder_select="blockdsp golomb h264chroma idctdsp qpeldsp videodsp"
|
||||||
clearvideo_decoder_select="idctdsp"
|
clearvideo_decoder_select="idctdsp"
|
||||||
cllc_decoder_select="bswapdsp"
|
cllc_decoder_select="bswapdsp"
|
||||||
|
@ -33,15 +33,14 @@
|
|||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/intfloat.h"
|
#include "libavutil/intfloat.h"
|
||||||
#include "libavutil/mem_internal.h"
|
#include "libavutil/mem_internal.h"
|
||||||
|
#include "libavutil/tx.h"
|
||||||
|
|
||||||
#define BITSTREAM_READER_LE
|
#define BITSTREAM_READER_LE
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "dct.h"
|
|
||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
#include "codec_internal.h"
|
#include "codec_internal.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "rdft.h"
|
|
||||||
#include "wma_freqs.h"
|
#include "wma_freqs.h"
|
||||||
|
|
||||||
#define MAX_DCT_CHANNELS 6
|
#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 previous[MAX_DCT_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block
|
||||||
float quant_table[96];
|
float quant_table[96];
|
||||||
AVPacket *pkt;
|
AVPacket *pkt;
|
||||||
union {
|
AVTXContext *tx;
|
||||||
RDFTContext rdft;
|
av_tx_fn tx_fn;
|
||||||
DCTContext dct;
|
|
||||||
} trans;
|
|
||||||
} BinkAudioContext;
|
} BinkAudioContext;
|
||||||
|
|
||||||
|
|
||||||
@ -138,12 +135,15 @@ static av_cold int decode_init(AVCodecContext *avctx)
|
|||||||
|
|
||||||
s->first = 1;
|
s->first = 1;
|
||||||
|
|
||||||
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
|
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);
|
float scale = 0.5;
|
||||||
else if (CONFIG_BINKAUDIO_DCT_DECODER)
|
ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_RDFT, 1, 1 << frame_len_bits, &scale, 0);
|
||||||
ret = ff_dct_init(&s->trans.dct, frame_len_bits, DCT_III);
|
} else if (CONFIG_BINKAUDIO_DCT_DECODER) {
|
||||||
else
|
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);
|
av_assert0(0);
|
||||||
|
}
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -177,13 +177,12 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct,
|
|||||||
float q, quant[25];
|
float q, quant[25];
|
||||||
int width, coeff;
|
int width, coeff;
|
||||||
GetBitContext *gb = &s->gb;
|
GetBitContext *gb = &s->gb;
|
||||||
|
LOCAL_ALIGNED_32(float, coeffs, [4098]);
|
||||||
|
|
||||||
if (use_dct)
|
if (use_dct)
|
||||||
skip_bits(gb, 2);
|
skip_bits(gb, 2);
|
||||||
|
|
||||||
for (ch = 0; ch < channels; ch++) {
|
for (ch = 0; ch < channels; ch++) {
|
||||||
FFTSample *coeffs = out[ch + ch_offset];
|
|
||||||
|
|
||||||
if (s->version_b) {
|
if (s->version_b) {
|
||||||
if (get_bits_left(gb) < 64)
|
if (get_bits_left(gb) < 64)
|
||||||
return AVERROR_INVALIDDATA;
|
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) {
|
if (CONFIG_BINKAUDIO_DCT_DECODER && use_dct) {
|
||||||
coeffs[0] /= 0.5;
|
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++) {
|
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)
|
static av_cold int decode_end(AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
BinkAudioContext * s = avctx->priv_data;
|
BinkAudioContext * s = avctx->priv_data;
|
||||||
if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
|
av_tx_uninit(&s->tx);
|
||||||
ff_rdft_end(&s->trans.rdft);
|
|
||||||
else if (CONFIG_BINKAUDIO_DCT_DECODER)
|
|
||||||
ff_dct_end(&s->trans.dct);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user