ref: 6d3d30870972151e7ebfef6ded2ecb410dea4bbf
parent: 29ac3d1e5745ea2476951074c9e643e4a6ddca8b
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Dec 16 08:21:44 EST 2020
split bw/color branches
--- a/main.c
+++ b/main.c
@@ -13,7 +13,7 @@
int mainstacksize = 128*1024;
static Image *curim;
-static u8int *rgb;
+static u8int *curpx;
static uvlong lastframe;
static int audiofd = -1;
static Channel *audiosync;
@@ -81,21 +81,26 @@
if(curim != nil && (Dx(curim->r) != f->w || Dy(curim->r) != f->h)){
freeimage(curim);
curim = nil;
- free(rgb);
- rgb = nil;
+ free(curpx);
+ curpx = nil;
}
r = Rect(0,0,f->w,f->h);
- if(curim == nil)
- curim = allocimage(display, r, bw ? GREY8 : RGB24, 0, DNofill);
- if(rgb == nil)
- rgb = malloc(f->w*f->h*(bw ? 1 : 3));
if(bw){
+ if(curim == nil)
+ curim = allocimage(display, r, GREY8, 0, DNofill);
+ if(curpx == nil)
+ curpx = malloc(f->w*f->h);
for(y = 0; y < f->h; y++)
- memmove(rgb+f->w*y, f->yuv[0]+f->ystride*y, f->w);
+ memmove(curpx+f->w*y, f->yuv[0]+f->ystride*y, f->w);
+ loadimage(curim, r, curpx, f->w*f->h);
}else{
- yuv420_rgb24(f->w, f->h, f->yuv[0], f->yuv[1], f->yuv[2], f->ystride, f->uvstride, rgb, f->w*3);
+ if(curim == nil)
+ curim = allocimage(display, r, RGB24, 0, DNofill);
+ if(curpx == nil)
+ curpx = 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, curpx, f->w*3);
+ loadimage(curim, r, curpx, f->w*f->h*3);
}
- loadimage(curim, r, rgb, f->w*f->h*(bw ? 1 : 3));
dispdelay = nanosec() - x;