[FFmpeg-devel] [PATCH] avfilter/vf_psnr: Fix rounding error in average_max

Michael Niedermayer michael at niedermayer.cc
Thu Jul 21 12:18:47 EEST 2016


On Thu, Jul 21, 2016 at 10:41:10AM +0200, Paul B Mahol wrote:
> On 7/21/16, Michael Niedermayer <michael at niedermayer.cc> wrote:
> > The intermediate was rounded to an integer
> >
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavfilter/vf_psnr.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> > index f3dff62..54d4ff0 100644
> > --- a/libavfilter/vf_psnr.c
> > +++ b/libavfilter/vf_psnr.c
> > @@ -246,6 +246,7 @@ static int config_input_ref(AVFilterLink *inlink)
> >      const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
> >      AVFilterContext *ctx  = inlink->dst;
> >      PSNRContext *s = ctx->priv;
> > +    double average_max;
> >      unsigned sum;
> >      int j;
> >
> > @@ -278,10 +279,12 @@ static int config_input_ref(AVFilterLink *inlink)
> >      sum = 0;
> >      for (j = 0; j < s->nb_components; j++)
> >          sum += s->planeheight[j] * s->planewidth[j];
> > +    average_max = 0;
> >      for (j = 0; j < s->nb_components; j++) {
> >          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;
> >      if (ARCH_X86)
> > --
> > 1.7.9.5
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> 
> ok

applied

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160721/f1a5623f/attachment.sig>


More information about the ffmpeg-devel mailing list