From 4154609e5de76bc8858d3f86e0af09ba2700c488 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 23 Sep 2017 21:57:45 +0200 Subject: Fix colour distortion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/blind-to-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/blind-to-video.c') diff --git a/src/blind-to-video.c b/src/blind-to-video.c index d57920d..a902c35 100644 --- a/src/blind-to-video.c +++ b/src/blind-to-video.c @@ -119,8 +119,8 @@ PROCESS(struct stream *stream, size_t n) b = srgb_encode(b); srgb_to_yuv(r, g, b, pixel + 0, pixel + 1, pixel + 2); y = (long int)(pixel[0] * 0xDAF4L) + 0x1001L; - u = (long int)(pixel[1] * 0xFFFFL) + 0x8000L; - v = (long int)(pixel[2] * 0xFFFFL) + 0x8000L; + u = (long int)(pixel[1] * 0xFF00L) + 0x8000L; + v = (long int)(pixel[2] * 0xFF00L) + 0x8000L; *pixels++ = htole((uint16_t)CLIP(0, a, 0xFFFFL)); *pixels++ = htole((uint16_t)CLIP(0, y, 0xFFFFL)); *pixels++ = htole((uint16_t)CLIP(0, u, 0xFFFFL)); -- cgit v1.2.3-70-g09d2