[FFmpeg-devel] [PATCH 1/8] lavfi: add helper functions and macros for activate.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.c | 20 +
 libavfilter/filters.h  | 78 ++
 2 files changed, 98 insertions(+)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 6a97456054..91939eab8a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1650,6 +1650,26 @@ void ff_inlink_request_frame(AVFilterLink *link)
 ff_filter_set_ready(link->src, 100);
 }
 
+void ff_inlink_set_status(AVFilterLink *link, int status)
+{
+if (link->status_out)
+return;
+link->frame_wanted_out = 0;
+link->frame_blocked_in = 0;
+ff_avfilter_link_set_out_status(link, status, AV_NOPTS_VALUE);
+while (ff_framequeue_queued_frames(&link->fifo)) {
+   AVFrame *frame = ff_framequeue_take(&link->fifo);
+   av_frame_free(&frame);
+}
+if (!link->status_in)
+link->status_in = status;
+}
+
+int ff_outlink_get_status(AVFilterLink *link)
+{
+return link->status_in;
+}
+
 const AVClass *avfilter_get_class(void)
 {
 return &avfilter_class;
diff --git a/libavfilter/filters.h b/libavfilter/filters.h
index 1cbc18158f..b3c4a959a3 100644
--- a/libavfilter/filters.h
+++ b/libavfilter/filters.h
@@ -140,6 +140,12 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int 
*rstatus, int64_t *rpts
  */
 void ff_inlink_request_frame(AVFilterLink *link);
 
+/**
+ * Set the status on an input link.
+ * Also discard all frames in the link's FIFO.
+ */
+void ff_inlink_set_status(AVFilterLink *link, int status);
+
 /**
  * Test if a frame is wanted on an output link.
  */
@@ -148,6 +154,11 @@ static inline int ff_outlink_frame_wanted(AVFilterLink 
*link)
 return link->frame_wanted_out;
 }
 
+/**
+ * Get the status on an output link.
+ */
+int ff_outlink_get_status(AVFilterLink *link);
+
 /**
  * Set the status field of a link from the source filter.
  * The pts should reflect the timestamp of the status change,
@@ -160,4 +171,71 @@ static inline void ff_outlink_set_status(AVFilterLink 
*link, int status, int64_t
 ff_avfilter_link_set_in_status(link, status, pts);
 }
 
+/**
+ * Forward the status on an output link to an input link.
+ * If the status is set, it will discard all queued frames and this macro
+ * will return immediately.
+ */
+#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink) do { \
+int ret = ff_outlink_get_status(outlink); \
+if (ret) { \
+   ff_inlink_set_status(inlink, ret); \
+   return 0; \
+} \
+} while (0)
+
+/**
+ * Forward the status on an output link to all input links.
+ * If the status is set, it will discard all queued frames and this macro
+ * will return immediately.
+ */
+#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter) do { \
+int ret = ff_outlink_get_status(outlink); \
+if (ret) { \
+unsigned i; \
+for (i = 0; i < filter->nb_inputs; i++) \
+ff_inlink_set_status(filter->inputs[i], ret); \
+   return 0; \
+} \
+} while (0)
+
+/**
+ * Acknowledge the status on an input link and forward it to an output link.
+ * If the status is set, this macro will return immediately.
+ */
+#define FF_FILTER_FORWARD_STATUS(inlink, outlink) do { \
+int status; \
+int64_t pts; \
+if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
+   ff_outlink_set_status(outlink, status, pts); \
+   return 0; \
+} \
+} while (0)
+
+/**
+ * Acknowledge the status on an input link and forward it to an output link.
+ * If the status is set, this macro will return immediately.
+ */
+#define FF_FILTER_FORWARD_STATUS_ALL(inlink, filter) do { \
+int status; \
+int64_t pts; \
+if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
+unsigned i; \
+for (i = 0; i < filter->nb_outputs; i++) \
+ff_outlink_set_status(filter->outputs[i], status, pts); \
+   return 0; \
+} \
+} while (0)
+
+/**
+ * Forward the frame_wanted_out flag from an output link to an input link.
+ * If the flag is set, this macro will return immediately.
+ */
+#define FF_FILTER_FORWARD_WANTED(outlink, inlink) do { \
+if (ff_outlink_frame_wanted(outlink)) { \
+   ff_inlink_request_frame(inlink); \
+   return 0; \
+} \
+} while (0)
+
 #endif /* AVFILTER_FILTERS_H */
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 2/8] lavfi/af_agate: use helper macros.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/af_agate.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c
index f4fcabef93..20905ccb19 100644
--- a/libavfilter/af_agate.c
+++ b/libavfilter/af_agate.c
@@ -270,10 +270,10 @@ static int activate(AVFilterContext *ctx)
 {
 AudioGateContext *s = ctx->priv;
 AVFrame *out = NULL, *in[2] = { NULL };
-int ret, i, status, nb_samples;
+int ret, i, nb_samples;
 double *dst;
-int64_t pts;
 
+FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &in[0])) > 0) {
 av_audio_fifo_write(s->fifo[0], (void **)in[0]->extended_data,
 in[0]->nb_samples);
@@ -321,13 +321,9 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 }
-if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
-ff_outlink_set_status(ctx->outputs[0], status, pts);
-return 0;
-} else if (ff_inlink_acknowledge_status(ctx->inputs[1], &status, &pts)) {
-ff_outlink_set_status(ctx->outputs[0], status, pts);
-return 0;
-} else {
+FF_FILTER_FORWARD_STATUS(ctx->inputs[0], ctx->outputs[0]);
+FF_FILTER_FORWARD_STATUS(ctx->inputs[1], ctx->outputs[0]);
+/* TODO reindent */
 if (ff_outlink_frame_wanted(ctx->outputs[0])) {
 if (!av_audio_fifo_size(s->fifo[0]))
 ff_inlink_request_frame(ctx->inputs[0]);
@@ -335,7 +331,6 @@ static int activate(AVFilterContext *ctx)
 ff_inlink_request_frame(ctx->inputs[1]);
 }
 return 0;
-}
 }
 
 static int scquery_formats(AVFilterContext *ctx)
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 3/8] lavfi/af_sidechaincompress: use helper macros.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/af_sidechaincompress.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/libavfilter/af_sidechaincompress.c 
b/libavfilter/af_sidechaincompress.c
index f174b70a5b..55bed43844 100644
--- a/libavfilter/af_sidechaincompress.c
+++ b/libavfilter/af_sidechaincompress.c
@@ -188,10 +188,10 @@ static int activate(AVFilterContext *ctx)
 {
 SidechainCompressContext *s = ctx->priv;
 AVFrame *out = NULL, *in[2] = { NULL };
-int ret, i, status, nb_samples;
+int ret, i, nb_samples;
 double *dst;
-int64_t pts;
 
+FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
 if ((ret = ff_inlink_consume_frame(ctx->inputs[0], &in[0])) > 0) {
 av_audio_fifo_write(s->fifo[0], (void **)in[0]->extended_data,
 in[0]->nb_samples);
@@ -239,13 +239,9 @@ static int activate(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 }
-if (ff_inlink_acknowledge_status(ctx->inputs[0], &status, &pts)) {
-ff_outlink_set_status(ctx->outputs[0], status, pts);
-return 0;
-} else if (ff_inlink_acknowledge_status(ctx->inputs[1], &status, &pts)) {
-ff_outlink_set_status(ctx->outputs[0], status, pts);
-return 0;
-} else {
+FF_FILTER_FORWARD_STATUS(ctx->inputs[0], ctx->outputs[0]);
+FF_FILTER_FORWARD_STATUS(ctx->inputs[1], ctx->outputs[0]);
+/* TODO reindent */
 if (ff_outlink_frame_wanted(ctx->outputs[0])) {
 if (!av_audio_fifo_size(s->fifo[0]))
 ff_inlink_request_frame(ctx->inputs[0]);
@@ -253,7 +249,6 @@ static int activate(AVFilterContext *ctx)
 ff_inlink_request_frame(ctx->inputs[1]);
 }
 return 0;
-}
 }
 
 static int query_formats(AVFilterContext *ctx)
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 5/8] lavfi/vf_zoompan: make some function arguments simple.

2017-09-07 Thread Nicolas George
The modified value is never used after the function call.

Signed-off-by: Nicolas George 
---
 libavfilter/vf_zoompan.c | 39 +++
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_zoompan.c b/libavfilter/vf_zoompan.c
index b1ade33b1f..e0a5a8eb64 100644
--- a/libavfilter/vf_zoompan.c
+++ b/libavfilter/vf_zoompan.c
@@ -149,7 +149,7 @@ static int config_output(AVFilterLink *outlink)
 }
 
 static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double 
*var_values, int i,
-   double *zoom, double *dx, double *dy)
+   double zoom, double dx, double dy)
 {
 ZPContext *s = ctx->priv;
 AVFilterLink *outlink = ctx->outputs[0];
@@ -167,23 +167,23 @@ static int output_single_frame(AVFilterContext *ctx, 
AVFrame *in, double *var_va
 var_values[VAR_FRAME] = i;
 var_values[VAR_ON] = outlink->frame_count_in + 1;
 
-*zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
+zoom = av_expr_eval(s->zoom_expr, var_values, NULL);
 
-*zoom = av_clipd(*zoom, 1, 10);
-var_values[VAR_ZOOM] = *zoom;
-w = in->width * (1.0 / *zoom);
-h = in->height * (1.0 / *zoom);
+zoom = av_clipd(zoom, 1, 10);
+var_values[VAR_ZOOM] = zoom;
+w = in->width * (1.0 / zoom);
+h = in->height * (1.0 / zoom);
 
-*dx = av_expr_eval(s->x_expr, var_values, NULL);
+dx = av_expr_eval(s->x_expr, var_values, NULL);
 
-x = *dx = av_clipd(*dx, 0, FFMAX(in->width - w, 0));
-var_values[VAR_X] = *dx;
+x = dx = av_clipd(dx, 0, FFMAX(in->width - w, 0));
+var_values[VAR_X] = dx;
 x &= ~((1 << s->desc->log2_chroma_w) - 1);
 
-*dy = av_expr_eval(s->y_expr, var_values, NULL);
+dy = av_expr_eval(s->y_expr, var_values, NULL);
 
-y = *dy = av_clipd(*dy, 0, FFMAX(in->height - h, 0));
-var_values[VAR_Y] = *dy;
+y = dy = av_clipd(dy, 0, FFMAX(in->height - h, 0));
+var_values[VAR_Y] = dy;
 y &= ~((1 << s->desc->log2_chroma_h) - 1);
 
 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
@@ -229,12 +229,12 @@ static int output_single_frame(AVFilterContext *ctx, 
AVFrame *in, double *var_va
 s->current_frame++;
 
 if (s->current_frame >= s->nb_frames) {
-if (*dx != -1)
-s->x = *dx;
-if (*dy != -1)
-s->y = *dy;
-if (*zoom != -1)
-s->prev_zoom = *zoom;
+if (dx != -1)
+s->x = dx;
+if (dy != -1)
+s->y = dy;
+if (zoom != -1)
+s->prev_zoom = zoom;
 s->prev_nb_frames = s->nb_frames;
 s->nb_frames = 0;
 s->current_frame = 0;
@@ -287,9 +287,8 @@ static int activate(AVFilterContext *ctx)
 s->var_values[VAR_DURATION] = s->nb_frames = nb_frames;
 }
 if (s->in) {
-double zoom = -1, dx = -1, dy = -1;
 ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
-  &zoom, &dx, &dy);
+  -1, -1, -1);
 return ret;
 }
 FF_FILTER_FORWARD_STATUS(inlink, outlink);
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/vf_zoompan.c | 36 +---
 1 file changed, 9 insertions(+), 27 deletions(-)


I do not have the faintest idea what the output of this filter is supposed
to look like, so testing is limited. But at least now it outputs something.


diff --git a/libavfilter/vf_zoompan.c b/libavfilter/vf_zoompan.c
index 14d0a1707b..b1ade33b1f 100644
--- a/libavfilter/vf_zoompan.c
+++ b/libavfilter/vf_zoompan.c
@@ -95,7 +95,6 @@ typedef struct ZPcontext {
 double var_values[VARS_NB];
 int nb_frames;
 int current_frame;
-int finished;
 AVRational framerate;
 } ZPContext;
 
@@ -240,7 +239,6 @@ static int output_single_frame(AVFilterContext *ctx, 
AVFrame *in, double *var_va
 s->nb_frames = 0;
 s->current_frame = 0;
 av_frame_free(&s->in);
-s->finished = 1;
 }
 return ret;
 error:
@@ -253,22 +251,12 @@ static int activate(AVFilterContext *ctx)
 ZPContext *s = ctx->priv;
 AVFilterLink *inlink = ctx->inputs[0];
 AVFilterLink *outlink = ctx->outputs[0];
-int status, ret = 0;
-int64_t pts;
-
-if (s->in && ff_outlink_frame_wanted(outlink)) {
-double zoom = -1, dx = -1, dy = -1;
-
-ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
-  &zoom, &dx, &dy);
-if (ret < 0)
-return ret;
-}
+int ret = 0;
 
+FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
 if (!s->in && (ret = ff_inlink_consume_frame(inlink, &s->in)) > 0) {
-double zoom = -1, dx = -1, dy = -1, nb_frames;
+double nb_frames;
 
-s->finished = 0;
 s->var_values[VAR_IN_W]  = s->var_values[VAR_IW] = s->in->width;
 s->var_values[VAR_IN_H]  = s->var_values[VAR_IH] = s->in->height;
 s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = s->w;
@@ -297,22 +285,16 @@ static int activate(AVFilterContext *ctx)
 }
 
 s->var_values[VAR_DURATION] = s->nb_frames = nb_frames;
-
+}
+if (s->in) {
+double zoom = -1, dx = -1, dy = -1;
 ret = output_single_frame(ctx, s->in, s->var_values, s->current_frame,
   &zoom, &dx, &dy);
-if (ret < 0)
-return ret;
-}
-if (ret < 0) {
 return ret;
-} else if (s->finished && ff_inlink_acknowledge_status(inlink, &status, 
&pts)) {
-ff_outlink_set_status(outlink, status, pts);
-return 0;
-} else {
-if (ff_outlink_frame_wanted(outlink) && s->finished)
-ff_inlink_request_frame(inlink);
-return 0;
 }
+FF_FILTER_FORWARD_STATUS(inlink, outlink);
+FF_FILTER_FORWARD_WANTED(outlink, inlink);
+return 0;
 }
 
 static int query_formats(AVFilterContext *ctx)
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 8/8] doc: update filter_design.txt.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 doc/filter_design.txt | 251 +++---
 1 file changed, 135 insertions(+), 116 deletions(-)

diff --git a/doc/filter_design.txt b/doc/filter_design.txt
index e8a7c53ee9..90fa53367b 100644
--- a/doc/filter_design.txt
+++ b/doc/filter_design.txt
@@ -5,7 +5,7 @@ This document explains guidelines that should be observed (or 
ignored with
 good reason) when writing filters for libavfilter.
 
 In this document, the word “frame” indicates either a video frame or a group
-of audio samples, as stored in an AVFilterBuffer structure.
+of audio samples, as stored in an AVFrame structure.
 
 
 Format negotiation
@@ -35,32 +35,31 @@ Format negotiation
   to set the formats supported on another.
 
 
-Buffer references ownership and permissions
-===
+Frame references ownership and permissions
+==
 
   Principle
   -
 
-Audio and video data are voluminous; the buffer and buffer reference
+Audio and video data are voluminous; the frame and frame reference
 mechanism is intended to avoid, as much as possible, expensive copies of
 that data while still allowing the filters to produce correct results.
 
-The data is stored in buffers represented by AVFilterBuffer structures.
-They must not be accessed directly, but through references stored in
-AVFilterBufferRef structures. Several references can point to the
-same buffer; the buffer is automatically deallocated once all
-corresponding references have been destroyed.
+The data is stored in buffers represented by AVFrame structures.
+Several references can point to the same frame buffer; the buffer is
+automatically deallocated once all corresponding references have been
+destroyed.
 
 The characteristics of the data (resolution, sample rate, etc.) are
 stored in the reference; different references for the same buffer can
 show different characteristics. In particular, a video reference can
 point to only a part of a video buffer.
 
-A reference is usually obtained as input to the start_frame or
-filter_frame method or requested using the ff_get_video_buffer or
-ff_get_audio_buffer functions. A new reference on an existing buffer can
-be created with the avfilter_ref_buffer. A reference is destroyed using
-the avfilter_unref_bufferp function.
+A reference is usually obtained as input to the filter_frame method or
+requested using the ff_get_video_buffer or ff_get_audio_buffer
+functions. A new reference on an existing buffer can be created with
+av_frame_ref(). A reference is destroyed using
+the av_frame_free() function.
 
   Reference ownership
   ---
@@ -73,17 +72,13 @@ Buffer references ownership and permissions
 
 Here are the (fairly obvious) rules for reference ownership:
 
-* A reference received by the filter_frame method (or its start_frame
-  deprecated version) belongs to the corresponding filter.
+* A reference received by the filter_frame method belongs to the
+  corresponding filter.
 
-  Special exception: for video references: the reference may be used
-  internally for automatic copying and must not be destroyed before
-  end_frame; it can be given away to ff_start_frame.
+* A reference passed to ff_filter_frame is given away and must no longer
+  be used.
 
-* A reference passed to ff_filter_frame (or the deprecated
-  ff_start_frame) is given away and must no longer be used.
-
-* A reference created with avfilter_ref_buffer belongs to the code that
+* A reference created with av_frame_ref() belongs to the code that
   created it.
 
 * A reference obtained with ff_get_video_buffer or ff_get_audio_buffer
@@ -95,89 +90,32 @@ Buffer references ownership and permissions
   Link reference fields
   -
 
-The AVFilterLink structure has a few AVFilterBufferRef fields. The
-cur_buf and out_buf were used with the deprecated
-start_frame/draw_slice/end_frame API and should no longer be used.
-src_buf and partial_buf are used by libavfilter internally
-and must not be accessed by filters.
-
-  Reference permissions
-  -
-
-The AVFilterBufferRef structure has a perms field that describes what
-the code that owns the reference is allowed to do to the buffer data.
-Different references for the same buffer can have different permissions.
-
-For video filters that implement the deprecated
-start_frame/draw_slice/end_frame API, the permissions only apply to the
-parts of the buffer that have already been covered by the draw_slice
-method.
-
-The value is a binary OR of the following constants:
-
-* AV_PERM_READ: the owner can read the buffer data; this is essentially
-  always true and is there for self-documentation.
-
-* AV_PER

[FFmpeg-devel] [PATCH 6/8] lavfi: remove framesync.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/framesync.c | 343 
 libavfilter/framesync.h | 297 -
 2 files changed, 640 deletions(-)
 delete mode 100644 libavfilter/framesync.c
 delete mode 100644 libavfilter/framesync.h

diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c
deleted file mode 100644
index eb05d66a86..00
--- a/libavfilter/framesync.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (c) 2013 Nicolas George
- *
- * 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
- */
-
-#define FF_INTERNAL_FIELDS 1
-#include "framequeue.h"
-
-#include "libavutil/avassert.h"
-#include "avfilter.h"
-#include "bufferqueue.h"
-#include "framesync.h"
-#include "internal.h"
-
-#define OFFSET(member) offsetof(FFFrameSync, member)
-
-static const char *framesync_name(void *ptr)
-{
-return "framesync";
-}
-
-static const AVClass framesync_class = {
-.version   = LIBAVUTIL_VERSION_INT,
-.class_name= "framesync",
-.item_name = framesync_name,
-.category  = AV_CLASS_CATEGORY_FILTER,
-.option= NULL,
-.parent_log_context_offset = OFFSET(parent),
-};
-
-enum {
-STATE_BOF,
-STATE_RUN,
-STATE_EOF,
-};
-
-int ff_framesync_init(FFFrameSync *fs, void *parent, unsigned nb_in)
-{
-fs->class  = &framesync_class;
-fs->parent = parent;
-fs->nb_in  = nb_in;
-
-fs->in = av_calloc(nb_in, sizeof(*fs->in));
-if (!fs->in)
-return AVERROR(ENOMEM);
-return 0;
-}
-
-static void framesync_sync_level_update(FFFrameSync *fs)
-{
-unsigned i, level = 0;
-
-for (i = 0; i < fs->nb_in; i++)
-if (fs->in[i].state != STATE_EOF)
-level = FFMAX(level, fs->in[i].sync);
-av_assert0(level <= fs->sync_level);
-if (level < fs->sync_level)
-av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level);
-if (level)
-fs->sync_level = level;
-else
-fs->eof = 1;
-}
-
-int ff_framesync_configure(FFFrameSync *fs)
-{
-unsigned i;
-int64_t gcd, lcm;
-
-if (!fs->time_base.num) {
-for (i = 0; i < fs->nb_in; i++) {
-if (fs->in[i].sync) {
-if (fs->time_base.num) {
-gcd = av_gcd(fs->time_base.den, fs->in[i].time_base.den);
-lcm = (fs->time_base.den / gcd) * fs->in[i].time_base.den;
-if (lcm < AV_TIME_BASE / 2) {
-fs->time_base.den = lcm;
-fs->time_base.num = av_gcd(fs->time_base.num,
-   fs->in[i].time_base.num);
-} else {
-fs->time_base.num = 1;
-fs->time_base.den = AV_TIME_BASE;
-break;
-}
-} else {
-fs->time_base = fs->in[i].time_base;
-}
-}
-}
-if (!fs->time_base.num) {
-av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n");
-return AVERROR(EINVAL);
-}
-av_log(fs, AV_LOG_VERBOSE, "Selected %d/%d time base\n",
-   fs->time_base.num, fs->time_base.den);
-}
-
-for (i = 0; i < fs->nb_in; i++)
-fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
-fs->sync_level = UINT_MAX;
-framesync_sync_level_update(fs);
-
-return 0;
-}
-
-static void framesync_advance(FFFrameSync *fs)
-{
-int latest;
-unsigned i;
-int64_t pts;
-
-if (fs->eof)
-return;
-while (!fs->frame_ready) {
-latest = -1;
-for (i = 0; i < fs->nb_in; i++) {
-if (!fs->in[i].have_next) {
-if (latest < 0 || fs->in[i].pts < fs->in[latest].pts)
-latest = i;
-}
-}
-if (latest >= 0) {
-fs->in_request = latest;
-break;
-}
-
-pts = fs->in[0].pts_next;
-for (i = 1; i < fs->nb_in; i++)
-if (fs->in[i].pts_next < pts)
-pts = fs->in[i].pts_next;
-if (pts == INT64_MAX) {
-fs->eof = 1;
-break;
-}
-for 

[FFmpeg-devel] [PATCH 7/8] lavfi: rename framesync2 to framesync.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 libavfilter/Makefile  | 48 +++
 libavfilter/f_streamselect.c  | 12 
 libavfilter/{framesync2.c => framesync.c} | 32 ++---
 libavfilter/{framesync2.h => framesync.h} | 42 +--
 libavfilter/maskedmerge.h |  2 +-
 libavfilter/vf_blend.c| 12 
 libavfilter/vf_displace.c | 16 +--
 libavfilter/vf_hysteresis.c   | 14 -
 libavfilter/vf_libvmaf.c  | 12 
 libavfilter/vf_lut2.c | 14 -
 libavfilter/vf_lut3d.c| 12 
 libavfilter/vf_maskedclamp.c  | 16 +--
 libavfilter/vf_maskedmerge.c  | 14 -
 libavfilter/vf_mergeplanes.c  | 12 
 libavfilter/vf_midequalizer.c | 14 -
 libavfilter/vf_overlay.c  | 12 
 libavfilter/vf_paletteuse.c   | 12 
 libavfilter/vf_premultiply.c  | 14 -
 libavfilter/vf_psnr.c | 12 
 libavfilter/vf_remap.c| 16 +--
 libavfilter/vf_ssim.c | 12 
 libavfilter/vf_stack.c| 12 
 libavfilter/vf_threshold.c| 18 ++--
 23 files changed, 190 insertions(+), 190 deletions(-)
 rename libavfilter/{framesync2.c => framesync.c} (93%)
 rename libavfilter/{framesync2.h => framesync.h} (86%)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1e460ab988..3948f6b688 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -67,7 +67,7 @@ OBJS-$(CONFIG_ASHOWINFO_FILTER)  += af_ashowinfo.o
 OBJS-$(CONFIG_ASIDEDATA_FILTER)  += f_sidedata.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o
-OBJS-$(CONFIG_ASTREAMSELECT_FILTER)  += f_streamselect.o framesync2.o
+OBJS-$(CONFIG_ASTREAMSELECT_FILTER)  += f_streamselect.o framesync.o
 OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o
 OBJS-$(CONFIG_ATRIM_FILTER)  += trim.o
 OBJS-$(CONFIG_AZMQ_FILTER)   += f_zmq.o
@@ -136,7 +136,7 @@ OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BITPLANENOISE_FILTER)  += vf_bitplanenoise.o
 OBJS-$(CONFIG_BLACKDETECT_FILTER)+= vf_blackdetect.o
 OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o
-OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o framesync2.o
+OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o framesync.o
 OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o
 OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
@@ -169,7 +169,7 @@ OBJS-$(CONFIG_DESHAKE_FILTER)+= vf_deshake.o
 OBJS-$(CONFIG_DESPILL_FILTER)+= vf_despill.o
 OBJS-$(CONFIG_DETELECINE_FILTER) += vf_detelecine.o
 OBJS-$(CONFIG_DILATION_FILTER)   += vf_neighbor.o
-OBJS-$(CONFIG_DISPLACE_FILTER)   += vf_displace.o framesync2.o
+OBJS-$(CONFIG_DISPLACE_FILTER)   += vf_displace.o framesync.o
 OBJS-$(CONFIG_DOUBLEWEAVE_FILTER)+= vf_weave.o
 OBJS-$(CONFIG_DRAWBOX_FILTER)+= vf_drawbox.o
 OBJS-$(CONFIG_DRAWGRAPH_FILTER)  += f_drawgraph.o
@@ -198,19 +198,19 @@ OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
 OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
 OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
 OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
-OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync2.o
+OBJS-$(CONFIG_HALDCLUT_FILTER)   += vf_lut3d.o framesync.o
 OBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
 OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
 OBJS-$(CONFIG_HISTOGRAM_FILTER)  += vf_histogram.o
 OBJS-$(CONFIG_HQDN3D_FILTER) += vf_hqdn3d.o
 OBJS-$(CONFIG_HQX_FILTER)+= vf_hqx.o
-OBJS-$(CONFIG_HSTACK_FILTER) += vf_stack.o framesync2.o
+OBJS-$(CONFIG_HSTACK_FILTER) += vf_stack.o framesync.o
 OBJS-$(CONFIG_HUE_FILTER)+= vf_hue.o
 OBJS-$(CONFIG_HWDOWNLOAD_FILTER) += vf_hwdownload.o
 OBJS-$(CONFIG_HWMAP_FILTER)  += vf_hwmap.o
 OBJS-$(CONFIG_HWUPLOAD_CUDA_FILTER)  += vf_hwupload_cuda.o
 OBJS-$(CONFIG_HWUPLOAD_FILTER)   += vf_hwupload.o
-OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync2.o
+OBJS-$(CONFIG_HYSTERESIS_FILTER) += vf_hysteresis.o framesync.o
 OBJS-$(CONFIG_IDET_FILTER)   += vf_idet.o
 OBJS-$(CONFIG_IL_FILTER) += vf_il.o
 OBJS-$(CONFIG_INFLATE_FI

[FFmpeg-devel] [PATCH 1/5] lavfi: guess a timestamp for compat status change.

2017-09-07 Thread Nicolas George
Use the earliest input with the same status.
If that fails, print a warning and use the earliest source.
With this change, simple filter forward correctly the timestamp
of EOF.
Filters that are supposed to change it should be updated to
actually forward it.

Signed-off-by: Nicolas George 
---
 libavfilter/avfilter.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 6a97456054..e5c1238182 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -427,6 +427,24 @@ int ff_request_frame(AVFilterLink *link)
 return 0;
 }
 
+static int64_t guess_status_pts(AVFilterContext *ctx, int status)
+{
+unsigned i;
+int64_t r = INT64_MAX;
+
+for (i = 0; i < ctx->nb_inputs; i++)
+if (ctx->inputs[i]->status_out == status)
+r = FFMIN(r, ctx->inputs[i]->current_pts);
+if (r < INT64_MAX)
+return r;
+av_log(ctx, AV_LOG_WARNING, "EOF timestamp not reliable\n");
+for (i = 0; i < ctx->nb_inputs; i++)
+r = FFMIN(r, ctx->inputs[i]->status_in_pts);
+if (r < INT64_MAX)
+return r;
+return AV_NOPTS_VALUE;
+}
+
 static int ff_request_frame_to_filter(AVFilterLink *link)
 {
 int ret = -1;
@@ -440,7 +458,7 @@ static int ff_request_frame_to_filter(AVFilterLink *link)
 ret = ff_request_frame(link->src->inputs[0]);
 if (ret < 0) {
 if (ret != AVERROR(EAGAIN) && ret != link->status_in)
-ff_avfilter_link_set_in_status(link, ret, AV_NOPTS_VALUE);
+ff_avfilter_link_set_in_status(link, ret, 
guess_status_pts(link->src, ret));
 if (ret == AVERROR_EOF)
 ret = 0;
 }
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 2/5] ffmpeg: rename a variable.

2017-09-07 Thread Nicolas George
Makes the reason of the "FIXME" comment more obvious.
Avoid name conflicts for the next commit.

Signed-off-by: Nicolas George 
---
 ffmpeg.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)


