Re: [FFmpeg-devel] [PATCH 2/3] avformat/rawdec: reduce randomness in used identifiers

2020-06-05 Thread Anton Khirnov
Quoting Michael Niedermayer (2020-06-04 01:19:18)
>Subject: avformat/rawdec: reduce randomness in used identifiers

The patch looks ok, but the commit message is not very clear. "fix
identifier names" would be easier to understand IMO.

-- 
Anton Khirnov
___
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 4/4] lavf/tls: verify TLS connections by default whenever possible

2020-06-05 Thread Anton Khirnov
Quoting Moritz Barsnick (2020-06-03 12:32:25)
> On Wed, Jun 03, 2020 at 02:40:53 -0500, Ridley Combs wrote:
> > > Strictly speaking, this is a change in behavior, so I would at least
> > > appreciate a version bump.
> >
> > Reasonable; what level should it be? I'd guess a minor bump? Though
> > traditionally AVOption changes are micro.
> 
> For behavioral changes, and changes to option handling, I am under the
> impression that a micro bump is what is commonly used in libav*, though
> https://ffmpeg.org/developer.html#Code
> says "binary compatible change". Perhaps others can comment.

It's a breaking change, I'd prefer postponing it until a major bump. And
it should be mentioned in APIchanges.

-- 
Anton Khirnov
___
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] pthread_frame: use av_buffer_replace() to simplify code

2020-06-05 Thread Anton Khirnov
---
 libavcodec/pthread_frame.c | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 601f170447..3626e745f5 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -297,16 +297,9 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
 
 dst->hwaccel_flags = src->hwaccel_flags;
 
-if (!!dst->internal->pool != !!src->internal->pool ||
-(dst->internal->pool && dst->internal->pool->data != 
src->internal->pool->data)) {
-av_buffer_unref(&dst->internal->pool);
-
-if (src->internal->pool) {
-dst->internal->pool = av_buffer_ref(src->internal->pool);
-if (!dst->internal->pool)
-return AVERROR(ENOMEM);
-}
-}
+err = av_buffer_replace(&dst->internal->pool, src->internal->pool);
+if (err < 0)
+return err;
 }
 
 if (for_user) {
-- 
2.26.2

___
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] lavu/buffer: add a convenience function for replacing buffers

2020-06-05 Thread Anton Khirnov
A common pattern e.g. in libavcodec is replacing/updating buffer
references: unref old one, ref new one. This function allows simplifying
such code an avoiding unnecessary refs+unrefs if the references are
already equivalent.
---
 doc/APIchanges |  3 +++
 libavutil/buffer.c | 22 ++
 libavutil/buffer.h | 17 +
 3 files changed, 42 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index fb5534b5f5..757d814eee 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2020-xx-xx - xx - lavc 56.50.100 - buffer.h
+  Add a av_buffer_replace() convenience function.
+
 2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
   Move AVCodec-related public API to new header codec.h.
 
diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index 6d9cb7428e..ecd83da9c3 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -216,6 +216,28 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size)
 return 0;
 }
 
+int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src)
+{
+AVBufferRef *dst = *pdst;
+
+if (!src) {
+av_buffer_unref(pdst);
+return !!dst;
+}
+
+if (dst && dst->buffer == src->buffer) {
+/* make sure the data pointers match */
+dst->data = src->data;
+dst->size = src->size;
+return 0;
+}
+
+av_buffer_unref(pdst);
+*pdst = av_buffer_ref(src);
+
+return *pdst ? 1 : AVERROR(ENOMEM);
+}
+
 AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
AVBufferRef* (*alloc)(void *opaque, int 
size),
void (*pool_free)(void *opaque))
diff --git a/libavutil/buffer.h b/libavutil/buffer.h
index e0f94314f4..497dc98c20 100644
--- a/libavutil/buffer.h
+++ b/libavutil/buffer.h
@@ -197,6 +197,23 @@ int av_buffer_make_writable(AVBufferRef **buf);
  */
 int av_buffer_realloc(AVBufferRef **buf, int size);
 
+/**
+ * Ensure dst refers to the same data as src.
+ *
+ * When *dst is already equivalent to src, do nothing. Otherwise unreference 
dst
+ * and replace it with a new reference to src.
+ *
+ * @param dst Pointer to either a valid buffer reference or NULL. On success,
+ *this will point to a buffer reference equivalent to src. On
+ *failure, dst will be unreferenced.
+ * @param src A buffer reference to replace dst with. May be NULL, then this
+ *function is equivalent to av_buffer_unref(dst).
+ * @return 0 if dst was equivalent to src on input and nothing was done
+ * 1 if dst was replaced with a new reference to src
+ * A negative error code on failure.
+ */
+int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src);
+
 /**
  * @}
  */
-- 
2.26.2

___
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] mpegvideo: use av_buffer_replace() to simplify code

2020-06-05 Thread Anton Khirnov
---
 libavcodec/mpegpicture.c | 36 ++--
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 5fce25ec6e..59097fab0c 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -320,30 +320,22 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture 
*pic)
 
 int ff_update_picture_tables(Picture *dst, Picture *src)
 {
- int i;
-
-#define UPDATE_TABLE(table)   \
-do {  \
-if (src->table && \
-(!dst->table || dst->table->buffer != src->table->buffer)) {  \
-av_buffer_unref(&dst->table); \
-dst->table = av_buffer_ref(src->table);   \
-if (!dst->table) {\
-ff_free_picture_tables(dst);  \
-return AVERROR(ENOMEM);   \
-} \
-} \
-} while (0)
+int i, ret;
 
-UPDATE_TABLE(mb_var_buf);
-UPDATE_TABLE(mc_mb_var_buf);
-UPDATE_TABLE(mb_mean_buf);
-UPDATE_TABLE(mbskip_table_buf);
-UPDATE_TABLE(qscale_table_buf);
-UPDATE_TABLE(mb_type_buf);
+ret  = av_buffer_replace(&dst->mb_var_buf,   src->mb_var_buf);
+ret |= av_buffer_replace(&dst->mc_mb_var_buf,src->mc_mb_var_buf);
+ret |= av_buffer_replace(&dst->mb_mean_buf,  src->mb_mean_buf);
+ret |= av_buffer_replace(&dst->mbskip_table_buf, src->mbskip_table_buf);
+ret |= av_buffer_replace(&dst->qscale_table_buf, src->qscale_table_buf);
+ret |= av_buffer_replace(&dst->mb_type_buf,  src->mb_type_buf);
 for (i = 0; i < 2; i++) {
-UPDATE_TABLE(motion_val_buf[i]);
-UPDATE_TABLE(ref_index_buf[i]);
+ret |= av_buffer_replace(&dst->motion_val_buf[i], 
src->motion_val_buf[i]);
+ret |= av_buffer_replace(&dst->ref_index_buf[i],  
src->ref_index_buf[i]);
+}
+
+if (ret < 0) {
+ff_free_picture_tables(dst);
+return ret;
 }
 
 dst->mb_var= src->mb_var;
-- 
2.26.2

___
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] hevcdec: use av_buffer_replace() to simplify code

2020-06-05 Thread Anton Khirnov
---
 libavcodec/hevcdec.c | 36 
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 0772608a30..94fd6f6e0d 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -3420,30 +3420,21 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 if (s->ps.sps != s0->ps.sps)
 s->ps.sps = NULL;
 for (i = 0; i < FF_ARRAY_ELEMS(s->ps.vps_list); i++) {
-av_buffer_unref(&s->ps.vps_list[i]);
-if (s0->ps.vps_list[i]) {
-s->ps.vps_list[i] = av_buffer_ref(s0->ps.vps_list[i]);
-if (!s->ps.vps_list[i])
-return AVERROR(ENOMEM);
-}
+ret = av_buffer_replace(&s->ps.vps_list[i], s0->ps.vps_list[i]);
+if (ret < 0)
+return ret;
 }
 
 for (i = 0; i < FF_ARRAY_ELEMS(s->ps.sps_list); i++) {
-av_buffer_unref(&s->ps.sps_list[i]);
-if (s0->ps.sps_list[i]) {
-s->ps.sps_list[i] = av_buffer_ref(s0->ps.sps_list[i]);
-if (!s->ps.sps_list[i])
-return AVERROR(ENOMEM);
-}
+ret = av_buffer_replace(&s->ps.sps_list[i], s0->ps.sps_list[i]);
+if (ret < 0)
+return ret;
 }
 
 for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++) {
-av_buffer_unref(&s->ps.pps_list[i]);
-if (s0->ps.pps_list[i]) {
-s->ps.pps_list[i] = av_buffer_ref(s0->ps.pps_list[i]);
-if (!s->ps.pps_list[i])
-return AVERROR(ENOMEM);
-}
+ret = av_buffer_replace(&s->ps.pps_list[i], s0->ps.pps_list[i]);
+if (ret < 0)
+return ret;
 }
 
 if (s->ps.sps != s0->ps.sps)
@@ -3468,12 +3459,9 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 s->max_ra = INT_MAX;
 }
 
-av_buffer_unref(&s->sei.a53_caption.buf_ref);
-if (s0->sei.a53_caption.buf_ref) {
-s->sei.a53_caption.buf_ref = 
av_buffer_ref(s0->sei.a53_caption.buf_ref);
-if (!s->sei.a53_caption.buf_ref)
-return AVERROR(ENOMEM);
-}
+ret = av_buffer_replace(&s->sei.a53_caption.buf_ref, 
s0->sei.a53_caption.buf_ref);
+if (ret < 0)
+return ret;
 
 s->sei.frame_packing= s0->sei.frame_packing;
 s->sei.display_orientation  = s0->sei.display_orientation;
