shithub: mcfs

Download patch

ref: 050366e484a2302927f9d537eea79250d30fa867
parent: 21b0ea38419d431dc8d9492df9761c348df3558b
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Feb 17 10:40:05 EST 2021

aac: be more careful with remuxing

--- a/aac.c
+++ b/aac.c
@@ -25,19 +25,16 @@
 			werrstr("AAC object type %d, can't write ADTS", objt);
 			return -1;
 		}
-		sz = 0; /* will be filled in later */
 		ctx->adts[0] = 0xff; /* syncword */
 		ctx->adts[1] = 0xf1; /* syncword, mpeg4, no crc */
 		ctx->adts[2] = (objt-1)<<6 | ratei<<2 | chanc>>2; /* object type, rate, channel config */
-		ctx->adts[3] = (chanc&3)<<6 | (sz>>11)&3; /* channel config, frame length */
-		ctx->adts[4] = sz>>3; /* frame length */
-		ctx->adts[5] = (sz&7)<<5 | 0x1f; /* frame length, fullness */
+		ctx->adts[3] = (chanc&3)<<6; /* channel config */
 		ctx->adts[6] = 0xfc; /* fullness, number of frames */
 	}
 	for(i = 0; i < np; i++, p++){
 		sz = 7+p->sz;
-		ctx->adts[3] = ctx->adts[3]&~3 | (sz>>11)&3; /* channels, frame length */
-		ctx->adts[4] = sz>>3; /* frame length */
+		ctx->adts[3] = ctx->adts[3]&(3<<6) | (sz>>11)&3; /* channels, frame length */
+		ctx->adts[4] = (sz>>3) & 0xff; /* frame length */
 		ctx->adts[5] = (sz&7)<<5 | 0x1f; /* frame length, fullness */
 		if(Bwrite(out, ctx->adts, 7) != 7 || Bwrite(out, p->data, p->sz) != p->sz)
 			goto err;