This patch and the following have already been discussed. The changes are
tested and work, but they were on hold pending possible checks by Michael.
Since nothing comes, I will push soon unless somebody objects with new
arguments.

With this patch series, when a filter uses ff_request_frame() and it returns
EOF, inlink->current_pts is correctly set to the end timestamp of the
stream.

It applies in particular to Thierry's patch for vf_fps.


diff --git a/ffmpeg.c b/ffmpeg.c
index ccb6638e0a..c8ee64621c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2628,7 +2628,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 
 // while we have more to decode or while the decoder did output something 
on EOF
 while (ist->decoding_needed) {
-int64_t duration = 0;
+int64_t duration_dts = 0;
 int got_output = 0;
 int decode_failed = 0;
 
@@ -2645,22 +2645,22 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
&decode_failed);
 if (!repeating || !pkt || got_output) {
 if (pkt && pkt->duration) {
-duration = av_rescale_q(pkt->duration, ist->st->time_base, 
AV_TIME_BASE_Q);
+duration_dts = av_rescale_q(pkt->duration, 
ist->st->time_base, AV_TIME_BASE_Q);
 } else if(ist->dec_ctx->framerate.num != 0 && 
ist->dec_ctx->framerate.den != 0) {
 int ticks= av_stream_get_parser(ist->st) ? 
av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame;
-duration = ((int64_t)AV_TIME_BASE *
+duration_dts = ((int64_t)AV_TIME_BASE *
 ist->dec_ctx->framerate.den * ticks) /
 ist->dec_ctx->framerate.num / 
ist->dec_ctx->ticks_per_frame;
 }
 
-if(ist->dts != AV_NOPTS_VALUE && duration) {
-ist->next_dts += duration;
+if(ist->dts != AV_NOPTS_VALUE && duration_dts) {
+ist->next_dts += duration_dts;
 }else
 ist->next_dts = AV_NOPTS_VALUE;
 }
 
 if (got_output)
-ist->next_pts += duration; //FIXME the duration is not correct 
in some cases
+ist->next_pts += duration_dts; //FIXME the duration is not 
correct in some cases
 break;
 case AVMEDIA_TYPE_SUBTITLE:
 if (repeating)
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 5/5] ffmpeg: send EOF pts to filters.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 ffmpeg.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index b95addd277..1d248bc269 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2223,14 +2223,14 @@ static int ifilter_send_frame(InputFilter *ifilter, 
AVFrame *frame)
 return 0;
 }
 
-static int ifilter_send_eof(InputFilter *ifilter)
+static int ifilter_send_eof(InputFilter *ifilter, int64_t pts)
 {
 int i, j, ret;
 
 ifilter->eof = 1;
 
 if (ifilter->filter) {
-ret = av_buffersrc_add_frame_flags(ifilter->filter, NULL, 
AV_BUFFERSRC_FLAG_PUSH);
+ret = av_buffersrc_close(ifilter->filter, pts, AV_BUFFERSRC_FLAG_PUSH);
 if (ret < 0)
 return ret;
 } else {
@@ -2581,8 +2581,12 @@ out:
 static int send_filter_eof(InputStream *ist)
 {
 int i, ret;
+/* TODO keep pts also in stream time base to avoid converting back */
+int64_t pts = av_rescale_q_rnd(ist->pts, AV_TIME_BASE_Q, 
ist->st->time_base,
+   AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX);
+
 for (i = 0; i < ist->nb_filters; i++) {
-ret = ifilter_send_eof(ist->filters[i]);
+ret = ifilter_send_eof(ist->filters[i], pts);
 if (ret < 0)
 return ret;
 }
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 3/5] ffmpeg: use reordered duration for stream PTS.

2017-09-07 Thread Nicolas George
Signed-off-by: Nicolas George 
---
 ffmpeg.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index c8ee64621c..b95addd277 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2368,7 +2368,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, 
int *got_output,
 return err < 0 ? err : ret;
 }
 
-static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int 
eof,
+static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, 
int64_t *duration_pts, int eof,
 int *decode_failed)
 {
 AVFrame *decoded_frame;
@@ -2459,6 +2459,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output, int eo
 ist->hwaccel_retrieved_pix_fmt = decoded_frame->format;
 
 best_effort_timestamp= decoded_frame->best_effort_timestamp;
+*duration_pts = decoded_frame->pkt_duration;
 
 if (ist->framerate.num)
 best_effort_timestamp = ist->cfr_next_pts++;
@@ -2629,6 +2630,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 // while we have more to decode or while the decoder did output something 
on EOF
 while (ist->decoding_needed) {
 int64_t duration_dts = 0;
+int64_t duration_pts = 0;
 int got_output = 0;
 int decode_failed = 0;
 
@@ -2641,7 +2643,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
&decode_failed);
 break;
 case AVMEDIA_TYPE_VIDEO:
-ret = decode_video(ist, repeating ? NULL : &avpkt, 
&got_output, !pkt,
+ret = decode_video(ist, repeating ? NULL : &avpkt, 
&got_output, &duration_pts, !pkt,
&decode_failed);
 if (!repeating || !pkt || got_output) {
 if (pkt && pkt->duration) {
@@ -2660,7 +2662,7 @@ static int process_input_packet(InputStream *ist, const 
AVPacket *pkt, int no_eo
 }
 
 if (got_output)
-ist->next_pts += duration_dts; //FIXME the duration is not 
correct in some cases
+ist->next_pts += av_rescale_q(duration_pts, 
ist->st->time_base, AV_TIME_BASE_Q);
 break;
 case AVMEDIA_TYPE_SUBTITLE:
 if (repeating)
-- 
2.14.1

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


[FFmpeg-devel] [PATCH 4/5] lavfi/buffersrc: add av_buffersrc_close().

2017-09-07 Thread Nicolas George
TODO APIChanges and minor bump.

Signed-off-by: Nicolas George 
---
 libavfilter/buffersrc.c | 22 --
 libavfilter/buffersrc.h |  8 
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index e8f59c2de7..ad5aedd5f7 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -196,16 +196,9 @@ static int av_buffersrc_add_frame_internal(AVFilterContext 
*ctx,
 
 s->nb_failed_requests = 0;
 
-if (!frame) {
-s->eof = 1;
-ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, 
AV_NOPTS_VALUE);
-if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
-ret = push_frame(ctx->graph);
-if (ret < 0)
-return ret;
-}
-return 0;
-} else if (s->eof)
+if (!frame)
+return av_buffersrc_close(ctx, AV_NOPTS_VALUE, flags);
+if (s->eof)
 return AVERROR(EINVAL);
 
 refcounted = !!frame->buf[0];
@@ -267,6 +260,15 @@ static int av_buffersrc_add_frame_internal(AVFilterContext 
*ctx,
 return 0;
 }
 
+int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
+{
+BufferSourceContext *s = ctx->priv;
+
+s->eof = 1;
+ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, pts);
+return (flags & AV_BUFFERSRC_FLAG_PUSH) ? push_frame(ctx->graph) : 0;
+}
+
 static av_cold int init_video(AVFilterContext *ctx)
 {
 BufferSourceContext *c = ctx->priv;
diff --git a/libavfilter/buffersrc.h b/libavfilter/buffersrc.h
index e42c78196b..0652113f2b 100644
--- a/libavfilter/buffersrc.h
+++ b/libavfilter/buffersrc.h
@@ -193,6 +193,14 @@ av_warn_unused_result
 int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
  AVFrame *frame, int flags);
 
+/**
+ * Close the buffer source after EOF.
+ *
+ * This is similar to passing NULL to av_buffersrc_add_frame_flags()
+ * except it takes the timestamp of the EOF, i.e. the timestamp of the end
+ * of the last frame.
+ */
+int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags);
 
 /**
  * @}
-- 
2.14.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 lpf msa functions

2017-09-07 Thread Manojkumar Bhosale
LGTM

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
kaustubh.ra...@imgtec.com
Sent: Monday, September 4, 2017 6:02 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 lpf msa functions

From: Kaustubh Raste 

Updated VP9_LPF_FILTER4_4W macro to process on 8 bit data.
Replaced VP9_LPF_FILTER4_8W with VP9_LPF_FILTER4_4W.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/vp9_lpf_msa.c |   94 ++---
 1 file changed, 14 insertions(+), 80 deletions(-)

diff --git a/libavcodec/mips/vp9_lpf_msa.c b/libavcodec/mips/vp9_lpf_msa.c 
index eef8afc..c82a9e9 100644
--- a/libavcodec/mips/vp9_lpf_msa.c
+++ b/libavcodec/mips/vp9_lpf_msa.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Shivraj Patil (shivraj.pa...@imgtec.com)
+ * Copyright (c) 2015 - 2017 Shivraj Patil (shivraj.pa...@imgtec.com)
  *
  * This file is part of FFmpeg.
  *
@@ -22,63 +22,12 @@
 #include "libavutil/mips/generic_macros_msa.h"
 #include "vp9dsp_mips.h"
 
-#define VP9_LPF_FILTER4_8W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in,  \
-   p1_out, p0_out, q0_out, q1_out)   \
-{\
-v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign;  \
-v16i8 filt, filt1, filt2, cnst4b, cnst3b;\
-v8i16 q0_sub_p0_r, filt_r, cnst3h;   \
- \
-p1_m = (v16i8) __msa_xori_b(p1_in, 0x80);\
-p0_m = (v16i8) __msa_xori_b(p0_in, 0x80);\
-q0_m = (v16i8) __msa_xori_b(q0_in, 0x80);\
-q1_m = (v16i8) __msa_xori_b(q1_in, 0x80);\
- \
-filt = __msa_subs_s_b(p1_m, q1_m);   \
-filt = filt & (v16i8) hev_in;\
-q0_sub_p0 = q0_m - p0_m; \
-filt_sign = __msa_clti_s_b(filt, 0); \
- \
-cnst3h = __msa_ldi_h(3); \
-q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0);\
-q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h);   \
-filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt);  \
-filt_r += q0_sub_p0_r;   \
-filt_r = __msa_sat_s_h(filt_r, 7);   \
- \
-/* combine left and right part */\
-filt = __msa_pckev_b((v16i8) filt_r, (v16i8) filt_r);\
- \
-filt = filt & (v16i8) mask_in;   \
-cnst4b = __msa_ldi_b(4); \
-filt1 = __msa_adds_s_b(filt, cnst4b);\
-filt1 >>= 3; \
- \
-cnst3b = __msa_ldi_b(3); \
-filt2 = __msa_adds_s_b(filt, cnst3b);\
-filt2 >>= 3; \
- \
-q0_m = __msa_subs_s_b(q0_m, filt1);  \
-q0_out = __msa_xori_b((v16u8) q0_m, 0x80);   \
-p0_m = __msa_adds_s_b(p0_m, filt2);  \
-p0_out = __msa_xori_b((v16u8) p0_m, 0x80);   \
- \
-filt = __msa_srari_b(filt1, 1);  \
-hev_in = __msa_xori_b((v16u8) hev_in, 0xff); \
-filt = filt & (v16i8) hev_in;\
- \
-q1_m = __msa_subs_s_b(q1_m, filt);   \
-q1_out = __msa_xori_b((v16u8) q1_m, 0x80);   \
-p1_m = __msa_adds_s_b(p1_m, filt);   \
-p1_out = __msa_xori_b((v16u8) p1_m, 0x80);   \
-}
-
 #define VP9_LPF_FILTER4_4W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in,  \
p1_out, p0_out, q0_out, q1_out)   \
 {  

Re: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 idct msa functions

2017-09-07 Thread Manojkumar Bhosale
LGTM

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
kaustubh.ra...@imgtec.com
Sent: Monday, September 4, 2017 6:02 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 idct msa functions

From: Kaustubh Raste 

Removed memset calls.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/vp9_idct_msa.c |  118 
 1 file changed, 70 insertions(+), 48 deletions(-)

diff --git a/libavcodec/mips/vp9_idct_msa.c b/libavcodec/mips/vp9_idct_msa.c 
index 25ea16c..bd762f2 100644
--- a/libavcodec/mips/vp9_idct_msa.c
+++ b/libavcodec/mips/vp9_idct_msa.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Shivraj Patil (shivraj.pa...@imgtec.com)
+ * Copyright (c) 2015 - 2017 Shivraj Patil (shivraj.pa...@imgtec.com)
  *
  * This file is part of FFmpeg.
  *
@@ -352,6 +352,7 @@ static void vp9_idct4x4_1_add_msa(int16_t *input, uint8_t 
*dst,
 out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS);
 out = ROUND_POWER_OF_TWO(out, 4);
 vec = __msa_fill_h(out);
+input[0] = 0;
 
 ADDBLK_ST4x4_UB(vec, vec, vec, vec, dst, dst_stride);  } @@ -360,9 +361,11 
