Re: [FFmpeg-devel] [PATCH] avfilter/af_atempo: switch to rdft from lavu/tx
6 Feb 2022, 19:04 by pkoshe...@gmail.com: > On Sun, Feb 6, 2022 at 10:24 AM Paul B Mahol wrote: > >> On Sun, Feb 6, 2022 at 6:16 PM Pavel Koshevoy wrote: >> >> > On Sun, Feb 6, 2022 at 4:24 AM Paul B Mahol wrote: >> >> > > >> > > >> > Is the old API being removed or deprecated? >> > Just wondering why this change is necessary. >> > >> >> New api is faster. >> Old API will get deprecated soon, but we have to replace its use in our code first. New API is faster, and supports non-power-of-two lengths. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/af_atempo: switch to rdft from lavu/tx
On Sun, Feb 6, 2022 at 10:24 AM Paul B Mahol wrote: > On Sun, Feb 6, 2022 at 6:16 PM Pavel Koshevoy wrote: > > > On Sun, Feb 6, 2022 at 4:24 AM Paul B Mahol wrote: > > > > > Signed-off-by: Paul B Mahol > > > --- > > > configure | 3 - > > > libavfilter/af_atempo.c | 126 > > > 2 files changed, 64 insertions(+), 65 deletions(-) > > > > > > diff --git a/configure b/configure > > > index 5a8b52c77d..6ec25dd622 100755 > > > --- a/configure > > > +++ b/configure > > > @@ -3610,8 +3610,6 @@ amovie_filter_deps="avcodec avformat" > > > aresample_filter_deps="swresample" > > > asr_filter_deps="pocketsphinx" > > > ass_filter_deps="libass" > > > -atempo_filter_deps="avcodec" > > > -atempo_filter_select="rdft" > > > avgblur_opencl_filter_deps="opencl" > > > avgblur_vulkan_filter_deps="vulkan spirv_compiler" > > > azmq_filter_deps="libzmq" > > > @@ -7387,7 +7385,6 @@ enabled zlib && add_cppflags -DZLIB_CONST > > > # conditional library dependencies, in any order > > > enabled amovie_filter && prepend avfilter_deps "avformat > avcodec" > > > enabled aresample_filter&& prepend avfilter_deps "swresample" > > > -enabled atempo_filter && prepend avfilter_deps "avcodec" > > > enabled bm3d_filter && prepend avfilter_deps "avcodec" > > > enabled cover_rect_filter && prepend avfilter_deps "avformat > avcodec" > > > enabled ebur128_filter && enabled swresample && prepend avfilter_deps > > > "swresample" > > > diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c > > > index e9a6da7970..27f2f6daa0 100644 > > > --- a/libavfilter/af_atempo.c > > > +++ b/libavfilter/af_atempo.c > > > @@ -39,13 +39,13 @@ > > > */ > > > > > > #include > > > -#include "libavcodec/avfft.h" > > > #include "libavutil/avassert.h" > > > #include "libavutil/avstring.h" > > > #include "libavutil/channel_layout.h" > > > #include "libavutil/eval.h" > > > #include "libavutil/opt.h" > > > #include "libavutil/samplefmt.h" > > > +#include "libavutil/tx.h" > > > #include "avfilter.h" > > > #include "audio.h" > > > #include "internal.h" > > > @@ -67,7 +67,8 @@ typedef struct AudioFragment { > > > > > > // rDFT transform of the down-mixed mono fragment, used for > > > // fast waveform alignment via correlation in frequency domain: > > > -FFTSample *xdat; > > > +float *xdat_in; > > > +float *xdat; > > > } AudioFragment; > > > > > > > > Is the old API being removed or deprecated? > > Just wondering why this change is necessary. > > > > New api is faster. > > > > > > > > > > > > /** > > > @@ -140,9 +141,11 @@ typedef struct ATempoContext { > > > FilterState state; > > > > > > // for fast correlation calculation in frequency domain: > > > -RDFTContext *real_to_complex; > > > -RDFTContext *complex_to_real; > > > -FFTSample *correlation; > > > +AVTXContext *real_to_complex; > > > +AVTXContext *complex_to_real; > > > +av_tx_fn r2c_fn, c2r_fn; > > > +float *correlation_in; > > > +float *correlation; > > > > > > // for managing AVFilterPad.request_frame and > > AVFilterPad.filter_frame > > > AVFrame *dst_buffer; > > > @@ -228,18 +231,18 @@ static void yae_release_buffers(ATempoContext > > > *atempo) > > > > > > av_freep(>frag[0].data); > > > av_freep(>frag[1].data); > > > +av_freep(>frag[0].xdat_in); > > > +av_freep(>frag[1].xdat_in); > > > av_freep(>frag[0].xdat); > > > av_freep(>frag[1].xdat); > > > > > > av_freep(>buffer); > > > av_freep(>hann); > > > +av_freep(>correlation_in); > > > av_freep(>correlation); > > > > > > -av_rdft_end(atempo->real_to_complex); > > > -atempo->real_to_complex = NULL; > > > - > > > -av_rdft_end(atempo->complex_to_real); > > > -atempo->complex_to_real = NULL; > > > +av_tx_uninit(>real_to_complex); > > > +av_tx_uninit(>complex_to_real); > > > } > > > > > > /* av_realloc is not aligned enough; fortunately, the data does not > need > > > to > > > @@ -247,7 +250,7 @@ static void yae_release_buffers(ATempoContext > > *atempo) > > > #define RE_MALLOC_OR_FAIL(field, field_size)\ > > > do {\ > > > av_freep(); \ > > > -field = av_malloc(field_size); \ > > > +field = av_calloc(field_size, 1); \ > > > if (!field) { \ > > > yae_release_buffers(atempo);\ > > > return AVERROR(ENOMEM); \ > > > @@ -265,6 +268,7 @@ static int yae_reset(ATempoContext *atempo, > > > { > > > const int sample_size = av_get_bytes_per_sample(format); > > > uint32_t nlevels = 0; > > > +float scale = 1.f, iscale = 1.f; > > > uint32_t pot; > > > int i; > > > > > > @@ -288,29
Re: [FFmpeg-devel] [PATCH] avfilter/af_atempo: switch to rdft from lavu/tx
On Sun, Feb 6, 2022 at 6:16 PM Pavel Koshevoy wrote: > On Sun, Feb 6, 2022 at 4:24 AM Paul B Mahol wrote: > > > Signed-off-by: Paul B Mahol > > --- > > configure | 3 - > > libavfilter/af_atempo.c | 126 > > 2 files changed, 64 insertions(+), 65 deletions(-) > > > > diff --git a/configure b/configure > > index 5a8b52c77d..6ec25dd622 100755 > > --- a/configure > > +++ b/configure > > @@ -3610,8 +3610,6 @@ amovie_filter_deps="avcodec avformat" > > aresample_filter_deps="swresample" > > asr_filter_deps="pocketsphinx" > > ass_filter_deps="libass" > > -atempo_filter_deps="avcodec" > > -atempo_filter_select="rdft" > > avgblur_opencl_filter_deps="opencl" > > avgblur_vulkan_filter_deps="vulkan spirv_compiler" > > azmq_filter_deps="libzmq" > > @@ -7387,7 +7385,6 @@ enabled zlib && add_cppflags -DZLIB_CONST > > # conditional library dependencies, in any order > > enabled amovie_filter && prepend avfilter_deps "avformat avcodec" > > enabled aresample_filter&& prepend avfilter_deps "swresample" > > -enabled atempo_filter && prepend avfilter_deps "avcodec" > > enabled bm3d_filter && prepend avfilter_deps "avcodec" > > enabled cover_rect_filter && prepend avfilter_deps "avformat avcodec" > > enabled ebur128_filter && enabled swresample && prepend avfilter_deps > > "swresample" > > diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c > > index e9a6da7970..27f2f6daa0 100644 > > --- a/libavfilter/af_atempo.c > > +++ b/libavfilter/af_atempo.c > > @@ -39,13 +39,13 @@ > > */ > > > > #include > > -#include "libavcodec/avfft.h" > > #include "libavutil/avassert.h" > > #include "libavutil/avstring.h" > > #include "libavutil/channel_layout.h" > > #include "libavutil/eval.h" > > #include "libavutil/opt.h" > > #include "libavutil/samplefmt.h" > > +#include "libavutil/tx.h" > > #include "avfilter.h" > > #include "audio.h" > > #include "internal.h" > > @@ -67,7 +67,8 @@ typedef struct AudioFragment { > > > > // rDFT transform of the down-mixed mono fragment, used for > > // fast waveform alignment via correlation in frequency domain: > > -FFTSample *xdat; > > +float *xdat_in; > > +float *xdat; > > } AudioFragment; > > > > > Is the old API being removed or deprecated? > Just wondering why this change is necessary. > New api is faster. > > > > > > /** > > @@ -140,9 +141,11 @@ typedef struct ATempoContext { > > FilterState state; > > > > // for fast correlation calculation in frequency domain: > > -RDFTContext *real_to_complex; > > -RDFTContext *complex_to_real; > > -FFTSample *correlation; > > +AVTXContext *real_to_complex; > > +AVTXContext *complex_to_real; > > +av_tx_fn r2c_fn, c2r_fn; > > +float *correlation_in; > > +float *correlation; > > > > // for managing AVFilterPad.request_frame and > AVFilterPad.filter_frame > > AVFrame *dst_buffer; > > @@ -228,18 +231,18 @@ static void yae_release_buffers(ATempoContext > > *atempo) > > > > av_freep(>frag[0].data); > > av_freep(>frag[1].data); > > +av_freep(>frag[0].xdat_in); > > +av_freep(>frag[1].xdat_in); > > av_freep(>frag[0].xdat); > > av_freep(>frag[1].xdat); > > > > av_freep(>buffer); > > av_freep(>hann); > > +av_freep(>correlation_in); > > av_freep(>correlation); > > > > -av_rdft_end(atempo->real_to_complex); > > -atempo->real_to_complex = NULL; > > - > > -av_rdft_end(atempo->complex_to_real); > > -atempo->complex_to_real = NULL; > > +av_tx_uninit(>real_to_complex); > > +av_tx_uninit(>complex_to_real); > > } > > > > /* av_realloc is not aligned enough; fortunately, the data does not need > > to > > @@ -247,7 +250,7 @@ static void yae_release_buffers(ATempoContext > *atempo) > > #define RE_MALLOC_OR_FAIL(field, field_size)\ > > do {\ > > av_freep(); \ > > -field = av_malloc(field_size); \ > > +field = av_calloc(field_size, 1); \ > > if (!field) { \ > > yae_release_buffers(atempo);\ > > return AVERROR(ENOMEM); \ > > @@ -265,6 +268,7 @@ static int yae_reset(ATempoContext *atempo, > > { > > const int sample_size = av_get_bytes_per_sample(format); > > uint32_t nlevels = 0; > > +float scale = 1.f, iscale = 1.f; > > uint32_t pot; > > int i; > > > > @@ -288,29 +292,29 @@ static int yae_reset(ATempoContext *atempo, > > // initialize audio fragment buffers: > > RE_MALLOC_OR_FAIL(atempo->frag[0].data, atempo->window * > > atempo->stride); > > RE_MALLOC_OR_FAIL(atempo->frag[1].data, atempo->window * > > atempo->stride); > > -RE_MALLOC_OR_FAIL(atempo->frag[0].xdat,
Re: [FFmpeg-devel] [PATCH] avfilter/af_atempo: switch to rdft from lavu/tx
On Sun, Feb 6, 2022 at 4:24 AM Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > configure | 3 - > libavfilter/af_atempo.c | 126 > 2 files changed, 64 insertions(+), 65 deletions(-) > > diff --git a/configure b/configure > index 5a8b52c77d..6ec25dd622 100755 > --- a/configure > +++ b/configure > @@ -3610,8 +3610,6 @@ amovie_filter_deps="avcodec avformat" > aresample_filter_deps="swresample" > asr_filter_deps="pocketsphinx" > ass_filter_deps="libass" > -atempo_filter_deps="avcodec" > -atempo_filter_select="rdft" > avgblur_opencl_filter_deps="opencl" > avgblur_vulkan_filter_deps="vulkan spirv_compiler" > azmq_filter_deps="libzmq" > @@ -7387,7 +7385,6 @@ enabled zlib && add_cppflags -DZLIB_CONST > # conditional library dependencies, in any order > enabled amovie_filter && prepend avfilter_deps "avformat avcodec" > enabled aresample_filter&& prepend avfilter_deps "swresample" > -enabled atempo_filter && prepend avfilter_deps "avcodec" > enabled bm3d_filter && prepend avfilter_deps "avcodec" > enabled cover_rect_filter && prepend avfilter_deps "avformat avcodec" > enabled ebur128_filter && enabled swresample && prepend avfilter_deps > "swresample" > diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c > index e9a6da7970..27f2f6daa0 100644 > --- a/libavfilter/af_atempo.c > +++ b/libavfilter/af_atempo.c > @@ -39,13 +39,13 @@ > */ > > #include > -#include "libavcodec/avfft.h" > #include "libavutil/avassert.h" > #include "libavutil/avstring.h" > #include "libavutil/channel_layout.h" > #include "libavutil/eval.h" > #include "libavutil/opt.h" > #include "libavutil/samplefmt.h" > +#include "libavutil/tx.h" > #include "avfilter.h" > #include "audio.h" > #include "internal.h" > @@ -67,7 +67,8 @@ typedef struct AudioFragment { > > // rDFT transform of the down-mixed mono fragment, used for > // fast waveform alignment via correlation in frequency domain: > -FFTSample *xdat; > +float *xdat_in; > +float *xdat; > } AudioFragment; > > Is the old API being removed or deprecated? Just wondering why this change is necessary. > /** > @@ -140,9 +141,11 @@ typedef struct ATempoContext { > FilterState state; > > // for fast correlation calculation in frequency domain: > -RDFTContext *real_to_complex; > -RDFTContext *complex_to_real; > -FFTSample *correlation; > +AVTXContext *real_to_complex; > +AVTXContext *complex_to_real; > +av_tx_fn r2c_fn, c2r_fn; > +float *correlation_in; > +float *correlation; > > // for managing AVFilterPad.request_frame and AVFilterPad.filter_frame > AVFrame *dst_buffer; > @@ -228,18 +231,18 @@ static void yae_release_buffers(ATempoContext > *atempo) > > av_freep(>frag[0].data); > av_freep(>frag[1].data); > +av_freep(>frag[0].xdat_in); > +av_freep(>frag[1].xdat_in); > av_freep(>frag[0].xdat); > av_freep(>frag[1].xdat); > > av_freep(>buffer); > av_freep(>hann); > +av_freep(>correlation_in); > av_freep(>correlation); > > -av_rdft_end(atempo->real_to_complex); > -atempo->real_to_complex = NULL; > - > -av_rdft_end(atempo->complex_to_real); > -atempo->complex_to_real = NULL; > +av_tx_uninit(>real_to_complex); > +av_tx_uninit(>complex_to_real); > } > > /* av_realloc is not aligned enough; fortunately, the data does not need > to > @@ -247,7 +250,7 @@ static void yae_release_buffers(ATempoContext *atempo) > #define RE_MALLOC_OR_FAIL(field, field_size)\ > do {\ > av_freep(); \ > -field = av_malloc(field_size); \ > +field = av_calloc(field_size, 1); \ > if (!field) { \ > yae_release_buffers(atempo);\ > return AVERROR(ENOMEM); \ > @@ -265,6 +268,7 @@ static int yae_reset(ATempoContext *atempo, > { > const int sample_size = av_get_bytes_per_sample(format); > uint32_t nlevels = 0; > +float scale = 1.f, iscale = 1.f; > uint32_t pot; > int i; > > @@ -288,29 +292,29 @@ static int yae_reset(ATempoContext *atempo, > // initialize audio fragment buffers: > RE_MALLOC_OR_FAIL(atempo->frag[0].data, atempo->window * > atempo->stride); > RE_MALLOC_OR_FAIL(atempo->frag[1].data, atempo->window * > atempo->stride); > -RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, atempo->window * > sizeof(FFTComplex)); > -RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, atempo->window * > sizeof(FFTComplex)); > +RE_MALLOC_OR_FAIL(atempo->frag[0].xdat_in, (atempo->window + 1) * > sizeof(AVComplexFloat)); > +RE_MALLOC_OR_FAIL(atempo->frag[1].xdat_in, (atempo->window + 1) * > sizeof(AVComplexFloat)); > +
[FFmpeg-devel] [PATCH] avfilter/af_atempo: switch to rdft from lavu/tx
Signed-off-by: Paul B Mahol --- configure | 3 - libavfilter/af_atempo.c | 126 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/configure b/configure index 5a8b52c77d..6ec25dd622 100755 --- a/configure +++ b/configure @@ -3610,8 +3610,6 @@ amovie_filter_deps="avcodec avformat" aresample_filter_deps="swresample" asr_filter_deps="pocketsphinx" ass_filter_deps="libass" -atempo_filter_deps="avcodec" -atempo_filter_select="rdft" avgblur_opencl_filter_deps="opencl" avgblur_vulkan_filter_deps="vulkan spirv_compiler" azmq_filter_deps="libzmq" @@ -7387,7 +7385,6 @@ enabled zlib && add_cppflags -DZLIB_CONST # conditional library dependencies, in any order enabled amovie_filter && prepend avfilter_deps "avformat avcodec" enabled aresample_filter&& prepend avfilter_deps "swresample" -enabled atempo_filter && prepend avfilter_deps "avcodec" enabled bm3d_filter && prepend avfilter_deps "avcodec" enabled cover_rect_filter && prepend avfilter_deps "avformat avcodec" enabled ebur128_filter && enabled swresample && prepend avfilter_deps "swresample" diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index e9a6da7970..27f2f6daa0 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -39,13 +39,13 @@ */ #include -#include "libavcodec/avfft.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/eval.h" #include "libavutil/opt.h" #include "libavutil/samplefmt.h" +#include "libavutil/tx.h" #include "avfilter.h" #include "audio.h" #include "internal.h" @@ -67,7 +67,8 @@ typedef struct AudioFragment { // rDFT transform of the down-mixed mono fragment, used for // fast waveform alignment via correlation in frequency domain: -FFTSample *xdat; +float *xdat_in; +float *xdat; } AudioFragment; /** @@ -140,9 +141,11 @@ typedef struct ATempoContext { FilterState state; // for fast correlation calculation in frequency domain: -RDFTContext *real_to_complex; -RDFTContext *complex_to_real; -FFTSample *correlation; +AVTXContext *real_to_complex; +AVTXContext *complex_to_real; +av_tx_fn r2c_fn, c2r_fn; +float *correlation_in; +float *correlation; // for managing AVFilterPad.request_frame and AVFilterPad.filter_frame AVFrame *dst_buffer; @@ -228,18 +231,18 @@ static void yae_release_buffers(ATempoContext *atempo) av_freep(>frag[0].data); av_freep(>frag[1].data); +av_freep(>frag[0].xdat_in); +av_freep(>frag[1].xdat_in); av_freep(>frag[0].xdat); av_freep(>frag[1].xdat); av_freep(>buffer); av_freep(>hann); +av_freep(>correlation_in); av_freep(>correlation); -av_rdft_end(atempo->real_to_complex); -atempo->real_to_complex = NULL; - -av_rdft_end(atempo->complex_to_real); -atempo->complex_to_real = NULL; +av_tx_uninit(>real_to_complex); +av_tx_uninit(>complex_to_real); } /* av_realloc is not aligned enough; fortunately, the data does not need to @@ -247,7 +250,7 @@ static void yae_release_buffers(ATempoContext *atempo) #define RE_MALLOC_OR_FAIL(field, field_size)\ do {\ av_freep(); \ -field = av_malloc(field_size); \ +field = av_calloc(field_size, 1); \ if (!field) { \ yae_release_buffers(atempo);\ return AVERROR(ENOMEM); \ @@ -265,6 +268,7 @@ static int yae_reset(ATempoContext *atempo, { const int sample_size = av_get_bytes_per_sample(format); uint32_t nlevels = 0; +float scale = 1.f, iscale = 1.f; uint32_t pot; int i; @@ -288,29 +292,29 @@ static int yae_reset(ATempoContext *atempo, // initialize audio fragment buffers: RE_MALLOC_OR_FAIL(atempo->frag[0].data, atempo->window * atempo->stride); RE_MALLOC_OR_FAIL(atempo->frag[1].data, atempo->window * atempo->stride); -RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, atempo->window * sizeof(FFTComplex)); -RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, atempo->window * sizeof(FFTComplex)); +RE_MALLOC_OR_FAIL(atempo->frag[0].xdat_in, (atempo->window + 1) * sizeof(AVComplexFloat)); +RE_MALLOC_OR_FAIL(atempo->frag[1].xdat_in, (atempo->window + 1) * sizeof(AVComplexFloat)); +RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, (atempo->window + 1) * sizeof(AVComplexFloat)); +RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, (atempo->window + 1) * sizeof(AVComplexFloat)); // initialize rDFT contexts: -av_rdft_end(atempo->real_to_complex); -atempo->real_to_complex = NULL; - -av_rdft_end(atempo->complex_to_real); -atempo->complex_to_real = NULL; +