-- 
2.26.2

___
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] avutil/buffer: separate public and internal flags inside AVBuffers

2020-06-05 Thread Anton Khirnov
Quoting James Almer (2020-06-01 18:04:35)
> It's better to not mix user provided flags and internal flags set by
> AVBufferRef helper functions.
> 
> Signed-off-by: James Almer 
> ---

Looks ok

-- 
Anton Khirnov
___
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 1/2] avutil/buffer: use the default allocator if none is provided to av_buffer_pool_init2()

2020-06-05 Thread Anton Khirnov
Quoting James Almer (2020-06-01 15:35:07)
> Signed-off-by: James Almer 
> ---
>  doc/APIchanges  | 3 +++
>  libavutil/buffer.c  | 3 +++
>  libavutil/version.h | 2 +-
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 

Looks ok

-- 
Anton Khirnov
___
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 v2] avutil/buffer: avutil/buffer: add a mention that some arguments from av_buffer_pool_init2() may be NULL

2020-06-05 Thread Anton Khirnov
Quoting James Almer (2020-06-01 15:35:08)
> Signed-off-by: James Almer 
> ---
>  libavutil/buffer.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 

Ok

-- 
Anton Khirnov
___
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] add ability to bypass custom video pts generation and use capture filter provided pts

2020-06-05 Thread Dmitry Sinitsyn
From: Dmitry Sinitsyn 

Hello,

This patch is about #8620 issue.
I do not know why initial developer thought that "PTS from video devices is 
unreliable" but nowadays my experience makes me sure that we should use sample 
stream start time as PTS for all types of streams.
But I do not want to break something.
So I propose new parameter to control this behavior with old-style way as 
default

---
 libavdevice/dshow.c | 1 +
 libavdevice/dshow_capture.h | 1 +
 libavdevice/dshow_pin.c | 8 
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index d7f5bd7069..1251fe604f 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -1317,6 +1317,7 @@ static const AVOption options[] = {
 { "audio_device_save", "save audio capture filter device (and properties) 
to file", OFFSET(audio_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 
0, DEC },
 { "video_device_load", "load video capture filter device (and properties) 
from file", OFFSET(video_filter_load_file), AV_OPT_TYPE_STRING, {.str = NULL}, 
0, 0, DEC },
 { "video_device_save", "save video capture filter device (and properties) 
to file", OFFSET(video_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 
0, DEC },
+   { "gen_video_pts", "generate own pts for video stream", 
OFFSET(gen_video_pts), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
 { NULL },
 };
 
diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index 475d62ba99..1298ebc041 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -311,6 +311,7 @@ struct dshow_ctx {
 char *audio_filter_save_file;
 char *video_filter_load_file;
 char *video_filter_save_file;
+int   gen_video_pts;
 
 IBaseFilter *device_filter[2];
 IPin*device_pin[2];
diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c
index 53b1c9150d..c77b3ae2b5 100644
--- a/libavdevice/dshow_pin.c
+++ b/libavdevice/dshow_pin.c
@@ -333,10 +333,13 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, 
IMediaSample *sample)
 if (!sample)
 return E_POINTER;
 
+priv_data = pin->filter->priv_data;
+s = priv_data;
+ctx = s->priv_data;
 IMediaSample_GetTime(sample, &orig_curtime, &dummy);
 orig_curtime += pin->filter->start_time;
 IReferenceClock_GetTime(clock, &graphtime);
-if (devtype == VideoDevice) {
+if (ctx->gen_video_pts && devtype == VideoDevice) {
 /* PTS from video devices is unreliable. */
 IReferenceClock_GetTime(clock, &curtime);
 } else {
@@ -354,9 +357,6 @@ libAVMemInputPin_Receive(libAVMemInputPin *this, 
IMediaSample *sample)
 
 buf_size = IMediaSample_GetActualDataLength(sample);
 IMediaSample_GetPointer(sample, &buf);
-priv_data = pin->filter->priv_data;
-s = priv_data;
-ctx = s->priv_data;
 index = pin->filter->stream_index;
 
 av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size 
%8d "
-- 
2.26.2.windows.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][GSoC]audio filter - Generate algorithmic riff music

2020-06-05 Thread Ashutosh Pradhan
diff --git a/Changelog b/Changelog
index 711c843b99..905b91b570 100644
--- a/Changelog
+++ b/Changelog
@@ -75,7 +75,7 @@ version :
 - PFM decoder
 - dblur video filter
 - Real War KVAG muxer
-
+- atone filter
 
 version 4.2:
 - tpad filter
diff --git a/configure b/configure
index 8569a60bf8..954e35d62c 100755
--- a/configure
+++ b/configure
@@ -233,6 +233,7 @@ External library support:
and libraw1394 [no]
   --enable-libfdk-aac  enable AAC de/encoding via libfdk-aac [no]
   --enable-libfliteenable flite (voice synthesis) support via libflite 
[no]
+  --enable-libfluidsynth   enable libfluidsynth support for fluidsynth [no]
   --enable-libfontconfig   enable libfontconfig, useful for drawtext filter 
[no]
   --enable-libfreetype enable libfreetype, needed for drawtext filter [no]
   --enable-libfribidi  enable libfribidi, improves drawtext filter [no]
@@ -1772,6 +1773,7 @@ EXTERNAL_LIBRARY_LIST="
 libdc1394
 libdrm
 libflite
+libfluidsynth
 libfontconfig
 libfreetype
 libfribidi
@@ -3484,6 +3486,7 @@ asr_filter_deps="pocketsphinx"
 ass_filter_deps="libass"
 atempo_filter_deps="avcodec"
 atempo_filter_select="rdft"
+atone_filter_deps="libfluidsynth"
 avgblur_opencl_filter_deps="opencl"
 avgblur_vulkan_filter_deps="vulkan libglslang"
 azmq_filter_deps="libzmq"
@@ -6304,6 +6307,7 @@ enabled libfdk_aac&& { check_pkg_config 
libfdk_aac fdk-aac "fdk-aac/aace
  warn "using libfdk without pkg-config"; } }
 flite_extralibs="-lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal 
-lflite_cmu_us_kal16 -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish 
-lflite_cmulex -lflite"
 enabled libflite  && require libflite "flite/flite.h" flite_init 
$flite_extralibs
+enabled libfluidsynth && require_pkg_config libfluidsynth fluidsynth 
"fluidsynth.h" fluid_log
 enabled fontconfig&& enable libfontconfig
 enabled libfontconfig && require_pkg_config libfontconfig fontconfig 
"fontconfig/fontconfig.h" FcInit
 enabled libfreetype   && require_pkg_config libfreetype freetype2 
"ft2build.h FT_FREETYPE_H" FT_Init_FreeType
diff --git a/doc/filters.texi b/doc/filters.texi
index f76604c51e..fc34f76bee 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -6125,6 +6125,62 @@ anoisesrc=d=60:c=pink:r=44100:a=0.5
 @end example
 @end itemize
 
+@section atone
+
+Generate algorithmic riff music.
+To compile filter configure ffmpeg with @code{--enable-libfluidsynth} 
+
+The filter accepts the following options:
+
+@table @option
+@item sample_rate, r
+Specify the sample rate. Default value is 44100 Hz.
+
+@item sfont
+Specify the location of soundfont file. Default value is 
+"/usr/share/sounds/sf2/FluidR3_GM.sf2"(for linux).
+
+@item duration, d
+Specify the duration of the generated audio stream. Not specifying this option
+results in playing tones for infinite length.
+
+@item velocity, v
+Specify the velocity of key press. Default value is 80.
+
+@item percussion_velocity
+Specify the velocity of key press for percussion track. Default value is 127.
+
+@item bpm
+Specify the beats per minute. Default is 100.
+
+@item instrument
+Specify the instrument. Available instruments are Acoustic-Grand, 
+Bright-Acoustic, ... as defined in the General Midi specifications. Default is 
Trumpet.
+
+@item percussion
+Specify the percussion track for beats. Available options are Jazz1, 
+Jazz2, ..., Jazz6, Rock1...4, Shuffle, Metronome. Default is Metronome.
+
+@item numbars
+Set the number of bars in which riff energy will change between 0 to 8. 
Default is 2.
+
+@item samples_per_frame
+Set the number of samples per each output frame. Default is 1024.
+@end table
+
+@subsection Examples
+
+@itemize
+
+@item
+Generate 10 seconds of riff music, with a key velocity of 100, instrument as 
Electric Guitar(jazz) 
+and percussion track as Jazz3:
+@example
+atone=d=10:v=100:sfont="example.sf2":instrument=Electric-Guitar-Jazz:percussion=Jazz3
+atone=duration=10:velocity=100:sfont="example.sf2":instrument=Electric-Guitar-Jazz:percussion=Jazz3
+@end example
+@end itemize
+
 @section hilbert
 
 Generate odd-tap Hilbert transform FIR coefficients.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 5123540653..b0938830f2 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -152,6 +152,7 @@ OBJS-$(CONFIG_FLITE_FILTER)  += asrc_flite.o
 OBJS-$(CONFIG_HILBERT_FILTER)+= asrc_hilbert.o
 OBJS-$(CONFIG_SINC_FILTER)   += asrc_sinc.o
 OBJS-$(CONFIG_SINE_FILTER)   += asrc_sine.o
+OBJS-$(CONFIG_ATONE_FILTER)  += asrc_atone.o
 
 OBJS-$(CONFIG_ANULLSINK_FILTER)  += asink_anullsink.o
 
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 1183e40267..90f266a2d9 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -146,6 +146,7 @@ extern AVFilter ff_asrc_flite;
 extern AVFilter ff

Re: [FFmpeg-devel] [PATCH 1/4] lavu/buffer: add a convenience function for replacing buffers

2020-06-05 Thread James Almer
On 6/5/2020 7:02 AM, Anton Khirnov wrote:
> A common pattern e.g. in libavcodec is replacing/updating buffer
> references: unref old one, ref new one. This function allows simplifying
> such code an avoiding unnecessary refs+unrefs if the references are
> already equivalent.
> ---
>  doc/APIchanges |  3 +++
>  libavutil/buffer.c | 22 ++
>  libavutil/buffer.h | 17 +
>  3 files changed, 42 insertions(+)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index fb5534b5f5..757d814eee 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil: 2017-10-21
>  
>  API changes, most recent first:
>  
> +2020-xx-xx - xx - lavc 56.50.100 - buffer.h
> +  Add a av_buffer_replace() convenience function.
> +
>  2020-xx-xx - xx - lavc 58.88.100 - avcodec.h codec.h
>Move AVCodec-related public API to new header codec.h.
>  
> diff --git a/libavutil/buffer.c b/libavutil/buffer.c
> index 6d9cb7428e..ecd83da9c3 100644
> --- a/libavutil/buffer.c
> +++ b/libavutil/buffer.c
> @@ -216,6 +216,28 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size)
>  return 0;
>  }
>  
> +int av_buffer_replace(AVBufferRef **pdst, AVBufferRef *src)
> +{
> +AVBufferRef *dst = *pdst;
> +
> +if (!src) {
> +av_buffer_unref(pdst);
> +return !!dst;
> +}
> +
> +if (dst && dst->buffer == src->buffer) {
> +/* make sure the data pointers match */

Maybe overkill, but if dst->buffer == src->buffer then you could also
add an assert to ensure that src->buffer is not writable.

> +dst->data = src->data;
> +dst->size = src->size;
> +return 0;
> +}
> +

> +av_buffer_unref(pdst);
> +*pdst = av_buffer_ref(src);
> +
> +return *pdst ? 1 : AVERROR(ENOMEM);
> +}

