[FFmpeg-devel] [PATCH] lavf/qsvvpp: add extra_hw_frames support

2019-06-05 Thread Zhong Li
extra_hw_frames is needed for some cases.
(eg: qsv decoding + qsv vpp + qsv look_ahead encoding, transcoding
 failed if no extra_hw_frames supported:
 ffmpeg -hwaccel qsv -c:v h264_qsv -i 
bbb_sunflower_1080p_30fps_normal_2000frames.mp4 \
-vf vpp_qsv=w=1280:h=720:extra_hw_frames=100 -v verbose  -c:v h264_qsv \
-look_ahead 1 -look_ahead_depth 100 out1.mp4
)

Signed-off-by: Zhong Li 
---
 libavfilter/qsvvpp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 62b91d6..49cb1ed 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -462,6 +462,8 @@ static int init_vpp_session(AVFilterContext *avctx, 
QSVVPPContext *s)
 out_frames_ctx->height= FFALIGN(outlink->h, 32);
 out_frames_ctx->sw_format = s->out_sw_format;
 out_frames_ctx->initial_pool_size = 64;
+if (avctx->extra_hw_frames > 0)
+out_frames_ctx->initial_pool_size += avctx->extra_hw_frames;
 out_frames_hwctx->frame_type  = s->out_mem_mode;
 
 ret = av_hwframe_ctx_init(out_frames_ref);
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 1/2] avcodec/bitstream: Check for integer code truncation in build_table()

2019-06-05 Thread Michael Niedermayer
Fixes: out of array read
Fixes: 
14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/bitstream.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 8762e5f4b2..590b490527 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -226,6 +226,10 @@ static int build_table(VLC *vlc, int table_nb_bits, int 
nb_codes,
 /* note: realloc has been done, so reload tables */
 table = (volatile VLC_TYPE (*)[2])&vlc->table[table_index];
 table[j][0] = index; //code
+if (table[j][0] != index) {
+avpriv_request_sample(NULL, "strange codes");
+return AVERROR_PATCHWELCOME;
+}
 i = k-1;
 }
 }
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] tools/target_dec_fuzzer: Limit error concealment on pixels instead of just frames

2019-06-05 Thread Michael Niedermayer
On Fri, May 17, 2019 at 10:57:53AM +0200, Michael Niedermayer wrote:
> This should reduce the amount of timeout issues overall
> 
> Fixes: Timeout (34->10sec)
> Fixes: 
> 14682/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-5728608414334976
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  tools/target_dec_fuzzer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply


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

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH 2/2] avcodec/bitstream: Check for more conflicting codes in build_table()

2019-06-05 Thread Michael Niedermayer
Fixes: out of array read
Fixes: 
14563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5646451545210880

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/bitstream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index 590b490527..be8a0f634d 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -188,8 +188,9 @@ static int build_table(VLC *vlc, int table_nb_bits, int 
nb_codes,
 }
 for (k = 0; k < nb; k++) {
 int bits = table[j][1];
+int oldsym  = table[j][0];
 ff_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n);
-if (bits != 0 && bits != n) {
+if ((bits || oldsym) && (bits != n || oldsym != symbol)) {
 av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
 return AVERROR_INVALIDDATA;
 }
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/diracdec: Fix integer overflow in global_mv()

2019-06-05 Thread Michael Niedermayer
On Wed, May 22, 2019 at 02:35:46AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 16384 * 196607 cannot be represented in type 
> 'int'
> Fixes: 
> 14810/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5091232683917312
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/diracdec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/dxv: Check op_offset in dxv_decompress_cocg()

2019-06-05 Thread Michael Niedermayer
On Tue, May 21, 2019 at 02:22:10AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 - 12 cannot be represented in 
> type 'int'
> Fixes: 
> 14732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-5735273129836544
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dxv.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/mss4: Check input size against skip bits

2019-06-05 Thread Michael Niedermayer
On Tue, May 14, 2019 at 02:50:48PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (17sec -> 20ms)
> Fixes: 
> 14615/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MTS2_fuzzer-5093007763701760
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mss4.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)

will apply

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] avfilter/framesync: fix shortest with eof_action=pass

2019-06-05 Thread Gyan


With current order, shortest gets ignored with eof_action=pass

Gyan
From 61834c8a9d8b01c2a82a001d2974d6389f7f7c49 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Wed, 5 Jun 2019 19:52:04 +0530
Subject: [PATCH] avfilter/framesync: fix shortest with eof_action=pass

Shifted check of shortest to after repeatlast,
to ensure shortest=1 is always honoured.
---
 libavfilter/framesync.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
index 22d3f091a3..bc95f7d904 100644
--- a/libavfilter/framesync.c
+++ b/libavfilter/framesync.c
@@ -127,16 +127,16 @@ int ff_framesync_configure(FFFrameSync *fs)
 fs->opt_shortest = 1;
 fs->opt_eof_action = EOF_ACTION_ENDALL;
 }
-if (fs->opt_shortest) {
-for (i = 0; i < fs->nb_in; i++)
-fs->in[i].after = EXT_STOP;
-}
 if (!fs->opt_repeatlast) {
 for (i = 1; i < fs->nb_in; i++) {
 fs->in[i].after = EXT_NULL;
 fs->in[i].sync  = 0;
 }
 }
