Commit ec6608f5 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_convolve: clear coefficients only when needed

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent be2da4c5
...@@ -158,39 +158,37 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata, ...@@ -158,39 +158,37 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata,
const int iw = (n - w) / 2, ih = (n - h) / 2; const int iw = (n - w) / 2, ih = (n - h) / 2;
int y, x; 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) { if (s->depth == 8) {
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
const uint8_t *src = in->data[plane] + in->linesize[plane] * y; const uint8_t *src = in->data[plane] + in->linesize[plane] * y;
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
fft_hdata[(y + ih) * n + iw + x].re = src[x] * scale; 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++) { 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].re = fft_hdata[(y + ih) * n + iw].re;
fft_hdata[(y + ih) * n + x].im = 0;
} }
for (x = n - iw; x < n; x++) { 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].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 (y = 0; y < ih; y++) {
for (x = 0; x < n; x++) { for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[ih * n + x].re; 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 (y = n - ih; y < n; y++) {
for (x = 0; x < n; x++) { 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].re = fft_hdata[(n - ih - 1) * n + x].re;
fft_hdata[y * n + x].im = 0;
} }
} }
} else { } else {
...@@ -199,26 +197,31 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata, ...@@ -199,26 +197,31 @@ static void fft_horizontal(ConvolveContext *s, FFTComplex *fft_hdata,
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
fft_hdata[(y + ih) * n + iw + x].re = src[x] * scale; 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++) { 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].re = fft_hdata[(y + ih) * n + iw].re;
fft_hdata[(y + ih) * n + x].im = 0;
} }
for (x = n - iw; x < n; x++) { 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].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 (y = 0; y < ih; y++) {
for (x = 0; x < n; x++) { for (x = 0; x < n; x++) {
fft_hdata[y * n + x].re = fft_hdata[ih * n + x].re; 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 (y = n - ih; y < n; y++) {
for (x = 0; x < n; x++) { 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].re = fft_hdata[(n - ih - 1) * n + x].re;
fft_hdata[y * n + x].im = 0;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment