[FFmpeg-cvslog] lavfi: add error handling to draw_slice().

Anton Khirnov git at videolan.org
Sun Jul 22 23:56:49 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Jul 14 09:25:33 2012 +0200| [e9b992d035b58209d66115bd7d964741dd31d592] | committer: Anton Khirnov

lavfi: add error handling to draw_slice().

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e9b992d035b58209d66115bd7d964741dd31d592
---

 libavfilter/avfilter.h       |    4 +++-
 libavfilter/fifo.c           |    5 ++++-
 libavfilter/internal.h       |    4 +++-
 libavfilter/split.c          |   12 ++++++++----
 libavfilter/vf_blackframe.c  |    4 ++--
 libavfilter/vf_boxblur.c     |    4 ++--
 libavfilter/vf_crop.c        |    6 +++---
 libavfilter/vf_delogo.c      |    5 ++++-
 libavfilter/vf_drawbox.c     |    4 ++--
 libavfilter/vf_drawtext.c    |    5 ++++-
 libavfilter/vf_fade.c        |    4 ++--
 libavfilter/vf_fieldorder.c  |    5 +++--
 libavfilter/vf_fps.c         |    3 ++-
 libavfilter/vf_frei0r.c      |    5 ++++-
 libavfilter/vf_gradfun.c     |    5 ++++-
 libavfilter/vf_hflip.c       |    4 ++--
 libavfilter/vf_hqdn3d.c      |    5 ++++-
 libavfilter/vf_libopencv.c   |    5 ++++-
 libavfilter/vf_lut.c         |    4 ++--
 libavfilter/vf_overlay.c     |    9 ++++++---
 libavfilter/vf_pad.c         |   18 +++++++++++-------
 libavfilter/vf_pixdesctest.c |    4 ++--
 libavfilter/vf_scale.c       |   10 +++++-----
 libavfilter/vf_select.c      |    5 +++--
 libavfilter/vf_slicify.c     |   23 +++++++++++++++--------
 libavfilter/vf_unsharp.c     |    3 ++-
 libavfilter/vf_vflip.c       |    4 ++--
 libavfilter/vf_yadif.c       |    5 ++++-
 libavfilter/video.c          |   20 ++++++++++++--------
 libavfilter/video.h          |    6 ++++--
 30 files changed, 128 insertions(+), 72 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index a685761cf..3cd65da 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -295,8 +295,10 @@ struct AVFilterPad {
      * and should do its processing.
      *
      * Input video pads only.
+     *
+     * @return >= 0 on success, a negative AVERROR on error.
      */
-    void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
+    int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
 
     /**
      * Samples filtering callback. This is where a filter receives audio data
diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c
index 185960e..f7788b2 100644
--- a/libavfilter/fifo.c
+++ b/libavfilter/fifo.c
@@ -100,7 +100,10 @@ static void queue_pop(FifoContext *s)
 
 static void end_frame(AVFilterLink *inlink) { }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 /**
  * Move data pointers and pts offset samples forward.
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index c08e00b..3a2d50d 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -106,8 +106,10 @@ struct AVFilterPad {
      * and should do its processing.
      *
      * Input video pads only.
+     *
+     * @return >= 0 on success, a negative AVERROR on error.
      */
-    void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
+    int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
 
     /**
      * Samples filtering callback. This is where a filter receives audio data
diff --git a/libavfilter/split.c b/libavfilter/split.c
index 5ffbc85..0ae0a60 100644
--- a/libavfilter/split.c
+++ b/libavfilter/split.c
@@ -77,13 +77,17 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
     return ret;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
-    int i;
+    int i, ret = 0;
 
-    for (i = 0; i < ctx->nb_outputs; i++)
-        ff_draw_slice(ctx->outputs[i], y, h, slice_dir);
+    for (i = 0; i < ctx->nb_outputs; i++) {
+        ret = ff_draw_slice(ctx->outputs[i], y, h, slice_dir);
+        if (ret < 0)
+            break;
+    }
+    return ret;
 }
 
 static void end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c
index f5301c6..9fd5449 100644
--- a/libavfilter/vf_blackframe.c
+++ b/libavfilter/vf_blackframe.c
@@ -74,7 +74,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
     BlackFrameContext *blackframe = ctx->priv;
@@ -88,7 +88,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         p += picref->linesize[0];
     }
 
-    ff_draw_slice(ctx->outputs[0], y, h, slice_dir);
+    return ff_draw_slice(ctx->outputs[0], y, h, slice_dir);
 }
 
 static void end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_boxblur.c b/libavfilter/vf_boxblur.c
index 9ecd78f..0247e93 100644
--- a/libavfilter/vf_boxblur.c
+++ b/libavfilter/vf_boxblur.c
@@ -306,7 +306,7 @@ static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li
                    h, radius, power, temp);
 }
 
-static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
     BoxBlurContext *boxblur = ctx->priv;
@@ -330,7 +330,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir)
               w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane],
               boxblur->temp);
 
-    ff_draw_slice(outlink, y0, h0, slice_dir);
+    return ff_draw_slice(outlink, y0, h0, slice_dir);
 }
 
 AVFilter avfilter_vf_boxblur = {
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 636e853..f7d311a 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -297,13 +297,13 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
     return ff_start_frame(link->dst->outputs[0], ref2);
 }
 
-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)
 {
     AVFilterContext *ctx = link->dst;
     CropContext *crop = ctx->priv;
 
     if (y >= crop->y + crop->h || y + h <= crop->y)
-        return;
+        return 0;
 
     if (y < crop->y) {
         h -= crop->y - y;
@@ -312,7 +312,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
     if (y + h > crop->y + crop->h)
         h = crop->y + crop->h - y;
 
-    ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir);
+    return ff_draw_slice(ctx->outputs[0], y - crop->y, h, slice_dir);
 }
 
 static void end_frame(AVFilterLink *link)
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 5f8f9ff..6e77cf1 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -245,7 +245,10 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static void end_frame(AVFilterLink *inlink)
 {
diff --git a/libavfilter/vf_drawbox.c b/libavfilter/vf_drawbox.c
index 3c35bb5..96b1c00 100644
--- a/libavfilter/vf_drawbox.c
+++ b/libavfilter/vf_drawbox.c
@@ -94,7 +94,7 @@ static int config_input(AVFilterLink *inlink)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
 {
     DrawBoxContext *drawbox = inlink->dst->priv;
     int plane, x, y, xb = drawbox->x, yb = drawbox->y;
@@ -120,7 +120,7 @@ static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(inlink->dst->outputs[0], y0, h, 1);
+    return ff_draw_slice(inlink->dst->outputs[0], y0, h, 1);
 }
 
 AVFilter avfilter_vf_drawbox = {
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index f9a9261..732ab32 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -791,7 +791,10 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static inline int normalize_double(int *n, double d)
 {
diff --git a/libavfilter/vf_fade.c b/libavfilter/vf_fade.c
index f67e4a8..0a2a655 100644
--- a/libavfilter/vf_fade.c
+++ b/libavfilter/vf_fade.c
@@ -97,7 +97,7 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     FadeContext *fade = inlink->dst->priv;
     AVFilterBufferRef *outpic = inlink->cur_buf;
@@ -134,7 +134,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+    return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
 }
 
 static void end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index 0a8af75..312ff4f 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -144,7 +144,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext   *ctx        = inlink->dst;
     FieldOrderContext *fieldorder = ctx->priv;
@@ -158,8 +158,9 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
      *  and that complexity will be added later */
     if (  !inpicref->video->interlaced
         || inpicref->video->top_field_first == fieldorder->dst_tff) {
-        ff_draw_slice(outlink, y, h, slice_dir);
+        return ff_draw_slice(outlink, y, h, slice_dir);
     }
+    return 0;
 }
 
 static void end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index ca0d366..619a86c 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -248,8 +248,9 @@ static int null_start_frame(AVFilterLink *link, AVFilterBufferRef *buf)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 {
+    return 0;
 }
 
 AVFilter avfilter_vf_fps = {
diff --git a/libavfilter/vf_frei0r.c b/libavfilter/vf_frei0r.c
index 0b149d3..21221e1 100644
--- a/libavfilter/vf_frei0r.c
+++ b/libavfilter/vf_frei0r.c
@@ -340,7 +340,10 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static void end_frame(AVFilterLink *inlink)
 {
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 83186e5..61be40c 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -210,7 +210,10 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static void end_frame(AVFilterLink *inlink)
 {
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index fc549aa..06c4248 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -81,7 +81,7 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     FlipContext *flip = inlink->dst->priv;
     AVFilterBufferRef *inpic  = inlink->cur_buf;
@@ -142,7 +142,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+    return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
 }
 
 AVFilter avfilter_vf_hflip = {
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index 75594db..3985ce4 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -290,7 +290,10 @@ static int config_input(AVFilterLink *inlink)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static void end_frame(AVFilterLink *inlink)
 {
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 176065d..aa30d36 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -67,7 +67,10 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 typedef struct {
     const char *name;
diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
index cdc9375..c56c55b 100644
--- a/libavfilter/vf_lut.c
+++ b/libavfilter/vf_lut.c
@@ -294,7 +294,7 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
     LutContext *lut = ctx->priv;
@@ -339,7 +339,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(outlink, y, h, slice_dir);
+    return ff_draw_slice(outlink, y, h, slice_dir);
 }
 
 static const AVFilterPad inputs[] = {
diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 926e9a2..2b9439c 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -320,7 +320,7 @@ static void blend_slice(AVFilterContext *ctx,
     }
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
     AVFilterLink *outlink = ctx->outputs[0];
@@ -334,7 +334,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
                     over->overpicref->video->w, over->overpicref->video->h,
                     y, outpicref->video->w, h);
     }
-    ff_draw_slice(outlink, y, h, slice_dir);
+    return ff_draw_slice(outlink, y, h, slice_dir);
 }
 
 static void end_frame(AVFilterLink *inlink)
@@ -342,7 +342,10 @@ static void end_frame(AVFilterLink *inlink)
     ff_end_frame(inlink->dst->outputs[0]);
 }
 
-static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static void null_end_frame(AVFilterLink *inlink) { }
 
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 298aae4..2f641f2 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -367,10 +367,10 @@ static void end_frame(AVFilterLink *link)
     ff_end_frame(link->dst->outputs[0]);
 }
 
