]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_select.c
Drop unnecessary 'l' length modifier when printfing double values.
[ffmpeg] / libavfilter / vf_select.c
index b9e053fc036daa51ca425d5b4c28c07a867419a7..674151d4ef73ecb13e7e30116f8a2bc8bdee9721 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "libavutil/eval.h"
 #include "libavutil/fifo.h"
+#include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "avfilter.h"
 #include "internal.h"
@@ -227,46 +228,27 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *picref)
     return res;
 }
 
-static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
 {
     SelectContext *select = inlink->dst->priv;
 
-    select->select = select_frame(inlink->dst, picref);
+    select->select = select_frame(inlink->dst, frame);
     if (select->select) {
         /* frame was requested through poll_frame */
         if (select->cache_frames) {
-            if (!av_fifo_space(select->pending_frames))
+            if (!av_fifo_space(select->pending_frames)) {
                 av_log(inlink->dst, AV_LOG_ERROR,
                        "Buffering limit reached, cannot cache more frames\n");
-            else
-                av_fifo_generic_write(select->pending_frames, &picref,
-                                      sizeof(picref), NULL);
+                avfilter_unref_bufferp(&frame);
+            } else
+                av_fifo_generic_write(select->pending_frames, &frame,
+                                      sizeof(frame), NULL);
             return 0;
         }
-        return ff_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0));
+        return ff_filter_frame(inlink->dst->outputs[0], frame);
     }
 
-    return 0;
-}
-
-static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
-{
-    SelectContext *select = inlink->dst->priv;
-
-    if (select->select && !select->cache_frames)
-        return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
-    return 0;
-}
-
-static int end_frame(AVFilterLink *inlink)
-{
-    SelectContext *select = inlink->dst->priv;
-
-    if (select->select) {
-        if (select->cache_frames)
-            return 0;
-        return ff_end_frame(inlink->dst->outputs[0]);
-    }
+    avfilter_unref_bufferp(&frame);
     return 0;
 }
 
@@ -279,12 +261,9 @@ static int request_frame(AVFilterLink *outlink)
 
     if (av_fifo_size(select->pending_frames)) {
         AVFilterBufferRef *picref;
+
         av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
-        ff_start_frame(outlink, avfilter_ref_buffer(picref, ~0));
-        ff_draw_slice(outlink, 0, outlink->h, 1);
-        ff_end_frame(outlink);
-        avfilter_unref_buffer(picref);
-        return 0;
+        return ff_filter_frame(outlink, picref);
     }
 
     while (!select->select) {
@@ -333,6 +312,27 @@ static av_cold void uninit(AVFilterContext *ctx)
     select->pending_frames = NULL;
 }
 
+static const AVFilterPad avfilter_vf_select_inputs[] = {
+    {
+        .name             = "default",
+        .type             = AVMEDIA_TYPE_VIDEO,
+        .get_video_buffer = ff_null_get_video_buffer,
+        .config_props     = config_input,
+        .filter_frame     = filter_frame,
+    },
+    { NULL }
+};
+
+static const AVFilterPad avfilter_vf_select_outputs[] = {
+    {
+        .name          = "default",
+        .type          = AVMEDIA_TYPE_VIDEO,
+        .poll_frame    = poll_frame,
+        .request_frame = request_frame,
+    },
+    { NULL }
+};
+
 AVFilter avfilter_vf_select = {
     .name      = "select",
     .description = NULL_IF_CONFIG_SMALL("Select frames to pass in output."),
@@ -341,17 +341,6 @@ AVFilter avfilter_vf_select = {
 
     .priv_size = sizeof(SelectContext),
 
-    .inputs    = (const AVFilterPad[]) {{ .name             = "default",
-                                          .type             = AVMEDIA_TYPE_VIDEO,
-                                          .get_video_buffer = ff_null_get_video_buffer,
-                                          .config_props     = config_input,
-                                          .start_frame      = start_frame,
-                                          .draw_slice       = draw_slice,
-                                          .end_frame        = end_frame },
-                                        { .name = NULL }},
-    .outputs   = (const AVFilterPad[]) {{ .name             = "default",
-                                          .type             = AVMEDIA_TYPE_VIDEO,
-                                          .poll_frame       = poll_frame,
-                                          .request_frame    = request_frame, },
-                                        { .name = NULL}},
+    .inputs    = avfilter_vf_select_inputs,
+    .outputs   = avfilter_vf_select_outputs,
 };