@@ static void vp9_idct4x4_colcol_addblk_msa(int16_t *input, uint8_t *dst,
   int32_t dst_stride)  {
 v8i16 in0, in1, in2, in3;
+v8i16 zero = { 0 };
 
 /* load vector elements of 4x4 block */
 LD4x4_SH(input, in0, in1, in2, in3);
+ST_SH2(zero, zero, input, 8);
 /* rows */
 VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
 /* columns */
@@ -377,9 +380,11 @@ static void vp9_iadst4x4_colcol_addblk_msa(int16_t *input, 
uint8_t *dst,
int32_t dst_stride)  {
 v8i16 in0, in1, in2, in3;
+v8i16 zero = { 0 };
 
 /* load vector elements of 4x4 block */
 LD4x4_SH(input, in0, in1, in2, in3);
+ST_SH2(zero, zero, input, 8);
 /* rows */
 VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3);
 /* columns */
@@ -394,9 +399,11 @@ static void vp9_iadst_idct_4x4_add_msa(int16_t *input, 
uint8_t *dst,
int32_t dst_stride, int32_t eob)  {
 v8i16 in0, in1, in2, in3;
+v8i16 zero = { 0 };
 
 /* load vector elements of 4x4 block */
 LD4x4_SH(input, in0, in1, in2, in3);
+ST_SH2(zero, zero, input, 8);
 /* cols */
 VP9_IADST4x4(in0, in1, in2, in3, in0, in1, in2, in3);
 /* columns */
@@ -411,9 +418,11 @@ static void vp9_idct_iadst_4x4_add_msa(int16_t *input, 
uint8_t *dst,
int32_t dst_stride, int32_t eob)  {
 v8i16 in0, in1, in2, in3;
+v8i16 zero = { 0 };
 
 /* load vector elements of 4x4 block */
 LD4x4_SH(input, in0, in1, in2, in3);
+ST_SH2(zero, zero, input, 8);
 /* cols */
 VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
 /* columns */
@@ -585,6 +594,7 @@ static void vp9_idct8x8_1_add_msa(int16_t *input, uint8_t 
*dst,
 out = ROUND_POWER_OF_TWO((out * cospi_16_64), VP9_DCT_CONST_BITS);
 val = ROUND_POWER_OF_TWO(out, 5);
 vec = __msa_fill_h(val);
+input[0] = 0;
 
 VP9_ADDBLK_ST8x4_UB(dst, dst_stride, vec, vec, vec, vec);
 dst += (4 * dst_stride);
@@ -601,9 +611,9 @@ static void vp9_idct8x8_12_colcol_addblk_msa(int16_t 
*input, uint8_t *dst,
 
 /* load vector elements of 8x8 block */
 LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7);
+ST_SH8(zero, zero, zero, zero, zero, zero, zero, zero, input, 8);
 ILVR_D2_SH(in1, in0, in3, in2, in0, in1);
 ILVR_D2_SH(in5, in4, in7, in6, in2, in3);
-//TRANSPOSE8X4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
 
 /* stage1 */
 ILVL_H2_SH(in3, in0, in2, in1, s0, s1); @@ -659,9 +669,11 @@ static void 
vp9_idct8x8_colcol_addblk_msa(int16_t *input, uint8_t *dst,
   int32_t dst_stride)  {
 v8i16 in0, in1, in2, in3, in4, in5, in6, in7;
+v8i16 zero = { 0 };
 
 /* load vector elements of 8x8 block */
 LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7);
+ST_SH8(zero, zero, zero, zero, zero, zero, zero, zero, input, 8);
 /* 1D idct8x8 */
 VP9_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7,
in0, in1, in2, in3, in4, in5, in6, in7); @@ -689,10 +701,11 
@@ static void vp9_iadst8x8_colcol_addblk_msa(int16_t *input, uint8_t *dst,
 v8i16 out0, out1, out2, out3, out4, out5, out6, out7;
 v8i16 cnst0, cnst1, cnst2, cnst3, cnst4;
 v8i16 temp0, temp1, temp2, temp3, s0, s1;
-v16i8 zero = { 0 };
+v8i16 zero = { 0 };
 
 /* load vector elements of 8x8 block */
 LD_SH8(input, 8, in0, in1, in2, in3, in4, in5, in6, in7);
+ST_SH8(zero, zero, zero, zero, zero, zero, zero, zero, input, 8);
 
 /* 1D adst8x8 */
 VP9_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, @@ -736,13 +749,13 @@ 
static void vp9_iadst8x8_colcol_addblk_msa(int16_t *input, uint8_t 

Re: [FFmpeg-devel] [PATCH 8/8] doc: update filter_design.txt.

2017-09-07 Thread Reto Kromer
Nicolas George wrote:

>Signed-off-by: Nicolas George 
>---
> doc/filter_design.txt | 251 
>+++---
> 1 file changed, 135 insertions(+), 116 deletions(-)
>
>diff --git a/doc/filter_design.txt b/doc/filter_design.txt
>index e8a7c53ee9..90fa53367b 100644
>--- a/doc/filter_design.txt
>+++ b/doc/filter_design.txt

>+The typical task of an activate callback is to fisrt check the 
>backward

tiny typo: first

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


Re: [FFmpeg-devel] [PATCH 8/8] doc: update filter_design.txt.

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Reto Kromer a écrit :
> tiny typo: first

Thanks, locally fixed.

Also fixed inut -> input in the same paragraph.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avcodec/nvenc: migrate to new encode API

2017-09-07 Thread Timo Rothenpieler

Am 06.09.2017 um 23:07 schrieb Philip Langdale:

On Wed, 6 Sep 2017 18:14:17 +0200
Timo Rothenpieler  wrote:


+int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
+{
+CUresult cu_res;
+CUcontext dummy;
+NvencSurface *tmpoutsurf;


You can remove tmpoutsurf in ff_nvenc_send_frame


But it's used in it? At the very end, to move the frames between
queues.



Yes, I mis-read that. Ship it.


applied



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


Re: [FFmpeg-devel] [PATCH] avformat/gdv: Make FixedSize static

2017-09-07 Thread Michael Niedermayer
On Mon, Sep 04, 2017 at 07:36:09PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/gdv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

applied

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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mov: Fix DoS in read_tfra()

2017-09-07 Thread Michael Niedermayer
On Tue, Sep 05, 2017 at 02:55:25AM +0200, Michael Niedermayer wrote:
> Fixes: Missing EOF check in loop
> No testcase
> 
> Found-by: Xiaohei and Wangchu from Alibaba Security Team
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/mov.c | 7 +++
>  1 file changed, 7 insertions(+)

patchset applied

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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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


Re: [FFmpeg-devel] [PATCH v2] ffprobe: use consistent string for unspecified color_range value

2017-09-07 Thread Tobias Rapp

On 05.09.2017 15:28, Paul B Mahol wrote:

On 9/5/17, Tobias Rapp  wrote:

On 29.08.2017 16:07, Tobias Rapp wrote:

Makes the handling of unspecified/unknown color_range values on stream
level consistent to the value used on frame level.

Signed-off-by: Tobias Rapp 
---
   ffprobe.c  | 8 
   tests/ref/fate/ffprobe_compact | 4 ++--
   tests/ref/fate/ffprobe_csv | 4 ++--
   tests/ref/fate/ffprobe_default | 4 ++--
   tests/ref/fate/ffprobe_flat| 4 ++--
   tests/ref/fate/ffprobe_ini | 4 ++--
   tests/ref/fate/mxf-probe-dnxhd | 2 +-
   tests/ref/fate/mxf-probe-dv25  | 2 +-
   8 files changed, 16 insertions(+), 16 deletions(-)
[...]


I'd like to push this if there are no objections within the next two days.



LGTM


Pushed, thanks for review.

Regards,
Tobias

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


Re: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 mc msa functions

2017-09-07 Thread Manojkumar Bhosale
LGTM

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
kaustubh.ra...@imgtec.com
Sent: Monday, September 4, 2017 6:03 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 mc msa functions

From: Kaustubh Raste 

Load the specific destination bytes instead of MSA load and pack.

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/h264qpel_msa.c  |   17 +-
 libavcodec/mips/vp9_mc_msa.c|  759 ---
 libavutil/mips/generic_macros_msa.h |   24 +-
 3 files changed, 369 insertions(+), 431 deletions(-)

diff --git a/libavcodec/mips/h264qpel_msa.c b/libavcodec/mips/h264qpel_msa.c
index c38f1f7..43d21f7 100644
--- a/libavcodec/mips/h264qpel_msa.c
+++ b/libavcodec/mips/h264qpel_msa.c
@@ -1479,7 +1479,8 @@ static void avc_luma_hz_and_aver_dst_8x8_msa(const 
uint8_t *src,
  plus20b, res0, res1, res2, res3);
 SRARI_H4_SH(res0, res1, res2, res3, 5);
 SAT_SH4_SH(res0, res1, res2, res3, 7);
-CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3,
+ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
+CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1,
 dst, dst_stride);
 
 dst += (4 * dst_stride);
@@ -1825,8 +1826,8 @@ static void avc_luma_vt_and_aver_dst_8x8_msa(const 
uint8_t *src,
 SRARI_H4_SH(out0, out1, out2, out3, 5);
 SAT_SH4_SH(out0, out1, out2, out3, 7);
 LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
-
-CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3,
+ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
+CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1,
 dst, dst_stride);
 dst += (4 * dst_stride);
 
@@ -2229,7 +2230,8 @@ static void avc_luma_mid_and_aver_dst_8w_msa(const 
uint8_t *src,
 res3 = AVC_CALC_DPADD_H_6PIX_2COEFF_SH(hz_out3, hz_out4, hz_out5,
hz_out6, hz_out7, hz_out8);
 LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3);
-CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3,
+ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
+CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1,
 dst, dst_stride);
 
 dst += (4 * dst_stride);
@@ -2518,8 +2520,8 @@ static void avc_luma_midv_qrt_and_aver_dst_8w_msa(const 
uint8_t *src,
 res1 = __msa_aver_s_h(res2, res3);
 res2 = __msa_aver_s_h(res4, res5);
 res3 = __msa_aver_s_h(res6, res7);
-
-CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1, dst2, dst3,
+ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
+CONVERT_UB_AVG_ST8x4_UB(res0, res1, res2, res3, dst0, dst1,
 dst, dst_stride);
 dst += (4 * dst_stride);
 
@@ -2676,7 +2678,8 @@ static void avc_luma_hv_qrt_and_aver_dst_8x8_msa(const 
uint8_t *src_x,
 out3 = __msa_srari_h((hz_out3 + vert_out3), 1);
 
 SAT_SH4_SH(out0, out1, out2, out3, 7);
-CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst2, dst3,
+ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1);
+CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1,
 dst, dst_stride);
 dst += (4 * dst_stride);
 
diff --git a/libavcodec/mips/vp9_mc_msa.c b/libavcodec/mips/vp9_mc_msa.c
index 1671d97..749e8cb 100644
--- a/libavcodec/mips/vp9_mc_msa.c
+++ b/libavcodec/mips/vp9_mc_msa.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Shivraj Patil (shivraj.pa...@imgtec.com)
+ * Copyright (c) 2015 - 2017 Shivraj Patil (shivraj.pa...@imgtec.com)
  *
  * This file is part of FFmpeg.
  *
@@ -145,16 +145,15 @@ static const int8_t vp9_bilinear_filters_msa[15][2] = {
 ST_UB(tmp_m, (pdst)); \
 }
 
-#define PCKEV_AVG_ST8x4_UB(in1, dst0, in2, dst1, in3, dst2, in4, dst3,  \
-   pdst, stride)\
-{   \
-v16u8 tmp0_m, tmp1_m, tmp2_m, tmp3_m;   \
-uint8_t *pdst_m = (uint8_t *) (pdst);   \
-\
-PCKEV_B2_UB(in2, in1, in4, in3, tmp0_m, tmp1_m);\
-PCKEV_D2_UB(dst1, dst0, dst3, dst2, tmp2_m, tmp3_m);\
-AVER_UB2_UB(tmp0_m, tmp2_m, tmp1_m, tmp3_m, tmp0_m, tmp1_m);\
-ST8x4_UB(tmp0_m, tmp1_m, pdst_m, stride);   \
+#define PCKEV_AVG_ST8x4_UB(in0, in1, in2, in3,  dst0, dst1,   \
+   pdst, stride)  \
+{ \
+v16u8 tmp0_m, tmp1_m

Re: [FFmpeg-devel] [PATCH] avdevice/decklink: new options 'list_pixelformats' and 'pixelformat_code' to allow pixelformat selection by code

2017-09-07 Thread Gildas Fargeas
Sorry I completely forgot about the texi doc !
I agree with you regarding rgb48. It feels misleading. r210 is fine with
me.
I'll send the changes in a few minutes.

2017-09-06 18:47 GMT+02:00 Marton Balint :

>
>
> On Wed, 6 Sep 2017, Gildas Fargeas wrote:
>
> Alright, this should do the trick:
>> - use named const for raw_format option
>> - deprecate bm_v210
>> - bumped avdevice micro version
>>
>> ---
>> libavdevice/decklink_common.cpp |  2 +-
>> libavdevice/decklink_common_c.h |  1 +
>> libavdevice/decklink_dec.cpp| 43 ++
>> ---
>> libavdevice/decklink_dec_c.c|  6 ++
>> libavdevice/version.h   |  2 +-
>> 5 files changed, 45 insertions(+), 9 deletions(-)
>>
>
> Documentation is still missing for the new option from doc/indevs.texi.
>
>
>
>> diff --git a/libavdevice/decklink_common.cpp
>> b/libavdevice/decklink_common.cpp
>> index cbb591ce64..ff2df95909 100644
>> --- a/libavdevice/decklink_common.cpp
>> +++ b/libavdevice/decklink_common.cpp
>> @@ -241,7 +241,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
>> if (ctx->bmd_mode == bmdModeUnknown)
>> return -1;
>> if (direction == DIRECTION_IN) {
>> -if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode,
>> bmdFormat8BitYUV,
>> +if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode,
>> (BMDPixelFormat) cctx->raw_format,
>>bmdVideoOutputFlagDefault,
>>&support, NULL) != S_OK)
>> return -1;
>> diff --git a/libavdevice/decklink_common_c.h
>> b/libavdevice/decklink_common_c.h
>> index e263480474..5616ab32f9 100644
>> --- a/libavdevice/decklink_common_c.h
>> +++ b/libavdevice/decklink_common_c.h
>> @@ -49,6 +49,7 @@ struct decklink_cctx {
>> int video_input;
>> int draw_bars;
>> char *format_code;
>> +int raw_format;
>> int64_t queue_size;
>> };
>>
>> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
>> index c271ff3639..ccbb6f09f5 100644
>> --- a/libavdevice/decklink_dec.cpp
>> +++ b/libavdevice/decklink_dec.cpp
>> @@ -651,6 +651,11 @@ av_cold int ff_decklink_read_header(AVFormatContext
>> *avctx)
>> return AVERROR_EXIT;
>> }
>>
>> +if (cctx->v210) {
>> +av_log(avctx, AV_LOG_WARNING, "The bm_v210 option is deprecated
>> and will be removed. Please use the -raw_format yuv422p10.\n");
>> +cctx->raw_format = MKBETAG('v','2','1','0');
>> +}
>> +
>> strcpy (fname, avctx->filename);
>> tmp=strchr (fname, '@');
>> if (tmp != NULL) {
>> @@ -723,15 +728,39 @@ av_cold int ff_decklink_read_header(AVFormatContext
>> *avctx)
>> st->time_base.num  = ctx->bmd_tb_num;
>> av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den,
>> st->time_base.num));
>>
>> -if (cctx->v210) {
>> -st->codecpar->codec_id= AV_CODEC_ID_V210;
>> -st->codecpar->codec_tag   = MKTAG('V', '2', '1', '0');
>> -st->codecpar->bit_rate= av_rescale(ctx->bmd_width *
>> ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
>> -} else {
>> +switch((BMDPixelFormat)cctx->raw_format) {
>> +case bmdFormat8BitYUV:
>> st->codecpar->codec_id= AV_CODEC_ID_RAWVIDEO;
>> -st->codecpar->format  = AV_PIX_FMT_UYVY422;
>> st->codecpar->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
>> +st->codecpar->format  = AV_PIX_FMT_UYVY422;
>> st->codecpar->bit_rate= av_rescale(ctx->bmd_width *
>> ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
>> +break;
>> +case bmdFormat10BitYUV:
>> +st->codecpar->codec_id= AV_CODEC_ID_V210;
>> +st->codecpar->codec_tag   = MKTAG('V','2','1','0');
>> +st->codecpar->bit_rate= av_rescale(ctx->bmd_width *
>> ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
>> +st->codecpar->bits_per_coded_sample = 10;
>> +break;
>> +case bmdFormat8BitARGB:
>> +st->codecpar->codec_id= AV_CODEC_ID_RAWVIDEO;
>> +st->codecpar->codec_tag   = avcodec_pix_fmt_to_codec_tag((enum
>> AVPixelFormat)st->codecpar->format);;
>> +st->codecpar->format= AV_PIX_FMT_ARGB;
>> +break;
>> +case bmdFormat8BitBGRA:
>> +st->codecpar->codec_id= AV_CODEC_ID_RAWVIDEO;
>> +st->codecpar->codec_tag   = avcodec_pix_fmt_to_codec_tag((enum
>> AVPixelFormat)st->codecpar->format);
>> +st->codecpar->format= AV_PIX_FMT_BGRA;
>> +break;
>> +case bmdFormat10BitRGB:
>> +st->codecpar->codec_id= AV_CODEC_ID_R210;
>> +st->codecpar->codec_tag   = MKTAG('R','2','1','0');
>> +st->codecpar->format= AV_PIX_FMT_RGB48LE;
>> +st->codecpar->bits_per_coded_sample = 10;
>>
>
> You may want to add bitrates to the new formats.
>
>
> +break;
>> +default:
>> +av_log(avctx, AV_LOG_ERROR, "Raw Format %.4s not supported\n",
>> (char*) &cctx->raw_format);

[FFmpeg-devel] [PATCH] avdevice/decklink: new options 'list_pixelformats' and 'pixelformat_code' to allow pixelformat selection by code

2017-09-07 Thread Gildas Fargeas
Ok, I changed the texi, added the bitrate and turned rgb48 value to rgb10. 

---
 doc/indevs.texi | 22 ++--
 libavdevice/decklink_common.cpp |  2 +-
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 46 ++---
 libavdevice/decklink_dec_c.c|  6 ++
 libavdevice/version.h   |  2 +-
 6 files changed, 68 insertions(+), 11 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index ad6418751b..0c71361ded 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -214,8 +214,9 @@ need to configure with the appropriate @code{--extra-cflags}
 and @code{--extra-ldflags}.
 On Windows, you need to run the IDL files through @command{widl}.
 
-DeckLink is very picky about the formats it supports. Pixel format is
-uyvy422 or v210, framerate and video size must be determined for your device 
with
+DeckLink is very picky about the formats it supports. Pixel format of the
+input can be set with @option{raw_format}.
+Framerate and video size must be determined for your device with
 @command{-list_formats 1}. Audio sample rate is always 48 kHz and the number
 of channels can be 2, 8 or 16. Note that all audio channels are bundled in one 
single
 audio track.
@@ -239,9 +240,26 @@ Note that there is a FourCC @option{'pal '} that can also 
be used
 as @option{pal} (3 letters).
 
 @item bm_v210
+This is a deprecated option, you can use @option{raw_format} instead. 
 If set to @samp{1}, video is captured in 10 bit v210 instead
 of uyvy422. Not all Blackmagic devices support this option.
 
+@item raw_format
+Set the pixel format of the captured video. 
+Available values are:
+@table @samp
+@item uyvy422
+
+@item yuv422p10
+
+@item argb
+
+@item bgra
+
+@item rgb10
+
+@end table
+
 @item teletext_lines
 If set to nonzero, an additional teletext stream will be captured from the
 vertical ancillary data. Both SD PAL (576i) and HD (1080i or 1080p)
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index cbb591ce64..ff2df95909 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -241,7 +241,7 @@ int ff_decklink_set_format(AVFormatContext *avctx,
 if (ctx->bmd_mode == bmdModeUnknown)
 return -1;
 if (direction == DIRECTION_IN) {
-if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
+if (ctx->dli->DoesSupportVideoMode(ctx->bmd_mode, (BMDPixelFormat) 
cctx->raw_format,
bmdVideoOutputFlagDefault,
&support, NULL) != S_OK)
 return -1;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index e263480474..5616ab32f9 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -49,6 +49,7 @@ struct decklink_cctx {
 int video_input;
 int draw_bars;
 char *format_code;
+int raw_format;
 int64_t queue_size;
 };
 
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index c271ff3639..dd1423b866 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -651,6 +651,11 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
 return AVERROR_EXIT;
 }
 
+if (cctx->v210) {
+av_log(avctx, AV_LOG_WARNING, "The bm_v210 option is deprecated and 
will be removed. Please use the -raw_format yuv422p10.\n");
+cctx->raw_format = MKBETAG('v','2','1','0');
+}
+
 strcpy (fname, avctx->filename);
 tmp=strchr (fname, '@');
 if (tmp != NULL) {
@@ -723,15 +728,42 @@ av_cold int ff_decklink_read_header(AVFormatContext 
*avctx)
 st->time_base.num  = ctx->bmd_tb_num;
 av_stream_set_r_frame_rate(st, av_make_q(st->time_base.den, 
st->time_base.num));
 
-if (cctx->v210) {
-st->codecpar->codec_id= AV_CODEC_ID_V210;
-st->codecpar->codec_tag   = MKTAG('V', '2', '1', '0');
-st->codecpar->bit_rate= av_rescale(ctx->bmd_width * 
ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
-} else {
+switch((BMDPixelFormat)cctx->raw_format) {
+case bmdFormat8BitYUV:
 st->codecpar->codec_id= AV_CODEC_ID_RAWVIDEO;
-st->codecpar->format  = AV_PIX_FMT_UYVY422;
 st->codecpar->codec_tag   = MKTAG('U', 'Y', 'V', 'Y');
+st->codecpar->format  = AV_PIX_FMT_UYVY422;
 st->codecpar->bit_rate= av_rescale(ctx->bmd_width * 
ctx->bmd_height * 16, st->time_base.den, st->time_base.num);
+break;
+case bmdFormat10BitYUV:
+st->codecpar->codec_id= AV_CODEC_ID_V210;
+st->codecpar->codec_tag   = MKTAG('V','2','1','0');
+st->codecpar->bit_rate= av_rescale(ctx->bmd_width * 
ctx->bmd_height * 64, st->time_base.den, st->time_base.num * 3);
+st->codecpar->bits_per_coded_sample = 10;
+break;
+case bmdFormat8BitARGB:
+st->codecpar->codec_id= AV_COD

[FFmpeg-devel] rtmps connect block

2017-09-07 Thread Qiming Jin (qimijin)
Hi all
Please help check an issue:
When I sent date to rtmps server(facebook live).  Connection will block after 
sent 10 packet.
Below is the situation:
1 build: ./configure –enable-openssl && make && make install
2 connet to rtmp is ok. But rtmps is fail, BLOCK after sent out 10 packet.
3 if delete  this line :
ret = ffurl_read(rt->stream, &c, 1);
and add:
  ret = AVERROR(EAGAIN);
in function rtmp_write(), then every thing will be ok.
I also found this line was added at this commit:
https://github.com/FFmpeg/FFmpeg/commit/7dc747f50b0adeaf2bcf6413e291dc4bffa54f9a
4 my code is attached,  for your reference.

  I want to know if this is a bug, if not, how to fix this? Can I simply fix it 
as point3 said.
Thanks!


(gdb) bt
#0  0x76657bb0 in __poll_nocancel () from /lib64/libc.so.6
#1  0x005ae7a5 in ff_network_wait_fd (write=0, fd=8) at 
libavformat/network.c:79
#2  ff_network_wait_fd_timeout (fd=8, write=write@entry=0, timeout=0, 
int_cb=int_cb@entry=0x1c37e70)
at libavformat/network.c:92
#3  0x005b9fc6 in tcp_read (h=0x1c37e40, buf=0x1c45b93 "\027\003\003", 
size=5) at libavformat/tcp.c:219
#4  0x005a2c86 in retry_transfer_wrapper (transfer_func=0x5b9f80 
, size_min=1, size=5,
buf=0x1c45b93 "\027\003\003", h=0x1c37e40) at libavformat/avio.c:380
#5  ffurl_read (h=0x1c37e40, buf=0x1c45b93 "\027\003\003", size=5) at 
libavformat/avio.c:416
#6  0x005ba901 in url_bio_bread (b=0x1c363c0, buf=, 
len=)
at libavformat/tls_openssl.c:97
#7  0x77494c4b in BIO_read () from /lib64/libcrypto.so.10
#8  0x771787d4 in ssl3_read_n () from /lib64/libssl.so.10
#9  0x77179acd in ssl3_read_bytes () from /lib64/libssl.so.10
#10 0x77176d74 in ssl3_read_internal () from /lib64/libssl.so.10
#11 0x005baaba in tls_read (h=0x1ce0c80, buf=0x7fffdcf0 
"L\001\305\001", size=1)
at libavformat/tls_openssl.c:306
#12 0x005a2c86 in retry_transfer_wrapper (transfer_func=0x5baa80 
, size_min=1, size=1,
buf=0x7fffdcf0 "L\001\305\001", h=0x1ce0c80) at libavformat/avio.c:380
#13 ffurl_read (h=0x1ce0c80, buf=buf@entry=0x7fffdcf0 "L\001\305\001", 
size=size@entry=1) at libavformat/avio.c:416
#14 0x005b540c in rtmp_write (s=s@entry=0x1caf500, 
buf=buf@entry=0x1c50140 "\b", size=size@entry=434)
at libavformat/rtmpproto.c:3083
#15 0x005a2fdb in retry_transfer_wrapper (transfer_func=0x5b5070 
, size_min=434, size=434,
buf=0x1c50140 "\b", h=0x1caf500) at libavformat/avio.c:380
#16 ffurl_write (h=0x1caf500, buf=0x1c50140 "\b", size=434) at 
libavformat/avio.c:434
#17 0x0047c5bd in writeout (len=434, data=, s=0x1cab1c0) 
at libavformat/aviobuf.c:154
#18 flush_buffer (s=0x1cab1c0) at libavformat/aviobuf.c:171
#19 avio_flush (s=0x1cab1c0) at libavformat/aviobuf.c:227
#20 0x00510d45 in write_packet (pkt=0x7fffdec0, s=0x1c37260) at 
libavformat/mux.c:776
#21 av_interleaved_write_frame (s=0x1c37260, pkt=0x0) at libavformat/mux.c:1291
#22 0x00464202 in main ()


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


Re: [FFmpeg-devel] [PATCH]lavf/gdv: Improve palette saturation

2017-09-07 Thread Carl Eugen Hoyos
2017-08-26 13:00 GMT+02:00 Carl Eugen Hoyos :
> Hi!
>
> Attached patch slightly improves the saturation of the gdv palette.

I'll push this if there are no objections.

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


[FFmpeg-devel] [PATCH]lavf/supenc: Add a raw PGS muxer

2017-09-07 Thread Carl Eugen Hoyos
Hi!

Attached patch implements ticket #2208.

Please comment, Carl Eugen
From 919cd9728e73a9570a11f0d575b23c0212ca52e4 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Thu, 7 Sep 2017 15:28:55 +0200
Subject: [PATCH] lavf/supenc: Add a raw PGS muxer.

Fixes ticket #2208.
---
 Changelog|1 +
 libavformat/Makefile |1 +
 libavformat/allformats.c |2 +-
 libavformat/supenc.c |   54 ++
 libavformat/version.h|2 +-
 5 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/supenc.c

diff --git a/Changelog b/Changelog
index cae5254..b62291a 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - add --disable-autodetect build switch
 - drop deprecated qtkit input device (use avfoundation instead)
 - despill video filter
+- raw PGS subtitle muxer
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/libavformat/Makefile b/libavformat/Makefile
index de954af..ef44f14 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -473,6 +473,7 @@ OBJS-$(CONFIG_STR_DEMUXER)   += psxstr.o
 OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)+= subviewer1dec.o subtitles.o
 OBJS-$(CONFIG_SUBVIEWER_DEMUXER) += subviewerdec.o subtitles.o
 OBJS-$(CONFIG_SUP_DEMUXER)   += supdec.o
+OBJS-$(CONFIG_SUP_MUXER) += supenc.o
 OBJS-$(CONFIG_SVAG_DEMUXER)  += svag.o
 OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index cb09a60..62b0cf8 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -303,7 +303,7 @@ static void register_all(void)
 REGISTER_DEMUXER (STL,  stl);
 REGISTER_DEMUXER (SUBVIEWER1,   subviewer1);
 REGISTER_DEMUXER (SUBVIEWER,subviewer);
-REGISTER_DEMUXER (SUP,  sup);
+REGISTER_MUXDEMUX(SUP,  sup);
 REGISTER_DEMUXER (SVAG, svag);
 REGISTER_MUXDEMUX(SWF,  swf);
 REGISTER_DEMUXER (TAK,  tak);
diff --git a/libavformat/supenc.c b/libavformat/supenc.c
new file mode 100644
index 000..bc8cd0b
--- /dev/null
+++ b/libavformat/supenc.c
@@ -0,0 +1,54 @@
+/*
+ * raw PGS muxer
+ * Copyright (c) 2017 Carl Eugen Hoyos
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "internal.h"
+
+static int sup_write_header(AVFormatContext *s)
+{
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "only exactly one PGS stream is supported\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int sup_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+AVIOContext *pb = s->pb;
+
+avio_wb16(pb, 0x5047); /* PG */
+avio_wb32(pb, pkt->pts == AV_NOPTS_VALUE ? 0 : pkt->pts);
+avio_wb32(pb, pkt->dts == AV_NOPTS_VALUE ? 0 : pkt->dts);
+avio_write(pb, pkt->data, pkt->size);
+
+return 0;
+}
+
+AVOutputFormat ff_sup_muxer = {
+.name  = "sup",
+.long_name = NULL_IF_CONFIG_SMALL("raw HDMV Presentation Graphic Stream subtitles"),
+.extensions= "sup",
+.subtitle_codec= AV_CODEC_ID_HDMV_PGS_SUBTITLE,
+.write_header  = sup_write_header,
+.write_packet  = sup_write_packet,
+};
diff --git a/libavformat/version.h b/libavformat/version.h
index 9cca76e..aeb5940 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
-#define LIBAVFORMAT_VERSION_MINOR  81
+#define LIBAVFORMAT_VERSION_MINOR  82
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]lavf/gdv: Improve palette saturation

2017-09-07 Thread Ronald S. Bultje
Hi Carl,

On Mon, Aug 28, 2017 at 10:49 AM, Carl Eugen Hoyos 
wrote:

> 2017-08-27 9:03 GMT+02:00 Paul B Mahol :
> > On 8/26/17, Carl Eugen Hoyos  wrote:
>
> >> Attached patch slightly improves the saturation of the
> >> gdv palette.
> >>
> >> Please comment, Carl Eugen
> >
> > Does this match how it is displayed by original game?
>
> The original game was written for a graphic adapter that
> supports 6bit palette. FFmpeg only supports 8bit palette,
>

OK, so that matches the current code:

 unsigned r = bytestream2_get_byte(gb);
 unsigned g = bytestream2_get_byte(gb);
 unsigned b = bytestream2_get_byte(gb);
 gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;

This indeed suggests the byte only contains 6 lower bits, the upper 2 being
0. It also indeed suggests that "white" (11) would be converted to (in
bits) 1100, not , which is indeed unsaturated.


> the patch makes the colour white (and all saturated colours)
> as similar to the intended output as possible and does not
> change black (and other colours with little intensity).


So let's say you have (in bits) 11 or 00 (white and black).

 unsigned r = bytestream2_get_byte(gb);
 unsigned g = bytestream2_get_byte(gb);
 unsigned b = bytestream2_get_byte(gb);
+r |= r >> 4;
+g |= g >> 4;
+b |= b >> 4;

This converts that to 11 and 00.

 gdv->pal[i] = 0xFFU << 24 | r << 18 | g << 10 | b << 2;

And it seems to me that the color is then _still_ 1100, which is
unsaturated. Don't you want to do something like:

#define convert6to8(x) ((x << 2) | ((x + 8) >> 4))

 unsigned r = bytestream2_get_byte(gb);
 unsigned g = bytestream2_get_byte(gb);
 unsigned b = bytestream2_get_byte(gb);
+r = convert6to8(r);
+g = convert6to8(g);
+b = convert6to8(b);
 gdv->pal[i] = (0xFFU << 24) | (r << 16) | (g << 8) | b;

Or am I misunderstanding?

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


[FFmpeg-devel] [PATCH] libavcodec/h264_parse: don't use uninitialized value when chroma_format_idc==0

2017-09-07 Thread Mark Wachsler
When parsing a monochrome file, chroma_log2_weight_denom was used without
being initialized, which could lead to a bogus error message being printed, e.g.
  [h264 @ 0x61a26480] chroma_log2_weight_denom 24576 is out of range
It also could led to warnings using AddressSanitizer.
---
 libavcodec/h264_parse.c | 27 +++
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index 3d20075f6a..a7c71d9bbb 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -34,21 +34,22 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS 
*sps,
 
 pwt->use_weight = 0;
 pwt->use_weight_chroma  = 0;
-pwt->luma_log2_weight_denom = get_ue_golomb(gb);
-if (sps->chroma_format_idc)
-pwt->chroma_log2_weight_denom = get_ue_golomb(gb);
 
+pwt->luma_log2_weight_denom = get_ue_golomb(gb);
 if (pwt->luma_log2_weight_denom > 7U) {
 av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of 
range\n", pwt->luma_log2_weight_denom);
 pwt->luma_log2_weight_denom = 0;
 }
-if (pwt->chroma_log2_weight_denom > 7U) {
-av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of 
range\n", pwt->chroma_log2_weight_denom);
-pwt->chroma_log2_weight_denom = 0;
-}
+luma_def = 1 << pwt->luma_log2_weight_denom;
 
-luma_def   = 1 << pwt->luma_log2_weight_denom;
-chroma_def = 1 << pwt->chroma_log2_weight_denom;
+if (sps->chroma_format_idc) {
+pwt->chroma_log2_weight_denom = get_ue_golomb(gb);
+if (pwt->chroma_log2_weight_denom > 7U) {
+av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out 
of range\n", pwt->chroma_log2_weight_denom);
+pwt->chroma_log2_weight_denom = 0;
+}
+chroma_def = 1 << pwt->chroma_log2_weight_denom;
+}
 
 for (list = 0; list < 2; list++) {
 pwt->luma_weight_flag[list]   = 0;
@@ -102,9 +103,11 @@ int ff_h264_pred_weight_table(GetBitContext *gb, const SPS 
*sps,
 if (picture_structure == PICT_FRAME) {
 pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 
2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
 pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 
2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
-for (j = 0; j < 2; j++) {
-pwt->chroma_weight[16 + 2 * i][list][j][0] = 
pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = 
pwt->chroma_weight[i][list][j][0];
-pwt->chroma_weight[16 + 2 * i][list][j][1] = 
pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = 
pwt->chroma_weight[i][list][j][1];
+if (sps->chroma_format_idc) {
+for (j = 0; j < 2; j++) {
+pwt->chroma_weight[16 + 2 * i][list][j][0] = 
pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = 
pwt->chroma_weight[i][list][j][0];
+pwt->chroma_weight[16 + 2 * i][list][j][1] = 
pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = 
pwt->chroma_weight[i][list][j][1];
+}
 }
 }
 }
-- 
2.14.1.581.gf28d330327-goog

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


Re: [FFmpeg-devel] [PATCH] libavcodec/h264_parse: don't use uninitialized value when chroma_format_idc==0

2017-09-07 Thread Mark Wachsler
I have updated my patch to also fix the references to chroma_weight in the
MBAFF case, as suggested by Mark Thompson, but without erroring out on
invalid values.

On Thu, Sep 7, 2017 at 9:42 AM, Mark Wachsler  wrote:

> When parsing a monochrome file, chroma_log2_weight_denom was used without
> being initialized, which could lead to a bogus error message being
> printed, e.g.
>   [h264 @ 0x61a26480] chroma_log2_weight_denom 24576 is out of range
> It also could led to warnings using AddressSanitizer.
> ---
>  libavcodec/h264_parse.c | 27 +++
>  1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> index 3d20075f6a..a7c71d9bbb 100644
> --- a/libavcodec/h264_parse.c
> +++ b/libavcodec/h264_parse.c
> @@ -34,21 +34,22 @@ int ff_h264_pred_weight_table(GetBitContext *gb,
> const SPS *sps,
>
>  pwt->use_weight = 0;
>  pwt->use_weight_chroma  = 0;
> -pwt->luma_log2_weight_denom = get_ue_golomb(gb);
> -if (sps->chroma_format_idc)
> -pwt->chroma_log2_weight_denom = get_ue_golomb(gb);
>
> +pwt->luma_log2_weight_denom = get_ue_golomb(gb);
>  if (pwt->luma_log2_weight_denom > 7U) {
>  av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of
> range\n", pwt->luma_log2_weight_denom);
>  pwt->luma_log2_weight_denom = 0;
>  }
> -if (pwt->chroma_log2_weight_denom > 7U) {
> -av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out
> of range\n", pwt->chroma_log2_weight_denom);
> -pwt->chroma_log2_weight_denom = 0;
> -}
> +luma_def = 1 << pwt->luma_log2_weight_denom;
>
> -luma_def   = 1 << pwt->luma_log2_weight_denom;
> -chroma_def = 1 << pwt->chroma_log2_weight_denom;
> +if (sps->chroma_format_idc) {
> +pwt->chroma_log2_weight_denom = get_ue_golomb(gb);
> +if (pwt->chroma_log2_weight_denom > 7U) {
> +av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is
> out of range\n", pwt->chroma_log2_weight_denom);
> +pwt->chroma_log2_weight_denom = 0;
> +}
> +chroma_def = 1 << pwt->chroma_log2_weight_denom;
> +}
>
>  for (list = 0; list < 2; list++) {
>  pwt->luma_weight_flag[list]   = 0;
> @@ -102,9 +103,11 @@ int ff_h264_pred_weight_table(GetBitContext *gb,
> const SPS *sps,
>  if (picture_structure == PICT_FRAME) {
>  pwt->luma_weight[16 + 2 * i][list][0] =
> pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
>  pwt->luma_weight[16 + 2 * i][list][1] =
> pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
> -for (j = 0; j < 2; j++) {
> -pwt->chroma_weight[16 + 2 * i][list][j][0] =
> pwt->chroma_weight[16 + 2 * i + 1][list][j][0] =
> pwt->chroma_weight[i][list][j][0];
> -pwt->chroma_weight[16 + 2 * i][list][j][1] =
> pwt->chroma_weight[16 + 2 * i + 1][list][j][1] =
> pwt->chroma_weight[i][list][j][1];
> +if (sps->chroma_format_idc) {
> +for (j = 0; j < 2; j++) {
> +pwt->chroma_weight[16 + 2 * i][list][j][0] =
> pwt->chroma_weight[16 + 2 * i + 1][list][j][0] =
> pwt->chroma_weight[i][list][j][0];
> +pwt->chroma_weight[16 + 2 * i][list][j][1] =
> pwt->chroma_weight[16 + 2 * i + 1][list][j][1] =
> pwt->chroma_weight[i][list][j][1];
> +}
>  }
>  }
>  }
> --
> 2.14.1.581.gf28d330327-goog
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] lavu/timer.h: add Linux Perf API support

2017-09-07 Thread Clément Bœsch
On Sun, Sep 03, 2017 at 08:30:24PM +0200, Michael Niedermayer wrote:
> On Sat, Sep 02, 2017 at 08:17:40PM +0200, Clément Bœsch wrote:
> > From: Clément Bœsch 
> > 
> > Refer to "checkasm: use perf API on Linux ARM*" commit for the
> > rationale.
> > 
> > The implementation is somehow duplicated with checkasm, but so is the
> > current usage of AV_READ_TIME(). Until these implementations and
> > heuristics are made consistent, I don't see a way of sharing that code.
> > 
> > Note: when using libavutil/timer.h, it is now important to include
> > before any other include due to the _GNU_SOURCE requirement.
> > ---
> >  libavutil/timer.h | 46 +++---
> >  1 file changed, 43 insertions(+), 3 deletions(-)
> 
> this breaks building   testprogs on qemu arm:
> 
> src/libavutil/tests/base64.c: In function ‘main’:
> src/libavutil/tests/base64.c:105:159: error: implicit declaration of function 
> ‘syscall’ [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
> make: *** [libavutil/tests/base64.o] Error 1
> make: *** Waiting for unfinished jobs
> src/libavutil/tests/adler32.c: In function ‘main’:
> src/libavutil/tests/adler32.c:42:159: error: implicit declaration of function 
> ‘syscall’ [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
> make: *** [libavutil/tests/adler32.o] Error 1
> src/libavutil/tests/aes.c: In function ‘main’:
> src/libavutil/tests/aes.c:94:163: error: implicit declaration of function 
> ‘syscall’ [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
> make: *** [libavutil/tests/aes.o] Error 1
> src/libavformat/utils.c: In function 
> ‘avformat_transfer_internal_stream_timing_info’:
> src/libavformat/utils.c:5537:5: warning: ‘codec’ is deprecated (declared at 
> src/libavformat/avformat.h:893) [-Wdeprecated-declarations]
> src/libavformat/utils.c:5538:5: warning: ‘codec’ is deprecated (declared at 
> src/libavformat/avformat.h:893) [-Wdeprecated-declarations]
> 

Fixed in my branch (https://github.com/ubitux/FFmpeg/compare/perf)

Also attaching to this mail the two patches fixing this.

Thanks.

-- 
Clément B.
From 110a9025bdcb96f498a8c9728ff2b7de15f7a990 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 
Date: Thu, 7 Sep 2017 15:56:56 +0200
Subject: [PATCH 3/5] lavu/tests/des: rename crypt to crypt_ref

This will prevent a symbol clash with crypt(3) after unistd.h is
included.
---
 libavutil/tests/des.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/tests/des.c b/libavutil/tests/des.c
index 309be29473..eac33d47d4 100644
--- a/libavutil/tests/des.c
+++ b/libavutil/tests/des.c
@@ -34,7 +34,7 @@ static uint64_t rand64(void)
 
 static const uint8_t test_key[] = { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 };
 static const DECLARE_ALIGNED(8, uint8_t, plain)[] = { 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10 };
-static const DECLARE_ALIGNED(8, uint8_t, crypt)[] = { 0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18 };
+static const DECLARE_ALIGNED(8, uint8_t, crypt_ref)[] = { 0x4a, 0xb6, 0x5b, 0x3d, 0x4b, 0x06, 0x15, 0x18 };
 static DECLARE_ALIGNED(8, uint8_t, tmp)[8];
 static DECLARE_ALIGNED(8, uint8_t, large_buffer)[10002][8];
 static const uint8_t cbc_key[] = {
@@ -82,13 +82,13 @@ int main(void)
 key[0].word = AV_RB64(test_key);
 data.word   = AV_RB64(plain);
 gen_roundkeys(roundkeys, key[0].word);
-if (des_encdec(data.word, roundkeys, 0) != AV_RB64(crypt)) {
+if (des_encdec(data.word, roundkeys, 0) != AV_RB64(crypt_ref)) {
 printf("Test 1 failed\n");
 return 1;
 }
 av_des_init(&d, test_key, 64, 0);
 av_des_crypt(&d, tmp, plain, 1, NULL, 0);
-if (memcmp(tmp, crypt, sizeof(crypt))) {
+if (memcmp(tmp, crypt_ref, sizeof(crypt_ref))) {
 printf("Public API decryption failed\n");
 return 1;
 }
-- 
2.14.1

From c5173492fecd1badafdd959987e996f5ca5d64c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 
Date: Thu, 7 Sep 2017 15:52:47 +0200
Subject: [PATCH 4/5] lavu/tests: move timer.h include earlier

In the next commit, timer.h will require a _GNU_SOURCE to be set before
including system headers. This commit prevents compilation failures.
---
 libavutil/tests/adler32.c   | 4 +++-
 libavutil/tests/aes.c   | 3 +++
 libavutil/tests/base64.c| 4 +++-
 libavutil/tests/des.c   | 2 ++
 libavutil/tests/eval.c  | 3 ++-
 libavutil/tests/softfloat.c | 2 ++
 6 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/libavutil/tests/adler32.c b/libavutil/tests/adler32.c
index 511bf1e401..13f760b477 100644
--- a/libavutil/tests/adler32.c
+++ b/libavutil/tests/adler32.c
@@ -17,10 +17,12 @@
  */
 
 // LCOV_EXCL_START
+
+#include "libavutil/timer.h"
+
 #include 
 
 #include "libavutil/log.h"
-#include "libavutil/timer.h"
 #include "libavutil/adler32.h"
 
 #define LEN 7001
diff --git a/libavutil/tests/aes.c b/libavut

Re: [FFmpeg-devel] [PATCH 1/7] build: fix objcc header check

2017-09-07 Thread Clément Bœsch
On Wed, Sep 06, 2017 at 10:05:40PM +0200, Thilo Borgmann wrote:
> Hi,
> 
> Am 06.09.17 um 11:58 schrieb Clément Bœsch:
> > From: Clément Bœsch 
> > 
> > $headers is a variable set in the context of other functions (we don't
> > use the "local" keyword in our scripts, so those variables are global).
> > 
> > Currently, when checking for AVFoundation/AVFoundation.h, the actual
> > enabled header is math.h.
> > 
> > Similarly, when testing for QuartzCore/CoreImage.h, the actual enabled
> > header is CoreGraphics/CoreGraphics.h.
> > 
> > This is completely broken and may be the reason why these checks are
> > made in random places.
> 
> thus it was just a typo like the patch 1 suggested?
> 

What do you mean by "like the patch 1 suggested"? This is the patch 1.
And yeah, I guess it's a typo from day 1 (a2c6a99ba5). I didn't check if
the code was valid back then thanks to a side effect (basically if
check_cc was setting headers=$1 somewhere), but it's definitely broken
currently.

> Patch 1-5 ok!
> For patch 6-7 maybe someone else can have a closer look.

I'll wait a little more and push the patchset.

Thanks

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH]lavf/supenc: Add a raw PGS muxer

2017-09-07 Thread wm4
On Thu, 7 Sep 2017 15:32:58 +0200
Carl Eugen Hoyos  wrote:

> Hi!
> 
> Attached patch implements ticket #2208.
> 
> Please comment, Carl Eugen

Probably worse than:

 From: phint...@gmail.com
 To: ffmpeg-devel@ffmpeg.org
 Cc: Petri Hintukainen 
 Subject: [FFmpeg-devel] [PATCH v2] Add SUP/PGS subtitle muxer
 Date: Tue, 30 Sep 2014 11:01:17 +0300
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/supenc: Add a raw PGS muxer

2017-09-07 Thread Carl Eugen Hoyos
2017-09-07 16:14 GMT+02:00 wm4 :
> On Thu, 7 Sep 2017 15:32:58 +0200
> Carl Eugen Hoyos  wrote:
>
>> Hi!
>>
>> Attached patch implements ticket #2208.
>>
>> Please comment, Carl Eugen
>
> Probably worse than:

Looks similar except for working with mkv input and a useless cast.

>  From: phint...@gmail.com
>  To: ffmpeg-devel@ffmpeg.org
>  Cc: Petri Hintukainen 
>  Subject: [FFmpeg-devel] [PATCH v2] Add SUP/PGS subtitle muxer
>  Date: Tue, 30 Sep 2014 11:01:17 +0300

You reviewed it but sadly, you forgot to push.

Please mention ticket #2208 in the commit message.

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


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Signed-off-by: Nicolas George 
> ---
>  libavfilter/vf_zoompan.c | 36 +---
>  1 file changed, 9 insertions(+), 27 deletions(-)
>
>
> I do not have the faintest idea what the output of this filter is supposed
> to look like, so testing is limited. But at least now it outputs something.

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


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> > I do not have the faintest idea what the output of this filter is supposed
> > to look like, so testing is limited. But at least now it outputs something.
> Breaks duration expression.

I do not see how it could be, as the filter currently does not work at
all.

If you cannot be convinced to be less terse, I will not touch it again,
please fix it yourself.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Le primidi 21 fructidor, an CCXXV, Paul B Mahol a ecrit :
>> > I do not have the faintest idea what the output of this filter is
>> > supposed
>> > to look like, so testing is limited. But at least now it outputs
>> > something.
>> Breaks duration expression.
>
> I do not see how it could be, as the filter currently does not work at
> all.

Works here, you will need to be more verbose.

>
> If you cannot be convinced to be less terse, I will not touch it again,
> please fix it yourself.

Duration expressions says by how much frames filter will spend on
zooming current
input frame.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> Works here, you will need to be more verbose.

./ffmpeg_g -lavfi testsrc2,zoompan -f framecrc -

begs to differ.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Le primidi 21 fructidor, an CCXXV, Paul B Mahol a ecrit :
>> Works here, you will need to be more verbose.
>
> ./ffmpeg_g -lavfi testsrc2,zoompan -f framecrc -

Lavd bug. Normal -vf approach works.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/8] lavfi/vf_zoompan: fix scheduling logic.

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> > ./ffmpeg_g -lavfi testsrc2,zoompan -f framecrc -
> Lavd bug.

Read again, this is not using lavd at all. And it should work. The fact
that it does not is definitely a zoompan bug.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> ffmpeg | branch: master | Paul B Mahol  | Thu Sep  7 
> 16:49:46 2017 +0200| [e1524de4546beab75cbf600fdde6c14204a66059] | committer: 
> Paul B Mahol
> 
> avfilter/vf_zoompan: fix specific corner case when no frame was ever 
> requested from input
> 
> Reported-by: Nicolas George
> Signed-off-by: Paul B Mahol 

I am sorry, but it does not fix anything. The logic of the activate()
callback is still completely bogus and non-conforming to what it should
be.

I could help you fix it, but apparently you are not interested.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Le primidi 21 fructidor, an CCXXV, Paul B Mahol a ecrit :
>> ffmpeg | branch: master | Paul B Mahol  | Thu Sep  7
>> 16:49:46 2017 +0200| [e1524de4546beab75cbf600fdde6c14204a66059] |
>> committer: Paul B Mahol
>>
>> avfilter/vf_zoompan: fix specific corner case when no frame was ever
>> requested from input
>>
>> Reported-by: Nicolas George
>> Signed-off-by: Paul B Mahol 
>
> I am sorry, but it does not fix anything. The logic of the activate()
> callback is still completely bogus and non-conforming to what it should
> be.

What it should be?

>
> I could help you fix it, but apparently you are not interested.

I'm interested in everyone's opinion.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avformat/mxfdec: use the common packet pts setter function for opatom files

2017-09-07 Thread Marton Balint
Fixes ticket #6631.

Signed-off-by: Marton Balint 
---
 libavformat/mxfdec.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3e2f5011ee..476d284c96 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3217,15 +3217,9 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 pkt->stream_index = st->index;
 
-if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
-mxf->current_edit_unit >= 0 && mxf->current_edit_unit < t->nb_ptses) {
-pkt->dts = mxf->current_edit_unit + t->first_dts;
-pkt->pts = t->ptses[mxf->current_edit_unit];
-} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-int ret = mxf_set_audio_pts(mxf, st->codecpar, pkt);
-if (ret < 0)
-return ret;
-}
+ret = mxf_set_pts(mxf, st, pkt, next_pos);
+if (ret < 0)
+return ret;
 
 mxf->current_edit_unit += edit_units;
 
-- 
2.13.5

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


[FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: factorize packet pts setter function

2017-09-07 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/mxfdec.c | 52 +---
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 91731a7533..3e2f5011ee 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -3060,6 +3060,32 @@ static int mxf_set_audio_pts(MXFContext *mxf, 
AVCodecParameters *par,
 return 0;
 }
 
+static int mxf_set_pts(MXFContext *mxf, AVStream *st, AVPacket *pkt, int64_t 
next_ofs)
+{
+AVCodecParameters *par = st->codecpar;
+MXFTrack *track = st->priv_data;
+
+if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+/* mxf->current_edit_unit good - see if we have an
+ * index table to derive timestamps from */
+MXFIndexTable *t = &mxf->index_tables[0];
+
+if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) 
{
+pkt->dts = mxf->current_edit_unit + t->first_dts;
+pkt->pts = t->ptses[mxf->current_edit_unit];
+} else if (track && track->intra_only) {
+/* intra-only -> PTS = EditUnit.
+ * let utils.c figure out DTS since it can be < PTS if low_delay = 
0 (Sony IMX30) */
+pkt->pts = mxf->current_edit_unit;
+}
+} else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
+int ret = mxf_set_audio_pts(mxf, par, pkt);
+if (ret < 0)
+return ret;
+}
+return 0;
+}
+
 static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
 {
 KLVPacket klv;
@@ -3083,8 +3109,6 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 int index = mxf_get_stream_index(s, &klv);
 int64_t next_ofs, next_klv;
 AVStream *st;
-MXFTrack *track;
-AVCodecParameters *par;
 
 if (index < 0) {
 av_log(s, AV_LOG_ERROR,
@@ -3094,7 +3118,6 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 }
 
 st = s->streams[index];
-track = st->priv_data;
 
 if (s->streams[index]->discard == AVDISCARD_ALL)
 goto skip;
@@ -3129,26 +3152,9 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 pkt->stream_index = index;
 pkt->pos = klv.offset;
 
-par = st->codecpar;
-
-if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
-/* mxf->current_edit_unit good - see if we have an
- * index table to derive timestamps from */
-MXFIndexTable *t = &mxf->index_tables[0];
-
-if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < 
t->nb_ptses) {
-pkt->dts = mxf->current_edit_unit + t->first_dts;
-pkt->pts = t->ptses[mxf->current_edit_unit];
-} else if (track && track->intra_only) {
-/* intra-only -> PTS = EditUnit.
- * let utils.c figure out DTS since it can be < PTS if 
low_delay = 0 (Sony IMX30) */
-pkt->pts = mxf->current_edit_unit;
-}
-} else if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
-ret = mxf_set_audio_pts(mxf, par, pkt);
-if (ret < 0)
-return ret;
-}
+ret = mxf_set_pts(mxf, st, pkt, next_ofs);
+if (ret < 0)
+return ret;
 
 /* seek for truncated packets */
 avio_seek(s->pb, next_klv, SEEK_SET);
-- 
2.13.5

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> What it should be?

It should look like it does look after this patch. Maybe the change
breaks something I did not notice, but the general logic should be what
I wrote.

The things that are wrong in the current state of code: checking
ff_outlink_frame_wanted(), duplication of the output_single_frame() call
block, impossible condition about ret < 0, duplicate semantic of the
"finished" variable, useless conditions that mask the logic of the flow.

Could you show an actual example that works with your current version
and that does not work with the modified code?

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Le primidi 21 fructidor, an CCXXV, Paul B Mahol a ecrit :
>> What it should be?
>
> It should look like it does look after this patch. Maybe the change
> breaks something I did not notice, but the general logic should be what
> I wrote.
>
> The things that are wrong in the current state of code: checking
> ff_outlink_frame_wanted(), duplication of the output_single_frame() call
> block, impossible condition about ret < 0, duplicate semantic of the
> "finished" variable, useless conditions that mask the logic of the flow.
>
> Could you show an actual example that works with your current version
> and that does not work with the modified code?

Take single image as input, and example as listed in documentation of zoompan:

zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> Take single image as input, and example as listed in documentation of zoompan:
> 
> zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'

I am sorry but I have better use of my time than debugging this filter.
So please, if you want any help about it, give me a complete, exact and
minimal command-line that I can use, and describe precisely what I am
supposed to observe both in the case where it works and in the case
where it does not.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Paul B Mahol
On 9/7/17, Nicolas George  wrote:
> Le primidi 21 fructidor, an CCXXV, Paul B Mahol a ecrit :
>> Take single image as input, and example as listed in documentation of
>> zoompan:
>>
>> zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'
>
> I am sorry but I have better use of my time than debugging this filter.
> So please, if you want any help about it, give me a complete, exact and
> minimal command-line that I can use, and describe precisely what I am
> supposed to observe both in the case where it works and in the case
> where it does not.

ffmpeg -lavfi 
"testsrc2,trim=end_frame=1,zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'"
-f framecrc -

Should output 700 frames and not 1 frame.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_zoompan: fix specific corner case when no frame was ever requested from input

2017-09-07 Thread Nicolas George
Le primidi 21 fructidor, an CCXXV, Paul B Mahol a écrit :
> ffmpeg -lavfi 
> "testsrc2,trim=end_frame=1,zoompan=z='min(zoom+0.0015,1.5)':d=700:x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'"
> -f framecrc -
> 
> Should output 700 frames and not 1 frame.

It does. So my patch is valid. Will push soon unless I see a complete
console output proving it is not.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] lavd: implement threaded NewTek NDI output

2017-09-07 Thread Maksym Veremeyenko

05.09.2017 23:50, Marton Balint пише:
[...]
If I get this correctly, this patch is needed because you can only 
schedule 1 frame to the NDI API, therefore especially for shorter audio 
frames the buffer may underrun, right?. If that is the case, then I'd 
describe this in a bit more detail in the docs and/or the commit message.


this patch was needed to make an audio play smooth. sometimes i notices 
some audio issue with /reference monitoring tool/ - so it is rather 
research purpose to find a proper way.


if i specify 16 packets queue and use two queues i got video/audio 
unsync (all monitoring performed by *Studio Monitor* software).


*perfectly* working was reached by audio queue for two packets 
(previously processed by *asetnsamples* filter) and no-threads for video.


then i say about audio issue i mean that i *hear* by NDI software but 
not a logged output of reference analizer - i have only visual/cosumer 
method for estimating quality of audio/video packets sending...


Also, decklink uses a concept called preroll for a similar purpose, it 
is specified in time, and the video buffer is capable of storing 
preroll*2 amount of video. (Also, at the start of the stream the code 
only starts draining the buffer after preroll amount of video is 
received, there comes the name, preroll. This way the buffer won't 
underrun even at the start of the stream).
decklink has driver's DMAed memory for prerolled frame and decklink 
internally align audio/video samples to make it synchronous... so it 
hard to compare with hardware driven device.


I just mentioned this because you may want to support a similar concept, 
or specify buffer sizes in time, instead of in frames. But if not, that 
is fine as well.

queues is in a packet count units - AVPacket been queued.



As for the actual code - I see a lot of code duplications :), maybe you 
can factorize audio_thread and video_thread to use the same function, 
and also the code which creates these threads.

if it does not decrease code reading quality i can do that easy



But in general the code looks fine.

thanks

--
Maksym Veremeyenko

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


Re: [FFmpeg-devel] [PATCH] lavd: implement threaded NewTek NDI output

2017-09-07 Thread Maksym Veremeyenko

06.09.2017 11:42, Marton Balint пише:
[...]
I've given this some more thought, and this only makes sense if NDI is 
throttling the output (e.g via clock_audio or clock_video). If not, then 
using threads should not make any difference, so something different 
might be going on. Do you have an idea what?


clock_audio or clock_video do exactly what you mean - it prevent sending 
more packets then realtime.


in my case clock_audio=1, clock_video=1, video_queue=2, audio_queue=2 
gives very smooth result. extending queue size make monitoring software 
unsync output...


--
Maksym Veremeyenko

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


Re: [FFmpeg-devel] [PATCH v23 1/2] avformat/dashdec: add dash demuxer base version

2017-09-07 Thread Steven Liu
2017-09-05 17:36 GMT+08:00 Steven Liu :
> 2017-09-01 18:26 GMT+08:00 Steven Liu :
>> ffmpeg need a dash demuxer for demux the dash formats base on
>> https://github.com/samsamsam-iptvplayer/exteplayer3/blob/master/tmp/ffmpeg/patches/3.2.2/01_add_dash_demux.patch
>>
>> TODO:
>> 1. support multi bitrate dash.
>>
>> v2 fixed:
>> 1. from autodetect to disabled
>> 2. from camelCase code style to ffmpeg code style
>> 3. from RepType to AVMediaType
>> 4. fix variable typo
>> 5. change time value from uint32_t to uint64_t
>> 6. removed be used once API
>> 7. change 'time(NULL)`, except it is not 2038-safe.' to av_gettime and 
>> av_timegm
>> 8. merge complex free operation to free_fragment
>> 9. use API from snprintf to av_asprintf
>>
>> v3 fixed:
>> 1. fix typo from --enabled-xml2 to --enable-xml2
>>
>> v4 fixed:
>> 1. from --enable-xml2 to --enable-libxml2
>> 2. move system includes to top
>> 3. remove nouse includes
>> 4. rename enum name
>> 5. add a trailing comma for the last entry enum
>> 6. fix comment typo
>> 7. add const to DASHContext class front
>> 8. check sscanf if return arguments and give warning message when error
>> 9. check validity before free seg->url and seg
>> 10. check if the val is null, before use atoll
>>
>> v5 fixed:
>> 1. fix typo from mainifest to manifest
>>
>> v6 fixed:
>> 1. from realloc to av_realloc
>> 2. from free to av_free
>>
>> v7 fixed:
>> 1. remove the -lxml2 from configure when require_pkg_config
>>
>> v8 fixed:
>> 1. fix replace filename template by av_asprintf secure problem
>>
>> v9 modified:
>> 1. make manifest parser clearly
>>
>> v10 fixed:
>> 1. fix function API name code style
>> 2. remove redundant strreplace call
>> 3. remove redundant memory operation and check return value from 
>> get_content_url()
>> 4. add space between ) and {
>> 5. remove no need to log the value for print
>>
>> v11 fixed:
>> 1. from atoll to strtoll
>> Suggested-by: Michael Niedermayer 
>>
>> v12 fixed:
>> 1. remove strreplace and instead by av_strreplace
>> Suggested-by: Nicolas George 
>>
>> v13 fixed:
>> 1. fix bug: cannot play:
>> http://dash.edgesuite.net/akamai/bbb_30fps/bbb_30fps.mpd
>> Reported-by: Andy Furniss 
>>
>> v14 fixed:
>> 1. fix bug: TLS connection was non-properly terminated
>> 2. fix bug: No trailing CRLF found in HTTP header
>> Reported-by: Andy Furniss 
>>
>> v15 fixed:
>> 1. play youtube link: ffmpeg -i $(youtube-dl -J 
>> "https://www.youtube.com/watch?v=XmL19DOP_Ls"; | jq -r 
>> ".requested_formats[0].manifest_url")
>> 2. code refine for timeline living stream
>> Reported-by: Ricardo Constantino 
>>
>> v16 fixed:
>> 1. remove the snprintf and instead by get_segment_filename make safety
>> 2. remove unnecessary loops
>> 3. updated xmlStrcmp and xmlFree to av_* functions
>> 4. merge code repeat into one function
>> 5. add memory alloc faild check
>> 6. update update_init_section and open_url
>> 7. output safety error message when filename template not safe
>> Suggested-by : wm4 
>>
>> v17 fixed:
>> 1. add memory alloc faild check
>> 2. fix resource space error at free_representation
>>
>> v18 fixed:
>> 1. add condition of template format
>>
>> v19 fixed:
>> 1. fix typo of the option describe
>>
>> v20 fixed:
>> 1. add the c->base_url alloc check
>> 2. make the DASHTmplId same to dashenc
>>
>> v21 fixed:
>> 1. remove get_repl_pattern_and_format and get_segment_filename
>> 2. process use dashcomm APIs
>>
>> v22 fixed:
>> 1. modify the include "dashcomm.h" to include "dash.h"
>> 2. use internal API from dash_fill_tmpl_params to ff_dash_fill_tmpl_params
>>
>> Signed-off-by: Steven Liu 
>> Signed-off-by: samsamsam 
>> ---
>>  configure|4 +
>>  libavformat/Makefile |1 +
>>  libavformat/allformats.c |2 +-
>>  libavformat/dashdec.c| 1848 
>> ++
>>  4 files changed, 1854 insertions(+), 1 deletion(-)
>>  create mode 100644 libavformat/dashdec.c
>>
>> diff --git a/configure b/configure
>> index 4f1c172333..3f0d05a6f9 100755
>> --- a/configure
>> +++ b/configure
>> @@ -272,6 +272,7 @@ External library support:
>>--enable-libxcb-shapeenable X11 grabbing shape rendering [autodetect]
>>--enable-libxvid enable Xvid encoding via xvidcore,
>> native MPEG-4/Xvid encoder exists [no]
>> +  --enable-libxml2 enable XML parsing using the C library libxml2 
>> [no]
>>--enable-libzimg enable z.lib, needed for zscale filter [no]
>>--enable-libzmq  enable message passing via libzmq [no]
>>--enable-libzvbi enable teletext support via libzvbi [no]
>> @@ -1578,6 +1579,7 @@ EXTERNAL_LIBRARY_LIST="
>>  libvpx
>>  libwavpack
>>  libwebp
>> +libxml2
>>  libzimg
>>  libzmq
>>  libzvbi
>> @@ -2939,6 +2941,7 @@ avi_muxer_select="riffenc"
>>  caf_demuxer_select="iso_media riffdec"
>>  caf_muxer_select="iso_media"
>>  dash_muxer_select="mp4_muxer"
>> +dash_demuxer_deps="libxml2"
>>  dirac_demuxer_select="d

Re: [FFmpeg-devel] [PATCH 1/4] avdevice/decklink_dec: Added VANC search for all resolutions

2017-09-07 Thread Marton Balint


On Tue, 5 Sep 2017, Jeyapal, Karthick wrote:



Overlooked a “signed vs unsigned comparison” compilation warning in the 
previous patch. Sorry about that. Please use this updated patch(attached) for 
review.


Thanks, I think it is better if we parse all lines after the line 
affected by switching, so I am suggesting these start lines:


480i: 11.. , 274..
480p: 11..
576i: 7.., 320..
576p: 7..
720p: 8..
1080i: 8.., 570..
1080p: 8..

Also there is a condition in the code:

+if (i == vanc_line_numbers[idx].field0_vanc_end)
+i = vanc_line_numbers[idx].field1_vanc_start;

I think 'i' should be field1_vanc_start - 1, because the loop will 
increase the value of i.


Otherwise the patch looks good.

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


[FFmpeg-devel] [PATCH 2/2] avcodec/pthread_slice: add main function support for avpriv_slicethread_create()

2017-09-07 Thread Ilia Valiakhmetov
---
 libavcodec/internal.h  |  4 
 libavcodec/pthread_slice.c | 33 ++---
 libavcodec/thread.h|  1 +
 libavutil/slicethread.h| 18 ++
 4 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 64120ea..4668952 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -64,6 +64,10 @@
  * dimensions to coded rather than display values.
  */
 #define FF_CODEC_CAP_EXPORTS_CROPPING   (1 << 4)
+/**
+ * Codec initializes slice-based threading with a main function
+ */
+#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF(1 << 5)
 
 #ifdef TRACE
 #   define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index c781d35..65e5abf 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -38,21 +38,13 @@
 
 typedef int (action_func)(AVCodecContext *c, void *arg);
 typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int 
threadnr);
+typedef int (main_func)(AVCodecContext *c);
 
-typedef struct SliceThreadContext {
-AVSliceThread *thread;
-action_func *func;
-action_func2 *func2;
-void *args;
-int *rets;
-int job_size;
-
-int *entries;
-int entries_count;
-int thread_count;
-pthread_cond_t *progress_cond;
-pthread_mutex_t *progress_mutex;
-} SliceThreadContext;
+static void main_function(void *priv) {
+AVCodecContext *avctx = priv;
+SliceThreadContext *c = avctx->internal->thread_ctx;
+c->m_func(avctx);
+}
 
 static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int 
nb_threads)
 {
@@ -84,7 +76,7 @@ void ff_slice_thread_free(AVCodecContext *avctx)
 av_freep(&avctx->internal->thread_ctx);
 }
 
-static int thread_execute(AVCodecContext *avctx, action_func* func, void *arg, 
int *ret, int job_count, int job_size)
+int ff_thread_execute(AVCodecContext *avctx, action_func* func, void *arg, int 
*ret, int job_count, int job_size)
 {
 SliceThreadContext *c = avctx->internal->thread_ctx;
 
@@ -99,7 +91,7 @@ static int thread_execute(AVCodecContext *avctx, action_func* 
func, void *arg, i
 c->func = func;
 c->rets = ret;
 
-avpriv_slicethread_execute(c->thread, job_count, 0);
+avpriv_slicethread_execute(c->thread, job_count, !!c->m_func);
 return 0;
 }
 
@@ -107,13 +99,14 @@ static int thread_execute2(AVCodecContext *avctx, 
action_func2* func2, void *arg
 {
 SliceThreadContext *c = avctx->internal->thread_ctx;
 c->func2 = func2;
-return thread_execute(avctx, NULL, arg, ret, job_count, 0);
+return ff_thread_execute(avctx, NULL, arg, ret, job_count, 0);
 }
 
 int ff_slice_thread_init(AVCodecContext *avctx)
 {
 SliceThreadContext *c;
 int thread_count = avctx->thread_count;
+static void (*main_f)(void *);
 
 #if HAVE_W32THREADS
 w32thread_init();
@@ -142,7 +135,8 @@ int ff_slice_thread_init(AVCodecContext *avctx)
 }
 
 avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c));
-if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, 
worker_func, NULL, thread_count)) <= 1) {
+main_f = avctx->codec->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF ? 
&main_function : NULL;
+if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, 
worker_func, main_f, thread_count)) <= 1) {
 if (c)
 avpriv_slicethread_free(&c->thread);
 av_freep(&avctx->internal->thread_ctx);
@@ -150,9 +144,10 @@ int ff_slice_thread_init(AVCodecContext *avctx)
 avctx->active_thread_type = 0;
 return 0;
 }
