[FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Muhammad Faiz
So, all frames and errors are correctly reported in order.
Also limit the numbers of error during draining to prevent infinite loop.

This fix fate failure with THREADS>=4:
  make fate-h264-attachment-631 THREADS=4
This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.

Suggested-by: wm4, Ronald S. Bultje, Marton Balint
Signed-off-by: Muhammad Faiz 
---
 libavcodec/decode.c| 21 +++--
 libavcodec/internal.h  |  3 +++
 libavcodec/pthread_frame.c | 15 +++
 3 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6ff3c40..edfae55 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
(AVRational){avctx->ticks_per_frame, 1}));
 #endif
 
-if (avctx->internal->draining && !got_frame)
-avci->draining_done = 1;
+/* do not stop draining when got_frame != 0 or ret < 0 */
+if (avctx->internal->draining && !got_frame) {
+if (ret < 0) {
+/* prevent infinite loop if a decoder wrongly always return error 
on draining */
+/* reasonable nb_errors_max = maximum b frames + thread count */
+int nb_errors_max = 20 + (HAVE_THREADS && 
avctx->active_thread_type & FF_THREAD_FRAME ?
+avctx->thread_count : 1);
+
+if (avci->nb_draining_errors++ >= nb_errors_max) {
+av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, 
this is a bug. "
+   "Stop draining and force EOF.\n");
+avci->draining_done = 1;
+ret = AVERROR_BUG;
+}
+} else {
+avci->draining_done = 1;
+}
+}
 
 avci->compat_decode_consumed += ret;
 
@@ -1659,6 +1675,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 avctx->internal->draining  = 0;
 avctx->internal->draining_done = 0;
+avctx->internal->nb_draining_errors = 0;
 av_frame_unref(avctx->internal->buffer_frame);
 av_frame_unref(avctx->internal->compat_decode_frame);
 av_packet_unref(avctx->internal->buffer_pkt);
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 84d3362..caa46dc 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -200,6 +200,9 @@ typedef struct AVCodecInternal {
 int showed_multi_packet_warning;
 
 int skip_samples_multiplier;
+
+/* to prevent infinite loop on errors when draining */
+int nb_draining_errors;
 } AVCodecInternal;
 
 struct AVCodecDefault {
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 13d6828..363b139 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -509,8 +509,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
 /*
  * Return the next available frame from the oldest thread.
  * If we're at the end of the stream, then we have to skip threads that
- * didn't output a frame, because we don't want to accidentally signal
- * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
+ * didn't output a frame/error, because we don't want to accidentally 
signal
+ * EOF (avpkt->size == 0 && *got_picture_ptr == 0 && err >= 0).
  */
 
 do {
@@ -526,20 +526,19 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
 av_frame_move_ref(picture, p->frame);
 *got_picture_ptr = p->got_frame;
 picture->pkt_dts = p->avpkt.dts;
-
-if (p->result < 0)
-err = p->result;
+err = p->result;
 
 /*
  * A later call with avkpt->size == 0 may loop over all threads,
- * including this one, searching for a frame to return before being
+ * including this one, searching for a frame/error to return before 
being
  * stopped by the "finished != fctx->next_finished" condition.
- * Make sure we don't mistakenly return the same frame again.
+ * Make sure we don't mistakenly return the same frame/error again.
  */
 p->got_frame = 0;
+p->result = 0;
 
 if (finished >= avctx->thread_count) finished = 0;
-} while (!avpkt->size && !*got_picture_ptr && finished != 
fctx->next_finished);
+} while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != 
fctx->next_finished);
 
 update_context_from_thread(avctx, p->avctx, 1);
 
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH] doc/developer: Add terse documentation of assumed C implementation defined behavior

2017-04-28 Thread wm4
On Fri, 28 Apr 2017 02:50:42 +0200
Michael Niedermayer  wrote:

> Suggested-by: "Ronald S. Bultje" 
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/developer.texi | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/doc/developer.texi b/doc/developer.texi
> index dbe1f5421f..a948113792 100644
> --- a/doc/developer.texi
> +++ b/doc/developer.texi
> @@ -131,6 +131,11 @@ designated struct initializers (@samp{struct s x = @{ .i 
> = 17 @};});
>  
>  @item
>  compound literals (@samp{x = (struct s) @{ 17, 23 @};}).
> +
> +@item
> +Implementation defined behavior for signed integers is assumed to match the
> +expected for Twos complement. Non representable values in integer casts are 
> binary

Patch is ok, but "the expected for Twos complement" sounds a bit weird.
Maybe "expected behavior"? Also "two's complement".

> +truncated. Shift right of signed values uses sign extension.
>  @end itemize
>  
>  These features are supported by all compilers we care about, so we will not

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread wm4
On Fri, 28 Apr 2017 17:19:13 +0700
Muhammad Faiz  wrote:

> So, all frames and errors are correctly reported in order.
> Also limit the numbers of error during draining to prevent infinite loop.
> 
> This fix fate failure with THREADS>=4:
>   make fate-h264-attachment-631 THREADS=4
> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
> 
> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c| 21 +++--
>  libavcodec/internal.h  |  3 +++
>  libavcodec/pthread_frame.c | 15 +++
>  3 files changed, 29 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 6ff3c40..edfae55 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
> (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>  
> -if (avctx->internal->draining && !got_frame)
> -avci->draining_done = 1;
> +/* do not stop draining when got_frame != 0 or ret < 0 */
> +if (avctx->internal->draining && !got_frame) {
> +if (ret < 0) {
> +/* prevent infinite loop if a decoder wrongly always return 
> error on draining */
> +/* reasonable nb_errors_max = maximum b frames + thread count */
> +int nb_errors_max = 20 + (HAVE_THREADS && 
> avctx->active_thread_type & FF_THREAD_FRAME ?
> +avctx->thread_count : 1);
> +
> +if (avci->nb_draining_errors++ >= nb_errors_max) {
> +av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, 
> this is a bug. "
> +   "Stop draining and force EOF.\n");
> +avci->draining_done = 1;
> +ret = AVERROR_BUG;
> +}
> +} else {
> +avci->draining_done = 1;
> +}
> +}

Yeah, that's fancy and should mostly work. 20 should be large enough
to account for h264 and hevc, but in theory not all decoders need to
honor this delay (consider hardware decoder wrappers). But this is only
about the case of errors during draining, so it should be still ok.

In any case better than my earlier shithacks.

>  
>  avci->compat_decode_consumed += ret;
>  
> @@ -1659,6 +1675,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
>  {
>  avctx->internal->draining  = 0;
>  avctx->internal->draining_done = 0;
> +avctx->internal->nb_draining_errors = 0;
>  av_frame_unref(avctx->internal->buffer_frame);
>  av_frame_unref(avctx->internal->compat_decode_frame);
>  av_packet_unref(avctx->internal->buffer_pkt);
> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
> index 84d3362..caa46dc 100644
> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -200,6 +200,9 @@ typedef struct AVCodecInternal {
>  int showed_multi_packet_warning;
>  
>  int skip_samples_multiplier;
> +
> +/* to prevent infinite loop on errors when draining */
> +int nb_draining_errors;
>  } AVCodecInternal;
>  
>  struct AVCodecDefault {
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 13d6828..363b139 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -509,8 +509,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
>  /*
>   * Return the next available frame from the oldest thread.
>   * If we're at the end of the stream, then we have to skip threads that
> - * didn't output a frame, because we don't want to accidentally signal
> - * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
> + * didn't output a frame/error, because we don't want to accidentally 
> signal
> + * EOF (avpkt->size == 0 && *got_picture_ptr == 0 && err >= 0).
>   */
>  
>  do {
> @@ -526,20 +526,19 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
>  av_frame_move_ref(picture, p->frame);
>  *got_picture_ptr = p->got_frame;
>  picture->pkt_dts = p->avpkt.dts;
> -
> -if (p->result < 0)
> -err = p->result;
> +err = p->result;
>  
>  /*
>   * A later call with avkpt->size == 0 may loop over all threads,
> - * including this one, searching for a frame to return before being
> + * including this one, searching for a frame/error to return before 
> being
>   * stopped by the "finished != fctx->next_finished" condition.
> - * Make sure we don't mistakenly return the same frame again.
> + * Make sure we don't mistakenly return the same frame/error again.
>   */
>  p->got_frame = 0;
> +p->result = 0;
>  
>  if (finished >= avctx->thread_count) finished = 0;
> -} while (!avpkt->size && !*got_picture_ptr && finished != 
> fctx->next_finished);
> +} while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != 
> fctx->next_finished);
>

Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Ronald S. Bultje
Hi,

On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  wrote:

