ref: 29ac3d1e5745ea2476951074c9e643e4a6ddca8b
parent: dd0fde6262de2b1be2d49a6414c99e203d2a21b8
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Dec 16 05:40:27 EST 2020
add b&w mode (-b)
--- a/main.c
+++ b/main.c
@@ -23,6 +23,7 @@
static uvlong dispdelay;
static int framedrop;
static uvlong late;
+static int bw;
static void
audioproc(void *x)
@@ -60,6 +61,7 @@
{
uvlong x, end, left;
Rectangle r, clip;
+ int y;
x = nanosec();
if(lastframe == 0)
@@ -84,11 +86,16 @@
}
r = Rect(0,0,f->w,f->h);
if(curim == nil)
- curim = allocimage(display, r, RGB24, 0, DNofill);
+ curim = allocimage(display, r, bw ? GREY8 : RGB24, 0, DNofill);
if(rgb == nil)
- rgb = malloc(f->w*f->h*3);
- yuv420_rgb24(f->w, f->h, f->yuv[0], f->yuv[1], f->yuv[2], f->ystride, f->uvstride, rgb, f->w*3);
- loadimage(curim, r, rgb, f->w*f->h*3);
+ rgb = malloc(f->w*f->h*(bw ? 1 : 3));
+ if(bw){
+ for(y = 0; y < f->h; y++)
+ memmove(rgb+f->w*y, f->yuv[0]+f->ystride*y, f->w);
+ }else{
+ yuv420_rgb24(f->w, f->h, f->yuv[0], f->yuv[1], f->yuv[2], f->ystride, f->uvstride, rgb, f->w*3);
+ }
+ loadimage(curim, r, rgb, f->w*f->h*(bw ? 1 : 3));
dispdelay = nanosec() - x;
@@ -174,6 +181,9 @@
usage();
}
audio = EARGF(usage());
+ break;
+ case 'b':
+ bw++;
break;
case 'D':
framedrop++;