shithub: mcfs

Download patch

ref: 8fb29e99f76d82c1399dd2e5ffb81bd8421d0aeb
parent: 9ded8ee0d2acb896ba8a88038c8fb422078cda71
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Sep 9 11:06:30 EDT 2020

a few cosmetic tweaks

--- a/README.md
+++ b/README.md
@@ -11,6 +11,8 @@
 
 ## Status
 
+The code looks horrible.
+
 It's not a filesystem yet, but it can extract video streams (as IVF)
 and audio streams (only AAC atm).
 
--- a/iso.c
+++ b/iso.c
@@ -168,6 +168,8 @@
 
 	FmtMp4a = 0x6d703461u,
 	FmtAv01 = 0x61763031u,
+	FmtAvc1 = 0x61766331u,
+	FmtVp09 = 0x76703039u,
 
 	BoxUuid = 0x75756964u,
 	BoxFtyp = 0x66747970u,
@@ -443,9 +445,7 @@
 	Track *t;
 	int i;
 
-	for(t = tracks, i = 0; i < ntracks && t->id != id; i++, t++){
-		fprint(2, "%d != %d\n", t->id, id);
-	}
+	for(t = tracks, i = 0; i < ntracks && t->id != id; i++, t++);
 	if(i >= ntracks){
 		werrstr("no track %d", id);
 		t = nil;
@@ -639,7 +639,6 @@
 	Binit(&out, 1, OWRITE);
 
 	if(t->audio.format != 0){
-		Bprint(&stderr, "audio: format=%T channels=%d samplerate=%d\n", t->audio.format, t->audio.channels, t->audio.samplerate);
 		if(t->audio.format == FmtMp4a){
 			for(i = 0; i < nelem(srate2mpeg4fi) && srate2mpeg4fi[i] != t->audio.samplerate; i++);
 			if(i >= nelem(srate2mpeg4fi)){
@@ -654,7 +653,6 @@
 			return -1;
 		}
 	}else if(t->video.format != 0){
-		Bprint(&stderr, "video: format=%T resolution=%dx%d\n", t->video.format, t->video.width, t->video.height);
 		/* video is remuxed into IVF */
 		memset(frame, 0, 0x20);
 		memmove(frame, "DKIF", 4);
@@ -664,41 +662,41 @@
 		frame[7] = 0;
 		if(t->video.format == FmtAv01){
 			memmove(frame+8, "AV01", 4);
-			frame[12] = t->video.width;
-			frame[13] = t->video.width >> 8;
-			frame[14] = t->video.height;
-			frame[15] = t->video.height >> 8;
-			/* timebase denum */
-			frame[16] = t->timescale;
-			frame[17] = t->timescale >> 8;
-			frame[18] = t->timescale >> 16;
-			frame[19] = t->timescale >> 24;
-			/* timebase num */
-			frame[20] = 1;
-			frame[21] = 0;
-			frame[22] = 0;
-			frame[23] = 0;
-			/* FIXME is it a "number of frames" or "total duration?" */
-			dur = 0;
-			for(i = 0, m = t->moof; i < t->nmoof; i++, m++){
-				for(j = 0; j < m->trun.trun.samplecount; j++){
-					dur += m->trun.trun.samples[j].duration;
-				}
-			}
-			frame[24] = dur;
-			frame[25] = dur >> 8;
-			frame[26] = dur >> 16;
-			frame[27] = dur >> 24;
-			frame[28] = dur >> 32; /* FIXME is it 64 bits? */
-			frame[29] = dur >> 40;
-			frame[30] = dur >> 48;
-			frame[31] = dur >> 56;
-
-			Bwrite(&out, frame, 0x20);
 		}else{
-			werrstr("video: unknown format %T", t->video.format);
+			werrstr("video: unsupported video format %T", t->video.format);
 			return -1;
 		}
+		frame[12] = t->video.width;
+		frame[13] = t->video.width >> 8;
+		frame[14] = t->video.height;
+		frame[15] = t->video.height >> 8;
+		/* timebase denum */
+		frame[16] = t->timescale;
+		frame[17] = t->timescale >> 8;
+		frame[18] = t->timescale >> 16;
+		frame[19] = t->timescale >> 24;
+		/* timebase num */
+		frame[20] = 1;
+		frame[21] = 0;
+		frame[22] = 0;
+		frame[23] = 0;
+		/* FIXME is it a "number of frames" or "total duration?" */
+		dur = 0;
+		for(i = 0, m = t->moof; i < t->nmoof; i++, m++){
+			for(j = 0; j < m->trun.trun.samplecount; j++){
+				dur += m->trun.trun.samples[j].duration;
+			}
+		}
+		frame[24] = dur;
+		frame[25] = dur >> 8;
+		frame[26] = dur >> 16;
+		frame[27] = dur >> 24;
+		frame[28] = dur >> 32; /* FIXME is it 64 bits? */
+		frame[29] = dur >> 40;
+		frame[30] = dur >> 48;
+		frame[31] = dur >> 56;
+
+		Bwrite(&out, frame, 0x20);
 	}
 
 	res = -1;
@@ -1211,14 +1209,15 @@
 			t = &tracks[i];
 			print("%d	", t->id);
 			if(t->handlertype == HandlerVideo)
-				print("video	%T", t->video.format);
+				print("video	%T	%d	%d", t->video.format, t->video.width, t->video.height);
 			else if(t->handlertype == HandlerAudio)
-				print("audio	%T", t->audio.format);
+				print("audio	%T	%d	%d", t->audio.format, t->audio.channels, t->audio.samplerate);
 			else
 				print("%T	???", t->handlertype);
 			print("\n");
 		}
 	}else if(trackdump >= 0 && dumptrack(f, trackdump) != 0){
+		Bprint(&stderr, "%r\n");
 		status = "dump";
 	}