> So, all frames and errors are correctly reported in order.
> Also limit the numbers of error during draining to prevent infinite loop.
>
> This fix fate failure with THREADS>=4:
>   make fate-h264-attachment-631 THREADS=4
> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>
> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c| 21 +++--
>  libavcodec/internal.h  |  3 +++
>  libavcodec/pthread_frame.c | 15 +++
>  3 files changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 6ff3c40..edfae55 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
> (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>
> -if (avctx->internal->draining && !got_frame)
> -avci->draining_done = 1;
> +/* do not stop draining when got_frame != 0 or ret < 0 */
> +if (avctx->internal->draining && !got_frame) {
> +if (ret < 0) {
> +/* prevent infinite loop if a decoder wrongly always return
> error on draining */
> +/* reasonable nb_errors_max = maximum b frames + thread count
> */
> +int nb_errors_max = 20 + (HAVE_THREADS &&
> avctx->active_thread_type & FF_THREAD_FRAME ?
> +avctx->thread_count : 1);
> +
> +if (avci->nb_draining_errors++ >= nb_errors_max) {
> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
> draining, this is a bug. "
> +   "Stop draining and force EOF.\n");
> +avci->draining_done = 1;
> +ret = AVERROR_BUG;
> +}
> +} else {
> +avci->draining_done = 1;
> +}
> +}


Hm... I guess this is OK, it would be really nice to have a way of breaking
in developer builds (e.g. av_assert or so, although I guess technically
this could be enabled in prod builds also).

Also, Marton suggested to return AVERROR_EOF, maybe handle that here also
in addition to ret=0?

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


[FFmpeg-devel] [PATCH 2/2] avfilter: add video oscilloscope filter

2017-04-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  78 ++
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_datascope.c | 381 +
 4 files changed, 461 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2fe7ff7..d94f0aa 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10224,6 +10224,84 @@ other parameters is 0.
 These parameters correspond to the parameters assigned to the
 libopencv function @code{cvSmooth}.
 
+@section oscilloscope
+
+2D Video Oscilloscope.
+
+Useful to measure spatial impulse, step responses, chroma delays, etc.
+
+It accepts the following parameters:
+
+@table @option
+@item x
+Set scope center x position.
+
+@item y
+Set scope center y position.
+
+@item s
+Set scope size, relative to frame diagonal.
+
+@item t
+Set scope tilt/rotation.
+
+@item o
+Set trace opacity.
+
+@item tx
+Set trace center x position.
+
+@item ty
+Set trace center y position.
+
+@item tw
+Set trace width, relative to width of frame.
+
+@item th
+Set trace height, relative to height of frame.
+
+@item c
+Set which components to trace. By default it traces first three components.
+
+@item g
+Draw trace grid. By default is enabled.
+
+@item st
+Draw some statistics. By default is enabled.
+
+@item sc
+Draw scope. By default is enabled.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Inspect full first row of video frame.
+@example
+oscilloscope=x=0.5:y=0:s=1
+@end example
+
+@item
+Inspect full last row of video frame.
+@example
+oscilloscope=x=0.5:y=1:s=1
+@end example
+
+@item
+Inspect full 5th line of video frame of height 1080.
+@example
+oscilloscope=x=0.5:y=5/1080:s=1
+@end example
+
+@item
+Inspect full last column of video frame.
+@example
+oscilloscope=x=1:y=0.5:s=1:t=1
+@end example
+
+@end itemize
+
 @anchor{overlay}
 @section overlay
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e40c6fe..66c36e4 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -236,6 +236,7 @@ OBJS-$(CONFIG_NULL_FILTER)   += vf_null.o
 OBJS-$(CONFIG_OCR_FILTER)+= vf_ocr.o
 OBJS-$(CONFIG_OCV_FILTER)+= vf_libopencv.o
 OBJS-$(CONFIG_OPENCL)+= deshake_opencl.o 
unsharp_opencl.o
+OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)   += vf_datascope.o
 OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o dualinput.o 
framesync.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 0852b54..8fb87eb 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -246,6 +246,7 @@ static void register_all(void)
 REGISTER_FILTER(NULL,   null,   vf);
 REGISTER_FILTER(OCR,ocr,vf);
 REGISTER_FILTER(OCV,ocv,vf);
+REGISTER_FILTER(OSCILLOSCOPE,   oscilloscope,   vf);
 REGISTER_FILTER(OVERLAY,overlay,vf);
 REGISTER_FILTER(OWDENOISE,  owdenoise,  vf);
 REGISTER_FILTER(PAD,pad,vf);
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 5ad4bb8..4c3c903 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -630,3 +630,384 @@ AVFilter ff_vf_pixscope = {
 .inputs= pixscope_inputs,
 .outputs   = pixscope_outputs,
 };
+
+typedef struct PixelValues {
+uint16_t p[4];
+} PixelValues;
+
+typedef struct OscilloscopeContext {
+const AVClass *class;
+
+float xpos, ypos;
+float tx, ty;
+float size;
+float tilt;
+float theight, twidth;
+float o;
+int components;
+int grid;
+int statistics;
+int scope;
+
+int x1, y1, x2, y2;
+int ox, oy;
+int height, width;
+
+int max;
+int nb_planes;
+int nb_comps;
+int is_rgb;
+uint8_t rgba_map[4];
+FFDrawContext draw;
+FFDrawColor   dark;
+FFDrawColor   black;
+FFDrawColor   white;
+FFDrawColor   green;
+FFDrawColor   blue;
+FFDrawColor   red;
+FFDrawColor   cyan;
+FFDrawColor   magenta;
+FFDrawColor   gray;
+FFDrawColor  *colors[4];
+
+int nb_values;
+PixelValues  *values;
+
+void (*pick_color)(FFDrawContext *draw, FFDrawColor *color, AVFrame *in, 
int x, int y, int *value);
+void (*draw_trace)(struct OscilloscopeContext *s, AVFrame *frame);
+} OscilloscopeContext;
+
+#define OOFFSET(x) offsetof(OscilloscopeContext, x)
+
+static const AVOption oscilloscope_options[] = {
+{ "x",  "set scope x position",OOFFSET(xpos),   AV_OPT_TYPE_FLOAT, 
{.dbl=0.5}, 0, 1,  FLAGS },
+{ "y",  "set scope y position",OOFFSET(ypos),   AV_OPT_TYPE_FLOAT, 
{.dbl=0.5}, 0, 1,  FLAGS },
+{ "s",  "set scope size",  OOFFSET(size),   AV_OPT_TYPE_FLOAT, 
{.dbl=0.8}, 0, 1,  FLAGS },
+{ "t",  "set 

[FFmpeg-devel] [PATCH 1/2] avfilter: add pixscope filter

2017-04-28 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_datascope.c | 225 +++--
 3 files changed, 220 insertions(+), 7 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 074c690..e40c6fe 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -245,6 +245,7 @@ OBJS-$(CONFIG_PERMS_FILTER)  += f_perms.o
 OBJS-$(CONFIG_PERSPECTIVE_FILTER)+= vf_perspective.o
 OBJS-$(CONFIG_PHASE_FILTER)  += vf_phase.o
 OBJS-$(CONFIG_PIXDESCTEST_FILTER)+= vf_pixdesctest.o
+OBJS-$(CONFIG_PIXSCOPE_FILTER)   += vf_datascope.o
 OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
 OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index c69f79e..0852b54 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -255,6 +255,7 @@ static void register_all(void)
 REGISTER_FILTER(PERSPECTIVE,perspective,vf);
 REGISTER_FILTER(PHASE,  phase,  vf);
 REGISTER_FILTER(PIXDESCTEST,pixdesctest,vf);
+REGISTER_FILTER(PIXSCOPE,   pixscope,   vf);
 REGISTER_FILTER(PP, pp, vf);
 REGISTER_FILTER(PP7,pp7,vf);
 REGISTER_FILTER(PREMULTIPLY,premultiply,vf);
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c
index 01a5d99..5ad4bb8 100644
--- a/libavfilter/vf_datascope.c
+++ b/libavfilter/vf_datascope.c
@@ -76,7 +76,7 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
 }
 
-static void draw_text(DatascopeContext *s, AVFrame *frame, FFDrawColor *color,
+static void draw_text(FFDrawContext *draw, AVFrame *frame, FFDrawColor *color,
   int x0, int y0, const uint8_t *text, int vertical)
 {
 int x = x0;
@@ -87,7 +87,7 @@ static void draw_text(DatascopeContext *s, AVFrame *frame, 
FFDrawColor *color,
 y0 += 8;
 continue;
 }
-ff_blend_mask(&s->draw, color, frame->data, frame->linesize,
+ff_blend_mask(draw, color, frame->data, frame->linesize,
   frame->width, frame->height,
   avpriv_cga_font + *text * 8, 1, 8, 8, 0, 0, x, y0);
 if (vertical) {
@@ -201,7 +201,7 @@ static int filter_color2(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs
 char text[256];
 
 snprintf(text, sizeof(text), format[C>>2], value[p]);
-draw_text(s, out, &reverse, xoff + x * C * 10 + 2, yoff + y * 
P * 12 + p * 10 + 2, text, 0);
+draw_text(&s->draw, out, &reverse, xoff + x * C * 10 + 2, yoff 
+ y * P * 12 + p * 10 + 2, text, 0);
 }
 }
 }
@@ -239,7 +239,7 @@ static int filter_color(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 char text[256];
 
 snprintf(text, sizeof(text), format[C>>2], value[p]);
-draw_text(s, out, &color, xoff + x * C * 10 + 2, yoff + y * P 
* 12 + p * 10 + 2, text, 0);
+draw_text(&s->draw, out, &color, xoff + x * C * 10 + 2, yoff + 
y * P * 12 + p * 10 + 2, text, 0);
 }
 }
 }
@@ -276,7 +276,7 @@ static int filter_mono(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)
 char text[256];
 
 snprintf(text, sizeof(text), format[C>>2], value[p]);
-draw_text(s, out, &s->white, xoff + x * C * 10 + 2, yoff + y * 
P * 12 + p * 10 + 2, text, 0);
+draw_text(&s->draw, out, &s->white, xoff + x * C * 10 + 2, 
yoff + y * P * 12 + p * 10 + 2, text, 0);
 }
 }
 }
