shithub: treason

Download patch

ref: 54665a8d26c814f399e8dfd7bc85cb7e00484712
parent: cc9ca3545bb7e030a3fb4f95fa7fdf8b0ebfdeff
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Dec 14 08:24:01 EST 2020

show decoding and total times

--- a/decoder.h
+++ b/decoder.h
@@ -7,6 +7,7 @@
 	Channel *finished;
 	Decoderops *ops;
 	double timebase;
+	uvlong decodetime;
 
 	void *aux;
 	char info[128];
--- a/decoder_av1.c
+++ b/decoder_av1.c
@@ -44,6 +44,7 @@
 	uvlong lasttimestamp;
 	Dav1dPicture pic;
 	Dav1dData data;
+	uvlong start;
 	Decoder *d;
 	Channel *c;
 	Frame *f;
@@ -58,7 +59,9 @@
 		if(data.sz == 0)
 			break;
 
+		start = nanosec();
 		res = dav1d_get_picture(a->c, &pic);
+		d->decodetime = nanosec() - start;
 		if(res < 0){
 			if(res != DAV1D_ERR(EAGAIN)){
 				werrstr("dav1d_get_picture: %d", res);
--- a/decoder_h264.c
+++ b/decoder_h264.c
@@ -164,10 +164,12 @@
 	Streamframe sf;
 	Aux *a;
 	int res, w, h, *stride;
+	uvlong start;
 
 	d = x;
 	a = d->aux;
 	lasttimestamp = 0;
+	start = nanosec();
 	for(res = 0; res >= 0 && (res = Sread(d->s, &sf)) == 0 && sf.sz > 0;){
 		if((res = WelsDecodeBs(&a->ctx, sf.buf, sf.sz, a->data, &a->info, nil)) != 0){
 			werrstr("WelsDecodeBs: error %#x", res);
@@ -183,9 +185,11 @@
 			if(a->data[0] == nil)
 				continue;
 		}
+		d->decodetime = nanosec() - start;
 
 		if(sf.timestamp < lasttimestamp) /* this is not supposed to happen unless mcfs is wrong */
 			continue;
+
 		w = a->info.UsrData.sSystemBuffer.iWidth;
 		h = a->info.UsrData.sSystemBuffer.iHeight;
 		if((f = malloc(sizeof(*f) + w*h*3)) == nil)
@@ -206,6 +210,7 @@
 			free(f);
 			goto done;
 		}
+		start = nanosec();
 	}
 	if(res != 0)
 		fprint(2, "h264: %r\n");
--- a/decoder_vpx.c
+++ b/decoder_vpx.c
@@ -27,6 +27,7 @@
 	int res;
 	u8int *pic;
     vpx_codec_iter_t iter;
+    uvlong start;
     vpx_image_t *im;
 
 	threadsetname("decoder/vpx");
@@ -35,10 +36,12 @@
 	lasttimestamp = 0;
 	memset(&pic, 0, sizeof(pic));
 	for(res = 0; res >= 0 && (res = Sread(d->s, &sf)) == 0 && sf.sz > 0;){
+		start = nanosec();
 		if((res = vpx_codec_decode(&a->ctx, sf.buf, sf.sz, NULL, 0)) != 0){
 			werrstr("vpx_codec_decode failed");
 			break;
 		}
+		d->decodetime = nanosec() - start;
 
 		for(iter = nil;;){
 			if((im = vpx_codec_get_frame(&a->ctx, &iter)) == nil)
--- a/main.c
+++ b/main.c
@@ -19,7 +19,7 @@
 static Channel *audiofinished;
 static char info[256];
 static int showinfo;
-static uvlong delay;
+static uvlong dispdelay;
 static int framedrop;
 
 static void
@@ -56,8 +56,8 @@
 	if(lastframe == 0)
 		lastframe = nanosec();
 
-	end = lastframe + f->dt - delay;
-	if(framedrop && delay > 0 && nanosec() >= end+delay)
+	end = lastframe + f->dt - dispdelay;
+	if(framedrop && dispdelay > 0 && nanosec() >= end+dispdelay)
 		goto drop;
 
 	lockdisplay(display);
@@ -100,7 +100,7 @@
 	flushimage(display, 1);
 	unlockdisplay(display);
 
-	delay = nanosec() - x;
+	dispdelay = nanosec() - x;
 drop:
 	if(audiosync != nil)
 		sendp(audiosync, nil);
@@ -234,9 +234,11 @@
 			case Cframe:
 				snprint(
 					info, sizeof(info),
-					"yuv→rgb=%zdms display=%zdms %dx%d %s %s",
-					delay/1000000ULL,
+					"decode=%zdms yuv→rgb=%zdms display=%zdms total=%zdms %dx%d %s %s",
+					d->decodetime/1000000ULL,
+					dispdelay/1000000ULL,
 					yuv→rgb/1000000ULL,
+					(d->decodetime + dispdelay + yuv→rgb)/1000000ULL,
 					frame->w, frame->h,
 					d->info,
 					d->s->info