[FFmpeg-devel] [PATCH] lavfi/overlay: add repeatlast option

Stefano Sabatini stefasab at gmail.com
Fri Apr 5 13:49:55 CEST 2013


TODO: bump micro
---
 doc/filters.texi         |    5 +++++
 libavfilter/vf_overlay.c |    6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index f836d81..4e475a8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4296,6 +4296,11 @@ Default value is @samp{yuv420}.
 If set to 1, force the filter to accept inputs in the RGB
 color space. Default value is 0. This option is deprecated, use
 @option{format} instead.
+
+ at item repeatlast
+If set to 1, force the filter to verlay the last overlay frame over
+the main input until the end of the stream, a value of 0 disable this
+behavior. Default value is 1.
 @end table
 
 The @option{x}, @option{y}, and @option{enable} expressions can
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index aadb024..bef187b 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -109,6 +109,7 @@ typedef struct {
     int overlay_pix_step[4];    ///< steps per pixel for each plane of the overlay
     int hsub, vsub;             ///< chroma subsampling values
     int shortest;               ///< terminate stream when the shortest input terminates
+    int repeatlast;             ///< repeat last overlay frame
 
     double var_values[VAR_VARS_NB];
     char *x_expr, *y_expr, *enable_expr;
@@ -135,6 +136,7 @@ static const AVOption overlay_options[] = {
         { "yuv444", "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_YUV444}, .flags = FLAGS, .unit = "format" },
         { "rgb",    "", 0, AV_OPT_TYPE_CONST, {.i64=OVERLAY_FORMAT_RGB},    .flags = FLAGS, .unit = "format" },
 
+    { "repeatlast", "repeat overlay of the last overlay frame", OFFSET(repeatlast), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, FLAGS },
     { NULL }
 };
 
@@ -579,6 +581,10 @@ static int try_filter_frame(AVFilterContext *ctx, AVFrame *mainpic)
      * before the main frame, we can drop the current overlay. */
     while (1) {
         next_overpic = ff_bufqueue_peek(&over->queue_over, 0);
+        if (!next_overpic && over->overlay_eof && !over->repeatlast) {
+            av_frame_free(&over->overpicref);
+            break;
+        }
         if (!next_overpic || av_compare_ts(next_overpic->pts, ctx->inputs[OVERLAY]->time_base,
                                            mainpic->pts     , ctx->inputs[MAIN]->time_base) > 0)
             break;
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list