Nit: How about instead something like

newbuf = av_buffer_ref(src);
if (!newbuf)
return AVERROR(ENOMEM);

buffer_replace(pdst, &newbuf);

return 0;

It's IMO cleaner looking, and prevents pdst from being modified on failure.

> +
>  AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
> AVBufferRef* (*alloc)(void *opaque, int 
> size),
> void (*pool_free)(void *opaque))
> diff --git a/libavutil/buffer.h b/libavutil/buffer.h
> index e0f94314f4..497dc98c20 100644
> --- a/libavutil/buffer.h
> +++ b/libavutil/buffer.h
> @@ -197,6 +197,23 @@ int av_buffer_make_writable(AVBufferRef **buf);
>   */
>  int av_buffer_realloc(AVBufferRef **buf, int size);
>  
> +/**
> + * Ensure dst refers to the same data as src.
> + *
> + * When *dst is already equivalent to src, do nothing. Otherwise unreference 
> dst
> + * and replace it with a new reference to src.
> + *
> + * @param dst Pointer to either a valid buffer reference or NULL. On success,
> + *this will point to a buffer reference equivalent to src. On
> + *failure, dst will be unreferenced.
> + * @param src A buffer reference to replace dst with. May be NULL, then this
> + *function is equivalent to av_buffer_unref(dst).
> + * @return 0 if dst was equivalent to src on input and nothing was done
> + * 1 if dst was replaced with a new reference to src

Either of these values mean success, and the user will not really care
if the function was a no-op or a ref (the next three patches are an
example of this). In the end, dst is guaranteed to point to the same
underlying buffer as src as long as the return value is not negative,
regardless of what the function did internally.

This is already the case for av_buffer_make_writable(), where we don't
discriminate between a no-op and a reallocation either, and in other
similar functions (packet, frame, etc), so I'd strongly prefer if we can
keep this consistent.

> + * A negative error code on failure.
> + */
> +int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src);
> +
>  /**
>   * @}
>   */
> 

___
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] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions

2020-06-05 Thread Max Dmitrichenko
On Mon, May 25, 2020 at 12:40 AM Soft Works  wrote:

> These are:
> - Dimensions are already aligned (e.g. 1920x800)
> - No scaling is done
> - Color format conversion (e.g. 10bit to 8bit)
>
> Example command:
> ffmpeg -c:v hevc_qsv -hwaccel qsv -i hevc_10bit_1920_800.mkv
> -filter_complex "scale_qsv=format=nv12" -c:v h264_qsv out.mkv
>
> Fix:
> - Increase the frame height to the next alignment value
>
> V2:
> - removed empty line
> - removed duplicated line
> ---
>  libavfilter/qsvvpp.c   | 7 ++-
>  libavfilter/vf_scale_qsv.c | 9 -
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 1bbb7a7e68..98d2353d1c 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -420,6 +420,7 @@ static int init_vpp_session(AVFilterContext *avctx,
> QSVVPPContext *s)
>  mfxHandleType handle_type;
>  mfxVersion ver;
>  mfxIMPL impl;
> +int height_align_adjust = 0;
>  int ret, i;
>
>  if (inlink->hw_frames_ctx) {
> @@ -463,9 +464,13 @@ static int init_vpp_session(AVFilterContext *avctx,
> QSVVPPContext *s)
>  out_frames_ctx   = (AVHWFramesContext *)out_frames_ref->data;
>  out_frames_hwctx = out_frames_ctx->hwctx;
>
> +/* work around a bug in MSDK where VPP processing hangs under
> certain conditions */
> +if (inlink->h == outlink->h)
> +height_align_adjust = 1;
> +
>  out_frames_ctx->format= AV_PIX_FMT_QSV;
>  out_frames_ctx->width = FFALIGN(outlink->w, 32);
> -out_frames_ctx->height= FFALIGN(outlink->h, 32);
> +out_frames_ctx->height= FFALIGN(outlink->h +
> height_align_adjust, 32);
>  out_frames_ctx->sw_format = s->out_sw_format;
>  out_frames_ctx->initial_pool_size = 64;
>  if (avctx->extra_hw_frames > 0)
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> index 5259104a4f..303d2101a9 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -181,8 +181,10 @@ static int init_out_pool(AVFilterContext *ctx,
>  AVQSVFramesContext *out_frames_hwctx;
>  enum AVPixelFormat in_format;
>  enum AVPixelFormat out_format;
> +int height_align_adjust = 0;
>  int i, ret;
>
>  /* check that we have a hw context */
>  if (!ctx->inputs[0]->hw_frames_ctx) {
>  av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
> @@ -191,6 +193,7 @@ static int init_out_pool(AVFilterContext *ctx,
>  in_frames_ctx   =
> (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
>  in_frames_hwctx = in_frames_ctx->hwctx;
>
>  in_format = in_frames_ctx->sw_format;
>  out_format= (s->format == AV_PIX_FMT_NONE) ? in_format :
> s->format;
>
> @@ -200,9 +203,13 @@ static int init_out_pool(AVFilterContext *ctx,
>  out_frames_ctx   = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
>  out_frames_hwctx = out_frames_ctx->hwctx;
>
> +/* work around a bug in MSDK where VPP processing hangs under certain
> conditions */
> +if (in_frames_ctx->height == out_height)
> +height_align_adjust = 1;
> +
>  out_frames_ctx->format= AV_PIX_FMT_QSV;
>  out_frames_ctx->width = FFALIGN(out_width,  16);
> -out_frames_ctx->height= FFALIGN(out_height, 16);
> +out_frames_ctx->height= FFALIGN(out_height +
> height_align_adjust, 16);
>  out_frames_ctx->sw_format = out_format;
>  out_frames_ctx->initial_pool_size = 4;
>
> --
> 2.26.2.windows.1
>
>
patch seems to be manually edited and cannot be applied automatically.

During my tests, I couldn't see any change of behavior with and without
patch,
more details needed for patch justification.

regards
Max
___
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 v4 3/3] fate: add yuv420p10 and yuv422p10 tests for overlay filter

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

Signed-off-by: Limin Wang 
---
 tests/fate/filter-video.mak | 8 
 tests/filtergraphs/overlay_yuv420p10| 5 +
 tests/filtergraphs/overlay_yuv422p10| 5 +
 tests/ref/fate/filter-overlay_yuv420p10 | 8 
 tests/ref/fate/filter-overlay_yuv422p10 | 8 
 5 files changed, 34 insertions(+)
 create mode 100644 tests/filtergraphs/overlay_yuv420p10
 create mode 100644 tests/filtergraphs/overlay_yuv422p10
 create mode 100644 tests/ref/fate/filter-overlay_yuv420p10
 create mode 100644 tests/ref/fate/filter-overlay_yuv422p10

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index cfeb53e..def6079 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -223,6 +223,10 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER 
SCALE_FILTER PAD_FILTER OVERLAY_F
 fate-filter-overlay_yuv420: tests/data/filtergraphs/overlay_yuv420
 fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420
 
+FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER 
OVERLAY_FILTER) += fate-filter-overlay_yuv420p10
+fate-filter-overlay_yuv420p10: tests/data/filtergraphs/overlay_yuv420p10
+fate-filter-overlay_yuv420p10: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420p10 
-frames:v 3
+
 FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER 
OVERLAY_FILTER) += fate-filter-overlay_nv12
 fate-filter-overlay_nv12: tests/data/filtergraphs/overlay_nv12
 fate-filter-overlay_nv12: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv12
@@ -237,6 +241,10 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER 
SCALE_FILTER PAD_FILTER OVERLAY_F
 fate-filter-overlay_yuv422: tests/data/filtergraphs/overlay_yuv422
 fate-filter-overlay_yuv422: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422
 
+FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER 
OVERLAY_FILTER) += fate-filter-overlay_yuv422p10
+fate-filter-overlay_yuv422p10: tests/data/filtergraphs/overlay_yuv422p10
+fate-filter-overlay_yuv422p10: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422p10 
-frames:v 3
+
 FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER 
OVERLAY_FILTER) += fate-filter-overlay_yuv444
 fate-filter-overlay_yuv444: tests/data/filtergraphs/overlay_yuv444
 fate-filter-overlay_yuv444: CMD = framecrc -c:v pgmyuv -i $(SRC) 
-filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv444
diff --git a/tests/filtergraphs/overlay_yuv420p10 
b/tests/filtergraphs/overlay_yuv420p10
new file mode 100644
index 000..7cc9dcb
--- /dev/null
+++ b/tests/filtergraphs/overlay_yuv420p10
@@ -0,0 +1,5 @@
+sws_flags=+accurate_rnd+bitexact;
+split [main][over];
+[over] scale=88:72, pad=96:80:4:4 [overf];
+[main] format=yuv420p10 [mainf];
+[mainf][overf] overlay=240:16:format=yuv420p10
diff --git a/tests/filtergraphs/overlay_yuv422p10 
b/tests/filtergraphs/overlay_yuv422p10
new file mode 100644
index 000..459d140
--- /dev/null
+++ b/tests/filtergraphs/overlay_yuv422p10
@@ -0,0 +1,5 @@
+sws_flags=+accurate_rnd+bitexact;
+split [main][over];
+[over] scale=88:72, pad=96:80:4:4 [overf];
+[main] format=yuv420p10 [mainf];
+[mainf][overf] overlay=240:16:format=yuv422p10
diff --git a/tests/ref/fate/filter-overlay_yuv420p10 
b/tests/ref/fate/filter-overlay_yuv420p10
new file mode 100644
index 000..cc90fb5
--- /dev/null
+++ b/tests/ref/fate/filter-overlay_yuv420p10
@@ -0,0 +1,8 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 352x288
+#sar 0: 0/1
+0,  0,  0,1,   304128, 0x85348342
+0,  1,  1,1,   304128, 0x2871d7dc
+0,  2,  2,1,   304128, 0x75819b2a
diff --git a/tests/ref/fate/filter-overlay_yuv422p10 
b/tests/ref/fate/filter-overlay_yuv422p10
new file mode 100644
index 000..a601931
--- /dev/null
+++ b/tests/ref/fate/filter-overlay_yuv422p10
@@ -0,0 +1,8 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 352x288
+#sar 0: 0/1
+0,  0,  0,1,   608256, 0x8e3fe595
+0,  1,  1,1,   608256, 0x38512396
+0,  2,  2,1,   608256, 0x0195cb34
-- 
1.8.3.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 v4 2/3] avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support

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

