aboutsummaryrefslogtreecommitdiffstats
path: root/src/vu-from-video.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-13 08:59:01 +0100
committerMattias Andrée <maandree@kth.se>2017-01-13 08:59:01 +0100
commit1519bc79a4bc7749b0e4808d78f3ee0c171db9e8 (patch)
treee03d704079cc8c5a47763933b6a6cc0e0b8934dd /src/vu-from-video.c
parentvu-from-image: style fix + vu-from-video: fix loop (diff)
downloadblind-1519bc79a4bc7749b0e4808d78f3ee0c171db9e8.tar.gz
blind-1519bc79a4bc7749b0e4808d78f3ee0c171db9e8.tar.bz2
blind-1519bc79a4bc7749b0e4808d78f3ee0c171db9e8.tar.xz
vu-from-video: fix Y'UV encoding + add vu-to-video
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/vu-from-video.c')
-rw-r--r--src/vu-from-video.c12
1 files changed, 6 insertions, 6 deletions
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);