From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH v5 13/13] avfilter/x86/f_ebur128: implement AVX peak calculation Date: Fri, 20 Jun 2025 15:21:38 +0200 Message-ID: <20250620132139.2431475-13-ffmpeg@haasn.xyz> (raw) In-Reply-To: <20250620132139.2431475-1-ffmpeg@haasn.xyz> From: Niklas Haas <git@haasn.dev> Stereo only, for simplicity. Slightly faster than the C code. --- libavfilter/f_ebur128.c | 8 +++----- libavfilter/f_ebur128.h | 2 +- libavfilter/x86/f_ebur128.asm | 20 ++++++++++++++++++++ libavfilter/x86/f_ebur128_init.c | 9 +++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 514be7a8e3..80cbe20330 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -502,6 +502,9 @@ static int config_audio_output(AVFilterLink *outlink) return AVERROR(ENOMEM); } +#if ARCH_X86 + ff_ebur128_init_x86(&ebur128->dsp, nb_channels); +#endif return 0; } @@ -581,11 +584,6 @@ static av_cold int init(AVFilterContext *ctx) ebur128->dsp.filter_channels = ff_ebur128_filter_channels_c; ebur128->dsp.find_peak = ff_ebur128_find_peak_c; - -#if ARCH_X86 - ff_ebur128_init_x86(&ebur128->dsp); -#endif - return 0; } diff --git a/libavfilter/f_ebur128.h b/libavfilter/f_ebur128.h index ad24a3c129..19564f562b 100644 --- a/libavfilter/f_ebur128.h +++ b/libavfilter/f_ebur128.h @@ -55,7 +55,7 @@ static_assert(offsetof(EBUR128DSPContext, pre) == 0, "struct l static_assert(offsetof(EBUR128DSPContext, rlb) == 5 * sizeof(double), "struct layout mismatch"); static_assert(offsetof(EBUR128DSPContext, y) == 10 * sizeof(double), "struct layout mismatch"); -void ff_ebur128_init_x86(EBUR128DSPContext *dsp); +void ff_ebur128_init_x86(EBUR128DSPContext *dsp, int nb_channels); void ff_ebur128_filter_channels_c(const EBUR128DSPContext *, const double *, double *, double *, double *, double *, int); diff --git a/libavfilter/x86/f_ebur128.asm b/libavfilter/x86/f_ebur128.asm index d9cc8d9361..84f414349d 100644 --- a/libavfilter/x86/f_ebur128.asm +++ b/libavfilter/x86/f_ebur128.asm @@ -39,6 +39,10 @@ struc DSP .z resq 1 endstruc +SECTION_RODATA + +abs_mask: dq 0x7FFFFFFFFFFFFFFF + SECTION .text %macro MOVNQ 3 ; num, dst, src @@ -139,3 +143,19 @@ cglobal ebur128_filter_channels, 7, 9, 14, dsp, samples, cache400, cache3000, su test channelsd, channelsd jnz .loop RET + +cglobal ebur128_find_peak_2ch, 4, 5, 3, ch_peaks, channels, samples, nb_samples + vpbroadcastq m2, [abs_mask] + movupd m0, [ch_peaksq] +.loop: + movupd m1, [samplesq] + add samplesq, 16 + pand m1, m2 + maxpd m0, m1 + dec nb_samplesd + jg .loop + movupd [ch_peaksq], m0 + shufpd m1, m0, m0, 1 + maxpd m0, m1 + movq rax, m0 + RET diff --git a/libavfilter/x86/f_ebur128_init.c b/libavfilter/x86/f_ebur128_init.c index 8f38aee967..4a7109746d 100644 --- a/libavfilter/x86/f_ebur128_init.c +++ b/libavfilter/x86/f_ebur128_init.c @@ -26,10 +26,15 @@ void ff_ebur128_filter_channels_avx(const EBUR128DSPContext *, const double *, double *, double *, double *, double *, int); -av_cold void ff_ebur128_init_x86(EBUR128DSPContext *dsp) +double ff_ebur128_find_peak_2ch_avx(double *, int, const double *, int); + +av_cold void ff_ebur128_init_x86(EBUR128DSPContext *dsp, int nb_channels) { int cpu_flags = av_get_cpu_flags(); - if (ARCH_X86_64 && EXTERNAL_AVX(cpu_flags)) + if (ARCH_X86_64 && EXTERNAL_AVX(cpu_flags)) { dsp->filter_channels = ff_ebur128_filter_channels_avx; + if (nb_channels == 2) + dsp->find_peak = ff_ebur128_find_peak_2ch_avx; + } } -- 2.49.0 _______________________________________________ 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".
next prev parent reply other threads:[~2025-06-20 13:22 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-06-20 13:21 [FFmpeg-devel] [PATCH v5 01/13] avfilter/f_ebur128: use transformed direct form II Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 02/13] avfilter/f_ebur128: simplify sample cache array Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 03/13] avfilter/f_ebur128: use structs for biquad weights Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 04/13] avfilter/f_ebur128: use a single packed array for the integrator cache Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 05/13] avfilter/f_ebur128: move weights and cache to EBUR128DSPContext Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 06/13] avfilter/f_ebur128: split off C implementation to separate function Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 07/13] avfilter/x86/f_ebur128: add x86 AVX implementation Niklas Haas 2025-06-20 13:49 ` James Almer 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 08/13] avfilter/f_ebur128: remove pointless macro Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 09/13] avfilter/f_ebur128: move true peak calculation out of main loop Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 10/13] avfilter/f_ebur128: lift sample " Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 11/13] avfilter/f_ebur128: move variable declarations to usage site Niklas Haas 2025-06-20 13:21 ` [FFmpeg-devel] [PATCH v5 12/13] avfilter/f_ebur128: move peak detection to reusable DSP function Niklas Haas 2025-06-20 13:21 ` Niklas Haas [this message] 2025-06-20 13:23 ` [FFmpeg-devel] [PATCH v5 01/13] avfilter/f_ebur128: use transformed direct form II Niklas Haas
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=20250620132139.2431475-13-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /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