Signed-off-by: Limin Wang 
---
 doc/filters.texi |  6 
 libavfilter/vf_overlay.c | 79 
 libavfilter/vf_overlay.h |  2 ++
 3 files changed, 87 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index f76604c..4c54325 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14342,9 +14342,15 @@ It accepts the following values:
 @item yuv420
 force YUV420 output
 
+@item yuv420p10
+force YUV420p10 output
+
 @item yuv422
 force YUV422 output
 
+@item yuv422p10
+force YUV422p10 output
+
 @item yuv444
 force YUV444 output
 
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 7f73848..5ab3f3f 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -154,6 +154,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_YUVA420P10, AV_PIX_FMT_YUVA422P10,
 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 +173,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_YUV420P10, AV_PIX_FMT_YUVA420P10,
+AV_PIX_FMT_NONE
+};
+static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
+AV_PIX_FMT_YUVA420P10, 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
 };
@@ -179,6 +188,13 @@ static int query_formats(AVFilterContext *ctx)
 AV_PIX_FMT_YUVA422P, AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat main_pix_fmts_yuv422p10[] = {
+AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE
+};
+static const enum AVPixelFormat overlay_pix_fmts_yuv422p10[] = {
+AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE
+};
+
 static const enum AVPixelFormat main_pix_fmts_yuv444[] = {
 AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVA444P, 
AV_PIX_FMT_NONE
 };
@@ -217,6 +233,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))) 
{
@@ -224,6 +247,13 @@ static int query_formats(AVFilterContext *ctx)
 goto fail;
 }
 break;
+case OVERLAY_FORMAT_YUV422P10:
+if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422p10)) 
||
+!(overlay_formats = 
ff_make_format_list(overlay_pix_fmts_yuv422p10))) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+break;
 case OVERLAY_FORMAT_YUV444:
 if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv444)) ||
 !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444))) 
{
@@ -566,6 +596,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, \
@@ -617,6 +648,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, \
@@ -648,6 +680,7 @@ static av_always_inline void 
blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
 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,
@@ -694,6 +727,38 @@ stat

[FFmpeg-devel] [PATCH v4 1/3] avfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based function

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

Signed-off-by: Limin Wang 
---
It's old patch, so rebase and merge into one patch for review, 
in addition, I have added format for yuv422p10, and fate test case. 

 libavfilter/vf_overlay.c | 417 +--
 1 file changed, 220 insertions(+), 197 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index b5ab5fb..7f73848 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -441,190 +441,213 @@ static av_always_inline void 
blend_slice_packed_rgb(AVFilterContext *ctx,
 }
 }
 
-static av_always_inline void blend_plane(AVFilterContext *ctx,
- AVFrame *dst, const AVFrame *src,
- int src_w, int src_h,
- int dst_w, int dst_h,
- int i, int hsub, int vsub,
- int x, int y,
- int main_has_alpha,
- int dst_plane,
- int dst_offset,
- int dst_step,
- int straight,
- int yuv,
- int jobnr,
- int nb_jobs)
-{
-OverlayContext *octx = ctx->priv;
-int src_wp = AV_CEIL_RSHIFT(src_w, hsub);
-int src_hp = AV_CEIL_RSHIFT(src_h, vsub);
-int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub);
-int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub);
-int yp = y>>vsub;
-int xp = x>>hsub;
-uint8_t *s, *sp, *d, *dp, *dap, *a, *da, *ap;
-int jmax, j, k, kmax;
-int slice_start, slice_end;
-
-j = FFMAX(-yp, 0);
-jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp);
-
-slice_start = j + (jmax * jobnr) / nb_jobs;
-slice_end = j + (jmax * (jobnr+1)) / nb_jobs;
-
-sp = src->data[i] + (slice_start) * src->linesize[i];
-dp = dst->data[dst_plane]
-  + (yp + slice_start) * dst->linesize[dst_plane]
-  + dst_offset;
-ap = src->data[3] + (slice_start << vsub) * src->linesize[3];
-dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3];
-
-for (j = slice_start; j < slice_end; j++) {
-k = FFMAX(-xp, 0);
-d = dp + (xp+k) * dst_step;
-s = sp + k;
-a = ap + (kblend_row[i](d, da, s, a, kmax - k, 
src->linesize[3]);
-
-s += c;
-d += dst_step * c;
-da += (1 << hsub) * c;
-a += (1 << hsub) * c;
-k += c;
-}
-for (; k < kmax; k++) {
-int alpha_v, alpha_h, alpha;
-
-// average alpha for color components, improve quality
-if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
-alpha = (a[0] + a[src->linesize[3]] +
- a[1] + a[src->linesize[3]+1]) >> 2;
-} else if (hsub || vsub) {
-alpha_h = hsub && k+1 < src_wp ?
-(a[0] + a[1]) >> 1 : a[0];
-alpha_v = vsub && j+1 < src_hp ?
-(a[0] + a[src->linesize[3]]) >> 1 : a[0];
-alpha = (alpha_v + alpha_h) >> 1;
-} else
-alpha = a[0];
-// if the main channel has an alpha channel, alpha has to be 
calculated
-// to create an un-premultiplied (straight) alpha value
-if (main_has_alpha && alpha != 0 && alpha != 255) {
-// average alpha for color components, improve quality
-uint8_t alpha_d;
-if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
-alpha_d = (da[0] + da[dst->linesize[3]] +
-   da[1] + da[dst->linesize[3]+1]) >> 2;
-} else if (hsub || vsub) {
-alpha_h = hsub && k+1 < src_wp ?
-(da[0] + da[1]) >> 1 : da[0];
-alpha_v = vsub && j+1 < src_hp ?
-(da[0] + da[dst->linesize[3]]) >> 1 : da[0];
-alpha_d = (alpha_v + alpha_h) >> 1;
-} else
-alpha_d = da[0];
-alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d);
-}
-if (straight) {
-*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha);
-} else {
-if (i && yuv)
-*d = av_clip(FAST_DIV255((*d - 128) * (255 - alpha)) + *s 
- 128, -128, 128) + 128;
-else
-*d = FFMIN(FAST_DIV255(*d * (255 - alpha)) + *s, 255);
-}
-s++;
-d += dst_step;
-da += 1 << hsub;
-a += 1 << hsub;
-}
-dp += dst->linesize[dst_plane];
-sp += src->line

Re: [FFmpeg-devel] [PATCH v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-06-05 Thread lance . lmwang
On Thu, May 28, 2020 at 04:14:27PM +0200, Nicolas George wrote:
> lance.lmw...@gmail.com (12020-05-28):
> > will apply the patchset tomorrow if no further comments.
> 
> Please give me time to look carefully. This is not urgent.

Nicolas, do you have got free time to review the patch set and give 
your feedback?

> 
> 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".


-- 
Thanks,
Limin Wang
___
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] avutil/dict: av_realloc -> av_realloc_array()

