Re: [FFmpeg-devel] [PATCH] avfilter/scale.c: factorize ff_scale_eval_dimensions

2019-12-07 Thread Gyan



On 07-12-2019 11:47 pm, Michael Niedermayer wrote:

On Sat, Dec 07, 2019 at 12:08:53PM +0530, Gyan wrote:


  doc/filters.texi |   40 +
  libavfilter/scale.c  |   59 
++-
  libavfilter/scale.h  |   20 ++
  libavfilter/vf_scale.c   |   28 ++--
  libavfilter/vf_scale_cuda.c  |   11 
  libavfilter/vf_scale_npp.c   |   11 
  libavfilter/vf_scale_vaapi.c |   11 
  7 files changed, 144 insertions(+), 36 deletions(-)
f0a65d11857e709ee7cdf862ba108c765c4f5a2f  
v2-0001-avfilter-scale.c-factorize-ff_scale_eval_dimensio.patch
 From 863c6feac1790560f7bdc29358cfcd0e5ee370f6 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 2 Dec 2019 21:11:21 +0530
Subject: [PATCH v2] avfilter/scale.c: factorize ff_scale_eval_dimensions

Adjustment of evaluated values shifted to ff_adjust_scale_dimensions
Shifted code for force_original_aspect_ratio and force_divisble_by from
vf_scale so it is now available for scale_cuda, scale_npp and
scale_vaapi as well.
---
  doc/filters.texi | 40 
  libavfilter/scale.c  | 59 +---
  libavfilter/scale.h  | 20 
  libavfilter/vf_scale.c   | 28 ++---
  libavfilter/vf_scale_cuda.c  | 11 +++
  libavfilter/vf_scale_npp.c   | 11 +++
  libavfilter/vf_scale_vaapi.c | 11 +++
  7 files changed, 144 insertions(+), 36 deletions(-)

The changes should be ok i think.


Will push in a few hours.

Thanks,
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] avformat/matroskadec: Add a fate test for CodecPrivate compression

2019-12-07 Thread James Almer
On 12/7/2019 1:35 PM, Andreas Rheinhardt wrote:
> This test contains a track with zlib compressed CodecPrivate in addition
> to compressed frames; the former was unchecked before.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  tests/fate/matroska.mak| 5 +
>  tests/ref/fate/matroska-zlib-decompression | 5 +
>  2 files changed, 10 insertions(+)
>  create mode 100644 tests/ref/fate/matroska-zlib-decompression
> 
> diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
> index 25f5df82c8..04ac11aea5 100644
> --- a/tests/fate/matroska.mak
> +++ b/tests/fate/matroska.mak
> @@ -12,6 +12,11 @@ fate-matroska-remux: REF = e5457e5fa606d564a54914bd12f426c8
>  FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER VORBIS_PARSER) += 
> fate-matroska-xiph-lacing
>  fate-matroska-xiph-lacing: CMD = framecrc -i 
> $(TARGET_SAMPLES)/mkv/xiph_lacing.mka -c:a copy
>  
> +# This tests that the matroska demuxer supports decompressing
> +# zlib compressed tracks (both the CodecPrivate as well as the actual 
> frames).
> +FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER ZLIB FRAMECRC_MUXER 
> FILE_PROTOCOL PIPE_PROTOCOL) += fate-matroska-zlib-decompression
> +fate-matroska-zlib-decompression: CMD = framecrc -i 
> $(TARGET_SAMPLES)/mkv/subtitle_zlib.mks -c:s copy
> +
>  FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += 
> fate-matroska-spherical-mono
>  fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
> -show_entries stream_side_data_list -select_streams v -v 0 
> $(TARGET_SAMPLES)/mkv/spherical.mkv
>  
> diff --git a/tests/ref/fate/matroska-zlib-decompression 
> b/tests/ref/fate/matroska-zlib-decompression
> new file mode 100644
> index 00..0ea732346a
> --- /dev/null
> +++ b/tests/ref/fate/matroska-zlib-decompression
> @@ -0,0 +1,5 @@
> +#extradata 0:  348, 0x5f625922
> +#tb 0: 1/1000
> +#media_type 0: subtitle
> +#codec_id 0: dvd_subtitle
> +0,   1000,   1000, 1991,  191, 0x52f74934

Pushed (And sample uploaded). Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avfilter/vf_yaepblur: add yaepblur filter

2019-12-07 Thread Tao Zhang
Paul B Mahol  于2019年12月7日周六 下午11:21写道:
>
> On 12/7/19, Tao Zhang  wrote:
> > I'm sorry for the late reply.
> >
> > Paul B Mahol  于2019年12月7日周六 上午2:48写道:
> >>
> >> On 12/5/19, Paul B Mahol  wrote:
> >> > On 12/5/19, Tao Zhang  wrote:
> >> >> Hello everyone,
> >> >> Can I assume this patch is ok if no comments or objections?
> >> >
> >> > Yes, give some time for it to be applied.
> >> > I'm busy with other stuff right now. So this patch LGTM (Note to
> >> > committer to bump minor of libavfiter upon pushing).
> >>
> >> I do not get anywhere near output of this filter with either
> >> avgblur/gblur/boxblur?
> >>
> >> How should output of this filter look like?
> > Assume keeping planes and radius unchanged,
> > 1) the output is near avgblur/boxblur when sigma close to INT_MAX
> > 2) the output is near raw input when sigma close to one, so why not
> > zero? just keep code simple, I need to gurantee the
> > denominator larger than zero
> > 3) the output is local adaptive that means blur stronger on flat area
> > while blur weaker on edge otherwise.
>
> Is there plan to make it faster with SIMD?
Yes, I will work on this.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
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 4/4] avcodec/apedec: Fix undefined integer overflow in decode_array_0000()

2019-12-07 Thread Michael Niedermayer
Fixes: signed integer overflow: -2143289344 - 6246400 cannot be represented in 
type 'int'
Fixes: 
19239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5173755680915456

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

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 2b5bd759f5..ebda288043 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -614,7 +614,7 @@ static void decode_array_(APEContext *ctx, 
GetBitContext *gb,
 return ;
 }
 out[i] = get_rice_ook(>gb, rice->k);
