diff mbox series

[FFmpeg-devel,2/2] avfilter/vf_scale: test return code of scale_frame()

Message ID 20240709093437.16563-2-ffmpeg@haasn.xyz
State New
Headers show
Series [FFmpeg-devel,1/2] avfilter/vf_scale: fix frame lifetimes | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Niklas Haas July 9, 2024, 9:34 a.m. UTC
From: Niklas Haas <git@haasn.dev>

Instead of testing the returned frame against NULL, test the return code
itself, going more in line with the usual behavior of such functions.
---
 libavfilter/vf_scale.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index a1a322ed9e..ae7356fd7b 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -883,7 +883,6 @@  static int scale_frame(AVFilterLink *link, AVFrame **frame_in,
     int frame_changed;
 
     *frame_in = NULL;
-    *frame_out = NULL;
     if (in->colorspace == AVCOL_SPC_YCGCO)
         av_log(link->dst, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
 
@@ -1064,14 +1063,15 @@  FF_ENABLE_DEPRECATION_WARNINGS
     }
 
     ret = scale_frame(ctx->inputs[0], &in, &out);
-    if (out) {
-        out->pts = av_rescale_q(fs->pts, fs->time_base, outlink->time_base);
-        return ff_filter_frame(outlink, out);
-    }
+    if (ret < 0)
+        goto err;
+
+    av_assert0(out);
+    out->pts = av_rescale_q(fs->pts, fs->time_base, outlink->time_base);
+    return ff_filter_frame(outlink, out);
 
 err:
-    if (ret < 0)
-        av_frame_free(&in);
+    av_frame_free(&in);
     return ret;
 }