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

2017-12-01 Thread Nicolas George
Paul B Mahol (2017-11-30):
> I like nano-optimizations!

If it makes the code negligibly faster at the cost of making it more
complex, it is a nano-optimization. In this case, since it makes the
code both simpler and faster, it is just better coding.

> Should I commit with that changed or send another one for review?

Go ahead.

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 init_padding option

2017-11-30 Thread Paul B Mahol
On 11/30/17, Nicolas George  wrote:
> Moritz Barsnick (2017-11-30):
>> Wouldn't
>>tile->first_frame = 0;
>> be faster and easier? Or did you mean to use different variables in the
>> check and the assignment?
>
> Or even clearing the option after is has been used. Single test, single
> field: faster, less memory, less code.

I like nano-optimizations!

Should I commit with that changed or send another one for review?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-11-30 Thread Nicolas George
Moritz Barsnick (2017-11-30):
> Wouldn't
>tile->first_frame = 0;
> be faster and easier? Or did you mean to use different variables in the
> check and the assignment?

Or even clearing the option after is has been used. Single test, single
field: faster, less memory, less 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] [PATCH] avfilter/vf_tile: add init_padding option

2017-11-30 Thread Moritz Barsnick
On Wed, Nov 29, 2017 at 20:29:49 +0100, Paul B Mahol wrote:
> +{ "init_padding", " set how many frames to initially pad", 
> OFFSET(init_padding),
  ^ space
Some whitespace slipped in there. 

> +if (tile->first_frame)
> +tile->first_frame = 0;

Wouldn't
   tile->first_frame = 0;
be faster and easier? Or did you mean to use different variables in the
check and the assignment?

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


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

2017-11-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  5 +
 libavfilter/vf_tile.c | 16 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 4a4efc70c8..ec37b9dcb8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14637,6 +14637,11 @@ is "black".
 @item overlap
 Set the number of frames to overlap when tiling several successive frames 
together.
 The value must be between @code{0} and @var{nb_frames - 1}.
+
+@item init_padding
+Set the number of frames to initially be empty before displaying first output 
frame.
+This controls how soon will one get first output frame.
+The value must be between @code{0} and @var{nb_frames - 1}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 7717ce12e7..924cfe77bb 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -38,6 +38,8 @@ typedef struct TileContext {
 unsigned margin;
 unsigned padding;
 unsigned overlap;
+unsigned init_padding;
+unsigned first_frame;
 unsigned current;
 unsigned nb_frames;
 FFDrawContext draw;
@@ -62,6 +64,8 @@ static const AVOption tile_options[] = {
 { "color",   "set the color of the unused area", OFFSET(rgba_color), 
AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
 { "overlap", "set how many frames to overlap for each render", 
OFFSET(overlap),
 AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+{ "init_padding", " set how many frames to initially pad", 
OFFSET(init_padding),
+AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
 { NULL }
 };
 
@@ -99,6 +103,13 @@ static av_cold int init(AVFilterContext *ctx)
 tile->overlap = tile->nb_frames - 1;
 }
 
+if (tile->init_padding >= tile->nb_frames) {
+av_log(ctx, AV_LOG_WARNING, "init_padding must be less than %d\n", 
tile->nb_frames);
+} else {
+tile->current = tile->init_padding;
+}
+tile->first_frame = 1;
+
 return 0;
 }
 
@@ -201,11 +212,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 tile->out_ref->height = outlink->h;
 
 /* fill surface once for margin/padding */
-if (tile->margin || tile->padding)
+if (tile->margin || tile->padding ||
+(tile->init_padding != 0 && tile->first_frame))
 ff_fill_rectangle(>draw, >blank,
   tile->out_ref->data,
   tile->out_ref->linesize,
   0, 0, outlink->w, outlink->h);
+if (tile->first_frame)
+tile->first_frame = 0;
 }
 
 if (tile->prev_out_ref) {
-- 
2.11.0

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


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

2017-11-29 Thread Nicolas George
Paul B Mahol (2017-11-29):
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  4 
>  libavfilter/vf_tile.c | 12 +++-
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 4a4efc70c8..4eb302448b 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -14637,6 +14637,10 @@ is "black".
>  @item overlap
>  Set the number of frames to overlap when tiling several successive frames 
> together.
>  The value must be between @code{0} and @var{nb_frames - 1}.
> +
> +@item init_padding

> +Set the number of input frames to initially pad before displaying first 
> output frame.

Even knowing what it is supposed to mean I cannot parse this sentence.

> +The value must be between @code{0} and @var{nb_frames - 1}.
>  @end table
>  
>  @subsection Examples
> diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
> index 7717ce12e7..c347939cce 100644
> --- a/libavfilter/vf_tile.c
> +++ b/libavfilter/vf_tile.c
> @@ -38,6 +38,7 @@ typedef struct TileContext {
>  unsigned margin;
>  unsigned padding;
>  unsigned overlap;
> +unsigned init_padding;
>  unsigned current;
>  unsigned nb_frames;
>  FFDrawContext draw;
> @@ -62,6 +63,8 @@ static const AVOption tile_options[] = {
>  { "color",   "set the color of the unused area", OFFSET(rgba_color), 
> AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
>  { "overlap", "set how many frames to overlap for each render", 
> OFFSET(overlap),
>  AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
> +{ "init_padding", " set how many frames to initially pad", 
> OFFSET(init_padding),
> +AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
>  { NULL }
>  };
>  
> @@ -99,6 +102,12 @@ static av_cold int init(AVFilterContext *ctx)
>  tile->overlap = tile->nb_frames - 1;
>  }
>  
> +if (tile->init_padding >= tile->nb_frames) {
> +av_log(ctx, AV_LOG_WARNING, "init_padding must be less than %d\n", 
> tile->nb_frames);
> +} else {
> +tile->current = tile->init_padding;
> +}
> +
>  return 0;
>  }
>  
> @@ -201,7 +210,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *picref)
>  tile->out_ref->height = outlink->h;
>  
>  /* fill surface once for margin/padding */
> -if (tile->margin || tile->padding)
> +if (tile->margin || tile->padding ||

> +(tile->init_padding != 0 && !tile->prev_out_ref))

Incorrect, prev_out_ref is only set if overlap is non-zero.

>  ff_fill_rectangle(>draw, >blank,
>tile->out_ref->data,
>tile->out_ref->linesize,

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

2017-11-29 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  4 
 libavfilter/vf_tile.c | 12 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 4a4efc70c8..4eb302448b 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14637,6 +14637,10 @@ is "black".
 @item overlap
 Set the number of frames to overlap when tiling several successive frames 
together.
 The value must be between @code{0} and @var{nb_frames - 1}.
+
+@item init_padding
+Set the number of input frames to initially pad before displaying first output 
frame.
+The value must be between @code{0} and @var{nb_frames - 1}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 7717ce12e7..c347939cce 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -38,6 +38,7 @@ typedef struct TileContext {
 unsigned margin;
 unsigned padding;
 unsigned overlap;
+unsigned init_padding;
 unsigned current;
 unsigned nb_frames;
 FFDrawContext draw;
@@ -62,6 +63,8 @@ static const AVOption tile_options[] = {
 { "color",   "set the color of the unused area", OFFSET(rgba_color), 
AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
 { "overlap", "set how many frames to overlap for each render", 
OFFSET(overlap),
 AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+{ "init_padding", " set how many frames to initially pad", 
OFFSET(init_padding),
+AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
 { NULL }
 };
 
@@ -99,6 +102,12 @@ static av_cold int init(AVFilterContext *ctx)
 tile->overlap = tile->nb_frames - 1;
 }
 
+if (tile->init_padding >= tile->nb_frames) {
+av_log(ctx, AV_LOG_WARNING, "init_padding must be less than %d\n", 
tile->nb_frames);
+} else {
+tile->current = tile->init_padding;
+}
+
 return 0;
 }
 
@@ -201,7 +210,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 tile->out_ref->height = outlink->h;
 
 /* fill surface once for margin/padding */
-if (tile->margin || tile->padding)
+if (tile->margin || tile->padding ||
+(tile->init_padding != 0 && !tile->prev_out_ref))
 ff_fill_rectangle(>draw, >blank,
   tile->out_ref->data,
   tile->out_ref->linesize,
-- 
2.11.0

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


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

2017-11-26 Thread Nicolas George
Paul B Mahol (2017-11-24):
> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi  |  4 
>  libavfilter/vf_tile.c | 12 +++-
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 76929e4db5..11ce0482c2 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -14497,6 +14497,10 @@ is "black".
>  @item overlap
>  Set the number of frames to overlap when tiling several successive frames 
> together.
>  The value must be between @code{0} and @var{nb_frames - 1}.
> +

> +@item init_padding
> +Set the number of input frames to initially consume before displaying first 
> output frame.
> +The value must be between @code{0} and @var{nb_frames - 1}.

The documentations says that, the code does the opposite.

>  @end table
>  
>  @subsection Examples
> diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
> index 7717ce12e7..c78fa611dd 100644
> --- a/libavfilter/vf_tile.c
> +++ b/libavfilter/vf_tile.c
> @@ -38,6 +38,7 @@ typedef struct TileContext {
>  unsigned margin;
>  unsigned padding;
>  unsigned overlap;
> +unsigned init_padding;
>  unsigned current;
>  unsigned nb_frames;
>  FFDrawContext draw;
> @@ -62,6 +63,8 @@ static const AVOption tile_options[] = {
>  { "color",   "set the color of the unused area", OFFSET(rgba_color), 
> AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
>  { "overlap", "set how many frames to overlap for each render", 
> OFFSET(overlap),
>  AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
> +{ "init_padding", " set how many frames to initially pad", 
> OFFSET(init_padding),
> +AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
>  { NULL }
>  };
>  
> @@ -99,6 +102,13 @@ static av_cold int init(AVFilterContext *ctx)
>  tile->overlap = tile->nb_frames - 1;
>  }
>  
> +if (tile->init_padding >= tile->nb_frames) {
> +av_log(ctx, AV_LOG_WARNING, "init_padding must be less than %d\n", 
> tile->nb_frames);

> +tile->current = 0;

Unnecessary and confusing.

> +} else {
> +tile->current = tile->init_padding;
> +}
> +
>  return 0;
>  }
>  
> @@ -201,7 +211,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *picref)
>  tile->out_ref->height = outlink->h;
>  
>  /* fill surface once for margin/padding */

> -if (tile->margin || tile->padding)
> +if (tile->margin || tile->padding || tile->init_padding != 0)

This change should only be applied to the first frame.

>  ff_fill_rectangle(>draw, >blank,
>tile->out_ref->data,
>tile->out_ref->linesize,

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

2017-11-24 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  4 
 libavfilter/vf_tile.c | 12 +++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 76929e4db5..11ce0482c2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14497,6 +14497,10 @@ is "black".
 @item overlap
 Set the number of frames to overlap when tiling several successive frames 
together.
 The value must be between @code{0} and @var{nb_frames - 1}.
+
+@item init_padding
+Set the number of input frames to initially consume before displaying first 
output frame.
+The value must be between @code{0} and @var{nb_frames - 1}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 7717ce12e7..c78fa611dd 100644
--- a/libavfilter/vf_tile.c
+++ b/libavfilter/vf_tile.c
@@ -38,6 +38,7 @@ typedef struct TileContext {
 unsigned margin;
 unsigned padding;
 unsigned overlap;
+unsigned init_padding;
 unsigned current;
 unsigned nb_frames;
 FFDrawContext draw;
@@ -62,6 +63,8 @@ static const AVOption tile_options[] = {
 { "color",   "set the color of the unused area", OFFSET(rgba_color), 
AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
 { "overlap", "set how many frames to overlap for each render", 
OFFSET(overlap),
 AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
+{ "init_padding", " set how many frames to initially pad", 
OFFSET(init_padding),
+AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
 { NULL }
 };
 
@@ -99,6 +102,13 @@ static av_cold int init(AVFilterContext *ctx)
 tile->overlap = tile->nb_frames - 1;
 }
 
+if (tile->init_padding >= tile->nb_frames) {
+av_log(ctx, AV_LOG_WARNING, "init_padding must be less than %d\n", 
tile->nb_frames);
+tile->current = 0;
+} else {
+tile->current = tile->init_padding;
+}
+
 return 0;
 }
 
@@ -201,7 +211,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 tile->out_ref->height = outlink->h;
 
 /* fill surface once for margin/padding */
-if (tile->margin || tile->padding)
+if (tile->margin || tile->padding || tile->init_padding != 0)
 ff_fill_rectangle(>draw, >blank,
   tile->out_ref->data,
   tile->out_ref->linesize,
-- 
2.11.0

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