shithub: mcfs

Download patch

ref: 7aee9d30601748c0affb1fe73331db5e5d9f069e
parent: ab497acde3c65099cedd199cf49602c743d7e669
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Mar 16 21:52:11 EDT 2020

stco/co64

--- a/iso.c
+++ b/iso.c
@@ -96,6 +96,11 @@
 		}stsc;
 
 		struct {
+			u32int entrycount;
+			u64int *chunkoffset;
+		}stco_co64;
+
+		struct {
 			u64int creattime;
 			u64int modtime;
 			u32int trackid;
@@ -139,6 +144,7 @@
 					BoxStts = 0x73747473u,
 					BoxStsc = 0x73747363u,
 					BoxStco = 0x7374636fu,
+					BoxCo64 = 0x636f3634u,
 					BoxStsz = 0x7374737au,
 					BoxStss = 0x73747373u,
 					BoxVmhd = 0x766d6864u,
@@ -160,10 +166,10 @@
 	b->type == BoxMvhd || b->type == BoxTrex || b->type == BoxMdhd || b->type == BoxHdlr || \
 	b->type == BoxMfhd || b->type == BoxTfhd || b->type == BoxTfdt || b->type == BoxTrun || \
 	b->type == BoxStsd || b->type == BoxStts || b->type == BoxStss || b->type == BoxTkhd || \
-	b->type == BoxElst || b->type == BoxStsc \
+	b->type == BoxElst || b->type == BoxStsc || b->type == BoxStco || b->type == BoxCo64 \
 )
 
-#define eBread(sz, e) if(Bread(f, d, sz) != sz){ werrstr(e); goto err; }
+#define eBread(sz, e) if(Bread(f, d, (sz)) != (sz)){ werrstr(e); goto err; }
 
 static int dflag;
 static int dind;
@@ -302,6 +308,10 @@
 	}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);
+	}else if(b->type == BoxStco || b->type == BoxCo64){
+		print("\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]);
 	}else{
 		print("\t%.*sstart\t%zd\n", dind, ind, b->dstart);
 		print("\t%.*ssize\t%zd\n", dind, ind, b->dsz);
@@ -490,6 +500,15 @@
 			b->stsc.entry[u].samplesperchunk = bu32(d);
 			eBread(4, "sample_description_table");
 			b->stsc.entry[u].sdt = bu32(d);
+		}
+		printbox(b);
+	}else if(b->type == BoxStco || b->type == BoxCo64){
+		eBread(4, "entry_count");
+		b->stco_co64.entrycount = bu32(d);
+		b->stco_co64.chunkoffset = calloc(b->stco_co64.entrycount, sizeof(*b->stco_co64.chunkoffset));
+		for(u = 0; u < b->stco_co64.entrycount; u++){
+			eBread(b->type == BoxStco ? 4 : 8, "chunk_offset");
+			b->stco_co64.chunkoffset[u] = b->type == BoxStco ? bu32(d) : bu64(d);
 		}
 		printbox(b);
 	}else if(b->type == BoxTkhd){