diff mbox series

[FFmpeg-devel,18/24] sws: move initializing dither_error higher up

Message ID 20210531075515.19544-18-anton@khirnov.net
State Accepted
Commit d6649d9a3badfae00b8735e6d8628ab2b856dccd
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
It does not interact in any way with the code setting up the image
pointers/strides, so it should not be intermixed with it.
---
 libswscale/swscale.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer June 1, 2021, 12:33 p.m. UTC | #1
On Mon, May 31, 2021 at 09:55:09AM +0200, Anton Khirnov wrote:
> It does not interact in any way with the code setting up the image
> pointers/strides, so it should not be intermixed with it.
> ---
>  libswscale/swscale.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

ok

thx

[...]
diff mbox series

Patch

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 2d6ed95cfb..b9b2826911 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -907,6 +907,10 @@  int attribute_align_arg sws_scale(struct SwsContext *c,
     if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH)
         return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride);
 
+    if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0])
+        for (i = 0; i < 4; i++)
+            memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2));
+
     memcpy(src2,       srcSlice,  sizeof(src2));
     memcpy(dst2,       dst,       sizeof(dst2));
     memcpy(srcStride2, srcStride, sizeof(srcStride2));
@@ -959,10 +963,6 @@  int attribute_align_arg sws_scale(struct SwsContext *c,
         src2[0] = base;
     }
 
-    if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0])
-        for (i = 0; i < 4; i++)
-            memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2));
-
     if (c->sliceDir != 1) {
         // slices go from bottom to top => we flip the image internally
         for (i=0; i<4; i++) {