From: Lynne <dev@lynne.ee> To: Ffmpeg Devel <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] vorbisdec: convert to lavu/tx Date: Sat, 29 Oct 2022 08:34:41 +0200 (CEST) Message-ID: <NFXRlzW--3-9@lynne.ee> (raw) [-- Attachment #1: Type: text/plain, Size: 120 bytes --] This also fixes not checking the return values on transform init. Total decoder speedup on Zen 3: 9% Patch attached. [-- Attachment #2: 0001-vorbisdec-convert-to-lavu-tx.patch --] [-- Type: text/x-diff, Size: 3525 bytes --] From efe3006093cd80182b293f01aa98fb75733a8188 Mon Sep 17 00:00:00 2001 From: Lynne <dev@lynne.ee> Date: Sat, 29 Oct 2022 08:30:56 +0200 Subject: [PATCH] vorbisdec: convert to lavu/tx This also fixes not checking the return values on transform init. Total decoder speedup on Zen 3: 9% --- libavcodec/vorbisdec.c | 32 +++++++++++++++++++++++--------- 1 file 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 -- 2.37.2.609.g9ff673ca1a [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2022-10-29 6:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=NFXRlzW--3-9@lynne.ee \ --to=dev@lynne.ee \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git