-rice->ksum += out[i] - out[i - 64];
+rice->ksum += out[i] - (unsigned)out[i - 64];
 while (rice->ksum < ksummin) {
 rice->k--;
 ksummin = rice->k ? ksummin >> 1 : 0;
-- 
2.23.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 2/4] avcodec/alac: Fix integer overflow in LPC coefficient adaption

2019-12-07 Thread Michael Niedermayer
Fixes: signed integer overflow: 267693597 * 10 cannot be represented in type 
'int'
Fixes: 
19237/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-5755407700328448

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

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index d08c946249..ea5ab182f9 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -228,7 +228,7 @@ static void lpc_prediction(int32_t *error_buffer, uint32_t 
*buffer_out,
 sign = sign_only(val) * error_sign;
 lpc_coefs[j] -= sign;
 val *= (unsigned)sign;
-error_val -= (val >> lpc_quant) * (j + 1);
+error_val -= (val >> lpc_quant) * (j + 1U);
 }
 }
 }
-- 
2.23.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 3/4] Remove redundant ;

2019-12-07 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavfilter/af_axcorrelate.c | 4 ++--
 libavfilter/vf_drawbox.c | 2 +-
 libavformat/dashdec.c| 2 +-
 libavformat/hlsenc.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavfilter/af_axcorrelate.c b/libavfilter/af_axcorrelate.c
index 861903b0f1..6e9a028716 100644
--- a/libavfilter/af_axcorrelate.c
+++ b/libavfilter/af_axcorrelate.c
@@ -238,11 +238,11 @@ static int activate(AVFilterContext *ctx)
 
 ret = av_audio_fifo_peek(s->fifo[0], (void 
**)s->cache[0]->extended_data, available);
 if (ret < 0)
-return ret;;
+return ret;
 
 ret = av_audio_fifo_peek(s->fifo[1], (void 
**)s->cache[1]->extended_data, available);
 if (ret < 0)
-return ret;;
+return ret;
 
 out = ff_get_audio_buffer(ctx->outputs[0], out_samples);
 if (!out)
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index d71e3af397..2750048bcd 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -292,7 +292,7 @@ static int process_command(AVFilterContext *ctx, const char 
*cmd, const char *ar
 ret = init(ctx);
 if (ret < 0)
 goto end;
-ret = config_input(inlink);;
+ret = config_input(inlink);
 end:
 if (ret < 0) {
 s->x = old_x;
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index d001c5b76d..72ba9605f0 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1934,7 +1934,7 @@ static int reopen_demux_for_component(AVFormatContext *s, 
struct representation
 goto fail;
 
 pls->ctx->flags = AVFMT_FLAG_CUSTOM_IO;
-pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;;
+pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
 pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? 
s->max_analyze_duration : 4 * AV_TIME_BASE;
 ret = av_probe_input_buffer(>pb, _fmt, "", NULL, 0, 0);
 if (ret < 0) {
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 043438368e..fc53c9d654 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -475,7 +475,7 @@ static int flush_dynbuf(VariantStream *vs, int 
*range_length)
 static void reflush_dynbuf(VariantStream *vs, int *range_length)
 {
 // re-open buffer
-avio_write(vs->out, vs->temp_buffer, *range_length);;
+avio_write(vs->out, vs->temp_buffer, *range_length);
 }
 
 #if HAVE_DOS_PATHS
-- 
2.23.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 1/4] avcodec/g729postfilter: Optimize out overflowing multiplication from apply_tilt_comp()

2019-12-07 Thread Michael Niedermayer
Fixes: signed integer overflow: -1114392282 * 2 cannot be represented in type 
'int'
Fixes: 
19236/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G729_fuzzer-5741678938030080

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

diff --git a/libavcodec/g729postfilter.c b/libavcodec/g729postfilter.c
index fc9a8d54cc..ab668594d2 100644
--- a/libavcodec/g729postfilter.c
+++ b/libavcodec/g729postfilter.c
@@ -486,14 +486,14 @@ static int16_t apply_tilt_comp(int16_t* out, int16_t* 
res_pst, int refl_coeff,
 
 if (refl_coeff > 0) {
 gt = (refl_coeff * G729_TILT_FACTOR_PLUS + 0x4000) >> 15;
-fact = 0x4000; // 0.5 in (0.15)
-sh_fact = 15;
+fact = 0x2000; // 0.5 in (0.15)
+sh_fact = 14;
 } else {
 gt = (refl_coeff * G729_TILT_FACTOR_MINUS + 0x4000) >> 15;
-fact = 0x800; // 0.5 in (3.12)
-sh_fact = 12;
+fact = 0x400; // 0.5 in (3.12)
+sh_fact = 11;
 }
-ga = (fact << 15) / av_clip_int16(32768 - FFABS(gt));
+ga = (fact << 16) / av_clip_int16(32768 - FFABS(gt));
 gt >>= 1;
 
 /* Apply tilt compensation filter to signal. */
@@ -503,12 +503,12 @@ static int16_t apply_tilt_comp(int16_t* out, int16_t* 
res_pst, int refl_coeff,
 tmp2 = (gt * res_pst[i-1]) * 2 + 0x4000;
 tmp2 = res_pst[i] + (tmp2 >> 15);
 
-tmp2 = (tmp2 * ga * 2 + fact) >> sh_fact;
+tmp2 = (tmp2 * ga + fact) >> sh_fact;
 out[i] = tmp2;
 }
 tmp2 = (gt * ht_prev_data) * 2 + 0x4000;
 tmp2 = res_pst[0] + (tmp2 >> 15);
-tmp2 = (tmp2 * ga * 2 + fact) >> sh_fact;
+tmp2 = (tmp2 * ga + fact) >> sh_fact;
 out[0] = tmp2;
 
 return tmp;
-- 
2.23.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 2/7] avformat/id3v2: Fix double-free on error

2019-12-07 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> ff_id3v2_parse_priv_dict() uses av_dict_set() with the flags
> AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL. In this case both
> key and value are freed on error (and owned by the destination
> dictionary on success), so that freeing them again on error is a
> double-free and therefore forbidden. But it nevertheless happened.
> 
> Fixes CID 1452489 and 1452421.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/id3v2.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index b43ab1745f..e9843eef9a 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -1263,8 +1263,6 @@ int ff_id3v2_parse_priv_dict(AVDictionary **metadata, 
> ID3v2ExtraMeta **extra_met
>  }
>  
>  if ((ret = av_dict_set(metadata, key, escaped, dict_flags)) < 0) 
> {
> -av_free(key);
> -av_free(escaped);
>  return ret;
>  }
>  }
> 
Ping.

- Andreas
___
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] avutil/buffer: add av_buffer_pool_buffer_get_opaque

2019-12-07 Thread Marton Balint
In order to access the original opaque parameter of a buffer in the buffer
pool. (The buffer pool implementation overrides the normal opaque parameter but
also saves it so it is accessible).

Signed-off-by: Marton Balint 
---
 doc/APIchanges  |  3 +++
 libavutil/buffer.c  |  6 ++
 libavutil/buffer.h  | 13 +
 libavutil/version.h |  4 ++--
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 401c65a753..5b8d801f06 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2019-12-xx - xx - lavu 56.37.100 - buffer.h
+  Add av_buffer_pool_buffer_get_opaque().
+
 2019-11-17 - 1c23abc88f - lavu 56.36.100 - eval API
   Add av_expr_count_vars().
 
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index f0034b026a..ec00fb22ec 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -355,3 +355,9 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
 
 return ret;
 }
