[FFmpeg-cvslog] mailmap: add entry for myself

2020-07-12 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Mon Jul 13 
09:37:37 2020 +0800| [7772666e5bfff27c4900942e7558a2d327df8f32] | committer: 
Guo, Yejun

mailmap: add entry for myself

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7772666e5bfff27c4900942e7558a2d327df8f32
---

 .mailmap | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.mailmap b/.mailmap
index f14770d800..3bd1a85c3c 100644
--- a/.mailmap
+++ b/.mailmap
@@ -21,3 +21,4 @@
 rcombs  
  
  
+ 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] swscale/swscale: remove useless code

2020-04-02 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Apr  1 
15:32:15 2020 +0800| [4700f7d6fce3ae3fcce86e069edf16b6cbae614b] | committer: 
Michael Niedermayer

swscale/swscale: remove useless code

Signed-off-by: Ruiling Song 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4700f7d6fce3ae3fcce86e069edf16b6cbae614b
---

 libswscale/swscale.c  | 16 +---
 libswscale/swscale_internal.h |  5 +
 libswscale/x86/swscale.c  |  3 +--
 3 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 8436f056d4..001cfbf15b 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -266,8 +266,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 
 /* vars which will change and which we need to store back in the context */
 int dstY = c->dstY;
-int lumBufIndex  = c->lumBufIndex;
-int chrBufIndex  = c->chrBufIndex;
 int lastInLumBuf = c->lastInLumBuf;
 int lastInChrBuf = c->lastInChrBuf;
 
@@ -336,8 +334,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
  * will not get executed. This is not really intended but works
  * currently, so people might do it. */
 if (srcSliceY == 0) {
-lumBufIndex  = -1;
-chrBufIndex  = -1;
 dstY = 0;
 lastInLumBuf = -1;
 lastInChrBuf = -1;
@@ -461,7 +457,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 desc[i].process(c, [i], firstPosY, lastPosY - firstPosY + 
1);
 }
 
-lumBufIndex += lastLumSrcY - lastInLumBuf;
 lastInLumBuf = lastLumSrcY;
 
 if (cPosY < lastChrSrcY + 1) {
@@ -469,20 +464,13 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 desc[i].process(c, [i], firstCPosY, lastCPosY - 
firstCPosY + 1);
 }
 
-chrBufIndex += lastChrSrcY - lastInChrBuf;
 lastInChrBuf = lastChrSrcY;
 
-// wrap buf index around to stay inside the ring buffer
-if (lumBufIndex >= vLumFilterSize)
-lumBufIndex -= vLumFilterSize;
-if (chrBufIndex >= vChrFilterSize)
-chrBufIndex -= vChrFilterSize;
 if (!enough_lines)
 break;  // we can't output a dstY line so let's try with the next 
slice
 
 #if HAVE_MMX_INLINE
-ff_updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex,
-  lastInLumBuf, lastInChrBuf);
+ff_updateMMXDitherTables(c, dstY);
 #endif
 if (should_dither) {
 c->chrDither8 = ff_dither_8x8_128[chrDstY & 7];
@@ -524,8 +512,6 @@ static int swscale(SwsContext *c, const uint8_t *src[],
 
 /* store changed local vars back in the context */
 c->dstY = dstY;
-c->lumBufIndex  = lumBufIndex;
-c->chrBufIndex  = chrBufIndex;
 c->lastInLumBuf = lastInLumBuf;
 c->lastInChrBuf = lastInChrBuf;
 
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index a59d12745a..9dda53eead 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -350,8 +350,6 @@ typedef struct SwsContext {
 //@{
 int lastInLumBuf; ///< Last scaled horizontal luma/alpha line 
from source in the ring buffer.
 int lastInChrBuf; ///< Last scaled horizontal chroma line 
from source in the ring buffer.
-int lumBufIndex;  ///< Index in ring buffer of the last scaled 
horizontal luma/alpha line from source.
-int chrBufIndex;  ///< Index in ring buffer of the last scaled 
horizontal chroma line from source.
 //@}
 
 uint8_t *formatConvBuffer;
@@ -635,8 +633,7 @@ int ff_yuv2rgb_c_init_tables(SwsContext *c, const int 
inv_table[4],
 void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4],
 int brightness, int contrast, int saturation);
 
-void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int 
chrBufIndex,
-   int lastInLumBuf, int lastInChrBuf);
+void ff_updateMMXDitherTables(SwsContext *c, int dstY);
 
 av_cold void ff_sws_init_range_convert(SwsContext *c);
 
diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c
index e9d474a1e8..61110839ee 100644
--- a/libswscale/x86/swscale.c
+++ b/libswscale/x86/swscale.c
@@ -79,8 +79,7 @@ DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w)= 
0x0001000100010001ULL;
 #include "swscale_template.c"
 #endif
 