@@ -328,7 +328,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
   0, xmaxlen + y * P * 12 + (P + 1) * P - 2, 
ymaxlen, 10);
 
-draw_text(s, out, &s->yellow, 2, xmaxlen + y * P * 12 + (P + 1) * 
P, text, 0);
+draw_text(&s->draw, out, &s->yellow, 2, xmaxlen + y * P * 12 + (P 
+ 1) * P, text, 0);
 }
 
 for (x = 0; x < X; x++) {
@@ -337,7 +337,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 ff_fill_rectangle(&s->draw, &s->gray, out->data, out->linesize,
   ymaxlen + x * C * 10 + 2 * C - 2, 0, 10, 
xmaxlen);
 
-draw_text(s, out, &s->yellow, ymaxlen + x * C * 10 + 2 * C, 2, 
text, 1);
+draw_text(&s->draw, out, &s->yellow, ymaxlen + x * C * 10 + 2 * C, 
2, text, 1);
 }
 }
 
@@ -419,3 +419,214 @@ AVFilter ff_vf_datascope = {
 .outputs   = outputs,
 .flags = AVFILTER_FLAG_SLICE_THREADS,
 }

[FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: fix macro parameter escaping

2017-04-28 Thread Matthieu Bouron
Untested: fixes ticket #6324.
---
 libavcodec/aarch64/simple_idct_neon.S | 42 +--
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavcodec/aarch64/simple_idct_neon.S 
b/libavcodec/aarch64/simple_idct_neon.S
index 52273420f9..fa43bcfb01 100644
--- a/libavcodec/aarch64/simple_idct_neon.S
+++ b/libavcodec/aarch64/simple_idct_neon.S
@@ -74,21 +74,21 @@ endconst
 .endm
 
 .macro idct_col4_top y1 y2 y3 y4 i l
-smull\i v7.4S,  \y3\().\l, z2
-smull\i v16.4S, \y3\().\l, z6
-smull\i v17.4S, \y2\().\l, z1
+smull\i v7.4S,  \y3\().\l\(), z2
+smull\i v16.4S, \y3\().\l\(), z6
+smull\i v17.4S, \y2\().\l\(), z1
 add v19.4S, v23.4S, v7.4S
-smull\i v18.4S, \y2\().\l, z3
+smull\i v18.4S, \y2\().\l\(), z3
 add v20.4S, v23.4S, v16.4S
-smull\i v5.4S,  \y2\().\l, z5
+smull\i v5.4S,  \y2\().\l\(), z5
 sub v21.4S, v23.4S, v16.4S
-smull\i v6.4S,  \y2\().\l, z7
+smull\i v6.4S,  \y2\().\l\(), z7
 sub v22.4S, v23.4S, v7.4S
 
-smlal\i v17.4S, \y4\().\l, z3
-smlsl\i v18.4S, \y4\().\l, z7
-smlsl\i v5.4S,  \y4\().\l, z1
-smlsl\i v6.4S,  \y4\().\l, z5
+smlal\i v17.4S, \y4\().\l\(), z3
+smlsl\i v18.4S, \y4\().\l\(), z7
+smlsl\i v5.4S,  \y4\().\l\(), z1
+smlsl\i v6.4S,  \y4\().\l\(), z5
 .endm
 
 .macro idct_row4_neon y1 y2 y3 y4 pass
@@ -171,7 +171,7 @@ function idct_col4_neon\i
 cmp x4, #0
 beq 1f
 
-smull\i v7.4S,  v28.\l, z4
+smull\i v7.4S,  v28.\l\(), z4
 add v19.4S, v19.4S, v7.4S
 sub v20.4S, v20.4S, v7.4S
 sub v21.4S, v21.4S, v7.4S
@@ -181,17 +181,17 @@ function idct_col4_neon\i
 cmp x5, #0
 beq 2f
 
-smlal\i v17.4S, v29.\l, z5
-smlsl\i v18.4S, v29.\l, z1
-smlal\i v5.4S,  v29.\l, z7
-smlal\i v6.4S,  v29.\l, z3
+smlal\i v17.4S, v29.\l\(), z5
+smlsl\i v18.4S, v29.\l\(), z1
+smlal\i v5.4S,  v29.\l\(), z7
+smlal\i v6.4S,  v29.\l\(), z3
 
 2:  mov x5, v31.D[\i - 1]
 cmp x4, #0
 beq 3f
 
-smull\i v7.4S,  v30.\l, z6
-smull\i v16.4S, v30.\l, z2
+smull\i v7.4S,  v30.\l\(), z6
+smull\i v16.4S, v30.\l\(), z2
 add v19.4S, v19.4S, v7.4S
 sub v22.4S, v22.4S, v7.4S
 sub v20.4S, v20.4S, v16.4S
@@ -200,10 +200,10 @@ function idct_col4_neon\i
 3:  cmp x5, #0
 beq 4f
 
-smlal\i v17.4S, v31.\l, z7
-smlsl\i v18.4S, v31.\l, z5
-smlal\i v5.4S,  v31.\l, z3
-smlsl\i v6.4S,  v31.\l, z1
+smlal\i v17.4S, v31.\l\(), z7
+smlsl\i v18.4S, v31.\l\(), z5
+smlal\i v5.4S,  v31.\l\(), z3
+smlsl\i v6.4S,  v31.\l\(), z1
 
 4:  addhn   v7.4H, v19.4S, v17.4S
 addhn2  v7.8H, v20.4S, v18.4S
-- 
2.12.2

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


Re: [FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: fix macro parameter escaping

2017-04-28 Thread Matthieu Bouron
On Fri, Apr 28, 2017 at 4:53 PM, Matthieu Bouron 
wrote:

> Untested: fixes ticket #6324.
> ---
>  libavcodec/aarch64/simple_idct_neon.S | 42 +-
> -
>  1 file changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/libavcodec/aarch64/simple_idct_neon.S
> b/libavcodec/aarch64/simple_idct_neon.S
> index 52273420f9..fa43bcfb01 100644
> --- a/libavcodec/aarch64/simple_idct_neon.S
> +++ b/libavcodec/aarch64/simple_idct_neon.S
> @@ -74,21 +74,21 @@ endconst
>  .endm
>
>  .macro idct_col4_top y1 y2 y3 y4 i l
> -smull\i v7.4S,  \y3\().\l, z2
> -smull\i v16.4S, \y3\().\l, z6
> -smull\i v17.4S, \y2\().\l, z1
> +smull\i v7.4S,  \y3\().\l\(), z2
> +smull\i v16.4S, \y3\().\l\(), z6
> +smull\i v17.4S, \y2\().\l\(), z1
>  add v19.4S, v23.4S, v7.4S
> -smull\i v18.4S, \y2\().\l, z3
> +smull\i v18.4S, \y2\().\l\(), z3
>  add v20.4S, v23.4S, v16.4S
> -smull\i v5.4S,  \y2\().\l, z5
> +smull\i v5.4S,  \y2\().\l\(), z5
>  sub v21.4S, v23.4S, v16.4S
> -smull\i v6.4S,  \y2\().\l, z7
> +smull\i v6.4S,  \y2\().\l\(), z7
>  sub v22.4S, v23.4S, v7.4S
>
> -smlal\i v17.4S, \y4\().\l, z3
> -smlsl\i v18.4S, \y4\().\l, z7
> -smlsl\i v5.4S,  \y4\().\l, z1
> -smlsl\i v6.4S,  \y4\().\l, z5
> +smlal\i v17.4S, \y4\().\l\(), z3
> +smlsl\i v18.4S, \y4\().\l\(), z7
> +smlsl\i v5.4S,  \y4\().\l\(), z1
> +smlsl\i v6.4S,  \y4\().\l\(), z5
>  .endm
>
>  .macro idct_row4_neon y1 y2 y3 y4 pass
> @@ -171,7 +171,7 @@ function idct_col4_neon\i
>  cmp x4, #0
>  beq 1f
>
> -smull\i v7.4S,  v28.\l, z4
> +smull\i v7.4S,  v28.\l\(), z4
>  add v19.4S, v19.4S, v7.4S
>  sub v20.4S, v20.4S, v7.4S
>  sub v21.4S, v21.4S, v7.4S
> @@ -181,17 +181,17 @@ function idct_col4_neon\i
>  cmp x5, #0
>  beq 2f
>
> -smlal\i v17.4S, v29.\l, z5
> -smlsl\i v18.4S, v29.\l, z1
> -smlal\i v5.4S,  v29.\l, z7
> -smlal\i v6.4S,  v29.\l, z3
> +smlal\i v17.4S, v29.\l\(), z5
> +smlsl\i v18.4S, v29.\l\(), z1
> +smlal\i v5.4S,  v29.\l\(), z7
> +smlal\i v6.4S,  v29.\l\(), z3
>
>  2:  mov x5, v31.D[\i - 1]
>  cmp x4, #0
>  beq 3f
>
> -smull\i v7.4S,  v30.\l, z6
> -smull\i v16.4S, v30.\l, z2
> +smull\i v7.4S,  v30.\l\(), z6
> +smull\i v16.4S, v30.\l\(), z2
>  add v19.4S, v19.4S, v7.4S
>  sub v22.4S, v22.4S, v7.4S
>  sub v20.4S, v20.4S, v16.4S
> @@ -200,10 +200,10 @@ function idct_col4_neon\i
>  3:  cmp x5, #0
>  beq 4f
>
> -smlal\i v17.4S, v31.\l, z7
> -smlsl\i v18.4S, v31.\l, z5
> -smlal\i v5.4S,  v31.\l, z3
> -smlsl\i v6.4S,  v31.\l, z1
> +smlal\i v17.4S, v31.\l\(), z7
> +smlsl\i v18.4S, v31.\l\(), z5
> +smlal\i v5.4S,  v31.\l\(), z3
> +smlsl\i v6.4S,  v31.\l\(), z1
>
>  4:  addhn   v7.4H, v19.4S, v17.4S
>  addhn2  v7.8H, v20.4S, v18.4S
> --
> 2.12.2
>
>
Please discard this patch as it does not fix the mentioned trac ticket
(which is in fact invalid).

Sorry for the noise,
Matthieu
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Muhammad Faiz
On Fri, Apr 28, 2017 at 5:51 PM, wm4  wrote:
> On Fri, 28 Apr 2017 17:19:13 +0700
> Muhammad Faiz  wrote:
>
>> So, all frames and errors are correctly reported in order.
>> Also limit the numbers of error during draining to prevent infinite loop.
>>
>> This fix fate failure with THREADS>=4:
>>   make fate-h264-attachment-631 THREADS=4
>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>>
>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> Signed-off-by: Muhammad Faiz 
>> ---
>>  libavcodec/decode.c| 21 +++--
>>  libavcodec/internal.h  |  3 +++
>>  libavcodec/pthread_frame.c | 15 +++
>>  3 files changed, 29 insertions(+), 10 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 6ff3c40..edfae55 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
>> (AVRational){avctx->ticks_per_frame, 1}));
>>  #endif
>>
>> -if (avctx->internal->draining && !got_frame)
>> -avci->draining_done = 1;
>> +/* do not stop draining when got_frame != 0 or ret < 0 */
>> +if (avctx->internal->draining && !got_frame) {
>> +if (ret < 0) {
>> +/* prevent infinite loop if a decoder wrongly always return 
>> error on draining */
>> +/* reasonable nb_errors_max = maximum b frames + thread count */
>> +int nb_errors_max = 20 + (HAVE_THREADS && 
>> avctx->active_thread_type & FF_THREAD_FRAME ?
>> +avctx->thread_count : 1);
>> +
>> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>> +av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, 
>> this is a bug. "
>> +   "Stop draining and force EOF.\n");
>> +avci->draining_done = 1;
>> +ret = AVERROR_BUG;
>> +}
>> +} else {
>> +avci->draining_done = 1;
>> +}
>> +}
>
> Yeah, that's fancy and should mostly work. 20 should be large enough
> to account for h264 and hevc, but in theory not all decoders need to
> honor this delay (consider hardware decoder wrappers). But this is only
> about the case of errors during draining, so it should be still ok.
>
> In any case better than my earlier shithacks.
>
>>
>>  avci->compat_decode_consumed += ret;
>>
>> @@ -1659,6 +1675,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
>>  {
>>  avctx->internal->draining  = 0;
>>  avctx->internal->draining_done = 0;
>> +avctx->internal->nb_draining_errors = 0;
>>  av_frame_unref(avctx->internal->buffer_frame);
>>  av_frame_unref(avctx->internal->compat_decode_frame);
>>  av_packet_unref(avctx->internal->buffer_pkt);
>> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
>> index 84d3362..caa46dc 100644
>> --- a/libavcodec/internal.h
>> +++ b/libavcodec/internal.h
>> @@ -200,6 +200,9 @@ typedef struct AVCodecInternal {
>>  int showed_multi_packet_warning;
>>
>>  int skip_samples_multiplier;
>> +
>> +/* to prevent infinite loop on errors when draining */
>> +int nb_draining_errors;
>>  } AVCodecInternal;
>>
>>  struct AVCodecDefault {
>> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
>> index 13d6828..363b139 100644
>> --- a/libavcodec/pthread_frame.c
>> +++ b/libavcodec/pthread_frame.c
>> @@ -509,8 +509,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
>>  /*
>>   * Return the next available frame from the oldest thread.
>>   * If we're at the end of the stream, then we have to skip threads that
>> - * didn't output a frame, because we don't want to accidentally signal
>> - * EOF (avpkt->size == 0 && *got_picture_ptr == 0).
>> + * didn't output a frame/error, because we don't want to accidentally 
>> signal
>> + * EOF (avpkt->size == 0 && *got_picture_ptr == 0 && err >= 0).
>>   */
>>
>>  do {
>> @@ -526,20 +526,19 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
>>  av_frame_move_ref(picture, p->frame);
>>  *got_picture_ptr = p->got_frame;
>>  picture->pkt_dts = p->avpkt.dts;
>> -
>> -if (p->result < 0)
>> -err = p->result;
>> +err = p->result;
>>
>>  /*
>>   * A later call with avkpt->size == 0 may loop over all threads,
>> - * including this one, searching for a frame to return before being
>> + * including this one, searching for a frame/error to return before 
>> being
>>   * stopped by the "finished != fctx->next_finished" condition.
>> - * Make sure we don't mistakenly return the same frame again.
>> + * Make sure we don't mistakenly return the same frame/error again.
>>   */
>>  p->got_frame = 0;
>> +p->result = 0;
>>
>>  if (finished >= avctx->thread_count) finished = 0;
>> -} while (!avpkt->size && !*got_

Re: [FFmpeg-devel] [PATCH v9] - Added Turing codec interface for ffmpeg

2017-04-28 Thread Saverio Blasi
Hi Michael,

The patch applies nicely to my local ffmpeg repository. It is based on commit 
hash dd49eff93095110d2e878bbcc81b0062590d865f from the 23rd of April, so maybe 
something changed in the Configure file in the past few days?

Thanks,
Saverio

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
Michael Niedermayer
Sent: 26 April 2017 14:02
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v9] - Added Turing codec interface for ffmpeg

On Wed, Apr 26, 2017 at 07:55:59AM +, Saverio Blasi wrote:
> Hello,
>
> We have recently circulated this new version (see below) of our patch for 
> integrating our HEVC Turing codec with FFmpeg. Assuming that there are no 
> more requests for changes, we would like to understand what is the timeline 
> for integration within the project.
>
> Thanks a lot,

seems i cant automaticaly apply this locally

Applying: - Added Turing codec interface for ffmpeg
.git/rebase-apply/patch:56: trailing whitespace.
 die "ERROR: libturing requires turing api
error: corrupt patch at line 63
error: could not build fake ancestor
Patch failed at 0001 - Added Turing codec interface for ffmpeg The copy of the 
patch that failed is found in: .git/rebase-apply/patch When you have resolved 
this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".


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

Those who are best at talking, realize last or never when they are wrong.


-
http://www.bbc.co.uk
This e-mail (and any attachments) is confidential and
may contain personal views which are not the views of the BBC unless 
specifically stated.
If you have received it in
error, please delete it from your system.
Do not use, copy or disclose the
information in any way nor act in reliance on it and notify the sender
immediately.
Please note that the BBC monitors e-mails
sent or received.
Further communication will signify your consent to
this.
-
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] FFmpeg development requirement

2017-04-28 Thread Andres Manguel
Hi all,

We are looking for an ffmpeg development to compose multiple matroska files to 
a single mpeg4 file.

Bellow you will find the requirements definition for this composer.

Hope to hear from you soon.

Thanks in advance,
Andres Manguel

- Technology

FFmpeg Fast Video Processing.
AWS to iOS and Android Streaming.

- Input

Webm Video and Audio Individual files.

- Output

MPEG4 Video and Audio Single file.

- Resizable

Mobile Phone Display Size.

- Background

Vertical Video.
0 (Transparent) to 1 Video.

- Front

Circular Videos.
0 to 9 Videos.

- Layout



- Text

To be defined.


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


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Muhammad Faiz
On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  wrote:
> Hi,
>
> On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  wrote:
>>
>> So, all frames and errors are correctly reported in order.
>> Also limit the numbers of error during draining to prevent infinite loop.
>>
>> This fix fate failure with THREADS>=4:
>>   make fate-h264-attachment-631 THREADS=4
>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>>
>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> Signed-off-by: Muhammad Faiz 
>> ---
>>  libavcodec/decode.c| 21 +++--
>>  libavcodec/internal.h  |  3 +++
>>  libavcodec/pthread_frame.c | 15 +++
>>  3 files changed, 29 insertions(+), 10 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 6ff3c40..edfae55 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
>> (AVRational){avctx->ticks_per_frame, 1}));
>>  #endif
>>
>> -if (avctx->internal->draining && !got_frame)
>> -avci->draining_done = 1;
>> +/* do not stop draining when got_frame != 0 or ret < 0 */
>> +if (avctx->internal->draining && !got_frame) {
>> +if (ret < 0) {
>> +/* prevent infinite loop if a decoder wrongly always return
>> error on draining */
>> +/* reasonable nb_errors_max = maximum b frames + thread count
>> */
>> +int nb_errors_max = 20 + (HAVE_THREADS &&
>> avctx->active_thread_type & FF_THREAD_FRAME ?
>> +avctx->thread_count : 1);
>> +
>> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
>> draining, this is a bug. "
>> +   "Stop draining and force EOF.\n");
>> +avci->draining_done = 1;
>> +ret = AVERROR_BUG;
>> +}
>> +} else {
>> +avci->draining_done = 1;
>> +}
>> +}
>
>
> Hm... I guess this is OK, it would be really nice to have a way of breaking
> in developer builds (e.g. av_assert or so, although I guess technically this
> could be enabled in prod builds also).

