[FFmpeg-cvslog] avfilter/vf_convolve: clear coefficients only when needed

Paul B Mahol git at videolan.org
Mon Dec 25 13:00:53 EET 2017


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Dec 25 10:04:59 2017 +0100| [ec6608f51b2d5a979b59d0dcc6a06629a0f8bd81] | committer: Paul B Mahol

avfilter/vf_convolve: clear coefficients only when needed

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ec6608f51b2d5a979b59d0dcc6a06629a0f8bd81
---

 libavfilter/vf_convolve.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_convolve.c b/libavfilter/vf_convolve.c
index 6eb9548456..2af9df5983 100644
--- a/libavfilter/vf_convolve.c
+++ b/libavfilter/vf_convolve.c
@@ -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;
             }
         }
     }



More information about the ffmpeg-cvslog mailing list