diff mbox

[FFmpeg-devel,1/2] swscale: fix dithers table for DITHER_COPY macro

Message ID 20171024080217.2868-1-mateuszb@poczta.onet.pl
State New
Headers show

Commit Message

Mateusz Oct. 24, 2017, 8:02 a.m. UTC
The Bayer matrix 8x8 used in DITHER_COPY macro is table dithers[5].
Remaining dithers[] matrixes are generated from this matrix by
downshift or upshift.

This patch fixes dithers[6] and dithers[7] matrixes -- they were
too dark.

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

Comments

Mateusz Nov. 11, 2017, 5:40 p.m. UTC | #1
W dniu 24.10.2017 o 10:02, Mateusz pisze:
> The Bayer matrix 8x8 used in DITHER_COPY macro is table dithers[5].
> Remaining dithers[] matrixes are generated from this matrix by
> downshift or upshift.
> 
> This patch fixes dithers[6] and dithers[7] matrixes -- they were
> too dark.

ping
Mateusz Feb. 2, 2018, 4:50 p.m. UTC | #2
W dniu 24.10.2017 o 10:02, Mateusz pisze:
> The Bayer matrix 8x8 used in DITHER_COPY macro is table dithers[5].
> Remaining dithers[] matrixes are generated from this matrix by
> downshift or upshift.
> 
> This patch fixes dithers[6] and dithers[7] matrixes -- they were
> too dark.
> 
> Signed-off-by: Mateusz Brzostek <mateuszb@poczta.onet.pl>
> ---
>  libswscale/swscale_unscaled.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

ping 2

I've attached simple C program that generates all dithers[] tables
from dithers[5] table. There are 512 numbers to check, so it is simpler
to generate all tables, copy result to source file and use 'git diff'
to check them all.

It's time to finally fix DITHER_COPY macro and maybe optionally copy 
the changes to release 3.4.2.

Mateusz
#include <stdio.h>
#include <stdint.h>

const uint8_t dithers5[8][8] = {
  {  18, 34, 30, 46, 17, 33, 29, 45,},
  {  50,  2, 62, 14, 49,  1, 61, 13,},
  {  26, 42, 22, 38, 25, 41, 21, 37,},
  {  58, 10, 54,  6, 57,  9, 53,  5,},
  {  16, 32, 28, 44, 19, 35, 31, 47,},
  {  48,  0, 60, 12, 51,  3, 63, 15,},
  {  24, 40, 20, 36, 27, 43, 23, 39,},
  {  56,  8, 52,  4, 59, 11, 55,  7,},
};

int main() {
    for (int b = 0; b < 8; b++) {
        for (int y = 0; y < 8; y++) {
            printf("  { ");
            for (int x = 0; x < 8; x++)
                printf("%3d,", b <= 5 ? dithers5[y][x] >> (5-b) : dithers5[y][x] << (b-5));
            printf("},\n");
        }
        printf("},{\n");
    }
    return 0;
}
diff mbox

Patch

diff --git a/libswscale/swscale_unscaled.c b/libswscale/swscale_unscaled.c
index 5d81cd5af9..6ffde1ec59 100644
--- a/libswscale/swscale_unscaled.c
+++ b/libswscale/swscale_unscaled.c
@@ -90,15 +90,6 @@  DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={
   {  48,  0, 60, 12, 51,  3, 63, 15,},
   {  24, 40, 20, 36, 27, 43, 23, 39,},
   {  56,  8, 52,  4, 59, 11, 55,  7,},
-},{
-  {  18, 34, 30, 46, 17, 33, 29, 45,},
-  {  50,  2, 62, 14, 49,  1, 61, 13,},
-  {  26, 42, 22, 38, 25, 41, 21, 37,},
-  {  58, 10, 54,  6, 57,  9, 53,  5,},
-  {  16, 32, 28, 44, 19, 35, 31, 47,},
-  {  48,  0, 60, 12, 51,  3, 63, 15,},
-  {  24, 40, 20, 36, 27, 43, 23, 39,},
-  {  56,  8, 52,  4, 59, 11, 55,  7,},
 },{
   {  36, 68, 60, 92, 34, 66, 58, 90,},
   { 100,  4,124, 28, 98,  2,122, 26,},
@@ -108,6 +99,15 @@  DECLARE_ALIGNED(8, static const uint8_t, dithers)[8][8][8]={
   {  96,  0,120, 24,102,  6,126, 30,},
   {  48, 80, 40, 72, 54, 86, 46, 78,},
   { 112, 16,104,  8,118, 22,110, 14,},
+},{
+  {  72,136,120,184, 68,132,116,180,},
+  { 200,  8,248, 56,196,  4,244, 52,},
+  { 104,168, 88,152,100,164, 84,148,},
+  { 232, 40,216, 24,228, 36,212, 20,},
+  {  64,128,112,176, 76,140,124,188,},
+  { 192,  0,240, 48,204, 12,252, 60,},
+  {  96,160, 80,144,108,172, 92,156,},
+  { 224, 32,208, 16,236, 44,220, 28,},
 }};