Add av_assert2().

>
> Also, Marton suggested to return AVERROR_EOF, maybe handle that here also in
> addition to ret=0?

Modified.

Updated patch attached.

Thank's
From f684770e016fa36d458d08383065815882cbc7f8 Mon Sep 17 00:00:00 2001
From: Muhammad Faiz 
Date: Fri, 28 Apr 2017 17:08:39 +0700
Subject: [PATCH v3] avcodec/pthread_frame, decode: allow errors to happen on
 draining

So, all frames and errors are correctly reported in order.
Also limit the number of errors during draining to prevent infinite loop.
Also return AVERROR_EOF directly on EOF instead of only setting draining_done.

This fix fate failure with THREADS>=4:
  make fate-h264-attachment-631 THREADS=4
This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.

Suggested-by: wm4, Ronald S. Bultje, Marton Balint
Signed-off-by: Muhammad Faiz 
---
 libavcodec/decode.c| 23 +--
 libavcodec/internal.h  |  3 +++
 libavcodec/pthread_frame.c | 15 +++
 3 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6ff3c40..fb4d4af 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -568,8 +568,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
 #endif
 
-if (avctx->internal->draining && !got_frame)
-avci->draining_done = 1;
+/* do not stop draining when got_frame != 0 or ret < 0 */
+if (avctx->internal->draining && !got_frame) {
+if (ret < 0) {
+/* prevent infinite loop if a decoder wrongly always return error on draining */
+/* reasonable nb_errors_max = maximum b frames + thread count */
+int nb_errors_max = 20 + (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME ?
+avctx->thread_count : 1);
+
+if (avci->nb_draining_errors++ >= nb_errors_max) {
+av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, this is a bug. "
+   "Stop draining and force EOF.\n");
+avci->draining_done = 1;
+ret = AVERROR_BUG;
+av_assert2(0);
+}
+} else {
+avci->draining_done = 1;
+ret = AVERROR_EOF;
+}
+}
 
 avci->compat_decode_consumed += ret;
 
