diff mbox series

[FFmpeg-devel,17/24] sws: move the early return for zero-sized slices higher up

Message ID 20210531075515.19544-17-anton@khirnov.net
State Accepted
Commit e1889855983094ca74c494d29b33e482b1bba865
Headers show
Series [FFmpeg-devel,01/24] sws: remove unnecessary braces | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Anton Khirnov May 31, 2021, 7:55 a.m. UTC
Place it right after the input parameter validation. There is no point
in performing any setup if the sws_scale() call won't do anything.
---
 libswscale/swscale.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer June 1, 2021, 12:32 p.m. UTC | #1
On Mon, May 31, 2021 at 09:55:08AM +0200, Anton Khirnov wrote:
> Place it right after the input parameter validation. There is no point
> in performing any setup if the sws_scale() call won't do anything.
> ---
>  libswscale/swscale.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 270adcc072..2d6ed95cfb 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -897,6 +897,10 @@  int attribute_align_arg sws_scale(struct SwsContext *c,
         return AVERROR(EINVAL);
     }
 
+    // do not mess up sliceDir if we have a "trailing" 0-size slice
+    if (srcSliceH == 0)
+        return 0;
+
     if (c->gamma_flag && c->cascaded_context[0])
         return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride);
 
@@ -908,10 +912,6 @@  int attribute_align_arg sws_scale(struct SwsContext *c,
     memcpy(srcStride2, srcStride, sizeof(srcStride2));
     memcpy(dstStride2, dstStride, sizeof(dstStride2));
 
-    // do not mess up sliceDir if we have a "trailing" 0-size slice
-    if (srcSliceH == 0)
-        return 0;
-
     if (frame_start) {
         if (srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
             av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");