-void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int 
chrBufIndex,
-   int lastInLumBuf, int lastInChrBuf)
+void ff_updateMMXDitherTables(SwsContext *c, int dstY)
 {
 const int dstH= c->dstH;
 const int flags= c->flags;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo

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

2019-08-07 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Thu Jun 27 
10:07:21 2019 +0800| [98e419cbf5443b3e95d6bc7bdb807c9f54bfd6a7] | committer: 
Ruiling Song

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 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98e419cbf5443b3e95d6bc7bdb807c9f54bfd6a7
---

 libavfilter/convolution.h |  64 ++
 libavfilter/vf_convolution.c  |  41 +
 libavfilter/x86/Makefile  |   2 +
 libavfilter/x86/vf_convolution.asm| 156 ++
 libavfilter/x86/vf_convolution_init.c |  46 ++
 5 files changed, 271 insertions(+), 38 deletions(-)

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, "prewi

[FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-11 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed May 15 
17:54:10 2019 +0800| [83f9da77684e7ea0d8e9f9712ec716424140043a] | committer: 
Ruiling Song

avfilter/vf_gblur: add x86 SIMD optimizations

The horizontal pass get ~2x performance with the patch
under single thread.

Tested overall performance using the command(avx2 enabled):
./ffmpeg -i 1080p.mp4 -vf gblur -f null /dev/null
./ffmpeg -i 1080p.mp4 -vf gblur=threads=1 -f null /dev/null
For single thread, the fps improves from 43 to 60, about 40%.
For multi-thread, the fps improves from 110 to 130, about 20%.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83f9da77684e7ea0d8e9f9712ec716424140043a
---

 libavfilter/gblur.h |  55 
 libavfilter/vf_gblur.c  |  71 +++
 libavfilter/x86/Makefile|   2 +
 libavfilter/x86/vf_gblur.asm| 185 
 libavfilter/x86/vf_gblur_init.c |  36 
 5 files changed, 310 insertions(+), 39 deletions(-)

diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h
new file mode 100644
index 00..87129801de
--- /dev/null
+++ b/libavfilter/gblur.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Pascal Getreuer
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * Redistribution and use in source and binary forms, with or without 
modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials provided
+ *with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AVFILTER_GBLUR_H
+#define AVFILTER_GBLUR_H
+#include "avfilter.h"
+
+typedef struct GBlurContext {
+const AVClass *class;
+
+float sigma;
+float sigmaV;
+int steps;
+int planes;
+
+int depth;
+int planewidth[4];
+int planeheight[4];
+float *buffer;
+float boundaryscale;
+float boundaryscaleV;
+float postscale;
+float postscaleV;
+float nu;
+float nuV;
+int nb_planes;
+void (*horiz_slice)(float *buffer, int width, int height, int steps, float 
nu, float bscale);
+} GBlurContext;
+void ff_gblur_init(GBlurContext *s);
+void ff_gblur_init_x86(GBlurContext *s);
+#endif
diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index b91a8c074a..e71b33da80 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -30,30 +30,10 @@
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
+#include "gblur.h"
 #include "internal.h"
 #include "video.h"
 
-typedef struct GBlurContext {
-const AVClass *class;
-
-float sigma;
-float sigmaV;
-int steps;
-int planes;
-
-int depth;
-int planewidth[4];
-int planeheight[4];
-float *buffer;
-float boundaryscale;
-float boundaryscaleV;
-float postscale;
-float postscaleV;
-float nu;
-float nuV;
-int nb_planes;
-} GBlurContext;
-
 #define OFFSET(x) offsetof(GBlurContext, x)
 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
@@ -72,39 +52,44 @@ typedef struct ThreadData {
 int width;
 } ThreadData;
 
-static int filter_horizontally(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+static void horiz_slice_c(float *buffer, int width, int height, int steps,
+  float nu, float bscale)
 {
-GBlurContext *s = ctx->priv;
-ThreadData *td = arg;
-const int height = td->height;
-const int width = td->width;
-const int slice_start = (height *  jobnr   ) / nb_jobs;
-const int slice_end   = (height * (jobnr+1)) / nb_jobs;
-const float boundaryscale = s->boundaryscale;
-const int steps = s->steps;
-const float nu = s->nu;
-float *buffer = s->buffer;
-int y, x, step;
+int step, x, y;
 float *ptr;
-
-/* Filter horizontally along each row */
-for (y = slice_sta

[FFmpeg-cvslog] checkasm/vf_gblur: add test for horiz_slice simd

2019-06-11 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jun  4 
16:34:08 2019 +0800| [8f4963ad25ac6c71c126ac90c240b1f88ebf0312] | committer: 
Ruiling Song

checkasm/vf_gblur: add test for horiz_slice simd

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f4963ad25ac6c71c126ac90c240b1f88ebf0312
---

 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 +++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/vf_gblur.c | 66 +++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 72 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 886ae33167..f5780eedb2 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -35,6 +35,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC)  += $(AVCODECOBJS-yes)
 AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
 AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
 AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
+AVFILTEROBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o
 AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index bf51e00eab..3e2ec377be 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -162,6 +162,9 @@ static const struct {
 #if CONFIG_COLORSPACE_FILTER
 { "vf_colorspace", checkasm_check_colorspace },
 #endif
+#if CONFIG_GBLUR_FILTER
+{ "vf_gblur", checkasm_check_vf_gblur },
+#endif
 #if CONFIG_HFLIP_FILTER
 { "vf_hflip", checkasm_check_vf_hflip },
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 9b8d2f5419..aed15b5fa4 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -71,6 +71,7 @@ void checkasm_check_sw_rgb(void);
 void checkasm_check_utvideodsp(void);
 void checkasm_check_v210dec(void);
 void checkasm_check_v210enc(void);
+void checkasm_check_vf_gblur(void);
 void checkasm_check_vf_hflip(void);
 void checkasm_check_vf_threshold(void);
 void checkasm_check_vp8dsp(void);
diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c
new file mode 100644
index 00..1d63fc22a0
--- /dev/null
+++ b/tests/checkasm/vf_gblur.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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.
+ */
+
+#include 
+#include "checkasm.h"
+#include "libavfilter/gblur.h"
+
+#define WIDTH 256
+#define HEIGHT 256
+#define PIXELS (WIDTH * HEIGHT)
+#define BUF_SIZE (PIXELS * 4)
+
+#define randomize_buffers(buf, size) \
+do { \
+int j;   \
+float *tmp_buf = (float *)buf;   \
+for (j = 0; j < size; j++)   \
+tmp_buf[j] = (float)(rnd() & 0xFF); \
+} while (0)
+
+void checkasm_check_vf_gblur(void)
+{
+float *dst_ref = av_malloc(BUF_SIZE);
+float *dst_new = av_malloc(BUF_SIZE);
+int w = WIDTH;
+int h = HEIGHT;
+int steps = 2;
+float nu = 0.101f;
+float bscale = 1.112f;
+GBlurContext s;
+
+declare_func(void, float *dst, int w, int h, int steps, float nu, float 
bscale);
+
+randomize_buffers(dst_ref, PIXELS);
+memcpy(dst_new, dst_ref, BUF_SIZE);
+
+ff_gblur_init();
+
+if (check_func(s.horiz_slice, "horiz_slice")) {
+call_ref(dst_ref, w, h, steps, nu, bscale);
+call_new(dst_new, w, h, steps, nu, bscale);
+
+if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
+fail();
+}
+bench_new(dst_new, w, h, 1, nu, bscale);
+}
+report("horiz_slice");
+av_freep(_ref);
+av_freep(_new);
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index c453273cd0..618bde509f 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -27,6 +27,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp
  \
 fate-checkasm-v210enc   \
 fate-checkasm-vf_blend  \
 fate-che

[FFmpeg-cvslog] avfilter/vf_unsharp: enable slice threading

2019-06-02 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue May  7 
09:46:33 2019 +0800| [94ceeba9f991ab69b192fa8527be0965de7e254b] | committer: 
Ruiling Song

avfilter/vf_unsharp: enable slice threading

benchmarking with a simple command:
ffmpeg -i 1080p.mp4 -vf unsharp=la=3:ca=3 -an -f null /dev/null
with the patch, the fps increase from 50 to 120 on my local machine (i7-6770HQ).

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=94ceeba9f991ab69b192fa8527be0965de7e254b
---

 libavfilter/unsharp.h|   4 +-
 libavfilter/vf_unsharp.c | 102 ---
 2 files changed, 81 insertions(+), 25 deletions(-)

diff --git a/libavfilter/unsharp.h b/libavfilter/unsharp.h
index caff986fc1..a60b30f31a 100644
--- a/libavfilter/unsharp.h
+++ b/libavfilter/unsharp.h
@@ -37,7 +37,8 @@ typedef struct UnsharpFilterParam {
 int steps_y; ///< vertical step count
 int scalebits;   ///< bits to shift pixel
 int32_t halfscale;   ///< amount to add to pixel
-uint32_t *sc[MAX_MATRIX_SIZE - 1];   ///< finite state machine storage
+uint32_t *sr;///< finite state machine storage within a row
+uint32_t **sc;   ///< finite state machine storage across rows
 } UnsharpFilterParam;
 
 typedef struct UnsharpContext {
@@ -47,6 +48,7 @@ typedef struct UnsharpContext {
 UnsharpFilterParam luma;   ///< luma parameters (width, height, amount)
 UnsharpFilterParam chroma; ///< chroma parameters (width, height, amount)
 int hsub, vsub;
+int nb_threads;
 int opencl;
 int (* apply_unsharp)(AVFilterContext *ctx, AVFrame *in, AVFrame *out);
 } UnsharpContext;
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index 41ccc56942..af05833a5d 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -47,15 +47,22 @@
 #include "libavutil/pixdesc.h"
 #include "unsharp.h"
 
-static void apply_unsharp(  uint8_t *dst, int dst_stride,
-  const uint8_t *src, int src_stride,
-  int width, int height, UnsharpFilterParam *fp)
+typedef struct TheadData {
+UnsharpFilterParam *fp;
+uint8_t   *dst;
+const uint8_t *src;
+int dst_stride;
+int src_stride;
+int width;
+int height;
+} ThreadData;
+
+static int unsharp_slice(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
+ThreadData *td = arg;
+UnsharpFilterParam *fp = td->fp;
 uint32_t **sc = fp->sc;
-uint32_t sr[MAX_MATRIX_SIZE - 1], tmp1, tmp2;
-
-int32_t res;
-int x, y, z;
+uint32_t *sr = fp->sr;
 const uint8_t *src2 = NULL;  //silence a warning
 const int amount = fp->amount;
 const int steps_x = fp->steps_x;
@@ -63,30 +70,54 @@ static void apply_unsharp(  uint8_t *dst, int 
dst_stride,
 const int scalebits = fp->scalebits;
 const int32_t halfscale = fp->halfscale;
 
+uint8_t *dst = td->dst;
+const uint8_t *src = td->src;
+const int dst_stride = td->dst_stride;
+const int src_stride = td->src_stride;
+const int width = td->width;
+const int height = td->height;
+const int sc_offset = jobnr * 2 * steps_y;
+const int sr_offset = jobnr * (MAX_MATRIX_SIZE - 1);
+const int slice_start = (height * jobnr) / nb_jobs;
+const int slice_end = (height * (jobnr+1)) / nb_jobs;
+
+int32_t res;
+int x, y, z;
+uint32_t tmp1, tmp2;
+
 if (!amount) {
-av_image_copy_plane(dst, dst_stride, src, src_stride, width, height);
-return;
+av_image_copy_plane(dst + slice_start * dst_stride, dst_stride,
+src + slice_start * src_stride, src_stride,
+width, slice_end - slice_start);
+return 0;
 }
 
 for (y = 0; y < 2 * steps_y; y++)
-memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * steps_x));
+memset(sc[sc_offset + y], 0, sizeof(sc[y][0]) * (width + 2 * steps_x));
 
-for (y = -steps_y; y < height + steps_y; y++) {
+// if this is not the first tile, we start from (slice_start - steps_y),
+// so we can get smooth result at slice boundary
+if (slice_start > steps_y) {
+src += (slice_start - steps_y) * src_stride;
+dst += (slice_start - steps_y) * dst_stride;
+}
+
+for (y = -steps_y + slice_start; y < steps_y + slice_end; y++) {
 if (y < height)
 src2 = src;
 
-memset(sr, 0, sizeof(sr[0]) * (2 * steps_x - 1));
+memset(sr + sr_offset, 0, sizeof(sr[0]) * (2 * steps_x - 1));
 for (x = -steps_x; x < width + steps_x; x++) {
 tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x];
 for (z = 0; z < steps_x * 2; z += 2) {
-tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1;
-

[FFmpeg-cvslog] lavfi/opencl: add nlmeans_opencl filter

2019-05-24 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Fri Apr 12 
16:29:03 2019 +0800| [1d74150a7dacf4912de21820ab1011b94c13eeb5] | committer: 
Ruiling Song

lavfi/opencl: add nlmeans_opencl filter

Reviewed-by: Mark Thompson 
Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d74150a7dacf4912de21820ab1011b94c13eeb5
---

 configure   |   1 +
 doc/filters.texi|   4 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/opencl/nlmeans.cl   | 115 +++
 libavfilter/opencl_source.h |   1 +
 libavfilter/version.h   |   2 +-
 libavfilter/vf_nlmeans_opencl.c | 443 
 8 files changed, 567 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 9b4305cf0d..32fc26356c 100755
--- a/configure
+++ b/configure
@@ -3470,6 +3470,7 @@ mpdecimate_filter_select="pixelutils"
 minterpolate_filter_select="scene_sad"
 mptestsrc_filter_deps="gpl"
 negate_filter_deps="lut_filter"
+nlmeans_opencl_filter_deps="opencl"
 nnedi_filter_deps="gpl"
 ocr_filter_deps="libtesseract"
 ocv_filter_deps="libopencv"
diff --git a/doc/filters.texi b/doc/filters.texi
index 163ffef13f..4fdcfe919e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19350,6 +19350,10 @@ Make every semi-green pixel in the input transparent 
with some slight blending:
 @end example
 @end itemize
 
+@section nlmeans_opencl
+
+Non-local Means denoise filter through OpenCL, this filter accepts same 
options as @ref{nlmeans}.
+
 @section overlay_opencl
 
 Overlay one video on top of another.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b9109cc0d3..9a61c25b05 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -297,6 +297,7 @@ OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o
 OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o
 OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o
 OBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o
+OBJS-$(CONFIG_NLMEANS_OPENCL_FILTER) += vf_nlmeans_opencl.o opencl.o 
opencl/nlmeans.o
 OBJS-$(CONFIG_NNEDI_FILTER)  += vf_nnedi.o
 OBJS-$(CONFIG_NOFORMAT_FILTER)   += vf_format.o
 OBJS-$(CONFIG_NOISE_FILTER)  += vf_noise.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 78ed1cf804..40534738ee 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -282,6 +282,7 @@ extern AVFilter ff_vf_mix;
 extern AVFilter ff_vf_mpdecimate;
 extern AVFilter ff_vf_negate;
 extern AVFilter ff_vf_nlmeans;
+extern AVFilter ff_vf_nlmeans_opencl;
 extern AVFilter ff_vf_nnedi;
 extern AVFilter ff_vf_noformat;
 extern AVFilter ff_vf_noise;
diff --git a/libavfilter/opencl/nlmeans.cl b/libavfilter/opencl/nlmeans.cl
new file mode 100644
index 00..72bd681fd6
--- /dev/null
+++ b/libavfilter/opencl/nlmeans.cl
@@ -0,0 +1,115 @@
+/*
+ * 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
+ */
+
+const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
+   CLK_ADDRESS_CLAMP_TO_EDGE   |
+   CLK_FILTER_NEAREST);
+
+kernel void horiz_sum(__global uint4 *integral_img,
+  __read_only image2d_t src,
+  int width,
+  int height,
+  int4 dx,
+  int4 dy)
+{
+
+int y = get_global_id(0);
+int work_size = get_global_size(0);
+
+uint4 sum = (uint4)(0);
+float4 s2;
+for (int i = 0; i < width; i++) {
+float s1 = read_imagef(src, sampler, (int2)(i, y)).x;
+s2.x = read_imagef(src, sampler, (int2)(i + dx.x, y + dy.x)).x;
+s2.y = read_imagef(src, sampler, (int2)(i + dx.y, y + dy.y)).x;
+s2.z = read_imagef(src, sampler, (int2)(i + dx.z, y + dy.z)).x;
+s2.w = read_imagef(src, sampler, (int2)(i + dx.w, y + dy.w)).x;
+sum += convert_uint4((s1 - s2) * (s1 - s2) * 255 * 255);
+integral_img[y * width + i] = sum;
+}
+}
+
+kernel void vert_sum(__global uint4 *integral_img,
+ __global int *overflow,
+ int width,

[FFmpeg-cvslog] avutil/tx: should check against (*ctx)

2019-05-16 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Thu May 16 
12:47:36 2019 +0800| [65646db8e8d5aa95ef8282823fdf5ec1a5f3df69] | committer: 
James Almer

avutil/tx: should check against (*ctx)

ctx is a pointer to pointer here.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=65646db8e8d5aa95ef8282823fdf5ec1a5f3df69
---

 libavutil/tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index a138c67bdc..93f6e489d3 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -697,7 +697,7 @@ static int gen_mdct_exptab(AVTXContext *s, int len4, double 
scale)
 
 av_cold void av_tx_uninit(AVTXContext **ctx)
 {
-if (!ctx)
+if (!(*ctx))
 return;
 
 av_free((*ctx)->pfatab);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavfi/gblur: doing several columns at the same time

2019-05-07 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Mon May  6 
11:48:31 2019 +0800| [06ba4783a0ba331153b71993bc1908958d483c2d] | committer: 
Ruiling Song

lavfi/gblur: doing several columns at the same time

Instead of doing each column one by one, doing several columns
together gives about 30% better performance.

Reviewed-by: Paul B Mahol 
Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=06ba4783a0ba331153b71993bc1908958d483c2d
---

 libavfilter/vf_gblur.c | 62 ++
 1 file changed, 42 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_gblur.c b/libavfilter/vf_gblur.c
index f77a3fffc3..b91a8c074a 100644
--- a/libavfilter/vf_gblur.c
+++ b/libavfilter/vf_gblur.c
@@ -108,6 +108,40 @@ static int filter_horizontally(AVFilterContext *ctx, void 
*arg, int jobnr, int n
 return 0;
 }
 
+static void do_vertical_columns(float *buffer, int width, int height,
+int column_begin, int column_end, int steps,
+float nu, float boundaryscale, int column_step)
+{
+const int numpixels = width * height;
+int i, x, k, step;
+float *ptr;
+for (x = column_begin; x < column_end;) {
+for (step = 0; step < steps; step++) {
+ptr = buffer + x;
+for (k = 0; k < column_step; k++) {
+ptr[k] *= boundaryscale;
+}
+/* Filter downwards */
+for (i = width; i < numpixels; i += width) {
+for (k = 0; k < column_step; k++) {
+ptr[i + k] += nu * ptr[i - width + k];
+}
+}
+i = numpixels - width;
+
+for (k = 0; k < column_step; k++)
+ptr[i + k] *= boundaryscale;
+
+/* Filter upwards */
+for (; i > 0; i -= width) {
+for (k = 0; k < column_step; k++)
+ptr[i - width + k] += nu * ptr[i + k];
+}
+}
+x += column_step;
+}
+}
+
 static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
 GBlurContext *s = ctx->priv;
@@ -117,31 +151,19 @@ static int filter_vertically(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_
 const int slice_start = (width *  jobnr   ) / nb_jobs;
 const int slice_end   = (width * (jobnr+1)) / nb_jobs;
 const float boundaryscale = s->boundaryscaleV;
-const int numpixels = width * height;
 const int steps = s->steps;
 const float nu = s->nuV;
 float *buffer = s->buffer;
-int i, x, step;
-float *ptr;
-
-/* Filter vertically along each column */
-for (x = slice_start; x < slice_end; x++) {
-for (step = 0; step < steps; step++) {
-ptr = buffer + x;
-ptr[0] *= boundaryscale;
-
-/* Filter downwards */
-for (i = width; i < numpixels; i += width)
-ptr[i] += nu * ptr[i - width];
-
-ptr[i = numpixels - width] *= boundaryscale;
+int aligned_end;
 
-/* Filter upwards */
-for (; i > 0; i -= width)
-ptr[i - width] += nu * ptr[i];
-}
-}
+aligned_end = slice_start + (((slice_end - slice_start) >> 3) << 3);
+/* Filter vertically along columns (process 8 columns in each step) */
+do_vertical_columns(buffer, width, height, slice_start, aligned_end,
+steps, nu, boundaryscale, 8);
 
+/* Filter un-aligned columns one by one */
+do_vertical_columns(buffer, width, height, aligned_end, slice_end,
+steps, nu, boundaryscale, 1);
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavfi/opencl: add more opencl helper macro

2019-04-25 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Fri Apr 12 
16:27:54 2019 +0800| [0fc464631aafa2741e97ce00fc8f81378fcf441a] | committer: 
Ruiling Song

lavfi/opencl: add more opencl helper macro

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0fc464631aafa2741e97ce00fc8f81378fcf441a
---

 libavfilter/opencl.h | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 0b06232ade..973b6d82dd 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -73,6 +73,44 @@ typedef struct OpenCLFilterContext {
 goto fail; \
 }  \
 } while(0)
+/**
+  * release an OpenCL Kernel
+  */
+#define CL_RELEASE_KERNEL(k)  \
+do {  \
+if (k) {  \
+cle = clReleaseKernel(k); \
+if (cle != CL_SUCCESS)\
+av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+   "OpenCL kernel: %d.\n", cle);  \
+} \
+} while(0)
+
+/**
+  * release an OpenCL Memory Object
+  */
+#define CL_RELEASE_MEMORY(m)  \
+do {  \
+if (m) {  \
+cle = clReleaseMemObject(m);  \
+if (cle != CL_SUCCESS)\
+av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+   "OpenCL memory: %d.\n", cle);  \
+} \
+} while(0)
+
+/**
+  * release an OpenCL Command Queue
+  */
+#define CL_RELEASE_QUEUE(q)   \
+do {  \
+if (q) {  \
+cle = clReleaseCommandQueue(q);   \
+if (cle != CL_SUCCESS)\
+av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+   "OpenCL command queue: %d.\n", cle);   \
+} \
+} while(0)
 
 /**
  * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavfi/colorspace: move some functions to common file

2019-03-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jan 22 
14:27:01 2019 +0800| [d0f3798b4e7f9ec3142f74946f7de41b9e3485cb] | committer: 
Ruiling Song

lavfi/colorspace: move some functions to common file

These functions can be reused by other colorspace filters,
so move them to common file. No functional changes.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d0f3798b4e7f9ec3142f74946f7de41b9e3485cb
---

 libavfilter/colorspace.c| 71 
 libavfilter/colorspace.h|  4 +++
 libavfilter/vf_colorspace.c | 80 +++--
 3 files changed, 79 insertions(+), 76 deletions(-)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index c6682216d6..19616e4f12 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -93,6 +93,77 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
 rgb2xyz[2][1] *= sg;
 rgb2xyz[2][2] *= sb;
 }
+static const double ycgco_matrix[3][3] =
+{
+{  0.25, 0.5,  0.25 },
+{ -0.25, 0.5, -0.25 },
+{  0.5,  0,   -0.5  },
+};
+
+static const double gbr_matrix[3][3] =
+{
+{ 0,1,   0   },
+{ 0,   -0.5, 0.5 },
+{ 0.5, -0.5, 0   },
+};
+
+/*
+ * All constants explained in e.g. 
https://linuxtv.org/downloads/v4l-dvb-apis/ch02s06.html
+ * The older ones (bt470bg/m) are also explained in their respective ITU docs
+ * (e.g. 
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.470-5-199802-S!!PDF-E.pdf)
+ * whereas the newer ones can typically be copied directly from wikipedia :)
+ */
+static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = {
+[AVCOL_SPC_FCC]= { 0.30,   0.59,   0.11   },
+[AVCOL_SPC_BT470BG]= { 0.299,  0.587,  0.114  },
+[AVCOL_SPC_SMPTE170M]  = { 0.299,  0.587,  0.114  },
+[AVCOL_SPC_BT709]  = { 0.2126, 0.7152, 0.0722 },
+[AVCOL_SPC_SMPTE240M]  = { 0.212,  0.701,  0.087  },
+[AVCOL_SPC_YCOCG]  = { 0.25,   0.5,0.25   },
+[AVCOL_SPC_RGB]= { 1,  1,  1  },
+[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
+[AVCOL_SPC_BT2020_CL]  = { 0.2627, 0.6780, 0.0593 },
+};
+
+const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp)
+{
+const struct LumaCoefficients *coeffs;
+
+if (csp >= AVCOL_SPC_NB)
+return NULL;
+coeffs = _coefficients[csp];
+if (!coeffs->cr)
+return NULL;
+
+return coeffs;
+}
+
+void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
+   double rgb2yuv[3][3])
+{
+double bscale, rscale;
+
+// special ycgco matrix
+if (coeffs->cr == 0.25 && coeffs->cg == 0.5 && coeffs->cb == 0.25) {
+memcpy(rgb2yuv, ycgco_matrix, sizeof(double) * 9);
+return;
+} else if (coeffs->cr == 1 && coeffs->cg == 1 && coeffs->cb == 1) {
+memcpy(rgb2yuv, gbr_matrix, sizeof(double) * 9);
+return;
+}
+
+rgb2yuv[0][0] = coeffs->cr;
+rgb2yuv[0][1] = coeffs->cg;
+rgb2yuv[0][2] = coeffs->cb;
+bscale = 0.5 / (coeffs->cb - 1.0);
+rscale = 0.5 / (coeffs->cr - 1.0);
+rgb2yuv[1][0] = bscale * coeffs->cr;
+rgb2yuv[1][1] = bscale * coeffs->cg;
+rgb2yuv[1][2] = 0.5;
+rgb2yuv[2][0] = 0.5;
+rgb2yuv[2][1] = rscale * coeffs->cg;
+rgb2yuv[2][2] = rscale * coeffs->cb;
+}
 
 double ff_determine_signal_peak(AVFrame *in)
 {
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index 936681815a..459a5df60d 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -44,6 +44,10 @@ void ff_fill_rgb2xyz_table(const struct PrimaryCoefficients 
*coeffs,
const struct WhitepointCoefficients *wp,
double rgb2xyz[3][3]);
 
+const struct LumaCoefficients *ff_get_luma_coefficients(enum AVColorSpace csp);
+void ff_fill_rgb2yuv_table(const struct LumaCoefficients *coeffs,
+   double rgb2yuv[3][3]);
+
 double ff_determine_signal_peak(AVFrame *in);
 void ff_update_hdr_metadata(AVFrame *in, double peak);
 
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index f8d1ecdf4a..2120199bee 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -170,78 +170,6 @@ typedef struct ColorSpaceContext {
 // FIXME dithering if bitdepth goes down?
 // FIXME bitexact for fate integration?
 
-static const double ycgco_matrix[3][3] =
-{
-{  0.25, 0.5,  0.25 },
-{ -0.25, 0.5, -0.25 },
-{  0.5,  0,   -0.5  },
-};
-
-static const double gbr_matrix[3][3] =
-{
-{ 0,1,   0   },
-{ 0,   -0.5, 0.5 },
-{ 0.5, -0.5, 0   },
-};
-
-/*
- * All constants explained in e.g. 
https://linuxtv.org/downloads/v4l-dvb-apis/ch02s06.html
- * The older ones (bt470bg/m) are also explained in their respective ITU docs
- * (e.g. 
https://www.itu.int/dms_

[FFmpeg-cvslog] lavfi/colorspace_common: add ifdef check to be more compatible.

2019-03-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Mon Jan 21 
15:44:04 2019 +0800| [b073fb9eeae8f021a4e18886ccf73cda9f67b00c] | committer: 
Ruiling Song

lavfi/colorspace_common: add ifdef check to be more compatible.

Some filters may not need to do linearize/delinearize, thus
will even not define them. Add ifdef check, so they could easily
re-use the .cl file.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b073fb9eeae8f021a4e18886ccf73cda9f67b00c
---

 libavfilter/opencl/colorspace_common.cl | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavfilter/opencl/colorspace_common.cl 
b/libavfilter/opencl/colorspace_common.cl
index 1d68a546c7..ac911f03ef 100644
--- a/libavfilter/opencl/colorspace_common.cl
+++ b/libavfilter/opencl/colorspace_common.cl
@@ -124,10 +124,14 @@ float3 yuv2rgb(float y, float u, float v) {
 
 float3 yuv2lrgb(float3 yuv) {
 float3 rgb = yuv2rgb(yuv.x, yuv.y, yuv.z);
+#ifdef linearize
 float r = linearize(rgb.x);
 float g = linearize(rgb.y);
 float b = linearize(rgb.z);
 return (float3)(r, g, b);
+#else
+return rgb;
+#endif
 }
 
 float3 rgb2yuv(float r, float g, float b) {
@@ -151,19 +155,25 @@ float rgb2y(float r, float g, float b) {
 }
 
 float3 lrgb2yuv(float3 c) {
+#ifdef delinearize
 float r = delinearize(c.x);
 float g = delinearize(c.y);
 float b = delinearize(c.z);
-
 return rgb2yuv(r, g, b);
+#else
+return rgb2yuv(c.x, c.y, c.z);
+#endif
 }
 
 float lrgb2y(float3 c) {
+#ifdef delinearize
 float r = delinearize(c.x);
 float g = delinearize(c.y);
 float b = delinearize(c.z);
-
 return rgb2y(r, g, b);
+#else
+return rgb2y(c.x, c.y, c.z);
+#endif
 }
 
 float3 lrgb2lrgb(float3 c) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavu/opencl: replace va_ext.h with standard name

2019-03-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Fri Nov 23 
13:39:12 2018 +0800| [61cb505d18b8a335bd118d88c05b9daf40eb5f9b] | committer: 
Ruiling Song

lavu/opencl: replace va_ext.h with standard name

Khronos OpenCL header (https://github.com/KhronosGroup/OpenCL-Headers)
uses cl_va_api_media_sharing_intel.h. And Intel's official OpenCL driver
for Intel GPU (https://github.com/intel/compute-runtime) was compiled
against Khronos OpenCL header. So it's better to align with Khronos.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=61cb505d18b8a335bd118d88c05b9daf40eb5f9b
---

 configure| 2 +-
 libavutil/hwcontext_opencl.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index a817479559..331393f8d5 100755
--- a/configure
+++ b/configure
@@ -6472,7 +6472,7 @@ fi
 
 if enabled_all opencl vaapi ; then
 enabled opencl_drm_beignet && enable opencl_vaapi_beignet
-check_type "CL/cl.h CL/va_ext.h" "clCreateFromVA_APIMediaSurfaceINTEL_fn" 
&&
+check_type "CL/cl.h CL/cl_va_api_media_sharing_intel.h" 
"clCreateFromVA_APIMediaSurfaceINTEL_fn" &&
 enable opencl_vaapi_intel_media
 fi
 
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index d3df6221c4..b116c5b708 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -50,7 +50,7 @@
 #include 
 #endif
 #include 
-#include 
+#include 
 #include "hwcontext_vaapi.h"
 #endif
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavfi/opencl: add ff_opencl_print_const_matrix_3x3()

2019-03-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jan 22 
14:47:54 2019 +0800| [2593122a167de3294abd5b9cf04df5b8072ee3ed] | committer: 
Ruiling Song

lavfi/opencl: add ff_opencl_print_const_matrix_3x3()

This is used to print a 3x3 matrix into a part of OpenCL
source code.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2593122a167de3294abd5b9cf04df5b8072ee3ed
---

 libavfilter/opencl.c | 13 +
 libavfilter/opencl.h |  8 
 2 files changed, 21 insertions(+)

diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index ac5eec68c6..95f0bfc604 100644
--- a/libavfilter/opencl.c
+++ b/libavfilter/opencl.c
@@ -337,3 +337,16 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext 
*avctx,
 
 return 0;
 }
+
+void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const char *name_str,
+  double mat[3][3])
+{
+int i, j;
+av_bprintf(buf, "__constant float %s[9] = {\n", name_str);
+for (i = 0; i < 3; i++) {
+for (j = 0; j < 3; j++)
+av_bprintf(buf, " %.5ff,", mat[i][j]);
+av_bprintf(buf, "\n");
+}
+av_bprintf(buf, "};\n");
+}
diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 1b7f117865..0b06232ade 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -25,6 +25,7 @@
 // it was introduced in OpenCL 2.0.
 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
 
+#include "libavutil/bprint.h"
 #include "libavutil/buffer.h"
 #include "libavutil/hwcontext.h"
 #include "libavutil/hwcontext_opencl.h"
@@ -124,5 +125,12 @@ int ff_opencl_filter_work_size_from_image(AVFilterContext 
*avctx,
   size_t *work_size,
   AVFrame *frame, int plane,
   int block_alignment);
+/**
+ * Print a 3x3 matrix into a buffer as __constant array, which could
+ * be included in an OpenCL program.
+*/
+
+void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const char *name_str,
+  double mat[3][3]);
 
 #endif /* AVFILTER_OPENCL_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

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

[FFmpeg-cvslog] lavfi/tonemap_opencl: reuse color matrix calculation from colorspace.c

2019-03-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jan 22 
15:01:56 2019 +0800| [8b951cd4752c8db2b4532fae9fb300d422950cdd] | committer: 
Ruiling Song

lavfi/tonemap_opencl: reuse color matrix calculation from colorspace.c

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b951cd4752c8db2b4532fae9fb300d422950cdd
---

 libavfilter/opencl/colorspace_common.cl | 25 -
 libavfilter/vf_tonemap_opencl.c | 64 +++--
 2 files changed, 29 insertions(+), 60 deletions(-)

diff --git a/libavfilter/opencl/colorspace_common.cl 
b/libavfilter/opencl/colorspace_common.cl
index 94a4dd0e0e..1d68a546c7 100644
--- a/libavfilter/opencl/colorspace_common.cl
+++ b/libavfilter/opencl/colorspace_common.cl
@@ -39,31 +39,6 @@ constant const float ST2084_C1 = 0.8359375f;
 constant const float ST2084_C2 = 18.8515625f;
 constant const float ST2084_C3 = 18.6875f;
 
-__constant float yuv2rgb_bt2020[] = {
-1.0f, 0.0f, 1.4746f,
-1.0f, -0.16455f, -0.57135f,
-1.0f, 1.8814f, 0.0f
-};
-
-__constant float yuv2rgb_bt709[] = {
-1.0f, 0.0f, 1.5748f,
-1.0f, -0.18732f, -0.46812f,
-1.0f, 1.8556f, 0.0f
-};
-
-__constant float rgb2yuv_bt709[] = {
-0.2126f, 0.7152f, 0.0722f,
--0.11457f, -0.38543f, 0.5f,
-0.5f, -0.45415f, -0.04585f
-};
-
-__constant float rgb2yuv_bt2020[] ={
-0.2627f, 0.678f, 0.0593f,
--0.1396f, -0.36037f, 0.5f,
-0.5f, -0.4598f, -0.0402f,
-};
-
-
 float get_luma_dst(float3 c) {
 return luma_dst.x * c.x + luma_dst.y * c.y + luma_dst.z * c.z;
 }
diff --git a/libavfilter/vf_tonemap_opencl.c b/libavfilter/vf_tonemap_opencl.c
index ae3f98d817..315ead49d4 100644
--- a/libavfilter/vf_tonemap_opencl.c
+++ b/libavfilter/vf_tonemap_opencl.c
@@ -18,7 +18,6 @@
 #include 
 
 #include "libavutil/avassert.h"
-#include "libavutil/bprint.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/mem.h"
@@ -35,7 +34,6 @@
 // TODO:
 // - separate peak-detection from tone-mapping kernel to solve
 //one-frame-delay issue.
-// - import colorspace matrix generation from vf_colorspace.c
 // - more format support
 
 #define DETECTION_FRAMES 63
@@ -73,16 +71,6 @@ typedef struct TonemapOpenCLContext {
 cl_memutil_mem;
 } TonemapOpenCLContext;
 
-static const char *yuv_coff[AVCOL_SPC_NB] = {
-[AVCOL_SPC_BT709] = "rgb2yuv_bt709",
-[AVCOL_SPC_BT2020_NCL] = "rgb2yuv_bt2020",
-};
-
-static const char *rgb_coff[AVCOL_SPC_NB] = {
-[AVCOL_SPC_BT709] = "yuv2rgb_bt709",
-[AVCOL_SPC_BT2020_NCL] = "yuv2rgb_bt2020",
-};
-
 static const char *linearize_funcs[AVCOL_TRC_NB] = {
 [AVCOL_TRC_SMPTE2084] = "eotf_st2084",
 [AVCOL_TRC_ARIB_STD_B67] = "inverse_oetf_hlg",
@@ -93,11 +81,6 @@ static const char *delinearize_funcs[AVCOL_TRC_NB] = {
 [AVCOL_TRC_BT2020_10] = "inverse_eotf_bt1886",
 };
 
-static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB] = {
-[AVCOL_SPC_BT709]  = { 0.2126, 0.7152, 0.0722 },
-[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
-};
-
 static const struct PrimaryCoefficients primaries_table[AVCOL_PRI_NB] = {
 [AVCOL_PRI_BT709]  = { 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 },
 [AVCOL_PRI_BT2020] = { 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 },
@@ -137,8 +120,8 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
 {
 TonemapOpenCLContext *ctx = avctx->priv;
 int rgb2rgb_passthrough = 1;
-double rgb2rgb[3][3];
-struct LumaCoefficients luma_src, luma_dst;
+double rgb2rgb[3][3], rgb2yuv[3][3], yuv2rgb[3][3];
+const struct LumaCoefficients *luma_src, *luma_dst;
 cl_int cle;
 int err;
 AVBPrint header;
@@ -215,27 +198,37 @@ static int tonemap_opencl_init(AVFilterContext *avctx)
 
 if (rgb2rgb_passthrough)
 av_bprintf(, "#define RGB2RGB_PASSTHROUGH\n");
-else {
-av_bprintf(, "__constant float rgb2rgb[9] = {\n");
-av_bprintf(, "%.4ff, %.4ff, %.4ff,\n",
-   rgb2rgb[0][0], rgb2rgb[0][1], rgb2rgb[0][2]);
-av_bprintf(, "%.4ff, %.4ff, %.4ff,\n",
-   rgb2rgb[1][0], rgb2rgb[1][1], rgb2rgb[1][2]);
-av_bprintf(, "%.4ff, %.4ff, %.4ff};\n",
-   rgb2rgb[2][0], rgb2rgb[2][1], rgb2rgb[2][2]);
+else
+ff_opencl_print_const_matrix_3x3(, "rgb2rgb", rgb2rgb);
+
+
+luma_src = ff_get_luma_coefficients(ctx->colorspace_in);
+if (!luma_src) {
+err = AVERROR(EINVAL);
+av_log(avctx, AV_LOG_ERROR, "unsupported input colorspace %d (%s)\n",
+   ctx->colorspace_in, av_color_space_name(ctx->colorspace_in));
+goto fail;
 }
 
-av_bprintf(, "#define rgb_matrix %s\n",
-   rgb_coff[ctx->colorspace_in]);
-av_bprin

[FFmpeg-cvslog] MAINTAINERS: add myself for tonemap_opencl

2019-02-20 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Feb 13 
09:29:10 2019 +0800| [dfde416ea8d0ce9c11cb450211b4569b8217cfb3] | committer: 
Michael Niedermayer

MAINTAINERS: add myself for tonemap_opencl

Signed-off-by: Ruiling Song 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dfde416ea8d0ce9c11cb450211b4569b8217cfb3
---

 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7ac2d22d6e..412a739c37 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -362,6 +362,7 @@ Filters:
   vf_ssim.c Paul B Mahol
   vf_stereo3d.c Paul B Mahol
   vf_telecine.c Paul B Mahol
+  vf_tonemap_opencl.c   Ruiling Song
   vf_yadif.cMichael Niedermayer
   vf_zoompan.c  Paul B Mahol
 

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


[FFmpeg-cvslog] lavf: add transpose_opencl filter

2018-12-02 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Nov 28 
10:27:38 2018 +0800| [416dc9a5e81729e3313bcc13aebc5faa082c63a3] | committer: 
Mark Thompson

lavf: add transpose_opencl filter

Signed-off-by: Ruiling Song 
Signed-off-by: Mark Thompson 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=416dc9a5e81729e3313bcc13aebc5faa082c63a3
---

 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/opencl/transpose.cl   |  35 +
 libavfilter/opencl_source.h   |   1 +
 libavfilter/transpose.h   |  34 +
 libavfilter/vf_transpose.c|  14 +-
 libavfilter/vf_transpose_opencl.c | 288 ++
 8 files changed, 362 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index ed77b4ee81..1870b4d189 100755
--- a/configure
+++ b/configure
@@ -3480,6 +3480,7 @@ tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
 tonemap_opencl_filter_deps="opencl const_nan"
+transpose_opencl_filter_deps="opencl"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1895fa2b0d..6e2658186d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -393,6 +393,7 @@ OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += 
vf_tonemap_opencl.o colorspace.o
 OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
 OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o cuda_check.o
+OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   += vf_transpose_opencl.o opencl.o 
opencl/transpose.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
 OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 837c99eb75..a600069500 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -372,6 +372,7 @@ extern AVFilter ff_vf_tonemap_opencl;
 extern AVFilter ff_vf_tpad;
 extern AVFilter ff_vf_transpose;
 extern AVFilter ff_vf_transpose_npp;
+extern AVFilter ff_vf_transpose_opencl;
 extern AVFilter ff_vf_trim;
 extern AVFilter ff_vf_unpremultiply;
 extern AVFilter ff_vf_unsharp;
diff --git a/libavfilter/opencl/transpose.cl b/libavfilter/opencl/transpose.cl
new file mode 100644
index 00..e6388aba8f
--- /dev/null
+++ b/libavfilter/opencl/transpose.cl
@@ -0,0 +1,35 @@
+/*
+ * 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
+ */
+kernel void transpose(__write_only image2d_t dst,
+  __read_only image2d_t src,
+  int dir) {
+const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
+   CLK_ADDRESS_CLAMP_TO_EDGE   |
+   CLK_FILTER_NEAREST);
+
+int2 size = get_image_dim(dst);
+int x = get_global_id(0);
+int y = get_global_id(1);
+
+int xin = (dir & 2) ? (size.y - 1 - y) : y;
+int yin = (dir & 1) ? (size.x - 1 - x) : x;
+float4 data = read_imagef(src, sampler, (int2)(xin, yin));
+
+if (x < size.x && y < size.y)
+write_imagef(dst, (int2)(x, y), data);
+}
diff --git a/libavfilter/opencl_source.h b/libavfilter/opencl_source.h
index 2f67d890b3..4118138c30 100644
--- a/libavfilter/opencl_source.h
+++ b/libavfilter/opencl_source.h
@@ -25,6 +25,7 @@ extern const char *ff_opencl_source_convolution;
 extern const char *ff_opencl_source_neighbor;
 extern const char *ff_opencl_source_overlay;
 extern const char *ff_opencl_source_tonemap;
+extern const char *ff_opencl_source_transpose;
 extern const char *ff_opencl_source_unsharp;
 
 #endif /* AVFILTER_OPENCL_SOURCE_H */
diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
new file mode 100644
index 00..d4bb4da1ae
--- /dev/null
+++ b/libavfilter/transpose.h
@@ -0,0 +1,34 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it 

[FFmpeg-cvslog] doc/filters: add document for opencl filters

2018-11-05 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Mon Oct 29 
13:17:59 2018 +0800| [952a299fd390ca59267c30097ce2148ca730cc17] | committer: 
Lou Logan

doc/filters: add document for opencl filters

Signed-off-by: Danil Iashchenko 
Signed-off-by: Ruiling Song 
Signed-off-by: Gyan Doshi 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=952a299fd390ca59267c30097ce2148ca730cc17
---

 doc/filters.texi | 486 +++
 1 file changed, 486 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index e1798a53ef..902666c9d0 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10607,6 +10607,7 @@ A floating point number which specifies chroma temporal 
strength. It defaults to
 @var{luma_tmp}*@var{chroma_spatial}/@var{luma_spatial}.
 @end table
 
+@anchor{hwdownload}
 @section hwdownload
 
 Download hardware frames to system memory.
@@ -10697,6 +10698,7 @@ ways if there are any additional constraints on that 
filter's output.
 Do not use it without fully understanding the implications of its use.
 @end table
 
+@anchor{hwupload}
 @section hwupload
 
 Upload system memory frames to hardware surfaces.
@@ -18459,6 +18461,490 @@ pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} 
is 1.
 
 @c man end VIDEO FILTERS
 
+@chapter OpenCL Video Filters
+@c man begin OPENCL VIDEO FILTERS
+
+Below is a description of the currently available OpenCL video filters.
+
+To enable compilation of these filters you need to configure FFmpeg with
+@code{--enable-opencl}.
+
+Running OpenCL filters requires you to initialize a hardware device and to 
pass that device to all filters in any filter graph.
+@table @option
+
+@item -init_hw_device opencl[=@var{name}][:@var{device}[,@var{key=value}...]]
+Initialise a new hardware device of type @var{opencl} called @var{name}, using 
the
+given device parameters.
+
+@item -filter_hw_device @var{name}
+Pass the hardware device called @var{name} to all filters in any filter graph.
+
+@end table
+
+For more detailed information see 
@url{https://www.ffmpeg.org/ffmpeg.html#Advanced-Video-options}
+
+@itemize
+@item
+Example of choosing the first device on the second platform and running 
avgblur_opencl filter with default parameters on it.
+@example
+-init_hw_device opencl=gpu:1.0 -filter_hw_device gpu -i INPUT -vf "hwupload, 
avgblur_opencl, hwdownload" OUTPUT
+@end example
+@end itemize
+
+Since OpenCL filters are not able to access frame data in normal memory, all 
frame data needs to be uploaded(@ref{hwupload}) to hardware surfaces connected 
to the appropriate device before being used and then 
downloaded(@ref{hwdownload}) back to normal memory. Note that @ref{hwupload} 
will upload to a surface with the same layout as the software frame, so it may 
be necessary to add a @ref{format} filter immediately before to get the input 
into the right format and @ref{hwdownload} does not support all formats on the 
output - it may be necessary to insert an additional @ref{format} filter 
immediately following in the graph to get the output in a supported format.
+
+@section avgblur_opencl
+
+Apply average blur filter.
+
+The filter accepts the following options:
+
+@table @option
+@item sizeX
+Set horizontal radius size.
+Range is @code{[1, 1024]} and default value is @code{1}.
+
+@item planes
+Set which planes to filter. Default value is @code{0xf}, by which all planes 
are processed.
+
+@item sizeY
+Set vertical radius size. Range is @code{[1, 1024]} and default value is 
@code{0}. If zero, @code{sizeX} value will be used.
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Apply average blur filter with horizontal and vertical size of 3, setting each 
pixel of the output to the average value of the 7x7 region centered on it in 
the input. For pixels on the edges of the image, the region does not extend 
beyond the image boundaries, and so out-of-range coordinates are not used in 
the calculations.
+@example
+-i INPUT -vf "hwupload, avgblur_opencl=3, hwdownload" OUTPUT
+@end example
+@end itemize
+
+@section boxblur_opencl
+
+Apply a boxblur algorithm to the input video.
+
+It accepts the following parameters:
+
+@table @option
+
+@item luma_radius, lr
+@item luma_power, lp
+@item chroma_radius, cr
+@item chroma_power, cp
+@item alpha_radius, ar
+@item alpha_power, ap
+
+@end table
+
+A description of the accepted options follows.
+
+@table @option
+@item luma_radius, lr
+@item chroma_radius, cr
+@item alpha_radius, ar
+Set an expression for the box radius in pixels used for blurring the
+corresponding input plane.
+
+The radius value must be a non-negative number, and must not be
+greater than the value of the expression @code{min(w,h)/2} for the
+luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma
+planes.
+
+Default value for @option{luma_radius} is "2". If not specified,
+@option{chroma_radius} and @option{alpha_radius} default to the
+corresponding value set for @option{l

[FFmpeg-cvslog] doc/filters: add tonemap_opencl document.

2018-11-05 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Mon Oct 29 
13:56:59 2018 +0800| [a587454fd07c831a6c315ae2daf1d8f66396d967] | committer: 
Lou Logan

doc/filters: add tonemap_opencl document.

Signed-off-by: Ruiling Song 
Signed-off-by: Gyan Doshi 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a587454fd07c831a6c315ae2daf1d8f66396d967
---

 doc/filters.texi | 96 
 1 file changed, 96 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 902666c9d0..223940c721 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16650,6 +16650,7 @@ tmix=frames=3:weights="-1 2 -1":scale=1
 @end example
 @end itemize
 
+@anchor{tonemap}
 @section tonemap
 Tone map colors from different dynamic ranges.
 
@@ -18885,6 +18886,101 @@ Apply sobel operator with scale set to 2 and delta 
set to 10
 @end example
 @end itemize
 
+@section tonemap_opencl
+
+Perform HDR(PQ/HLG) to SDR conversion with tone-mapping.
+
+It accepts the following parameters:
+
+@table @option
+@item tonemap
+Specify the tone-mapping operator to be used. Same as tonemap option in 
@ref{tonemap}.
+
+@item param
+Tune the tone mapping algorithm. same as param option in @ref{tonemap}.
+
+@item desat
+Apply desaturation for highlights that exceed this level of brightness. The
+higher the parameter, the more color information will be preserved. This
+setting helps prevent unnaturally blown-out colors for super-highlights, by
+(smoothly) turning into white instead. This makes images feel more natural,
+at the cost of reducing information about out-of-range colors.
+
+The default value is 0.5, and the algorithm here is a little different from
+the cpu version tonemap currently. A setting of 0.0 disables this option.
+
+@item threshold
+The tonemapping algorithm parameters is fine-tuned per each scene. And a 
threshold
+is used to detect whether the scene has changed or not. If the distance beween
+the current frame average brightness and the current running average exceeds
+a threshold value, we would re-calculate scene average and peak brightness.
+The default value is 0.2.
+
+@item format
+Specify the output pixel format.
+
+Currently supported formats are:
+@table @var
+@item p010
+@item nv12
+@end table
+
+@item range, r
+Set the output color range.
+
+Possible values are:
+@table @var
+@item tv/mpeg
+@item pc/jpeg
+@end table
+
+Default is same as input.
+
+@item primaries, p
+Set the output color primaries.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@item transfer, t
+Set the output transfer characteristics.
+
+Possible values are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is bt709.
+
+@item matrix, m
+Set the output colorspace matrix.
+
+Possible value are:
+@table @var
+@item bt709
+@item bt2020
+@end table
+
+Default is same as input.
+
+@end table
+
+@subsection Example
+
+@itemize
+@item
+Convert HDR(PQ/HLG) video to bt2020-transfer-characteristic p010 format using 
linear operator.
+@example
+-i INPUT -vf 
"format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010"
 OUTPUT
+@end example
+@end itemize
+
 @section unsharp_opencl
 
 Sharpen or blur the input video.

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


[FFmpeg-cvslog] lavfi/opencl: add macro for opencl error handling.

2018-07-11 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Jul  4 
02:16:24 2018 +0800| [48a1abed133d005aa4d7f49e4fdd5bef9aa263f5] | committer: 
Mark Thompson

lavfi/opencl: add macro for opencl error handling.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48a1abed133d005aa4d7f49e4fdd5bef9aa263f5
---

 libavfilter/opencl.h| 12 ++
 libavfilter/vf_avgblur_opencl.c | 45 +--
 libavfilter/vf_overlay_opencl.c | 29 +--
 libavfilter/vf_program_opencl.c | 14 ++-
 libavfilter/vf_tonemap_opencl.c | 33 +-
 libavfilter/vf_unsharp_opencl.c | 52 +
 6 files changed, 48 insertions(+), 137 deletions(-)

diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 7441b11614..1b7f117865 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -62,6 +62,18 @@ typedef struct OpenCLFilterContext {
 }
 
 /**
+ * A helper macro to handle OpenCL errors. It will assign errcode to
+ * variable err, log error msg, and jump to fail label on error.
+ */
+#define CL_FAIL_ON_ERROR(errcode, ...) do {\
+if (cle != CL_SUCCESS) {   \
+av_log(avctx, AV_LOG_ERROR, __VA_ARGS__);  \
+err = errcode; \
+goto fail; \
+}  \
+} while(0)
+
+/**
  * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
  */
 int ff_opencl_filter_query_formats(AVFilterContext *avctx);
diff --git a/libavfilter/vf_avgblur_opencl.c b/libavfilter/vf_avgblur_opencl.c
index d1d3eb1983..bc6bcab682 100644
--- a/libavfilter/vf_avgblur_opencl.c
+++ b/libavfilter/vf_avgblur_opencl.c
@@ -64,26 +64,16 @@ static int avgblur_opencl_init(AVFilterContext *avctx)
 ctx->command_queue = clCreateCommandQueue(ctx->ocf.hwctx->context,
   ctx->ocf.hwctx->device_id,
   0, );
-if (!ctx->command_queue) {
-av_log(avctx, AV_LOG_ERROR, "Failed to create OpenCL "
-   "command queue: %d.\n", cle);
-err = AVERROR(EIO);
-goto fail;
-}
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create OpenCL "
+ "command queue %d.\n", cle);
 
 ctx->kernel_horiz = clCreateKernel(ctx->ocf.program,"avgblur_horiz", );
-if (!ctx->kernel_horiz) {
-av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle);
-err = AVERROR(EIO);
-goto fail;
-}
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create horizontal "
+ "kernel %d.\n", cle);
 
 ctx->kernel_vert = clCreateKernel(ctx->ocf.program,"avgblur_vert", );
-if (!ctx->kernel_vert) {
-av_log(avctx, AV_LOG_ERROR, "Failed to create kernel: %d.\n", cle);
-err = AVERROR(EIO);
-goto fail;
-}
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create vertical "
+ "kernel %d.\n", cle);
 
 ctx->initialised = 1;
 return 0;
@@ -236,12 +226,8 @@ static int avgblur_opencl_filter_frame(AVFilterLink 
*inlink, AVFrame *input)
 cle = clEnqueueNDRangeKernel(ctx->command_queue, 
ctx->kernel_horiz, 2, NULL,
  global_work, NULL,
  0, NULL, NULL);
-if (cle != CL_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n",
-   cle);
-err = AVERROR(EIO);
-goto fail;
-}
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue horizontal "
+ "kernel: %d.\n", cle);
 cle = clFinish(ctx->command_queue);
 
 err = ff_opencl_filter_work_size_from_image(avctx, global_work,
@@ -259,22 +245,13 @@ static int avgblur_opencl_filter_frame(AVFilterLink 
*inlink, AVFrame *input)
 cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel_vert, 
2, NULL,
  global_work, NULL,
  0, NULL, NULL);
-if (cle != CL_SUCCESS) {
-av_log(avctx, AV_LOG_ERROR, "Failed to enqueue kernel: %d.\n",
-   cle);
-err = AVERROR(EIO);
-goto fail;
-}
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue vertical "
+ "kernel: %d.\n", cle);
 }
 }
 
 cle = clFinish(ctx->command_queue);
-if (cle != CL_SUCCESS)

[FFmpeg-cvslog] lavfi/vf_avgblur_opencl: remove useless clFinish().

2018-07-11 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Jul  4 
02:16:25 2018 +0800| [923ee63d6cd140e1f957c838b1d062ca4fb73580] | committer: 
Mark Thompson

lavfi/vf_avgblur_opencl: remove useless clFinish().

The very last clFinish() should be ok.

Signed-off-by: Ruiling Song 
Reviewed-by: Danil Iashchenko 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=923ee63d6cd140e1f957c838b1d062ca4fb73580
---

 libavfilter/vf_avgblur_opencl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavfilter/vf_avgblur_opencl.c b/libavfilter/vf_avgblur_opencl.c
index bc6bcab682..99ed1ca307 100644
--- a/libavfilter/vf_avgblur_opencl.c
+++ b/libavfilter/vf_avgblur_opencl.c
@@ -228,7 +228,6 @@ static int avgblur_opencl_filter_frame(AVFilterLink 
*inlink, AVFrame *input)
  0, NULL, NULL);
 CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to enqueue horizontal "
  "kernel: %d.\n", cle);
