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

Mateusz mateuszb at poczta.onet.pl
Fri Feb 2 18:50:04 EET 2018


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 at 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
-------------- next part --------------
#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;
}


More information about the ffmpeg-devel mailing list