diff options
Diffstat (limited to 'src/blind-to-video.c')
| -rw-r--r-- | src/blind-to-video.c | 14 |
1 files changed, 7 insertions, 7 deletions
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); } |