-cle = clFinish(ctx->command_queue);
 
 err = ff_opencl_filter_work_size_from_image(avctx, global_work,
 i == 0 ? output : 
intermediate, p, 0);

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


[FFmpeg-cvslog] lavfi: make vf_colorspace use functions from colorspace.c

2018-06-20 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jun 19 
09:57:32 2018 +0800| [649d7ca47780523673bbfe43407b9cb71c4ad811] | committer: 
Mark Thompson

lavfi: make vf_colorspace use functions from colorspace.c

These functions are shared among colorspace related filters.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=649d7ca47780523673bbfe43407b9cb71c4ad811
---

 libavfilter/Makefile|   2 +-
 libavfilter/vf_colorspace.c | 118 +---
 2 files changed, 23 insertions(+), 97 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 589682f353..34333aa520 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -168,7 +168,7 @@ OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += 
vf_colorchannelmixer.o
 OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
 OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
-OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspacedsp.o
+OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspace.o 
colorspacedsp.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)+= vf_convolution.o
 OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER) += vf_convolution_opencl.o 
opencl.o \
opencl/convolution.o
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 71ea08a20f..b593215daa 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -33,6 +33,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
+#include "colorspace.h"
 
 enum DitherMode {
 DITHER_NONE,
@@ -110,21 +111,13 @@ static const enum AVColorSpace default_csp[CS_NB + 1] = {
 
 struct ColorPrimaries {
 enum Whitepoint wp;
-double xr, yr, xg, yg, xb, yb;
+struct PrimaryCoefficients coeff;
 };
 
 struct TransferCharacteristics {
 double alpha, beta, gamma, delta;
 };
 
-struct LumaCoefficients {
-double cr, cg, cb;
-};
-
-struct WhitepointCoefficients {
-double xw, yw;
-};
-
 typedef struct ColorSpaceContext {
 const AVClass *class;
 
@@ -286,57 +279,30 @@ static const struct WhitepointCoefficients 
whitepoint_coefficients[WP_NB] = {
 };
 
 static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB] = {
-[AVCOL_PRI_BT709] = { WP_D65, 0.640, 0.330, 0.300, 0.600, 0.150, 0.060 
},
-[AVCOL_PRI_BT470M]= { WP_C,   0.670, 0.330, 0.210, 0.710, 0.140, 0.080 
},
-[AVCOL_PRI_BT470BG]   = { WP_D65, 0.640, 0.330, 0.290, 0.600, 0.150, 
0.060,},
-[AVCOL_PRI_SMPTE170M] = { WP_D65, 0.630, 0.340, 0.310, 0.595, 0.155, 0.070 
},
-[AVCOL_PRI_SMPTE240M] = { WP_D65, 0.630, 0.340, 0.310, 0.595, 0.155, 0.070 
},
-[AVCOL_PRI_SMPTE428]  = { WP_E,   0.735, 0.265, 0.274, 0.718, 0.167, 0.009 
},
-[AVCOL_PRI_SMPTE431]  = { WP_DCI, 0.680, 0.320, 0.265, 0.690, 0.150, 0.060 
},
-[AVCOL_PRI_SMPTE432]  = { WP_D65, 0.680, 0.320, 0.265, 0.690, 0.150, 0.060 
},
-[AVCOL_PRI_FILM]  = { WP_C,   0.681, 0.319, 0.243, 0.692, 0.145, 0.049 
},
-[AVCOL_PRI_BT2020]= { WP_D65, 0.708, 0.292, 0.170, 0.797, 0.131, 0.046 
},
-[AVCOL_PRI_JEDEC_P22] = { WP_D65, 0.630, 0.340, 0.295, 0.605, 0.155, 0.077 
},
+[AVCOL_PRI_BT709] = { WP_D65, { 0.640, 0.330, 0.300, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_BT470M]= { WP_C,   { 0.670, 0.330, 0.210, 0.710, 0.140, 
0.080 } },
+[AVCOL_PRI_BT470BG]   = { WP_D65, { 0.640, 0.330, 0.290, 0.600, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE170M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE240M] = { WP_D65, { 0.630, 0.340, 0.310, 0.595, 0.155, 
0.070 } },
+[AVCOL_PRI_SMPTE428]  = { WP_E,   { 0.735, 0.265, 0.274, 0.718, 0.167, 
0.009 } },
+[AVCOL_PRI_SMPTE431]  = { WP_DCI, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_SMPTE432]  = { WP_D65, { 0.680, 0.320, 0.265, 0.690, 0.150, 
0.060 } },
+[AVCOL_PRI_FILM]  = { WP_C,   { 0.681, 0.319, 0.243, 0.692, 0.145, 
0.049 } },
+[AVCOL_PRI_BT2020]= { WP_D65, { 0.708, 0.292, 0.170, 0.797, 0.131, 
0.046 } },
+[AVCOL_PRI_JEDEC_P22] = { WP_D65, { 0.630, 0.340, 0.295, 0.605, 0.155, 
0.077 } },
 };
 
 static const struct ColorPrimaries *get_color_primaries(enum AVColorPrimaries 
prm)
 {
-const struct ColorPrimaries *coeffs;
+const struct ColorPrimaries *p;
 
 if (prm >= AVCOL_PRI_NB)
 return NULL;
-coeffs = _primaries[prm];
-if (!coeffs->xr)
+p = _primaries[prm];
+if (!p->coeff.xr)
 return NULL;
 
-return coeffs;
-}
-
-static void invert_matrix3x3(const double in[3][3], double out[3][3])
-{
-double m00 = in[0][0], m01 = in[0][1], m02 = in[0][2],
-   m10 = in[1][0], m11 = in[1][1], m12 = in[1][2],
-   m20 = in[2][0], m21 = in[2][1], m22 = in[2][2];
-int i, j;
-double det;
-
-   

[FFmpeg-cvslog] lavfi: add opencl tonemap filter

2018-06-20 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Jun 19 
09:57:31 2018 +0800| [8b8b0e2cd26cf1f522c630859fcbcc62b6493fb9] | committer: 
Mark Thompson

lavfi: add opencl tonemap filter

This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.

An example command to use this filter with vaapi codecs:
FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
vaapi -i INPUT -filter_hw_device ocl -filter_complex \
'[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
[x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b8b0e2cd26cf1f522c630859fcbcc62b6493fb9
---

 configure   |   1 +
 libavfilter/Makefile|   2 +
 libavfilter/allfilters.c|   1 +
 libavfilter/colorspace.c|  90 +
 libavfilter/colorspace.h|  41 +++
 libavfilter/opencl/colorspace_common.cl | 220 +++
 libavfilter/opencl/tonemap.cl   | 272 ++
 libavfilter/opencl_source.h |   2 +
 libavfilter/vf_tonemap_opencl.c | 624 
 9 files changed, 1253 insertions(+)

diff --git a/configure b/configure
index 8ca258691d..6ad5ce8eaf 100755
--- a/configure
+++ b/configure
@@ -3412,6 +3412,7 @@ tinterlace_filter_deps="gpl"
 tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
+tonemap_opencl_filter_deps="opencl const_nan"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 552499558d..589682f353 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -358,6 +358,8 @@ OBJS-$(CONFIG_TINTERLACE_FILTER) += 
vf_tinterlace.o
 OBJS-$(CONFIG_TLUT2_FILTER)  += vf_lut2.o framesync.o
 OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o framesync.o
 OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o
+OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o 
colorspace.o opencl.o \
+opencl/tonemap.o 
opencl/colorspace_common.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 2b44626028..e07fe67ec5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -346,6 +346,7 @@ extern AVFilter ff_vf_tinterlace;
 extern AVFilter ff_vf_tlut2;
 extern AVFilter ff_vf_tmix;
 extern AVFilter ff_vf_tonemap;
+extern AVFilter ff_vf_tonemap_opencl;
 extern AVFilter ff_vf_transpose;
 extern AVFilter ff_vf_trim;
 extern AVFilter ff_vf_unpremultiply;
diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
new file mode 100644
index 00..7fd7bdf0d9
--- /dev/null
+++ b/libavfilter/colorspace.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2016 Ronald S. Bultje 
+ * 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
+ */
+
+#include "colorspace.h"
+
+
+void invert_matrix3x3(const double in[3][3], double out[3][3])
+{
+double m00 = in[0][0], m01 = in[0][1], m02 = in[0][2],
+   m10 = in[1][0], m11 = in[1][1], m12 = in[1][2],
+   m20 = in[2][0], m21 = in[2][1], m22 = in[2][2];
+int i, j;
+double det;
+
+out[0][0] =  (m11 * m22 - m21 * m12);
+out[0][1] = -(m01 * m22 - m21 * m02);
+out[0][2] =  (m01 * m12 - m11 * m02);
+out[1][0] = -(m10 * m22 - m20 * m12);
+out[1][1] =  (m00 * m22 - m20 * m02);
+out[1][2] = -(m00 * m12 - m10 * m02);
+out[2][0] =  (m10 * m21 - m20 * m11);
+out[2][1] = -(m00 * m21 - m20 * m01);
+out[2][2] =  (m00 * m11 - m10 * m01);
+
+det = m00 * out[0][0] + m10 * out[0][1] + m20 * out[0][2];
+det = 1.0 / det;
+
+for (i = 0; i < 3; i++) {
+for (j = 0; j < 3; j++)
+out[i][j]

[FFmpeg-cvslog] lavu: add calling convention for OpenCL callback.

2018-06-06 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Wed Jun  6 
23:31:44 2018 +0800| [e4006a474f689ef9534448d3382d220c62b413b6] | committer: 
Mark Thompson

lavu: add calling convention for OpenCL callback.

This fix a build error on Windows:
C2440: connot convert from 'void (__cdecl *) (...)' to 'void (__stdcall 
*)(...)'.

Signed-off-by: Ruiling Song 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4006a474f689ef9534448d3382d220c62b413b6
---

 libavutil/hwcontext_opencl.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5ae0c..e08d7bcb9b 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -141,9 +141,10 @@ typedef struct OpenCLFramesContext {
 } OpenCLFramesContext;
 
 
-static void opencl_error_callback(const char *errinfo,
-  const void *private_info, size_t cb,
-  void *user_data)
+static void CL_CALLBACK opencl_error_callback(const char *errinfo,
+  const void *private_info,
+  size_t cb,
+  void *user_data)
 {
 AVHWDeviceContext *ctx = user_data;
 av_log(ctx, AV_LOG_ERROR, "OpenCL error: %s\n", errinfo);

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


[FFmpeg-cvslog] lavf/qsv: clone the frame which may be managed by framework

2018-04-23 Thread Ruiling Song
ffmpeg | branch: release/4.0 | Ruiling Song <ruiling.s...@intel.com> | Tue Apr  
3 09:50:20 2018 +0800| [a768c0a3e1fa29eddc7dd348012b3093e476c94e] | committer: 
Mark Thompson

lavf/qsv: clone the frame which may be managed by framework

For filters based on framesync, the input frame was managed
by framesync, so we should not directly keep and destroy it,
instead we make a clone of it here, or else double-free will occur.
But for other filters not based on framesync, we still need to
free the input frame inside filter_frame.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
(cherry picked from commit d865783b6c8d4f96f5094ed72eff0f5a4a4908af)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a768c0a3e1fa29eddc7dd348012b3093e476c94e
---

 libavfilter/qsvvpp.c | 4 ++--
 libavfilter/vf_vpp_qsv.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 732cf56a6a..2c01295628 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -296,7 +296,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_log(ctx, AV_LOG_ERROR, "QSVVPP gets a wrong frame.\n");
 return NULL;
 }
-qsv_frame->frame   = picref;
+qsv_frame->frame   = av_frame_clone(picref);
 qsv_frame->surface = (mfxFrameSurface1 *)qsv_frame->frame->data[3];
 } else {
 /* make a copy if the input is not padded as libmfx requires */
@@ -318,7 +318,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_frame_copy_props(qsv_frame->frame, picref);
 av_frame_free();
 } else
-qsv_frame->frame = picref;
+qsv_frame->frame = av_frame_clone(picref);
 
 if (map_frame_to_surface(qsv_frame->frame,
 _frame->surface_internal) < 0) {
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 6be7098ae9..41a9f38962 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -341,9 +341,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 VPPContext   *vpp = inlink->dst->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 
-if (vpp->qsv)
+if (vpp->qsv) {
 ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
-else {
+av_frame_free();
+} else {
 if (picref->pts != AV_NOPTS_VALUE)
 picref->pts = av_rescale_q(picref->pts, inlink->time_base, 
outlink->time_base);
 ret = ff_filter_frame(outlink, picref);

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


[FFmpeg-cvslog] lavf: make overlay_qsv work based on framesync

2018-04-23 Thread Ruiling Song
ffmpeg | branch: release/4.0 | Ruiling Song <ruiling.s...@intel.com> | Tue Apr  
3 09:50:19 2018 +0800| [58569162c280a0765b63441001d359e62824c9de] | committer: 
Mark Thompson

lavf: make overlay_qsv work based on framesync

The existing version which was cherry-picked from Libav does not work
with FFmpeg framework, because ff_request_frame() was totally
different between Libav (recursive) and FFmpeg (non-recursive).
The existing overlay_qsv implementation depends on the recursive version
of ff_request_frame to trigger immediate call to request_frame() on input pad.
But this has been removed in FFmpeg since "lavfi: make request_frame() 
non-recursive."
Now that we have handy framesync support in FFmpeg, so I make it work
based on framesync. Some other fixing which is also needed to make
overlay_qsv work are put in a separate patch.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
(cherry picked from commit f3341a0452419c57faf4d28aebb24be5d41312f3)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58569162c280a0765b63441001d359e62824c9de
---

 libavfilter/Makefile |   2 +-
 libavfilter/vf_overlay_qsv.c | 213 ---
 2 files changed, 78 insertions(+), 137 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3a9fb02556..bcd5d437ff 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -267,7 +267,7 @@ OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)   += 
vf_datascope.o
 OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
-OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o
+OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o framesync.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
 OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index 6c3efdbeb5..20871786ee 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -36,6 +36,7 @@
 #include "formats.h"
 #include "video.h"
 
+#include "framesync.h"
 #include "qsvvpp.h"
 
 #define MAIN0
@@ -56,14 +57,10 @@ enum var_name {
 VAR_VARS_NB
 };
 
-enum EOFAction {
-EOF_ACTION_REPEAT,
-EOF_ACTION_ENDALL
-};
-
 typedef struct QSVOverlayContext {
 const AVClass  *class;
 
+FFFrameSync fs;
 QSVVPPContext  *qsv;
 QSVVPPParamqsv_param;
 mfxExtVPPComposite comp_conf;
@@ -72,10 +69,6 @@ typedef struct QSVOverlayContext {
 char *overlay_ox, *overlay_oy, *overlay_ow, *overlay_oh;
 uint16_t  overlay_alpha, overlay_pixel_alpha;
 
-enum EOFAction eof_action;  /* action to take on EOF from source */
-
-AVFrame *main;
-AVFrame *over_prev, *over_next;
 } QSVOverlayContext;
 
 static const char *const var_names[] = {
@@ -90,20 +83,25 @@ static const char *const var_names[] = {
 NULL
 };
 
-static const AVOption options[] = {
+static const AVOption overlay_qsv_options[] = {
 { "x", "Overlay x position", OFFSET(overlay_ox), AV_OPT_TYPE_STRING, { 
.str="0"}, 0, 255, .flags = FLAGS},
 { "y", "Overlay y position", OFFSET(overlay_oy), AV_OPT_TYPE_STRING, { 
.str="0"}, 0, 255, .flags = FLAGS},
 { "w", "Overlay width",  OFFSET(overlay_ow), AV_OPT_TYPE_STRING, { 
.str="overlay_iw"}, 0, 255, .flags = FLAGS},
 { "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_STRING, { 
.str="overlay_ih*w/overlay_iw"}, 0, 255, .flags = FLAGS},
 { "alpha", "Overlay global alpha", OFFSET(overlay_alpha), AV_OPT_TYPE_INT, 
{ .i64 = 255}, 0, 255, .flags = FLAGS},
 { "eof_action", "Action to take when encountering EOF from secondary input 
",
-OFFSET(eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
-EOF_ACTION_REPEAT, EOF_ACTION_ENDALL, .flags = FLAGS, "eof_action" },
-{ "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 
= EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
-{ "endall", "End both streams.",  0, AV_OPT_TYPE_CONST, { .i64 
= EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
+OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT 
},
+EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
+{ "repeat", "Repeat the previous frame.",   0, AV_OPT_TYPE_CONST, { 
.i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
+{ "endall", "En

[FFmpeg-cvslog] lavf/qsv: clone the frame which may be managed by framework

2018-04-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song <ruiling.s...@intel.com> | Tue Apr  3 
09:50:20 2018 +0800| [d865783b6c8d4f96f5094ed72eff0f5a4a4908af] | committer: 
Mark Thompson

lavf/qsv: clone the frame which may be managed by framework

For filters based on framesync, the input frame was managed
by framesync, so we should not directly keep and destroy it,
instead we make a clone of it here, or else double-free will occur.
But for other filters not based on framesync, we still need to
free the input frame inside filter_frame.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d865783b6c8d4f96f5094ed72eff0f5a4a4908af
---

 libavfilter/qsvvpp.c | 4 ++--
 libavfilter/vf_vpp_qsv.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 732cf56a6a..2c01295628 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -296,7 +296,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_log(ctx, AV_LOG_ERROR, "QSVVPP gets a wrong frame.\n");
 return NULL;
 }
-qsv_frame->frame   = picref;
+qsv_frame->frame   = av_frame_clone(picref);
 qsv_frame->surface = (mfxFrameSurface1 *)qsv_frame->frame->data[3];
 } else {
 /* make a copy if the input is not padded as libmfx requires */
@@ -318,7 +318,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_frame_copy_props(qsv_frame->frame, picref);
 av_frame_free();
 } else
-qsv_frame->frame = picref;
+qsv_frame->frame = av_frame_clone(picref);
 
 if (map_frame_to_surface(qsv_frame->frame,
 _frame->surface_internal) < 0) {
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 6be7098ae9..41a9f38962 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -341,9 +341,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 VPPContext   *vpp = inlink->dst->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 
-if (vpp->qsv)
+if (vpp->qsv) {
 ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
-else {
+av_frame_free();
+} else {
 if (picref->pts != AV_NOPTS_VALUE)
 picref->pts = av_rescale_q(picref->pts, inlink->time_base, 
outlink->time_base);
 ret = ff_filter_frame(outlink, picref);

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


[FFmpeg-cvslog] qsv: align surface width/height to 16.

2018-03-29 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song <ruiling.s...@intel.com> | Tue Mar  6 
10:35:56 2018 +0800| [86499771d1228d8303c8eb6509e20c0caaa02da5] | committer: 
Luca Barbato

qsv: align surface width/height to 16.

Per MediaSDK documentation, it requires width/height to 16 alignment.
Without this patch, hwupload pipeline may fail if 16 alignment is
not met. Although this patch also apply 16 alignment to qsv encoder/decoder,
it will not bring any side-effect to them as they are already aligned.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86499771d1228d8303c8eb6509e20c0caaa02da5
---

 libavutil/hwcontext_qsv.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 73b5f2467c..f5d78d0595 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -234,8 +234,8 @@ static int qsv_init_child_ctx(AVHWFramesContext *ctx)
 child_frames_ctx->format= device_priv->child_pix_fmt;
 child_frames_ctx->sw_format = ctx->sw_format;
 child_frames_ctx->initial_pool_size = ctx->initial_pool_size;
-child_frames_ctx->width = ctx->width;
-child_frames_ctx->height= ctx->height;
+child_frames_ctx->width = FFALIGN(ctx->width, 16);
+child_frames_ctx->height= FFALIGN(ctx->height, 16);
 
 #if CONFIG_DXVA2
 if (child_device_ctx->type == AV_HWDEVICE_TYPE_DXVA2) {
@@ -307,9 +307,9 @@ static int qsv_init_surface(AVHWFramesContext *ctx, 
mfxFrameSurface1 *surf)
 surf->Info.ChromaFormat   = MFX_CHROMAFORMAT_YUV444;
 
 surf->Info.FourCC = fourcc;
-surf->Info.Width  = ctx->width;
+surf->Info.Width  = FFALIGN(ctx->width, 16);
 surf->Info.CropW  = ctx->width;
-surf->Info.Height = ctx->height;
+surf->Info.Height = FFALIGN(ctx->height, 16);
 surf->Info.CropH  = ctx->height;
 surf->Info.FrameRateExtN  = 25;
 surf->Info.FrameRateExtD  = 1;

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


[FFmpeg-cvslog] qsv: Default PicStruct to progressive

2018-03-05 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song <ruiling.s...@intel.com> | Mon Feb 12 
16:37:16 2018 +0800| [8ca39b855a7b0e4d9f726fa9d285bc8edcb953e6] | committer: 
Luca Barbato

qsv: Default PicStruct to progressive

The PicStruct is required by MediaSDK, so give a default value.
hwupload does not work without this.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8ca39b855a7b0e4d9f726fa9d285bc8edcb953e6
---

 libavutil/hwcontext_qsv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 9fa603c350..73b5f2467c 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -313,6 +313,7 @@ static int qsv_init_surface(AVHWFramesContext *ctx, 
mfxFrameSurface1 *surf)
 surf->Info.CropH  = ctx->height;
 surf->Info.FrameRateExtN  = 25;
 surf->Info.FrameRateExtD  = 1;
+surf->Info.PicStruct  = MFX_PICSTRUCT_PROGRESSIVE;
 
 return 0;
 }

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


[FFmpeg-cvslog] lavc/qsv: default la_ds to MFX_LOOKAHEAD_DS_UNKNOWN

2018-02-12 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song <ruiling.s...@intel.com> | Sun Feb 11 
15:43:45 2018 +0800| [9b09792c90b580842157ca8ce534be434725a841] | committer: 
Maxym Dmytrychenko

lavc/qsv: default la_ds to MFX_LOOKAHEAD_DS_UNKNOWN

MFX_LOOKAHEAD_DS_UNKNOWN means auto.
-1 is not a valid value.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim@gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b09792c90b580842157ca8ce534be434725a841
---

 libavcodec/qsvenc.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 725651e2e1..31537b2663 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -73,8 +73,9 @@
 { "slow",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_QUALITY  
}, INT_MIN, INT_MAX, VE, "preset" }, \
 { "la_depth", "Number of frames to analyze before encoding.", 
OFFSET(qsv.la_depth), AV_OPT_TYPE_INT, { .i64 = 9 },   9, 100, VE, "la_depth" 
},  \
 { "unset", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 9 }, INT_MIN, INT_MAX, 
  VE, "la_depth" },  \
-{ "la_ds", "Downscaling factor for the frames saved for the lookahead 
analysis", OFFSET(qsv.la_ds), AV_OPT_TYPE_INT, { .i64 = -1 },   -1, 
MFX_LOOKAHEAD_DS_4x, VE, "la_ds" }, \
-{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 }, INT_MIN, INT_MAX, 
  VE, "la_ds" }, \
+{ "la_ds", "Downscaling factor for the frames saved for the lookahead 
analysis", OFFSET(qsv.la_ds), AV_OPT_TYPE_INT,\
+{ .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, 
MFX_LOOKAHEAD_DS_UNKNOWN, MFX_LOOKAHEAD_DS_4x, VE, "la_ds" },   
   \
+{ "auto", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_UNKNOWN }, 
INT_MIN, INT_MAX, VE, "la_ds" }, \
 { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_OFF }, INT_MIN, 
INT_MAX,  VE, "la_ds" }, \
 { "2x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_2x }, INT_MIN, 
INT_MAX,VE, "la_ds" }, \
 { "4x", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_LOOKAHEAD_DS_4x }, INT_MIN, 
INT_MAX,VE, "la_ds" }, \

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


[FFmpeg-cvslog] qsv: Skip the packet if decoding failure

2018-01-25 Thread Ruiling , Song
ffmpeg | branch: master | Ruiling, Song <ruiling.s...@intel.com> | Wed Jan 24 
10:14:51 2018 +0800| [559370f2c45110afd8308eec7194437736c323d4] | committer: 
Luca Barbato

qsv: Skip the packet if decoding failure

MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.

Signed-off-by: Ruiling Song <ruiling.s...@intel.com>
Signed-off-by: Luca Barbato <lu_z...@gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=559370f2c45110afd8308eec7194437736c323d4
---

 libavcodec/qsvdec_h2645.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 83880dc085..78a7b613f9 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -153,8 +153,12 @@ static int qsv_decode_frame(AVCodecContext *avctx, void 
*data,
 }
 
 ret = ff_qsv_process_data(avctx, >qsv, frame, got_frame, 
>buffer_pkt);
-if (ret < 0)
+if (ret < 0){
+/* Drop buffer_pkt when failed to decode the packet. Otherwise,
+   the decoder will keep decoding the failure packet. */
+av_packet_unref(>buffer_pkt);
 return ret;
+}
 
 s->buffer_pkt.size -= ret;
 s->buffer_pkt.data += ret;

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