From 1519bc79a4bc7749b0e4808d78f3ee0c171db9e8 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 13 Jan 2017 08:59:01 +0100 Subject: vu-from-video: fix Y'UV encoding + add vu-to-video MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/vu-from-video.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/vu-from-video.c') diff --git a/src/vu-from-video.c b/src/vu-from-video.c index 92503bb..c780b55 100644 --- a/src/vu-from-video.c +++ b/src/vu-from-video.c @@ -112,9 +112,9 @@ convert_segment(char *buf, size_t n, int fd, char *file) if (draft) { for (ptr = i = 0; ptr < n; ptr += 8) { pixels[i][3] = ntohs(((uint16_t *)(buf + ptr))[0]) / max; - y = ntohs(((uint16_t *)(buf + ptr))[1]); - u = ntohs(((uint16_t *)(buf + ptr))[2]); - v = ntohs(((uint16_t *)(buf + ptr))[3]); + y = (ntohs(((uint16_t *)(buf + ptr))[1]) - 16 * 256); + u = (ntohs(((uint16_t *)(buf + ptr))[2]) - 128 * 256); + v = (ntohs(((uint16_t *)(buf + ptr))[3]) - 128 * 256); scaled_yuv_to_ciexyz(y, u, v, pixels[i] + 0, pixels[i] + 1, pixels[i] + 2); if (++i == 1024) { i = 0; @@ -124,9 +124,9 @@ convert_segment(char *buf, size_t n, int fd, char *file) } else { for (ptr = i = 0; ptr < n; ptr += 8) { pixels[i][3] = ntohs(((uint16_t *)(buf + ptr))[0]) / max; - y = ntohs(((uint16_t *)(buf + ptr))[1]) / max; - u = ntohs(((uint16_t *)(buf + ptr))[2]) / max; - v = ntohs(((uint16_t *)(buf + ptr))[3]) / max; + y = (ntohs(((uint16_t *)(buf + ptr))[1]) - 16 * 256) / max; + u = (ntohs(((uint16_t *)(buf + ptr))[2]) - 128 * 256) / max; + v = (ntohs(((uint16_t *)(buf + ptr))[3]) - 128 * 256) / max; yuv_to_srgb(y, u, v, &r, &g, &b); r = srgb_decode(r); g = srgb_decode(g); -- cgit v1.2.3-70-g09d2