+c->m_func = NULL;
 avctx->thread_count = thread_count;
 
-avctx->execute = thread_execute;
+avctx->execute = ff_thread_execute;
 avctx->execute2 = thread_execute2;
 return 0;
 }
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 90864b5..dd8f5fe 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -133,6 +133,7 @@ void ff_thread_release_buffer(AVCodecContext *avctx, 
ThreadFrame *f);
 int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src);
 
 int ff_thread_init(AVCodecContext *s);
+int ff_thread_execute(AVCodecContext *avctx, int (*func)(AVCodecContext *c, 
void *arg), void *arg, int *ret, int job_count, int job_size);
 void ff_thread_free(AVCodecContext *s);
 
 int ff_alloc_entries(AVCodecContext *avctx, int count);
diff --git a/libavutil/slicethread.h b/libavutil/slicethread.h
index f6f6f30..9d15c96 100644
--- a/libavutil/slicethread.h
+++ b/libavutil/slicethread.h
@@ -16,11 +16,29 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/avcodec.h"
+
 #ifndef AVUTIL_SLICETHREAD_H
 #define AVUTIL_SLICETHREAD_H
 
 typedef struct AVSliceThread AVSliceThread;
 
+typedef struct SliceThreadContext {
+AVSliceThread *thread;
+int (*func)(AVCodecContext *c, void *arg);
+int (*func2)(AVCodecContex

Re: [FFmpeg-devel] [PATCH] avformat/mux: stop delaying writing the header

2017-09-07 Thread Michael Niedermayer
On Fri, May 26, 2017 at 05:08:51PM -0300, James Almer wrote:
> There's no need to wait for the first packet of every stream now that
> every bitstream filter behaves as intended.
> 
> Signed-off-by: James Almer 
> ---
> What should we do with the AVFMT_FLAG_AUTO_BSF flag? Do we deprecate
> it and force the automatic insertion of muxer-required bitstream
> filters now that the generic muxing code will always behave the same,
> or keep it to give the user a choice to apply said bitstream filters?
> I ask because some filters, like vp9_superframe, are necessary to
> avoid creating broken files, so it's not wise to allow the user to
> disable it.
> It would also go in line with AVCodec.bsfs, which is essentially a
> non-optional (for reasons made obvious in fa1749dd34) autobsf at the
> codec level instead of container level.
> 
> The change to fate-rgb24-mkv is a regression that can be prevented by
> committing https://ffmpeg.org/pipermail/ffmpeg-devel/2017-May/211311.html
> or a similar solution, maybe using avformat_init_output(), to make sure
> ffmpeg.c sets AVCodecParameters->field_order for the output stream before
> calling avformat_write_header().
> 
>  libavformat/internal.h |  6 -
>  libavformat/mux.c  | 53 
> +-
>  libavformat/options_table.h|  2 +-
>  libavformat/tests/fifo_muxer.c | 52 -
>  tests/ref/fate/fifo-muxer-tst  |  1 -
>  tests/ref/fate/rgb24-mkv   |  4 ++--
>  6 files changed, 14 insertions(+), 104 deletions(-)

seems not to apply cleanly, so i cannot test it

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

No great genius has ever existed without some touch of madness. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH] vf_fps: uses the last frame duration to duplicate it if needed

2017-09-07 Thread Thierry Foucu
Hi Nicolas,

On Wed, Sep 6, 2017 at 2:07 PM, Nicolas George  wrote:

> Le decadi 20 fructidor, an CCXXV, Thierry Foucu a écrit :
> > ---
> >  libavfilter/vf_fps.c| 40 ++
> +-
> >  tests/ref/fate/filter-fps   |  6 ++
> >  tests/ref/fate/filter-fps-r |  4 
> >  3 files changed, 45 insertions(+), 5 deletions(-)
>
> Already explained: no, pkt_duration is not part of the information taken
> into account by libavfilter. The correct way of obtaining the end
> timestamp is to use the link's timestamp after EOF. There is an old
> patch series to ensure it is accurate, but it has been delayed by
> bikeshedding.
>
>
Sorry I did not know and I did not see any documentation in the header
explaining which field of the AVFrame can/cannot be used by filter.

If we cannot used the duration of the AVframe, how can we resolve the
problem I'm trying to resolve.
For example, if you take a video with a fps of 1 frame/second and you are
trying to convert it to 30fps, the duration of the output file will be
shorter by 1 second.
Knowing the last frame duration allows us to pad the last video frame with
the correct fps.

You are saying there is an old patch series to ensure it. How far are you
with it?
With the patch you are talking about, will we be able to do what i'm trying
to do with this patch?

Regards.


> Regards,
>
> --
>   Nicolas George
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] vf_fps: uses the last frame duration to duplicate it if needed

