X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_zoompan.c;h=e18ebb4f113109a3e1a184716a05cc1c60d00f70;hb=a04ad248a05e7b613abe09b3bb067f555108d794;hp=dea10d51371f6905104061ca785019c2c3496fae;hpb=92219ef4ac01b00e630b39cb19e8fbd17fdb63d0;p=ffmpeg diff --git a/libavfilter/vf_zoompan.c b/libavfilter/vf_zoompan.c index dea10d51371..e18ebb4f113 100644 --- a/libavfilter/vf_zoompan.c +++ b/libavfilter/vf_zoompan.c @@ -38,7 +38,8 @@ static const char *const var_names[] = { "on", "duration", "pduration", - "time", + "in_time", "it", + "out_time", "time", "ot", "frame", "zoom", "pzoom", @@ -61,7 +62,8 @@ enum var_name { VAR_ON, VAR_DURATION, VAR_PDURATION, - VAR_TIME, + VAR_IN_TIME, VAR_IT, + VAR_TIME, VAR_OUT_TIME, VAR_OT, VAR_FRAME, VAR_ZOOM, VAR_PZOOM, @@ -155,6 +157,7 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va { ZPContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; + AVFilterLink *inlink = ctx->inputs[0]; int64_t pts = s->frame_count; int k, x, y, w, h, ret = 0; uint8_t *input[4]; @@ -165,7 +168,10 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va var_values[VAR_PY] = s->y; var_values[VAR_PZOOM] = s->prev_zoom; var_values[VAR_PDURATION] = s->prev_nb_frames; - var_values[VAR_TIME] = pts * av_q2d(outlink->time_base); + var_values[VAR_IN_TIME] = var_values[VAR_IT] = in->pts == AV_NOPTS_VALUE ? + NAN : in->pts * av_q2d(inlink->time_base); + var_values[VAR_OUT_TIME] = pts * av_q2d(outlink->time_base); + var_values[VAR_TIME] = var_values[VAR_OT] = var_values[VAR_OUT_TIME]; var_values[VAR_FRAME] = i; var_values[VAR_ON] = outlink->frame_count_in; @@ -245,6 +251,8 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va } return ret; error: + sws_freeContext(s->sws); + s->sws = NULL; av_frame_free(&out); return ret; } @@ -257,6 +265,8 @@ static int activate(AVFilterContext *ctx) int status, ret = 0; int64_t pts; + FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + if (s->in && ff_outlink_frame_wanted(outlink)) { double zoom = -1, dx = -1, dy = -1; @@ -344,6 +354,10 @@ static av_cold void uninit(AVFilterContext *ctx) sws_freeContext(s->sws); s->sws = NULL; + av_expr_free(s->x_expr); + av_expr_free(s->y_expr); + av_expr_free(s->zoom_expr); + av_frame_free(&s->in); } static const AVFilterPad inputs[] = { @@ -363,7 +377,7 @@ static const AVFilterPad outputs[] = { { NULL } }; -AVFilter ff_vf_zoompan = { +const AVFilter ff_vf_zoompan = { .name = "zoompan", .description = NULL_IF_CONFIG_SMALL("Apply Zoom & Pan effect."), .priv_size = sizeof(ZPContext),