Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-10-01 Thread Carl Eugen Hoyos
2017-10-01 20:44 GMT+02:00 Ronald S. Bultje :
> Hi,
>
> On Sun, Oct 1, 2017 at 12:17 PM, Carl Eugen Hoyos 
> wrote:
>
>> 2017-10-01 14:03 GMT+02:00 Ronald S. Bultje :
>> > Hi,
>> >
>> > On Sat, Sep 30, 2017 at 3:40 PM, Carl Eugen Hoyos 
>> > wrote:
>>
>> >> Attached patch also support GBRP, I don't know if this is a good or
>> >> bad idea.
>> >
>> > I would personally probably err on the side of caution, but no strong
>> > opinions. If this works (I assume it does), I guess it's fine (?).
>>
>> Do you want me to commit (with or without GBRP)?
>>
>> Sorry, I really don't know if this is supposed to do something
>> useful or not.
>>
>
> vmafmotion in itself isn't very useful, but it's part of the native vmaf
> filter, which will be quite useful.
>
> I'd suggest to commit it without GBRP support for now. I'm not against GBRP
> support per se, I just don't know if the results are meaningful (since we'd
> base the metric on the G channel only), so I'd rather be conservative.

Pushed without GBRP, thank you!

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-10-01 Thread Ronald S. Bultje
Hi,

On Sun, Oct 1, 2017 at 12:17 PM, Carl Eugen Hoyos 
wrote:

> 2017-10-01 14:03 GMT+02:00 Ronald S. Bultje :
> > Hi,
> >
> > On Sat, Sep 30, 2017 at 3:40 PM, Carl Eugen Hoyos 
> > wrote:
>
> >> Attached patch also support GBRP, I don't know if this is a good or
> >> bad idea.
> >
> > I would personally probably err on the side of caution, but no strong
> > opinions. If this works (I assume it does), I guess it's fine (?).
>
> Do you want me to commit (with or without GBRP)?
>
> Sorry, I really don't know if this is supposed to do something
> useful or not.
>

vmafmotion in itself isn't very useful, but it's part of the native vmaf
filter, which will be quite useful.

I'd suggest to commit it without GBRP support for now. I'm not against GBRP
support per se, I just don't know if the results are meaningful (since we'd
base the metric on the G channel only), so I'd rather be conservative.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-10-01 Thread Carl Eugen Hoyos
2017-10-01 14:03 GMT+02:00 Ronald S. Bultje :
> Hi,
>
> On Sat, Sep 30, 2017 at 3:40 PM, Carl Eugen Hoyos 
> wrote:

>> Attached patch also support GBRP, I don't know if this is a good or
>> bad idea.
>
> I would personally probably err on the side of caution, but no strong
> opinions. If this works (I assume it does), I guess it's fine (?).

Do you want me to commit (with or without GBRP)?

Sorry, I really don't know if this is supposed to do something
useful or not.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-10-01 Thread Ronald S. Bultje
Hi,

On Sat, Sep 30, 2017 at 3:40 PM, Carl Eugen Hoyos 
wrote:

