ref: 771e72df354b0a5f6dcbce6c2a59c8d8239a2ec5
parent: 610d6911a250a03d4a234a78f99c1d3772dd68a6
author: Sigrid Haflínudóttir <[email protected]>
date: Mon Mar 16 21:14:04 EDT 2020
parse more stuff
--- a/iso.c
+++ b/iso.c
@@ -69,6 +69,25 @@
u32int firstsampleflags;
RunSample *samples;
}trun;
+
+ struct {
+ u32int handlertype;
+ u32int entrycount;
+ }stsd;
+
+ struct {
+ u64int creattime;
+ u64int modtime;
+ u32int trackid;
+ u64int duration;
+ u32int width;
+ u32int height;
+ }tkhd;
+
+ struct {
+ u32int handlertype;
+ char *name;
+ }hdlr;
};
};
@@ -117,7 +136,8 @@
#define isfullbox(b) ( \
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 == BoxMfhd || b->type == BoxTfhd || b->type == BoxTfdt || b->type == BoxTrun || \
+ b->type == BoxStsd || b->type == BoxTkhd \
)
#define eBread(sz, e) if(Bread(f, d, sz) != sz){ werrstr(e); goto err; }
@@ -234,6 +254,19 @@
if(b->flags & 0x800)
print("\t\t%.*s.timeoffset\t%zd\n", dind, ind, b->trun.samples[u].timeoffset);
}
+ }else if(b->type == BoxStsd){
+ print("\t%.*shandlertype\t%08x\n", dind, ind, b->stsd.handlertype);
+ print("\t%.*sentrycount\t%ud\n", dind, ind, b->stsd.entrycount);
+ }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);
+ }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{
print("\t%.*sstart\t%zd\n", dind, ind, b->dstart);
print("\t%.*ssize\t%zd\n", dind, ind, b->dsz);
@@ -369,6 +402,7 @@
eBread(4, "first_sample_flags");
b->trun.firstsampleflags = bu32(d);
}
+ /* FIXME free those */
b->trun.samples = calloc(b->trun.samplecount, sizeof(RunSample));
for(u = 0; u < b->trun.samplecount; u++){
if(b->flags & 0x100){
@@ -393,6 +427,59 @@
}
}
printbox(b);
+ }else if(b->type == BoxStsd){
+ eBread(4, "handler_type");
+ b->stsd.handlertype = bu32(d);
+ eBread(4, "entry_count");
+ b->stsd.entrycount = bu32(d);
+ /* FIXME not reading actual entries here */
+ printbox(b);
+ }else if(b->type == BoxTkhd){
+ if(b->version == 1){
+ eBread(8, "creation_time");
+ b->tkhd.creattime = bu64(d);
+ eBread(8, "modification_time");
+ b->tkhd.modtime = bu64(d);
+ eBread(8, "track_id"); /* skipping 4 reserved as well */
+ b->tkhd.trackid = bu32(d);
+ eBread(8, "duration");
+ b->tkhd.duration = bu64(d);
+ }else if(b->version == 0){
+ eBread(4, "creation_time");
+ b->tkhd.creattime = bu32(d);
+ eBread(4, "modification_time");
+ b->tkhd.modtime = bu32(d);
+ eBread(8, "track_id"); /* skipping 4 reserved as well */
+ b->tkhd.trackid = bu32(d);
+ eBread(4, "duration");
+ b->tkhd.duration = bu32(d);
+ }else{
+ werrstr("uknown version %d", b->version);
+ goto err;
+ }
+ eBread(8+2+2+2+2, "reserved, layer, alternate_group, volume, reserved");
+ eBread(9*4, "matrix");
+ eBread(4, "width");
+ b->tkhd.width = bu32(d)>>16; /* FIXME fixed-point 16.16 */
+ eBread(4, "height");
+ b->tkhd.height = bu32(d)>>16; /* FIXME fixed-point 16.16 */
+ printbox(b);
+ }else if(b->type == BoxHdlr){
+ eBread(4, "pre_defined");
+ eBread(4, "handler_type");
+ b->hdlr.handlertype = bu32(d);
+ eBread(3*4, "reserved");
+ for(u = 0; u < sizeof(d)-1; u++){
+ if(Bread(f, d+u, 1) != 1){
+ werrstr("name");
+ goto err;
+ }
+ if(d[u] == 0)
+ break;
+ }
+ d[u] = 0;
+ b->hdlr.name = strdup((char*)d);
+ printbox(b);
}else{
printbox(b);
}
@@ -482,6 +569,7 @@
for(;;){
dind = 0;
+ memset(&b, 0, sizeof(b));
if(parsebox(f, &b, &eof) != 0){
if(eof)
break;