diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-09-23 21:57:45 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-09-23 21:57:45 +0200 |
| commit | 4154609e5de76bc8858d3f86e0af09ba2700c488 (patch) | |
| tree | 853583f99e97895a51db57d0e66672672d20c2f9 /src/blind-from-video.c | |
| parent | Fix conversion of Y value (diff) | |
| download | blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.gz blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.bz2 blind-4154609e5de76bc8858d3f86e0af09ba2700c488.tar.xz | |
Fix colour distortion
This matrices are not convert to or from the proper YUV colour space both
rather the ones used in videos. srgb_to_yuv was created by converting the
image [sRGB(100%, 0, 0); sRGB(0, 100%, 0); sRGB(0, 0, 100%)] to YUV with
FFmpeg and transposing the matrix. yuv_to_srgb is the inversion of that
matrix, the values in the first column should all be 1 but are not due to
rounding/truncation error.
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-from-video.c')
| -rw-r--r-- | src/blind-from-video.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/blind-from-video.c b/src/blind-from-video.c index f258058..3041ea1 100644 --- a/src/blind-from-video.c +++ b/src/blind-from-video.c @@ -75,7 +75,7 @@ get_metadata(char *file, size_t *width, size_t *height) do {\ typedef TYPE pixel_t[4];\ size_t i, ptr;\ - TYPE y, u, v, max = (TYPE)UINT16_MAX, ymax = (TYPE)0xDAF4;\ + TYPE y, u, v, max = (TYPE)0xFF00L, ymax = (TYPE)0xDAF4L;\ TYPE r, g, b;\ pixel_t pixels[1024];\ uint16_t *pix;\ @@ -97,6 +97,7 @@ get_metadata(char *file, size_t *width, size_t *height) for (ptr = i = 0; ptr < n; ptr += 8) {\ pix = (uint16_t *)(buf + ptr);\ pixels[i][3] = le16toh(pix[0]) / max;\ + pixels[i][3] = CLIP(0, pixels[i][3], 1);\ y = (TYPE)((long int)le16toh(pix[1]) - 0x1001L) / ymax;\ u = (TYPE)((long int)le16toh(pix[2]) - 0x8000L) / max;\ v = (TYPE)((long int)le16toh(pix[3]) - 0x8000L) / max;\ |