+
+void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref)
+{
+BufferPoolEntry *buf = ref->buffer->opaque;
+return buf->opaque;
+}
diff --git a/libavutil/buffer.h b/libavutil/buffer.h
index 73b6bd0b14..e0f94314f4 100644
--- a/libavutil/buffer.h
+++ b/libavutil/buffer.h
@@ -284,6 +284,19 @@ void av_buffer_pool_uninit(AVBufferPool **pool);
  */
 AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
 
+/**
+ * Query the original opaque parameter of an allocated buffer in the pool.
+ *
+ * @param ref a buffer reference to a buffer returned by av_buffer_pool_get.
+ * @return the opaque parameter set by the buffer allocator function of the
+ * buffer pool.
+ *
+ * @note the opaque parameter of ref is used by the buffer pool implementation,
+ * therefore you have to use this function to access the original opaque
+ * parameter of an allocated buffer.
+ */
+void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref);
+
 /**
  * @}
  */
diff --git a/libavutil/version.h b/libavutil/version.h
index e18163388d..4de0fa1fc3 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,8 +79,8 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  36
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MINOR  37
+#define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
-- 
2.16.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 2/2] avdevice/xcbgrab: use a buffer pool for shared memory segments

2019-12-07 Thread Marton Balint
Also by wrapping the SHM buffer in an AVBufferRef we eliminate yet another
possible memcpy improving performance.

Signed-off-by: Marton Balint 
---
 libavdevice/xcbgrab.c | 79 ++-
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 158f381c04..82ea09ca96 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -49,13 +49,11 @@
 typedef struct XCBGrabContext {
 const AVClass *class;
 
-uint8_t *buffer;
-
 xcb_connection_t *conn;
 xcb_screen_t *screen;
 xcb_window_t window;
 #if CONFIG_LIBXCB_SHM
-xcb_shm_seg_t segment;
+AVBufferPool *shm_pool;
 #endif
 int64_t time_frame;
 AVRational time_base;
@@ -231,31 +229,35 @@ static int check_shm(xcb_connection_t *conn)
 return 0;
 }
 
-static int allocate_shm(AVFormatContext *s)
+static void free_shm_buffer(void *opaque, uint8_t *data)
 {
-XCBGrabContext *c = s->priv_data;
-int size = c->frame_size + AV_INPUT_BUFFER_PADDING_SIZE;
+shmdt(data);
+}
+
+static AVBufferRef *allocate_shm_buffer(void *opaque, int size)
+{
+xcb_connection_t *conn = opaque;
+xcb_shm_seg_t segment;
+AVBufferRef *ref;
 uint8_t *data;
 int id;
 
-if (c->buffer)
-return 0;
 id = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777);
-if (id == -1) {
-char errbuf[1024];
-int err = AVERROR(errno);
-av_strerror(err, errbuf, sizeof(errbuf));
-av_log(s, AV_LOG_ERROR, "Cannot get %d bytes of shared memory: %s.\n",
-   size, errbuf);
-return err;
-}
-xcb_shm_attach(c->conn, c->segment, id, 0);
+if (id == -1)
+return NULL;
+
+segment = xcb_generate_id(conn);
+xcb_shm_attach(conn, segment, id, 0);
 data = shmat(id, NULL, 0);
 shmctl(id, IPC_RMID, 0);
 if ((intptr_t)data == -1 || !data)
-return AVERROR(errno);
-c->buffer = data;
-return 0;
+return NULL;
+
+ref = av_buffer_create(data, size, free_shm_buffer, (void 
*)(ptrdiff_t)segment, 0);
+if (!ref)
+shmdt(data);
+
+return ref;
 }
 
 static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
@@ -265,15 +267,19 @@ static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket 
*pkt)
 xcb_shm_get_image_reply_t *img;
 xcb_drawable_t drawable = c->screen->root;
 xcb_generic_error_t *e = NULL;
-int ret;
+AVBufferRef *buf;
+xcb_shm_seg_t segment;
 
-ret = allocate_shm(s);
-if (ret < 0)
-return ret;
+buf = av_buffer_pool_get(c->shm_pool);
+if (!buf) {
+av_log(s, AV_LOG_ERROR, "Could not get shared memory buffer.\n");
+return AVERROR(ENOMEM);
+}
+segment = (xcb_shm_seg_t)av_buffer_pool_buffer_get_opaque(buf);
 
 iq = xcb_shm_get_image(c->conn, drawable,
c->x, c->y, c->width, c->height, ~0,
-   XCB_IMAGE_FORMAT_Z_PIXMAP, c->segment, 0);
+   XCB_IMAGE_FORMAT_Z_PIXMAP, segment, 0);
 img = xcb_shm_get_image_reply(c->conn, iq, );
 
 xcb_flush(c->conn);
@@ -287,12 +293,16 @@ static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket 
*pkt)
e->sequence, e->resource_id, e->minor_code, e->major_code);
 
 free(e);
