ref: ebae65d8a472ede5e1a6e299c2a7d54bf95c319f
parent: 17578ac2a4ded4303459881acd0d149188692292
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Jul 30 18:54:32 EDT 2022
much betta
--- a/hj264.c
+++ b/hj264.c
@@ -62,7 +62,7 @@
u8int bgrx[];
};
-static uvlong nframes, tstart, debug;
+static uvlong tstart, debug;
static int opt;
#pragma varargck type "ℏ" int
@@ -228,7 +228,7 @@
{
Hj264 *h;
- h = *threaddata();
+ h = *procdata();
Bflush(&h->out);
return 1;
@@ -246,9 +246,9 @@
h = p;
prev = nil;
+ *procdata() = h;
threadsetname("hj264/encthread");
threadnotify(done, 1);
- *threaddata() = h;
for(;;){
if(recv(h->frame, &img) < 0)
@@ -332,8 +332,8 @@
main(int argc, char **argv)
{
int nthreads, fps, kbps, denoise, quality, qp, gop;
+ uvlong fstart, fend, f₀, nframes;
char *s, tmp[61], *f[5];
- uvlong fstart, fend, f₀;
int ww, hh, in, fmt;
u8int v[20];
Img *img;
@@ -459,8 +459,11 @@
break;
fend = npe_nanosec();
- if(debug && nframes > 0 && (nframes % fps) == 0)
+ if(debug && nframes > 0 && (nframes % fps) == 0){
fprint(2, "avg fps: %llud\n", nframes/((fend - f₀)/Nsec));
+ f₀ = npe_nanosec();
+ nframes = -1;
+ }
if(Nsec/fps > (fend - fstart))
npe_nsleep(Nsec/fps - (fend - fstart));