ref: 4ddd74becb975b678d89c5d738e701b235607c5b
parent: 4968057b69842a4e3a73149fb26c01a25a69b935
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Aug 4 14:03:29 EDT 2021
add -O option to disable optimizations
--- a/hj264.c
+++ b/hj264.c
@@ -63,6 +63,8 @@
u8int bgrx[];
};
+static int nopt;
+
#pragma varargck type "ℏ" int
static int
hjerror(Fmt *f)
@@ -239,7 +241,7 @@
for(;;){
if((img = recvp(h->frame)) == nil)
break;
- if(prev != nil && memcmp(img->bgrx, prev->bgrx, img->w*img->h*4) == 0){
+ if(!nopt && prev != nil && memcmp(img->bgrx, prev->bgrx, img->w*img->h*4) == 0){
free(img);
continue;
}
@@ -246,8 +248,12 @@
xrgb2yuv420(img->bgrx, img->w, img->h, &h->yuv);
ts = img->ns / Nmsec;
- free(prev);
- prev = img;
+ if(!nopt){
+ free(prev);
+ prev = img;
+ }else{
+ free(img);
+ }
if(hj264_encode(h, &data, &sz) != 0)
sysfatal("hj264_encode: %r");
@@ -305,7 +311,7 @@
static void
usage(void)
{
- fprint(2, "usage: %s [-D] [-f FPS] [-F FORMAT] [-g GOP] [-n THREADS] [-k KBPS] [-q 0…10] [-Q QP] FILE\n", argv0);
+ fprint(2, "usage: %s [-D] [-f FPS] [-F FORMAT] [-g GOP] [-n THREADS] [-O] [-k KBPS] [-q 0…10] [-Q QP] FILE\n", argv0);
threadexitsall("usage");
}
@@ -376,6 +382,9 @@
break;
case 'n':
nthreads = atoi(EARGF(usage()));
+ break;
+ case 'O':
+ nopt = 1;
break;
case 'q':
quality = atoi(EARGF(usage()));