vf_drawtext: switch to filter_frame, this filter did not support slices

Based on patch by Anton Khirnov
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-11-28 18:07:51 +01:00
parent 384641468b
commit 7bfa2f25c0

View File

@ -965,23 +965,17 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
return 0; return 0;
} }
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
{
return 0;
}
static int end_frame(AVFilterLink *inlink)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0]; AVFilterLink *outlink = ctx->outputs[0];
DrawTextContext *dtext = ctx->priv; DrawTextContext *dtext = ctx->priv;
AVFilterBufferRef *picref = inlink->cur_buf;
int ret; int ret;
dtext->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ? dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
NAN : picref->pts * av_q2d(inlink->time_base); NAN : frame->pts * av_q2d(inlink->time_base);
draw_text(ctx, picref, picref->video->w, picref->video->h); draw_text(ctx, frame, frame->video->w, frame->video->h);
av_log(ctx, AV_LOG_DEBUG, "n:%d t:%f text_w:%d text_h:%d x:%d y:%d\n", av_log(ctx, AV_LOG_DEBUG, "n:%d t:%f text_w:%d text_h:%d x:%d y:%d\n",
(int)dtext->var_values[VAR_N], dtext->var_values[VAR_T], (int)dtext->var_values[VAR_N], dtext->var_values[VAR_T],
@ -990,10 +984,7 @@ static int end_frame(AVFilterLink *inlink)
dtext->var_values[VAR_N] += 1.0; dtext->var_values[VAR_N] += 1.0;
if ((ret = ff_draw_slice(outlink, 0, picref->video->h, 1)) < 0 || return ff_filter_frame(inlink->dst->outputs[0], frame);
(ret = ff_end_frame(outlink)) < 0)
return ret;
return 0;
} }
static const AVFilterPad avfilter_vf_drawtext_inputs[] = { static const AVFilterPad avfilter_vf_drawtext_inputs[] = {
@ -1001,9 +992,7 @@ static const AVFilterPad avfilter_vf_drawtext_inputs[] = {
.name = "default", .name = "default",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.get_video_buffer = ff_null_get_video_buffer, .get_video_buffer = ff_null_get_video_buffer,
.start_frame = ff_null_start_frame, .filter_frame = filter_frame,
.draw_slice = null_draw_slice,
.end_frame = end_frame,
.config_props = config_input, .config_props = config_input,
.min_perms = AV_PERM_WRITE | .min_perms = AV_PERM_WRITE |
AV_PERM_READ, AV_PERM_READ,