+av_buffer_unref();
 return AVERROR(EACCES);
 }
 
 free(img);
 
-pkt->data = c->buffer;
+av_init_packet(pkt);
+
+pkt->buf = buf;
+pkt->data = buf->data;
 pkt->size = c->frame_size;
 
 return 0;
@@ -425,8 +435,10 @@ static int xcbgrab_read_packet(AVFormatContext *s, 
AVPacket *pkt)
 xcbgrab_update_region(s);
 
 #if CONFIG_LIBXCB_SHM
-if (c->has_shm && xcbgrab_frame_shm(s, pkt) < 0)
+if (c->has_shm && xcbgrab_frame_shm(s, pkt) < 0) {
+av_log(s, AV_LOG_WARNING, "Continuing without shared memory.\n");
 c->has_shm = 0;
+}
 #endif
 if (!c->has_shm)
 ret = xcbgrab_frame(s, pkt);
@@ -447,9 +459,7 @@ static av_cold int xcbgrab_read_close(AVFormatContext *s)
 XCBGrabContext *ctx = s->priv_data;
 
 #if CONFIG_LIBXCB_SHM
-if (ctx->buffer) {
-shmdt(ctx->buffer);
-}
+av_buffer_pool_uninit(>shm_pool);
 #endif
 
 xcb_disconnect(ctx->conn);
@@ -515,6 +525,12 @@ static int pixfmt_from_pixmap_format(AVFormatContext *s, 
int depth,
 if (*pix_fmt) {
 c->bpp= fmt->bits_per_pixel;
 c->frame_size = c->width * c->height * fmt->bits_per_pixel / 8;
+#if CONFIG_LIBXCB_SHM
+c->shm_pool = av_buffer_pool_init2(c->frame_size + 
AV_INPUT_BUFFER_PADDING_SIZE,
+   c->conn, allocate_shm_buffer, 
NULL);
+if (!c->shm_pool)
+return AVERROR(ENOMEM);
+#endif
 return 0;
 }
 
@@ -680,8 +696,7 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
 }
 
 #if CONFIG_LIBXCB_SHM
-if ((c->has_shm = 

Re: [FFmpeg-devel] [PATCH 001/244] Add a new channel layout API

2019-12-07 Thread Nicolas George
Anton Khirnov (12019-12-06):
> The new API is more extensible and allows for custom layouts.
> More accurate information is exported, eg for decoders that do not
> set a channel layout, lavc will not make one up for them.
> 
> Deprecate the old API working with just uint64_t bitmasks.
> 
> Expanded and completed by Vittorio Giovara .
> Signed-off-by: Vittorio Giovara 
> ---
>  libavutil/channel_layout.c | 393 +--
>  libavutil/channel_layout.h | 415 ++---
>  libavutil/version.h|   3 +
>  3 files changed, 719 insertions(+), 92 deletions(-)

Thanks for sending this here. I will make a few preliminary remarks
below.

Before that, I want to mention I think the real trial for this API will
be integration with libavfilter, especially the format negotiation and
the user interface of the filters that allow fine control of channels.
The negotiation, in particular, promises to be an interesting
algorithmic problem. By "real trial", I mean that it is very possible
that trying to implement that will make us realize some details need to
be changed. I have these questions in mind while writing my comments.

Two important comments to consider, because they affect the structure of
the API itself:

- about av_channel_layout_describe(), a general reflection on functions
  that return strings;

- about getting a channel by name.

> 
> diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
> index 3bd5ee29b7..b7077ed5fd 100644
> --- a/libavutil/channel_layout.c
> +++ b/libavutil/channel_layout.c
> @@ -37,75 +37,89 @@ struct channel_name {
>  };
>  
>  static const struct channel_name channel_names[] = {
> - [0] = { "FL","front left"},
> - [1] = { "FR","front right"   },
> - [2] = { "FC","front center"  },
> - [3] = { "LFE",   "low frequency" },
> - [4] = { "BL","back left" },
> - [5] = { "BR","back right"},
> - [6] = { "FLC",   "front left-of-center"  },
> - [7] = { "FRC",   "front right-of-center" },
> - [8] = { "BC","back center"   },
> - [9] = { "SL","side left" },
> -[10] = { "SR","side right"},
> -[11] = { "TC","top center"},
> -[12] = { "TFL",   "top front left"},
> -[13] = { "TFC",   "top front center"  },
> -[14] = { "TFR",   "top front right"   },
> -[15] = { "TBL",   "top back left" },
> -[16] = { "TBC",   "top back center"   },
> -[17] = { "TBR",   "top back right"},
> -[29] = { "DL","downmix left"  },
> -[30] = { "DR","downmix right" },
> -[31] = { "WL","wide left" },
> -[32] = { "WR","wide right"},
> -[33] = { "SDL",   "surround direct left"  },
> -[34] = { "SDR",   "surround direct right" },
> -[35] = { "LFE2",  "low frequency 2"   },
> +[AV_CHAN_FRONT_LEFT   ] = { "FL","front left"
> },
> +[AV_CHAN_FRONT_RIGHT  ] = { "FR","front right"   
> },
> +[AV_CHAN_FRONT_CENTER ] = { "FC","front center"  
> },
> +[AV_CHAN_LOW_FREQUENCY] = { "LFE",   "low frequency" 
> },
> +[AV_CHAN_BACK_LEFT] = { "BL","back left" 
> },
> +[AV_CHAN_BACK_RIGHT   ] = { "BR","back right"
> },
> +[AV_CHAN_FRONT_LEFT_OF_CENTER ] = { "FLC",   "front left-of-center"  
> },
> +[AV_CHAN_FRONT_RIGHT_OF_CENTER] = { "FRC",   "front right-of-center" 
> },
> +[AV_CHAN_BACK_CENTER  ] = { "BC","back center"   
> },
> +[AV_CHAN_SIDE_LEFT] = { "SL","side left" 
> },
> +[AV_CHAN_SIDE_RIGHT   ] = { "SR","side right"
> },
> +[AV_CHAN_TOP_CENTER   ] = { "TC","top center"
> },
> +[AV_CHAN_TOP_FRONT_LEFT   ] = { "TFL",   "top front left"
> },
> +[AV_CHAN_TOP_FRONT_CENTER ] = { "TFC",   "top front center"  
> },
> +[AV_CHAN_TOP_FRONT_RIGHT  ] = { "TFR",   "top front right"   
> },
> +[AV_CHAN_TOP_BACK_LEFT] = { "TBL",   "top back left" 
> },
> +[AV_CHAN_TOP_BACK_CENTER  ] = { "TBC",   "top back center"   
> },
> +[AV_CHAN_TOP_BACK_RIGHT   ] = { "TBR",   "top back right"
> },
> +[AV_CHAN_STEREO_LEFT  ] = { "DL","downmix left"  
> },
> +[AV_CHAN_STEREO_RIGHT ] = { "DR","downmix right" 
> },
> +[AV_CHAN_WIDE_LEFT] = { "WL","wide left" 
> },
> +[AV_CHAN_WIDE_RIGHT   ] = { "WR","wide right"
> },
> +

Re: [FFmpeg-devel] [PATCH] tools/target_dec_fuzzer: set request_channel_layout

2019-12-07 Thread Michael Niedermayer
On Fri, Dec 06, 2019 at 08:31:09PM -0300, James Almer wrote:
> On 12/6/2019 8:08 PM, Michael Niedermayer wrote:
> > On Fri, Dec 06, 2019 at 11:56:13AM -0300, James Almer wrote:
> >> Should increase coverage of some decoders.
> >>
> >> Signed-off-by: James Almer 
> >> ---
> >> Passing 6 to av_get_default_channel_layout() will return the 5.1 layout but
> >> never 5.1(side), which is for example what the dts decoder actually looks 
> >> for.
> >> Any suggestion on how to make the fuzzer pick one of the non default 
> >> layouts
> >> using a given amount of channels?
> > 
> > did you try:
> > 
> > diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> > index 691a79329f..d53dccdcf5 100644
> > --- a/tools/target_dec_fuzzer.c
> > +++ b/tools/target_dec_fuzzer.c
> > @@ -212,6 +212,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> > size) {
> >  ctx->codec_tag  = 
> > bytestream2_get_le32();
> >  keyframes   = 
> > bytestream2_get_le64();
> >  flushpattern= 
> > bytestream2_get_le64();
> > +ctx->request_channel_layout = 
> > bytestream2_get_le64();
> 
> I guess it'll going to get a hit at some point whereas my approach will
> not, so LGTM.

will apply (unless i see some problem before)

thanks

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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] MAINTAINERS: add myself as libxavs2 maintainer

2019-12-07 Thread Michael Niedermayer
On Sat, Oct 12, 2019 at 09:28:44AM +0800, hwren wrote:
> From: hwrenx 
> 
> Signed-off-by: hwrenx 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)

will apply

thanks

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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] avfilter/scale.c: factorize ff_scale_eval_dimensions