-static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)
+static int draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)
 {
     PadContext *pad = link->dst->priv;
-    int bar_y, bar_h = 0;
+    int bar_y, bar_h = 0, ret = 0;
 
     if        (slice_dir * before_slice ==  1 && y == pad->y) {
         /* top bar */
@@ -387,15 +387,17 @@ static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir,
                           link->dst->outputs[0]->out_buf->linesize,
                           pad->line, pad->line_step, pad->hsub, pad->vsub,
                           0, bar_y, pad->w, bar_h);
-        ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir);
+        ret = ff_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir);
     }
+    return ret;
 }
 
-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)
 {
     PadContext *pad = link->dst->priv;
     AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf;
     AVFilterBufferRef *inpic = link->cur_buf;
+    int ret;
 
     y += pad->y;
 
@@ -403,7 +405,7 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
     h &= ~((1 << pad->vsub) - 1);
 
     if (!h)
-        return;
+        return 0;
     draw_send_bar_slice(link, y, h, slice_dir, 1);
 
     /* left border */
@@ -421,9 +423,11 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
     ff_draw_rectangle(outpic->data, outpic->linesize,
                       pad->line, pad->line_step, pad->hsub, pad->vsub,
                       pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h);
-    ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
+    ret = ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
+    if (ret < 0)
+        return ret;
 
-    draw_send_bar_slice(link, y, h, slice_dir, -1);
+    return draw_send_bar_slice(link, y, h, slice_dir, -1);
 }
 
 AVFilter avfilter_vf_pad = {
diff --git a/libavfilter/vf_pixdesctest.c b/libavfilter/vf_pixdesctest.c
index ae0a506..caf0852 100644
--- a/libavfilter/vf_pixdesctest.c
+++ b/libavfilter/vf_pixdesctest.c
@@ -90,7 +90,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     PixdescTestContext *priv = inlink->dst->priv;
     AVFilterBufferRef *inpic    = inlink->cur_buf;
@@ -117,7 +117,7 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+    return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
 }
 
 AVFilter avfilter_vf_pixdesctest = {
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 6c54210..73f31a6 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -291,16 +291,15 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
     return 0;
 }
 
