From 1334c8c26a8d1c3f8e2aa98b902b2dab6e524a84 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Sat, 24 Sep 2022 01:07:15 +0200
Subject: [PATCH 4/6] vorbisdec: convert to lavu/tx
---
libavcodec/vorbisdec.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
@@ -29,6 +29,7 @@
#include <inttypes.h>
#include <math.h>
+#include "libavutil/tx.h"
#include "libavutil/avassert.h"
#include "libavutil/float_dsp.h"
@@ -36,7 +37,6 @@
#include "avcodec.h"
#include "codec_internal.h"
#include "decode.h"
-#include "fft.h"
#include "get_bits.h"
#include "vorbis.h"
#include "vorbisdsp.h"
@@ -129,7 +129,8 @@ typedef struct vorbis_context_s {
VorbisDSPContext dsp;
AVFloatDSPContext *fdsp;
- FFTContext mdct[2];
+ AVTXContext *tx[2];
+ av_tx_fn tx_fn[2];
uint8_t first_frame;
int64_t initial_pts;
uint32_t version;
@@ -201,8 +202,8 @@ static void vorbis_free(vorbis_context *vc)
av_freep(&vc->residues);
av_freep(&vc->modes);
- ff_mdct_end(&vc->mdct[0]);
- ff_mdct_end(&vc->mdct[1]);
+ av_tx_uninit(&vc->tx[0]);
+ av_tx_uninit(&vc->tx[1]);
if (vc->codebooks)
for (i = 0; i < vc->codebook_count; ++i) {
@@ -961,6 +962,8 @@ static int vorbis_parse_setup_hdr(vorbis_context *vc)
static int vorbis_parse_id_hdr(vorbis_context *vc)
{
+ int ret;
+ const float mdct_scale = -1.0f;
GetBitContext *gb = &vc->gb;
unsigned bl0, bl1;
@@ -1008,8 +1011,14 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
vc->previous_window = -1;
- ff_mdct_init(&vc->mdct[0], bl0, 1, -1.0);
- ff_mdct_init(&vc->mdct[1], bl1, 1, -1.0);
+ if ((ret = av_tx_init(&vc->tx[0], &vc->tx_fn[0], AV_TX_FLOAT_MDCT, 1, 1 << (bl0 - 1),
+ &mdct_scale, 0)))
+ return ret;
+
+ if ((ret = av_tx_init(&vc->tx[1], &vc->tx_fn[1], AV_TX_FLOAT_MDCT, 1, 1 << (bl1 - 1),
+ &mdct_scale, 0)))
+ return ret;
+
vc->fdsp = avpriv_float_dsp_alloc(vc->avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (!vc->fdsp)
return AVERROR(ENOMEM);
@@ -1584,7 +1593,8 @@ static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
{
GetBitContext *gb = &vc->gb;
- FFTContext *mdct;
+ AVTXContext *tx;
+ av_tx_fn tx_fn;
int previous_window = vc->previous_window;
unsigned mode_number, blockflag, blocksize;
int i, j;
@@ -1706,12 +1716,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr)
// Dotproduct, MDCT
- mdct = &vc->mdct[blockflag];
+ tx = vc->tx[blockflag];
+ tx_fn = vc->tx_fn[blockflag];
for (j = vc->audio_channels-1;j >= 0; j--) {
ch_res_ptr = vc->channel_residues + res_chan[j] * blocksize / 2;
vc->fdsp->vector_fmul(floor_ptr[j], floor_ptr[j], ch_res_ptr, blocksize / 2);
- mdct->imdct_half(mdct, ch_res_ptr, floor_ptr[j]);
+ tx_fn(tx, ch_res_ptr, floor_ptr[j], sizeof(float));
}
// Overlap/add, save data for next overlapping
--
2.37.2.609.g9ff673ca1a