X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_zoompan.c;h=d9d53decf4d41d8608ce6d77103a7fbe5ea08f50;hb=e5bcda6473a2d6984216004506374669501fcf3b;hp=0635171b57877d473287859ef3975e7e691ab514;hpb=04e4ab44d7c5eca9e1929b34d8fb966afc403e3a;p=ffmpeg diff --git a/libavfilter/vf_zoompan.c b/libavfilter/vf_zoompan.c index 0635171b578..d9d53decf4d 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,9 +168,12 @@ 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 + 1; + var_values[VAR_ON] = outlink->frame_count_in; *zoom = av_expr_eval(s->zoom_expr, var_values, NULL); @@ -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; @@ -274,8 +284,8 @@ static int activate(AVFilterContext *ctx) s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = s->in->height; s->var_values[VAR_OUT_W] = s->var_values[VAR_OW] = s->w; s->var_values[VAR_OUT_H] = s->var_values[VAR_OH] = s->h; - s->var_values[VAR_IN] = inlink->frame_count_out + 1; - s->var_values[VAR_ON] = outlink->frame_count_in + 1; + s->var_values[VAR_IN] = inlink->frame_count_out - 1; + s->var_values[VAR_ON] = outlink->frame_count_in; s->var_values[VAR_PX] = s->x; s->var_values[VAR_PY] = s->y; s->var_values[VAR_X] = 0; @@ -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[] = {