1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/vf_convolve: clear coefficients only when needed

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2017-12-25 10:04:59 +01:00
parent be2da4c522
commit ec6608f51b

View File

@ -158,39 +158,37 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata,
const int iw = (n - w) / 2, ih = (n - h) / 2;
int y, x;
for (y = 0; y < n; y++) {
for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = 0;
fft_hdata[y * n + x].im = 0;
}
}
if (s->depth == 8) {
for (y = 0; y < h; y++) {
const uint8_t *src = in->data[plane] + in->linesize[plane] * y;
for (x = 0; x < w; x++) {
fft_hdata[(y + ih) * n + iw + x].re = src[x] * scale;
fft_hdata[(y + ih) * n + iw + x].im = 0;
}
for (x = 0; x < iw; x++) {
fft_hdata[(y + ih) * n + x].re = fft_hdata[(y + ih) * n + iw].re;
fft_hdata[(y + ih) * n + x].im = 0;
}
for (x = n - iw; x < n; x++) {
fft_hdata[(y + ih) * n + x].re = fft_hdata[(y + ih) * n + n - iw - 1].re;
fft_hdata[(y + ih) * n + x].im = 0;
}
}
for (y = 0; y < ih; y++) {
for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[ih * n + x].re;
fft_hdata[y * n + x].im = 0;
}
}
for (y = n - ih; y < n; y++) {
for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[(n - ih - 1) * n + x].re;
fft_hdata[y * n + x].im = 0;
}
}
} else {
@ -199,26 +197,31 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata,
for (x = 0; x < w; x++) {
fft_hdata[(y + ih) * n + iw + x].re = src[x] * scale;
fft_hdata[(y + ih) * n + iw + x].im = 0;
}
for (x = 0; x < iw; x++) {
fft_hdata[(y + ih) * n + x].re = fft_hdata[(y + ih) * n + iw].re;
fft_hdata[(y + ih) * n + x].im = 0;
}
for (x = n - iw; x < n; x++) {
fft_hdata[(y + ih) * n + x].re = fft_hdata[(y + ih) * n + n - iw - 1].re;
fft_hdata[(y + ih) * n + x].im = 0;
}
}
for (y = 0; y < ih; y++) {
for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[ih * n + x].re;
fft_hdata[y * n + x].im = 0;
}
}
for (y = n - ih; y < n; y++) {
for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[(n - ih - 1) * n + x].re;
fft_hdata[y * n + x].im = 0;
}
}
}