]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_slicify.c
lpc: Add a function for calculating reflection coefficients from samples
[ffmpeg] / libavfilter / vf_slicify.c
index 4b78dca493808bc6905606a8ead413f1ed2a157c..f81ab0d0c19d2671ed490cf6d4f0167574194f08 100644 (file)
@@ -26,6 +26,7 @@
 #include "avfilter.h"
 #include "internal.h"
 #include "video.h"
+#include "libavutil/common.h"
 #include "libavutil/pixdesc.h"
 
 typedef struct {
@@ -53,13 +54,14 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
 static int config_props(AVFilterLink *link)
 {
     SliceContext *slice = link->dst->priv;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
 
-    slice->vshift = av_pix_fmt_descriptors[link->format].log2_chroma_h;
+    slice->vshift = desc->log2_chroma_h;
 
     return 0;
 }
 
-static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
+static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
 {
     SliceContext *slice = link->dst->priv;
 
@@ -75,29 +77,57 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
     av_log(link->dst, AV_LOG_DEBUG, "h:%d\n", slice->h);
     link->cur_buf = NULL;
 
-    ff_start_frame(link->dst->outputs[0], picref);
+    return ff_start_frame(link->dst->outputs[0], picref);
 }
 
-static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 {
     SliceContext *slice = link->dst->priv;
-    int y2;
+    int y2, ret = 0;
 
     if (slice_dir == 1) {
-        for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h)
-            ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir);
+        for (y2 = y; y2 + slice->h <= y + h; y2 += slice->h) {
+            ret = ff_draw_slice(link->dst->outputs[0], y2, slice->h, slice_dir);
+            if (ret < 0)
+                return ret;
+        }
 
         if (y2 < y + h)
-            ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir);
+            return ff_draw_slice(link->dst->outputs[0], y2, y + h - y2, slice_dir);
     } else if (slice_dir == -1) {
-        for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h)
-            ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir);
+        for (y2 = y + h; y2 - slice->h >= y; y2 -= slice->h) {
+            ret = ff_draw_slice(link->dst->outputs[0], y2 - slice->h, slice->h, slice_dir);
+            if (ret < 0)
+                return ret;
+        }
 
         if (y2 > y)
-            ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir);
+            return ff_draw_slice(link->dst->outputs[0], y, y2 - y, slice_dir);
     }
+    return 0;
 }
 
+static const AVFilterPad avfilter_vf_slicify_inputs[] = {
+    {
+        .name             = "default",
+        .type             = AVMEDIA_TYPE_VIDEO,
+        .get_video_buffer = ff_null_get_video_buffer,
+        .start_frame      = start_frame,
+        .draw_slice       = draw_slice,
+        .config_props     = config_props,
+        .end_frame        = ff_null_end_frame,
+    },
+    { NULL }
+};
+
+static const AVFilterPad avfilter_vf_slicify_outputs[] = {
+    {
+        .name = "default",
+        .type = AVMEDIA_TYPE_VIDEO,
+    },
+    { NULL }
+};
+
 AVFilter avfilter_vf_slicify = {
     .name      = "slicify",
     .description = NULL_IF_CONFIG_SMALL("Pass the images of input video on to next video filter as multiple slices."),
@@ -106,15 +136,6 @@ AVFilter avfilter_vf_slicify = {
 
     .priv_size = sizeof(SliceContext),
 
-    .inputs    = (const AVFilterPad[]) {{ .name             = "default",
-                                          .type             = AVMEDIA_TYPE_VIDEO,
-                                          .get_video_buffer = ff_null_get_video_buffer,
-                                          .start_frame      = start_frame,
-                                          .draw_slice       = draw_slice,
-                                          .config_props     = config_props,
-                                          .end_frame        = ff_null_end_frame, },
-                                        { .name = NULL}},
-    .outputs   = (const AVFilterPad[]) {{ .name            = "default",
-                                          .type            = AVMEDIA_TYPE_VIDEO, },
-                                        { .name = NULL}},
+    .inputs    = avfilter_vf_slicify_inputs,
+    .outputs   = avfilter_vf_slicify_outputs,
 };