2020-06-05 Thread lance . lmwang
On Sat, May 30, 2020 at 10:10:32PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavutil/dict.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 0ea7138..9d3d96c 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -103,8 +103,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const 
> char *value,
>  av_free(tag->key);
>  *tag = m->elems[--m->count];
>  } else if (copy_value) {
> -AVDictionaryEntry *tmp = av_realloc(m->elems,
> -(m->count + 1) * 
> sizeof(*m->elems));
> +AVDictionaryEntry *tmp = av_realloc_array(m->elems,
> +  m->count + 1, 
> sizeof(*m->elems));
>  if (!tmp)
>  goto err_out;
>  m->elems = tmp;
> -- 
> 1.8.3.1
> 

will apply it tomorrow if no further comments.


-- 
Thanks,
Limin Wang
___
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/dashenc: reopen new http session for http_persistent

2020-06-05 Thread Chris Ribble
On Tue, Jun 2, 2020 at 12:22 AM Siyuan Huang 
wrote:

> Hello Chris Ribble
>
>
>
> Looks you are working for http patch ,
>
> Can you share a test script for it ?
>
>
Siyuan Huang,

There is a description of the problem in the Trac ticket along with an
example of how to reproduce the issue: https://trac.ffmpeg.org/ticket/8693

Let me know what else you are interested in with regard to a test script.

Thanks,
Chris
___
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/dashenc: reopen new http session for http_persistent

2020-06-05 Thread Chris Ribble
> Hello Chris Ribble
>
>
>
> Looks you are working for http patch ,
>
> Can you share a test script for it ?
>

There is a description of the problem in the Trac ticket along with an
example of how to reproduce the issue:
https://trac.ffmpeg.org/ticket/8693

Let me know what else you are interested in with regard to a test script.
___
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 v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-06-05 Thread Nicolas George
lance.lmw...@gmail.com (12020-05-25):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/Makefile|   1 -
>  libavfilter/graphdump.c |  89 +
>  tools/graph2dot.c   | 204 
> 
>  3 files changed, 89 insertions(+), 205 deletions(-)
>  delete mode 100644 tools/graph2dot.c

I think the parsing of the options string should go in a separate first
patch. Then another separate patch to add file output. Then this patch.

> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 4d07bb6..291126e 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -526,7 +526,6 @@ SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h
>  
>  OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o
>  
> -TOOLS = graph2dot
>  TESTPROGS = drawutils filtfmts formats integral
>  
>  TOOLS-$(CONFIG_LIBZMQ) += zmqsend
> diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
> index 79ef1a7..97d4f39 100644
> --- a/libavfilter/graphdump.c
> +++ b/libavfilter/graphdump.c
> @@ -151,15 +151,104 @@ static void avfilter_graph_dump_to_buf(AVBPrint *buf, 
> AVFilterGraph *graph)
>  }
>  }
>  
> +static void avfilter_graph2dot_to_buf(AVBPrint *buf, AVFilterGraph *graph)
> +{
> +int i, j;
> +
> +av_bprintf(buf, "digraph G {\n");
> +av_bprintf(buf, "node [shape=box]\n");
> +av_bprintf(buf, "rankdir=LR\n");
> +
> +for (i = 0; i < graph->nb_filters; i++) {

> +char filter_ctx_label[128];
> +const AVFilterContext *filter_ctx = graph->filters[i];
> +
> +snprintf(filter_ctx_label, sizeof(filter_ctx_label), "%s\\n(%s)",
> + filter_ctx->name,
> + filter_ctx->filter->name);

Do not use a temporary buffer when the target is AVBprint. Same below.

> +
> +for (j = 0; j < filter_ctx->nb_outputs; j++) {
> +AVFilterLink *link = filter_ctx->outputs[j];
> +if (link) {
> +char dst_filter_ctx_label[128];
> +const AVFilterContext *dst_filter_ctx = link->dst;
> +
> +snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label),
> + "%s\\n(%s)",
> + dst_filter_ctx->name,
> + dst_filter_ctx->filter->name);
> +

> +av_bprintf(buf, "\"%s\" -> \"%s\" [ label= \"inpad:%s -> 
> outpad:%s\\n",
> +filter_ctx_label, dst_filter_ctx_label,
> +avfilter_pad_get_name(link->srcpad, 0),
> +avfilter_pad_get_name(link->dstpad, 0));

Indentation is off. Same below.

> +
> +if (link->type == AVMEDIA_TYPE_VIDEO) {
> +const AVPixFmtDescriptor *desc = 
> av_pix_fmt_desc_get(link->format);
> +av_bprintf(buf,
> +"fmt:%s w:%d h:%d tb:%d/%d",
> +desc->name,
> +link->w, link->h,
> +link->time_base.num, link->time_base.den);
> +} else if (link->type == AVMEDIA_TYPE_AUDIO) {
> +char audio_buf[255];
> +av_get_channel_layout_string(audio_buf, 
> sizeof(audio_buf), -1,
> + link->channel_layout);
> +av_bprintf(buf,
> +"fmt:%s sr:%d cl:%s tb:%d/%d",
> +av_get_sample_fmt_name(link->format),
> +link->sample_rate, audio_buf,
> +link->time_base.num, link->time_base.den);
> +}
> +av_bprintf(buf, "\" ];\n");
> +}
> +}
> +}
> +av_bprintf(buf, "}\n");
> +}

I did not check the logic itself, I assume it is identical to graph2dot.

> +
>  char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
>  {
>  AVBPrint buf;
>  char *dump = NULL;
> +int ret;
> +AVDictionary *dict = NULL;
> +AVDictionaryEntry *format = NULL;
> +AVDictionaryEntry *filename = NULL;
> +
> +ret = av_dict_parse_string(&dict, options, "=", ":", 0);
> +if (ret < 0) {
> +av_dict_free(&dict);
> +return NULL;
> +}
> +format = av_dict_get(dict, "fmt", NULL, 0);
>  
> +if (format && !av_strcasecmp(format->value, "DOT")) {
> +av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> +avfilter_graph2dot_to_buf(&buf, graph);

> +av_bprint_finalize(&buf, &dump);

Missing error check. (Yes, the error check is also missing in the
existing code.)

> +} else {

Invalid format selections should be reported to users.

>  av_bprint_init(&buf, 0, AV_BPRINT_SIZE_COUNT_ONLY);
>  avfilter_graph_dump_to_buf(&buf, graph);
>  av_bprint_init(&buf, buf.len + 1, buf.len + 1);
>  avfilter_graph_dump_to_buf(&buf, graph);
>  av_bprint_finalize(&buf, &dump);
> +}
> +
>

Re: [FFmpeg-devel] [PATCH v7 2/3] avdevice/lavfi: support the dumpgraph with options

2020-06-05 Thread Nicolas George
lance.lmw...@gmail.com (12020-05-25):
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  doc/indevs.texi | 19 +--
>  libavdevice/lavfi.c |  8 +---
>  2 files changed, 22 insertions(+), 5 deletions(-)

Either we case about backwards compatibility, and you cannot change the
type of the existing option at all, or we do not, and it is not
necessary to add another option.

I move we do not care much about compatibility: the syntax was never
documented, except "1" should work. Then accept "1" and any valid
key-value string.

Regards,

-- 
  Nicolas George


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] fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale

2020-06-05 Thread Eoff, Ullysses A
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Fu, Linjie
> Sent: Friday, March 13, 2020 8:18 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: add -autoscale to 
> disable/enable the default scale
> 
> > From: ffmpeg-devel  On Behalf Of
> > Nicolas George
> > Sent: Tuesday, February 18, 2020 03:02
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: add -autoscale
> > to disable/enable the default scale
> >
> > Gyan Doshi (12020-02-18):
> > > Protection in the command line tool will help steer the user towards
> > > choosing an accommodating encoder, which is possible once the flag and a
> > > check is added.
> >
> > True, but minor and should not block the patch.
> >
> 
> Ping, thanks.
> 
> - Linjie

Are all of the reviews addressed for this patch?  Is it ready to be merged, yet?

Cheers,
U. Artie

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

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

Re: [FFmpeg-devel] [RFC PATCH 1/2] libavcodec/jpeg2000_parser: Add jpeg2000 parser

2020-06-05 Thread Gautam Ramakrishnan
On Fri, Jun 5, 2020 at 8:23 AM Gautam Ramakrishnan  wrote:
>
> On Fri, Jun 5, 2020 at 3:21 AM Michael Niedermayer
>  wrote:
> >
> > On Thu, Jun 04, 2020 at 01:24:42PM +0530, gautamr...@gmail.com wrote:
> > > From: Gautam Ramakrishnan 
> > >
> > > I have attempted to write a JPEG2000 Parser. Have tested
> > > by generating a file containing 14 frames, as mentioned
> > > by Micheal. Have also tried testing with various packet
> > > sizes by setting -frame_size option.
> > > ---
> > >  libavcodec/Makefile  |   1 +
> > >  libavcodec/jpeg2000_parser.c | 190 +++
> > >  libavcodec/parsers.c |   1 +
> > >  3 files changed, 192 insertions(+)
> > >  create mode 100644 libavcodec/jpeg2000_parser.c
> >
> > The code seems to work fine, is there a reason why it has a "RFC" in the
> > subject. That is, should this be reviewed & applied or not yet ?
> I wanted to get the fate test also reviewed. If this looks fine to
> everyone, this can
> be applied and the FATE test can be reviewed separately.
> >
> > thx
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > Good people do not need laws to tell them to act responsibly, while bad
> > people will find a way around the laws. -- Plato
> > ___
> > 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".
>
>
>
> --
> -
> Gautam |


