]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_tile: add init_padding option
authorPaul B Mahol <onemda@gmail.com>
Fri, 17 Nov 2017 20:33:37 +0000 (21:33 +0100)
committerPaul B Mahol <onemda@gmail.com>
Fri, 1 Dec 2017 09:55:30 +0000 (10:55 +0100)
Signed-off-by: Paul B Mahol <onemda@gmail.com>
doc/filters.texi
libavfilter/vf_tile.c

index 4a4efc70c8ca9c8d46d5c14ab9a3244bb639ea73..ec37b9dcb869f70c6cc0f12e0927b4afeb2133e5 100644 (file)
@@ -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
index 7717ce12e72eb9ac4beed44732e3db75314554e6..439689a14d4663468e24aa0b2aca9f3515e42f03 100644 (file)
@@ -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,11 +210,12 @@ 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)
             ff_fill_rectangle(&tile->draw, &tile->blank,
                               tile->out_ref->data,
                               tile->out_ref->linesize,
                               0, 0, outlink->w, outlink->h);
+        tile->init_padding = 0;
     }
 
     if (tile->prev_out_ref) {