summaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_setpts.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/vf_setpts.c')
-rw-r--r--libavfilter/vf_setpts.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/libavfilter/vf_setpts.c b/libavfilter/vf_setpts.c
index f2b86a1..0c4881e 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 }
};
OpenPOWER on IntegriCloud