diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-11-27 07:49:45 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-11-28 08:50:19 +0100 |
commit | 565e4993c63f797e2d50ad2f1e8f62fdbe299666 (patch) | |
tree | bae5282b2ee875de4b01467f3cfaab54b0ab6ec0 /libavfilter/vf_setpts.c | |
parent | bb6c67bb36b136de10256f0999128df4a42f9ffc (diff) | |
download | ffmpeg-565e4993c63f797e2d50ad2f1e8f62fdbe299666.tar.gz |
lavfi: merge start_frame/draw_slice/end_frame
Any alleged performance benefits gained from the split are purely
mythological and do not justify added code complexity.
Diffstat (limited to 'libavfilter/vf_setpts.c')
-rw-r--r-- | libavfilter/vf_setpts.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c index f2b86a16af..0c4881efc1 100644 --- a/libavfilter/vf_setpts.c +++ b/libavfilter/vf_setpts.c @@ -102,39 +102,36 @@ static int config_input(AVFilterLink *inlink) #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) -static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) +static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame) { SetPTSContext *setpts = inlink->dst->priv; + int64_t in_pts = frame->pts; double d; - AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); - - if (!outpicref) - return AVERROR(ENOMEM); if (isnan(setpts->var_values[VAR_STARTPTS])) - setpts->var_values[VAR_STARTPTS] = TS2D(inpicref->pts); + setpts->var_values[VAR_STARTPTS] = TS2D(frame->pts); - setpts->var_values[VAR_INTERLACED] = inpicref->video->interlaced; - setpts->var_values[VAR_PTS ] = TS2D(inpicref->pts); - setpts->var_values[VAR_POS ] = inpicref->pos == -1 ? NAN : inpicref->pos; + setpts->var_values[VAR_INTERLACED] = frame->video->interlaced; + setpts->var_values[VAR_PTS ] = TS2D(frame->pts); + setpts->var_values[VAR_POS ] = frame->pos == -1 ? NAN : frame->pos; d = av_expr_eval(setpts->expr, setpts->var_values, NULL); - outpicref->pts = D2TS(d); + frame->pts = D2TS(d); #ifdef DEBUG av_log(inlink->dst, AV_LOG_DEBUG, "n:%"PRId64" interlaced:%d pos:%"PRId64" pts:%"PRId64" t:%f -> pts:%"PRId64" t:%f\n", (int64_t)setpts->var_values[VAR_N], (int)setpts->var_values[VAR_INTERLACED], - inpicref ->pos, - inpicref ->pts, inpicref ->pts * av_q2d(inlink->time_base), - outpicref->pts, outpicref->pts * av_q2d(inlink->time_base)); + frame->pos, in_pts, in_pts * av_q2d(inlink->time_base), + frame->pts, frame->pts * av_q2d(inlink->time_base)); #endif + setpts->var_values[VAR_N] += 1.0; - setpts->var_values[VAR_PREV_INPTS ] = TS2D(inpicref ->pts); - setpts->var_values[VAR_PREV_OUTPTS] = TS2D(outpicref->pts); - return ff_start_frame(inlink->dst->outputs[0], outpicref); + setpts->var_values[VAR_PREV_INPTS ] = TS2D(in_pts); + setpts->var_values[VAR_PREV_OUTPTS] = TS2D(frame->pts); + return ff_filter_frame(inlink->dst->outputs[0], frame); } static av_cold void uninit(AVFilterContext *ctx) @@ -150,7 +147,7 @@ static const AVFilterPad avfilter_vf_setpts_inputs[] = { .type = AVMEDIA_TYPE_VIDEO, .get_video_buffer = ff_null_get_video_buffer, .config_props = config_input, - .start_frame = start_frame, + .filter_frame = filter_frame, }, { NULL } }; |