Re: [FFmpeg-devel] [PATCH] avfilter/vf_tile: add skip option

2017-11-11 Thread Nicolas George
Le septidi 17 brumaire, an CCXXVI, Paul B Mahol a écrit :
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  5 +
>  libavfilter/vf_tile.c | 53 
> ++-
>  2 files changed, 49 insertions(+), 9 deletions(-)

The logic of the code looks ok to me.

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] avfilter/vf_tile: add skip option

2017-11-10 Thread Nicolas George
Le decadi 20 brumaire, an CCXXVI, Paul B Mahol a écrit :
> Yes.

Ok, I will look at the code with that in mind.

> What if user sets overlap to same or greater than nb_frames, just error out?

That seems reasonable. Clamping the value with a warning would be ok
too, I think. Both of these solutions allow extension.

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] avfilter/vf_tile: add skip option

2017-11-10 Thread Paul B Mahol
On 11/10/17, Nicolas George  wrote:
> Le septidi 17 brumaire, an CCXXVI, Paul B Mahol a ecrit :
>> Signed-off-by: Paul B Mahol 
>> ---
>>  doc/filters.texi  |  5 +
>>  libavfilter/vf_tile.c | 53
>> ++-
>>  2 files changed, 49 insertions(+), 9 deletions(-)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 2ba6e04166..a6d537485b 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -14439,6 +14439,11 @@ refer to the pad video filter.
>>  Specify the color of the unused area. For the syntax of this option,
>> check the
>>  "Color" section in the ffmpeg-utils manual. The default value of
>> @var{color}
>>  is "black".
>> +
>
>> +@item skip
>> +Set the number of frames to skip from input before rendering output
>> frame.
>> +The default value is @code{0}, meaning skip @var{nb_frames} frames. If it
>> is more
>> +than @var{nb_frames} its is set to @var{nb_frames}.
>
> I had trouble understanding the logic of the code, until I realized the
> problem was here: I think the documentation does not explain well what
> the option is meant to do.
>
> If I understand correctly, using an example: if a 5x4 tile, the normal
> mapping is:
>
> out  0 <- in  0 .. in 19
> out  1 <- in 20 .. in 39
> out  2 <- in 40 .. in 59
> out  3 <- in 60 .. in 79
>
> But if "skip" is set to 15, it becomes:
>
> out  0 <- in  0 .. in 19
> out  1 <- in 15 .. in 34
> out  2 <- in 30 .. in 49
> out  3 <- in 45 .. in 64
>
> In other words, the output frames overlap by nb_frames - skip input
> frames.
>
> Is it what you intended?

Yes.

>
> If so, then the doc needs to be clarified. And I think the name of the
> option is misleading. What about "step"? Or maybe "period"?

It could be...

>
> Or possibly even better: reverse the direction of the option "overlap=5"
> instead of "step=15".

What if user sets overlap to same or greater than nb_frames, just error out?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_tile: add skip option

2017-11-10 Thread Nicolas George
Le septidi 17 brumaire, an CCXXVI, Paul B Mahol a écrit :
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  5 +
>  libavfilter/vf_tile.c | 53 
> ++-
>  2 files changed, 49 insertions(+), 9 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 2ba6e04166..a6d537485b 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -14439,6 +14439,11 @@ refer to the pad video filter.
>  Specify the color of the unused area. For the syntax of this option, check 
> the
>  "Color" section in the ffmpeg-utils manual. The default value of @var{color}
>  is "black".
> +

> +@item skip
> +Set the number of frames to skip from input before rendering output frame.
> +The default value is @code{0}, meaning skip @var{nb_frames} frames. If it is 
> more
> +than @var{nb_frames} its is set to @var{nb_frames}.

I had trouble understanding the logic of the code, until I realized the
problem was here: I think the documentation does not explain well what
the option is meant to do.

If I understand correctly, using an example: if a 5x4 tile, the normal
mapping is:

out  0 <- in  0 .. in 19
out  1 <- in 20 .. in 39
out  2 <- in 40 .. in 59
out  3 <- in 60 .. in 79

But if "skip" is set to 15, it becomes:

out  0 <- in  0 .. in 19
out  1 <- in 15 .. in 34
out  2 <- in 30 .. in 49
out  3 <- in 45 .. in 64

In other words, the output frames overlap by nb_frames - skip input
frames.

Is it what you intended?

If so, then the doc needs to be clarified. And I think the name of the
option is misleading. What about "step"? Or maybe "period"?

Or possibly even better: reverse the direction of the option "overlap=5"
instead of "step=15".

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] avfilter/vf_tile: add skip option

2017-11-09 Thread Nicolas George
Le nonidi 19 brumaire, an CCXXVI, Paul B Mahol a écrit :
> ping

Please, it has not yet been 48 hours. I cannot promise to have time to
look at it carefully enough before Sunday.

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] avfilter/vf_tile: add skip option

