diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-10-13 23:10:05 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-10-14 01:27:16 +0200 |
commit | 8add1b39e285915434a948d1bcc2988af0fddef1 (patch) | |
tree | c9e4a2cccd77cadc3bf82e64ebc0bb9621e9dd4c | |
parent | 933765aa0e07653307ff65a6af159a5922f1dc1d (diff) | |
download | ffmpeg-8add1b39e285915434a948d1bcc2988af0fddef1.tar.gz |
avfilter/vf_fftfilt: simplify bits/len calculation
-rw-r--r-- | libavfilter/vf_fftfilt.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c index f6871e4bbb..237306fecf 100644 --- a/libavfilter/vf_fftfilt.c +++ b/libavfilter/vf_fftfilt.c @@ -266,7 +266,7 @@ static int config_props(AVFilterLink *inlink) { FFTFILTContext *s = inlink->dst->priv; const AVPixFmtDescriptor *desc; - int rdft_hbits, rdft_vbits, i, plane; + int i, plane; desc = av_pix_fmt_desc_get(inlink->format); s->depth = desc->comp[0].depth; @@ -282,9 +282,8 @@ static int config_props(AVFilterLink *inlink) int h = s->planeheight[i]; /* RDFT - Array initialization for Horizontal pass*/ - for (rdft_hbits = 1; 1 << rdft_hbits < w*10/9; rdft_hbits++); - s->rdft_hbits[i] = rdft_hbits; - s->rdft_hlen[i] = 1 << rdft_hbits; + s->rdft_hlen[i] = 1 << (32 - ff_clz(w)); + s->rdft_hbits[i] = av_log2(s->rdft_hlen[i]); if (!(s->rdft_hdata[i] = av_malloc_array(h, s->rdft_hlen[i] * sizeof(FFTSample)))) return AVERROR(ENOMEM); @@ -294,9 +293,8 @@ static int config_props(AVFilterLink *inlink) return AVERROR(ENOMEM); /* RDFT - Array initialization for Vertical pass*/ - for (rdft_vbits = 1; 1 << rdft_vbits < h*10/9; rdft_vbits++); - s->rdft_vbits[i] = rdft_vbits; - s->rdft_vlen[i] = 1 << rdft_vbits; + s->rdft_vlen[i] = 1 << (32 - ff_clz(h)); + s->rdft_vbits[i] = av_log2(s->rdft_vlen[i]); if (!(s->rdft_vdata[i] = av_malloc_array(s->rdft_hlen[i], s->rdft_vlen[i] * sizeof(FFTSample)))) return AVERROR(ENOMEM); |