-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)
 {
     ScaleContext *scale = link->dst->priv;
-    int out_h;
+    int out_h, ret;
     AVFilterBufferRef *cur_pic = link->cur_buf;
     const uint8_t *data[4];
 
     if (!scale->sws) {
-        ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
-        return;
+        return ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
     }
 
     if (scale->slice_y == 0 && slice_dir == -1)
@@ -319,9 +318,10 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 
     if (slice_dir == -1)
         scale->slice_y -= out_h;
-    ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir);
+    ret = ff_draw_slice(link->dst->outputs[0], scale->slice_y, out_h, slice_dir);
     if (slice_dir == 1)
         scale->slice_y += out_h;
+    return ret;
 }
 
 AVFilter avfilter_vf_scale = {
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
index 8b3a6f8..a4bb2df 100644
--- a/libavfilter/vf_select.c
+++ b/libavfilter/vf_select.c
@@ -249,12 +249,13 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     SelectContext *select = inlink->dst->priv;
 
     if (select->select && !select->cache_frames)
-        ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+        return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
+    return 0;
 }
 
 static void end_frame(AVFilterLink *inlink)
diff --git a/libavfilter/vf_slicify.c b/libavfilter/vf_slicify.c
index 0999487..3c69cfd 100644
--- a/libavfilter/vf_slicify.c
+++ b/libavfilter/vf_slicify.c
@@ -78,24 +78,31 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *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;
 }
 
 AVFilter avfilter_vf_slicify = {
diff --git a/libavfilter/vf_unsharp.c b/libavfilter/vf_unsharp.c
index dcf4ebe..41bcae2 100644
--- a/libavfilter/vf_unsharp.c
+++ b/libavfilter/vf_unsharp.c
@@ -229,8 +229,9 @@ static void end_frame(AVFilterLink *link)
     ff_end_frame(link->dst->outputs[0]);
 }
 
