Browse Source

avfilter/vf_psnr: Fix rounding error in average_max

The intermediate was rounded to an integer

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.2
Michael Niedermayer 9 years ago
parent
commit
9264bb7e79
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      libavfilter/vf_psnr.c

+ 4
- 1
libavfilter/vf_psnr.c View File

@@ -241,6 +241,7 @@ static int config_input_ref(AVFilterLink *inlink)
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
PSNRContext *s = ctx->priv; PSNRContext *s = ctx->priv;
double average_max;
unsigned sum; unsigned sum;
int j; int j;


@@ -273,10 +274,12 @@ static int config_input_ref(AVFilterLink *inlink)
sum = 0; sum = 0;
for (j = 0; j < s->nb_components; j++) for (j = 0; j < s->nb_components; j++)
sum += s->planeheight[j] * s->planewidth[j]; sum += s->planeheight[j] * s->planewidth[j];
average_max = 0;
for (j = 0; j < s->nb_components; j++) { for (j = 0; j < s->nb_components; j++) {
s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum; s->planeweight[j] = (double) s->planeheight[j] * s->planewidth[j] / sum;
s->average_max += s->max[j] * s->planeweight[j];
average_max += s->max[j] * s->planeweight[j];
} }
s->average_max = lrint(average_max);


s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit; s->dsp.sse_line = desc->comp[0].depth > 8 ? sse_line_16bit : sse_line_8bit;
if (ARCH_X86) if (ARCH_X86)


Loading…
Cancel
Save