aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_drawtext.c
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2013-04-15 17:42:04 +0200
committerClément Bœsch <ubitux@gmail.com>2013-04-23 01:02:27 +0200
commitb8a5c76131944b4cc17c6db609288d0000d56a43 (patch)
tree2aeabcf34ac5d3ada79c9ae6168dba392ab393dd /libavfilter/vf_drawtext.c
parentf4596e8bb6f74599b8258c87036c237c5da4b209 (diff)
downloadffmpeg-b8a5c76131944b4cc17c6db609288d0000d56a43.tar.gz
lavfi: add frame counter into AVFilterLink and use it in filters.
Diffstat (limited to 'libavfilter/vf_drawtext.c')
-rw-r--r--libavfilter/vf_drawtext.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 07684785a5..c404fa53c5 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -164,7 +164,6 @@ typedef struct {
AVRational tc_rate; ///< frame rate for timecode
AVTimecode tc; ///< timecode context
int tc24hmax; ///< 1 if timecode is wrapped to 24 hours, 0 otherwise
- int frame_id;
int reload; ///< reload text file for each frame
} DrawTextContext;
@@ -820,6 +819,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
int width, int height)
{
DrawTextContext *dtext = ctx->priv;
+ AVFilterLink *inlink = ctx->inputs[0];
uint32_t code = 0, prev_code = 0;
int x = 0, y = 0, i = 0, ret;
int max_text_line_w = 0, len;
@@ -857,7 +857,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
if (dtext->tc_opt_string) {
char tcbuf[AV_TIMECODE_STR_SIZE];
- av_timecode_make_string(&dtext->tc, tcbuf, dtext->frame_id++);
+ av_timecode_make_string(&dtext->tc, tcbuf, inlink->frame_count);
av_bprint_clear(bp);
av_bprintf(bp, "%s%s", dtext->text, tcbuf);
}
@@ -983,6 +983,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
if ((ret = load_textfile(ctx)) < 0)
return ret;
+ dtext->var_values[VAR_N] = inlink->frame_count;
dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
NAN : frame->pts * av_q2d(inlink->time_base);
@@ -993,8 +994,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
(int)dtext->var_values[VAR_TEXT_W], (int)dtext->var_values[VAR_TEXT_H],
dtext->x, dtext->y);
- dtext->var_values[VAR_N] += 1.0;
-
return ff_filter_frame(outlink, frame);
}