@@ -1659,6 +1677,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
 {
 avctx->internal->draining  = 0;
 avctx->internal->draining_done = 0;
+avctx->internal->nb_draining_errors = 0;
 av_frame_unref(avctx->internal->buffer_frame);
 av_frame_unref(avctx->internal->compat_decode_frame);
 av_packet_unref(avctx->internal->

Re: [FFmpeg-devel] [PATCH] avfilter/lavfutils: use image2pipe demuxer on ff_load_image

2017-04-28 Thread Muhammad Faiz
On Tue, Apr 25, 2017 at 2:43 PM, Muhammad Faiz  wrote:
> allow protocols other than file to be used
> for example, use data protocol to embed a file in script
>
> Signed-off-by: Muhammad Faiz 
> ---
>  libavfilter/lavfutils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavfilter/lavfutils.c b/libavfilter/lavfutils.c
> index 706badf..35878b3 100644
> --- a/libavfilter/lavfutils.c
> +++ b/libavfilter/lavfutils.c
> @@ -38,7 +38,7 @@ int ff_load_image(uint8_t *data[4], int linesize[4],
>
>  av_register_all();
>
> -iformat = av_find_input_format("image2");
> +iformat = av_find_input_format("image2pipe");
>  if ((ret = avformat_open_input(&format_ctx, filename, iformat, NULL)) < 
> 0) {
>  av_log(log_ctx, AV_LOG_ERROR,
> "Failed to open input file '%s'\n", filename);
> --
> 2.9.3
>

Applied

Thank's
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/aarch64/simple_idct: separate macro arguments with commas

2017-04-28 Thread Matthieu Bouron
Untested: fixes ticket #6324.
---
 libavcodec/aarch64/simple_idct_neon.S | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/aarch64/simple_idct_neon.S 
b/libavcodec/aarch64/simple_idct_neon.S
index 52273420f9..d31f72a609 100644
--- a/libavcodec/aarch64/simple_idct_neon.S
+++ b/libavcodec/aarch64/simple_idct_neon.S
@@ -61,19 +61,19 @@ endconst
 br  x10
 .endm
 
-.macro smull1 a b c
+.macro smull1 a, b, c
 smull   \a, \b, \c
 .endm
 
-.macro smlal1 a b c
+.macro smlal1 a, b, c
 smlal   \a, \b, \c
 .endm
 
-.macro smlsl1 a b c
+.macro smlsl1 a, b, c
 smlsl   \a, \b, \c
 .endm
 
-.macro idct_col4_top y1 y2 y3 y4 i l
+.macro idct_col4_top y1, y2, y3, y4, i, l
 smull\i v7.4S,  \y3\().\l, z2
 smull\i v16.4S, \y3\().\l, z6
 smull\i v17.4S, \y2\().\l, z1
@@ -91,7 +91,7 @@ endconst
 smlsl\i v6.4S,  \y4\().\l, z5
 .endm
 
-.macro idct_row4_neon y1 y2 y3 y4 pass
+.macro idct_row4_neon y1, y2, y3, y4, pass
 ld1 {\y1\().2D-\y2\().2D}, [x2], #32
 moviv23.4S, #1<<2, lsl #8
 orr v5.16B, \y1\().16B, \y2\().16B
@@ -153,7 +153,7 @@ endconst
 trn2\y4\().4S, v17.4S, v19.4S
 .endm
 
-.macro declare_idct_col4_neon i l
+.macro declare_idct_col4_neon i, l
 function idct_col4_neon\i
 dup v23.4H, z4c
 .if \i == 1
-- 
2.12.2

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


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Muhammad Faiz
On Fri, Apr 28, 2017 at 11:23 PM, Muhammad Faiz  wrote:
> On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  wrote:
>> Hi,
>>
>> On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  wrote:
>>>
>>> So, all frames and errors are correctly reported in order.
>>> Also limit the numbers of error during draining to prevent infinite loop.
>>>
>>> This fix fate failure with THREADS>=4:
>>>   make fate-h264-attachment-631 THREADS=4
>>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>>>
>>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>>> Signed-off-by: Muhammad Faiz 
>>> ---
>>>  libavcodec/decode.c| 21 +++--
>>>  libavcodec/internal.h  |  3 +++
>>>  libavcodec/pthread_frame.c | 15 +++
>>>  3 files changed, 29 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>>> index 6ff3c40..edfae55 100644
>>> --- a/libavcodec/decode.c
>>> +++ b/libavcodec/decode.c
>>> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
>>> (AVRational){avctx->ticks_per_frame, 1}));
>>>  #endif
>>>
>>> -if (avctx->internal->draining && !got_frame)
>>> -avci->draining_done = 1;
>>> +/* do not stop draining when got_frame != 0 or ret < 0 */
>>> +if (avctx->internal->draining && !got_frame) {
>>> +if (ret < 0) {
>>> +/* prevent infinite loop if a decoder wrongly always return
>>> error on draining */
>>> +/* reasonable nb_errors_max = maximum b frames + thread count
>>> */
>>> +int nb_errors_max = 20 + (HAVE_THREADS &&
>>> avctx->active_thread_type & FF_THREAD_FRAME ?
>>> +avctx->thread_count : 1);
>>> +
>>> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>>> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
>>> draining, this is a bug. "
>>> +   "Stop draining and force EOF.\n");
>>> +avci->draining_done = 1;
>>> +ret = AVERROR_BUG;
>>> +}
>>> +} else {
>>> +avci->draining_done = 1;
>>> +}
>>> +}
>>
>>
>> Hm... I guess this is OK, it would be really nice to have a way of breaking
>> in developer builds (e.g. av_assert or so, although I guess technically this
>> could be enabled in prod builds also).
>
> Add av_assert2().
>
>>
>> Also, Marton suggested to return AVERROR_EOF, maybe handle that here also in
>> addition to ret=0?
>
> Modified.
>
> Updated patch attached.
>
> Thank's

