diff options
author | Muhammad Faiz <mfcc64@gmail.com> | 2017-08-03 07:59:09 +0700 |
---|---|---|
committer | Muhammad Faiz <mfcc64@gmail.com> | 2017-08-06 16:25:33 +0700 |
commit | 5987b16f868cc4e615d1e4b344498509cca97fb8 (patch) | |
tree | b3d75fc2f9c1ea9b4fc8a92f9c82155174910ce6 | |
parent | 66395ac32bfbc6e22da7176700479ef5543e493f (diff) | |
download | ffmpeg-5987b16f868cc4e615d1e4b344498509cca97fb8.tar.gz |
avfilter/vf_ssim: fix temp size calculation
Also use av_mallocz_array.
Fix Ticket6519.
Reviewed-by: Tobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
(cherry picked from commit f2d23ec03f28c6233059687c65a9124f65f8c312)
-rw-r--r-- | libavfilter/vf_ssim.c | 6 |
1 files 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); |