shithub: mcfs

Download patch

ref: cb8864eb448c73bf5ade441f12b00ead0d0a86a1
parent: 451447fc7b3cf5d6849b1b6168ca1eec8dfdfdf4
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Mar 16 22:05:45 EDT 2020

print debug info to stderr

--- a/iso.c
+++ b/iso.c
@@ -211,30 +211,30 @@
 	if(dflag == 0)
 		return;
 
-	print("%.*s%T\n", dind, ind, b->type);
+	fprint(2, "%.*s%T\n", dind, ind, b->type);
 
 	/* full box */
 	if(isfullbox(b)){
-		print("\t%.*sversion\t%d\n", dind, ind, b->version);
-		print("\t%.*sflags\t0x%ux\n", dind, ind, b->flags);
+		fprint(2, "\t%.*sversion\t%d\n", dind, ind, b->version);
+		fprint(2, "\t%.*sflags\t0x%ux\n", dind, ind, b->flags);
 	}
 
 	if(b->type == BoxFtyp){
-		print("\t%.*sbrand\t%T\n", dind, ind, b->ftyp.brand);
-		print("\t%.*sversion\t%d\n", dind, ind, b->ftyp.version);
-		print("\t%.*scompat", dind, ind);
+		fprint(2, "\t%.*sbrand\t%T\n", dind, ind, b->ftyp.brand);
+		fprint(2, "\t%.*sversion\t%d\n", dind, ind, b->ftyp.version);
+		fprint(2, "\t%.*scompat", dind, ind);
 		for(i = 0; i < b->ftyp.ncompat; i++)
-			print("\t%.*s%T", dind, ind, b->ftyp.compat[i]);
-		print("\n");
+			fprint(2, "\t%.*s%T", dind, ind, b->ftyp.compat[i]);
+		fprint(2, "\n");
 	}else if(b->type == BoxMvhd){
-		print("\t%.*screation\t%zd\n", dind, ind, b->mvhd.creation);
-		print("\t%.*smodification\t%zd\n", dind, ind, b->mvhd.modification);
-		print("\t%.*stimescale\t%ud\n", dind, ind, b->mvhd.timescale);
-		print("\t%.*sduration\t%zd\n", dind, ind, b->mvhd.duration);
-		print("\t%.*srate\t0x%ux\n", dind, ind, b->mvhd.rate);
-		print("\t%.*svolume\t0x%ux\n", dind, ind, b->mvhd.volume);
-		print("\t%.*snexttrack\t0x%ux\n", dind, ind, b->mvhd.nexttrack);
-		print("\t%.*smatrix\t0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux\n", dind, ind,
+		fprint(2, "\t%.*screation\t%zd\n", dind, ind, b->mvhd.creation);
+		fprint(2, "\t%.*smodification\t%zd\n", dind, ind, b->mvhd.modification);
+		fprint(2, "\t%.*stimescale\t%ud\n", dind, ind, b->mvhd.timescale);
+		fprint(2, "\t%.*sduration\t%zd\n", dind, ind, b->mvhd.duration);
+		fprint(2, "\t%.*srate\t0x%ux\n", dind, ind, b->mvhd.rate);
+		fprint(2, "\t%.*svolume\t0x%ux\n", dind, ind, b->mvhd.volume);
+		fprint(2, "\t%.*snexttrack\t0x%ux\n", dind, ind, b->mvhd.nexttrack);
+		fprint(2, "\t%.*smatrix\t0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux 0x%ux\n", dind, ind,
 			b->mvhd.matrix[0],
 			b->mvhd.matrix[1],
 			b->mvhd.matrix[2],
@@ -246,89 +246,89 @@
 			b->mvhd.matrix[8]
 		);
 	}else if(b->type == BoxTrex){
-		print("\t%.*strackid\t0x%ux\n", dind, ind, b->trex.trackid);
-		print("\t%.*sdefsample.\n", dind, ind);
-		print("\t\t%.*s.descrindex\t0x%ux\n", dind, ind, b->trex.defsample.descrindex);
-		print("\t\t%.*s.duration\t%ud\n", dind, ind, b->trex.defsample.duration);
-		print("\t\t%.*s.size\t0x%ux\n", dind, ind, b->trex.defsample.size);
-		print("\t\t%.*s.flags\t0x%ux\n", dind, ind, b->trex.defsample.flags);
+		fprint(2, "\t%.*strackid\t0x%ux\n", dind, ind, b->trex.trackid);
+		fprint(2, "\t%.*sdefsample.\n", dind, ind);
+		fprint(2, "\t\t%.*s.descrindex\t0x%ux\n", dind, ind, b->trex.defsample.descrindex);
+		fprint(2, "\t\t%.*s.duration\t%ud\n", dind, ind, b->trex.defsample.duration);
+		fprint(2, "\t\t%.*s.size\t0x%ux\n", dind, ind, b->trex.defsample.size);
+		fprint(2, "\t\t%.*s.flags\t0x%ux\n", dind, ind, b->trex.defsample.flags);
 	}else if(b->type == BoxMfhd){
-		print("\t%.*sseqnumber\t%ud\n", dind, ind, b->mfhd.seqnumber);
+		fprint(2, "\t%.*sseqnumber\t%ud\n", dind, ind, b->mfhd.seqnumber);
 	}else if(b->type == BoxTfhd){
-		print("\t%.*strackid\t0x%ux\n", dind, ind, b->tfhd.trackid);
+		fprint(2, "\t%.*strackid\t0x%ux\n", dind, ind, b->tfhd.trackid);
 		if(b->flags & 1)
-			print("\t%.*sbaseoffset\t%zd\n", dind, ind, b->tfhd.baseoffset);
-		print("\t%.*sdefsample.\n", dind, ind);
+			fprint(2, "\t%.*sbaseoffset\t%zd\n", dind, ind, b->tfhd.baseoffset);
+		fprint(2, "\t%.*sdefsample.\n", dind, ind);
 		if(b->flags & 2)
-			print("\t\t%.*s.descrindex\t0x%ux\n", dind, ind, b->tfhd.defsample.descrindex);
+			fprint(2, "\t\t%.*s.descrindex\t0x%ux\n", dind, ind, b->tfhd.defsample.descrindex);
 		if(b->flags & 8)
-			print("\t\t%.*s.duration\t%ud\n", dind, ind, b->tfhd.defsample.duration);
+			fprint(2, "\t\t%.*s.duration\t%ud\n", dind, ind, b->tfhd.defsample.duration);
 		if(b->flags & 16)
-			print("\t\t%.*s.size\t0x%ux\n", dind, ind, b->tfhd.defsample.size);
+			fprint(2, "\t\t%.*s.size\t0x%ux\n", dind, ind, b->tfhd.defsample.size);
 		if(b->flags & 32)
-			print("\t\t%.*s.flags\t0x%ux\n", dind, ind, b->tfhd.defsample.flags);
+			fprint(2, "\t\t%.*s.flags\t0x%ux\n", dind, ind, b->tfhd.defsample.flags);
 		if(b->flags & 0x10000)
-			print("\t%.*sduration is empty\n", dind, ind);
+			fprint(2, "\t%.*sduration is empty\n", dind, ind);
 		if(b->flags & 0x20000)
-			print("\t%.*sdefault base is moof\n", dind, ind);
+			fprint(2, "\t%.*sdefault base is moof\n", dind, ind);
 	}else if(b->type == BoxTfdt){
-		print("\t%.*sdecodetime\t%zd\n", dind, ind, b->tfdt.decodetime);
+		fprint(2, "\t%.*sdecodetime\t%zd\n", dind, ind, b->tfdt.decodetime);
 	}else if(b->type == BoxTrun){
-		print("\t%.*ssamplecount\t%ud\n", dind, ind, b->trun.samplecount);
+		fprint(2, "\t%.*ssamplecount\t%ud\n", dind, ind, b->trun.samplecount);
 		if(b->flags & 1)
-			print("\t%.*sdataoffset\t%d\n", dind, ind, b->trun.dataoffset);
+			fprint(2, "\t%.*sdataoffset\t%d\n", dind, ind, b->trun.dataoffset);
 		if(b->flags & 2)
-			print("\t%.*sfirstsampleflags\t0x%ux\n", dind, ind, b->trun.firstsampleflags);
+			fprint(2, "\t%.*sfirstsampleflags\t0x%ux\n", dind, ind, b->trun.firstsampleflags);
 		for(u = 0; u < b->trun.samplecount; u++){
-			print("\t%.*ssamples[%zd]\n", dind, ind, u);
+			fprint(2, "\t%.*ssamples[%zd]\n", dind, ind, u);
 			if(b->flags & 0x100)
-				print("\t\t%.*s.duration\t%ud\n", dind, ind, b->trun.samples[u].duration);
+				fprint(2, "\t\t%.*s.duration\t%ud\n", dind, ind, b->trun.samples[u].duration);
 			if(b->flags & 0x200)
-				print("\t\t%.*s.size\t%ud\n", dind, ind, b->trun.samples[u].size);
+				fprint(2, "\t\t%.*s.size\t%ud\n", dind, ind, b->trun.samples[u].size);
 			if(b->flags & 0x400)
-				print("\t\t%.*s.flags\t0x%ux\n", dind, ind, b->trun.samples[u].flags);
+				fprint(2, "\t\t%.*s.flags\t0x%ux\n", dind, ind, b->trun.samples[u].flags);
 			if(b->flags & 0x800)
-				print("\t\t%.*s.timeoffset\t%zd\n", dind, ind, b->trun.samples[u].timeoffset);
+				fprint(2, "\t\t%.*s.timeoffset\t%zd\n", dind, ind, b->trun.samples[u].timeoffset);
 		}
 	}else if(b->type == BoxStsd){
-		print("\t%.*shandler_type\t%08x\n", dind, ind, b->stsd.handlertype);
-		print("\t%.*sentry_count\t%ud\n", dind, ind, b->stsd.entrycount);
+		fprint(2, "\t%.*shandler_type\t%08x\n", dind, ind, b->stsd.handlertype);
+		fprint(2, "\t%.*sentry_count\t%ud\n", dind, ind, b->stsd.entrycount);
 	}else if(b->type == BoxStts){
-		print("\t%.*sentry_count\t%ud\n", dind, ind, b->stts.entrycount);
+		fprint(2, "\t%.*sentry_count\t%ud\n", dind, ind, b->stts.entrycount);
 	}else if(b->type == BoxStss){
-		print("\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
+		fprint(2, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
 	}else if(b->type == BoxStsc){
-		print("\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
+		fprint(2, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
 		for(u = 0; u < b->stsc.entrycount; u++){
-			print("\t%.*sentry[%zd]\n", dind, ind, u);
-			print("\t\t%.*sfirst_chunk\t%ud\n", dind, ind, b->stsc.entry[u].firstchunk);
-			print("\t\t%.*ssamples_per_chunk\t%ud\n", dind, ind, b->stsc.entry[u].samplesperchunk);
-			print("\t\t%.*ssample_description_table\t%ud\n", dind, ind, b->stsc.entry[u].sdt);
+			fprint(2, "\t%.*sentry[%zd]\n", dind, ind, u);
+			fprint(2, "\t\t%.*sfirst_chunk\t%ud\n", dind, ind, b->stsc.entry[u].firstchunk);
+			fprint(2, "\t\t%.*ssamples_per_chunk\t%ud\n", dind, ind, b->stsc.entry[u].samplesperchunk);
+			fprint(2, "\t\t%.*ssample_description_table\t%ud\n", dind, ind, b->stsc.entry[u].sdt);
 		}
 	}else if(b->type == BoxStsz){
-		print("\t%.*ssample_size\t%ud\n", dind, ind, b->stsz.samplesize);
-		print("\t%.*ssample_count\t%ud\n", dind, ind, b->stsz.samplecount);
+		fprint(2, "\t%.*ssample_size\t%ud\n", dind, ind, b->stsz.samplesize);
+		fprint(2, "\t%.*ssample_count\t%ud\n", dind, ind, b->stsz.samplecount);
 		if(b->stsz.samplesize == 0){
 			for(u = 0; u < b->stsz.samplecount; u++)
-				print("\t%.*sentrysize[%zd]\t%ud\n", dind, ind, u, b->stsz.entrysize[u]);
+				fprint(2, "\t%.*sentrysize[%zd]\t%ud\n", dind, ind, u, b->stsz.entrysize[u]);
 		}
 	}else if(b->type == BoxTkhd){
-		print("\t%.*screation_time\t%zd\n", dind, ind, b->tkhd.creattime);
-		print("\t%.*smodification_timetime\t%zd\n", dind, ind, b->tkhd.modtime);
-		print("\t%.*strack_id\t%ud\n", dind, ind, b->tkhd.trackid);
-		print("\t%.*sduration\t%zd\n", dind, ind, b->tkhd.duration);
-		print("\t%.*swidth\t%ud\n", dind, ind, b->tkhd.width);
-		print("\t%.*sheight\t%ud\n", dind, ind, b->tkhd.height);
+		fprint(2, "\t%.*screation_time\t%zd\n", dind, ind, b->tkhd.creattime);
+		fprint(2, "\t%.*smodification_timetime\t%zd\n", dind, ind, b->tkhd.modtime);
+		fprint(2, "\t%.*strack_id\t%ud\n", dind, ind, b->tkhd.trackid);
+		fprint(2, "\t%.*sduration\t%zd\n", dind, ind, b->tkhd.duration);
+		fprint(2, "\t%.*swidth\t%ud\n", dind, ind, b->tkhd.width);
+		fprint(2, "\t%.*sheight\t%ud\n", dind, ind, b->tkhd.height);
 	}else if(b->type == BoxHdlr){
-		print("\t%.*shandler_type\t%c%c%c%c\n", dind, ind, b->hdlr.handlertype>>24, b->hdlr.handlertype>>16&0xff, b->hdlr.handlertype>>8&0xff, b->hdlr.handlertype&0xff);
-		print("\t%.*sname\t%s\n", dind, ind, b->hdlr.name);
+		fprint(2, "\t%.*shandler_type\t%c%c%c%c\n", dind, ind, b->hdlr.handlertype>>24, b->hdlr.handlertype>>16&0xff, b->hdlr.handlertype>>8&0xff, b->hdlr.handlertype&0xff);
+		fprint(2, "\t%.*sname\t%s\n", dind, ind, b->hdlr.name);
 	}else if(b->type == BoxStco || b->type == BoxCo64){
-		print("\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
+		fprint(2, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
 		for(u = 0; u < b->stco_co64.entrycount; u++)
-			print("\t%.*schunkoffset[%zd]\t%zd\n", dind, ind, u, b->stco_co64.chunkoffset[u]);
+			fprint(2, "\t%.*schunkoffset[%zd]\t%zd\n", dind, ind, u, b->stco_co64.chunkoffset[u]);
 	}else{
-		print("\t%.*sstart\t%zd\n", dind, ind, b->dstart);
-		print("\t%.*ssize\t%zd\n", dind, ind, b->dsz);
+		fprint(2, "\t%.*sstart\t%zd\n", dind, ind, b->dstart);
+		fprint(2, "\t%.*ssize\t%zd\n", dind, ind, b->dsz);
 	}
 }