>+} else {
>+avci->draining_done = 1;
>+ret = AVERROR_EOF;
>+}
>+}
>
>avci->compat_decode_consumed += ret;

I'm not sure about changing ret. It seems not trivial. So, I drop the
updated patch, and use the original patch.

Thank's
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Michael Niedermayer
On Fri, Apr 28, 2017 at 11:23:10PM +0700, Muhammad Faiz wrote:
> On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  wrote:
> > Hi,
> >
> > On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  wrote:
> >>
> >> So, all frames and errors are correctly reported in order.
> >> Also limit the numbers of error during draining to prevent infinite loop.
> >>
> >> This fix fate failure with THREADS>=4:
> >>   make fate-h264-attachment-631 THREADS=4
> >> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
> >>
> >> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> >> Signed-off-by: Muhammad Faiz 
> >> ---
> >>  libavcodec/decode.c| 21 +++--
> >>  libavcodec/internal.h  |  3 +++
> >>  libavcodec/pthread_frame.c | 15 +++
> >>  3 files changed, 29 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> >> index 6ff3c40..edfae55 100644
> >> --- a/libavcodec/decode.c
> >> +++ b/libavcodec/decode.c
> >> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
> >>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
> >> (AVRational){avctx->ticks_per_frame, 1}));
> >>  #endif
> >>
> >> -if (avctx->internal->draining && !got_frame)
> >> -avci->draining_done = 1;
> >> +/* do not stop draining when got_frame != 0 or ret < 0 */
> >> +if (avctx->internal->draining && !got_frame) {
> >> +if (ret < 0) {
> >> +/* prevent infinite loop if a decoder wrongly always return
> >> error on draining */
> >> +/* reasonable nb_errors_max = maximum b frames + thread count
> >> */
> >> +int nb_errors_max = 20 + (HAVE_THREADS &&
> >> avctx->active_thread_type & FF_THREAD_FRAME ?
> >> +avctx->thread_count : 1);
> >> +
> >> +if (avci->nb_draining_errors++ >= nb_errors_max) {
> >> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
> >> draining, this is a bug. "
> >> +   "Stop draining and force EOF.\n");
> >> +avci->draining_done = 1;
> >> +ret = AVERROR_BUG;
> >> +}
> >> +} else {
> >> +avci->draining_done = 1;
> >> +}
> >> +}
> >
> >
> > Hm... I guess this is OK, it would be really nice to have a way of breaking
> > in developer builds (e.g. av_assert or so, although I guess technically this
> > could be enabled in prod builds also).
> 
> Add av_assert2().
> 
> >
> > Also, Marton suggested to return AVERROR_EOF, maybe handle that here also in
> > addition to ret=0?
> 
> Modified.
> 
> Updated patch attached.
> 
> Thank's