> 2017-09-30 20:30 GMT+02:00 Ronald S. Bultje :
> > Hi Carl,
> >
> > On Sat, Sep 30, 2017 at 2:19 PM, Carl Eugen Hoyos 
> > wrote:
> >
> >> 2017-09-30 19:47 GMT+02:00 Ronald S. Bultje :
> >> > Hi Carl,
> >> >
> >> > On Sat, Sep 30, 2017 at 1:31 PM, Carl Eugen Hoyos  >
> >> > wrote:
> >> >
> >> >> Hi!
> >> >>
> >> >> 2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh  >:
> >> >>
> >> >> > +static int query_formats(AVFilterContext *ctx)
> >> >> > +{
> >> >> > +static const enum AVPixelFormat pix_fmts[] = {
> >> >> > +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
> >> >> > AV_PIX_FMT_YUV420P,
> >> >> > +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
> >> >> > AV_PIX_FMT_YUV420P10,
> >> >>
> >> >> Is the algorithm only defined for these formats and bit-depth
> >> >> or are there just missing features?
> >> >> Gray and gray10 come to mind...
> >> >>
> >> >
> >> > Great question! I _believe_ that vmaf overall is luma-only, so it
> should
> >> be
> >> > entirely independent of chroma.
> >>
> >> Then imo, above function is just wrong, it should check for
> >> non-rgb or similar (think of YUVA444 and friends).
> >>
> >
> > I don't think I'm familiar enough with lavfi to send a patch, can you
> send
> > one? What I've asked Ashish to do (and what he's done here) is simply to
> > reproduce as closely as possible what Netflix' code does, and they only
> > support 420, 422 and 444 for 8 and 10 bits/component. I'm happy to
> support
> > more if I know how to.
>
> Attached patch also support GBRP, I don't know if this is a good or
> bad idea.
>

I would personally probably err on the side of caution, but no strong
opinions. If this works (I assume it does), I guess it's fine (?).

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Carl Eugen Hoyos
2017-09-30 20:30 GMT+02:00 Ronald S. Bultje :
> Hi Carl,
>
> On Sat, Sep 30, 2017 at 2:19 PM, Carl Eugen Hoyos 
> wrote:
>
>> 2017-09-30 19:47 GMT+02:00 Ronald S. Bultje :
>> > Hi Carl,
>> >
>> > On Sat, Sep 30, 2017 at 1:31 PM, Carl Eugen Hoyos 
>> > wrote:
>> >
>> >> Hi!
>> >>
>> >> 2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh :
>> >>
>> >> > +static int query_formats(AVFilterContext *ctx)
>> >> > +{
>> >> > +static const enum AVPixelFormat pix_fmts[] = {
>> >> > +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
>> >> > AV_PIX_FMT_YUV420P,
>> >> > +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
>> >> > AV_PIX_FMT_YUV420P10,
>> >>
>> >> Is the algorithm only defined for these formats and bit-depth
>> >> or are there just missing features?
>> >> Gray and gray10 come to mind...
>> >>
>> >
>> > Great question! I _believe_ that vmaf overall is luma-only, so it should
>> be
>> > entirely independent of chroma.
>>
>> Then imo, above function is just wrong, it should check for
>> non-rgb or similar (think of YUVA444 and friends).
>>
>
> I don't think I'm familiar enough with lavfi to send a patch, can you send
> one? What I've asked Ashish to do (and what he's done here) is simply to
> reproduce as closely as possible what Netflix' code does, and they only
> support 420, 422 and 444 for 8 and 10 bits/component. I'm happy to support
> more if I know how to.

Attached patch also support GBRP, I don't know if this is a good or
bad idea.

Carl Eugen
From c7da156438424bf9b08aaddaada4967868d28105 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Sat, 30 Sep 2017 21:39:08 +0200
Subject: [PATCH] lavfi/vmafmotion: Allow more pix_fmts.

---
 libavfilter/vf_vmafmotion.c |   22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
index 6b6150a..48986b7 100644
--- a/libavfilter/vf_vmafmotion.c
+++ b/libavfilter/vf_vmafmotion.c
@@ -261,15 +261,19 @@ int ff_vmafmotion_init(VMAFMotionData *s,
 
 static int query_formats(AVFilterContext *ctx)
 {
-static const enum AVPixelFormat pix_fmts[] = {
-AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P,
-AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10,
-AV_PIX_FMT_NONE
-};
-
-AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
-if (!fmts_list)
-return AVERROR(ENOMEM);
+AVFilterFormats *fmts_list = NULL;
+int format, ret;
+
+for (format = 0; av_pix_fmt_desc_get(format); format++) {
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
+if (!(desc->flags & (AV_PIX_FMT_FLAG_HWACCEL | AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_PAL)) &&
+(desc->flags & AV_PIX_FMT_FLAG_PLANAR || desc->nb_components == 1) &&
+(!(desc->flags & AV_PIX_FMT_FLAG_BE) == !HAVE_BIGENDIAN || desc->comp[0].depth == 8) &&
+(desc->comp[0].depth == 8 || desc->comp[0].depth == 10) &&
+(ret = ff_add_format(_list, format)) < 0)
+return ret;
+}
+
 return ff_set_common_formats(ctx, fmts_list);
 }
 
-- 
1.7.10.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Ronald S. Bultje
Hi Carl,

On Sat, Sep 30, 2017 at 2:19 PM, Carl Eugen Hoyos 
wrote:

> 2017-09-30 19:47 GMT+02:00 Ronald S. Bultje :
> > Hi Carl,
> >
> > On Sat, Sep 30, 2017 at 1:31 PM, Carl Eugen Hoyos 
> > wrote:
> >
> >> Hi!
> >>
> >> 2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh :
> >>
> >> > +static int query_formats(AVFilterContext *ctx)
> >> > +{
> >> > +static const enum AVPixelFormat pix_fmts[] = {
> >> > +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
> >> > AV_PIX_FMT_YUV420P,
> >> > +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
> >> > AV_PIX_FMT_YUV420P10,
> >>
> >> Is the algorithm only defined for these formats and bit-depth
> >> or are there just missing features?
> >> Gray and gray10 come to mind...
> >>
> >
> > Great question! I _believe_ that vmaf overall is luma-only, so it should
> be
> > entirely independent of chroma.
>
> Then imo, above function is just wrong, it should check for
> non-rgb or similar (think of YUVA444 and friends).
>

I don't think I'm familiar enough with lavfi to send a patch, can you send
one? What I've asked Ashish to do (and what he's done here) is simply to
reproduce as closely as possible what Netflix' code does, and they only
support 420, 422 and 444 for 8 and 10 bits/component. I'm happy to support
more if I know how to.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Carl Eugen Hoyos
2017-09-30 19:47 GMT+02:00 Ronald S. Bultje :
> Hi Carl,
>
> On Sat, Sep 30, 2017 at 1:31 PM, Carl Eugen Hoyos 
> wrote:
>
>> Hi!
>>
>> 2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh :
>>
>> > +static int query_formats(AVFilterContext *ctx)
>> > +{
>> > +static const enum AVPixelFormat pix_fmts[] = {
>> > +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
>> > AV_PIX_FMT_YUV420P,
>> > +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
>> > AV_PIX_FMT_YUV420P10,
>>
>> Is the algorithm only defined for these formats and bit-depth
>> or are there just missing features?
>> Gray and gray10 come to mind...
>>
>
> Great question! I _believe_ that vmaf overall is luma-only, so it should be
> entirely independent of chroma.

Then imo, above function is just wrong, it should check for
non-rgb or similar (think of YUVA444 and friends).

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Ronald S. Bultje
Hi Carl,

On Sat, Sep 30, 2017 at 1:31 PM, Carl Eugen Hoyos 
wrote:

> Hi!
>
> 2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh :
>
> > +static int query_formats(AVFilterContext *ctx)
> > +{
> > +static const enum AVPixelFormat pix_fmts[] = {
> > +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
> > AV_PIX_FMT_YUV420P,
> > +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
> > AV_PIX_FMT_YUV420P10,
>
> Is the algorithm only defined for these formats and bit-depth
> or are there just missing features?
> Gray and gray10 come to mind...
>

Great question! I _believe_ that vmaf overall is luma-only, so it should be
entirely independent of chroma. As such, gray and gray10 could probably be
added to the list and it should just work.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Carl Eugen Hoyos
Hi!

2017-09-15 22:47 GMT+02:00 Ashish Pratap Singh :

> +static int query_formats(AVFilterContext *ctx)
> +{
> +static const enum AVPixelFormat pix_fmts[] = {
> +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P,
> AV_PIX_FMT_YUV420P,
> +AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10,
> AV_PIX_FMT_YUV420P10,

Is the algorithm only defined for these formats and bit-depth
or are there just missing features?
Gray and gray10 come to mind...

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-30 Thread Ronald S. Bultje
Hi,

On Fri, Sep 29, 2017 at 9:39 AM, Ronald S. Bultje 
wrote:

> Hi,
>
> On Fri, Sep 15, 2017 at 4:47 PM, Ashish Pratap Singh 
> wrote:
>
>> From: Ashish Singh 
>>
>> Hi, this patch addresses the previous issues and changes it to a single
>> input filter.
>>
>> Signed-off-by: Ashish Singh 
>> ---
>>  Changelog   |   1 +
>>  doc/filters.texi|  14 ++
>>  libavfilter/Makefile|   1 +
>>  libavfilter/allfilters.c|   1 +
>>  libavfilter/vf_vmafmotion.c | 325 ++
>> ++
>>  libavfilter/vmaf_motion.h   |  58 
>>  6 files changed, 400 insertions(+)
>>  create mode 100644 libavfilter/vf_vmafmotion.c
>>  create mode 100644 libavfilter/vmaf_motion.h
>
>
> I made tiny changes to this patch (see attached patch). Basically, it adds
> an option (similar to psnr/ssim filters) to log the per-frame scores to a
> file, which can be convenient for debugging the per-frame scores, or using
> them externally using CLI. Secondly, it adjusts the filter/sad so that the
> calculations use a slightly higher internal depth for the fixed-point
> integer calculations. This makes the score slightly closer to the
> floating-point equivalent in the reference code. Lastly, it normalizes the
> 10-bit score back to 8-bit, which is what the reference code does also. It
> also makes use of the vmafdsp.sad() function pointer instead of calling
> image_sad() directly, so SIMD will be used when added later on.
>
> This should address all review comments (the rest were basically things
> that will be used in subsequent patches, so whether we address it or not
> doesn't really affect the final product), so if there's no further
> comments, I'll squash the two patches together and push it.
>

And ... pushed.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-29 Thread Ronald S. Bultje
Hi,

On Fri, Sep 15, 2017 at 4:47 PM, Ashish Pratap Singh 
wrote:

> From: Ashish Singh 
>
> Hi, this patch addresses the previous issues and changes it to a single
> input filter.
>
> Signed-off-by: Ashish Singh 
> ---
>  Changelog   |   1 +
>  doc/filters.texi|  14 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_vmafmotion.c | 325 ++
> ++
>  libavfilter/vmaf_motion.h   |  58 
>  6 files changed, 400 insertions(+)
>  create mode 100644 libavfilter/vf_vmafmotion.c
>  create mode 100644 libavfilter/vmaf_motion.h


I made tiny changes to this patch (see attached patch). Basically, it adds
an option (similar to psnr/ssim filters) to log the per-frame scores to a
file, which can be convenient for debugging the per-frame scores, or using
them externally using CLI. Secondly, it adjusts the filter/sad so that the
calculations use a slightly higher internal depth for the fixed-point
integer calculations. This makes the score slightly closer to the
floating-point equivalent in the reference code. Lastly, it normalizes the
10-bit score back to 8-bit, which is what the reference code does also. It
also makes use of the vmafdsp.sad() function pointer instead of calling
image_sad() directly, so SIMD will be used when added later on.

This should address all review comments (the rest were basically things
that will be used in subsequent patches, so whether we address it or not
doesn't really affect the final product), so if there's no further
comments, I'll squash the two patches together and push it.

Ronald


0001-Tiny-adjustments.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-18 Thread Ashish Pratap Singh
Hi,

On Mon, Sep 18, 2017 at 6:46 AM, James Almer  wrote:

> On 9/15/2017 5:47 PM, Ashish Pratap Singh wrote:
> > From: Ashish Singh 
> >
> > Hi, this patch addresses the previous issues and changes it to a single
> > input filter.
> >
> > Signed-off-by: Ashish Singh 
> > ---
> >  Changelog   |   1 +
> >  doc/filters.texi|  14 ++
> >  libavfilter/Makefile|   1 +
> >  libavfilter/allfilters.c|   1 +
> >  libavfilter/vf_vmafmotion.c | 325 ++
> ++
> >  libavfilter/vmaf_motion.h   |  58 
> >  6 files changed, 400 insertions(+)
> >  create mode 100644 libavfilter/vf_vmafmotion.c
> >  create mode 100644 libavfilter/vmaf_motion.h
> >
> > diff --git a/Changelog b/Changelog
> > index ea48e81..574f46e 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -48,6 +48,7 @@ version :
> >  - convolve video filter
> >  - VP9 tile threading support
> >  - KMS screen grabber
> > +- vmafmotion video filter
> >
> >  version 3.3:
> >  - CrystalHD decoder moved to new decode API
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 830de54..d996357 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -15570,6 +15570,20 @@ vignette='PI/4+random(1)*PI/50':eval=frame
> >
> >  @end itemize
> >
> > +@section vmafmotion
> > +
> > +Obtain the average vmaf motion score of a video.
> > +It is one of the component filters of VMAF.
> > +
> > +The obtained average motion score is printed through the logging system.
> > +
> > +In the below example the input file @file{ref.mpg} is being processed
> and score
> > +is computed.
> > +
> > +@example
> > +ffmpeg -i ref.mpg -lavfi vmafmotion -f null -
> > +@end example
> > +
> >  @section vstack
> >  Stack input videos vertically.
> >
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index 8aa974e..4289ee0 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -330,6 +330,7 @@ OBJS-$(CONFIG_VFLIP_FILTER)  +=
> vf_vflip.o
> >  OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o
> vf_vidstabdetect.o
> >  OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)   += vidstabutils.o
> vf_vidstabtransform.o
> >  OBJS-$(CONFIG_VIGNETTE_FILTER)   += vf_vignette.o
> > +OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o
> framesync.o
> >  OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
> >  OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
> >  OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> > index 63e8672..8ec54be 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -341,6 +341,7 @@ static void register_all(void)
> >  REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
> >  REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
> >  REGISTER_FILTER(VIGNETTE,   vignette,   vf);
> > +REGISTER_FILTER(VMAFMOTION, vmafmotion, vf);
> >  REGISTER_FILTER(VSTACK, vstack, vf);
> >  REGISTER_FILTER(W3FDIF, w3fdif, vf);
> >  REGISTER_FILTER(WAVEFORM,   waveform,   vf);
> > diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
> > new file mode 100644
> > index 000..c31c37c
> > --- /dev/null
> > +++ b/libavfilter/vf_vmafmotion.c
> > @@ -0,0 +1,325 @@
> > +/*
> > + * Copyright (c) 2017 Ronald S. Bultje 
> > + * Copyright (c) 2017 Ashish Pratap Singh 
> > + *
> > + * 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
> > + */
> > +
> > +/**
> > + * @file
> > + * Calculate VMAF Motion score.
> > + */
> > +
> > +#include "libavutil/opt.h"
> > +#include "libavutil/pixdesc.h"
> > +#include "avfilter.h"
> > +#include "drawutils.h"
> > +#include "formats.h"
> > +#include "internal.h"
> > +#include "vmaf_motion.h"
> > +
> > +#define vmafmotion_options NULL
>
> This is unused.
>
Ok, I'll remove it.

>
> > +#define BIT_SHIFT 10
> > +
> > +static const float FILTER_5[5] = {
> > +0.054488685,
> > +0.244201342,
> > +

Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-17 Thread James Almer
On 9/15/2017 5:47 PM, Ashish Pratap Singh wrote:
> From: Ashish Singh 
> 
> Hi, this patch addresses the previous issues and changes it to a single
> input filter.
> 
> Signed-off-by: Ashish Singh 
> ---
>  Changelog   |   1 +
>  doc/filters.texi|  14 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_vmafmotion.c | 325 
> 
>  libavfilter/vmaf_motion.h   |  58 
>  6 files changed, 400 insertions(+)
>  create mode 100644 libavfilter/vf_vmafmotion.c
>  create mode 100644 libavfilter/vmaf_motion.h
> 
> diff --git a/Changelog b/Changelog
> index ea48e81..574f46e 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -48,6 +48,7 @@ version :
>  - convolve video filter
>  - VP9 tile threading support
>  - KMS screen grabber
> +- vmafmotion video filter
>  
>  version 3.3:
>  - CrystalHD decoder moved to new decode API
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 830de54..d996357 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -15570,6 +15570,20 @@ vignette='PI/4+random(1)*PI/50':eval=frame
>  
>  @end itemize
>  
> +@section vmafmotion
> +
> +Obtain the average vmaf motion score of a video.
> +It is one of the component filters of VMAF.
> +
> +The obtained average motion score is printed through the logging system.
> +
> +In the below example the input file @file{ref.mpg} is being processed and 
> score
> +is computed.
> +
> +@example
> +ffmpeg -i ref.mpg -lavfi vmafmotion -f null -
> +@end example
> +
>  @section vstack
>  Stack input videos vertically.
>  
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 8aa974e..4289ee0 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -330,6 +330,7 @@ OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
>  OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o 
> vf_vidstabdetect.o
>  OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)   += vidstabutils.o 
> vf_vidstabtransform.o
>  OBJS-$(CONFIG_VIGNETTE_FILTER)   += vf_vignette.o
> +OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o framesync.o
>  OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
>  OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
>  OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 63e8672..8ec54be 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -341,6 +341,7 @@ static void register_all(void)
>  REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
>  REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
>  REGISTER_FILTER(VIGNETTE,   vignette,   vf);
> +REGISTER_FILTER(VMAFMOTION, vmafmotion, vf);
>  REGISTER_FILTER(VSTACK, vstack, vf);
>  REGISTER_FILTER(W3FDIF, w3fdif, vf);
>  REGISTER_FILTER(WAVEFORM,   waveform,   vf);
> diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
> new file mode 100644
> index 000..c31c37c
> --- /dev/null
> +++ b/libavfilter/vf_vmafmotion.c
> @@ -0,0 +1,325 @@
> +/*
> + * Copyright (c) 2017 Ronald S. Bultje 
> + * Copyright (c) 2017 Ashish Pratap Singh 
> + *
> + * 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
> + */
> +
> +/**
> + * @file
> + * Calculate VMAF Motion score.
> + */
> +
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "avfilter.h"
> +#include "drawutils.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "vmaf_motion.h"
> +
> +#define vmafmotion_options NULL

This is unused.

> +#define BIT_SHIFT 10
> +
> +static const float FILTER_5[5] = {
> +0.054488685,
> +0.244201342,
> +0.402619947,
> +0.244201342,
> +0.054488685
> +};
> +
> +typedef struct VMAFMotionContext {
> +const AVClass *class;
> +VMAFMotionData data;
> +} VMAFMotionContext;
> +
> +AVFILTER_DEFINE_CLASS(vmafmotion);
> +
> +static uint64_t image_sad(const uint16_t *img1, const uint16_t *img2, int w,
> +  int h, ptrdiff_t 

[FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-15 Thread Ashish Pratap Singh
From: Ashish Singh 

Hi, this patch addresses the previous issues and changes it to a single
input filter.

Signed-off-by: Ashish Singh 
---
 Changelog   |   1 +
 doc/filters.texi|  14 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_vmafmotion.c | 325 
 libavfilter/vmaf_motion.h   |  58 
 6 files changed, 400 insertions(+)
 create mode 100644 libavfilter/vf_vmafmotion.c
 create mode 100644 libavfilter/vmaf_motion.h

diff --git a/Changelog b/Changelog
index ea48e81..574f46e 100644
--- a/Changelog
+++ b/Changelog
@@ -48,6 +48,7 @@ version :
 - convolve video filter
 - VP9 tile threading support
 - KMS screen grabber
+- vmafmotion video filter
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index 830de54..d996357 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15570,6 +15570,20 @@ vignette='PI/4+random(1)*PI/50':eval=frame
 
 @end itemize
 
+@section vmafmotion
+
+Obtain the average vmaf motion score of a video.
+It is one of the component filters of VMAF.
+
+The obtained average motion score is printed through the logging system.
+
+In the below example the input file @file{ref.mpg} is being processed and score
+is computed.
+
+@example
+ffmpeg -i ref.mpg -lavfi vmafmotion -f null -
+@end example
+
 @section vstack
 Stack input videos vertically.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 8aa974e..4289ee0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -330,6 +330,7 @@ OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
 OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o 
vf_vidstabdetect.o
 OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)   += vidstabutils.o 
vf_vidstabtransform.o
 OBJS-$(CONFIG_VIGNETTE_FILTER)   += vf_vignette.o
+OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o framesync.o
 OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 63e8672..8ec54be 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -341,6 +341,7 @@ static void register_all(void)
 REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
 REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
 REGISTER_FILTER(VIGNETTE,   vignette,   vf);
+REGISTER_FILTER(VMAFMOTION, vmafmotion, vf);
 REGISTER_FILTER(VSTACK, vstack, vf);
 REGISTER_FILTER(W3FDIF, w3fdif, vf);
 REGISTER_FILTER(WAVEFORM,   waveform,   vf);
diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
new file mode 100644
index 000..c31c37c
--- /dev/null
+++ b/libavfilter/vf_vmafmotion.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright (c) 2017 Ronald S. Bultje 
+ * Copyright (c) 2017 Ashish Pratap Singh 
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Calculate VMAF Motion score.
+ */
+
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "internal.h"
+#include "vmaf_motion.h"
+
+#define vmafmotion_options NULL
+#define BIT_SHIFT 10
+
+static const float FILTER_5[5] = {
+0.054488685,
+0.244201342,
+0.402619947,
+0.244201342,
+0.054488685
+};
+
+typedef struct VMAFMotionContext {
+const AVClass *class;
+VMAFMotionData data;
+} VMAFMotionContext;
+
+AVFILTER_DEFINE_CLASS(vmafmotion);
+
+static uint64_t image_sad(const uint16_t *img1, const uint16_t *img2, int w,
+  int h, ptrdiff_t _img1_stride, ptrdiff_t 
_img2_stride)
+{
+ptrdiff_t img1_stride = _img1_stride / sizeof(*img1);
+ptrdiff_t img2_stride = _img2_stride / sizeof(*img2);
+uint64_t sum = 0;
+int i, j;
+
+for (i = 0; i < h; i++) {
+for (j = 0; j < w; j++) {
+sum += abs(img1[j] - img2[j]);
+}
+img1 += img1_stride;
+

Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-13 Thread Tobias Rapp

On 13.09.2017 15:10, Ronald S. Bultje wrote:

Hi,

On Wed, Sep 6, 2017 at 4:04 PM, Ashish Pratap Singh 
wrote:


From: Ashish Singh 

Hi, this patch changes previous one to framesync2.
SIMD is a work in progress for this filter.

Signed-off-by: Ashish Singh 
---
  Changelog   |   1 +
  doc/filters.texi|  16 ++
  libavfilter/Makefile|   1 +
  libavfilter/allfilters.c|   1 +
  libavfilter/vf_vmafmotion.c | 413 ++
++
  libavfilter/vmaf_motion.h   |  42 +
  6 files changed, 474 insertions(+)
  create mode 100644 libavfilter/vf_vmafmotion.c
  create mode 100644 libavfilter/vmaf_motion.h



One more general comment on this filter: it appears to me that the motion
is calculated based on the reference, and we only use the "main" to apply
the metadata to. Although this makes sense from the "vmaf" filter
perspective, I'm actually wondering if - from the perspective of the
"vmafmotion" filter alone, it wouldn't be simpler to just have a single
filterpad input ("reference") and apply the metadata on it (when used by
itself). (The "vmaf" filter could still apply metadata on the "main").

What do people think? Would you prefer the "vmaf" and "vmafmotion" to
consistently apply the metadata on the "main" video frames, or would you
prefer that the "vmafmotion" filter more accurately presents which frame is
used for the motion scoring, which also happens to lead to simpler code /
filterchains?


So when I understand this correctly the "vmafmotion" filter would work 
similar (in structure) to the "idet" filter, comparing consecutive 
frames on a single filterpad input and attaching metadata to the output 
frames? Yes, that would make using the "vmafmotion" filter more simple 
and flexible, IMHO.


Regards,
Tobias

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-13 Thread Ashish Pratap Singh
Hi,

On Wed, Sep 13, 2017 at 6:40 PM, Ronald S. Bultje 
wrote:

> Hi,
>
> On Wed, Sep 6, 2017 at 4:04 PM, Ashish Pratap Singh 
> wrote:
>
>> From: Ashish Singh 
>>
>> Hi, this patch changes previous one to framesync2.
>> SIMD is a work in progress for this filter.
>>
>> Signed-off-by: Ashish Singh 
>> ---
>>  Changelog   |   1 +
>>  doc/filters.texi|  16 ++
>>  libavfilter/Makefile|   1 +
>>  libavfilter/allfilters.c|   1 +
>>  libavfilter/vf_vmafmotion.c | 413 ++
>> ++
>>  libavfilter/vmaf_motion.h   |  42 +
>>  6 files changed, 474 insertions(+)
>>  create mode 100644 libavfilter/vf_vmafmotion.c
>>  create mode 100644 libavfilter/vmaf_motion.h
>
>
> One more general comment on this filter: it appears to me that the motion
> is calculated based on the reference, and we only use the "main" to apply
> the metadata to. Although this makes sense from the "vmaf" filter
> perspective, I'm actually wondering if - from the perspective of the
> "vmafmotion" filter alone, it wouldn't be simpler to just have a single
> filterpad input ("reference") and apply the metadata on it (when used by
> itself). (The "vmaf" filter could still apply metadata on the "main").
>
> What do people think? Would you prefer the "vmaf" and "vmafmotion" to
> consistently apply the metadata on the "main" video frames, or would you
> prefer that the "vmafmotion" filter more accurately presents which frame is
> used for the motion scoring, which also happens to lead to simpler code /
> filterchains?
>
> Ronald
>

yeah, you are right. In this filter only reference video is considered. So
I can make it a single filterpad input if everything is fine.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-13 Thread Ronald S. Bultje
Hi,

On Wed, Sep 6, 2017 at 4:04 PM, Ashish Pratap Singh 
wrote:

> From: Ashish Singh 
>
> Hi, this patch changes previous one to framesync2.
> SIMD is a work in progress for this filter.
>
> Signed-off-by: Ashish Singh 
> ---
>  Changelog   |   1 +
>  doc/filters.texi|  16 ++
>  libavfilter/Makefile|   1 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/vf_vmafmotion.c | 413 ++
> ++
>  libavfilter/vmaf_motion.h   |  42 +
>  6 files changed, 474 insertions(+)
>  create mode 100644 libavfilter/vf_vmafmotion.c
>  create mode 100644 libavfilter/vmaf_motion.h


One more general comment on this filter: it appears to me that the motion
is calculated based on the reference, and we only use the "main" to apply
the metadata to. Although this makes sense from the "vmaf" filter
perspective, I'm actually wondering if - from the perspective of the
"vmafmotion" filter alone, it wouldn't be simpler to just have a single
filterpad input ("reference") and apply the metadata on it (when used by
itself). (The "vmaf" filter could still apply metadata on the "main").

What do people think? Would you prefer the "vmaf" and "vmafmotion" to
consistently apply the metadata on the "main" video frames, or would you
prefer that the "vmafmotion" filter more accurately presents which frame is
used for the motion scoring, which also happens to lead to simpler code /
filterchains?

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-08 Thread Ronald S. Bultje
Hi,

On Wed, Sep 6, 2017 at 4:04 PM, Ashish Pratap Singh 
wrote:

> +#define MAX_ALIGN 32
> +#define ALIGN_CEIL(x) ((x) + ((x) % MAX_ALIGN ? MAX_ALIGN - (x) %
> MAX_ALIGN : 0))
>

../libavutil/macros.h:#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))

>
> +static const AVOption vmafmotion_options[] = {
> +{ NULL }
> +};
>

#define vmafmotion_options NULL?


> +FRAMESYNC_DEFINE_CLASS(vmafmotion, VMAFMotionContext, fs);
>

src/libavfilter/vf_vmafmotion.c:59:1: warning: unused function
'vmafmotion_framesync_preinit' [-Wunused-function]
FRAMESYNC_DEFINE_CLASS(vmafmotion, VMAFMotionContext, fs);
^
src/libavfilter/framesync2.h:298:12: note: expanded from macro
'FRAMESYNC_DEFINE_CLASS'
static int name##_framesync_preinit(AVFilterContext *ctx) { \
   ^
:44:1: note: expanded from here
vmafmotion_framesync_preinit


> +static inline int floorn(int n, int m)
> +{
> +return n - n % m;
> +}
> +
> +static inline int ceiln(int n, int m)
> +{
> +return n % m ? n + (m - n % m) : n;
> +}
> +
> +static void convolution_x(const int *filter, int filt_w, const uint16_t
> *src,
> +  uint16_t *dst, int w, int h, ptrdiff_t
> src_stride,
> +  ptrdiff_t dst_stride)
>

I would move sad() convolution_x/y() as function pointers into a
VMAFMotionDSPContext.

In ffmpeg, we always express "stride" in bytes, not in pixels. In SIMD, it
will become clear why. Same comment for _y.


> +{
> +int radius = filt_w / 2;
> +int borders_left = ceiln(radius, 1);
> +int borders_right = floorn(w - (filt_w - radius), 1);
>

For cases where m is 1, ceiln() and floorn() just return n, so this can be
simplified. Same comment for _y.


> +#define conv_y_fn(type, bits) \
> +static void convolution_y_##bits##bit(const int *filter, int filt_w,
> \
> +  const type *src, uint16_t *dst,
> \
> +  int w, int h, ptrdiff_t
> src_stride, \
> +  ptrdiff_t dst_stride) \
> +{ \
> +int radius = filt_w / 2; \
> +int borders_top = ceiln(radius, 1); \
> +int borders_bottom = floorn(h - (filt_w - radius), 1); \
> +int i, j, k; \
> +int sum = 0; \
> +\
> +for (i = 0; i < borders_top; i++) { \
> +for (j = 0; j < w; j++) { \
> +sum = 0; \
> +for (k = 0; k < filt_w; k++) { \
> +int i_tap = FFABS(i - radius + k); \
> +if (i_tap >= h) { \
> +i_tap = h - (i_tap - h + 1); \
> +} \
> +sum += filter[k] * src[i_tap * src_stride + j]; \
> +} \
> +dst[i * dst_stride + j] = sum >> N; \
>

Same comment for bottom 2: I would decrease the shift in this expression by
a few bits. The reason is that you can use the extra bits as fractional
bits to increase precision. E.g. for 8-bits, the input is 8bits and the
filter is 15, but the uint16_t can hold 16 bits (let's say 15 so we can use
signed instructions also) data, so instead of 8*15>>15=8 bits, we can shift
by just 8bits to get 15 bits (full-width) uint16_t. Same for 10-bit, where
we can shift by 10 instead of 15.

The sad calculation then indeed has to downshift the result again (*score =
(double) (sad * 1.0 / (w * h)); becomes sad * 1.0 / (w * h << (15-bits)).


> +void convolution_f32(const int *filter, int filt_w, const void *src,
> + uint16_t *dst, uint16_t *tmp, int w, int h,
> + ptrdiff_t src_stride, ptrdiff_t dst_stride, uint8_t
> type)
> +{
> +if(type == 8) {
>

Rename "type" to bitdepth.


> +if (s->desc->comp[0].depth <= 8) {
> +ref_px_stride = ref_stride / sizeof(uint8_t);
> +convolution_f32(s->filter, 5, (const uint8_t *) ref->data[0],
> +s->blur_data, s->temp_data, s->width, s->height,
> +ref_px_stride, px_stride, 8);
> +} else {
> +ref_px_stride = ref_stride / sizeof(uint16_t);
> +convolution_f32(s->filter, 5, (const uint16_t *) ref->data[0],
> +s->blur_data, s->temp_data, s->width, s->height,
> +ref_px_stride, px_stride, 10);
> +}
>

The if and resulting cast are unnecessary f you express stride in bytes
instead of pixels.

+memcpy(s->prev_blur_data, s->blur_data, data_sz);
>

Hm... Try FFSWAP with pointers.


> +static int query_formats(AVFilterContext *ctx)
> +{
> +static const enum AVPixelFormat pix_fmts[] = {
> +AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P,
> +AV_PIX_FMT_YUV444P10LE, AV_PIX_FMT_YUV422P10LE,
> AV_PIX_FMT_YUV420P10LE,
>

Remove the LE suffix, this filter handles native endian.


> +static int activate(AVFilterContext *ctx)
> +{
> +VMAFMotionContext *s = ctx->priv;
> +return ff_framesync2_activate(>fs);
> +}
> +
> +
> +static av_cold void uninit(AVFilterContext *ctx)
>

One newline too many in between 

[FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-09-06 Thread Ashish Pratap Singh
From: Ashish Singh 

Hi, this patch changes previous one to framesync2.
SIMD is a work in progress for this filter.

Signed-off-by: Ashish Singh 
---
 Changelog   |   1 +
 doc/filters.texi|  16 ++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_vmafmotion.c | 413 
 libavfilter/vmaf_motion.h   |  42 +
 6 files changed, 474 insertions(+)
 create mode 100644 libavfilter/vf_vmafmotion.c
 create mode 100644 libavfilter/vmaf_motion.h

diff --git a/Changelog b/Changelog
index cae5254..883e08f 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - add --disable-autodetect build switch
 - drop deprecated qtkit input device (use avfoundation instead)
 - despill video filter
+- vmafmotion video filter
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index 7790367..9a348b6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15488,6 +15488,22 @@ vignette='PI/4+random(1)*PI/50':eval=frame
 
 @end itemize
 
+@section vmafmotion
+
+Obtain the average vmaf motion score between two input videos.
+It is one of the component filters of VMAF.
+
+This filter takes two input videos.
+
+The obtained average motion score is printed through the logging system.
+
+In the below example the input file @file{main.mpg} being processed is compared
+with the reference file @file{ref.mpg}.
+
+@example
+ffmpeg -i main.mpg -i ref.mpg -lavfi vmafmotion -f null -
+@end example
+
 @section vstack
 Stack input videos vertically.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1e460ab..de46649 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -328,6 +328,7 @@ OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
 OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o 
vf_vidstabdetect.o
 OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)   += vidstabutils.o 
vf_vidstabtransform.o
 OBJS-$(CONFIG_VIGNETTE_FILTER)   += vf_vignette.o
+OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o framesync2.o
 OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync2.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9a2cfea..31f1971 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -339,6 +339,7 @@ static void register_all(void)
 REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
 REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
 REGISTER_FILTER(VIGNETTE,   vignette,   vf);
+REGISTER_FILTER(VMAFMOTION, vmafmotion, vf);
 REGISTER_FILTER(VSTACK, vstack, vf);
 REGISTER_FILTER(W3FDIF, w3fdif, vf);
 REGISTER_FILTER(WAVEFORM,   waveform,   vf);
diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
new file mode 100644
index 000..873d00f
--- /dev/null
+++ b/libavfilter/vf_vmafmotion.c
@@ -0,0 +1,413 @@
+/*
+ * Copyright (c) 2017 Ronald S. Bultje 
+ * Copyright (c) 2017 Ashish Pratap Singh 
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Calculate VMAF Motion score between two input videos.
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "framesync2.h"
+#include "internal.h"
+#include "vmaf_motion.h"
+#include "video.h"
+
+typedef struct VMAFMotionContext {
+const AVClass *class;
+FFFrameSync fs;
+const AVPixFmtDescriptor *desc;
+int filter[5];
+int width;
+int height;
+uint16_t *prev_blur_data;
+uint16_t *blur_data;
+uint16_t *temp_data;
+double motion_sum;
+uint64_t nb_frames;
+} VMAFMotionContext;
+
+#define MAX_ALIGN 32
+#define ALIGN_CEIL(x) ((x) + ((x) % MAX_ALIGN ? MAX_ALIGN - (x) % MAX_ALIGN : 
0))
+
+static const AVOption vmafmotion_options[] = {
+{ NULL }
+};
+
+FRAMESYNC_DEFINE_CLASS(vmafmotion, VMAFMotionContext, 

Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-08-02 Thread Ashish Pratap Singh
Hi,

On Aug 2, 2017 19:18, "Nicolas George"  wrote:

Le quintidi 15 thermidor, an CCXXV, Ashish Pratap Singh a écrit :
> +FFDualInputContext dinput;

dualinput is about to be removed, please see the patch series two days
ago.

Regards,

--

Ok

  Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-08-02 Thread Nicolas George
Le quintidi 15 thermidor, an CCXXV, Ashish Pratap Singh a écrit :
> +FFDualInputContext dinput;

dualinput is about to be removed, please see the patch series two days
ago.

Regards,

-- 
  Nicolas George
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter: add vmafmotion filter

2017-08-02 Thread Ashish Pratap Singh
From: Ashish Singh 

Signed-off-by: Ashish Singh 
---
 doc/filters.texi|  19 +++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_vmafmotion.c | 404 
 libavfilter/vmaf_motion.h   |  42 +
 5 files changed, 467 insertions(+)
 create mode 100644 libavfilter/vf_vmafmotion.c
 create mode 100644 libavfilter/vmaf_motion.h

diff --git a/doc/filters.texi b/doc/filters.texi
index 2324b96..ee1e884 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15137,6 +15137,25 @@ vignette='PI/4+random(1)*PI/50':eval=frame
 
 @end itemize
 
+@section vmafmotion
+
+Obtain the average vmaf motion score between two input videos.
+It is one of the component filters of VMAF.
+
+This filter takes two input videos.
+
+Both input videos must have the same resolution and pixel format.
+Also it assumes that both inputs have the same number of frames.
+
+The obtained average motion score is printed through the logging system.
+
+In the below example the input file @file{main.mpg} being processed is compared
+with the reference file @file{ref.mpg}.
+
+@example
+ffmpeg -i main.mpg -i ref.mpg -lavfi vmafmotion -f null -
+@end example
+
 @section vstack
 Stack input videos vertically.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ee16361..771e434 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -322,6 +322,7 @@ OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
 OBJS-$(CONFIG_VIDSTABDETECT_FILTER)  += vidstabutils.o 
vf_vidstabdetect.o
 OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER)   += vidstabutils.o 
vf_vidstabtransform.o
 OBJS-$(CONFIG_VIGNETTE_FILTER)   += vf_vignette.o
+OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o dualinput.o 
framesync.o
 OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o
 OBJS-$(CONFIG_WAVEFORM_FILTER)   += vf_waveform.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index b1c2d11..644ab44 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -333,6 +333,7 @@ static void register_all(void)
 REGISTER_FILTER(VIDSTABDETECT,  vidstabdetect,  vf);
 REGISTER_FILTER(VIDSTABTRANSFORM, vidstabtransform, vf);
 REGISTER_FILTER(VIGNETTE,   vignette,   vf);
+REGISTER_FILTER(VMAFMOTION, vmafmotion, vf);
 REGISTER_FILTER(VSTACK, vstack, vf);
 REGISTER_FILTER(W3FDIF, w3fdif, vf);
 REGISTER_FILTER(WAVEFORM,   waveform,   vf);
diff --git a/libavfilter/vf_vmafmotion.c b/libavfilter/vf_vmafmotion.c
new file mode 100644
index 000..8456939
--- /dev/null
+++ b/libavfilter/vf_vmafmotion.c
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2017 Ronald S. Bultje 
+ * Copyright (c) 2017 Ashish Pratap Singh 
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Calculate VMAF Motion score between two input videos.
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "avfilter.h"
+#include "dualinput.h"
+#include "drawutils.h"
+#include "formats.h"
+#include "internal.h"
+#include "vmaf_motion.h"
+#include "video.h"
+
+typedef struct VMAFMotionContext {
+const AVClass *class;
+FFDualInputContext dinput;
+const AVPixFmtDescriptor *desc;
+int filter[5];
+int width;
+int height;
+uint16_t *prev_blur_data;
+uint16_t *blur_data;
+uint16_t *temp_data;
+double motion_sum;
+uint64_t nb_frames;
+} VMAFMotionContext;
+
+#define MAX_ALIGN 32
+#define ALIGN_CEIL(x) ((x) + ((x) % MAX_ALIGN ? MAX_ALIGN - (x) % MAX_ALIGN : 
0))
+
+static const AVOption vmafmotion_options[] = {
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(vmafmotion);
+
+static double image_sad(const uint16_t *img1, const uint16_t *img2, int w, int 
h,
+ptrdiff_t img1_stride, ptrdiff_t img2_stride)
+{
+uint64_t sum = 0;
+int i, j;
+
+for (i = 0; i < h; i++) {
+for (j = 0; j < w; j++) {
+sum += abs(img1[i * img1_stride + j] - img2[i * img2_stride +