Commit eadb52d4 authored by Muhammad Faiz's avatar Muhammad Faiz

avfilter/vf_ssim: fix temp size calculation

Also use av_mallocz_array.
Fix Ticket6519.
Reviewed-by: 's avatarTobias Rapp <t.rapp@noa-archive.com>
Signed-off-by: 's avatarMuhammad Faiz <mfcc64@gmail.com>
(cherry picked from commit f2d23ec0)
parent afa34cb3
......@@ -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);
......
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