>  decode.c|   23 +--
>  internal.h  |3 +++
>  pthread_frame.c |   15 +++
>  3 files changed, 31 insertions(+), 10 deletions(-)
> d3049c52598070baa9566fc98a089111732595fa  
> 0001-avcodec-pthread_frame-decode-allow-errors-to-happen-.patch
> From f684770e016fa36d458d08383065815882cbc7f8 Mon Sep 17 00:00:00 2001
> From: Muhammad Faiz 
> Date: Fri, 28 Apr 2017 17:08:39 +0700
> Subject: [PATCH v3] avcodec/pthread_frame, decode: allow errors to happen on
>  draining
> 
> So, all frames and errors are correctly reported in order.
> Also limit the number of errors during draining to prevent infinite loop.
> Also return AVERROR_EOF directly on EOF instead of only setting draining_done.
> 
> This fix fate failure with THREADS>=4:
>   make fate-h264-attachment-631 THREADS=4
> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
> 
> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
> Signed-off-by: Muhammad Faiz 
> ---
>  libavcodec/decode.c| 23 +--
>  libavcodec/internal.h  |  3 +++
>  libavcodec/pthread_frame.c | 15 +++
>  3 files changed, 31 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 6ff3c40..fb4d4af 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -568,8 +568,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
> (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>  
> -if (avctx->internal->draining && !got_frame)
> -avci->draining_done = 1;
> +/* do not stop draining when got_frame != 0 or ret < 0 */
> +if (avctx->internal->draining && !got_frame) {
> +if (ret < 0) {
> +/* prevent infinite loop if a decoder wrongly always return 
> error on draining */
> +/* reasonable nb_errors_max = maximum b frames + thread count */
> +int nb_errors_max = 20 + (HAVE_THREADS && 
> avctx->active_thread_type & FF_THREAD_FRAME ?
> +avctx->thread_count : 1);
> +
> +if (avci->nb_draining_errors++ >= nb_errors_max) {
> +av_log(avctx, AV_LOG_ERROR, "Too many errors when draining, 
> this is a bug. "
> +   "Stop draining and force EOF.\n");
> +avci->draining_done =

Re: [FFmpeg-devel] [PATCH v2] avcodec/pthread_frame, decode: allow errors to happen on draining

2017-04-28 Thread Muhammad Faiz
On Sat, Apr 29, 2017 at 6:01 AM, Michael Niedermayer
 wrote:
> On Fri, Apr 28, 2017 at 11:23:10PM +0700, Muhammad Faiz wrote:
>> On Fri, Apr 28, 2017 at 5:55 PM, Ronald S. Bultje  wrote:
>> > Hi,
>> >
>> > On Fri, Apr 28, 2017 at 6:19 AM, Muhammad Faiz  wrote:
>> >>
>> >> So, all frames and errors are correctly reported in order.
>> >> Also limit the numbers of error during draining to prevent infinite loop.
>> >>
>> >> This fix fate failure with THREADS>=4:
>> >>   make fate-h264-attachment-631 THREADS=4
>> >> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>> >>
>> >> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> >> Signed-off-by: Muhammad Faiz 
>> >> ---
>> >>  libavcodec/decode.c| 21 +++--
>> >>  libavcodec/internal.h  |  3 +++
>> >>  libavcodec/pthread_frame.c | 15 +++
>> >>  3 files changed, 29 insertions(+), 10 deletions(-)
>> >>
>> >> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> >> index 6ff3c40..edfae55 100644
>> >> --- a/libavcodec/decode.c
>> >> +++ b/libavcodec/decode.c
>> >> @@ -568,8 +568,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
>> >>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate,
>> >> (AVRational){avctx->ticks_per_frame, 1}));
>> >>  #endif
>> >>
>> >> -if (avctx->internal->draining && !got_frame)
>> >> -avci->draining_done = 1;
>> >> +/* do not stop draining when got_frame != 0 or ret < 0 */
>> >> +if (avctx->internal->draining && !got_frame) {
>> >> +if (ret < 0) {
>> >> +/* prevent infinite loop if a decoder wrongly always return
>> >> error on draining */
>> >> +/* reasonable nb_errors_max = maximum b frames + thread count
>> >> */
>> >> +int nb_errors_max = 20 + (HAVE_THREADS &&
>> >> avctx->active_thread_type & FF_THREAD_FRAME ?
>> >> +avctx->thread_count : 1);
>> >> +
>> >> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>> >> +av_log(avctx, AV_LOG_ERROR, "Too many errors when
>> >> draining, this is a bug. "
>> >> +   "Stop draining and force EOF.\n");
>> >> +avci->draining_done = 1;
>> >> +ret = AVERROR_BUG;
>> >> +}
>> >> +} else {
>> >> +avci->draining_done = 1;
>> >> +}
>> >> +}
>> >
>> >
>> > Hm... I guess this is OK, it would be really nice to have a way of breaking
>> > in developer builds (e.g. av_assert or so, although I guess technically 
>> > this
>> > could be enabled in prod builds also).
>>
>> Add av_assert2().
>>
>> >
>> > Also, Marton suggested to return AVERROR_EOF, maybe handle that here also 
>> > in
>> > addition to ret=0?
>>
>> Modified.
>>
>> Updated patch attached.
>>
>> Thank's
>
>>  decode.c|   23 +--
>>  internal.h  |3 +++
>>  pthread_frame.c |   15 +++
>>  3 files changed, 31 insertions(+), 10 deletions(-)
>> d3049c52598070baa9566fc98a089111732595fa  
>> 0001-avcodec-pthread_frame-decode-allow-errors-to-happen-.patch
>> From f684770e016fa36d458d08383065815882cbc7f8 Mon Sep 17 00:00:00 2001
>> From: Muhammad Faiz 
>> Date: Fri, 28 Apr 2017 17:08:39 +0700
>> Subject: [PATCH v3] avcodec/pthread_frame, decode: allow errors to happen on
>>  draining
>>
>> So, all frames and errors are correctly reported in order.
>> Also limit the number of errors during draining to prevent infinite loop.
>> Also return AVERROR_EOF directly on EOF instead of only setting 
>> draining_done.
>>
>> This fix fate failure with THREADS>=4:
>>   make fate-h264-attachment-631 THREADS=4
>> This also reverts a755b725ec1d657609c8bd726ce37e7cf193d03f.
>>
>> Suggested-by: wm4, Ronald S. Bultje, Marton Balint
>> Signed-off-by: Muhammad Faiz 
>> ---
>>  libavcodec/decode.c| 23 +--
>>  libavcodec/internal.h  |  3 +++
>>  libavcodec/pthread_frame.c | 15 +++
>>  3 files changed, 31 insertions(+), 10 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index 6ff3c40..fb4d4af 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -568,8 +568,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>  avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
>> (AVRational){avctx->ticks_per_frame, 1}));
>>  #endif
>>
>> -if (avctx->internal->draining && !got_frame)
>> -avci->draining_done = 1;
>> +/* do not stop draining when got_frame != 0 or ret < 0 */
>> +if (avctx->internal->draining && !got_frame) {
>> +if (ret < 0) {
>> +/* prevent infinite loop if a decoder wrongly always return 
>> error on draining */
>> +/* reasonable nb_errors_max = maximum b frames + thread count */
>> +int nb_errors_max = 20 + (HAVE_THREADS && 
>> avctx->active_thread_type & FF_THREAD_FRAME ?
>> +avctx->thread_count : 1);
>> +
>> +if (avci->nb_draining_errors++ >= nb_errors_max) {
>> +   

Re: [FFmpeg-devel] [PATCH v2] checkasm: add float_dsp tests

2017-04-28 Thread Michael Niedermayer
On Wed, Apr 26, 2017 at 02:32:00PM -0300, James Almer wrote:
> This is a port of libavutil/tests/float_dsp.c
> 
> Signed-off-by: James Almer 
> ---
>  tests/checkasm/Makefile|   1 +
>  tests/checkasm/checkasm.c  |  20 +++
>  tests/checkasm/checkasm.h  |   4 +
>  tests/checkasm/float_dsp.c | 302 
> +
>  tests/fate/checkasm.mak|   1 +
>  5 files changed, 328 insertions(+)
>  create mode 100644 tests/checkasm/float_dsp.c

fails on x86 32 linux

Test checkasm-float_dsp failed. Look at tests/data/fate/checkasm-float_dsp.err 
for details.
checkasm: using random seed 2975532195
 541.841064453125 - -nan = -nan
SSE:
 - float_dsp.vector_fmul [OK]
 - float_dsp.vector_fmac [OK]
 - float_dsp.butterflies_float   [OK]
   scalarproduct_float_sse (failed to issue emms)
 241.556915283203 - -nan = -nan
 - float_dsp.scalarproduct_float [FAILED]
SSE2:
 - float_dsp.vector_dmul [OK]
 - float_dsp.vector_dmac [OK]
AVX:
 - float_dsp.vector_fmul [OK]
 - float_dsp.vector_fmac [OK]
 - float_dsp.vector_dmul [OK]
 - float_dsp.vector_dmac [OK]
checkasm: 1 of 16 tests have failed
make: *** [fate-checkasm-float_dsp] Error 1


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

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


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


Re: [FFmpeg-devel] [PATCH] avformat/concatdec: port to the new bitstream filter API

2017-04-28 Thread James Almer
On 4/27/2017 10:59 PM, Michael Niedermayer wrote:
> On Wed, Apr 26, 2017 at 04:40:55PM -0300, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/concatdec.c | 86 
>> +++--
>>  1 file changed, 26 insertions(+), 60 deletions(-)
> 
> breaks
> ./ffmpeg -f concat -i ~/tickets/3108/concatfile.txt -codec copy test.avi
> (output produces many warnings/errors on playback)
> https://trac.ffmpeg.org/raw-attachment/ticket/3108/examplefiles.zip

Huh, this was more broken than i thought. Apparently, concatdec was
never really filtering anything before this patch.

detect_stream_specific() frees up the stream's extradata before the code
ever has the chance to call the bsf init function because, despite the
name, the compat code in av_bitstream_filter_init() does not call it.
That only happens in the first av_bitstream_filter_filter() call. The
h264_mp4toannexb bsf looks at extradata during init to figure out if it
needs to filter anything or just do a packet passthrough.
That aside, concatdec was also copying the input file's stream extradata
to the matched output stream extradata *before* it called
detect_stream_specific(), so any filtered extradata would have been
ignored anyway.

I don't know if this started happening after the new bsf API was
introduced and the old converted into a wrapper for the new, or if it
was always like this, but after this conversion it will not matter.

Will send an updated patch in a moment.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/concatdec: port to the new bitstream filter API

2017-04-28 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/concatdec.c | 94 -
 1 file changed, 30 insertions(+), 64 deletions(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index dd52e4d366..fa9443ff78 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -34,8 +34,7 @@ typedef enum ConcatMatchMode {
 } ConcatMatchMode;
 
 typedef struct ConcatStream {
-AVBitStreamFilterContext *bsf;
-AVCodecContext *avctx;
+AVBSFContext *bsf;
 int out_stream_index;
 } ConcatStream;
 
@@ -196,7 +195,8 @@ static int detect_stream_specific(AVFormatContext *avf, int 
idx)
 ConcatContext *cat = avf->priv_data;
 AVStream *st = cat->avf->streams[idx];
 ConcatStream *cs = &cat->cur_file->streams[idx];
-AVBitStreamFilterContext *bsf;
+const AVBitStreamFilter *filter;
+AVBSFContext *bsf;
 int ret;
 
 if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264) {
@@ -206,29 +206,28 @@ static int detect_stream_specific(AVFormatContext *avf, 
int idx)
 return 0;
 av_log(cat->avf, AV_LOG_INFO,
"Auto-inserting h264_mp4toannexb bitstream filter\n");
-if (!(bsf = av_bitstream_filter_init("h264_mp4toannexb"))) {
+filter = av_bsf_get_by_name("h264_mp4toannexb");
+if (!filter) {
 av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb bitstream filter "
"required for H.264 streams\n");
 return AVERROR_BSF_NOT_FOUND;
 }
+ret = av_bsf_alloc(filter, &bsf);
+if (ret < 0)
+return ret;
 cs->bsf = bsf;
 
-cs->avctx = avcodec_alloc_context3(NULL);
-if (!cs->avctx)
-return AVERROR(ENOMEM);
-
-/* This really should be part of the bsf work.
-   Note: input bitstream filtering will not work with bsf that
-   create extradata from the first packet. */
-av_freep(&st->codecpar->extradata);
-st->codecpar->extradata_size = 0;
+ret = avcodec_parameters_copy(bsf->par_in, st->codecpar);
+if (ret < 0)
+   return ret;
 
-ret = avcodec_parameters_to_context(cs->avctx, st->codecpar);
-if (ret < 0) {
-avcodec_free_context(&cs->avctx);
+ret = av_bsf_init(bsf);
+if (ret < 0)
 return ret;
-}
 
+ret = avcodec_parameters_copy(st->codecpar, bsf->par_out);
+if (ret < 0)
+return ret;
 }
 return 0;
 }
@@ -291,8 +290,11 @@ static int match_streams(AVFormatContext *avf)
 memset(map + cat->cur_file->nb_streams, 0,
(cat->avf->nb_streams - cat->cur_file->nb_streams) * sizeof(*map));
 
-for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++)
+for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
 map[i].out_stream_index = -1;
+if ((ret = detect_stream_specific(avf, i)) < 0)
+return ret;
+}
 switch (cat->stream_match_mode) {
 case MATCH_ONE_TO_ONE:
 ret = match_streams_one_to_one(avf);
@@ -305,9 +307,6 @@ static int match_streams(AVFormatContext *avf)
 }
 if (ret < 0)
 return ret;
-for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++)
-if ((ret = detect_stream_specific(avf, i)) < 0)
-return ret;
 cat->cur_file->nb_streams = cat->avf->nb_streams;
 return 0;
 }
