[FFmpeg-devel] [PATCH] vf_psnr: sse2 optimizations for sum-squared-error.

Ronald S. Bultje rsbultje at gmail.com
Mon Jul 13 01:34:52 CEST 2015


Hi,

On Sun, Jul 12, 2015 at 5:54 PM, Paul B Mahol <onemda at gmail.com> wrote:

> On 7/12/15, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> > The internal line accumulator for 16bit can overflow, so I changed that
> > from int to uint64_t in the C code. The matching assembly looks a little
> > weird but output looks correct.
> >
> > (avx2 should be trivial to add later.)
> > ---
> >  libavfilter/psnr.h             |  33 ++++++++++
> >  libavfilter/vf_psnr.c          |  76 ++++++++++------------
> >  libavfilter/x86/Makefile       |   2 +
> >  libavfilter/x86/vf_psnr.asm    | 139
> > +++++++++++++++++++++++++++++++++++++++++
> >  libavfilter/x86/vf_psnr_init.c |  39 ++++++++++++
> >  5 files changed, 247 insertions(+), 42 deletions(-)
> >  create mode 100644 libavfilter/psnr.h
> >  create mode 100644 libavfilter/x86/vf_psnr.asm
> >  create mode 100644 libavfilter/x86/vf_psnr_init.c
> >
> > diff --git a/libavfilter/psnr.h b/libavfilter/psnr.h
> > new file mode 100644
> > index 0000000..efe94da
> > --- /dev/null
> > +++ b/libavfilter/psnr.h
> > @@ -0,0 +1,33 @@
> > +/*
> > + * Copyright (c) 2015 Ronald S. Bultje <rsbultje at gmail.com>
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301
> > USA
> > + */
> > +
> > +#ifndef LIBAVFILTER_PSNR_H
> > +#define LIBAVFILTER_PSNR_H
> > +
> > +#include <stddef.h>
> > +#include <stdint.h>
> > +
> > +typedef struct PSNRDSPContext {
> > +    uint64_t (*sse_line)(const uint8_t *buf, const uint8_t *ref, int w);
>
> Besides naming of function sse_line rest LGTM.
>

That was sort of inspired by other functions in lavfi. I'm open to
alternative suggestions.

Ronald


More information about the ffmpeg-devel mailing list