+if (fs->opt_shortest) {
+for (i = 0; i < fs->nb_in; i++)
+fs->in[i].after = EXT_STOP;
+}
 
 if (!fs->time_base.num) {
 for (i = 0; i < fs->nb_in; i++) {
-- 
2.21.0___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH V3 2/2] checkasm/vf_gblur: add test for horiz_slice simd

2019-06-05 Thread Ruiling Song
Signed-off-by: Ruiling Song 
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/vf_gblur.c | 67 +++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 73 insertions(+)
 create mode 100644 tests/checkasm/vf_gblur.c

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..582bc7cc0f
--- /dev/null
+++ b/tests/checkasm/vf_gblur.c
@@ -0,0 +1,67 @@
+/*
+ * 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 i, j;
+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(&s);
+
+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(&dst_ref);
+av_freep(&dst_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-checkasm-vf_colorspace \
+fate-checkasm-vf_gblur  \
 fate-checkasm-vf_hflip  \
 fate-checkasm-vf_threshold  \
 fate-checkasm-videodsp  

[FFmpeg-devel] [PATCH V3 1/2] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-05 Thread Ruiling Song
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%.

v2:
Fix the bug when steps is not one.
v3:
Fix the bug when the upper half of 64bit register for 'int'
argument passing may have garbage.

Signed-off-by: Ruiling Song 
---
 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(-)
 create mode 100644 libavfilter/gblur.h
 create mode 100644 libavfilter/x86/vf_gblur.asm
 create mode 100644 libavfilter/x86/vf_gblur_init.c

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_start; y < slice_end; y++) {
+for (y = 0; y < height; y++) {
 for (step = 0; step < steps; step++) {
 ptr = buffer + 

Re: [FFmpeg-devel] [PATCH V2 2/2] checkasm/vf_gblur: add test for horiz_slice simd

2019-06-05 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Wednesday, June 5, 2019 4:16 AM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH V2 2/2] checkasm/vf_gblur: add test for
> horiz_slice simd
> 
> On Tue, Jun 04, 2019 at 04:42:09PM +0800, Ruiling Song wrote:
> > Signed-off-by: Ruiling Song 
> > ---
> >  tests/checkasm/Makefile   |  1 +
> >  tests/checkasm/checkasm.c |  3 ++
> >  tests/checkasm/checkasm.h |  1 +
> >  tests/checkasm/vf_gblur.c | 67
> +++
> >  tests/fate/checkasm.mak   |  1 +
> >  5 files changed, 73 insertions(+)
> >  create mode 100644 tests/checkasm/vf_gblur.c
> 
> this fails here: (ubuntu x86-64)
> 
> Test checkasm-vf_gblur failed. Look at tests/data/fate/checkasm-
> vf_gblur.err for details.
> checkasm: using random seed 1608403213
> test failed comparing 258.619 with 212.24 (abs diff=46.3793 with EPS=0.01)
> SSE4.1:
>horiz_slice_sse4 (vf_gblur.c:60)
>  - vf_gblur.horiz_slice [FAILED]
> checkasm: 1 of 1 tests have failed
> make: *** [fate-checkasm-vf_gblur] Error 1
Hi Michael,

Thanks so much for testing. I tried on three different hardware with Ubuntu 
18.04, and failed to reproduce the issue. It's really strange:(
But I reproduce a failure on WIN64. the root-cause of the bug is I missed the 
important fact that the 'int' parameter was passed in using lower 32bit of the 
64bit register. The upper 32bit may have garbage.
I have fixed the issue in V3. Hope it can solve the issue you met. Please help 
take a test when you have time.
If it cannot fix your issue, please help share me your CPU info, Ubuntu 
version, gcc version, and nasm/yasm version. Thanks so much!

Thanks!
Ruiling
> 
> 
> 
> [...]
> --
> Michael GnuPG fingerprint:
> 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> You can kill me, but you cannot change the truth.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avfilter/framesync: fix shortest with eof_action=pass

2019-06-05 Thread Nicolas George
Gyan (12019-06-05):
> With current order, shortest gets ignored with eof_action=pass

Enabling both does not make much sense. A warning may be a better idea.
But no objection.

Regards,

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/framesync: fix shortest with eof_action=pass

2019-06-05 Thread Gyan



On 05-06-2019 09:06 PM, Nicolas George wrote:

Gyan (12019-06-05):

With current order, shortest gets ignored with eof_action=pass

Enabling both does not make much sense. A warning may be a better idea.
But no objection.

This is to just to fix an edge case, for the careless user. Will apply.

BTW, what is the purpose of the repeatlast option, given the possibility 
of eof_action=repeat?


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

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

Re: [FFmpeg-devel] [PATCH] avcodec/h264_sei: Add experimental acces to truncated SEI data

2019-06-05 Thread Reimar Döffinger
On 04.06.2019, at 22:33, Antonin Gouzer  wrote:

> Hello,
> Thanks for your response.
> It's difficult to say if this is a common issue.
> I have hundred of thousands of files like this from an editor.
> 
> Even the off by one Size is not standart compliant and it would be
> incorrect to not report it as an error/warning

Warning yes, but as far as I know FFmpeg policy generally is to support all 
files that exist in the wild without extra options.
So I would maybe start with suggesting if you can convince the authors of that 
editor to fix it (doesn't fix existing files, but at least we won't have more 
of them generated).
Secondly, I would suggest to accept (with warning) the off-by-one case, unless 
stricter than default compliance is requested.
Lastly, up to you what to do about the case where it is off by more than one.
I think it should probably still be rejected at default compliance selection, 
but don't care whether to not support it at all or at experimental level.
Though last word is up to the maintainer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH] lavd/v4l2: produce a 0 byte packet when a dequeued buffer's size is unexpected

2019-06-05 Thread Alexander Strasser
From: Stephan Hilb 

Behave like we do for V4L2_BUF_FLAG_ERROR, implemented in commit 28f20d2ff4 .

For some devices (probably also related to the V4L driver implementation)
it happens that when invoking the ioctl DQBUF, the returned buffer is not
of the expected size. Here are two examples for such occurrences:

[video4linux2,v4l2 @ 0x258b440] Dequeued v4l2 buffer contains 609596 bytes, 
but 614400 were expected. Flags: 0x0001.
/dev/video1: Invalid data found when processing input

[video4linux2,v4l2 @ 0x225f440] Dequeued v4l2 buffer contains 609508 bytes, 
but 614400 were expected. Flags: 0x0001.
/dev/video1: Invalid data found when processing input

For the ffmpeg CLI tool this means it will stop capturing and exit.

The described behaviour was observed at least with one OmniVision USB
web cam and with some stk1160 devices.

If you search the web for the error message, you will find quite a few
instances of this problem. Some of them experienced on other devices.

Probably fixes ticket #4795

Signed-off-by: Alexander Strasser 
---

This is exactly Stephan's patch except for the commit message.

@Stephan: I hope you are OK with my wording in the new message.

I contacted Giorgio off-list and also put him in Bcc for this email.

He previously reacted, but he probably doesn't have enough time. So if
there are no objections I intent to commit in roughly a week if no
more issues are found and no objections are raised.

 libavdevice/v4l2.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index a9a0ed324d..446a243cf8 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -538,11 +538,10 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket 
*pkt)
 s->frame_size = buf.bytesused;

 if (s->frame_size > 0 && buf.bytesused != s->frame_size) {
-av_log(ctx, AV_LOG_ERROR,
+av_log(ctx, AV_LOG_WARNING,
"Dequeued v4l2 buffer contains %d bytes, but %d were 
expected. Flags: 0x%08X.\n",
buf.bytesused, s->frame_size, buf.flags);
-enqueue_buffer(s, &buf);
-return AVERROR_INVALIDDATA;
+buf.bytesused = 0;
 }
 }

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

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

[FFmpeg-devel] [PATCH] mpegts pat and sdt period should respect user options

2019-06-05 Thread Tomas Hulata
When mux_rate (CBR) is defined, pat/sdt period setting is now respected. 
In case of VBR, leave it as it was.


---
 libavformat/mpegtsenc.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index fc0ea225c6..5ad1f813e0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -999,10 +999,18 @@ static int mpegts_init(AVFormatContext *s)
 ts->last_sdt_ts = AV_NOPTS_VALUE;
 // The user specified a period, use only it
 if (ts->pat_period < INT_MAX/2) {
-    ts->pat_packet_period = INT_MAX;
+    if (ts->mux_rate > 1)
+    ts->pat_packet_period = (int64_t)ts->mux_rate * 
ts->pat_period /

+    (TS_PACKET_SIZE * 8);
+    else
+    ts->pat_packet_period = INT_MAX;
 }
 if (ts->sdt_period < INT_MAX/2) {
-    ts->sdt_packet_period = INT_MAX;
+    if (ts->mux_rate > 1)
+    ts->sdt_packet_period = (int64_t)ts->mux_rate * 
ts->sdt_period /

+    (TS_PACKET_SIZE * 8);
+    else
+    ts->sdt_packet_period = INT_MAX;
 }

 // output a PCR as soon as possible
--
2.19.1


smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avformat/id3v2enc: write CTOC too

2019-06-05 Thread Michael Niedermayer
On Tue, Jun 04, 2019 at 04:45:38PM +0200, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/id3v2enc.c | 36 
>  1 file changed, 36 insertions(+)

if this is written in a fate test then it will need an update
(this patch as it is ATM does write it in fate-lavf-fate-mp3)

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH V2 1/4] lavf/webvtt: fix ffmpeg -h demuxer=webvtt can't dump options

2019-06-05 Thread Jun Zhao
From: Jun Zhao 

fix ffmpeg -h demuxer=webvtt can't dump options

Signed-off-by: Jun Zhao 
---
 libavformat/webvttdec.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index e435de3..52579c5 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -192,14 +192,14 @@ static int webvtt_read_close(AVFormatContext *s)
 }
 
 #define OFFSET(x) offsetof(WebVTTContext, x)
-#define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM
+#define KIND_FLAGS AV_OPT_FLAG_SUBTITLE_PARAM|AV_OPT_FLAG_DECODING_PARAM
 
 static const AVOption options[] = {
 { "kind", "Set kind of WebVTT track", OFFSET(kind), AV_OPT_TYPE_INT, { 
.i64 = 0 }, 0, INT_MAX, KIND_FLAGS, "webvtt_kind" },
-{ "subtitles","WebVTT subtitles kind",0, AV_OPT_TYPE_CONST, { 
.i64 = 0 },   INT_MIN, INT_MAX, 0, "webvtt_kind" },
-{ "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, 0, "webvtt_kind" },
-{ "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, 0, "webvtt_kind" },
-{ "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, 0, "webvtt_kind" },
+{ "subtitles","WebVTT subtitles kind",0, AV_OPT_TYPE_CONST, { 
.i64 = 0 },   INT_MIN, INT_MAX, KIND_FLAGS, 
"webvtt_kind" },
+{ "captions", "WebVTT captions kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_CAPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, 
"webvtt_kind" },
+{ "descriptions", "WebVTT descriptions kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_DESCRIPTIONS }, INT_MIN, INT_MAX, KIND_FLAGS, 
"webvtt_kind" },
+{ "metadata", "WebVTT metadata kind", 0, AV_OPT_TYPE_CONST, { 
.i64 = AV_DISPOSITION_METADATA }, INT_MIN, INT_MAX, KIND_FLAGS, 
"webvtt_kind" },
 { NULL }
 };
 
-- 
1.7.1

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

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

[FFmpeg-devel] [PATCH V2 2/4] lavf/webvttenc: fix ffmpeg -h full can't display webvtt muxer

2019-06-05 Thread Jun Zhao
From: Jun Zhao 

fix ffmpeg -h full can't display webvtt muxer

Signed-off-by: Jun Zhao 
---
 libavformat/webvttenc.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 61b7f54..b4e8a61 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -26,6 +26,7 @@
 
 #include "avformat.h"
 #include "internal.h"
+#include "libavutil/opt.h"
 
 static void webvtt_write_time(AVIOContext *pb, int64_t millisec)
 {
@@ -94,6 +95,17 @@ static int webvtt_write_packet(AVFormatContext *ctx, 
AVPacket *pkt)
 return 0;
 }
 
+static const AVOption options[] = {
+{ NULL }
+};
+
+static const AVClass webvtt_muxer_class = {
+.class_name  = "WebVTT muxer",
+.item_name   = av_default_item_name,
+.option  = options,
+.version = LIBAVUTIL_VERSION_INT,
+};
+
 AVOutputFormat ff_webvtt_muxer = {
 .name  = "webvtt",
 .long_name = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
@@ -103,4 +115,5 @@ AVOutputFormat ff_webvtt_muxer = {
 .subtitle_codec= AV_CODEC_ID_WEBVTT,
 .write_header  = webvtt_write_header,
 .write_packet  = webvtt_write_packet,
+.priv_class= &webvtt_muxer_class,
 };
-- 
1.7.1

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

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

[FFmpeg-devel] [PATCH V2 0/4] fix webvtt can't dump option issue

2019-06-05 Thread Jun Zhao
V2: - fix WebVTT encoder fail issue

Jun Zhao (4):
  lavf/webvtt: fix ffmpeg -h demuxer=webvtt can't dump options
  lavf/webvttenc: fix ffmpeg -h full can't display webvtt muxer
  lavc/webvttdec: fix ffmpeg -h full can't display webvtt decoder
  lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

 libavcodec/webvttdec.c  |   13 +
 libavcodec/webvttenc.c  |   14 ++
 libavformat/webvttdec.c |   10 +-
 libavformat/webvttenc.c |   13 +
 4 files changed, 45 insertions(+), 5 deletions(-)

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

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

[FFmpeg-devel] [PATCH V2 4/4] lavc/webvttenc: fix ffmpeg -h full can't display webvtt encoder

2019-06-05 Thread Jun Zhao
From: Jun Zhao 

fix ffmpeg -h full can't display webvtt encoder

Signed-off-by: Jun Zhao 
---
 libavcodec/webvttenc.c |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/libavcodec/webvttenc.c b/libavcodec/webvttenc.c
index c84bbf4..21e7d92 100644
--- a/libavcodec/webvttenc.c
+++ b/libavcodec/webvttenc.c
@@ -24,11 +24,13 @@
 #include "avcodec.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/opt.h"
 #include "ass_split.h"
 #include "ass.h"
 
 #define WEBVTT_STACK_SIZE 64
 typedef struct {
+const AVClass *class;
 AVCodecContext *avctx;
 ASSSplitContext *ass_ctx;
 AVBPrint buffer;
@@ -224,6 +226,17 @@ static av_cold int webvtt_encode_init(AVCodecContext 
*avctx)
 return s->ass_ctx ? 0 : AVERROR_INVALIDDATA;
 }
 
+static const AVOption options[] = {
+{ NULL },
+};
+
+static const AVClass webvtt_encoder_class = {
+.class_name = "WebVTT encoder",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_webvtt_encoder = {
 .name   = "webvtt",
 .long_name  = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
@@ -233,4 +246,5 @@ AVCodec ff_webvtt_encoder = {
 .init   = webvtt_encode_init,
 .encode_sub = webvtt_encode_frame,
 .close  = webvtt_encode_close,
+.priv_class = &webvtt_encoder_class,
 };
-- 
1.7.1

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

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

[FFmpeg-devel] [PATCH V2 3/4] lavc/webvttdec: fix ffmpeg -h full can't display webvtt decoder

2019-06-05 Thread Jun Zhao
From: Jun Zhao 

fix ffmpeg -h full can't display webvtt decoder

Signed-off-by: Jun Zhao 
---
 libavcodec/webvttdec.c |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/libavcodec/webvttdec.c b/libavcodec/webvttdec.c
index 7b2d175..28113f6 100644
--- a/libavcodec/webvttdec.c
+++ b/libavcodec/webvttdec.c
@@ -28,6 +28,7 @@
 #include "avcodec.h"
 #include "ass.h"
 #include "libavutil/bprint.h"
+#include "libavutil/opt.h"
 
 static const struct {
 const char *from;
@@ -98,6 +99,17 @@ static int webvtt_decode_frame(AVCodecContext *avctx,
 return avpkt->size;
 }
 
+static const AVOption options[] = {
+{ NULL },
+};
+
+static const AVClass webvtt_decoder_class = {
+.class_name = "WebVTT decoder",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_webvtt_decoder = {
 .name   = "webvtt",
 .long_name  = NULL_IF_CONFIG_SMALL("WebVTT subtitle"),
@@ -107,4 +119,5 @@ AVCodec ff_webvtt_decoder = {
 .init   = ff_ass_subtitle_header_default,
 .flush  = ff_ass_decoder_flush,
 .priv_data_size = sizeof(FFASSDecoderContext),
+.priv_class = &webvtt_decoder_class,
 };
-- 
1.7.1

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

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

Re: [FFmpeg-devel] [PATCH v2] libavcodec/vp8dec: fix the multi-thread HWAccel decode error

2019-06-05 Thread Xiang, Haihao
On Tue, 2019-06-04 at 15:21 +0800, Wang, Shaofei wrote:
> > -Original Message-
> > From: Xiang, Haihao
> > Sent: Tuesday, May 28, 2019 12:23 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Wang, Shaofei 
> > Subject: Re: [FFmpeg-devel] [PATCH v2] libavcodec/vp8dec: fix the
> > multi-thread HWAccel decode error
> > 
> > On Thu, 2019-03-28 at 13:28 -0400, Shaofei Wang wrote:
> > > Fix the issue: https://github.com/intel/media-driver/issues/317
> > > 
> > > the root cause is update_dimensions will be called multple times when
> > > decoder thread number is not only 1, but update_dimensions call
> > > get_pixel_format in each decode thread will trigger the
> > > hwaccel_uninit/hwaccel_init more than once. But only one hwaccel
> > > should be shared with all decode threads.
> > > in current context,
> > > there are 3 situations in the update_dimensions():
> > > 1. First time calling. No matter single thread or multithread,
> > >get_pixel_format() should be called after dimensions were
> > >set;
> > > 2. Dimention changed at the runtime. Dimention need to be
> > >updated when macroblocks_base is already allocated,
> > >get_pixel_format() should be called to recreate new frames
> > >according to updated dimention;
> > 
> > s/Dimention/dimension ?
> 
> OK, should be dimension
> 
> > BTW this version of patch doesn't address the concern provided when
> > reviewing the first version of patch.
> > 
> > When (width != s->avctx->width || height != s->avctx->height) is true,
> > ff_set_dimensions() is called even if s->macroblocks_base is not allocated,
> > so
> > why set dim_reset to (s->macroblocks_base != NULL)? I think dim_reset
> > should be set to 1.
> 
> If s->macroblocks_base is available, it means macroblocks_base of the context 
>  has been already allocated by one of threads, so it's a reset operation when
>  (width != s->avctx->width...
> If s->macroblocks_base is null, it's not allocated yet, and
> (width != s->avctx->width..., just dimension need to be updated but it's not a
> dim reset operation. Since we only call get_pixel_format() in the first thread
> or
>  in the reset operation

Is it reasonable when dimension is updated however the low level frame still use
stale dimension info? 

Thanks
Haihao


> 
> > > if (width  != s->avctx->width || ((width+15)/16 != s->mb_width ||
> > > (height+15)/16 != s->mb_height) && s->macroblocks_base ||
> > >  height != s->avctx->height) { @@ -196,9 +196,12 @@ int
> > > update_dimensions(VP8Context *s, int width, int height, int is_vp7)
> > >  ret = ff_set_dimensions(s->avctx, width, height);
> > >  if (ret < 0)
> > >  return ret;
> > > +
> > > +dim_reset = (s->macroblocks_base != NULL);
> > 
> > 
> > > 3. Multithread first time calling. After decoder init, the
> > >other threads will call update_dimensions() at first time
> > >to allocate macroblocks_base and set dimensions.
> > >But get_pixel_format() is shouldn't be called due to low
> > >level frames and context are already created.
> > > 
> > > In this fix, we only call update_dimensions as need.
> > > 
> > > Signed-off-by: Wang, Shaofei 
> > > Reviewed-by: Jun, Zhao 
> > > Reviewed-by: Haihao Xiang 
> > > ---
> > > Previous code reviews:
> > > 2019-03-06 9:25 GMT+01:00, Wang, Shaofei :
> > > > > -Original Message-
> > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > > Behalf Of Carl Eugen Hoyos
> > > > > Sent: Wednesday, March 6, 2019 3:49 PM
> > > > > To: FFmpeg development discussions and patches
> > > > > 
> > > > > Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/vp8dec: fix the
> > > > > multi-thread HWAccel decode error
> > > > > 
> > > > > 2018-08-09 9:09 GMT+02:00, Jun Zhao :
> > > > > > the root cause is update_dimentions call get_pixel_format will
> > > > > > trigger the hwaccel_uninit/hwaccel_init , in current context,
> > > > > > there are 3 situations in the update_dimentions():
> > > > > > 1. First time calling. No matter single thread or multithread,
> > > > > >get_pixel_format() should be called after dimentions were
> > > > > >set;
> > > > > > 2. Dimention changed at the runtime. Dimention need to be
> > > > > >updated when macroblocks_base is already allocated,
> > > > > >get_pixel_format() should be called to recreate new frames
> > > > > >according to updated dimention; 3. Multithread first time
> > > > > > calling. After decoder init, the
> > > > > >other threads will call update_dimentions() at first time
> > > > > >to allocate macroblocks_base and set dimentions.
> > > > > >But get_pixel_format() is shouldn't be called due to low
> > > > > >level frames and context are already created.
> > > > > > In this fix, we only call update_dimentions as need.
> > > > > > 
> > > > > > Signed-off-by: Wang, Shaofei 
> > > > > > Reviewed-by: Jun, Zhao 
> > > > > > ---
> > > > > >  libavcodec/vp8.c |7 +--
> > > > > >  1 files changed, 5 insert

Re: [FFmpeg-devel] [PATCH v3] libavfilter: Add derain filter

2019-06-05 Thread Steven Liu
Steven Liu  于2019年6月1日周六 上午8:30写道:
>
>
>
> > 在 2019年5月30日,20:35,Xuewei Meng  写道:
> >
> > Remove the rain in the input image/video by applying the derain
> > methods based on convolutional neural networks. Training scripts
> > as well as scripts for model generation are provided in the
> > repository at https://github.com/XueweiMeng/derain_filter.git.
> >
> > Signed-off-by: Xuewei Meng 
> > ---
> > doc/filters.texi |  34 +++
> > libavfilter/Makefile |   1 +
> > libavfilter/allfilters.c |   1 +
> > libavfilter/vf_derain.c  | 212 +++
> > 4 files changed, 248 insertions(+)
> > create mode 100644 libavfilter/vf_derain.c
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 4fdcfe919e..f1d3841ed3 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -8248,6 +8248,40 @@ delogo=x=0:y=0:w=100:h=77:band=10
> >
> > @end itemize
> >
> > +@section derain
> > +
> > +Remove the rain in the input image/video by applying the derain methods 
> > based on
> > +convolutional neural networks. Supported models:
> > +
> > +@itemize
> > +@item
> > +Recurrent Squeeze-and-Excitation Context Aggregation Net (RESCAN).
> > +See 
> > @url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.pdf}.
> > +@end itemize
> > +
> > +Training scripts as well as scripts for model generation are provided in
> > +the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
> > +
> > +The filter accepts the following options:
> > +
> > +@table @option
> > +@item dnn_backend
> > +Specify which DNN backend to use for model loading and execution. This 
> > option accepts
> > +the following values:
> > +
> > +@table @samp
> > +@item native
> > +Native implementation of DNN loading and execution.
> > +@end table
> > +Default value is @samp{native}.
> > +
> > +@item model
> > +Set path to model file specifying network architecture and its parameters.
> > +Note that different backends use different file formats. TensorFlow backend
> > +can load files for both formats, while native backend can load files for 
> > only
> > +its format.
> > +@end table
> > +
> > @section deshake
> >
> > Attempt to fix small changes in horizontal and/or vertical shift. This
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index 9a61c25b05..b7191d0081 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -200,6 +200,7 @@ OBJS-$(CONFIG_DCTDNOIZ_FILTER)   += 
> > vf_dctdnoiz.o
> > OBJS-$(CONFIG_DEBAND_FILTER) += vf_deband.o
> > OBJS-$(CONFIG_DEBLOCK_FILTER)+= vf_deblock.o
> > OBJS-$(CONFIG_DECIMATE_FILTER)   += vf_decimate.o
> > +OBJS-$(CONFIG_DERAIN_FILTER) += vf_derain.o
> > OBJS-$(CONFIG_DECONVOLVE_FILTER) += vf_convolve.o framesync.o
> > OBJS-$(CONFIG_DEDOT_FILTER)  += vf_dedot.o
> > OBJS-$(CONFIG_DEFLATE_FILTER)+= vf_neighbor.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> > index 40534738ee..f3c8883960 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -196,6 +196,7 @@ extern AVFilter ff_vf_deinterlace_vaapi;
> > extern AVFilter ff_vf_dejudder;
> > extern AVFilter ff_vf_delogo;
> > extern AVFilter ff_vf_denoise_vaapi;
> > +extern AVFilter ff_vf_derain;
> > extern AVFilter ff_vf_deshake;
> > extern AVFilter ff_vf_despill;
> > extern AVFilter ff_vf_detelecine;
> > diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c
> > new file mode 100644
> > index 00..c380b40122
> > --- /dev/null
> > +++ b/libavfilter/vf_derain.c
> > @@ -0,0 +1,212 @@
> > +/*
> > + * Copyright (c) 2019 Xuewei Meng
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
> > 02110-1301 USA
> > + */
> > +
> > +/**
> > + * @file
> > + * Filter implementing image derain filter using deep convolutional 
> > networks.
> > + * 
> > http://openaccess.thecvf.com/content_ECCV_2018/html/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.html
> > + */
> > +
> > +#include "libavformat/avio.h"
> > +#include "libavutil/opt.h"
> > +#include "avfilter.h"
> > +#include "dnn_inte

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-05 Thread Lance Wang
On Sun, May 26, 2019 at 8:08 AM  wrote:

> From: Limin Wang 
>
> The test ffmpeg command in iMAC system:
> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
> Now I have tested with yuv420p10 overlay and check the result is OK,
> please help to test with your condition.
> ---
>  libavfilter/vf_overlay.c | 42 +++-
>  libavfilter/vf_overlay.h |  1 +
>  2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> index 2d06074f15..e708d525e5 100644
> --- a/libavfilter/vf_overlay.c
> +++ b/libavfilter/vf_overlay.c
> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx, const
> char *cmd, const char *ar
>  }
>
>  static const enum AVPixelFormat alpha_pix_fmts[] = {
> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
> AV_PIX_FMT_YUVA444P,
>  AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
>  AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
>  };
> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
>  AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
>  };
>
> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
> +AV_PIX_FMT_NONE
> +};
> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
> +};
> +
>  static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
>  AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
> AV_PIX_FMT_NONE
>  };
> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
>  goto fail;
>  }
>  break;
> +case OVERLAY_FORMAT_YUV420P10:
> +if (!(main_formats=
> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
> +!(overlay_formats =
> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +break;
>  case OVERLAY_FORMAT_YUV422:
>  if (!(main_formats=
> ff_make_format_list(main_pix_fmts_yuv422)) ||
>  !(overlay_formats =
> ff_make_format_list(overlay_pix_fmts_yuv422))) {
> @@ -565,6 +580,7 @@ static av_always_inline void
> blend_plane_##depth##_##nbits##bits(AVFilterContext
>  }
>   \
>  }
>  DEFINE_BLEND_PLANE(8, 8);
> +DEFINE_BLEND_PLANE(16, 10);
>
>  #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
>  \
>  static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
> *src, const AVFrame *dst, \
> @@ -616,6 +632,7 @@ static inline void
> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
>  }
>   \
>  }
>  DEFINE_ALPHA_COMPOSITE(8, 8);
> +DEFINE_ALPHA_COMPOSITE(16, 10);
>
>  #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
>  \
>  static av_always_inline void
> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
>\
> @@ -646,6 +663,7 @@ static av_always_inline void
> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
>  alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
>  }
>  DEFINE_BLEND_SLICE_YUV(8, 8);
> +DEFINE_BLEND_SLICE_YUV(16, 10);
>
>  static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
>  AVFrame *dst, const
> AVFrame *src,
> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext *ctx,
> void *arg, int jobnr, int n
>  return 0;
>  }
>
> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
> jobnr, int nb_jobs)
> +{
> +OverlayContext *s = ctx->priv;
> +ThreadData *td = arg;
> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y,
> 1, jobnr, nb_jobs);
> +return 0;
> +}
> +
> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
> jobnr, int nb_jobs)
> +{
> +OverlayContext *s = ctx->priv;
> +ThreadData *td = arg;
> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y,
> 1, jobnr, nb_jobs);
> +return 0;
> +}
>  static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr,
> int nb_jobs)
>  {
>  OverlayContext *s = ctx->priv;
> @@ -855,6 +888,9 @@ static int config_input_main(AVFilterLink *inlink)
>  case OVERLAY_FORMAT_YUV420:
>  s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 :
> blend_slice_yuv420;
>  break;
> +case OVERLAY_FORMAT_YUV420P10:
> +s->blend_slice = s->main_has_alpha ? blend_slice_yuva420p10 :
> blend_slice_yuv420p10;
> +break;
>  case 

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-05 Thread Liu Steven


> 在 2019年6月6日,下午2:06,Lance Wang  写道:
> 
> On Sun, May 26, 2019 at 8:08 AM  wrote:
> 
>> From: Limin Wang 
>> 
>> The test ffmpeg command in iMAC system:
>> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
>> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
>> Now I have tested with yuv420p10 overlay and check the result is OK,
>> please help to test with your condition.
>> ---
>> libavfilter/vf_overlay.c | 42 +++-
>> libavfilter/vf_overlay.h |  1 +
>> 2 files changed, 42 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
>> index 2d06074f15..e708d525e5 100644
>> --- a/libavfilter/vf_overlay.c
>> +++ b/libavfilter/vf_overlay.c
>> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx, const
>> char *cmd, const char *ar
>> }
>> 
>> static const enum AVPixelFormat alpha_pix_fmts[] = {
>> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
>> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
>> AV_PIX_FMT_YUVA444P,
>> AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
>> AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
>> };
>> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
>> AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
>> };
>> 
>> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
>> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
>> +AV_PIX_FMT_NONE
>> +};
>> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
>> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
>> +};
>> +
>> static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
>> AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
>> AV_PIX_FMT_NONE
>> };
>> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
>> goto fail;
>> }
>> break;
>> +case OVERLAY_FORMAT_YUV420P10:
>> +if (!(main_formats=
>> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
>> +!(overlay_formats =
>> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
>> +ret = AVERROR(ENOMEM);
>> +goto fail;
>> +}
>> +break;
>> case OVERLAY_FORMAT_YUV422:
>> if (!(main_formats=
>> ff_make_format_list(main_pix_fmts_yuv422)) ||
>> !(overlay_formats =
>> ff_make_format_list(overlay_pix_fmts_yuv422))) {
>> @@ -565,6 +580,7 @@ static av_always_inline void
>> blend_plane_##depth##_##nbits##bits(AVFilterContext
>> }
>>  \
>> }
>> DEFINE_BLEND_PLANE(8, 8);
>> +DEFINE_BLEND_PLANE(16, 10);
>> 
>> #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
>> \
>> static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
>> *src, const AVFrame *dst, \
>> @@ -616,6 +632,7 @@ static inline void
>> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
>> }
>>  \
>> }
>> DEFINE_ALPHA_COMPOSITE(8, 8);
>> +DEFINE_ALPHA_COMPOSITE(16, 10);
>> 
>> #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
>> \
>> static av_always_inline void
>> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
>>   \
>> @@ -646,6 +663,7 @@ static av_always_inline void
>> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
>> alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
>> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
>> }
>> DEFINE_BLEND_SLICE_YUV(8, 8);
>> +DEFINE_BLEND_SLICE_YUV(16, 10);
>> 
>> static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
>> AVFrame *dst, const
>> AVFrame *src,
>> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext *ctx,
>> void *arg, int jobnr, int n
>> return 0;
>> }
>> 
>> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
>> jobnr, int nb_jobs)
>> +{
>> +OverlayContext *s = ctx->priv;
>> +ThreadData *td = arg;
>> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y,
>> 1, jobnr, nb_jobs);
>> +return 0;
>> +}
>> +
>> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
>> jobnr, int nb_jobs)
>> +{
>> +OverlayContext *s = ctx->priv;
>> +ThreadData *td = arg;
>> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y,
>> 1, jobnr, nb_jobs);
>> +return 0;
>> +}
>> static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr,
>> int nb_jobs)
>> {
>> OverlayContext *s = ctx->priv;
>> @@ -855,6 +888,9 @@ static int config_input_main(AVFilterLink *inlink)
>> case OVERLAY_FORMAT_YUV420:
>> s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 :
>> blend_slice_yuv420;
>> break;
>> +case OVERLAY_FORMAT_Y

[FFmpeg-devel] [PATCH] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly

2019-06-05 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 libavfilter/vf_find_rect.c | 37 ++---
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index d7e6579af7..abf7d89d21 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -28,6 +28,7 @@
 #include "internal.h"
 
 #include "lavfutils.h"
+#include "lswsutils.h"
 
 #define MAX_MIPMAPS 5
 
@@ -244,6 +245,7 @@ static av_cold int init(AVFilterContext *ctx)
 {
 FOCContext *foc = ctx->priv;
 int ret, i;
+AVFrame tmp_frame;
 
 if (!foc->obj_filename) {
 av_log(ctx, AV_LOG_ERROR, "object filename not set\n");
@@ -254,24 +256,37 @@ static av_cold int init(AVFilterContext *ctx)
 if (!foc->obj_frame)
 return AVERROR(ENOMEM);
 
-if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize,
- &foc->obj_frame->width, &foc->obj_frame->height,
- &foc->obj_frame->format, foc->obj_filename, ctx)) 
< 0)
-return ret;
-
-if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) {
-av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n");
-return AVERROR(EINVAL);
-}
+if ((ret = ff_load_image(&tmp_frame.data, tmp_frame.linesize,
+ &tmp_frame.width, &tmp_frame.height,
+ &tmp_frame.format, foc->obj_filename, ctx)) < 0)
+goto error;
+
+/* convert object image to gray8 format with same width and height */
+foc->obj_frame->format = AV_PIX_FMT_GRAY8;
+foc->obj_frame->width  = tmp_frame.width;
+foc->obj_frame->height = tmp_frame.height;
+if ((ret = ff_scale_image(foc->obj_frame->data, foc->obj_frame->linesize, 
foc->obj_frame->width, foc->obj_frame->height,
+  foc->obj_frame->format, tmp_frame.data, 
tmp_frame.linesize, tmp_frame.width, tmp_frame.height,
+  tmp_frame.format, ctx)) < 0)
+goto error;
+av_freep(&tmp_frame.data);
 
 foc->needle_frame[0] = av_frame_clone(foc->obj_frame);
 for (i = 1; i < foc->mipmaps; i++) {
 foc->needle_frame[i] = downscale(foc->needle_frame[i-1]);
-if (!foc->needle_frame[i])
-return AVERROR(ENOMEM);
+if (!foc->needle_frame[i]) {
+ret = AVERROR(ENOMEM);
+goto error;
+}
 }
 
 return 0;
