aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-07-27 21:16:28 +0200
committerPaul B Mahol <onemda@gmail.com>2021-07-27 21:16:28 +0200
commit0068b3d0f0bc06b2b083eb729bf84f1a3196a2a9 (patch)
tree0da526a3d07486f53f77c1e2e049c0360becbe7a /libavfilter
parent925d41ebd47bb21a55de4cc1668277076349ce0e (diff)
downloadffmpeg-0068b3d0f0bc06b2b083eb729bf84f1a3196a2a9.tar.gz
avfilter/avf_showcqt: switch to TX FFT from avutil
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avf_showcqt.c33
-rw-r--r--libavfilter/avf_showcqt.h16
-rw-r--r--libavfilter/x86/avf_showcqt_init.c2
3 files changed, 27 insertions, 24 deletions
diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c
index f1d8f16b32..aa9900ebe0 100644
--- a/libavfilter/avf_showcqt.c
+++ b/libavfilter/avf_showcqt.c
@@ -19,7 +19,7 @@
*/
#include "config.h"
-#include "libavcodec/avfft.h"
+#include "libavutil/tx.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/xga_font_data.h"
@@ -144,13 +144,13 @@ static void common_uninit(ShowCQTContext *s)
av_frame_free(&s->axis_frame);
av_frame_free(&s->sono_frame);
- av_fft_end(s->fft_ctx);
- s->fft_ctx = NULL;
+ av_tx_uninit(&s->fft_ctx);
if (s->coeffs)
for (k = 0; k < s->cqt_len; k++)
av_freep(&s->coeffs[k].val);
av_freep(&s->coeffs);
av_freep(&s->fft_data);
+ av_freep(&s->fft_input);
av_freep(&s->fft_result);
av_freep(&s->cqt_result);
av_freep(&s->attack_data);
@@ -267,15 +267,15 @@ error:
return ret;
}
-static void cqt_calc(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs,
+static void cqt_calc(AVComplexFloat *dst, const AVComplexFloat *src, const Coeffs *coeffs,
int len, int fft_len)
{
int k, x, i, j;
for (k = 0; k < len; k++) {
- FFTComplex l, r, a = {0,0}, b = {0,0};
+ AVComplexFloat l, r, a = {0,0}, b = {0,0};
for (x = 0; x < coeffs[k].len; x++) {
- FFTSample u = coeffs[k].val[x];
+ float u = coeffs[k].val[x];
i = coeffs[k].start + x;
j = fft_len - i;
a.re += u * src[i].re;
@@ -730,7 +730,7 @@ static float calculate_gamma(float v, float g)
return expf(logf(v) / g);
}
-static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len, float cscheme[6])
+static void rgb_from_cqt(ColorFloat *c, const AVComplexFloat *v, float g, int len, float cscheme[6])
{
int x;
for (x = 0; x < len; x++) {
@@ -740,7 +740,7 @@ static void rgb_from_cqt(ColorFloat *c, const FFTComplex *v, float g, int len, f
}
}
-static void yuv_from_cqt(ColorFloat *c, const FFTComplex *v, float gamma, int len, float cm[3][3], float cscheme[6])
+static void yuv_from_cqt(ColorFloat *c, const AVComplexFloat *v, float gamma, int len, float cm[3][3], float cscheme[6])
{
int x;
for (x = 0; x < len; x++) {
@@ -1110,7 +1110,7 @@ static void process_cqt(ShowCQTContext *s)
if (s->fcount > 1) {
float rcp_fcount = 1.0f / s->fcount;
for (x = 0; x < s->width; x++) {
- FFTComplex result = {0.0f, 0.0f};
+ AVComplexFloat result = {0.0f, 0.0f};
for (i = 0; i < s->fcount; i++) {
result.re += s->cqt_result[s->fcount * x + i].re;
result.im += s->cqt_result[s->fcount * x + i].im;
@@ -1139,17 +1139,16 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
last_time = av_gettime_relative();
- memcpy(s->fft_result, s->fft_data, s->fft_len * sizeof(*s->fft_data));
+ memcpy(s->fft_input, s->fft_data, s->fft_len * sizeof(*s->fft_data));
if (s->attack_data) {
int k;
for (k = 0; k < s->remaining_fill_max; k++) {
- s->fft_result[s->fft_len/2+k].re *= s->attack_data[k];
- s->fft_result[s->fft_len/2+k].im *= s->attack_data[k];
+ s->fft_input[s->fft_len/2+k].re *= s->attack_data[k];
+ s->fft_input[s->fft_len/2+k].im *= s->attack_data[k];
}
}
- av_fft_permute(s->fft_ctx, s->fft_result);
- av_fft_calc(s->fft_ctx, s->fft_result);
+ s->tx_fn(s->fft_ctx, s->fft_result, s->fft_input, sizeof(float));
s->fft_result[s->fft_len] = s->fft_result[0];
UPDATE_TIME(s->fft_time);
@@ -1355,6 +1354,7 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowCQTContext *s = ctx->priv;
+ float scale;
int ret;
common_uninit(s);
@@ -1380,9 +1380,10 @@ static int config_output(AVFilterLink *outlink)
s->fft_len = 1 << s->fft_bits;
av_log(ctx, AV_LOG_INFO, "fft_len = %d, cqt_len = %d.\n", s->fft_len, s->cqt_len);
- s->fft_ctx = av_fft_init(s->fft_bits, 0);
+ ret = av_tx_init(&s->fft_ctx, &s->tx_fn, AV_TX_FLOAT_FFT, 0, s->fft_len, &scale, 0);
s->fft_data = av_calloc(s->fft_len, sizeof(*s->fft_data));
- s->fft_result = av_calloc(s->fft_len + 64, sizeof(*s->fft_result));
+ s->fft_input = av_calloc(FFALIGN(s->fft_len + 64, 256), sizeof(*s->fft_input));
+ s->fft_result = av_calloc(FFALIGN(s->fft_len + 64, 256), sizeof(*s->fft_result));
s->cqt_result = av_malloc_array(s->cqt_len, sizeof(*s->cqt_result));
if (!s->fft_ctx || !s->fft_data || !s->fft_result || !s->cqt_result)
return AVERROR(ENOMEM);
diff --git a/libavfilter/avf_showcqt.h b/libavfilter/avf_showcqt.h
index 0cef5a2003..b6c1e0e108 100644
--- a/libavfilter/avf_showcqt.h
+++ b/libavfilter/avf_showcqt.h
@@ -21,12 +21,12 @@
#ifndef AVFILTER_SHOWCQT_H
#define AVFILTER_SHOWCQT_H
-#include "libavcodec/avfft.h"
+#include "libavutil/tx.h"
#include "avfilter.h"
#include "internal.h"
typedef struct Coeffs {
- FFTSample *val;
+ float *val;
int start, len;
} Coeffs;
@@ -58,11 +58,13 @@ typedef struct ShowCQTContext {
int remaining_fill_max;
int64_t next_pts;
double *freq;
- FFTContext *fft_ctx;
+ AVTXContext *fft_ctx;
+ av_tx_fn tx_fn;
Coeffs *coeffs;
- FFTComplex *fft_data;
- FFTComplex *fft_result;
- FFTComplex *cqt_result;
+ AVComplexFloat *fft_data;
+ AVComplexFloat *fft_input;
+ AVComplexFloat *fft_result;
+ AVComplexFloat *cqt_result;
float *attack_data;
int fft_bits;
int fft_len;
@@ -76,7 +78,7 @@ typedef struct ShowCQTContext {
float cmatrix[3][3];
float cscheme_v[6];
/* callback */
- void (*cqt_calc)(FFTComplex *dst, const FFTComplex *src, const Coeffs *coeffs,
+ void (*cqt_calc)(AVComplexFloat *dst, const AVComplexFloat *src, const Coeffs *coeffs,
int len, int fft_len);
void (*permute_coeffs)(float *v, int len);
void (*draw_bar)(AVFrame *out, const float *h, const float *rcp_h,
diff --git a/libavfilter/x86/avf_showcqt_init.c b/libavfilter/x86/avf_showcqt_init.c
index 0cc164c352..2320b30239 100644
--- a/libavfilter/x86/avf_showcqt_init.c
+++ b/libavfilter/x86/avf_showcqt_init.c
@@ -24,7 +24,7 @@
#include "libavfilter/avf_showcqt.h"
#define DECLARE_CQT_CALC(type) \
-void ff_showcqt_cqt_calc_##type(FFTComplex *dst, const FFTComplex *src, \
+void ff_showcqt_cqt_calc_##type(AVComplexFloat *dst, const AVComplexFloat *src, \
const Coeffs *coeffs, int len, int fft_len)
DECLARE_CQT_CALC(sse);