1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

atrac1: convert to lavu/tx

This commit is contained in:
Lynne 2022-11-01 09:05:23 +01:00
parent 978963a77b
commit 5f52094f3d
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 19 additions and 13 deletions

2
configure vendored
View File

@ -2791,7 +2791,7 @@ asv1_decoder_select="blockdsp bswapdsp idctdsp"
asv1_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
asv2_decoder_select="blockdsp bswapdsp idctdsp"
asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
atrac1_decoder_select="mdct sinewin"
atrac1_decoder_select="sinewin"
atrac3_decoder_select="mdct"
atrac3al_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin"

View File

@ -32,12 +32,12 @@
#include "libavutil/float_dsp.h"
#include "libavutil/mem_internal.h"
#include "libavutil/tx.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "fft.h"
#include "sinewin.h"
#include "atrac.h"
@ -80,7 +80,8 @@ typedef struct AT1Ctx {
DECLARE_ALIGNED(32, float, mid)[256];
DECLARE_ALIGNED(32, float, high)[512];
float* bands[3];
FFTContext mdct_ctx[3];
AVTXContext *mdct_ctx[3];
av_tx_fn mdct_fn[3];
void (*vector_fmul_window)(float *dst, const float *src0,
const float *src1, const float *win, int len);
} AT1Ctx;
@ -93,7 +94,8 @@ static const uint8_t mdct_long_nbits[3] = {7, 7, 8};
static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits,
int rev_spec)
{
FFTContext* mdct_context = &q->mdct_ctx[nbits - 5 - (nbits > 6)];
AVTXContext *mdct_context = q->mdct_ctx[nbits - 5 - (nbits > 6)];
av_tx_fn mdct_fn = q->mdct_fn[nbits - 5 - (nbits > 6)];
int transf_size = 1 << nbits;
if (rev_spec) {
@ -101,7 +103,7 @@ static void at1_imdct(AT1Ctx *q, float *spec, float *out, int nbits,
for (i = 0; i < transf_size / 2; i++)
FFSWAP(float, spec[i], spec[transf_size - 1 - i]);
}
mdct_context->imdct_half(mdct_context, out, spec);
mdct_fn(mdct_context, out, spec, sizeof(float));
}
@ -322,9 +324,9 @@ static av_cold int atrac1_decode_end(AVCodecContext * avctx)
{
AT1Ctx *q = avctx->priv_data;
ff_mdct_end(&q->mdct_ctx[0]);
ff_mdct_end(&q->mdct_ctx[1]);
ff_mdct_end(&q->mdct_ctx[2]);
av_tx_uninit(&q->mdct_ctx[0]);
av_tx_uninit(&q->mdct_ctx[1]);
av_tx_uninit(&q->mdct_ctx[2]);
return 0;
}
@ -335,6 +337,7 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
AT1Ctx *q = avctx->priv_data;
AVFloatDSPContext *fdsp;
int channels = avctx->ch_layout.nb_channels;
float scale = -1.0 / (1 << 15);
int ret;
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
@ -351,12 +354,15 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
}
/* Init the mdct transforms */
if ((ret = ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15))) ||
(ret = ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) ||
(ret = ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)))) {
av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
if ((ret = av_tx_init(&q->mdct_ctx[0], &q->mdct_fn[0], AV_TX_FLOAT_MDCT,
1, 32, &scale, 0) < 0))
return ret;
if ((ret = av_tx_init(&q->mdct_ctx[1], &q->mdct_fn[1], AV_TX_FLOAT_MDCT,
1, 128, &scale, 0) < 0))
return ret;
if ((ret = av_tx_init(&q->mdct_ctx[2], &q->mdct_fn[2], AV_TX_FLOAT_MDCT,
1, 256, &scale, 0) < 0))
return ret;
}
ff_init_ff_sine_windows(5);