2019-12-07 Thread Michael Niedermayer
On Sat, Dec 07, 2019 at 12:08:53PM +0530, Gyan wrote:
> 
> 
> On 07-12-2019 12:36 am, Michael Niedermayer wrote:
> >On Wed, Dec 04, 2019 at 02:14:35PM +0530, Gyan wrote:
> >>Will help reduce code duplication when adding animation support to vf_scale.
> >>See Michael's last comment in https://patchwork.ffmpeg.org/patch/16272/
> >>
> >>Gyan
> >>  doc/filters.texi |   40 +
> >>  libavfilter/scale.c  |   59 
> >> ++-
> >>  libavfilter/scale.h  |4 ++
> >>  libavfilter/vf_scale.c   |   28 ++--
> >>  libavfilter/vf_scale_cuda.c  |   11 
> >>  libavfilter/vf_scale_npp.c   |   11 
> >>  libavfilter/vf_scale_vaapi.c |   11 
> >>  7 files changed, 128 insertions(+), 36 deletions(-)
> >>380bf799c14d6286cc625afe019aa553614a7d53  
> >>0001-avfilter-scale.c-factorize-ff_scale_eval_dimensions.patch
> >> From 138a8dba766674a1b017614c58fa99aeca98e9e5 Mon Sep 17 00:00:00 2001
> >>From: Gyan Doshi 
> >>Date: Mon, 2 Dec 2019 21:11:21 +0530
> >>Subject: [PATCH] avfilter/scale.c: factorize ff_scale_eval_dimensions
> >>
> >>Adjustment of evaluated values shifted to ff_adjust_scale_dimensions
> >>Shifted code for force_original_aspect_ratio and force_divisble_by from
> >>vf_scale so it is now available for scale_cuda, scale_npp and
> >>scale_vaapi as well.
> >>---
> >>  doc/filters.texi | 40 
> >>  libavfilter/scale.c  | 59 +---
> >>  libavfilter/scale.h  |  4 +++
> >>  libavfilter/vf_scale.c   | 28 ++---
> >>  libavfilter/vf_scale_cuda.c  | 11 +++
> >>  libavfilter/vf_scale_npp.c   | 11 +++
> >>  libavfilter/vf_scale_vaapi.c | 11 +++
> >>  7 files changed, 128 insertions(+), 36 deletions(-)
> >>
> >>diff --git a/doc/filters.texi b/doc/filters.texi
> >>index 5fdec6f015..9129f7e3a5 100644
> >>--- a/doc/filters.texi
> >>+++ b/doc/filters.texi
> >>@@ -16210,6 +16210,46 @@ Supersampling
> >>  @item lanczos
> >>  @end table
> >>+@item force_original_aspect_ratio
> >>+Enable decreasing or increasing output video width or height if necessary 
> >>to
> >>+keep the original aspect ratio. Possible values:
> >>+
> >>+@table @samp
> >>+@item disable
> >>+Scale the video as specified and disable this feature.
> >>+
> >>+@item decrease
> >>+The output video dimensions will automatically be decreased if needed.
> >>+
> >>+@item increase
> >>+The output video dimensions will automatically be increased if needed.
> >>+
> >>+@end table
> >>+
> >>+One useful instance of this option is that when you know a specific 
> >>device's
> >>+maximum allowed resolution, you can use this to limit the output video to
> >>+that, while retaining the aspect ratio. For example, device A allows
> >>+1280x720 playback, and your video is 1920x800. Using this option (set it to
> >>+decrease) and specifying 1280x720 to the command line makes the output
> >>+1280x533.
> >>+
> >>+Please note that this is a different thing than specifying -1 for 
> >>@option{w}
> >>+or @option{h}, you still need to specify the output resolution for this 
> >>option
> >>+to work.
> >>+
> >>+@item force_divisible_by
> >>+Ensures that both the output dimensions, width and height, are divisible 
> >>by the
> >>+given integer when used together with 
> >>@option{force_original_aspect_ratio}. This
> >>+works similar to using @code{-n} in the @option{w} and @option{h} options.
> >>+
> >>+This option respects the value set for 
> >>@option{force_original_aspect_ratio},
> >>+increasing or decreasing the resolution accordingly. The video's aspect 
> >>ratio
> >>+may be slightly modified.
> >>+
> >>+This option can be handy if you need to have a video fit within or exceed
> >>+a defined resolution using @option{force_original_aspect_ratio} but also 
> >>have
> >>+encoder restrictions on width or height divisibility.
> >>+
> >>  @end table
> >>  @section scale2ref
> >>diff --git a/libavfilter/scale.c b/libavfilter/scale.c
> >>index eaee95fac6..5e9f97230c 100644
> >>--- a/libavfilter/scale.c
> >>+++ b/libavfilter/scale.c
> >>@@ -111,8 +111,6 @@ int ff_scale_eval_dimensions(void *log_ctx,
> >>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
> >>  const AVPixFmtDescriptor *out_desc = 
> >> av_pix_fmt_desc_get(outlink->format);
> >>  const char *expr;
> >>-int w, h;
> >>-int factor_w, factor_h;
> >>  int eval_w, eval_h;
> >>  int ret;
> >>  const char scale2ref = outlink->src->nb_inputs == 2 && 
> >> outlink->src->inputs[1] == inlink;
> >>@@ -172,8 +170,28 @@ int ff_scale_eval_dimensions(void *log_ctx,
> >>  goto fail;
> >>  eval_w = (int) res == 0 ? inlink->w : (int) res;
> >>-w = eval_w;
> >>-h = eval_h;
> >>+*ret_w = eval_w;
> >>+*ret_h = eval_h;
> >>+
> >>+return 0;
> >>+
> >>+fail:
> >>+av_log(log_ctx, AV_LOG_ERROR,
> >>+   "Error when evaluating the 

Re: [FFmpeg-devel] [PATCH 3/6] avformat/matroskadec: Fix use-after-free when demuxing ProRes

2019-12-07 Thread James Almer
On 12/6/2019 8:16 PM, Andreas Rheinhardt wrote:
> ProRes in Matroska is supposed to not contain the first atom header
> (containing a size field and the tag "icpf") and therefore the Matroska
> demuxer has to recreate it; this involves an allocation and copy, of
> course. Whether the old buffer (containing the data without the atom
> header) needs to be freed or not depends upon whether it is what was
> directly read (in which case it is owned by an AVBuffer) or whether it
> has been allocated when reversing the track's content compression (e.g.
> zlib compression) that Matroska supports.
> 
> So there are three pointers involved: The one pointing to the directly
> read data (owned by the AVBuffer), the one pointing to the currently
> valid data (which coincides with the former if no content compression
> needed to be reverted) and the one pointing to the new data with the
> first atom header. The check for whether to free the second of these is
> simply whether the first two are different.
> 
> This works mostly, but there is a complication: Some muxers don't strip
> the first atom header away and in this case, it is also not reinserted
> and no new buffer is allocated; instead, the second and the third
> pointers agree. In this case, one must never free the second buffer.
> Yet it is currently done if the track is e.g. zlib compressed.
> This commit fixes this.
> 
> This is a regression since b8e75a2a.

Nice find, and somewhat obscure :p

> 
> Signed-off-by: Andreas Rheinhardt 
> ---
> A sample can be easily created by compressing ProRes_FromHaali.mkv
> (see https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3434/) with zlib
> with mkvmerge.

Curious how mkvmerge doesn't remove the atom (if present) when the
source is another Matroska file, but it does when the source is for
example a mov.
Guess it doesn't expect it in Matroska sources taking into account the
spec, so it remuxes everything blindly. But the result is that it
doesn't even make sure the output it creates is compliant. Maybe it
should be reported as a bug?

> 
>  libavformat/matroskadec.c | 11 ---
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 080a839b6a..d1a0a07782 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -3240,11 +3240,8 @@ fail:
>  static int matroska_parse_prores(MatroskaTrack *track, uint8_t *src,
>   uint8_t **pdst, int *size)
>  {
> -uint8_t *dst = src;
> -int dstlen = *size;
> -
> -if (AV_RB32([4]) != MKBETAG('i', 'c', 'p', 'f')) {
> -dstlen += 8;
> +uint8_t *dst;
> +int dstlen = *size + 8;
>  
>  dst = av_malloc(dstlen + AV_INPUT_BUFFER_PADDING_SIZE);
>  if (!dst)
> @@ -3254,7 +3251,6 @@ static int matroska_parse_prores(MatroskaTrack *track, 
> uint8_t *src,
>  AV_WB32(dst + 4, MKBETAG('i', 'c', 'p', 'f'));
>  memcpy(dst + 8, src, dstlen - 8);
>  memset(dst + dstlen, 0, AV_INPUT_BUFFER_PADDING_SIZE);
> -}
>  
>  *pdst = dst;
>  *size = dstlen;
> @@ -3409,7 +3405,8 @@ static int matroska_parse_frame(MatroskaDemuxContext 
> *matroska,
>  pkt_data = wv_data;
>  }
>  
> -if (st->codecpar->codec_id == AV_CODEC_ID_PRORES) {
> +if (st->codecpar->codec_id == AV_CODEC_ID_PRORES &&
> +AV_RB32(pkt_data + 4)  != MKBETAG('i', 'c', 'p', 'f')) {
>  uint8_t *pr_data;
>  res = matroska_parse_prores(track, pkt_data, _data, _size);
>  if (res < 0) {

Added a test and pushed. Thank you.
___
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] avformat/matroskadec: Add a fate test for CodecPrivate compression

2019-12-07 Thread Andreas Rheinhardt
This test contains a track with zlib compressed CodecPrivate in addition
to compressed frames; the former was unchecked before.

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/matroska.mak| 5 +
 tests/ref/fate/matroska-zlib-decompression | 5 +
 2 files changed, 10 insertions(+)
 create mode 100644 tests/ref/fate/matroska-zlib-decompression

diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak
index 25f5df82c8..04ac11aea5 100644
--- a/tests/fate/matroska.mak
+++ b/tests/fate/matroska.mak
@@ -12,6 +12,11 @@ fate-matroska-remux: REF = e5457e5fa606d564a54914bd12f426c8
 FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER VORBIS_PARSER) += 
fate-matroska-xiph-lacing
 fate-matroska-xiph-lacing: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/xiph_lacing.mka -c:a copy
 
+# This tests that the matroska demuxer supports decompressing
+# zlib compressed tracks (both the CodecPrivate as well as the actual frames).
+FATE_MATROSKA-$(call ALLYES, MATROSKA_DEMUXER ZLIB FRAMECRC_MUXER 
FILE_PROTOCOL PIPE_PROTOCOL) += fate-matroska-zlib-decompression
+fate-matroska-zlib-decompression: CMD = framecrc -i 
$(TARGET_SAMPLES)/mkv/subtitle_zlib.mks -c:s copy
+
 FATE_MATROSKA_FFPROBE-$(call ALLYES, MATROSKA_DEMUXER) += 
fate-matroska-spherical-mono
 fate-matroska-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) 
-show_entries stream_side_data_list -select_streams v -v 0 
$(TARGET_SAMPLES)/mkv/spherical.mkv
 
diff --git a/tests/ref/fate/matroska-zlib-decompression 
b/tests/ref/fate/matroska-zlib-decompression
new file mode 100644
index 00..0ea732346a
--- /dev/null
+++ b/tests/ref/fate/matroska-zlib-decompression
@@ -0,0 +1,5 @@
+#extradata 0:  348, 0x5f625922
+#tb 0: 1/1000
+#media_type 0: subtitle
+#codec_id 0: dvd_subtitle
+0,   1000,   1000, 1991,  191, 0x52f74934
-- 
2.20.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] avfilter/vf_yaepblur: add yaepblur filter

2019-12-07 Thread Paul B Mahol
On 12/7/19, Tao Zhang  wrote:
> I'm sorry for the late reply.
>
> Paul B Mahol  于2019年12月7日周六 上午2:48写道:
>>
>> On 12/5/19, Paul B Mahol  wrote:
>> > On 12/5/19, Tao Zhang  wrote:
>> >> Hello everyone,
>> >> Can I assume this patch is ok if no comments or objections?
>> >
>> > Yes, give some time for it to be applied.
>> > I'm busy with other stuff right now. So this patch LGTM (Note to
>> > committer to bump minor of libavfiter upon pushing).
>>
>> I do not get anywhere near output of this filter with either
>> avgblur/gblur/boxblur?
>>
>> How should output of this filter look like?
> Assume keeping planes and radius unchanged,
> 1) the output is near avgblur/boxblur when sigma close to INT_MAX
> 2) the output is near raw input when sigma close to one, so why not
> zero? just keep code simple, I need to gurantee the
> denominator larger than zero
> 3) the output is local adaptive that means blur stronger on flat area
> while blur weaker on edge otherwise.

