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

Paul B Mahol onemda at gmail.com
Fri Nov 17 22:34:37 EET 2017


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 doc/filters.texi      |  4 ++++
 libavfilter/vf_tile.c | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 5d99437871..7eeeafab8e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14461,6 +14461,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}.
+
+ at item queue
+Set the number of frames to initially queue when displaying first frame.
+The value must be between @code{0} and @var{nb_frames}.
 @end table
 
 @subsection Examples
diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
index 7717ce12e7..dfc9377569 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 queue;
     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 },
+    { "queue", " set how many frames to initially queue", OFFSET(queue),
+        AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
     { NULL }
 };
 
@@ -99,6 +102,19 @@ static av_cold int init(AVFilterContext *ctx)
         tile->overlap = tile->nb_frames - 1;
     }
 
+    if (!tile->queue) {
+        tile->queue = tile->nb_frames;
+        tile->current = 0;
+    } else {
+        if (tile->queue > tile->nb_frames) {
+            av_log(ctx, AV_LOG_WARNING, "queue must be less than or equal to %d\n", tile->nb_frames);
+            tile->queue = tile->nb_frames;
+            tile->current = 0;
+        } else {
+            tile->current = tile->nb_frames - tile->queue;
+        }
+    }
+
     return 0;
 }
 
@@ -201,7 +217,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->queue != tile->nb_frames)
             ff_fill_rectangle(&tile->draw, &tile->blank,
                               tile->out_ref->data,
                               tile->out_ref->linesize,
-- 
2.11.0



More information about the ffmpeg-devel mailing list