[FFmpeg-devel] avfilter/firequalizer: use zero phase kernel
Commit Message
this makes real-valued kernel
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
---
libavfilter/af_firequalizer.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
Comments
On 10/19/16, Muhammad Faiz <mfcc64@gmail.com> wrote:
> this makes real-valued kernel
>
> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
> ---
> libavfilter/af_firequalizer.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
applied
thanks
@@ -198,20 +198,19 @@ static void fast_convolute(FIREqualizerContext *s, const float *kernel_buf, floa
if (nsamples <= s->nsamples_max) {
float *buf = conv_buf + idx->buf_idx * s->rdft_len;
float *obuf = conv_buf + !idx->buf_idx * s->rdft_len + idx->overlap_idx;
+ int center = s->fir_len/2;
int k;
- memcpy(buf, data, nsamples * sizeof(*data));
- memset(buf + nsamples, 0, (s->rdft_len - nsamples) * sizeof(*data));
+ memset(buf, 0, center * sizeof(*data));
+ memcpy(buf + center, data, nsamples * sizeof(*data));
+ memset(buf + center + nsamples, 0, (s->rdft_len - nsamples - center) * sizeof(*data));
av_rdft_calc(s->rdft, buf);
buf[0] *= kernel_buf[0];
- buf[1] *= kernel_buf[1];
- for (k = 2; k < s->rdft_len; k += 2) {
- float re, im;
- re = buf[k] * kernel_buf[k] - buf[k+1] * kernel_buf[k+1];
- im = buf[k] * kernel_buf[k+1] + buf[k+1] * kernel_buf[k];
- buf[k] = re;
- buf[k+1] = im;
+ buf[1] *= kernel_buf[s->rdft_len/2];
+ for (k = 1; k < s->rdft_len/2; k++) {
+ buf[2*k] *= kernel_buf[k];
+ buf[2*k+1] *= kernel_buf[k];
}
av_rdft_calc(s->irdft, buf);
@@ -534,8 +533,8 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
}
memset(s->analysis_buf + center + 1, 0, (s->analysis_rdft_len - s->fir_len) * sizeof(*s->analysis_buf));
- memcpy(rdft_buf, s->analysis_buf + s->analysis_rdft_len - center, center * sizeof(*s->analysis_buf));
- memcpy(rdft_buf + center, s->analysis_buf, (s->rdft_len - center) * sizeof(*s->analysis_buf));
+ memcpy(rdft_buf, s->analysis_buf, s->rdft_len/2 * sizeof(*s->analysis_buf));
+ memcpy(rdft_buf + s->rdft_len/2, s->analysis_buf + s->analysis_rdft_len - s->rdft_len/2, s->rdft_len/2 * sizeof(*s->analysis_buf));
av_rdft_calc(s->rdft, rdft_buf);
for (k = 0; k < s->rdft_len; k++) {
@@ -548,6 +547,11 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
}
}
+ rdft_buf[s->rdft_len-1] = rdft_buf[1];
+ for (k = 0; k < s->rdft_len/2; k++)
+ rdft_buf[k] = rdft_buf[2*k];
+ rdft_buf[s->rdft_len/2] = rdft_buf[s->rdft_len-1];
+
if (dump_fp)
dump_fir(ctx, dump_fp, ch);