2017-11-09 Thread Paul B Mahol
On 11/7/17, Paul B Mahol  wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  5 +
>  libavfilter/vf_tile.c | 53
> ++-
>  2 files changed, 49 insertions(+), 9 deletions(-)
>

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


[FFmpeg-devel] [PATCH] avfilter/vf_tile: add skip option

2017-11-07 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  5 +
 libavfilter/vf_tile.c | 53 ++-
 2 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2ba6e04166..a6d537485b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14439,6 +14439,11 @@ refer to the pad video filter.
 Specify the color of the unused area. For the syntax of this option, check the
 "Color" section in the ffmpeg-utils manual. The default value of @var{color}
 is "black".
+
+@item skip
+Set the number of frames to skip from input before rendering output frame.
+The default value is @code{0}, meaning skip @var{nb_frames} frames. If it is 
more
+than @var{nb_frames} its is set to @var{nb_frames}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index e9d246fc73..089872831f 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -37,11 +37,13 @@ typedef struct TileContext {
 unsigned w, h;
 unsigned margin;
 unsigned padding;
+unsigned skip;
 unsigned current;
 unsigned nb_frames;
 FFDrawContext draw;
 FFDrawColor blank;
 AVFrame *out_ref;
+AVFrame *prev_out_ref;
 uint8_t rgba_color[4];
 } TileContext;
 
@@ -58,6 +60,8 @@ static const AVOption tile_options[] = {
 { "padding", "set inner border thickness in pixels", OFFSET(padding),
 AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1024, FLAGS },
 { "color",   "set the color of the unused area", OFFSET(rgba_color), 
AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
+{ "skip", "set how many frames to skip for each render", OFFSET(skip),
+AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
 { NULL }
 };
 
@@ -90,6 +94,10 @@ static av_cold int init(AVFilterContext *ctx)
 return AVERROR(EINVAL);
 }
 
+if (!tile->skip)
+tile->skip = tile->nb_frames;
+tile->skip = FFMIN(tile->skip, tile->nb_frames);
+
 return 0;
 }
 
@@ -120,19 +128,19 @@ static int config_props(AVFilterLink *outlink)
 outlink->h = tile->h * inlink->h + total_margin_h;
 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
 outlink->frame_rate = av_mul_q(inlink->frame_rate,
-   av_make_q(1, tile->nb_frames));
+   av_make_q(1, tile->skip));
 ff_draw_init(>draw, inlink->format, 0);
 ff_draw_color(>draw, >blank, tile->rgba_color);
 
 return 0;
 }
 
-static void get_current_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned 
*y)
+static void get_tile_pos(AVFilterContext *ctx, unsigned *x, unsigned *y, 
unsigned current)
 {
 TileContext *tile= ctx->priv;
 AVFilterLink *inlink = ctx->inputs[0];
-const unsigned tx = tile->current % tile->w;
-const unsigned ty = tile->current / tile->w;
+const unsigned tx = current % tile->w;
+const unsigned ty = current / tile->w;
 
 *x = tile->margin + (inlink->w + tile->padding) * tx;
 *y = tile->margin + (inlink->h + tile->padding) * ty;
@@ -144,7 +152,7 @@ static void draw_blank_frame(AVFilterContext *ctx, AVFrame 
*out_buf)
 AVFilterLink *inlink = ctx->inputs[0];
 unsigned x0, y0;
 
-get_current_tile_pos(ctx, , );
+get_tile_pos(ctx, , , tile->current);
 ff_fill_rectangle(>draw, >blank,
   out_buf->data, out_buf->linesize,
   x0, y0, inlink->w, inlink->h);
@@ -160,8 +168,13 @@ static int end_last_frame(AVFilterContext *ctx)
 
 while (tile->current < tile->nb_frames)
 draw_blank_frame(ctx, out_buf);
+tile->current = tile->nb_frames - tile->skip;
+if (tile->current) {
+av_frame_free(>prev_out_ref);
+tile->prev_out_ref = av_frame_clone(out_buf);
+}
 ret = ff_filter_frame(outlink, out_buf);
-tile->current = 0;
+tile->out_ref = NULL;
 return ret;
 }
 
@@ -176,7 +189,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 AVFilterLink *outlink = ctx->outputs[0];
 unsigned x0, y0;
 
-if (!tile->current) {
+if (!tile->out_ref) {
 tile->out_ref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!tile->out_ref) {
 av_frame_free();
@@ -194,7 +207,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
   0, 0, outlink->w, outlink->h);
 }
 
-get_current_tile_pos(ctx, , );
+if (tile->prev_out_ref) {
+unsigned x1, y1, i;
+
+for (i = tile->skip; i < tile->nb_frames; i++) {
+get_tile_pos(ctx, , , i);
+get_tile_pos(ctx, , , i - tile->skip);
+ff_copy_rectangle2(>draw,
+   tile->out_ref->data, tile->out_ref->linesize,
+   tile->prev_out_ref->data, 
tile->prev_out_ref->linesize,
+   x0, y0, x1, y1, inlink->w, inlink->h);
+
+}
+}
+
+