]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_fps.c
configure: add decimate filter dependency on avcodec
[ffmpeg] / libavfilter / vf_fps.c
index 3fdac4f267d797a901f7f22b92f7398467a5d1d3..c13b1bd3859736128430d9676678e9b2edeea62a 100644 (file)
@@ -25,6 +25,7 @@
  * a filter enforcing given constant framerate
  */
 
+#include "libavutil/common.h"
 #include "libavutil/fifo.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
@@ -55,8 +56,9 @@ typedef struct FPSContext {
 
 #define OFFSET(x) offsetof(FPSContext, x)
 #define V AV_OPT_FLAG_VIDEO_PARAM
+#define F AV_OPT_FLAG_FILTERING_PARAM
 static const AVOption fps_options[] = {
-    { "fps", "A string describing desired output framerate", OFFSET(fps), AV_OPT_TYPE_STRING, { .str = "25" }, .flags = V },
+    { "fps", "A string describing desired output framerate", OFFSET(fps), AV_OPT_TYPE_STRING, { .str = "25" }, .flags = V|F },
     { NULL },
 };
 
@@ -114,7 +116,7 @@ static int config_props(AVFilterLink* link)
 {
     FPSContext   *s = link->src->priv;
 
-    link->time_base = (AVRational){ s->framerate.den, s->framerate.num };
+    link->time_base = av_inv_q(s->framerate);
     link->frame_rate= s->framerate;
     link->w         = link->src->inputs[0]->w;
     link->h         = link->src->inputs[0]->h;
@@ -230,7 +232,7 @@ static int end_frame(AVFilterLink *inlink)
 
         /* duplicate the frame if needed */
         if (!av_fifo_size(s->fifo) && i < delta - 1) {
-            AVFilterBufferRef *dup = avfilter_ref_buffer(buf_out, AV_PERM_READ);
+            AVFilterBufferRef *dup = avfilter_ref_buffer(buf_out, ~0);
 
             av_log(ctx, AV_LOG_DEBUG, "Duplicating frame.\n");
             if (dup)
@@ -288,13 +290,16 @@ AVFilter avfilter_vf_fps = {
 
     .inputs    = (const AVFilterPad[]) {{ .name            = "default",
                                           .type            = AVMEDIA_TYPE_VIDEO,
+                                          .min_perms       = AV_PERM_READ | AV_PERM_PRESERVE,
                                           .start_frame     = null_start_frame,
                                           .draw_slice      = null_draw_slice,
                                           .end_frame       = end_frame, },
                                         { .name = NULL}},
     .outputs   = (const AVFilterPad[]) {{ .name            = "default",
                                           .type            = AVMEDIA_TYPE_VIDEO,
+                                          .rej_perms       = AV_PERM_WRITE,
                                           .request_frame   = request_frame,
                                           .config_props    = config_props},
                                         { .name = NULL}},
+    .priv_class = &fps_class,
 };