+error:
+if (foc->obj_frame)
+av_freep(&foc->obj_frame->data[0]);
+av_frame_free(&foc->obj_frame);
+return ret;
+
 }
 
 static const AVFilterPad foc_inputs[] = {
-- 
2.21.0

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

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

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-05 Thread Lance Wang
OK,  I'll update the doc/filters.texi for the new option for the update
patch.  Thanks for the feedback.

On Thu, Jun 6, 2019 at 2:19 PM Liu Steven  wrote:

>
>
> > 在 2019年6月6日,下午2:06,Lance Wang  写道:
> >
> > On Sun, May 26, 2019 at 8:08 AM  wrote:
> >
> >> From: Limin Wang 
> >>
> >> The test ffmpeg command in iMAC system:
> >> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
> >> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
> >> Now I have tested with yuv420p10 overlay and check the result is OK,
> >> please help to test with your condition.
> >> ---
> >> libavfilter/vf_overlay.c | 42 +++-
> >> libavfilter/vf_overlay.h |  1 +
> >> 2 files changed, 42 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> >> index 2d06074f15..e708d525e5 100644
> >> --- a/libavfilter/vf_overlay.c
> >> +++ b/libavfilter/vf_overlay.c
> >> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx,
> const
> >> char *cmd, const char *ar
> >> }
> >>
> >> static const enum AVPixelFormat alpha_pix_fmts[] = {
> >> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
> >> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
> >> AV_PIX_FMT_YUVA444P,
> >> AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
> >> AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
> >> };
> >> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
> >> AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
> >> };
> >>
> >> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
> >> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
> >> +AV_PIX_FMT_NONE
> >> +};
> >> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
> >> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
> >> +};
> >> +
> >> static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
> >> AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
> >> AV_PIX_FMT_NONE
> >> };
> >> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
> >> goto fail;
> >> }
> >> break;
> >> +case OVERLAY_FORMAT_YUV420P10:
> >> +if (!(main_formats=
> >> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
> >> +!(overlay_formats =
> >> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
> >> +ret = AVERROR(ENOMEM);
> >> +goto fail;
> >> +}
> >> +break;
> >> case OVERLAY_FORMAT_YUV422:
> >> if (!(main_formats=
> >> ff_make_format_list(main_pix_fmts_yuv422)) ||
> >> !(overlay_formats =
> >> ff_make_format_list(overlay_pix_fmts_yuv422))) {
> >> @@ -565,6 +580,7 @@ static av_always_inline void
> >> blend_plane_##depth##_##nbits##bits(AVFilterContext
> >> }
> >>  \
> >> }
> >> DEFINE_BLEND_PLANE(8, 8);
> >> +DEFINE_BLEND_PLANE(16, 10);
> >>
> >> #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
> >> \
> >> static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
> >> *src, const AVFrame *dst, \
> >> @@ -616,6 +632,7 @@ static inline void
> >> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
> >> }
> >>  \
> >> }
> >> DEFINE_ALPHA_COMPOSITE(8, 8);
> >> +DEFINE_ALPHA_COMPOSITE(16, 10);
> >>
> >> #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
> >> \
> >> static av_always_inline void
> >> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
> >>   \
> >> @@ -646,6 +663,7 @@ static av_always_inline void
> >> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
> >> alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
> >> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
> >> }
> >> DEFINE_BLEND_SLICE_YUV(8, 8);
> >> +DEFINE_BLEND_SLICE_YUV(16, 10);
> >>
> >> static av_always_inline void blend_slice_planar_rgb(AVFilterContext
> *ctx,
> >> AVFrame *dst, const
> >> AVFrame *src,
> >> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext
> *ctx,
> >> void *arg, int jobnr, int n
> >> return 0;
> >> }
> >>
> >> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
> >> jobnr, int nb_jobs)
> >> +{
> >> +OverlayContext *s = ctx->priv;
> >> +ThreadData *td = arg;
> >> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x,
> s->y,
> >> 1, jobnr, nb_jobs);
> >> +return 0;
> >> +}
> >> +
> >> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
> >> jobnr, int nb_jobs)
> >> +{
> >> +OverlayContext *s = ctx->priv;
> >> +ThreadData *td = arg;
> >> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x,
> s->y,
> >> 1, jobnr, nb_jobs);
> >>