[FFmpeg-cvslog] lavfi/vf_scale: forward errors from swscale

Anton Khirnov git at videolan.org
Mon Jul 12 13:52:53 EEST 2021


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 23 16:06:55 2021 +0200| [a948e47960fb16819af16d0542a203c59d8de157] | committer: Anton Khirnov

lavfi/vf_scale: forward errors from swscale

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

 libavfilter/vf_scale.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 72b49e8918..71d7fa2890 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -655,6 +655,7 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
     AVFrame *out;
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
     char buf[32];
+    int ret;
     int in_range;
     int frame_changed;
 
@@ -669,7 +670,6 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out)
                     in->sample_aspect_ratio.num != link->sample_aspect_ratio.num;
 
     if (scale->eval_mode == EVAL_MODE_FRAME || frame_changed) {
-        int ret;
         unsigned vars_w[VARS_NB] = { 0 }, vars_h[VARS_NB] = { 0 };
 
         av_expr_count_vars(scale->w_pexpr, vars_w, VARS_NB);
@@ -791,8 +791,9 @@ scale:
               INT_MAX);
 
     if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) {
-        scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0);
-        scale_slice(scale, out, in, scale->isws[1], 0,  link->h   /2, 2, 1);
+        ret = scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0);
+        if (ret >= 0)
+            ret = scale_slice(scale, out, in, scale->isws[1], 0,  link->h   /2, 2, 1);
     } else if (scale->nb_slices) {
         int i, slice_h, slice_start, slice_end = 0;
         const int nb_slices = FFMIN(scale->nb_slices, link->h);
@@ -800,14 +801,18 @@ scale:
             slice_start = slice_end;
             slice_end   = (link->h * (i+1)) / nb_slices;
             slice_h     = slice_end - slice_start;
-            scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0);
+            ret = scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0);
+            if (ret < 0)
+                break;
         }
     } else {
-        scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0);
+        ret = scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0);
     }
 
     av_frame_free(&in);
-    return 0;
+    if (ret < 0)
+        av_frame_free(frame_out);
+    return ret;
 }
 
 static int filter_frame(AVFilterLink *link, AVFrame *in)



More information about the ffmpeg-cvslog mailing list