From deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 9 Apr 2017 17:33:31 +0200 Subject: Clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-to-video.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/blind-to-video.c') diff --git a/src/blind-to-video.c b/src/blind-to-video.c index 04cfd91..4da9306 100644 --- a/src/blind-to-video.c +++ b/src/blind-to-video.c @@ -34,9 +34,9 @@ process_xyza(char *buf, size_t n, int fd, const char *fname) u = (long int)g + 128L * 256L; v = (long int)b + 128L * 256L; *pixels++ = 0xFFFFU; - *pixels++ = htole16((uint16_t)(y < 0 ? 0 : y > 0xFFFFL ? 0xFFFFL : y)); - *pixels++ = htole16((uint16_t)(u < 0 ? 0 : u > 0xFFFFL ? 0xFFFFL : u)); - *pixels++ = htole16((uint16_t)(v < 0 ? 0 : v > 0xFFFFL ? 0xFFFFL : v)); + *pixels++ = htole16((uint16_t)CLIP(0, y, 0xFFFFL)); + *pixels++ = htole16((uint16_t)CLIP(0, u, 0xFFFFL)); + *pixels++ = htole16((uint16_t)CLIP(0, v, 0xFFFFL)); if (pixels == end) ewriteall(fd, pixels = pixbuf, sizeof(pixbuf), fname); } @@ -52,10 +52,10 @@ process_xyza(char *buf, size_t n, int fd, const char *fname) y = (long int)(pixel[0] * 0xFFFFL) + 16L * 256L; u = (long int)(pixel[1] * 0xFFFFL) + 128L * 256L; v = (long int)(pixel[2] * 0xFFFFL) + 128L * 256L; - *pixels++ = htole16((uint16_t)(a < 0 ? 0 : a > 0xFFFFL ? 0xFFFFL : a)); - *pixels++ = htole16((uint16_t)(y < 0 ? 0 : y > 0xFFFFL ? 0xFFFFL : y)); - *pixels++ = htole16((uint16_t)(u < 0 ? 0 : u > 0xFFFFL ? 0xFFFFL : u)); - *pixels++ = htole16((uint16_t)(v < 0 ? 0 : v > 0xFFFFL ? 0xFFFFL : v)); + *pixels++ = htole16((uint16_t)CLIP(0, a, 0xFFFFL)); + *pixels++ = htole16((uint16_t)CLIP(0, y, 0xFFFFL)); + *pixels++ = htole16((uint16_t)CLIP(0, u, 0xFFFFL)); + *pixels++ = htole16((uint16_t)CLIP(0, v, 0xFFFFL)); if (pixels == end) ewriteall(fd, pixels = pixbuf, sizeof(pixbuf), fname); } -- cgit v1.2.3-70-g09d2