-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)
 {
+    return 0;
 }
 
 AVFilter avfilter_vf_unsharp = {
diff --git a/libavfilter/vf_vflip.c b/libavfilter/vf_vflip.c
index c9a6c05..dc7604c 100644
--- a/libavfilter/vf_vflip.c
+++ b/libavfilter/vf_vflip.c
@@ -82,11 +82,11 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *inpicref)
     return ff_start_frame(link->dst->outputs[0], outpicref);
 }
 
-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)
 {
     AVFilterContext *ctx = link->dst;
 
-    ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir);
+    return ff_draw_slice(ctx->outputs[0], link->h - (y+h), h, -1 * slice_dir);
 }
 
 AVFilter avfilter_vf_vflip = {
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c
index 83bb4de..19652aa 100644
--- a/libavfilter/vf_yadif.c
+++ b/libavfilter/vf_yadif.c
@@ -377,7 +377,10 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
     return 0;
 }
 
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+    return 0;
+}
 
 static int config_props(AVFilterLink *link)
 {
diff --git a/libavfilter/video.c b/libavfilter/video.c
index bdd79b5..ffcc234 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -263,12 +263,12 @@ void ff_end_frame(AVFilterLink *link)
     clear_link(link);
 }
 
-void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 {
-    ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
+    return ff_draw_slice(link->dst->outputs[0], y, h, slice_dir);
 }
 
-static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterLink *outlink = NULL;
 
@@ -276,14 +276,15 @@ static void default_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir
         outlink = inlink->dst->outputs[0];
 
     if (outlink)
-        ff_draw_slice(outlink, y, h, slice_dir);
+        return ff_draw_slice(outlink, y, h, slice_dir);
+    return 0;
 }
 
-void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+int ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 {
     uint8_t *src[4], *dst[4];
-    int i, j, vsub;
-    void (*draw_slice)(AVFilterLink *, int, int, int);
+    int i, j, vsub, ret;
+    int (*draw_slice)(AVFilterLink *, int, int, int);
 
     FF_DPRINTF_START(NULL, draw_slice); ff_dlog_link(NULL, link, 0); av_dlog(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
 
@@ -317,5 +318,8 @@ void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
 
     if (!(draw_slice = link->dstpad->draw_slice))
         draw_slice = default_draw_slice;
-    draw_slice(link, y, h, slice_dir);
+    ret = draw_slice(link, y, h, slice_dir);
+    if (ret < 0)
+        clear_link(link);
+    return ret;
 }
diff --git a/libavfilter/video.h b/libavfilter/video.h
index 3edf47a..893960e 100644
--- a/libavfilter/video.h
+++ b/libavfilter/video.h
@@ -40,7 +40,7 @@ AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms,
                                        int w, int h);
 
 int ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
-void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
+int ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
 void ff_null_end_frame(AVFilterLink *link);
 
 /**
@@ -78,7 +78,9 @@ void ff_end_frame(AVFilterLink *link);
  *             from the top slice to the bottom slice if the value is 1,
  *             from the bottom slice to the top slice if the value is -1,
  *             for other values the behavior of the function is undefined.
+ *
+ * @return >= 0 on success, a negative AVERROR on error.
  */
-void ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
+int ff_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
 
 #endif /* AVFILTER_VIDEO_H */



More information about the ffmpeg-cvslog mailing list