@@ -370,10 +369,8 @@ static int concat_read_close(AVFormatContext *avf)
 for (i = 0; i < cat->nb_files; i++) {
 av_freep(&cat->files[i].url);
 for (j = 0; j < cat->files[i].nb_streams; j++) {
-if (cat->files[i].streams[j].avctx)
-avcodec_free_context(&cat->files[i].streams[j].avctx);
 if (cat->files[i].streams[j].bsf)
-av_bitstream_filter_close(cat->files[i].streams[j].bsf);
+av_bsf_free(&cat->files[i].streams[j].bsf);
 }
 av_freep(&cat->files[i].streams);
 av_dict_free(&cat->files[i].metadata);
@@ -524,56 +521,25 @@ static int open_next_file(AVFormatContext *avf)
 
 static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
 {
-AVStream *st = avf->streams[cs->out_stream_index];
-AVBitStreamFilterContext *bsf;
-AVPacket pkt2;
 int ret;
 
 av_assert0(cs->out_stream_index >= 0);
-for (bsf = cs->bsf; bsf; bsf = bsf->next) {
-pkt2 = *pkt;
-
-ret = av_bitstream_filter_filter(bsf, cs->avctx, NULL,
- &pkt2.data, &pkt2.size,
- pkt->data, pkt->size,
- !!(pkt->flags & AV_PKT_FLAG_KEY));
+if (cs->bsf) {
+ret = av_bsf_send_packet(cs->bsf, pkt);
 if (ret < 0) {
+av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb filter "
+   "failed to send input packet\n");
 av_packet_unref(pkt);
 r

Re: [FFmpeg-devel] [PATCH] libvpxenc: allow aq-mode 4 (equator360)

2017-04-28 Thread James Zern
On Thu, Apr 20, 2017 at 3:06 PM, James Zern  wrote:
> On Thu, Apr 20, 2017 at 1:42 PM, Ronald S. Bultje  wrote:
>> Hi,
>>
>> On Thu, Apr 20, 2017 at 2:42 PM, James Zern 
>> wrote:
>>
>>> On Thu, Apr 13, 2017 at 6:44 PM, James Zern  wrote:
>>> > this was added in 1.6.0
>>> >
>>> > Signed-off-by: James Zern 
>>> > ---
>>> >  doc/encoders.texi  | 2 +-
>>> >  libavcodec/libvpxenc.c | 3 ++-
>>> >  2 files changed, 3 insertions(+), 2 deletions(-)
>>> >
>>>
>>> I'll submit this soon if there aren't any comments.
>>
>>
>> Looks good.
>>
>> (I'm guessing it doesn't need an ABI version check because it's
>> automatically clipped internally if you specify aq-mode=4 to an earlier
>> version of the library?)
>>
>
> Older libs will fail as it will exceed the range check. I debated an
> abi check, but that only pushes the range failure up to this level if
> we constrain the range.

Pushed with an abi check since control failures are non-fatal as
opposed to the range check in libvpxenc.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Ignore expired cookies

2017-04-28 Thread Michael Niedermayer
On Wed, Apr 26, 2017 at 09:48:09PM -0400, Micah Galizia wrote:
> Signed-off-by: Micah Galizia 
> ---
>  libavformat/http.c | 212 
> +++--
>  1 file changed, 155 insertions(+), 57 deletions(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 293a8a7204..58fc3902ab 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -29,6 +29,7 @@
>  #include "libavutil/avstring.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/time.h"
> +#include "libavutil/parseutils.h"
>  
>  #include "avformat.h"
>  #include "http.h"
> @@ -48,6 +49,8 @@
>  #define MAX_REDIRECTS 8
>  #define HTTP_SINGLE   1
>  #define HTTP_MUTLI2
> +#define MAX_EXPIRY19
> +#define WHITESPACES " \n\t\r"
>  typedef enum {
>  LOWER_PROTO,
>  READ_HEADERS,
> @@ -680,10 +683,110 @@ static int parse_icy(HTTPContext *s, const char *tag, 
> const char *p)
>  return 0;
>  }
>  
> +static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
> +{
> +char exp_buf[MAX_EXPIRY];
> +int i, j, exp_buf_len = MAX_EXPIRY-1;
> +char *expiry;
> +
> +// strip off any punctuation or whitespace
> +for (i = 0, j = 0; exp_str[i] != '\0' && j < exp_buf_len; i++) {
> +if ((exp_str[i] >= '0' && exp_str[i] <= '9') ||
> +(exp_str[i] >= 'A' && exp_str[i] <= 'Z') ||
> +(exp_str[i] >= 'a' && exp_str[i] <= 'z')) {
> +exp_buf[j] = exp_str[i];
> +j++;
> +}
> +}
> +exp_buf[j] = '\0';
> +expiry = exp_buf;
> +
> +// move the string beyond the day of week
> +while ((*expiry < '0' || *expiry > '9') && *expiry != '\0')
> +expiry++;
> +
> +return av_small_strptime(expiry, "%d%b%Y%H%M%S", buf) ? 0 : 
> AVERROR(EINVAL);
> +}
> +

> +static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
> +{
> +char *param, *next_param, *cstr, *back;
> +
> +if (!(cstr = av_strdup(set_cookie)))
> +return AVERROR(EINVAL);
> +
> +// strip any trailing whitespace
> +back = &cstr[strlen(cstr)-1];
> +while (strchr(WHITESPACES, *back)) {
> +*back='\0';
> +back--;
> +}
> +
> +next_param = cstr;
> +while ((param = av_strtok(next_param, ";", &next_param))) {
> +char *name, *value;
> +param += strspn(param, WHITESPACES);
> +if ((name = av_strtok(param, "=", &value))) {
> +if (av_dict_set(dict, name, value, 0) < 0)
> +return -1;

this leaks cstr


[...]
> @@ -876,87 +979,82 @@ static int get_cookies(HTTPContext *s, char **cookies, 
> const char *path,
>  av_dict_free(&s->cookie_dict);
>  
>  *cookies = NULL;
> -while ((cookie = av_strtok(set_cookies, "\n", &next))) {
> -int domain_offset = 0;
> -char *param, *next_param, *cdomain = NULL, *cpath = NULL, *cvalue = 
> NULL;
> -set_cookies = NULL;
> +while ((cookie = av_strtok(next, "\n", &next))) {
> +AVDictionary *cookie_params = NULL;
> +AVDictionaryEntry *cookie_entry, *e;
>  
>  // store the cookie in a dict in case it is updated in the response
>  if (parse_cookie(s, cookie, &s->cookie_dict))
>  av_log(s, AV_LOG_WARNING, "Unable to parse '%s'\n", cookie);
>  
> -while ((param = av_strtok(cookie, "; ", &next_param))) {
> -if (cookie) {
> -// first key-value pair is the actual cookie value
> -cvalue = av_strdup(param);
> -cookie = NULL;
> -} else if (!av_strncasecmp("path=",   param, 5)) {
> -av_free(cpath);
> -cpath = av_strdup(¶m[5]);
> -} else if (!av_strncasecmp("domain=", param, 7)) {
> -// if the cookie specifies a sub-domain, skip the leading 
> dot thereby
> -// supporting URLs that point to sub-domains and the master 
> domain
> -int leading_dot = (param[7] == '.');
> -av_free(cdomain);
> -cdomain = av_strdup(¶m[7+leading_dot]);
> -} else {
> -// ignore unknown attributes
> -}
> +// continue on to the next cookie if this one cannot be parsed
> +if (parse_set_cookie(cookie, &cookie_params))
> +continue;
> +
> +// if the cookie has no value, skip it
> +cookie_entry = av_dict_get(cookie_params, "", NULL, 
> AV_DICT_IGNORE_SUFFIX);
> +if (!cookie_entry || !cookie_entry->value) {
> +av_dict_free(&cookie_params);
> +continue;
>  }
> -if (!cdomain)
> -cdomain = av_strdup(domain);
> -
> -// ensure all of the necessary values are valid
> -if (!cdomain || !cpath || !cvalue) {
> -av_log(s, AV_LOG_WARNING,
> -   "Invalid cookie found, no value, path or domain 
> specified\n");
> -goto done_cookie;
> +
> +// if the cookie has expired, don't

Re: [FFmpeg-devel] [PATCH] avformat/movenc: Explicitly address potential division by zero.

2017-04-28 Thread Michael Niedermayer
On Thu, Apr 27, 2017 at 03:08:29PM -0700, Lucas Cooper wrote:
> find_fps attempts to infer framerate from AVCodec's timebase. When this
> results in a frame rate that isn't explicitly marked as supported in
> av_timecode_check_frame_rate, find_fps returns the AVStream's
> avg_frame_rate, which, per avformat.h, _may_ be set (or not).
> 
> mov_get_mpeg2_xdcam_codec_tag, mov_get_h264_codec_tag and
> find_compressor attempt to call av_q2d on the return value of find_fps,
> which in the above case, may result in division by zero and therefore,
> an undefined frame rate when NaN is converted to int.
> ---
>  libavformat/movenc.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)

applied

thx

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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


Re: [FFmpeg-devel] [PATCH] Ignore expired cookies

2017-04-28 Thread Michael Niedermayer
On Wed, Apr 26, 2017 at 09:48:09PM -0400, Micah Galizia wrote:
> Signed-off-by: Micah Galizia 
> ---
>  libavformat/http.c | 212 
> +++--
>  1 file changed, 155 insertions(+), 57 deletions(-)

forgot to mention
the commit message "Ignore expired cookies"
needs lib & file/ module prefix

no major issue, i add these on pushing unless i forget

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

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


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