2017-09-07 Thread Nicolas George
[ Ccing you, but no need to Cc me. ]

Le primidi 21 fructidor, an CCXXV, Thierry Foucu a écrit :
> Sorry I did not know and I did not see any documentation in the header
> explaining which field of the AVFrame can/cannot be used by filter.

Yes, it lacks documentation.

> If we cannot used the duration of the AVframe, how can we resolve the
> problem I'm trying to resolve.
> For example, if you take a video with a fps of 1 frame/second and you are
> trying to convert it to 30fps, the duration of the output file will be
> shorter by 1 second.
> Knowing the last frame duration allows us to pad the last video frame with
> the correct fps.
> 
> You are saying there is an old patch series to ensure it. How far are you
> with it?
> With the patch you are talking about, will we be able to do what i'm trying
> to do with this patch?

Yes, it is meant exactly for that. The patch series I was referring is
this one:

https://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215988.html
https://patchwork.ffmpeg.org/patch/5024/
(and next)

I thought I had cced you on one of the patches, but it may have been
ignored.

With this patch series, when a filter reaches EOF, the link->current_pts
contains the timestamp of the end, including the duration of the last
frame: from that, you can implement your patch in a very similar way.

(Although vf_fps would need to be rewritten to take advantage of the
link's FIFO, but that is more work, and not required immediately.)

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] avformat/mux: stop delaying writing the header

2017-09-07 Thread James Almer
There's no need to wait for the first packet of every stream now that
every bitstream filter behaves as intended.

Signed-off-by: James Almer 
---
What should we do with the AVFMT_FLAG_AUTO_BSF flag? Do we deprecate
it and force the automatic insertion of muxer-required bitstream
filters now that the generic muxing code will always behave the same,
or keep it to give the user a choice to apply said bitstream filters?
I ask because some filters, like vp9_superframe, are necessary to
avoid creating broken files, so it's not wise to allow the user to
disable it.
It would also go in line with AVCodec.bsfs, which is essentially a
non-optional (for reasons made obvious in fa1749dd34) autobsf at the
codec level instead of container level.

The change to fate-rgb24-mkv is a regression that can be prevented by
committing https://ffmpeg.org/pipermail/ffmpeg-devel/2017-May/211311.html
or a similar solution, maybe using avformat_init_output(), to make sure
ffmpeg.c sets AVCodecParameters->field_order for the output stream before
calling avformat_write_header().

 libavformat/internal.h |  6 -
 libavformat/mux.c  | 51 -
 libavformat/options_table.h|  2 +-
 libavformat/tests/fifo_muxer.c | 52 --
 tests/ref/fate/fifo-muxer-tst  |  1 -
 tests/ref/fate/rgb24-mkv   |  4 ++--
 6 files changed, 13 insertions(+), 103 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index d136c79bdd..d46340029b 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -121,12 +121,6 @@ struct AVFormatInternal {
 int avoid_negative_ts_use_pts;
 
 /**
- * Whether or not a header has already been written
- */
-int header_written;
-int write_header_ret;
-
-/**
  * Timestamp of the end of the shortest stream.
  */
 int64_t shortest_end;
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 53ad46df42..6a81faf3fb 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -478,25 +478,6 @@ static void flush_if_needed(AVFormatContext *s)
 }
 }
 
-static int write_header_internal(AVFormatContext *s)
-{
-if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
-avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
-if (s->oformat->write_header) {
-int ret = s->oformat->write_header(s);
-if (ret >= 0 && s->pb && s->pb->error < 0)
-ret = s->pb->error;
-s->internal->write_header_ret = ret;
-if (ret < 0)
-return ret;
-flush_if_needed(s);
-}
-s->internal->header_written = 1;
-if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
-avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN);
-return 0;
-}
-
 int avformat_init_output(AVFormatContext *s, AVDictionary **options)
 {
 int ret = 0;
@@ -535,11 +516,18 @@ int avformat_write_header(AVFormatContext *s, 
AVDictionary **options)
 if ((ret = avformat_init_output(s, options)) < 0)
 return ret;
 
-if (!(s->oformat->check_bitstream && s->flags & AVFMT_FLAG_AUTO_BSF)) {
-ret = write_header_internal(s);
+if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER);
+if (s->oformat->write_header) {
+int ret = s->oformat->write_header(s);
+if (ret >= 0 && s->pb && s->pb->error < 0)
+ret = s->pb->error;
 if (ret < 0)
 goto fail;
+flush_if_needed(s);
 }
+if (!(s->oformat->flags & AVFMT_NOFILE) && s->pb)
+avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_UNKNOWN);
 
 if (!s->internal->streams_initialized) {
 if ((ret = init_pts(s)) < 0)
@@ -765,12 +753,6 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
-if (!s->internal->header_written) {
-ret = s->internal->write_header_ret ? s->internal->write_header_ret : 
write_header_internal(s);
-if (ret < 0)
-goto fail;
-}
-
 if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
 AVFrame *frame = (AVFrame *)pkt->data;
 av_assert0(pkt->size == UNCODED_FRAME_PACKET_SIZE);
@@ -786,7 +768,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ret = s->pb->error;
 }
 
-fail:
 #if FF_API_LAVF_MERGE_SD
 FF_DISABLE_DEPRECATION_WARNINGS
 if (did_split)
