shithub: mcfs

Download patch

ref: 792fec9929df590a990c94a0ac96f4b769234c90
parent: 0c272ab00fe0275858ab03a1bccf5d04ae7e631b
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Sep 13 15:04:58 EDT 2020

don't double-print (dsize/etc); make esds parser return error instead of calling sysfatal directly

--- a/iso.c
+++ b/iso.c
@@ -156,11 +156,6 @@
 			u32int handlertype;
 			char *name;
 		}hdlr;
-
-		struct {
-			int id;
-			int flags;
-		}esds;
 	};
 };
 
@@ -478,13 +473,6 @@
 		Bprint(&stderr, "\t%.*sentry_count\t%ud\n", dind, ind, b->stss.entrycount);
 		for(u = 0; dflag > 1 && u < b->stco_co64.entrycount; u++)
 			Bprint(&stderr, "\t%.*schunkoffset[%zd]\t%zd\n", dind, ind, u, b->stco_co64.chunkoffset[u]);
-	}else if(b->type == BoxEsds){
-		Bprint(&stderr, "\t%.*sid\t%d\n", dind, ind, b->esds.id);
-		Bprint(&stderr, "\t%.*sflags\t0x%x\n", dind, ind, b->esds.flags);
-	}else{
-		Bprint(&stderr, "\t%.*soffset\t%zd\n", dind, ind, b->offset);
-		Bprint(&stderr, "\t%.*sdstart\t%zd\n", dind, ind, b->dstart);
-		Bprint(&stderr, "\t%.*sdsize\t%zd\n", dind, ind, b->dsz);
 	}
 }
 
@@ -582,7 +570,7 @@
 				if(t->audio.format == FmtMp4a){
 					samplesz += 7;
 					frame[3] = (t->audio.channels&3)<<6 | (samplesz>>11)&3; /* channels, frame length */
-					frame[4] = (samplesz>>3)&0xff; /* frame length */
+					frame[4] = (samplesz>>3); /* frame length */
 					frame[5] = (samplesz&7)<<5 | 0x1f; /* frame length, fullness */
 					frame[6] = 0xfc; /* fullness, number of frames */
 					samplesz -= 7;
@@ -916,14 +904,22 @@
 			n -= 2;
 
 			if(o == 0x40){ /* AAC */
-				if((x >> 11) == 0x1f)
-					sysfatal("extended object type not supported");
+				if((x >> 11) == 0x1f){
+					werrstr("extended object type not supported");
+					return -1;
+				}
 
 				srate = (x >> 7) & 0xf;
-				if(srate == 0xf)
-					sysfatal("extended sample rate not supported");
+				if(srate == 0xf){
+					werrstr("extended sample rate not supported");
+					return -1;
+				}
 				e->audio.samplerate = srate2mpeg4fi[srate];
 				e->audio.channels = aacchans[(x >> 3) & 0xf];
+				if(e->audio.channels == 0){
+					werrstr("zero channels?");
+					return -1;
+				}
 				break;
 			}
 		}
@@ -1168,7 +1164,8 @@
 		printbox(b);
 	}else if(b->type == BoxEsds){
 		assert(sampleentry != nil);
-		parseesds(f, sampleentry, b->dsz);
+		if(parseesds(f, sampleentry, b->dsz) != 0)
+			goto err;
 		/* print it with the sample entry */
 	}else if(b->type == BoxStts){
 		eBread(4, "entry_count");