Should I resubmit this patch, or can it be accepted from here?
-- 
-
Gautam |
___
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 v7 2/3] avdevice/lavfi: support the dumpgraph with options

2020-06-05 Thread Marton Balint



On Fri, 5 Jun 2020, Nicolas George wrote:


lance.lmw...@gmail.com (12020-05-25):

From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/indevs.texi | 19 +--
 libavdevice/lavfi.c |  8 +---
 2 files changed, 22 insertions(+), 5 deletions(-)


Either we case about backwards compatibility, and you cannot change the
type of the existing option at all, or we do not, and it is not
necessary to add another option.


I think it always depended on the fallout, we were never blindly strict 
about this.




I move we do not care much about compatibility: the syntax was never
documented, except "1" should work. Then accept "1" and any valid
key-value string.


I suggested the separate option for the options because otherwise you 
can't do dumpgraph without options specified, so you cant make the 
code call avfilter_dump_graph(graph, NULL).


"1" as a special string might be OK until some deprecation period but not 
for all eternity if the options string wants to be an options list and if 
it must be parseable as an AVDictionary. That would be the same 
inconsistency which we tried to avoid all over the codebase. E.g. this 
option looks like a dictionary, except "1" is also accepted...


Regards,
Marton
___
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 4/5] [utils, mathematics] Fix overflow in compute_pkt_fields().

2020-06-05 Thread Dale Curtis
Bump for this one again. Thanks in advance.

- dale

On Thu, May 28, 2020 at 12:37 PM Dale Curtis 
wrote:

>   Bump now that the saturated math operations have landed. Thanks!
>
> - dale
>
> On Thu, May 14, 2020 at 3:31 PM Dale Curtis 
> wrote:
>
>> Fixes one issue in the function itself and one in the dependent
>> function av_add_stable() which wasn't checking for NaN.
>>
>> Signed-off-by: Dale Curtis 
>> ---
>>  libavformat/utils.c | 2 +-
>>  libavutil/mathematics.c | 2 +-
>>  2 files changed, 2 insertions(+), 2 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".

Re: [FFmpeg-devel] [PATCH 3/5] [mov] Check if DTS is AV_NOPTS_VALUE in mov_find_next_sample().

2020-06-05 Thread Dale Curtis
Bump for this one again. Thanks in advance.

- dale

On Thu, May 28, 2020 at 12:37 PM Dale Curtis 
wrote:

>   Bump now that the saturated math operations have landed. Thanks!
>
> - dale
>
> On Thu, May 14, 2020 at 3:31 PM Dale Curtis 
> wrote:
>
>>
>> Signed-off-by: Dale Curtis 
>> ---
>>  libavformat/mov.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>
___
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/movtextdec: Fix shift overflows in mov_text_init()

2020-06-05 Thread Michael Niedermayer
Fixes: left shift of 243 by 24 places cannot be represented in type 'int'
Fixes: 
22716/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MOVTEXT_fuzzer-5704263425851392

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

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 4b4da5e0d9..4a21dbf36d 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -492,10 +492,10 @@ static int mov_text_init(AVCodecContext *avctx) {
 return ff_ass_subtitle_header_full(avctx,
 m->frame_width, m->frame_height,
 m->d.font, m->d.fontsize,
-(255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
-(255 - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
-(255 - m->d.back_alpha) << 24 | 
RGB_TO_BGR(m->d.back_color),
-(255 - m->d.back_alpha) << 24 | 
RGB_TO_BGR(m->d.back_color),
+(255U - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
+(255U - m->d.alpha) << 24 | RGB_TO_BGR(m->d.color),
+(255U - m->d.back_alpha) << 24 | 
RGB_TO_BGR(m->d.back_color),
+(255U - m->d.back_alpha) << 24 | 
RGB_TO_BGR(m->d.back_color),
 m->d.bold, m->d.italic, m->d.underline,
 ASS_DEFAULT_BORDERSTYLE, m->d.alignment);
 } else
-- 
2.17.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 2/2] avcodec/huffyuvdec: Test vertical coordinate more often

2020-06-05 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
22892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-5135996772679680.fuzz

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

diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 0ee7ec3917..e713b91e4d 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -928,12 +928,16 @@ static int decode_slice(AVCodecContext *avctx, AVFrame 
*p, int height,
 left= left_prediction(s, p->data[plane], s->temp[0], w, 0);
 
 y = 1;
+if (y >= h)
+break;
 
 /* second line is left predicted for interlaced case */
 if (s->interlaced) {
 decode_plane_bitstream(s, w, plane);
 left = left_prediction(s, p->data[plane] + 
p->linesize[plane], s->temp[0], w, left);
 y++;
+if (y >= h)
+break;
 }
 
 lefttop = p->data[plane][0];
@@ -1045,6 +1049,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame 
*p, int height,
 }
 
 cy = y = 1;
+if (y >= height)
+break;
 
 /* second line is left predicted for interlaced case */
 if (s->interlaced) {
@@ -1057,6 +1063,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame 
*p, int height,
 }
 y++;
 cy++;
+if (y >= height)
+break;
 }
 
 /* next 4 pixels are left predicted too */
-- 
2.17.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] [RFC PATCH 1/2] libavcodec/jpeg2000_parser: Add jpeg2000 parser

2020-06-05 Thread Michael Niedermayer
On Fri, Jun 05, 2020 at 09:54:49PM +0530, Gautam Ramakrishnan wrote:
> On Fri, Jun 5, 2020 at 8:23 AM Gautam Ramakrishnan  
> wrote:
> >
> > On Fri, Jun 5, 2020 at 3:21 AM Michael Niedermayer
> >  wrote:
> > >
> > > On Thu, Jun 04, 2020 at 01:24:42PM +0530, gautamr...@gmail.com wrote:
> > > > From: Gautam Ramakrishnan 
> > > >
> > > > I have attempted to write a JPEG2000 Parser. Have tested
> > > > by generating a file containing 14 frames, as mentioned
> > > > by Micheal. Have also tried testing with various packet
> > > > sizes by setting -frame_size option.
> > > > ---
> > > >  libavcodec/Makefile  |   1 +
> > > >  libavcodec/jpeg2000_parser.c | 190 +++
> > > >  libavcodec/parsers.c |   1 +
> > > >  3 files changed, 192 insertions(+)
> > > >  create mode 100644 libavcodec/jpeg2000_parser.c
> > >
> > > The code seems to work fine, is there a reason why it has a "RFC" in the
> > > subject. That is, should this be reviewed & applied or not yet ?
> > I wanted to get the fate test also reviewed. If this looks fine to
> > everyone, this can
> > be applied and the FATE test can be reviewed separately.
> > >
> > > thx
> > >
> > > [...]
> > > --
> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> > >
> > > Good people do not need laws to tell them to act responsibly, while bad
> > > people will find a way around the laws. -- Plato
> > > ___
> > > 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".
> >
> >
> >
> > --
> > -
> > Gautam |
> 
> 
> Should I resubmit this patch, or can it be accepted from here?

probably it can be, but if you resubmit then please check the
formating, there are some inconsitancies like ) { vs ){

thx

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


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 2/2] avcodec/huffyuvdec: Test vertical coordinate more often

2020-06-05 Thread Paul B Mahol
probably ok

On 6/5/20, Michael Niedermayer  wrote:
> Fixes: out of array access
> Fixes:
> 22892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-5135996772679680.fuzz
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/huffyuvdec.c | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
> index 0ee7ec3917..e713b91e4d 100644
> --- a/libavcodec/huffyuvdec.c
> +++ b/libavcodec/huffyuvdec.c
> @@ -928,12 +928,16 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>  left= left_prediction(s, p->data[plane], s->temp[0], w, 0);
>
>  y = 1;
> +if (y >= h)
> +break;
>
>  /* second line is left predicted for interlaced case */
>  if (s->interlaced) {
>  decode_plane_bitstream(s, w, plane);
>  left = left_prediction(s, p->data[plane] +
> p->linesize[plane], s->temp[0], w, left);
>  y++;
> +if (y >= h)
> +break;
>  }
>
>  lefttop = p->data[plane][0];
> @@ -1045,6 +1049,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>  }
>
>  cy = y = 1;
> +if (y >= height)
> +break;
>
>  /* second line is left predicted for interlaced case */
>  if (s->interlaced) {
> @@ -1057,6 +1063,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame
> *p, int height,
>  }
>  y++;
>  cy++;
> +if (y >= height)
> +break;
>  }
>
>  /* next 4 pixels are left predicted too */
> --
> 2.17.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 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 4/4] pthread_frame: use av_buffer_replace() to simplify code

2020-06-05 Thread Michael Niedermayer
On Fri, Jun 05, 2020 at 12:02:19PM +0200, Anton Khirnov wrote:
> ---
>  libavcodec/pthread_frame.c | 13 +++--
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 

this changes the output from: (it has fewer frames output)

./ffmpeg -i tickets/5522/progressive_q_mediumhd.avi -f framecrc -

i assume the sample is here:
https://trac.ffmpeg.org/raw-attachment/ticket/5522/progressive_q_mediumhd.avi

thx

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 2/3] avformat/rawdec: reduce randomness in used identifiers

