From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id EB11E4F4C9 for ; Tue, 17 Jun 2025 13:48:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8729F68D258; Tue, 17 Jun 2025 16:48:47 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id D0FEB68C6DE for ; Tue, 17 Jun 2025 16:48:40 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id 968F84052B; Tue, 17 Jun 2025 15:48:40 +0200 (CEST) Date: Tue, 17 Jun 2025 15:48:40 +0200 Message-ID: <20250617154840.GB2472956@haasn.xyz> From: Niklas Haas To: ffmpeg-devel@ffmpeg.org In-Reply-To: <20250617120609.1987435-13-ffmpeg@haasn.xyz> References: <20250617120609.1987435-1-ffmpeg@haasn.xyz> <20250617120609.1987435-13-ffmpeg@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH v4 13/13] avfilter/x86/f_ebur128: implement AVX true peak calculation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, 17 Jun 2025 14:06:06 +0200 Niklas Haas wrote: > From: Niklas Haas > > Stereo only, for simplicity. Slightly faster than the C code. I will drop this and the prior commit and resubmit them in a refactored form that also speeds up the sample peak calculation. In the meantime, I would appreciate a review of the rest. > --- > libavfilter/f_ebur128.c | 8 +++----- > libavfilter/f_ebur128.h | 2 +- > libavfilter/x86/f_ebur128.asm | 25 +++++++++++++++++++++++++ > libavfilter/x86/f_ebur128_init.c | 9 +++++++-- > 4 files changed, 36 insertions(+), 8 deletions(-) > > diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c > index 0adc89c823..c64f6ed032 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.true_peak = ff_ebur128_true_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 8aab7838a0..5fb9d4a8d5 100644 > --- a/libavfilter/f_ebur128.h > +++ b/libavfilter/f_ebur128.h > @@ -53,7 +53,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..53dd3f858d 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,24 @@ cglobal ebur128_filter_channels, 7, 9, 14, dsp, samples, cache400, cache3000, su > test channelsd, channelsd > jnz .loop > RET > + > +cglobal ebur128_true_peak_stereo, 5, 6, 4, tp, tppf, channels, samples, nb_samples > + vpbroadcastq m4, [abs_mask] > + pxor m0, m0 ; maxpeak > + movupd m1, [tpq] ; tp > + pxor m2, m2 ; tppf > +.inner: > + movupd m3, [samplesq] > + add samplesq, 16 > + pand m3, m4 > + maxpd m1, m3 > + maxpd m2, m3 > + dec nb_samplesd > + jg .inner > + movupd [tpq], m1 > + movupd [tppfq], m2 > + maxpd m0, m1 > + 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..527e5e4dbc 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_true_peak_stereo_avx(double *, 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->true_peak = ff_ebur128_true_peak_stereo_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".