@@ -934,11 +915,6 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt)
 
 if (!pkt) {
 if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
-if (!s->internal->header_written) {
-ret = s->internal->write_header_ret ? 
s->internal->write_header_ret : write_header_internal(s);
-if (ret < 0)
-return ret;
-}
 ret = s->oformat->write_packet(s, NULL);
 flush_if_needed(s);
 if (ret >= 0 && s->pb && s->pb->error < 0)
@@ -1322,14 +1298,8 @@ int av_write_

Re: [FFmpeg-devel] [PATCH] vf_fps: uses the last frame duration to duplicate it if needed

2017-09-07 Thread Thierry Foucu
On Thu, Sep 7, 2017 at 11:37 AM, Nicolas George  wrote:

> [ Ccing you, but no need to Cc me. ]
>
> Le primidi 21 fructidor, an CCXXV, Thierry Foucu a écrit :
> > Sorry I did not know and I did not see any documentation in the header
> > explaining which field of the AVFrame can/cannot be used by filter.
>
> Yes, it lacks documentation.
>
> > If we cannot used the duration of the AVframe, how can we resolve the
> > problem I'm trying to resolve.
> > For example, if you take a video with a fps of 1 frame/second and you are
> > trying to convert it to 30fps, the duration of the output file will be
> > shorter by 1 second.
> > Knowing the last frame duration allows us to pad the last video frame
> with
> > the correct fps.
> >
> > You are saying there is an old patch series to ensure it. How far are you
> > with it?
> > With the patch you are talking about, will we be able to do what i'm
> trying
> > to do with this patch?
>
> Yes, it is meant exactly for that. The patch series I was referring is
> this one:
>
> https://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215988.html
> https://patchwork.ffmpeg.org/patch/5024/
> (and next)
>
> I thought I had cced you on one of the patches, but it may have been
> ignored.
>
>
Thanks Nicolas.


> With this patch series, when a filter reaches EOF, the link->current_pts
> contains the timestamp of the end, including the duration of the last
> frame: from that, you can implement your patch in a very similar way.
>

As soon as your patches landed, I will re-work on my patch and send it to
the list.

>
> (Although vf_fps would need to be rewritten to take advantage of the
> link's FIFO, but that is more work, and not required immediately.)
>

any pointer on this? maybe i can give it a shot as well.

>
> Regards,
>
> --
>   Nicolas George
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/4] avdevice/decklink_dec: Added Closed caption decode from VANC

2017-09-07 Thread Marton Balint


On Tue, 5 Sep 2017, Jeyapal, Karthick wrote:





On 9/3/17, 8:19 PM, "Marton Balint" mailto:c...@passwd.hu>> 
wrote:



Why don't use you simply use uint16_t here as well? I think we typically
try to avoid unsigned as a type.

Done. Changed it to uint16_t.


This VANC parser does not seem right. VANC header can appear multiple
times, you seem to parse only the first DID. Also, you should simply
ignore unknown DID-s, ffmpeg will not be able to parse all types there
are, there is no need to warn.

Thanks for pointing it out. Have handled it now. Also changed the warning log 
to debug log.

Please find the patch attached.


Here are some more comments for the code:

[..]


-static uint8_t* teletext_data_unit_from_vanc_data(uint16_t *py, uint8_t *tgt, 
int64_t wanted_lines)
+uint8_t *vanc_to_cc(AVFormatContext *avctx, uint16_t *buf, size_t words,
+unsigned &cc_count)
 {
-uint16_t *pend = py + 1920;
+size_t len = (buf[5] & 0xff) + 6 + 1;

-while (py < pend - 6) {
-if (py[0] == 0 && py[1] == 0x3ff && py[2] == 0x3ff) {   // 
ancillary data flag
-py += 3;
-tgt = teletext_data_unit_from_ancillary_packet(py, pend, tgt, 
wanted_lines, 0);
-py += py[2] & 255;
+/* CDP follows */
+uint16_t *cdp = &buf[6];


Inline declarations are not allowed in ffmpeg.


+if (cdp[0] != 0x96 || cdp[1] != 0x69) {
+av_log(avctx, AV_LOG_WARNING, "Invalid CDP header 0x%.2x 0x%.2x", 
cdp[0], cdp[1]);
+return NULL;
+}
+
+len -= 7; // remove VANC header and checksum
+
+if (cdp[2] != len) {
+av_log(avctx, AV_LOG_WARNING, "CDP len %d != %zu", cdp[2], len);
+return NULL;
+}
+
+uint8_t cdp_sum = 0;


inline declaration


+for (size_t i = 0; i < len - 1; i++)


inline declaration


+cdp_sum += cdp[i];
+cdp_sum = cdp_sum ? 256 - cdp_sum : 0;
+if (cdp[len - 1] != cdp_sum) {
+av_log(avctx, AV_LOG_WARNING, "CDP checksum invalid 0x%.4x != 0x%.4x", 
cdp_sum, cdp[len-1]);
+return NULL;
+}
+
+uint8_t rate = cdp[3];


inline declaration


+if (!(rate & 0x0f)) {
+av_log(avctx, AV_LOG_WARNING, "CDP frame rate invalid (0x%.2x)", rate);
+return NULL;
+}
+rate >>= 4;
+if (rate > 8) {
+av_log(avctx, AV_LOG_WARNING, "CDP frame rate invalid (0x%.2x)", rate);
+return NULL;
+}
+
+if (!(cdp[4] & 0x43)) /* ccdata_present | caption_service_active | 
reserved */ {
+av_log(avctx, AV_LOG_WARNING, "CDP flags invalid (0x%.2x)", cdp[4]);
+return NULL;
+}
+
+uint16_t hdr = (cdp[5] << 8) | cdp[6];


inline declaration


+if (cdp[7] != 0x72) /* ccdata_id */ {
+av_log(avctx, AV_LOG_WARNING, "Invalid ccdata_id 0x%.2x", cdp[7]);
+return NULL;
+}
+
+cc_count = cdp[8];
+if (!(cc_count & 0xe0)) {
+av_log(avctx, AV_LOG_WARNING, "Invalid cc_count 0x%.2x", cc_count);
+return NULL;
+}
+
+cc_count &= 0x1f;
+if ((len - 13) < cc_count * 3) {
+av_log(avctx, AV_LOG_WARNING, "Invalid cc_count %d (> %zu)", cc_count 
* 3, len - 13);
+return NULL;
+}
+
+if (cdp[len - 4] != 0x74) /* footer id */ {
+av_log(avctx, AV_LOG_WARNING, "Invalid footer id 0x%.2x", cdp[len-4]);
+return NULL;
+}
+
+uint16_t ftr = (cdp[len - 3] << 8) | cdp[len - 2];


inline declaration


+if (ftr != hdr) {
+av_log(avctx, AV_LOG_WARNING, "Header 0x%.4x != Footer 0x%.4x", hdr, 
ftr);
+return NULL;
+}
+
+uint8_t *cc = (uint8_t *)av_malloc(cc_count * 3);


inline declaration
malloc missing error check


+
+for (size_t i = 0; i < cc_count; i++) {


inline declaration


+cc[3*i + 0] = cdp[9 + 3*i+0] /* & 3 */;
+cc[3*i + 1] = cdp[9 + 3*i+1];
+cc[3*i + 2] = cdp[9 + 3*i+2];
+}
+
+cc_count *= 3;
+return cc;
+}
+
+uint8_t *get_metadata(AVFormatContext *avctx, uint16_t *buf, size_t width,
+  uint8_t *tgt, size_t tgt_size, AVPacket *pkt)
+{
+decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data;
+uint16_t *max_buf = buf + width;
+
+static const uint8_t vanc_header[6] = { 0x00, 0x00, 0xff, 0x03, 0xff, 0x03 
};
+while (buf < max_buf - 6) {
+uint16_t did = buf[3] & 0xFF;  // data 
id
+uint16_t sdid = buf[4] & 0xFF; // 
secondary data id
+/* Check for VANC header */
+if (memcmp(vanc_header, buf, 3 * 2)) {


Maybe it's personal preference, but I find the (buf[0] == 0 && buf[1] ==
0x3ff && buf[2] == 0x3ff) better. Also, maybe performance wise it might be 
faster
then calling memcmp each time, although I am not sure.

Also since we are going to parse vanc in every capture, I wonder if we 
should simply take into account the general requirement that vanc packets 
should start immediately and they should be contiguous. As far as I know, 
with compliant sources, we can simply return

[FFmpeg-devel] [PATCH] avfilter: add starfield video source

2017-09-07 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vsrc_starfield.c | 191 +++
 3 files changed, 193 insertions(+)
 create mode 100644 libavfilter/vsrc_starfield.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1e460ab..4cc99f0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -352,6 +352,7 @@ OBJS-$(CONFIG_NULLSRC_FILTER)+= 
vsrc_testsrc.o
 OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEBARS_FILTER)  += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEHDBARS_FILTER)+= vsrc_testsrc.o
+OBJS-$(CONFIG_STARFIELD_FILTER)  += vsrc_starfield.o
 OBJS-$(CONFIG_TESTSRC_FILTER)+= vsrc_testsrc.o
 OBJS-$(CONFIG_TESTSRC2_FILTER)   += vsrc_testsrc.o
 OBJS-$(CONFIG_YUVTESTSRC_FILTER) += vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9a2cfea..f1f87ca 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -363,6 +363,7 @@ static void register_all(void)
 REGISTER_FILTER(RGBTESTSRC, rgbtestsrc, vsrc);
 REGISTER_FILTER(SMPTEBARS,  smptebars,  vsrc);
 REGISTER_FILTER(SMPTEHDBARS,smptehdbars,vsrc);
+REGISTER_FILTER(STARFIELD,  starfield,  vsrc);
 REGISTER_FILTER(TESTSRC,testsrc,vsrc);
 REGISTER_FILTER(TESTSRC2,   testsrc2,   vsrc);
 REGISTER_FILTER(YUVTESTSRC, yuvtestsrc, vsrc);
diff --git a/libavfilter/vsrc_starfield.c b/libavfilter/vsrc_starfield.c
new file mode 100644
index 000..96b8667
--- /dev/null
+++ b/libavfilter/vsrc_starfield.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/internal.h"
+#include "libavutil/lfg.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/random_seed.h"
+#include "libavutil/avstring.h"
+#include "avfilter.h"
+#include "internal.h"
+#include "formats.h"
+#include "video.h"
+
+typedef struct Star {
+int x, y;
+AVRational z;
+unsigned r, g, b;
+} Star;
+
+typedef struct StarFieldContext {
+const AVClass *class;
+
+int w, h;
+uint64_t pts;
+AVRational frame_rate;
+AVRational speed;
+int nb_stars;
+int64_t seed;
+
+AVLFG lfg;
+Star *stars;
+} StarFieldContext;
+
+#define OFFSET(x) offsetof(StarFieldContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption starfield_options[] = {
+{ "size",  "set video size",   OFFSET(w),  AV_OPT_TYPE_IMAGE_SIZE, 
{.str = "hd720"},   0, 0, FLAGS },
+{ "rate",  "set video rate",   OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, 
{.str = "25"},  0,   INT_MAX, FLAGS },
+{ "stars", "set stars number", OFFSET(nb_stars),   AV_OPT_TYPE_INT,
{.i64 = 1024},  1, 81920, FLAGS },
+{ "seed",  "set seed", OFFSET(seed),   AV_OPT_TYPE_INT64,  
{.i64 = -1},   -1, INT64_MAX, FLAGS },
+{ "speed", "set speed",OFFSET(speed),  AV_OPT_TYPE_RATIONAL,   
{.dbl = 1.01},  1, 2, FLAGS },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(starfield);
+
+static void init_star(StarFieldContext *s, Star *star, int depth)
+{
+star->x = av_lfg_get(&s->lfg) - INT_MAX;
+star->y = av_lfg_get(&s->lfg) - INT_MAX;
+star->z.num = star->z.den = 1;
+star->r = av_lfg_get(&s->lfg) >> av_log2(depth / 32);
+star->g = av_lfg_get(&s->lfg) >> av_log2(depth / 32);
+star->b = av_lfg_get(&s->lfg) >> av_log2(depth / 32);
+}
+
+static av_cold int init(AVFilterContext *ctx)
+{
+StarFieldContext *s = ctx->priv;
+int i;
+
+s->stars = av_calloc(s->nb_stars, sizeof(*s->stars));
+if (!s->stars)
+return AVERROR(ENOMEM);
+
+if (s->seed == -1)
+s->seed = av_get_random_seed();
+av_lfg_init(&s->lfg, s->seed);
+
+for (i = 0; i < s->nb_stars; i++) {
+init_star(s, &s->stars[i], i+1);
+}
+
+return 0;
+}
+
+static av_cold void uninit(AVFilterContext *ctx)
+{
+StarFieldContext *s = ctx->priv;
+
+av_freep(&s->stars);
+}
+
+static int config

[FFmpeg-devel] [PATCHv11] libavcodec: v4l2: add support for v4l2 mem2mem codecs

2017-09-07 Thread Jorge Ramirez-Ortiz
This patchset enhances Alexis Ballier's original patch and validates
it using Qualcomm's Venus hardware (driver recently landed upstream
[1]).

This has been tested on Qualcomm's DragonBoard 410c and 820c
Configure/make scripts have been validated on Ubuntu 10.04 and
16.04.

Tested decoders:
   - h264
   - h263
   - mpeg4
   - vp8
   - vp9
   - hevc

Tested encoders:
   - h264
   - h263
   - mpeg4

Tested transcoding (concurrent encoding/decoding)

Some of the changes introduced:
- v4l2: code cleanup and abstractions added
- v4l2: follow the new encode/decode api.
- v4l2: fix display size for NV12 output pool.
- v4l2: handle EOS.
- v4l2: vp8 and mpeg4 decoding and encoding.
- v4l2: hevc and vp9 support.
- v4l2: generate EOF on dequeue errors.
- v4l2: h264_mp4toannexb filtering.
- v4l2: fixed make install and fate issues.
- v4l2: codecs enabled/disabled depending on pixfmt defined
- v4l2: pass timebase/framerate to the context
- v4l2: runtime decoder reconfiguration.
- v4l2: add more frame information
- v4l2: free hardware resources on last reference being released
- v4l2: encoding: disable b-frames for upstreaming (patch required)

[1] https://lwn.net/Articles/697956/

Reviewed-by: Jorge Ramirez 
Reviewed-by: Alexis Ballier 
Tested-by: Jorge Ramirez 
---
 Changelog |   1 +
 configure |  28 +++
 libavcodec/Makefile   |  15 ++
 libavcodec/allcodecs.c|   9 +
 libavcodec/v4l2_buffers.c | 448 ++
 libavcodec/v4l2_buffers.h | 121 ++
 libavcodec/v4l2_context.c | 604 ++
 libavcodec/v4l2_context.h | 206 
 libavcodec/v4l2_fmt.c | 182 ++
 libavcodec/v4l2_fmt.h |  34 +++
 libavcodec/v4l2_m2m.c | 331 +
 libavcodec/v4l2_m2m.h |  94 
 libavcodec/v4l2_m2m_dec.c | 232 ++
 libavcodec/v4l2_m2m_enc.c | 350 +++
 14 files changed, 2655 insertions(+)
 create mode 100644 libavcodec/v4l2_buffers.c
 create mode 100644 libavcodec/v4l2_buffers.h
 create mode 100644 libavcodec/v4l2_context.c
 create mode 100644 libavcodec/v4l2_context.h
 create mode 100644 libavcodec/v4l2_fmt.c
 create mode 100644 libavcodec/v4l2_fmt.h
 create mode 100644 libavcodec/v4l2_m2m.c
 create mode 100644 libavcodec/v4l2_m2m.h
 create mode 100644 libavcodec/v4l2_m2m_dec.c
 create mode 100644 libavcodec/v4l2_m2m_enc.c

diff --git a/Changelog b/Changelog
index cae5254..95f70f0 100644
--- a/Changelog
+++ b/Changelog
@@ -43,6 +43,7 @@ version :
 - add --disable-autodetect build switch
 - drop deprecated qtkit input device (use avfoundation instead)
 - despill video filter
+- V4L2 mem2mem HW assisted codecs
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/configure b/configure
index 2f3fa2b..93ec18c 100755
--- a/configure
+++ b/configure
@@ -185,6 +185,7 @@ Individual component options:
   --enable-filter=NAME enable filter NAME
   --disable-filter=NAMEdisable filter NAME
   --disable-filtersdisable all filters
+  --disable-v4l2_m2m   disable V4L2 mem2mem code [autodetect]
 
 External library support:
 
@@ -1609,6 +1610,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST="
 vda
 vdpau
 videotoolbox_hwaccel
+v4l2_m2m
 xvmc
 "
 
@@ -2740,6 +2742,7 @@ omx_rpi_select="omx"
 qsvdec_select="qsv"
 qsvenc_select="qsv"
 vaapi_encode_deps="vaapi"
+v4l2_m2m_deps_any="linux_videodev2_h"
 
 hwupload_cuda_filter_deps="cuda"
 scale_npp_filter_deps="cuda libnpp"
@@ -2749,6 +2752,8 @@ nvenc_deps="cuda"
 nvenc_deps_any="dlopen LoadLibrary"
 nvenc_encoder_deps="nvenc"
 
+h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m"
+h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m"
 h264_crystalhd_decoder_select="crystalhd h264_mp4toannexb_bsf h264_parser"
 h264_cuvid_decoder_deps="cuda cuvid"
 h264_cuvid_decoder_select="h264_mp4toannexb_bsf"
@@ -2767,6 +2772,8 @@ h264_vda_decoder_deps="vda"
 h264_vda_decoder_select="h264_decoder"
 h264_vdpau_decoder_deps="vdpau"
 h264_vdpau_decoder_select="h264_decoder"
+h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m"
+h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m"
 hevc_cuvid_decoder_deps="cuda cuvid"
 hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf"
 hevc_mediacodec_decoder_deps="mediacodec"
@@ -2778,12 +2785,15 @@ hevc_qsv_encoder_deps="libmfx"
 hevc_qsv_encoder_select="hevcparse qsvenc"
 hevc_vaapi_encoder_deps="VAEncPictureParameterBufferHEVC"
 hevc_vaapi_encoder_select="vaapi_encode golomb"
+hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m"
+hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m"
 mjpeg_cuvid_decoder_deps="cuda cuvid"
 mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG"
 mjpeg_vaapi_encoder_select="v

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/pthread_slice: add main function support for avpriv_slicethread_create()

2017-09-07 Thread Michael Niedermayer
On Fri, Sep 08, 2017 at 12:55:29AM +0700, Ilia Valiakhmetov wrote:
> ---
>  libavcodec/internal.h  |  4 
>  libavcodec/pthread_slice.c | 33 ++---
>  libavcodec/thread.h|  1 +
>  libavutil/slicethread.h| 18 ++
>  4 files changed, 37 insertions(+), 19 deletions(-)

applying only patch 1 fails to build

libavcodec/vp9.c: In function ‘thread_execute3’:
libavcodec/vp9.c:94:5: error: unknown type name ‘SliceThreadContext’
 SliceThreadContext *c = avctx->internal->thread_ctx;
 ^
libavcodec/vp9.c:95:6: error: request for member ‘func2’ in something not a 
structure or union
 c->func2 = func;
  ^
libavcodec/vp9.c:96:6: error: request for member ‘m_func’ in something not a 
structure or union
 c->m_func = m_func;
  ^
libavcodec/vp9.c:97:5: error: implicit declaration of function 
‘ff_thread_execute’ [-Werror=implicit-function-declaration]
 return ff_thread_execute(avctx, NULL, arg, ret, job_count, 0);
 ^
libavcodec/vp9.c: At top level:
libavcodec/vp9.c:1790:22: error: ‘FF_CODEC_CAP_SLICE_THREAD_HAS_MF’ undeclared 
here (not in a function)
 .caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF,
  ^


applying both patches fails to build on mingw64

In file included from src/libavutil/slicethread.c:20:0:
src/libavutil/slicethread.h:38:5: error: unknown type name ‘pthread_cond_t’
 pthread_cond_t *progress_cond;
 ^
src/libavutil/slicethread.h:39:5: error: unknown type name ‘pthread_mutex_t’
 pthread_mutex_t *progress_mutex;
 ^
make: *** [libavutil/slicethread.o] Error 1
make: *** Waiting for unfinished jobs


[...]
-- 
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: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCHv2 2/2] avcodec/pthread_slice: add ff_slice_thread_execute_with_mainfunc()

2017-09-07 Thread Ilia Valiakhmetov
Signed-off-by: Ilia Valiakhmetov 

v2:
---
 libavcodec/internal.h  |  4 
 libavcodec/pthread_slice.c | 22 --
 libavcodec/thread.h|  4 +++-
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 64120ea..4668952 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -64,6 +64,10 @@
  * dimensions to coded rather than display values.
  */
 #define FF_CODEC_CAP_EXPORTS_CROPPING   (1 << 4)
+/**
+ * Codec initializes slice-based threading with a main function
+ */
+#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF(1 << 5)
 
 #ifdef TRACE
 #   define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index c781d35..d659f9b 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -38,11 +38,13 @@
 
 typedef int (action_func)(AVCodecContext *c, void *arg);
 typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int 
threadnr);
+typedef int (main_func)(AVCodecContext *c);
 
 typedef struct SliceThreadContext {
 AVSliceThread *thread;
 action_func *func;
 action_func2 *func2;
+main_func *mainfunc;
 void *args;
 int *rets;
 int job_size;
@@ -54,6 +56,12 @@ typedef struct SliceThreadContext {
 pthread_mutex_t *progress_mutex;
 } SliceThreadContext;
 
+static void main_function(void *priv) {
+AVCodecContext *avctx = priv;
+SliceThreadContext *c = avctx->internal->thread_ctx;
+c->mainfunc(avctx);
+}
+
 static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int 
nb_threads)
 {
 AVCodecContext *avctx = priv;
@@ -99,7 +107,7 @@ static int thread_execute(AVCodecContext *avctx, 
action_func* func, void *arg, i
 c->func = func;
 c->rets = ret;
 
-avpriv_slicethread_execute(c->thread, job_count, 0);
+avpriv_slicethread_execute(c->thread, job_count, !!c->mainfunc  );
 return 0;
 }
 
@@ -110,10 +118,19 @@ static int thread_execute2(AVCodecContext *avctx, 
action_func2* func2, void *arg
 return thread_execute(avctx, NULL, arg, ret, job_count, 0);
 }
 
+int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, action_func2* 
func2, main_func *mainfunc, void *arg, int *ret, int job_count)
+{
+SliceThreadContext *c = avctx->internal->thread_ctx;
+c->func2 = func2;
+c->mainfunc = mainfunc;
+return thread_execute(avctx, NULL, arg, ret, job_count, 0);
+}
+
 int ff_slice_thread_init(AVCodecContext *avctx)
 {
 SliceThreadContext *c;
 int thread_count = avctx->thread_count;
+static void (*mainfunc)(void *);
 
 #if HAVE_W32THREADS
 w32thread_init();
@@ -142,7 +159,8 @@ int ff_slice_thread_init(AVCodecContext *avctx)
 }
 
 avctx->internal->thread_ctx = c = av_mallocz(sizeof(*c));
-if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, 
worker_func, NULL, thread_count)) <= 1) {
+mainfunc = avctx->codec->caps_internal & FF_CODEC_CAP_SLICE_THREAD_HAS_MF 
? &main_function : NULL;
+if (!c || (thread_count = avpriv_slicethread_create(&c->thread, avctx, 
worker_func, mainfunc, thread_count)) <= 1) {
 if (c)
 avpriv_slicethread_free(&c->thread);
 av_freep(&avctx->internal->thread_ctx);
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 90864b5..3186193 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -133,8 +133,10 @@ void ff_thread_release_buffer(AVCodecContext *avctx, 
ThreadFrame *f);
 int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src);
 
 int ff_thread_init(AVCodecContext *s);
+int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
+int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int 
threadnr),
+int (*main_func)(AVCodecContext *c), void *arg, int *ret, int 
job_count);
 void ff_thread_free(AVCodecContext *s);
-
 int ff_alloc_entries(AVCodecContext *avctx, int count);
 void ff_reset_entries(AVCodecContext *avctx);
 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, 
int n);
-- 
2.8.3

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/pthread_slice: add main function support for avpriv_slicethread_create()

2017-09-07 Thread gh0st
Fixed in v2.

On Fri, Sep 8, 2017 at 3:40 AM, Michael Niedermayer 
wrote:

> On Fri, Sep 08, 2017 at 12:55:29AM +0700, Ilia Valiakhmetov wrote:
> > ---
> >  libavcodec/internal.h  |  4 
> >  libavcodec/pthread_slice.c | 33 ++---
> >  libavcodec/thread.h|  1 +
> >  libavutil/slicethread.h| 18 ++
> >  4 files changed, 37 insertions(+), 19 deletions(-)
>
> applying only patch 1 fails to build
>
> libavcodec/vp9.c: In function ‘thread_execute3’:
> libavcodec/vp9.c:94:5: error: unknown type name ‘SliceThreadContext’
>  SliceThreadContext *c = avctx->internal->thread_ctx;
>  ^
> libavcodec/vp9.c:95:6: error: request for member ‘func2’ in something not
> a structure or union
>  c->func2 = func;
>   ^
> libavcodec/vp9.c:96:6: error: request for member ‘m_func’ in something not
> a structure or union
>  c->m_func = m_func;
>   ^
> libavcodec/vp9.c:97:5: error: implicit declaration of function
> ‘ff_thread_execute’ [-Werror=implicit-function-declaration]
>  return ff_thread_execute(avctx, NULL, arg, ret, job_count, 0);
>  ^
> libavcodec/vp9.c: At top level:
> libavcodec/vp9.c:1790:22: error: ‘FF_CODEC_CAP_SLICE_THREAD_HAS_MF’
> undeclared here (not in a function)
>  .caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF,
>   ^
>
>
> applying both patches fails to build on mingw64
>
> In file included from src/libavutil/slicethread.c:20:0:
> src/libavutil/slicethread.h:38:5: error: unknown type name
> ‘pthread_cond_t’
>  pthread_cond_t *progress_cond;
>  ^
> src/libavutil/slicethread.h:39:5: error: unknown type name
> ‘pthread_mutex_t’
>  pthread_mutex_t *progress_mutex;
>  ^
> make: *** [libavutil/slicethread.o] Error 1
> make: *** Waiting for unfinished jobs
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who would give up essential Liberty, to purchase a little
> temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avcodec/vp9: change avctx->execute3 in favor of ff_slice_thread_execute_with_mainfunc()

