]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_mix.c
libavfilter/dnn: add more data type support for dnn model input
[ffmpeg] / libavfilter / vf_mix.c
index d0cc7cb83071fa139477a8023dd6bba707dfb214..873bef9dc3c82d58848f9866916f22cfa3420034 100644 (file)
@@ -108,7 +108,7 @@ static av_cold int init(AVFilterContext *ctx)
             break;
 
         p = NULL;
-        sscanf(arg, "%f", &s->weights[i]);
+        av_sscanf(arg, "%f", &s->weights[i]);
         s->wfactor += s->weights[i];
         last = i;
     }
@@ -348,16 +348,27 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
     ThreadData td;
     AVFrame *out;
 
+    if (s->nb_inputs == 1)
+        return ff_filter_frame(outlink, in);
+
     if (s->nb_frames < s->nb_inputs) {
         s->frames[s->nb_frames] = in;
         s->nb_frames++;
-        return 0;
+        if (s->nb_frames < s->nb_inputs)
+            return 0;
     } else {
         av_frame_free(&s->frames[0]);
         memmove(&s->frames[0], &s->frames[1], sizeof(*s->frames) * (s->nb_inputs - 1));
         s->frames[s->nb_inputs - 1] = in;
     }
 
+    if (ctx->is_disabled) {
+        out = av_frame_clone(s->frames[0]);
+        if (!out)
+            return AVERROR(ENOMEM);
+        return ff_filter_frame(outlink, out);
+    }
+
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out)
         return AVERROR(ENOMEM);
@@ -371,7 +382,7 @@ static int tmix_filter_frame(AVFilterLink *inlink, AVFrame *in)
 }
 
 static const AVOption tmix_options[] = {
-    { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 2, 128, .flags = FLAGS },
+    { "frames", "set number of successive frames to mix", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64=3}, 1, 128, .flags = FLAGS },
     { "weights", "set weight for each frame", OFFSET(weights_str), AV_OPT_TYPE_STRING, {.str="1 1 1"}, 0, 0, .flags = FLAGS },
     { "scale", "set scale", OFFSET(scale), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, INT16_MAX, .flags = FLAGS },
     { NULL },
@@ -398,7 +409,7 @@ AVFilter ff_vf_tmix = {
     .inputs        = inputs,
     .init          = init,
     .uninit        = uninit,
-    .flags         = AVFILTER_FLAG_SLICE_THREADS,
+    .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS,
 };
 
 #endif /* CONFIG_TMIX_FILTER */