Is there plan to make it faster with SIMD?
___
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 2/2] avcodec/atrac9dec: Check q_unit_cnt more completely before using it to access at9_tab_band_ext_group

2019-12-07 Thread Michael Niedermayer
On Fri, Dec 06, 2019 at 02:22:32PM +0100, Lynne wrote:
> Dec 3, 2019, 21:23 by mich...@niedermayer.cc:
> 
> > Fixes: index 8 out of bounds for type 'const uint8_t [8][3]'
> > Fixes: 
> > 19127/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ATRAC9_fuzzer-5709394985091072
> >
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> >
> 
> LGTM

will apply

thx

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

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


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] avfilter/vf_yaepblur: add yaepblur filter

2019-12-07 Thread Tao Zhang
I'm sorry for the late reply.

Paul B Mahol  于2019年12月7日周六 上午2:48写道:
>
> On 12/5/19, Paul B Mahol  wrote:
> > On 12/5/19, Tao Zhang  wrote:
> >> Hello everyone,
> >> Can I assume this patch is ok if no comments or objections?
> >
> > Yes, give some time for it to be applied.
> > I'm busy with other stuff right now. So this patch LGTM (Note to
> > committer to bump minor of libavfiter upon pushing).
>
> I do not get anywhere near output of this filter with either
> avgblur/gblur/boxblur?
>
> How should output of this filter look like?
Assume keeping planes and radius unchanged,
1) the output is near avgblur/boxblur when sigma close to INT_MAX
2) the output is near raw input when sigma close to one, so why not
zero? just keep code simple, I need to gurantee the
denominator larger than zero
3) the output is local adaptive that means blur stronger on flat area
while blur weaker on edge otherwise.
>
> >
> >>
> >> Tao Zhang  于2019年12月3日周二 下午5:26写道:
> >>>
> >>> ping:)
> >>>
> >>> leozhang  于2019年11月25日周一 下午5:53写道:
> >>> >
> >>> > Signed-off-by: leozhang 
> >>> > ---
> >>> > This filter blur the input while preserving edges, with slice threads
> >>> > speed up.
> >>> > My test speed is about 100fps on 1080p video with 16 threads, on my
> >>> > test
> >>> > machine whose cpu is E5-2660 v4 2.0GHz using 16 threads.
> >>> > I gauss that i7-9700K 3.6GHz can run faster more.
> >>> > The test command is
> >>> > ffmpeg -s 1920x1080 -r 30 -i your_test_file.yuv -filter_threads 16 -vf
> >>> > yaepblur -f null -
> >>> >
> >>> >  doc/filters.texi  |  22 +++
> >>> >  libavfilter/Makefile  |   1 +
> >>> >  libavfilter/allfilters.c  |   1 +
> >>> >  libavfilter/vf_yaepblur.c | 349
> >>> > ++
> >>> >  4 files changed, 373 insertions(+)
> >>> >  create mode 100644 libavfilter/vf_yaepblur.c
> >>> >
> >>> > diff --git a/doc/filters.texi b/doc/filters.texi
> >>> > index c04421b..61e93d5 100644
> >>> > --- a/doc/filters.texi
> >>> > +++ b/doc/filters.texi
> >>> > @@ -19775,6 +19775,28 @@ Only deinterlace frames marked as interlaced.
> >>> >  The default value is @code{all}.
> >>> >  @end table
> >>> >
> >>> > +@section yaepblur
> >>> > +
> >>> > +Apply blur filter while preserving edges ("yaepblur" means "yet
> >>> > another
> >>> > edge preserving blur filter").
> >>> > +The algorithm is described in
> >>> > +"J. S. Lee, Digital image enhancement and noise filtering by use of
> >>> > local statistics, IEEE Trans. Pattern Anal. Mach. Intell. PAMI-2,
> >>> > 1980."
> >>> > +
> >>> > +It accepts the following parameters:
> >>> > +
> >>> > +@table @option
> >>> > +@item radius, r
> >>> > +Set the window radius. Default value is 3.
> >>> > +
> >>> > +@item planes, p
> >>> > +Set which planes to filter. Default is only the first plane.
> >>> > +
> >>> > +@item sigma, s
> >>> > +Set blur strength. Default value is 128.
> >>> > +@end table
> >>> > +
> >>> > +@subsection Commands
> >>> > +This filter supports same @ref{commands} as options.
> >>> > +
> >>> >  @section zoompan
> >>> >
> >>> >  Apply Zoom & Pan effect.
> >>> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> >>> > index 6838d5c..b490a44 100644
> >>> > --- a/libavfilter/Makefile
> >>> > +++ b/libavfilter/Makefile
> >>> > @@ -442,6 +442,7 @@ OBJS-$(CONFIG_XSTACK_FILTER) +=
> >>> > vf_stack.o framesync.o
> >>> >  OBJS-$(CONFIG_YADIF_FILTER)  += vf_yadif.o
> >>> > yadif_common.o
> >>> >  OBJS-$(CONFIG_YADIF_CUDA_FILTER) += vf_yadif_cuda.o
> >>> > vf_yadif_cuda.ptx.o \
> >>> >  yadif_common.o
> >>> > +OBJS-$(CONFIG_YAEPBLUR_FILTER)   += vf_yaepblur.o
> >>> >  OBJS-$(CONFIG_ZMQ_FILTER)+= f_zmq.o
> >>> >  OBJS-$(CONFIG_ZOOMPAN_FILTER)+= vf_zoompan.o
> >>> >  OBJS-$(CONFIG_ZSCALE_FILTER) += vf_zscale.o
> >>> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> >>> > index 7c1e19e..8f41186 100644
> >>> > --- a/libavfilter/allfilters.c
> >>> > +++ b/libavfilter/allfilters.c
> >>> > @@ -420,6 +420,7 @@ extern AVFilter ff_vf_xmedian;
> >>> >  extern AVFilter ff_vf_xstack;
> >>> >  extern AVFilter ff_vf_yadif;
> >>> >  extern AVFilter ff_vf_yadif_cuda;
> >>> > +extern AVFilter ff_vf_yaepblur;
> >>> >  extern AVFilter ff_vf_zmq;
> >>> >  extern AVFilter ff_vf_zoompan;
> >>> >  extern AVFilter ff_vf_zscale;
> >>> > diff --git a/libavfilter/vf_yaepblur.c b/libavfilter/vf_yaepblur.c
> >>> > new file mode 100644
> >>> > index 000..ef6fbc9
> >>> > --- /dev/null
> >>> > +++ b/libavfilter/vf_yaepblur.c
> >>> > @@ -0,0 +1,349 @@
> >>> > +/*
> >>> > + * Copyright (C) 2019 Leo Zhang 
> >>> > +
> >>> > + * 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
> >>> > + 

[FFmpeg-devel] [PATCH 2/2] avfilter: Fix type in av_log for random_seed in cellauto and life

2019-12-07 Thread Michael Niedermayer
Fixes CID 1456556 / 1456555

Signed-off-by: Michael Niedermayer 
---
 libavfilter/vsrc_cellauto.c | 2 +-
 libavfilter/vsrc_life.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vsrc_cellauto.c b/libavfilter/vsrc_cellauto.c
index c75460334e..6fd812c54f 100644
--- a/libavfilter/vsrc_cellauto.c
+++ b/libavfilter/vsrc_cellauto.c
@@ -199,7 +199,7 @@ static av_cold int init(AVFilterContext *ctx)
 }
 
 av_log(ctx, AV_LOG_VERBOSE,
-   "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d 
seed:%"PRIu32"\n",
+   "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d 
seed:%"PRId64"\n",
s->w, s->h, s->frame_rate.num, s->frame_rate.den,
s->rule, s->stitch, s->scroll, s->start_full,
s->random_seed);
diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c
index 4c0ea73d8a..5932c2395b 100644
--- a/libavfilter/vsrc_life.c
+++ b/libavfilter/vsrc_life.c
@@ -260,7 +260,7 @@ static av_cold int init(AVFilterContext *ctx)
 }
 
 av_log(ctx, AV_LOG_VERBOSE,
-   "s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d 
seed:%"PRIu32"\n",
+   "s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d 
seed:%"PRId64"\n",
life->w, life->h, life->frame_rate.num, life->frame_rate.den,
life->rule_str, life->stay_rule, life->born_rule, life->stitch,
life->random_seed);
-- 
2.23.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 1/2] avcodec/adpcm: Fix overflow in FFABS() IMA_EA_EACS

2019-12-07 Thread Michael Niedermayer
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an 
unsigned type to negate this value to itself
Fixes: 
19235/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_EA_EACS_fuzzer-5680878952382464

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

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index edf7052636..1e23d82629 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -1233,7 +1233,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void 
*data,
 }
 for (i=0; i<=st; i++) {
 c->status[i].predictor  = bytestream2_get_le32u();
-if (FFABS(c->status[i].predictor) > (1<<16))
+if (FFABS((int64_t)c->status[i].predictor) > (1<<16))
 return AVERROR_INVALIDDATA;
 }
 
-- 
2.23.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".