2020-06-05 Thread Michael Niedermayer
On Fri, Jun 05, 2020 at 10:29:23AM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-06-04 01:19:18)
> >Subject: avformat/rawdec: reduce randomness in   used identifiers
> 
> The patch looks ok, but the commit message is not very clear. "fix
> identifier names" would be easier to understand IMO.

will apply with the suggested message

thx

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

Avoid a single point of failure, be that a person or equipment.


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 2/2] avcodec/huffyuvdec: Test vertical coordinate more often

2020-06-05 Thread Michael Niedermayer
On Fri, Jun 05, 2020 at 11:18:25PM +0200, Paul B Mahol wrote:
> probably ok

will apply

thx

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

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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 4/5] [utils, mathematics] Fix overflow in compute_pkt_fields().

2020-06-05 Thread Michael Niedermayer
On Thu, May 14, 2020 at 03:31:53PM -0700, Dale Curtis wrote:
> Fixes one issue in the function itself and one in the dependent
> function av_add_stable() which wasn't checking for NaN.
> 
> Signed-off-by: Dale Curtis 
> ---
>  libavformat/utils.c | 2 +-
>  libavutil/mathematics.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

will apply

thx

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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 1/3] libavcodec/png_parser.c: fix a use_of_uninitialized_value in target_dec_fuzzer.

2020-06-05 Thread Michael Niedermayer
On Thu, Jun 04, 2020 at 01:03:00PM -0700, Thierry Foucu wrote:
> the target_dec_fuzzer is checking for the avpkt.data pointer but if the
> png parser cannot combine the frame, the poutbuf is not set.
> ---
>  libavcodec/png_parser.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

thx

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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 3/3] libavcodec/bmp_parser.c: fix a use_of_uninitialized_value in target_dec_fuzzer.

2020-06-05 Thread Michael Niedermayer
On Thu, Jun 04, 2020 at 01:03:27PM -0700, Thierry Foucu wrote:
> the target_dec_fuzzer is checking for the avpkt.data pointer but if the
> bmp parser cannot combine the frame, the poutbuf is not set.
> ---
>  libavcodec/bmp_parser.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

thx

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

Avoid a single point of failure, be that a person or equipment.


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 2/3] libavcodec/mlp_parser.c: fix a use_of_uninitialized_value in target_dec_fuzzer.

2020-06-05 Thread Michael Niedermayer
On Thu, Jun 04, 2020 at 01:03:15PM -0700, Thierry Foucu wrote:
> the target_dec_fuzzer is checking for the avpkt.data pointer but if the
> mlp parser cannot combine the frame, the poutbuf is not set.
> ---
>  libavcodec/mlp_parser.c | 1 +
>  1 file changed, 1 insertion(+)

will apply

thx

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

The educated differ from the uneducated as much as the living from the
dead. -- 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".

Re: [FFmpeg-devel] [PATCH v7 2/3] avdevice/lavfi: support the dumpgraph with options

2020-06-05 Thread lance . lmwang
On Fri, Jun 05, 2020 at 07:10:08PM +0200, Marton Balint wrote:
> 
> 
> On Fri, 5 Jun 2020, Nicolas George wrote:
> 
> > lance.lmw...@gmail.com (12020-05-25):
> > > From: Limin Wang 
> > > 
> > > Signed-off-by: Limin Wang 
> > > ---
> > >  doc/indevs.texi | 19 +--
> > >  libavdevice/lavfi.c |  8 +---
> > >  2 files changed, 22 insertions(+), 5 deletions(-)
> > 
> > Either we case about backwards compatibility, and you cannot change the
> > type of the existing option at all, or we do not, and it is not
> > necessary to add another option.
> 
> I think it always depended on the fallout, we were never blindly strict
> about this.
> 
> > 
> > I move we do not care much about compatibility: the syntax was never
> > documented, except "1" should work. Then accept "1" and any valid
> > key-value string.
> 
> I suggested the separate option for the options because otherwise you can't
> do dumpgraph without options specified, so you cant make the code call
> avfilter_dump_graph(graph, NULL).
> 
> "1" as a special string might be OK until some deprecation period but not
> for all eternity if the options string wants to be an options list and if it
> must be parseable as an AVDictionary. That would be the same inconsistency
> which we tried to avoid all over the codebase. E.g. this option looks like a
> dictionary, except "1" is also accepted...

When I'm try to understand how to use the option, no document, so I had to 
study 
the code, it's string type, but no code to use it, so I think it's boolean 
type. 
I guess most of user will have the same feeling. So I prefer to Marton's
suggestion with separate option.

> 
> Regards,
> Marton
> ___
> 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".

-- 
Thanks,
Limin Wang
___
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 v7 1/3] avfilter/graphdump: support for the graph2dot function

2020-06-05 Thread lance . lmwang
On Fri, Jun 05, 2020 at 05:06:53PM +0200, Nicolas George wrote:
> lance.lmw...@gmail.com (12020-05-25):
> > From: Limin Wang 
> > 
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/Makefile|   1 -
> >  libavfilter/graphdump.c |  89 +
> >  tools/graph2dot.c   | 204 
> > 
> >  3 files changed, 89 insertions(+), 205 deletions(-)
> >  delete mode 100644 tools/graph2dot.c
> 
> I think the parsing of the options string should go in a separate first
> patch. Then another separate patch to add file output. Then this patch.

OK, will split the patch.

> 
> > 
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index 4d07bb6..291126e 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -526,7 +526,6 @@ SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h
> >  
> >  OBJS-$(CONFIG_LIBGLSLANG)+= glslang.o
> >  
> > -TOOLS = graph2dot
> >  TESTPROGS = drawutils filtfmts formats integral
> >  
> >  TOOLS-$(CONFIG_LIBZMQ) += zmqsend
> > diff --git a/libavfilter/graphdump.c b/libavfilter/graphdump.c
> > index 79ef1a7..97d4f39 100644
> > --- a/libavfilter/graphdump.c
> > +++ b/libavfilter/graphdump.c
> > @@ -151,15 +151,104 @@ static void avfilter_graph_dump_to_buf(AVBPrint 
> > *buf, AVFilterGraph *graph)
> >  }
> >  }
> >  
> > +static void avfilter_graph2dot_to_buf(AVBPrint *buf, AVFilterGraph *graph)
> > +{
> > +int i, j;
> > +
> > +av_bprintf(buf, "digraph G {\n");
> > +av_bprintf(buf, "node [shape=box]\n");
> > +av_bprintf(buf, "rankdir=LR\n");
> > +
> > +for (i = 0; i < graph->nb_filters; i++) {
> 
> > +char filter_ctx_label[128];
> > +const AVFilterContext *filter_ctx = graph->filters[i];
> > +
> > +snprintf(filter_ctx_label, sizeof(filter_ctx_label), "%s\\n(%s)",
> > + filter_ctx->name,
> > + filter_ctx->filter->name);
> 
> Do not use a temporary buffer when the target is AVBprint. Same below.

will fix

> 
> > +
> > +for (j = 0; j < filter_ctx->nb_outputs; j++) {
> > +AVFilterLink *link = filter_ctx->outputs[j];
> > +if (link) {
> > +char dst_filter_ctx_label[128];
> > +const AVFilterContext *dst_filter_ctx = link->dst;
> > +
> > +snprintf(dst_filter_ctx_label, 
> > sizeof(dst_filter_ctx_label),
> > + "%s\\n(%s)",
> > + dst_filter_ctx->name,
> > + dst_filter_ctx->filter->name);
> > +
> 
> > +av_bprintf(buf, "\"%s\" -> \"%s\" [ label= \"inpad:%s -> 
> > outpad:%s\\n",
> > +filter_ctx_label, dst_filter_ctx_label,
> > +avfilter_pad_get_name(link->srcpad, 0),
> > +avfilter_pad_get_name(link->dstpad, 0));
> 
> Indentation is off. Same below.

will fix

> 
> > +
> > +if (link->type == AVMEDIA_TYPE_VIDEO) {
> > +const AVPixFmtDescriptor *desc = 
> > av_pix_fmt_desc_get(link->format);
> > +av_bprintf(buf,
> > +"fmt:%s w:%d h:%d tb:%d/%d",
> > +desc->name,
> > +link->w, link->h,
> > +link->time_base.num, link->time_base.den);
> > +} else if (link->type == AVMEDIA_TYPE_AUDIO) {
> > +char audio_buf[255];
> > +av_get_channel_layout_string(audio_buf, 
> > sizeof(audio_buf), -1,
> > + link->channel_layout);
> > +av_bprintf(buf,
> > +"fmt:%s sr:%d cl:%s tb:%d/%d",
> > +av_get_sample_fmt_name(link->format),
> > +link->sample_rate, audio_buf,
> > +link->time_base.num, link->time_base.den);
> > +}
> > +av_bprintf(buf, "\" ];\n");
> > +}
> > +}
> > +}
> > +av_bprintf(buf, "}\n");
> > +}
> 
> I did not check the logic itself, I assume it is identical to graph2dot.

Yes, I try to keep the same for this version and consider to add more options 
later.

