Hi All,

vf_overlay video filter accepts expressions in its parameters. In
'frame-by-frame' evaluation mode it recalculates them regularly, but
incoming video frame size changes did not reflect in their values. So if you used
width or height of any source videos in expressions as parameters,
they stayed on their initial values. This patch corrects this bug.


Please consider to put this patch into the official ffmpeg source tree.

thank you,

Bela Bodecs

>From e8002f3566d4ffe32fb49bb58384b42019f6c480 Tue, 19 Jan 2016 20:41:56 +0100
From: Bela Bodecs <bode...@vivanet.hu>
Date: Tue, 19 Jan 2016 20:22:06 +0100
Subject: [PATCH] vf_overlay: handles expression evaluation of frame size change in frame-by-frame evalutaion mode


vf_overlay video filter accepts expressions in its parameters. In
'frame-by-frame' evaluation mode it recalculates them regularly, but
incoming video frame size changes did not reflect in their values. So if
you used width or height of any source videos in expressions as
parameters, they stayed on their initial values. This patch corrects
this bug.  

Signed-off-by: Bela Bodecs <bode...@vivanet.hu>

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 7457820..3eac7f0 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -597,10 +597,15 @@
         s->var_values[VAR_N] = inlink->frame_count;
         s->var_values[VAR_T] = mainpic->pts == AV_NOPTS_VALUE ?
             NAN : mainpic->pts * av_q2d(inlink->time_base);
         s->var_values[VAR_POS] = pos == -1 ? NAN : pos;
 
+        s->var_values[VAR_OVERLAY_W] = s->var_values[VAR_OW] = second->width;
+        s->var_values[VAR_OVERLAY_H] = s->var_values[VAR_OH] = second->height;
+        s->var_values[VAR_MAIN_W   ] = s->var_values[VAR_MW] = mainpic->width;
+        s->var_values[VAR_MAIN_H   ] = s->var_values[VAR_MH] = mainpic->height;
+
         eval_expr(ctx);
         av_log(ctx, AV_LOG_DEBUG, "n:%f t:%f pos:%f x:%f xi:%d y:%f yi:%d\n",
                s->var_values[VAR_N], s->var_values[VAR_T], s->var_values[VAR_POS],
                s->var_values[VAR_X], s->x,
                s->var_values[VAR_Y], s->y);
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to