aboutsummaryrefslogtreecommitdiffstats
path: root/src/vu-from-video.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-01-13 05:03:19 +0100
committerMattias Andrée <maandree@kth.se>2017-01-13 05:03:31 +0100
commit2640635b7d0f049ae15872ab9e7b5ef254233ccc (patch)
tree14dceb4727e3d46c3e0b3c747ff0134b24654fff /src/vu-from-video.c
parentAdd vu-from-video (diff)
downloadblind-2640635b7d0f049ae15872ab9e7b5ef254233ccc.tar.gz
blind-2640635b7d0f049ae15872ab9e7b5ef254233ccc.tar.bz2
blind-2640635b7d0f049ae15872ab9e7b5ef254233ccc.tar.xz
vu-from-video: add -d
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/vu-from-video.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/vu-from-video.c b/src/vu-from-video.c
index 96bd83d..9fa9942 100644
--- a/src/vu-from-video.c
+++ b/src/vu-from-video.c
@@ -2,6 +2,7 @@
#include "stream.h"
#include "util.h"
+#include <arpa/inet.h>
#if defined(HAVE_PRCTL)
# include <sys/prctl.h>
#endif
@@ -14,7 +15,9 @@
#include <string.h>
#include <unistd.h>
-USAGE("[-r frame-rate] [-w width -h height] input-file output-file")
+USAGE("[-r frame-rate] [-w width -h height] [-d] input-file output-file")
+
+static int draft = 0;
static void
read_metadata(FILE *fp, char *fname, size_t *width, size_t *height, size_t *frames)
@@ -106,19 +109,33 @@ convert_segment(char *buf, size_t n, int fd, char *file)
double y, u, v, max = (double)UINT16_MAX;
double r, g, b;
pixel_t pixels[1024];
- for (ptr = i = 0; ptr < n; ptr += 8, i++) {
- 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;
- yuv_to_srgb(y, u, v, &r, &g, &b);
- r = srgb_decode(r);
- g = srgb_decode(g);
- b = srgb_decode(b);
- srgb_to_ciexyz(r, g, b, pixels[i] + 0, pixels[i] + 1, pixels[i] + 2);
- if (++i == 1024) {
- i = 0;
- ewriteall(fd, pixels, sizeof(pixels), file);
+ if (draft) {
+ for (ptr = i = 0; ptr < n; ptr += 8, i++) {
+ 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]);
+ scaled_yuv_to_ciexyz(y, u, v, pixels[i] + 0, pixels[i] + 1, pixels[i] + 2);
+ if (++i == 1024) {
+ i = 0;
+ ewriteall(fd, pixels, sizeof(pixels), file);
+ }
+ }
+ } else {
+ for (ptr = i = 0; ptr < n; ptr += 8, i++) {
+ 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;
+ yuv_to_srgb(y, u, v, &r, &g, &b);
+ r = srgb_decode(r);
+ g = srgb_decode(g);
+ b = srgb_decode(b);
+ srgb_to_ciexyz(r, g, b, pixels[i] + 0, pixels[i] + 1, pixels[i] + 2);
+ if (++i == 1024) {
+ i = 0;
+ ewriteall(fd, pixels, sizeof(pixels), file);
+ }
}
}
if (i)
@@ -209,6 +226,9 @@ main(int argc, char *argv[])
struct stat st;
ARGBEGIN {
+ case 'd':
+ draft = 1;
+ break;
case 'r':
frame_rate = EARG();
break;