atrac3plus: convert to lavu/tx
This commit is contained in:
parent
b59e6b5d99
commit
34330adb29
2
configure
vendored
2
configure
vendored
@ -2792,8 +2792,6 @@ asv1_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
|
||||
asv2_decoder_select="blockdsp bswapdsp idctdsp"
|
||||
asv2_encoder_select="aandcttables bswapdsp fdctdsp pixblockdsp"
|
||||
atrac1_decoder_select="sinewin"
|
||||
atrac3p_decoder_select="mdct sinewin"
|
||||
atrac3pal_decoder_select="mdct sinewin"
|
||||
av1_decoder_select="av1_frame_split_bsf cbs_av1"
|
||||
bink_decoder_select="blockdsp hpeldsp"
|
||||
binkaudio_dct_decoder_select="dct wma_freqs"
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
#include "atrac.h"
|
||||
#include "avcodec.h"
|
||||
#include "fft.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
/** Global unit sizes */
|
||||
@ -172,14 +172,6 @@ void ff_atrac3p_init_vlcs(void);
|
||||
int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
int num_channels, AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* Initialize IMDCT transform.
|
||||
*
|
||||
* @param[in] avctx ptr to the AVCodecContext
|
||||
* @param[in] mdct_ctx pointer to MDCT transform context
|
||||
*/
|
||||
void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx);
|
||||
|
||||
/**
|
||||
* Initialize sine waves synthesizer and ff_sine_* tables.
|
||||
*/
|
||||
@ -221,8 +213,9 @@ void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *f
|
||||
* @param[in] wind_id which MDCT window to apply
|
||||
* @param[in] sb subband number
|
||||
*/
|
||||
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
|
||||
float *pOut, int wind_id, int sb);
|
||||
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, AVTXContext *mdct_ctx,
|
||||
av_tx_fn mdct_fn, float *pIn, float *pOut,
|
||||
int wind_id, int sb);
|
||||
|
||||
/**
|
||||
* Subband synthesis filter based on the polyphase quadrature (pseudo-QMF)
|
||||
@ -233,8 +226,8 @@ void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
|
||||
* @param[in] in input data to process
|
||||
* @param[out] out receives processed data
|
||||
*/
|
||||
void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
|
||||
const float *in, float *out);
|
||||
void ff_atrac3p_ipqf(AVTXContext *dct_ctx, av_tx_fn dct_fn,
|
||||
Atrac3pIPQFChannelCtx *hist, const float *in, float *out);
|
||||
|
||||
extern const uint16_t ff_atrac3p_qu_to_spec_pos[33];
|
||||
extern const float ff_atrac3p_sf_tab[64];
|
||||
|
@ -69,8 +69,10 @@ typedef struct ATRAC3PContext {
|
||||
DECLARE_ALIGNED(32, float, outp_buf)[2][ATRAC3P_FRAME_SAMPLES];
|
||||
|
||||
AtracGCContext gainc_ctx; ///< gain compensation context
|
||||
FFTContext mdct_ctx;
|
||||
FFTContext ipqf_dct_ctx; ///< IDCT context used by IPQF
|
||||
AVTXContext *mdct_ctx;
|
||||
av_tx_fn mdct_fn;
|
||||
AVTXContext *ipqf_dct_ctx; ///< IDCT context used by IPQF
|
||||
av_tx_fn ipqf_dct_fn;
|
||||
|
||||
Atrac3pChanUnitCtx *ch_units; ///< global channel units
|
||||
|
||||
@ -86,8 +88,8 @@ static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
|
||||
av_freep(&ctx->ch_units);
|
||||
av_freep(&ctx->fdsp);
|
||||
|
||||
ff_mdct_end(&ctx->mdct_ctx);
|
||||
ff_mdct_end(&ctx->ipqf_dct_ctx);
|
||||
av_tx_uninit(&ctx->mdct_ctx);
|
||||
av_tx_uninit(&ctx->ipqf_dct_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -170,6 +172,7 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
|
||||
{
|
||||
static AVOnce init_static_once = AV_ONCE_INIT;
|
||||
ATRAC3PContext *ctx = avctx->priv_data;
|
||||
float scale;
|
||||
int i, ch, ret;
|
||||
|
||||
if (!avctx->block_align) {
|
||||
@ -178,9 +181,17 @@ static av_cold int atrac3p_decode_init(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
/* initialize IPQF */
|
||||
ff_mdct_init(&ctx->ipqf_dct_ctx, 5, 1, 32.0 / 32768.0);
|
||||
scale = 32.0 / 32768.0;
|
||||
ret = av_tx_init(&ctx->ipqf_dct_ctx, &ctx->ipqf_dct_fn, AV_TX_FLOAT_MDCT,
|
||||
1, 16, &scale, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ff_atrac3p_init_imdct(avctx, &ctx->mdct_ctx);
|
||||
scale = -1.0f;
|
||||
ret = av_tx_init(&ctx->mdct_ctx, &ctx->mdct_fn, AV_TX_FLOAT_MDCT,
|
||||
1, 128, &scale, AV_TX_FULL_IMDCT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ff_atrac_init_gain_compensation(&ctx->gainc_ctx, 6, 2);
|
||||
|
||||
@ -288,7 +299,7 @@ static void reconstruct_frame(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
|
||||
for (ch = 0; ch < num_channels; ch++) {
|
||||
for (sb = 0; sb < ch_unit->num_subbands; sb++) {
|
||||
/* inverse transform and windowing */
|
||||
ff_atrac3p_imdct(ctx->fdsp, &ctx->mdct_ctx,
|
||||
ff_atrac3p_imdct(ctx->fdsp, ctx->mdct_ctx, ctx->mdct_fn,
|
||||
&ctx->samples[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
|
||||
&ctx->mdct_buf[ch][sb * ATRAC3P_SUBBAND_SAMPLES],
|
||||
(ch_unit->channels[ch].wnd_shape_prev[sb] << 1) +
|
||||
@ -328,8 +339,9 @@ static void reconstruct_frame(ATRAC3PContext *ctx, Atrac3pChanUnitCtx *ch_unit,
|
||||
}
|
||||
|
||||
/* subband synthesis and acoustic signal output */
|
||||
ff_atrac3p_ipqf(&ctx->ipqf_dct_ctx, &ch_unit->ipqf_ctx[ch],
|
||||
&ctx->time_buf[ch][0], &ctx->outp_buf[ch][0]);
|
||||
ff_atrac3p_ipqf(ctx->ipqf_dct_ctx, ctx->ipqf_dct_fn,
|
||||
&ch_unit->ipqf_ctx[ch], &ctx->time_buf[ch][0],
|
||||
&ctx->outp_buf[ch][0]);
|
||||
}
|
||||
|
||||
/* swap window shape and gain control buffers. */
|
||||
|
@ -79,12 +79,6 @@ const float ff_atrac3p_mant_tab[8] = {
|
||||
|
||||
#define ATRAC3P_MDCT_SIZE (ATRAC3P_SUBBAND_SAMPLES * 2)
|
||||
|
||||
av_cold void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx)
|
||||
{
|
||||
/* Initialize the MDCT transform. */
|
||||
ff_mdct_init(mdct_ctx, 8, 1, -1.0);
|
||||
}
|
||||
|
||||
#define TWOPI (2 * M_PI)
|
||||
|
||||
#define DEQUANT_PHASE(ph) (((ph) & 0x1F) << 6)
|
||||
@ -463,8 +457,9 @@ void ff_atrac3p_power_compensation(Atrac3pChanUnitCtx *ctx, AVFloatDSPContext *f
|
||||
}
|
||||
}
|
||||
|
||||
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
|
||||
float *pOut, int wind_id, int sb)
|
||||
void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, AVTXContext *mdct_ctx,
|
||||
av_tx_fn mdct_fn, float *pIn, float *pOut,
|
||||
int wind_id, int sb)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -472,7 +467,7 @@ void ff_atrac3p_imdct(AVFloatDSPContext *fdsp, FFTContext *mdct_ctx, float *pIn,
|
||||
for (i = 0; i < ATRAC3P_SUBBAND_SAMPLES / 2; i++)
|
||||
FFSWAP(float, pIn[i], pIn[ATRAC3P_SUBBAND_SAMPLES - 1 - i]);
|
||||
|
||||
mdct_ctx->imdct_calc(mdct_ctx, pOut, pIn);
|
||||
mdct_fn(mdct_ctx, pOut, pIn, sizeof(float));
|
||||
|
||||
/* Perform windowing on the output.
|
||||
* ATRAC3+ uses two different MDCT windows:
|
||||
@ -604,8 +599,8 @@ static const float ipqf_coeffs2[ATRAC3P_PQF_FIR_LEN][16] = {
|
||||
-4.4400572e-8, -4.2005411e-7, -8.0604229e-7, -5.8336207e-7 }
|
||||
};
|
||||
|
||||
void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
|
||||
const float *in, float *out)
|
||||
void ff_atrac3p_ipqf(AVTXContext *dct_ctx, av_tx_fn dct_fn,
|
||||
Atrac3pIPQFChannelCtx *hist, const float *in, float *out)
|
||||
{
|
||||
int i, s, sb, t, pos_now, pos_next;
|
||||
LOCAL_ALIGNED(32, float, idct_in, [ATRAC3P_SUBBANDS]);
|
||||
@ -619,7 +614,7 @@ void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
|
||||
idct_in[sb] = in[sb * ATRAC3P_SUBBAND_SAMPLES + s];
|
||||
|
||||
/* Calculate the sine and cosine part of the PQF using IDCT-IV */
|
||||
dct_ctx->imdct_half(dct_ctx, idct_out, idct_in);
|
||||
dct_fn(dct_ctx, idct_out, idct_in, sizeof(float));
|
||||
|
||||
/* append the result to the history */
|
||||
for (i = 0; i < 8; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user