diff mbox

[FFmpeg-devel,2/2] swscale: use dithering in DITHER_COPY only if not set -sws_dither none

Message ID 20171024080217.2868-2-mateuszb@poczta.onet.pl
State Accepted
Commit 50ce2960263daf48227df758df9ade19db7154fa
Headers show

Commit Message

Mateusz Oct. 24, 2017, 8:02 a.m. UTC
This patch uses dithering in DITHER_COPY macro only if
it was not used option '-sws_dither none'.
With option '-sws_dither none' it uses downshift.

For human eye dithering is OK, for video codecs not necessarily.
If user don't want to use dithering, we should respect that.

Signed-off-by: Mateusz Brzostek <mateuszb@poczta.onet.pl>
---
 libswscale/swscale_unscaled.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Oct. 25, 2017, 5:59 p.m. UTC | #1
On Tue, Oct 24, 2017 at 10:02:17AM +0200, Mateusz wrote:
> This patch uses dithering in DITHER_COPY macro only if
> it was not used option '-sws_dither none'.
> With option '-sws_dither none' it uses downshift.
> 
> For human eye dithering is OK, for video codecs not necessarily.
> If user don't want to use dithering, we should respect that.
> 
> Signed-off-by: Mateusz Brzostek <mateuszb@poczta.onet.pl>
> ---
>  libswscale/swscale_unscaled.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 6ffde1ec59..01d6d653bc 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -1485,7 +1485,25 @@  static int packedCopyWrapper(SwsContext *c, const uint8_t *src[],
 
 #define DITHER_COPY(dst, dstStride, src, srcStride, bswap, dbswap)\
     unsigned shift= src_depth-dst_depth, tmp;\
-    if (shiftonly) {\
+    if (c->dither == SWS_DITHER_NONE) {\
+        for (i = 0; i < height; i++) {\
+            for (j = 0; j < length-7; j+=8) {\
+                dst[j+0] = dbswap(bswap(src[j+0])>>shift);\
+                dst[j+1] = dbswap(bswap(src[j+1])>>shift);\
+                dst[j+2] = dbswap(bswap(src[j+2])>>shift);\
+                dst[j+3] = dbswap(bswap(src[j+3])>>shift);\
+                dst[j+4] = dbswap(bswap(src[j+4])>>shift);\
+                dst[j+5] = dbswap(bswap(src[j+5])>>shift);\
+                dst[j+6] = dbswap(bswap(src[j+6])>>shift);\
+                dst[j+7] = dbswap(bswap(src[j+7])>>shift);\
+            }\
+            for (; j < length; j++) {\
+                dst[j] = dbswap(bswap(src[j])>>shift);\
+            }\
+            dst += dstStride;\
+            src += srcStride;\
+        }\
+    } else if (shiftonly) {\
         for (i = 0; i < height; i++) {\
             const uint8_t *dither= dithers[shift-1][i&7];\
             for (j = 0; j < length-7; j+=8) {\