2017-09-07 Thread Ilia Valiakhmetov
Signed-off-by: Ilia Valiakhmetov 

v8:
---
 libavcodec/vp9.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index b780262..a71045e 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -1628,7 +1628,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 
-avctx->execute3(avctx, decode_tiles_mt, loopfilter_proc, s->td, 
NULL, s->s.h.tiling.tile_cols);
+ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, 
loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
 } else {
 ret = decode_tiles(avctx, data, size);
 if (ret < 0)
@@ -1776,7 +1776,8 @@ AVCodec ff_vp9_decoder = {
 .init  = vp9_decode_init,
 .close = vp9_decode_free,
 .decode= vp9_decode_frame,
-.capabilities  = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | 
AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_SLICE_THREAD_HAS_MF,
+.capabilities  = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | 
AV_CODEC_CAP_SLICE_THREADS,
+.caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF,
 .flush = vp9_decode_flush,
 .init_thread_copy  = 
ONLY_IF_THREADS_ENABLED(vp9_decode_init_thread_copy),
 .update_thread_context = 
ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context),
-- 
2.8.3

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_tonemap: don't use NAN constant as an initializer

2017-09-07 Thread Michael Niedermayer
On Wed, Sep 06, 2017 at 10:59:13PM -0300, James Almer wrote:
> Netbsd:
> src/libavfilter/vf_tonemap.c:314: error: initializer element is not constant
> src/libavfilter/vf_tonemap.c:314: error: (near initialization for 
> 'tonemap_options[8].default_val.dbl')
> 
> DJGPP
> src/libavfilter/vf_tonemap.c:314:87: error: initializer element is not 
> constant
>  { "param","tonemap parameter", OFFSET(param), 
> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
>   
>  ^
> src/libavfilter/vf_tonemap.c:314:87: note: (near initialization for 
> 'tonemap_options[8].default_val.dbl')
> 
> Signed-off-by: James Almer 
> ---
>  libavfilter/vf_tonemap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
> index 10308bdb16..d2c7ffa831 100644
> --- a/libavfilter/vf_tonemap.c
> +++ b/libavfilter/vf_tonemap.c
> @@ -311,7 +311,7 @@ static const AVOption tonemap_options[] = {
>  { "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD},
>   0, 0, FLAGS, "tonemap" },
>  { "hable",0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE},   
>   0, 0, FLAGS, "tonemap" },
>  { "mobius",   0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS},  
>   0, 0, FLAGS, "tonemap" },
> -{ "param","tonemap parameter", OFFSET(param), 
> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
> +{ "param","tonemap parameter", OFFSET(param), 
> AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, DBL_MIN, DBL_MAX, FLAGS },

building shared libs: (seems ok with static)
on linux x86-64

src/libavfilter/vf_tonemap.c:314:108: error: initializer element is not a 
compile-time constant
{ "param", "tonemap parameter", __builtin_offsetof(TonemapContext, param), 
AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, 2.2250738585072014e-308, 
1.7976931348623157e+308, 16 | (1<<16) },

   ^~~
1 error generated.
make: *** [libavfilter/vf_tonemap.o] Error 1
make: *** Waiting for unfinished jobs
src/libavfilter/vf_uspp.c:253:15: warning: 'avcodec_encode_video2' is 
deprecated [-Wdeprecated-declarations]
ret = avcodec_encode_video2(p->avctx_enc[i], &pkt, p->frame, 
&got_pkt_ptr);
  ^
src/libavcodec/avcodec.h:5486:5: note: 'avcodec_encode_video2' has been 
explicitly marked deprecated here
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt,
^
src/libavfilter/vf_uspp.c:259:41: warning: 'coded_frame' is deprecated 
[-Wdeprecated-declarations]
p->frame_dec = p->avctx_enc[i]->coded_frame;
^
src/libavcodec/avcodec.h:3167:42: note: 'coded_frame' has been explicitly 
marked deprecated here
__attribute__((deprecated)) AVFrame *coded_frame;
 ^
2 warnings generated.

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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_tonemap: don't use NAN constant as an initializer

2017-09-07 Thread James Almer
On 9/7/2017 6:16 PM, Michael Niedermayer wrote:
> On Wed, Sep 06, 2017 at 10:59:13PM -0300, James Almer wrote:
>> Netbsd:
>> src/libavfilter/vf_tonemap.c:314: error: initializer element is not constant
>> src/libavfilter/vf_tonemap.c:314: error: (near initialization for 
>> 'tonemap_options[8].default_val.dbl')
>>
>> DJGPP
>> src/libavfilter/vf_tonemap.c:314:87: error: initializer element is not 
>> constant
>>  { "param","tonemap parameter", OFFSET(param), 
>> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
>>  
>>   ^
>> src/libavfilter/vf_tonemap.c:314:87: note: (near initialization for 
>> 'tonemap_options[8].default_val.dbl')
>>
>> Signed-off-by: James Almer 
>> ---
>>  libavfilter/vf_tonemap.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
>> index 10308bdb16..d2c7ffa831 100644
>> --- a/libavfilter/vf_tonemap.c
>> +++ b/libavfilter/vf_tonemap.c
>> @@ -311,7 +311,7 @@ static const AVOption tonemap_options[] = {
>>  { "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD},   
>>0, 0, FLAGS, "tonemap" },
>>  { "hable",0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE},  
>>0, 0, FLAGS, "tonemap" },
>>  { "mobius",   0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS}, 
>>0, 0, FLAGS, "tonemap" },
>> -{ "param","tonemap parameter", OFFSET(param), 
>> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
>> +{ "param","tonemap parameter", OFFSET(param), 
>> AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, DBL_MIN, DBL_MAX, FLAGS },
> 
> building shared libs: (seems ok with static)
> on linux x86-64
> 
> src/libavfilter/vf_tonemap.c:314:108: error: initializer element is not a 
> compile-time constant
> { "param", "tonemap parameter", __builtin_offsetof(TonemapContext, 
> param), AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, 2.2250738585072014e-308, 
> 1.7976931348623157e+308, 16 | (1<<16) },

What can we do, then? NAN and nan("") are sometimes compile-time
constants and sometimes not, apparently depending on build type and
target system.

CCing Vittorio as he's the author of the filter.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/5] lavc: Add flag to mark packets containing trusted input

2017-09-07 Thread Mark Thompson
---
Also version bump.

As suggested by previous discussion around a wrapped_avframe decoder.


 doc/APIchanges   | 3 +++
 libavcodec/avcodec.h | 7 +++
 2 files changed, 10 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index b98a3419c4..26aa0b6481 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2017-09-xx - xxx - lavc 57.n+1.100 - avcodec.h
+  Add AV_PKT_FLAG_TRUSTED.
+
 2017-09-04 - xxx - lavc 57.105.100 - avcodec.h
   Add AV_HWACCEL_CODEC_CAP_EXPERIMENTAL, replacing the deprecated
   HWACCEL_CODEC_CAP_EXPERIMENTAL flag.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7708bb2adb..fdf93f9a54 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1709,6 +1709,13 @@ typedef struct AVPacket {
  * after decoding.
  **/
 #define AV_PKT_FLAG_DISCARD   0x0004
+/**
+ * The packet comes from a trusted source.
+ *
+ * Otherwise-unsafe constructs such as arbitrary pointers to data
+ * outside the packet may be followed.
+ */
+#define AV_PKT_FLAG_TRUSTED   0x0008
 
 enum AVSideDataParamChangeFlags {
 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/5] hwcontext_vaapi: Add DRM to VAAPI mapping

2017-09-07 Thread Mark Thompson
---
Unchanged.


 libavutil/hwcontext_vaapi.c | 215 +++-
 1 file changed, 214 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 3970726d30..c69db39238 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -25,6 +25,11 @@
 #   include 
 #endif
 
+#if CONFIG_LIBDRM
+#   include 
+#   include 
+#endif
+
 #include 
 #if HAVE_UNISTD_H
 #   include 
@@ -41,6 +46,10 @@
 #include "pixdesc.h"
 #include "pixfmt.h"
 
+#if CONFIG_LIBDRM
+#   include "hwcontext_drm.h"
+#endif
+
 typedef struct VAAPIDevicePriv {
 #if HAVE_VAAPI_X11
 Display *x11_display;
@@ -897,6 +906,170 @@ static int vaapi_map_from(AVHWFramesContext *hwfc, 
AVFrame *dst,
 return 0;
 }
 
+#if CONFIG_LIBDRM
+
+#define DRM_MAP(va, layers, ...) { \
+VA_FOURCC_ ## va, \
+layers, \
+{ __VA_ARGS__ } \
+}
+static const struct {
+uint32_t va_fourcc;
+int   nb_layer_formats;
+uint32_t layer_formats[AV_DRM_MAX_PLANES];
+} vaapi_drm_format_map[] = {
+DRM_MAP(NV12, 2, DRM_FORMAT_R8,  DRM_FORMAT_RG88),
+DRM_MAP(NV12, 1, DRM_FORMAT_NV12),
+#ifdef VA_FOURCC_P010
+DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616),
+#endif
+DRM_MAP(BGRA, 1, DRM_FORMAT_BGRA),
+DRM_MAP(BGRX, 1, DRM_FORMAT_BGRX),
+DRM_MAP(RGBA, 1, DRM_FORMAT_RGBA),
+DRM_MAP(RGBX, 1, DRM_FORMAT_RGBX),
+#ifdef VA_FOURCC_ABGR
+DRM_MAP(ABGR, 1, DRM_FORMAT_ABGR),
+DRM_MAP(XBGR, 1, DRM_FORMAT_XBGR),
+#endif
+DRM_MAP(ARGB, 1, DRM_FORMAT_ARGB),
+DRM_MAP(XRGB, 1, DRM_FORMAT_XRGB),
+};
+#undef DRM_MAP
+
+static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc,
+ HWMapDescriptor *hwmap)
+{
+AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx;
+
+VASurfaceID surface_id = (VASurfaceID)(uintptr_t)hwmap->priv;
+
+vaDestroySurfaces(dst_dev->display, &surface_id, 1);
+}
+
+static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst,
+  const AVFrame *src, int flags)
+{
+AVHWFramesContext  *dst_fc =
+(AVHWFramesContext*)dst->hw_frames_ctx->data;
+AVVAAPIDeviceContext  *dst_dev = dst_fc->device_ctx->hwctx;
+const AVDRMFrameDescriptor *desc;
+VASurfaceID surface_id;
+VAStatus vas;
+uint32_t va_fourcc, va_rt_format;
+int err, i, j, k;
+
+unsigned long buffer_handle;
+VASurfaceAttribExternalBuffers buffer_desc;
+VASurfaceAttrib attrs[2] = {
+{
+.type  = VASurfaceAttribMemoryType,
+.flags = VA_SURFACE_ATTRIB_SETTABLE,
+.value.type= VAGenericValueTypeInteger,
+.value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME,
+},
+{
+.type  = VASurfaceAttribExternalBufferDescriptor,
+.flags = VA_SURFACE_ATTRIB_SETTABLE,
+.value.type= VAGenericValueTypePointer,
+.value.value.p = &buffer_desc,
+}
+};
+
+desc = (AVDRMFrameDescriptor*)src->data[0];
+
+if (desc->nb_objects != 1) {
+av_log(dst_fc, AV_LOG_ERROR, "VAAPI can only map frames "
+   "made from a single DRM object.\n");
+return AVERROR(EINVAL);
+}
+
+va_fourcc = 0;
+for (i = 0; i < FF_ARRAY_ELEMS(vaapi_drm_format_map); i++) {
+if (desc->nb_layers != vaapi_drm_format_map[i].nb_layer_formats)
+continue;
+for (j = 0; j < desc->nb_layers; j++) {
+if (desc->layers[j].format !=
+vaapi_drm_format_map[i].layer_formats[j])
+break;
+}
+if (j != desc->nb_layers)
+continue;
+va_fourcc = vaapi_drm_format_map[i].va_fourcc;
+break;
+}
+if (!va_fourcc) {
+av_log(dst_fc, AV_LOG_ERROR, "DRM format not supported "
+   "by VAAPI.\n");
+return AVERROR(EINVAL);
+}
+
+av_log(dst_fc, AV_LOG_DEBUG, "Map DRM object %d to VAAPI as "
+   "%08x.\n", desc->objects[0].fd, va_fourcc);
+
+for (i = 0; i < FF_ARRAY_ELEMS(vaapi_format_map); i++) {
+if (vaapi_format_map[i].fourcc == va_fourcc)
+va_rt_format = vaapi_format_map[i].rt_format;
+}
+
+buffer_handle = desc->objects[0].fd;
+buffer_desc.pixel_format = va_fourcc;
+buffer_desc.width= src_fc->width;
+buffer_desc.height   = src_fc->height;
+buffer_desc.data_size= desc->objects[0].size;
+buffer_desc.buffers  = &buffer_handle;
+buffer_desc.num_buffers  = 1;
+buffer_desc.flags= 0;
+
+k = 0;
+for (i = 0; i < desc->nb_layers; i++) {
+for (j = 0; j < desc->layers[i].nb_planes; j++) {
+buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch;
+buffer_desc.offsets[k] = desc->layers[i].planes[j].offset;
+++k;
+}
+}
+buffer_desc.num_planes = k;
+
+vas = vaCreateSurfaces(dst_dev->display, v

[FFmpeg-devel] [PATCH 1/5] lavu: Add DRM hwcontext

2017-09-07 Thread Mark Thompson
---
Unchanged.


 configure  |   3 +
 libavutil/Makefile |   2 +
 libavutil/hwcontext.c  |   4 +
 libavutil/hwcontext.h  |   1 +
 libavutil/hwcontext_drm.c  | 291 +
 libavutil/hwcontext_drm.h  | 166 +++
 libavutil/hwcontext_internal.h |   1 +
 libavutil/pixdesc.c|   4 +
 libavutil/pixfmt.h |   7 +
 9 files changed, 479 insertions(+)
 create mode 100644 libavutil/hwcontext_drm.c
 create mode 100644 libavutil/hwcontext_drm.h

diff --git a/configure b/configure
index 2f3fa2ba3d..6581c53c1a 100755
--- a/configure
+++ b/configure
@@ -304,6 +304,7 @@ External library support:
   --disable-cuvid  disable Nvidia CUVID support [autodetect]
   --disable-d3d11vadisable Microsoft Direct3D 11 video acceleration 
code [autodetect]
   --disable-dxva2  disable Microsoft DirectX 9 video acceleration code 
[autodetect]
+  --enable-libdrm  enable DRM code (Linux) [no]
   --enable-libmfx  enable Intel MediaSDK (AKA Quick Sync Video) code 
via libmfx [no]
   --enable-libnpp  enable Nvidia Performance Primitives-based code [no]
   --enable-mmalenable Broadcom Multi-Media Abstraction Layer 
(Raspberry Pi) via MMAL [no]
@@ -1552,6 +1553,7 @@ EXTERNAL_LIBRARY_LIST="
 libcaca
 libcelt
 libdc1394
+libdrm
 libflite
 libfontconfig
 libfreetype
@@ -5856,6 +5858,7 @@ enabled libcelt   && require libcelt celt/celt.h 
celt_decode -lcelt0 &&
die "ERROR: libcelt must be installed and 
version must be >= 0.11.0."; }
 enabled libcaca   && require_pkg_config caca caca.h caca_create_canvas
 enabled libdc1394 && require_pkg_config libdc1394-2 dc1394/dc1394.h 
dc1394_new
+enabled libdrm&& require_pkg_config libdrm xf86drm.h drmGetVersion
 enabled libfdk_aac&& { use_pkg_config fdk-aac "fdk-aac/aacenc_lib.h" 
aacEncOpen ||
{ require libfdk_aac fdk-aac/aacenc_lib.h 
aacEncOpen -lfdk-aac &&
  warn "using libfdk without pkg-config"; } }
diff --git a/libavutil/Makefile b/libavutil/Makefile
index e45871fd11..65e285a701 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -34,6 +34,7 @@ HEADERS = adler32.h   
  \
   hwcontext.h   \
   hwcontext_cuda.h  \
   hwcontext_d3d11va.h   \
+  hwcontext_drm.h   \
   hwcontext_dxva2.h \
   hwcontext_qsv.h   \
   hwcontext_vaapi.h \
@@ -161,6 +162,7 @@ OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o
 OBJS-$(CONFIG_D3D11VA)  += hwcontext_d3d11va.o
 OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o
 OBJS-$(CONFIG_QSV)   += hwcontext_qsv.o
+OBJS-$(CONFIG_LIBDRM)   += hwcontext_drm.o
 OBJS-$(CONFIG_LZO)  += lzo.o
 OBJS-$(CONFIG_OPENCL)   += opencl.o opencl_internal.o
 OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 2a755a6878..aa6b3ad176 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -35,6 +35,9 @@ static const HWContextType *const hw_table[] = {
 #if CONFIG_D3D11VA
 &ff_hwcontext_type_d3d11va,
 #endif
+#if CONFIG_LIBDRM
+&ff_hwcontext_type_drm,
+#endif
 #if CONFIG_DXVA2
 &ff_hwcontext_type_dxva2,
 #endif
@@ -55,6 +58,7 @@ static const HWContextType *const hw_table[] = {
 
 static const char *const hw_type_names[] = {
 [AV_HWDEVICE_TYPE_CUDA]   = "cuda",
+[AV_HWDEVICE_TYPE_DRM]= "drm",
 [AV_HWDEVICE_TYPE_DXVA2]  = "dxva2",
 [AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va",
 [AV_HWDEVICE_TYPE_QSV]= "qsv",
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index afb0d80d59..03334e20e0 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -33,6 +33,7 @@ enum AVHWDeviceType {
 AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
 AV_HWDEVICE_TYPE_NONE,
 AV_HWDEVICE_TYPE_D3D11VA,
+AV_HWDEVICE_TYPE_DRM,
 };
 
 typedef struct AVHWDeviceInternal AVHWDeviceInternal;
diff --git a/libavutil/hwcontext_drm.c b/libavutil/hwcontext_drm.c
new file mode 100644
index 00..e7be9abd4c
--- /dev/null
+++ b/libavutil/hwcontext_drm.c
@@ -0,0 +1,291 @@
+/*
+ * 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 op

[FFmpeg-devel] [PATCH 4/5] lavc: Add wrapped_avframe decoder

2017-09-07 Thread Mark Thompson
Intended for use with hardware frames for which rawvideo is not
sufficient.  Requires the trusted packet flag to be set - decoding
fails if not to avoid security issues (the wrapped AVFrame can
contain pointers to arbitrary data).
---
Now uses the trusted packet flag, rejects the packet if not set.


 libavcodec/Makefile  |  1 +
 libavcodec/allcodecs.c   |  2 +-
 libavcodec/wrapped_avframe.c | 36 
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 999632cf9e..943e5db511 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -653,6 +653,7 @@ OBJS-$(CONFIG_WMV2_DECODER)+= wmv2dec.o wmv2.o 
wmv2data.o \
 OBJS-$(CONFIG_WMV2_ENCODER)+= wmv2enc.o wmv2.o wmv2data.o \
   msmpeg4.o msmpeg4enc.o msmpeg4data.o
 OBJS-$(CONFIG_WNV1_DECODER)+= wnv1.o
+OBJS-$(CONFIG_WRAPPED_AVFRAME_DECODER) += wrapped_avframe.o
 OBJS-$(CONFIG_WRAPPED_AVFRAME_ENCODER) += wrapped_avframe.o
 OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o
 OBJS-$(CONFIG_XAN_DPCM_DECODER)+= dpcm.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ce0bc7ecf3..625720578f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -377,7 +377,7 @@ static void register_all(void)
 REGISTER_DECODER(VQA,   vqa);
 REGISTER_DECODER(BITPACKED, bitpacked);
 REGISTER_DECODER(WEBP,  webp);
-REGISTER_ENCODER(WRAPPED_AVFRAME,   wrapped_avframe);
+REGISTER_ENCDEC (WRAPPED_AVFRAME,   wrapped_avframe);
 REGISTER_ENCDEC (WMV1,  wmv1);
 REGISTER_ENCDEC (WMV2,  wmv2);
 REGISTER_DECODER(WMV3,  wmv3);
diff --git a/libavcodec/wrapped_avframe.c b/libavcodec/wrapped_avframe.c
index 14360320ff..5f88a668b9 100644
--- a/libavcodec/wrapped_avframe.c
+++ b/libavcodec/wrapped_avframe.c
@@ -75,6 +75,33 @@ static int wrapped_avframe_encode(AVCodecContext *avctx, 
AVPacket *pkt,
 return 0;
 }
 
+static int wrapped_avframe_decode(AVCodecContext *avctx, void *data,
+  int *got_frame, AVPacket *pkt)
+{
+AVFrame *in, *out;
+int err;
+
+if (!(pkt->flags & AV_PKT_FLAG_TRUSTED)) {
+// This decoder is not usable with untrusted input.
+return AVERROR(EPERM);
+}
+
+if (pkt->size < sizeof(AVFrame))
+return AVERROR(EINVAL);
+
+in  = (AVFrame*)pkt->data;
+out = data;
+
+err = ff_decode_frame_props(avctx, out);
+if (err < 0)
+return err;
+
+av_frame_move_ref(out, in);
+
+*got_frame = 1;
+return 0;
+}
+
 AVCodec ff_wrapped_avframe_encoder = {
 .name   = "wrapped_avframe",
 .long_name  = NULL_IF_CONFIG_SMALL("AVFrame to AVPacket passthrough"),
@@ -83,3 +110,12 @@ AVCodec ff_wrapped_avframe_encoder = {
 .encode2= wrapped_avframe_encode,
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
 };
+
+AVCodec ff_wrapped_avframe_decoder = {
+.name   = "wrapped_avframe",
+.long_name  = NULL_IF_CONFIG_SMALL("AVPacket to AVFrame passthrough"),
+.type   = AVMEDIA_TYPE_VIDEO,
+.id = AV_CODEC_ID_WRAPPED_AVFRAME,
+.decode = wrapped_avframe_decode,
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE,
+};
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 5/5] lavd: Add KMS frame grabber

2017-09-07 Thread Mark Thompson
---
Now sets the trusted packet flag; otherwise unchanged.


 configure|   1 +
 libavdevice/Makefile |   1 +
 libavdevice/alldevices.c |   1 +
 libavdevice/kmsgrab.c| 455 +++
 4 files changed, 458 insertions(+)
 create mode 100644 libavdevice/kmsgrab.c

diff --git a/configure b/configure
index 6581c53c1a..76a7591ceb 100755
--- a/configure
+++ b/configure
@@ -3040,6 +3040,7 @@ gdigrab_indev_select="bmp_decoder"
 iec61883_indev_deps="libiec61883"
 jack_indev_deps="jack"
 jack_indev_deps_any="sem_timedwait dispatch_dispatch_h"
+kmsgrab_indev_deps="libdrm"
 lavfi_indev_deps="avfilter"
 libcdio_indev_deps="libcdio"
 libdc1394_indev_deps="libdc1394"
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 2a27d20388..f40f4d5298 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -32,6 +32,7 @@ OBJS-$(CONFIG_FBDEV_OUTDEV)  += fbdev_enc.o \
 OBJS-$(CONFIG_GDIGRAB_INDEV) += gdigrab.o
 OBJS-$(CONFIG_IEC61883_INDEV)+= iec61883.o
 OBJS-$(CONFIG_JACK_INDEV)+= jack.o timefilter.o
+OBJS-$(CONFIG_KMSGRAB_INDEV) += kmsgrab.o
 OBJS-$(CONFIG_LAVFI_INDEV)   += lavfi.o
 OBJS-$(CONFIG_OPENAL_INDEV)  += openal-dec.o
 OBJS-$(CONFIG_OPENGL_OUTDEV) += opengl_enc.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 38010e288a..b31558bcb5 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -53,6 +53,7 @@ static void register_all(void)
 REGISTER_INDEV   (GDIGRAB,  gdigrab);
 REGISTER_INDEV   (IEC61883, iec61883);
 REGISTER_INDEV   (JACK, jack);
+REGISTER_INDEV   (KMSGRAB,  kmsgrab);
 REGISTER_INDEV   (LAVFI,lavfi);
 REGISTER_INDEV   (OPENAL,   openal);
 REGISTER_OUTDEV  (OPENGL,   opengl);
diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
new file mode 100644
index 00..d0b9cf5001
--- /dev/null
+++ b/libavdevice/kmsgrab.c
@@ -0,0 +1,455 @@
+/*
+ * KMS/DRM input device
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "libavutil/hwcontext.h"
+#include "libavutil/hwcontext_drm.h"
+#include "libavutil/internal.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixfmt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/time.h"
+
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
+
+typedef struct KMSGrabContext {
+const AVClass *class;
+
+AVBufferRef *device_ref;
+AVHWDeviceContext *device;
+AVDRMDeviceContext *hwctx;
+
+AVBufferRef *frames_ref;
+AVHWFramesContext *frames;
+
+uint32_t plane_id;
+uint32_t drm_format;
+unsigned int width;
+unsigned int height;
+
+int64_t frame_delay;
+int64_t frame_last;
+
+const char *device_path;
+enum AVPixelFormat format;
+int64_t drm_format_modifier;
+int64_t source_plane;
+int64_t source_crtc;
+AVRational framerate;
+} KMSGrabContext;
+
+static void kmsgrab_free_desc(void *opaque, uint8_t *data)
+{
+AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor*)data;
+
+close(desc->objects[0].fd);
+
+av_free(desc);
+}
+
+static void kmsgrab_free_frame(void *opaque, uint8_t *data)
+{
+AVFrame *frame = (AVFrame*)data;
+
+av_frame_free(&frame);
+}
+
+static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
+{
+KMSGrabContext *ctx = avctx->priv_data;
+drmModePlane *plane;
+drmModeFB *fb;
+AVDRMFrameDescriptor *desc;
+AVFrame *frame;
+int64_t now;
+int err, fd;
+
+now = av_gettime();
+if (ctx->frame_last) {
+int64_t delay;
+while (1) {
+delay = ctx->frame_last + ctx->frame_delay - now;
+if (delay <= 0)
+break;
+av_usleep(delay);
+now = av_gettime();
+}
+}
+ctx->frame_last = now;
+
+plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id);
+if (!plane) {
+av_log(avctx, AV_LOG_ERROR, "Failed to get plane "
+   "%"PRIu32".\n", ctx->plane_id);
+return AVERROR(EI

Re: [FFmpeg-devel] [PATCH] avfilter/vf_tonemap: don't use NAN constant as an initializer

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 06:26:50PM -0300, James Almer wrote:
> On 9/7/2017 6:16 PM, Michael Niedermayer wrote:
> > On Wed, Sep 06, 2017 at 10:59:13PM -0300, James Almer wrote:
> >> Netbsd:
> >> src/libavfilter/vf_tonemap.c:314: error: initializer element is not 
> >> constant
> >> src/libavfilter/vf_tonemap.c:314: error: (near initialization for 
> >> 'tonemap_options[8].default_val.dbl')
> >>
> >> DJGPP
> >> src/libavfilter/vf_tonemap.c:314:87: error: initializer element is not 
> >> constant
> >>  { "param","tonemap parameter", OFFSET(param), 
> >> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
> >>
> >> ^
> >> src/libavfilter/vf_tonemap.c:314:87: note: (near initialization for 
> >> 'tonemap_options[8].default_val.dbl')
> >>
> >> Signed-off-by: James Almer 
> >> ---
> >>  libavfilter/vf_tonemap.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
> >> index 10308bdb16..d2c7ffa831 100644
> >> --- a/libavfilter/vf_tonemap.c
> >> +++ b/libavfilter/vf_tonemap.c
> >> @@ -311,7 +311,7 @@ static const AVOption tonemap_options[] = {
> >>  { "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD}, 
> >>  0, 0, FLAGS, "tonemap" },
> >>  { "hable",0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE},
> >>  0, 0, FLAGS, "tonemap" },
> >>  { "mobius",   0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS},   
> >>  0, 0, FLAGS, "tonemap" },
> >> -{ "param","tonemap parameter", OFFSET(param), 
> >> AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
> >> +{ "param","tonemap parameter", OFFSET(param), 
> >> AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, DBL_MIN, DBL_MAX, FLAGS },
> > 
> > building shared libs: (seems ok with static)
> > on linux x86-64
> > 
> > src/libavfilter/vf_tonemap.c:314:108: error: initializer element is not a 
> > compile-time constant
> > { "param", "tonemap parameter", __builtin_offsetof(TonemapContext, 
> > param), AV_OPT_TYPE_DOUBLE, {.dbl = nan("")}, 2.2250738585072014e-308, 
> > 1.7976931348623157e+308, 16 | (1<<16) },
> 
> What can we do, then? NAN and nan("") are sometimes compile-time
> constants and sometimes not, apparently depending on build type and
> target system.

using a finite value instead of NAN would avoid this problem
DBL_MIN or DBL_MAX may be options

[...]
-- 
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


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


[FFmpeg-devel] [PATCH] libavformat/matroskaenc.c: Write Tags element for WebM

2017-09-07 Thread Ivan Janatra
This is already supported per https://www.webmproject.org/docs/container/#Tags 
and 
https://github.com/nbirkbeck/matroska-specification/commit/28a54f991f118fff31fe6bfe256c2dfab46d00e5
---
 libavformat/matroskaenc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 9cc7be352e..5b70fead87 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1988,12 +1988,12 @@ static int mkv_write_header(AVFormatContext *s)
 ret = mkv_write_attachments(s);
 if (ret < 0)
 goto fail;
-
-ret = mkv_write_tags(s);
-if (ret < 0)
-goto fail;
 }
 
+ret = mkv_write_tags(s);
+if (ret < 0)
+goto fail;
+
 if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL) && !mkv->is_live)
 mkv_write_seekhead(pb, mkv);
 
-- 
2.14.1.581.gf28d330327-goog

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: factorize packet pts setter function

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 05:11:39PM +0200, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mxfdec.c | 52 
> +---
>  1 file changed, 29 insertions(+), 23 deletions(-)

LGTM

thx

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

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


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mxfdec: use the common packet pts setter function for opatom files

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 05:11:40PM +0200, Marton Balint wrote:
> Fixes ticket #6631.
> 
> Signed-off-by: Marton Balint 
> ---
>  libavformat/mxfdec.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)

please add a fate this if you push this

no more comments from me

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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


Re: [FFmpeg-devel] [PATCH 2/5] ffmpeg: rename a variable.

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 10:59:36AM +0200, Nicolas George wrote:
> Makes the reason of the "FIXME" comment more obvious.
> Avoid name conflicts for the next commit.
> 
> Signed-off-by: Nicolas George 
> ---
>  ffmpeg.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

LGTM

thx

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

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


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


Re: [FFmpeg-devel] [PATCH 3/5] ffmpeg: use reordered duration for stream PTS.

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 10:59:37AM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  ffmpeg.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)

probably ok

thanks

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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


Re: [FFmpeg-devel] [PATCH 5/5] ffmpeg: send EOF pts to filters.

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 10:59:39AM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  ffmpeg.c | 10 +++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

should be ok

thanks

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

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


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


[FFmpeg-devel] [PATCHv3] avformat/mpegts: opus muxing & demuxing for mapping family 255

2017-09-07 Thread pkv.stream

Hi,

I've removed inline declarations in the patch since they're not accepted 
in ffmpeg.


Thanks for any more comments or reviews.

Regards


From d05c62039b3edfd151b8c3824cc8f509f9ea8053 Mon Sep 17 00:00:00 2001
From: pkviet 
Date: Tue, 29 Aug 2017 01:24:12 +0200
Subject: [PATCH] avformat/mpegts: opus muxing & demuxing expanded

Support for opus in mpegts demuxer was brought by commit
9cfa68c560bdec82d2d5ec079f9c5b0f9ca37af0 (Kieran Kunhya).
Support for opus in mpegts muxer was then added by commit
01509cdf9287b975eced1fd609a8201fbd1438e3 (S. Droge).
Later commit 37941878f193a2316c514bd5ba55bfe9d2dfdfcf by Michael Graczyk
added support of mapping_family encoder parameter which allows for up to 255
audio channels (for family 255).
While matroska muxer & demuxer readily accepts mapping_family, it is not the
case for mpegts muxer & demuxer for all the range of the parameter (family 255
and also part of family 1 with channel_config_code > 0x81 unsupported).
This commit brings such a support.
---
 libavformat/mpegts.c| 64 ++---
 libavformat/mpegtsenc.c | 19 ++-
 2 files changed, 74 insertions(+), 9 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 4d2f5c6..fd2857c 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1633,7 +1633,7 @@ static const uint8_t opus_stream_cnt[9] = {
 1, 1, 1, 2, 2, 3, 4, 4, 5,
 };
 
-static const uint8_t opus_channel_map[8][8] = {
+static const uint8_t opus_channel_map_a[8][8] = {
 { 0 },
 { 0,1 },
 { 0,2,1 },
@@ -1644,6 +1644,17 @@ static const uint8_t opus_channel_map[8][8] = {
 { 0,6,1,2,3,4,5,7 },
 };
 
+static const uint8_t opus_channel_map_b[8][8] = {
+{ 0 },
+{ 0,1 },
+{ 0,1,2 },
+{ 0,1,2,3 },
+{ 0,1,2,3,4 },
+{ 0,1,2,3,4,5 },
+{ 0,1,2,3,4,5,6 },
+{ 0,1,2,3,4,5,6,7 },
+};
+
 int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int 
stream_type,
   const uint8_t **pp, const uint8_t *desc_list_end,
   Mp4Descr *mp4_descr, int mp4_descr_count, int 
pid,
@@ -1887,9 +1898,56 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 st->codecpar->extradata[18] = channel_config_code ? 
(channels > 2) : /* Dual Mono */ 255;
 st->codecpar->extradata[19] = 
opus_stream_cnt[channel_config_code];
 st->codecpar->extradata[20] = 
opus_coupled_stream_cnt[channel_config_code];
-memcpy(&st->codecpar->extradata[21], 
opus_channel_map[channels - 1], channels);
+memcpy(&st->codecpar->extradata[21], 
opus_channel_map_a[channels - 1], channels);
 } else {
-avpriv_request_sample(fc, "Opus in MPEG-TS - 
channel_config_code > 0x8");
+if (channel_config_code == 0x81) {
+channels = get8(pp, desc_end);
+st->codecpar->extradata_size = 22 + channels;
+size_t extradata_size;
+extradata_size = (22 + channels) * sizeof(uint8_t);
+uint8_t *extradata;
+extradata = av_malloc(extradata_size);
+if (!extradata)
+return AVERROR(ENOMEM);
+for (i = 0; i <= (22+channels); i++) {
+if (i < 9) {
+extradata[i] = opus_default_extradata[i];
+}
+else {
+extradata[i] = 0;
+}
+}
+memcpy(st->codecpar->extradata, extradata, 
sizeof(extradata));
+av_free(extradata);
+st->codecpar->extradata[9] = channels;
+st->codecpar->extradata[18] = 255;
+st->codecpar->extradata[19] = channels;
+st->codecpar->extradata[20] = 0;
+size_t channel_map_size = channels * sizeof(uint8_t);
+uint8_t *opus_channel_map255;
+opus_channel_map255 = av_malloc(channel_map_size);
+if (!opus_channel_map255)
+return AVERROR(ENOMEM);
+uint8_t j;
+for (j = 0; j < channels; j++) {
+opus_channel_map255[j] = j;
+}
+memcpy(&st->codecpar->extradata[21], 
opus_channel_map255, channels);
+av_free(opus_channel_map255);
+} else {
+if ((channel_config_code >= 0x82) && 
(channel_config_code <= 0x88)) {
+channels = get8(pp, desc_end);
+st->codecpar->extrad

[FFmpeg-devel] [PATCH] avcodec/hevc_ps: improve check for missing default display window bitstream

2017-09-07 Thread James Almer
Fixes ticket #6644

Signed-off-by: James Almer 
---
 libavcodec/hevc_ps.c | 33 +++--
 1 file changed, 27 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index ee31cc093c..eb104ca1b9 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -550,7 +550,7 @@ err:
 static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
int apply_defdispwin, HEVCSPS *sps)
 {
-VUI *vui  = &sps->vui;
+VUI backup_vui, *vui = &sps->vui;
 GetBitContext backup;
 int sar_present, alt = 0;
 
@@ -618,13 +618,14 @@ static void decode_vui(GetBitContext *gb, AVCodecContext 
*avctx,
 vui->field_seq_flag= get_bits1(gb);
 vui->frame_field_info_present_flag = get_bits1(gb);
 
+// Backup context in case an alternate header is detected
+memcpy(&backup, gb, sizeof(backup));
+memcpy(&backup_vui, vui, sizeof(backup_vui));
 if (get_bits_left(gb) >= 68 && show_bits_long(gb, 21) == 0x10) {
 vui->default_display_window_flag = 0;
 av_log(avctx, AV_LOG_WARNING, "Invalid default display window\n");
 } else
 vui->default_display_window_flag = get_bits1(gb);
-// Backup context in case an alternate header is detected
-memcpy(&backup, gb, sizeof(backup));
 
 if (vui->default_display_window_flag) {
 int vert_mult  = 1 + (sps->chroma_format_idc < 2);
@@ -651,18 +652,19 @@ static void decode_vui(GetBitContext *gb, AVCodecContext 
*avctx,
 }
 }
 
+timing_info:
 vui->vui_timing_info_present_flag = get_bits1(gb);
 
 if (vui->vui_timing_info_present_flag) {
-if( get_bits_left(gb) < 66) {
+if( get_bits_left(gb) < 66 && !alt) {
 // The alternate syntax seem to have timing info located
 // at where def_disp_win is normally located
 av_log(avctx, AV_LOG_WARNING,
"Strange VUI timing information, retrying...\n");
-vui->default_display_window_flag = 0;
-memset(&vui->def_disp_win, 0, sizeof(vui->def_disp_win));
+memcpy(vui, &backup_vui, sizeof(backup_vui));
 memcpy(gb, &backup, sizeof(backup));
 alt = 1;
+goto timing_info;
 }
 vui->vui_num_units_in_tick   = get_bits_long(gb, 32);
 vui->vui_time_scale  = get_bits_long(gb, 32);
@@ -680,6 +682,15 @@ static void decode_vui(GetBitContext *gb, AVCodecContext 
*avctx,
 
 vui->bitstream_restriction_flag = get_bits1(gb);
 if (vui->bitstream_restriction_flag) {
+if (get_bits_left(gb) < 8 && !alt) {
+av_log(avctx, AV_LOG_WARNING,
+   "Strange VUI bitstream restriction information, retrying"
+   " from timing information...\n");
+memcpy(vui, &backup_vui, sizeof(backup_vui));
+memcpy(gb, &backup, sizeof(backup));
+alt = 1;
+goto timing_info;
+}
 vui->tiles_fixed_structure_flag  = get_bits1(gb);
 vui->motion_vectors_over_pic_boundaries_flag = get_bits1(gb);
 vui->restricted_ref_pic_lists_flag   = get_bits1(gb);
@@ -689,6 +700,16 @@ static void decode_vui(GetBitContext *gb, AVCodecContext 
*avctx,
 vui->log2_max_mv_length_horizontal   = get_ue_golomb_long(gb);
 vui->log2_max_mv_length_vertical = get_ue_golomb_long(gb);
 }
+
+if (get_bits_left(gb) < 1 && !alt) {
+// XXX: Alternate syntax when sps_range_extension_flag != 0?
+av_log(avctx, AV_LOG_WARNING,
+   "Overread in VUI, retrying from timing information...\n");
+memcpy(vui, &backup_vui, sizeof(backup_vui));
+memcpy(gb, &backup, sizeof(backup));
+alt = 1;
+goto timing_info;
+}
 }
 
 static void set_default_scaling_list_data(ScalingList *sl)
-- 
2.13.3

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


Re: [FFmpeg-devel] [PATCH] libavcodec/h264_parse: don't use uninitialized value when chroma_format_idc==0

2017-09-07 Thread Michael Niedermayer
On Thu, Sep 07, 2017 at 09:42:07AM -0400, Mark Wachsler wrote:
> When parsing a monochrome file, chroma_log2_weight_denom was used without
> being initialized, which could lead to a bogus error message being printed, 
> e.g.
>   [h264 @ 0x61a26480] chroma_log2_weight_denom 24576 is out of range
> It also could led to warnings using AddressSanitizer.
> ---
>  libavcodec/h264_parse.c | 27 +++
>  1 file changed, 15 insertions(+), 12 deletions(-)

applied

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH] configure: Fix DEF file post-processing with LTO enabled.

2017-09-07 Thread Michael Niedermayer
On Wed, Sep 06, 2017 at 08:03:18PM +0200, Kacper Michajlow wrote:
> 2017-08-22 21:26 GMT+02:00 Kacper Michajłow :
> 
> > With LTO enabled exported symbol entry looks like:
> > av_audio_convert @3 DATA
> >
> > In order to maintain valid format we need to strip everything after @.
> >
> > This patch fixes linking libraries compiled with MinGW toolchain with LTO
> > enabled.
> >
> > Signed-off-by: Kacper Michajłow 
> > ---
> >  configure | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >
> Bump after two weeks.

in absence of anyone else applying this.

can you provide a testcase / command line to reproduce the issue
this fixes
maybe if its easy to reproduce it will get a reply sooner

thxs

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


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


Re: [FFmpeg-devel] [FFmpeg-cvslog] FATE: Add FITS tests

2017-09-07 Thread Michael Niedermayer
On Wed, Aug 30, 2017 at 10:20:32AM +, Paras Chadha wrote:
> ffmpeg | branch: master | Paras Chadha  | Tue Aug 29 
> 23:24:42 2017 +0530| [9d99f0afbeedf3e170478c3e8c05789bf2eef48f] | committer: 
> Paul B Mahol
> 
> FATE: Add FITS tests
> 
> Signed-off-by: Paras Chadha 
> 
> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9d99f0afbeedf3e170478c3e8c05789bf2eef48f
> ---
> 
>  tests/Makefile  |  1 +
>  tests/fate/avformat.mak |  1 +
>  tests/fate/demux.mak|  4 +++
>  tests/fate/fits.mak | 59 
> +
>  tests/lavf-regression.sh|  9 +
>  tests/ref/fate/fits-demux   | 10 ++
>  tests/ref/fate/fitsdec-bitpix-32|  6 
>  tests/ref/fate/fitsdec-bitpix-64|  6 
>  tests/ref/fate/fitsdec-blank_bitpix32   |  6 
>  tests/ref/fate/fitsdec-ext_data_min_max |  6 
>  tests/ref/fate/fitsdec-gbrap16  |  6 
>  tests/ref/fate/fitsdec-gbrp |  6 
>  tests/ref/fate/fitsdec-gbrp16   |  6 
>  tests/ref/fate/fitsdec-gray |  6 
>  tests/ref/fate/fitsdec-multi| 10 ++
>  tests/ref/fate/fitsenc-gbrap| 10 ++
>  tests/ref/fate/fitsenc-gbrap16be| 10 ++
>  tests/ref/fate/fitsenc-gbrp | 10 ++
>  tests/ref/fate/fitsenc-gbrp16be | 10 ++
>  tests/ref/fate/fitsenc-gray | 10 ++
>  tests/ref/fate/fitsenc-gray16be | 10 ++
>  tests/ref/lavf/fits | 18 ++
>  22 files changed, 220 insertions(+)
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index 30f05bec15..18fe9c5b4a 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -131,6 +131,7 @@ include $(SRC_PATH)/tests/fate/fft.mak
>  include $(SRC_PATH)/tests/fate/fifo-muxer.mak
>  include $(SRC_PATH)/tests/fate/filter-audio.mak
>  include $(SRC_PATH)/tests/fate/filter-video.mak
> +include $(SRC_PATH)/tests/fate/fits.mak
>  include $(SRC_PATH)/tests/fate/flac.mak
>  include $(SRC_PATH)/tests/fate/flvenc.mak
>  include $(SRC_PATH)/tests/fate/gapless.mak
> diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
> index 82a531c7a5..c4cf2bc473 100644
> --- a/tests/fate/avformat.mak
> +++ b/tests/fate/avformat.mak
> @@ -10,6 +10,7 @@ FATE_LAVF-$(call ENCDEC,  PCM_S16BE, CAF)   
>  += caf
>  FATE_LAVF-$(call ENCDEC,  DPX,   IMAGE2) += dpx
>  FATE_LAVF-$(call ENCDEC2, DVVIDEO,PCM_S16LE, AVI)+= 
> dv_fmt
>  FATE_LAVF-$(call ENCDEC2, MPEG1VIDEO, MP2,   FFM)+= ffm
> +FATE_LAVF-$(call ENCDEC,  FITS,  IMAGE2) += fits
>  FATE_LAVF-$(call ENCDEC,  RAWVIDEO,  FILMSTRIP)  += flm
>  FATE_LAVF-$(call ENCDEC,  FLV,   FLV)+= 
> flv_fmt
>  FATE_LAVF-$(call ENCDEC,  GIF,   IMAGE2) += gif
> diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
> index 8a2703fc84..261b004d69 100644
> --- a/tests/fate/demux.mak
> +++ b/tests/fate/demux.mak
> @@ -36,6 +36,10 @@ fate-d-cinema-demux: CMD = framecrc -i 
> $(TARGET_SAMPLES)/d-cinema/THX_Science_FL
>  FATE_SAMPLES_DEMUX-$(CONFIG_EA_DEMUXER) += fate-d-eavp6-demux
>  fate-d-eavp6-demux: CMD = framecrc -i $(TARGET_SAMPLES)/ea-vp6/SmallRing.vp6 
> -map 0 -vcodec copy
>  
> +FATE_SAMPLES_DEMUX-$(CONFIG_FITS_DEMUXER) += fate-fits-demux
> +fate-fits-demux: tests/data/fits-multi.fits
> +fate-fits-demux: CMD = framecrc -i $(TARGET_PATH)/tests/data/fits-multi.fits 
> -vcodec copy
> +
>  FATE_SAMPLES_DEMUX-$(CONFIG_FLV_DEMUXER) += fate-flv-demux
>  fate-flv-demux: CMD = framecrc -i 
> $(TARGET_SAMPLES)/flv/Enigma_Principles_of_Lust-part.flv -codec copy
>  
> diff --git a/tests/fate/fits.mak b/tests/fate/fits.mak
> new file mode 100644
> index 00..bc1b771a52
> --- /dev/null
> +++ b/tests/fate/fits.mak

> @@ -0,0 +1,59 @@
> +tests/data/fits-multi.fits: TAG = GEN
> +tests/data/fits-multi.fits: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
> + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
> +-i $(TARGET_SAMPLES)/gif/m4nb.gif \
> +-y $(TARGET_PATH)/$(@) 2>/dev/null
> +
> +#mapping of fits file formats to png filenames
> +map.tests/data/lena-gray.fits:= gray8
> +map.tests/data/lena-gbrp.fits:= rgb24
> +map.tests/data/lena-gbrp16.fits  := rgb48
> +map.tests/data/lena-gbrap16.fits := rgba64
> +
> +tests/data/lena%.fits: TAG = GEN
> +tests/data/lena%.fits: NAME = $(map.$(@))

> +tests/data/lena%.fits: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
> + $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
> +-i $(TARGET_SAMPLES)/png1/lena-$(map.$(@)).png \
> +-y $(TARGET_PATH)/$(@) 2>/dev/null

This is missing png dependancies or should not use a png file


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

No great genius has ever existed without some touch of madness. -- Ar

Re: [FFmpeg-devel] [PATCH] fate: add test for asetnsamples filter with padding disabled

2017-09-07 Thread Michael Niedermayer
On Tue, Sep 05, 2017 at 03:13:15PM +0200, Tobias Rapp wrote:
> Adds another test for asetnsamples filter where padding of the last
> frame is switched off. Renames the existing test to make the difference
> obvious.
> 
> Signed-off-by: Tobias Rapp 
> ---
>  tests/fate/filter-audio.mak | 13 
> +
>  .../fate/{filter-asetnsamples => filter-asetnsamples-nopad} |  2 +-
>  .../fate/{filter-asetnsamples => filter-asetnsamples-pad}   |  0
>  3 files changed, 10 insertions(+), 5 deletions(-)
>  copy tests/ref/fate/{filter-asetnsamples => filter-asetnsamples-nopad} (99%)
>  rename tests/ref/fate/{filter-asetnsamples => filter-asetnsamples-pad} (100%)

tested on linux x86-32 / 64, mips + migw32/64


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

Democracy is the form of government in which you can choose your dictator


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