[FFmpeg-cvslog] avfilter/vf_ssim: fix temp size calculation

Muhammad Faiz git at videolan.org
Sun Aug 6 12:36:13 EEST 2017


ffmpeg | branch: release/3.2 | Muhammad Faiz <mfcc64 at gmail.com> | Thu Aug  3 07:59:09 2017 +0700| [5987b16f868cc4e615d1e4b344498509cca97fb8] | committer: Muhammad Faiz

avfilter/vf_ssim: fix temp size calculation

Also use av_mallocz_array.
Fix Ticket6519.

Reviewed-by: Tobias Rapp <t.rapp at noa-archive.com>
Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>
(cherry picked from commit f2d23ec03f28c6233059687c65a9124f65f8c312)

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

 libavfilter/vf_ssim.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index dd8f264812..6fc80995a9 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -147,6 +147,8 @@ static float ssim_endn(const int (*sum0)[4], const int (*sum1)[4], int width)
     return ssim;
 }
 
+#define SUM_LEN(w) (((w) >> 2) + 3)
+
 static float ssim_plane(SSIMDSPContext *dsp,
                         uint8_t *main, int main_stride,
                         uint8_t *ref, int ref_stride,
@@ -155,7 +157,7 @@ static float ssim_plane(SSIMDSPContext *dsp,
     int z = 0, y;
     float ssim = 0.0;
     int (*sum0)[4] = temp;
-    int (*sum1)[4] = sum0 + (width >> 2) + 3;
+    int (*sum1)[4] = sum0 + SUM_LEN(width);
 
     width >>= 2;
     height >>= 2;
@@ -297,7 +299,7 @@ static int config_input_ref(AVFilterLink *inlink)
     for (i = 0; i < s->nb_components; i++)
         s->coefs[i] = (double) s->planeheight[i] * s->planewidth[i] / sum;
 
-    s->temp = av_malloc((2 * inlink->w + 12) * sizeof(*s->temp));
+    s->temp = av_mallocz_array(2 * SUM_LEN(inlink->w), sizeof(int[4]));
     if (!s->temp)
         return AVERROR(ENOMEM);
 



More information about the ffmpeg-cvslog mailing list