> 
> > +
> >  char *avfilter_graph_dump(AVFilterGraph *graph, const char *options)
> >  {
> >  AVBPrint buf;
> >  char *dump = NULL;
> > +int ret;
> > +AVDictionary *dict = NULL;
> > +AVDictionaryEntry *format = NULL;
> > +AVDictionaryEntry *filename = NULL;
> > +
> > +ret = av_dict_parse_string(&dict, options, "=", ":", 0);
> > +if (ret < 0) {
> > +av_dict_free(&dict);
> > +return NULL;
> > +}
> > +format = av_dict_get(dict, "fmt", NULL, 0);
> >  
> > +if (format && !av_strcasecmp(format->value, "DOT")) {
> > +av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
> > +avfilter_graph2dot_to_buf(&buf, graph);
> 

Re: [FFmpeg-devel] [PATCH v2] avfilter/qsvvpp: Work around a bug in MSDK where VPP processing hangs under certain conditions

2020-06-05 Thread Soft Works


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Max Dmitrichenko
> Sent: Friday, June 5, 2020 3:09 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2] avfilter/qsvvpp: Work around a bug
> in MSDK where VPP processing hangs under certain conditions
> 
> On Mon, May 25, 2020 at 12:40 AM Soft Works 
> wrote:
> 
> > These are:
> > - Dimensions are already aligned (e.g. 1920x800)
> > - No scaling is done
> > - Color format conversion (e.g. 10bit to 8bit)
> >
> > Example command:
> > ffmpeg -c:v hevc_qsv -hwaccel qsv -i hevc_10bit_1920_800.mkv
> > -filter_complex "scale_qsv=format=nv12" -c:v h264_qsv out.mkv
> >
> > Fix:
> > - Increase the frame height to the next alignment value
> >
> > V2:
> > - removed empty line
> > - removed duplicated line
> > ---
> >  libavfilter/qsvvpp.c   | 7 ++-
> >  libavfilter/vf_scale_qsv.c | 9 -
> >  2 files changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > 1bbb7a7e68..98d2353d1c 100644
> > --- a/libavfilter/qsvvpp.c
> > +++ b/libavfilter/qsvvpp.c
> > @@ -420,6 +420,7 @@ static int init_vpp_session(AVFilterContext
> > *avctx, QSVVPPContext *s)
> >  mfxHandleType handle_type;
> >  mfxVersion ver;
> >  mfxIMPL impl;
> > +int height_align_adjust = 0;
> >  int ret, i;
> >
> >  if (inlink->hw_frames_ctx) {
> > @@ -463,9 +464,13 @@ static int init_vpp_session(AVFilterContext
> > *avctx, QSVVPPContext *s)
> >  out_frames_ctx   = (AVHWFramesContext *)out_frames_ref->data;
> >  out_frames_hwctx = out_frames_ctx->hwctx;
> >
> > +/* work around a bug in MSDK where VPP processing hangs under
> > certain conditions */
> > +if (inlink->h == outlink->h)
> > +height_align_adjust = 1;
> > +
> >  out_frames_ctx->format= AV_PIX_FMT_QSV;
> >  out_frames_ctx->width = FFALIGN(outlink->w, 32);
> > -out_frames_ctx->height= FFALIGN(outlink->h, 32);
> > +out_frames_ctx->height= FFALIGN(outlink->h +
> > height_align_adjust, 32);
> >  out_frames_ctx->sw_format = s->out_sw_format;
> >  out_frames_ctx->initial_pool_size = 64;
> >  if (avctx->extra_hw_frames > 0) diff --git
> > a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index
> > 5259104a4f..303d2101a9 100644
> > --- a/libavfilter/vf_scale_qsv.c
> > +++ b/libavfilter/vf_scale_qsv.c
> > @@ -181,8 +181,10 @@ static int init_out_pool(AVFilterContext *ctx,
> >  AVQSVFramesContext *out_frames_hwctx;
> >  enum AVPixelFormat in_format;
> >  enum AVPixelFormat out_format;
> > +int height_align_adjust = 0;
> >  int i, ret;
> >
> >  /* check that we have a hw context */
> >  if (!ctx->inputs[0]->hw_frames_ctx) {
> >  av_log(ctx, AV_LOG_ERROR, "No hw context provided on
> > input\n"); @@ -191,6 +193,7 @@ static int init_out_pool(AVFilterContext
> *ctx,
> >  in_frames_ctx   =
> > (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
> >  in_frames_hwctx = in_frames_ctx->hwctx;
> >
> >  in_format = in_frames_ctx->sw_format;
> >  out_format= (s->format == AV_PIX_FMT_NONE) ? in_format :
> > s->format;
> >
> > @@ -200,9 +203,13 @@ static int init_out_pool(AVFilterContext *ctx,
> >  out_frames_ctx   = (AVHWFramesContext*)outlink->hw_frames_ctx-
> >data;
> >  out_frames_hwctx = out_frames_ctx->hwctx;
> >
> > +/* work around a bug in MSDK where VPP processing hangs under
> > + certain
> > conditions */
> > +if (in_frames_ctx->height == out_height)
> > +height_align_adjust = 1;
> > +
> >  out_frames_ctx->format= AV_PIX_FMT_QSV;
> >  out_frames_ctx->width = FFALIGN(out_width,  16);
> > -out_frames_ctx->height= FFALIGN(out_height, 16);
> > +out_frames_ctx->height= FFALIGN(out_height +
> > height_align_adjust, 16);
> >  out_frames_ctx->sw_format = out_format;
> >  out_frames_ctx->initial_pool_size = 4;
> >
> > --
> > 2.26.2.windows.1
> >
> >
> patch seems to be manually edited and cannot be applied automatically.
> 
> During my tests, I couldn't see any change of behavior with and without
> patch, more details needed for patch justification.

Well, before talking about the patch - the question is whether you can 
reproduce the hang with the video file I sent you and the command line 
above?

It should be reproducible with drivers corresponding to MSDK 1.31 
I haven't tried with the latest ones (1.32).

Maybe I haven't specified "hang" well enough. In that case, "hang" means
that ffmpeg totally gets stuck and does nothing, so you need to kill it.

BTW: We have deployed the patch to release last week and the affected
users have reported that it's resolved for them.

softworkz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH] libavcodec/jpeg2000_parser: Add jpeg2000 parser

2020-06-05 Thread gautamramk
From: Gautam Ramakrishnan 

I have attempted to write a JPEG2000 Parser. Have tested
by generating a file containing 14 frames, as mentioned
by Micheal. Have also tried testing with various packet
sizes by setting -frame_size option. Additionally,
fixed a few formatting issues as pointed out by Micheal.
---
 libavcodec/Makefile  |   1 +
 libavcodec/jpeg2000_parser.c | 190 +++
 libavcodec/parsers.c |   1 +
 3 files changed, 192 insertions(+)
 create mode 100644 libavcodec/jpeg2000_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 0a3bbc7128..5a6ea59715 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1074,6 +1074,7 @@ OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264_sei.o h264data.o
 OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
+OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
 OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o
 OBJS-$(CONFIG_MLP_PARSER)  += mlp_parse.o mlp_parser.o mlp.o
 OBJS-$(CONFIG_MPEG4VIDEO_PARSER)   += mpeg4video_parser.o h263.o \
diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
new file mode 100644
index 00..79fed0cbbe
--- /dev/null
+++ b/libavcodec/jpeg2000_parser.c
@@ -0,0 +1,190 @@
+/*
+ * JPEG2000 parser
+ * Copyright (c) 2020 Gautam Ramakrishnan
+ *
+ * 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
+ * JPEG2000 parser.
+ */
+
+#include "parser.h"
+
+/* Whether frame is jp2 file or codestream
+*/
+enum frame_type {
+jp2_file = 1,
+j2k_cstream
+};
+
+typedef struct JPEG2000ParserContext {
+ParseContext pc;
+uint64_t bytes_read;
+uint64_t fheader_state;
+uint32_t skip_bytes; // skip bytes inside codestream data
+enum frame_type ft; // 1 if file, 2 if codestream
+uint8_t fheader_read; // are we reading
+uint8_t reading_file_header;
+uint8_t skipped_codestream;
+uint8_t codestream_frame_end;
+uint8_t read_tp;
+uint8_t in_codestream;
+} JPEG2000ParserContext;
+
+static inline void reset_context(JPEG2000ParserContext *m)
+{
+ParseContext *pc = &m->pc;
+
+pc->frame_start_found= 0;
+pc->state = 0;
+m->bytes_read = 0;
+m->ft = 0;
+m->skipped_codestream = 0;
+m->fheader_read = 0;
+m->codestream_frame_end = 0;
+m->skip_bytes = 0;
+m->read_tp = 0;
+m->in_codestream = 0;
+}
+
+/* Returns 1 if marker has any data which can be skipped
+*/
+static uint8_t info_marker(uint16_t marker)
+{
+if (marker == 0xFF92 || marker == 0xFF4F ||
+marker == 0xFF90 || marker == 0xFF93 ||
+marker == 0xFFD9)
+return 0;
+else
+if (marker > 0xFF00) return 1;
+return 0;
+}
+
+/**
+ * Find the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int 
buf_size)
+{
+ParseContext *pc= &m->pc;
+int i;
+uint32_t state;
+uint64_t state64;
+state= pc->state;
+state64 = pc->state64;
+if (buf_size == 0) {
+return 0;
+}
+
+for (i = 0; i < buf_size; i++) {
+state = state << 8 | buf[i];
+state64 = state64 << 8 | buf[i];
+m->bytes_read++;
+if (m->skip_bytes) {
+m->skip_bytes--;
+continue;
+}
+if (m->codestream_frame_end) {
+reset_context(m);
+return i;
+}
+if (m->read_tp) { // Find out how many bytes inside Tile part 
codestream to skip.
+if (m->read_tp == 1) {
+m->skip_bytes = (state64 & 0x) - 10 > 0?
+(state64 & 0x) - 10 : 0;
+}
+m->read_tp--;
+}
+if (m->fheader_read) {
+if (m->fheader_read == 1) {
+if (state64 == 0x6A5020200D0A870A) { // JP2 signature box 
value.
+if (pc->frame_start_found) {
+pc->frame_start_found = 0;
+reset_context(m);
+return i -