]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_zoompan.c
Merge commit 'c51b2c79a7ba084253e892c56dd49ee97115c7de'
[ffmpeg] / libavfilter / vf_zoompan.c
index 0dc5f37058a2416d38317d74cafb6a90c83b3306..99a1a346a316ea3564a6b2be32433b39ec9355d3 100644 (file)
@@ -92,6 +92,7 @@ typedef struct ZPcontext {
     int nb_frames;
     int current_frame;
     int finished;
+    AVRational framerate;
 } ZPContext;
 
 #define OFFSET(x) offsetof(ZPContext, x)
@@ -103,6 +104,7 @@ static const AVOption zoompan_options[] = {
     { "y", "set the y expression", OFFSET(y_expr_str), AV_OPT_TYPE_STRING, {.str="0"}, .flags = FLAGS },
     { "d", "set the duration expression", OFFSET(duration_expr_str), AV_OPT_TYPE_STRING, {.str="90"}, .flags = FLAGS },
     { "s", "set the output image size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"}, .flags = FLAGS },
+    { "fps", "set the output framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, { .str = "25" }, .flags = FLAGS },
     { NULL }
 };
 
@@ -123,6 +125,8 @@ static int config_output(AVFilterLink *outlink)
 
     outlink->w = s->w;
     outlink->h = s->h;
+    outlink->time_base = av_inv_q(s->framerate);
+    outlink->frame_rate = s->framerate;
     s->desc = av_pix_fmt_desc_get(outlink->format);
 
     return 0;
@@ -133,8 +137,7 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va
 {
     ZPContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
-    int64_t pts = av_rescale_q(in->pts, ctx->inputs[0]->time_base,
-                               outlink->time_base) + s->frame_count;
+    int64_t pts = s->frame_count;
     int k, x, y, w, h, ret = 0;
     uint8_t *input[4];
     int px[4], py[4];
@@ -175,10 +178,10 @@ static int output_single_frame(AVFilterContext *ctx, AVFrame *in, double *var_va
         return ret;
     }
 
-    px[1] = px[2] = FF_CEIL_RSHIFT(x, s->desc->log2_chroma_w);
+    px[1] = px[2] = AV_CEIL_RSHIFT(x, s->desc->log2_chroma_w);
     px[0] = px[3] = x;
 
-    py[1] = py[2] = FF_CEIL_RSHIFT(y, s->desc->log2_chroma_h);
+    py[1] = py[2] = AV_CEIL_RSHIFT(y, s->desc->log2_chroma_h);
     py[0] = py[3] = y;
 
     s->sws = sws_alloc_context();
@@ -221,10 +224,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     double nb_frames;
     int ret;
 
-    if (s->in) {
-        av_frame_free(&in);
-        return 0;
-    }
+    av_assert0(s->in == NULL);
 
     s->finished = 0;
     s->var_values[VAR_IN_W]  = s->var_values[VAR_IW] = in->width;
@@ -265,8 +265,8 @@ static int request_frame(AVFilterLink *outlink)
     AVFilterContext *ctx = outlink->src;
     ZPContext *s = ctx->priv;
     AVFrame *in = s->in;
-    double zoom, dx, dy;
-    int ret;
+    double zoom=1, dx=0, dy=0;
+    int ret = -1;
 
     if (in) {
         ret = output_single_frame(ctx, in, s->var_values, s->current_frame,
@@ -283,7 +283,6 @@ static int request_frame(AVFilterLink *outlink)
         s->nb_frames = 0;
         s->current_frame = 0;
         av_frame_free(&s->in);
-        ret = 0;
         s->finished = 1;
         ret = ff_request_frame(ctx->inputs[0]);
     }
@@ -336,6 +335,7 @@ static const AVFilterPad inputs[] = {
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
+        .needs_fifo   = 1,
     },
     { NULL }
 };