Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-31 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Wednesday, July 17, 2019 8:42 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD
> for filter_3x3()
> 
> On 7/15/19, Song, Ruiling  wrote:
> >> -Original Message-
> >> From: Song, Ruiling
> >> Sent: Tuesday, July 9, 2019 9:15 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Cc: Song, Ruiling 
> >> Subject: [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()
> >>
> >> Tested using a simple command (apply edge enhance):
> >> ./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
> >>  -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0
> >> 0:0 0 0 -1 1 0 0
> >> 0 0:5:1:1:1:0:128:128:128" \
> >>  -an -vframes 1000 -f null /dev/null
> >>
> >> The fps increase from 151 to 270 on my local machine.
> >>
> >> Signed-off-by: Ruiling Song 
> > Ping?
> 
> Should be fine IFF output is exact with C version (under different
> parameters).
Thanks Paul, after fixing a bug in scalar code path, the v2 produces exact 
result as C version.
Have tested against many different parameters. Will apply in a few days.

Thanks!
Ruiling

> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-24 Thread Paul B Mahol
On 7/17/19, Paul B Mahol  wrote:
> On 7/15/19, Song, Ruiling  wrote:
>>> -Original Message-
>>> From: Song, Ruiling
>>> Sent: Tuesday, July 9, 2019 9:15 AM
>>> To: ffmpeg-devel@ffmpeg.org
>>> Cc: Song, Ruiling 
>>> Subject: [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()
>>>
>>> Tested using a simple command (apply edge enhance):
>>> ./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
>>>  -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0
>>> 0:0 0 0 -1 1 0 0
>>> 0 0:5:1:1:1:0:128:128:128" \
>>>  -an -vframes 1000 -f null /dev/null
>>>
>>> The fps increase from 151 to 270 on my local machine.
>>>
>>> Signed-off-by: Ruiling Song 
>> Ping?
>
> Should be fine IFF output is exact with C version (under different
> parameters).
>

So can you confirm this?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-17 Thread Paul B Mahol
On 7/15/19, Song, Ruiling  wrote:
>> -Original Message-
>> From: Song, Ruiling
>> Sent: Tuesday, July 9, 2019 9:15 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Cc: Song, Ruiling 
>> Subject: [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()
>>
>> Tested using a simple command (apply edge enhance):
>> ./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
>>  -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0
>> 0:0 0 0 -1 1 0 0
>> 0 0:5:1:1:1:0:128:128:128" \
>>  -an -vframes 1000 -f null /dev/null
>>
>> The fps increase from 151 to 270 on my local machine.
>>
>> Signed-off-by: Ruiling Song 
> Ping?

Should be fine IFF output is exact with C version (under different parameters).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-14 Thread Song, Ruiling
> -Original Message-
> From: Song, Ruiling
> Sent: Tuesday, July 9, 2019 9:15 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Song, Ruiling 
> Subject: [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()
> 
> Tested using a simple command (apply edge enhance):
> ./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
>  -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 
> 0 0 -1 1 0 0
> 0 0:5:1:1:1:0:128:128:128" \
>  -an -vframes 1000 -f null /dev/null
> 
> The fps increase from 151 to 270 on my local machine.
> 
> Signed-off-by: Ruiling Song 
Ping?

> ---
>  libavfilter/convolution.h |  64 +++
>  libavfilter/vf_convolution.c  |  41 +--
>  libavfilter/x86/Makefile  |   2 +
>  libavfilter/x86/vf_convolution.asm| 158 ++
>  libavfilter/x86/vf_convolution_init.c |  46 
>  5 files changed, 273 insertions(+), 38 deletions(-)
>  create mode 100644 libavfilter/convolution.h
>  create mode 100644 libavfilter/x86/vf_convolution.asm
>  create mode 100644 libavfilter/x86/vf_convolution_init.c
> 
> diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
> new file mode 100644
> index 00..fc6aad58fd
> --- /dev/null
> +++ b/libavfilter/convolution.h
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
> + * Copyright (c) 2015 Paul B Mahol
> + *
> + * 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 AVFILTER_CONVOLUTION_H
> +#define AVFILTER_CONVOLUTION_H
> +#include "avfilter.h"
> +
> +enum MatrixMode {
> +MATRIX_SQUARE,
> +MATRIX_ROW,
> +MATRIX_COLUMN,
> +MATRIX_NBMODES,
> +};
> +
> +typedef struct ConvolutionContext {
> +const AVClass *class;
> +
> +char *matrix_str[4];
> +float rdiv[4];
> +float bias[4];
> +int mode[4];
> +float scale;
> +float delta;
> +int planes;
> +
> +int size[4];
> +int depth;
> +int max;
> +int bpc;
> +int nb_planes;
> +int nb_threads;
> +int planewidth[4];
> +int planeheight[4];
> +int matrix[4][49];
> +int matrix_length[4];
> +int copy[4];
> +
> +void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
> stride,
> + int x, int width, int y, int height, int bpc);
> +void (*filter[4])(uint8_t *dst, int width,
> +  float rdiv, float bias, const int *const matrix,
> +  const uint8_t *c[], int peak, int radius,
> +  int dstride, int stride);
> +} ConvolutionContext;
> +
> +void ff_convolution_init_x86(ConvolutionContext *s);
> +#endif
> diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
> index 1305569c88..e3bf1df79f 100644
> --- a/libavfilter/vf_convolution.c
> +++ b/libavfilter/vf_convolution.c
> @@ -25,48 +25,11 @@
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
> +#include "convolution.h"
>  #include "formats.h"
>  #include "internal.h"
>  #include "video.h"
> 
> -enum MatrixMode {
> -MATRIX_SQUARE,
> -MATRIX_ROW,
> -MATRIX_COLUMN,
> -MATRIX_NBMODES,
> -};
> -
> -typedef struct ConvolutionContext {
> -const AVClass *class;
> -
> -char *matrix_str[4];
> -float rdiv[4];
> -float bias[4];
> -int mode[4];
> -float scale;
> -float delta;
> -int planes;
> -
> -int size[4];
> -int depth;
> -int max;
> -int bpc;
> -int nb_planes;
> -int nb_threads;
> -int planewidth[4];
> -int planeheight[4];
> -int matrix[4][49];
> -int matrix_length[4];
> -int copy[4];
> -
> -void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
> stride,
> - int x, int width, int y, int height, int bpc);
> -void (*filter[4])(uint8_t *dst, int width,
> -  float rdiv, float bias, const int *const matrix,
> -  const uint8_t *c[], int peak, int radius,
> -  int dstride, int stride);
> -} ConvolutionContext;
> -
>  #define OFFSET(x) offsetof(ConvolutionContext, x)
>  #define FLAGS
> AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> 
> @@ 

[FFmpeg-devel] [PATCH] avfilter/vf_convolution: add x86 SIMD for filter_3x3()

2019-07-08 Thread Ruiling Song
Tested using a simple command (apply edge enhance):
./ffmpeg_g -i ~/Downloads/bbb_sunflower_1080p_30fps_normal.mp4 \
 -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 
0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128" \
 -an -vframes 1000 -f null /dev/null

The fps increase from 151 to 270 on my local machine.

Signed-off-by: Ruiling Song 
---
 libavfilter/convolution.h |  64 +++
 libavfilter/vf_convolution.c  |  41 +--
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_convolution.asm| 158 ++
 libavfilter/x86/vf_convolution_init.c |  46 
 5 files changed, 273 insertions(+), 38 deletions(-)
 create mode 100644 libavfilter/convolution.h
 create mode 100644 libavfilter/x86/vf_convolution.asm
 create mode 100644 libavfilter/x86/vf_convolution_init.c

diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h
new file mode 100644
index 00..fc6aad58fd
--- /dev/null
+++ b/libavfilter/convolution.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
+ * Copyright (c) 2015 Paul B Mahol
+ *
+ * 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 AVFILTER_CONVOLUTION_H
+#define AVFILTER_CONVOLUTION_H
+#include "avfilter.h"
+
+enum MatrixMode {
+MATRIX_SQUARE,
+MATRIX_ROW,
+MATRIX_COLUMN,
+MATRIX_NBMODES,
+};
+
+typedef struct ConvolutionContext {
+const AVClass *class;
+
+char *matrix_str[4];
+float rdiv[4];
+float bias[4];
+int mode[4];
+float scale;
+float delta;
+int planes;
+
+int size[4];
+int depth;
+int max;
+int bpc;
+int nb_planes;
+int nb_threads;
+int planewidth[4];
+int planeheight[4];
+int matrix[4][49];
+int matrix_length[4];
+int copy[4];
+
+void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
+ int x, int width, int y, int height, int bpc);
+void (*filter[4])(uint8_t *dst, int width,
+  float rdiv, float bias, const int *const matrix,
+  const uint8_t *c[], int peak, int radius,
+  int dstride, int stride);
+} ConvolutionContext;
+
+void ff_convolution_init_x86(ConvolutionContext *s);
+#endif
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c
index 1305569c88..e3bf1df79f 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -25,48 +25,11 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
+#include "convolution.h"
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
 
-enum MatrixMode {
-MATRIX_SQUARE,
-MATRIX_ROW,
-MATRIX_COLUMN,
-MATRIX_NBMODES,
-};
-
-typedef struct ConvolutionContext {
-const AVClass *class;
-
-char *matrix_str[4];
-float rdiv[4];
-float bias[4];
-int mode[4];
-float scale;
-float delta;
-int planes;
-
-int size[4];
-int depth;
-int max;
-int bpc;
-int nb_planes;
-int nb_threads;
-int planewidth[4];
-int planeheight[4];
-int matrix[4][49];
-int matrix_length[4];
-int copy[4];
-
-void (*setup[4])(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
- int x, int width, int y, int height, int bpc);
-void (*filter[4])(uint8_t *dst, int width,
-  float rdiv, float bias, const int *const matrix,
-  const uint8_t *c[], int peak, int radius,
-  int dstride, int stride);
-} ConvolutionContext;
-
 #define OFFSET(x) offsetof(ConvolutionContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
@@ -625,6 +588,8 @@ static int config_input(AVFilterLink *inlink)
 s->filter[p] = filter16_7x7;
 }
 }
+if (ARCH_X86_64)
+ff_convolution_init_x86(s);
 } else if (!strcmp(ctx->filter->name, "prewitt")) {
 if (s->depth > 8)
 for (p = 0; p < s->nb_planes; p++)
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 6b0361bed2..8dc0b0e6d4 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -5,6 +5,7 @@