diff options
author | Lynne <dev@lynne.ee> | 2022-10-29 08:30:56 +0200 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2022-11-06 14:39:33 +0100 |
commit | 60c704677aeedada7e70b2afa8676c4973b9e145 (patch) | |
tree | e872df6fde9e0cb890fb5a5eb485166aed8b3d85 /libavcodec/vorbisdec.c | |
parent | 469cd8d7fa55ebd07be31e4c5bd0ed4b45c551dc (diff) | |
download | ffmpeg-60c704677aeedada7e70b2afa8676c4973b9e145.tar.gz |
vorbisdec: convert to lavu/tx
This also fixes not checking the return values on transform init.
Total decoder speedup on Zen 3: 9%
Diffstat (limited to 'libavcodec/vorbisdec.c')
-rw-r--r-- | libavcodec/vorbisdec.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 715a7f7d03..dd856a6dfe 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -31,12 +31,12 @@ #include "libavutil/avassert.h" #include "libavutil/float_dsp.h" +#include "libavutil/tx.h" #define BITSTREAM_READER_LE #include "avcodec.h" #include "codec_internal.h" #include "decode.h" -#include "fft.h" #include "get_bits.h" #include "vorbis.h" #include "vorbisdsp.h" @@ -130,7 +130,9 @@ typedef struct vorbis_context_s { VorbisDSPContext dsp; AVFloatDSPContext *fdsp; - FFTContext mdct[2]; + AVTXContext *mdct[2]; + av_tx_fn mdct_fn[2]; + uint8_t first_frame; int64_t initial_pts; uint32_t version; @@ -202,8 +204,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->mdct[0]); + av_tx_uninit(&vc->mdct[1]); if (vc->codebooks) for (i = 0; i < vc->codebook_count; ++i) { @@ -964,6 +966,8 @@ static int vorbis_parse_id_hdr(vorbis_context *vc) { GetBitContext *gb = &vc->gb; unsigned bl0, bl1; + float scale = -1.0; + int ret; if ((get_bits(gb, 8) != 'v') || (get_bits(gb, 8) != 'o') || (get_bits(gb, 8) != 'r') || (get_bits(gb, 8) != 'b') || @@ -1009,8 +1013,16 @@ 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); + ret = av_tx_init(&vc->mdct[0], &vc->mdct_fn[0], AV_TX_FLOAT_MDCT, 1, + vc->blocksize[0] >> 1, &scale, 0); + if (ret < 0) + return ret; + + ret = av_tx_init(&vc->mdct[1], &vc->mdct_fn[1], AV_TX_FLOAT_MDCT, 1, + vc->blocksize[1] >> 1, &scale, 0); + if (ret < 0) + return ret; + vc->fdsp = avpriv_float_dsp_alloc(vc->avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!vc->fdsp) return AVERROR(ENOMEM); @@ -1585,7 +1597,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 *mdct; + av_tx_fn mdct_fn; int previous_window = vc->previous_window; unsigned mode_number, blockflag, blocksize; int i, j; @@ -1707,12 +1720,13 @@ static int vorbis_parse_audio_packet(vorbis_context *vc, float **floor_ptr) // Dotproduct, MDCT - mdct = &vc->mdct[blockflag]; + mdct = vc->mdct[blockflag]; + mdct_fn = vc->mdct_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]); + mdct_fn(mdct, ch_res_ptr, floor_ptr[j], sizeof(float)); } // Overlap/add, save data for next overlapping |