]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_xmedian.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vf_xmedian.c
index 0c4d4ab047674cb48bc31d5368c75c44b3827671..168a5944dbb106c63f3cef39fea74081742fc445 100644 (file)
@@ -244,14 +244,20 @@ static int process_frame(FFFrameSync *fs)
             return ret;
     }
 
-    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+    if (ctx->is_disabled) {
+        out = av_frame_clone(in[0]);
+    } else {
+        out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
+    }
     if (!out)
         return AVERROR(ENOMEM);
     out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base);
 
-    td.in = in;
-    td.out = out;
-    ctx->internal->execute(ctx, s->median_frames, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+    if (!ctx->is_disabled) {
+        td.in = in;
+        td.out = out;
+        ctx->internal->execute(ctx, s->median_frames, &td, NULL, FFMIN(s->height[1], ff_filter_get_nb_threads(ctx)));
+    }
 
     return ff_filter_frame(outlink, out);
 }
@@ -316,7 +322,7 @@ static int config_output(AVFilterLink *outlink)
         in[i].time_base = inlink->time_base;
         in[i].sync   = 1;
         in[i].before = EXT_STOP;
-        in[i].after  = EXT_STOP;
+        in[i].after  = EXT_INFINITY;
     }
 
     ret = ff_framesync_configure(&s->fs);
@@ -383,19 +389,21 @@ static const AVFilterPad outputs[] = {
 };
 
 #if CONFIG_XMEDIAN_FILTER
-AVFILTER_DEFINE_CLASS(xmedian);
+FRAMESYNC_DEFINE_CLASS(xmedian, XMedianContext, fs);
 
-AVFilter ff_vf_xmedian = {
+const AVFilter ff_vf_xmedian = {
     .name          = "xmedian",
     .description   = NULL_IF_CONFIG_SMALL("Pick median pixels from several video inputs."),
     .priv_size     = sizeof(XMedianContext),
     .priv_class    = &xmedian_class,
     .query_formats = query_formats,
     .outputs       = outputs,
+    .preinit       = xmedian_framesync_preinit,
     .init          = init,
     .uninit        = uninit,
     .activate      = activate,
-    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS,
+    .flags         = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS |
+                     AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
     .process_command = process_command,
 };
 
@@ -467,7 +475,7 @@ static const AVFilterPad tmedian_outputs[] = {
 
 AVFILTER_DEFINE_CLASS(tmedian);
 
-AVFilter ff_vf_tmedian = {
+const AVFilter ff_vf_tmedian = {
     .name          = "tmedian",
     .description   = NULL_IF_CONFIG_SMALL("Pick median pixels from successive frames."),
     .priv_size     = sizeof(XMedianContext),