ref: 2d915aa23560d0af49997f36b979cb9f5a9f43da
parent: 97b0ebb4108acac122371253a54785ef54281648
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Feb 6 12:31:01 EST 2025
stop truncating the video, fix the weirdness about timestamps logic
--- a/hj264.c
+++ b/hj264.c
@@ -108,7 +108,7 @@
chanfree(done);
chanfree(job);
- threadexitsall(nil);
+ threadexits(nil);
}
static void
@@ -281,7 +281,7 @@
free(prev);
- threadexitsall(nil);
+ threadexits(nil);
}
static Img *
@@ -301,7 +301,7 @@
return nil;
}
}
- i->ns = tstart + npe_nanosec();
+ i->ns = npe_nanosec() - tstart;
if(tw > w){
p = i->bgrx + w*h*4;
tp = i->bgrx + tw*h*4;
@@ -315,6 +315,15 @@
return i;
}
+static int stop;
+
+static int
+note(void *, char *)
+{
+ stop = 1;
+ return 1;
+}
+
static void
usage(void)
{
@@ -333,6 +342,8 @@
Img *img;
Hj264 *h;
+ atnotify(note, 1);
+
/* use NPROC-1 threads by default */
nthreads = ((s = getenv("NPROC")) != nil) ? atoi(s)-1 : 1;
denoise = 0;
@@ -451,9 +462,11 @@
}
f₀ = npe_nanosec();
- tstart = nsec() - f₀;
+ tstart = f₀;
for(nframes = 0;; nframes++){
fstart = npe_nanosec();
+ if(stop)
+ break;
if((img = imgread(in, ww₀, hh₀, ww, hh)) == nil)
break;
if(sendp(h->frame, img) != 1)
--
⑨