shithub: aacenc

Download patch

ref: 71bcced2e52c711bf56e1afb6bb9899e0dcfa843
parent: 54d7f35236ac517e28ee4cb4df08804d3c7e0421
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Jul 15 21:20:22 EDT 2023

remove all the DSE nonsense

--- a/frontend/aacenc.c
+++ b/frontend/aacenc.c
@@ -43,14 +43,13 @@
 void
 main(int argc, char **argv)
 {
-	int nch, srate, type, brate, sz, n, r, q, i, nobuffer;
+	int nch, srate, type, brate, sz, n, r, q, nobuffer;
 	ulong insamples, outsz, insz;
 	faacEncConfigurationPtr fmt;
-	u8int *obuf, ph[7+1+4+8];
 	faacEncHandle e;
+	u8int *obuf;
 	s16int *pcm;
 	Biobuf in;
-	uvlong ns;
 	char *s;
 
 	nobuffer = 0;
@@ -106,7 +105,7 @@
 	insz = insamples * sizeof(*pcm);
 	if((pcm = malloc(insz)) == nil)
 		sysfatal("memory");
-	if((obuf = malloc(outsz)) == nil)
+	if((obuf = malloc(outsz + 32)) == nil) /* a bit extra for DSE */
 		sysfatal("memory");
 
 	fmt = faacEncGetCurrentConfiguration(e);
@@ -123,13 +122,10 @@
 
 	atnotify(done, 1);
 
-	ns = ~0ULL;
 	for(;;){
 		for(n = 0; n == 0 || (n & (sizeof(*pcm)-1)) != 0; n += r){
 			if((r = Bread(&in, pcm+n, insz-n)) < 0)
 				sysfatal("read: %r");
-			if(ns == ~0ULL)
-				ns = nsec();
 			if(r == 0)
 				break;
 		}
@@ -140,24 +136,8 @@
 		else if(sz == 0)
 			continue;
 
-		if(ns != 0){
-			memmove(ph, obuf, 7);
-			/* set frame size */
-			ph[3] &= ~3;
-			ph[4] = sizeof(ph)>>3;
-			ph[5] = (ph[5]&~0xe0) | sizeof(ph)<<5;
-			ph[7] = 0x04; /* DSE */
-			ph[8] = 'n';
-			ph[9] = 's';
-			ph[10] = 'e';
-			ph[11] = 'c';
-			for(i = 0; i < 8; i++, ns >>= 8)
-				ph[12+i] = ns;
-			ns = 0;
-			if(Bwrite(&out, ph, sizeof(ph)) < 0)
-				break;
-		}
-		if(Bwrite(&out, obuf, sz) < 0 || (nobuffer && Bflush(&out) < 0))
+		n = Bwrite(&out, obuf, sz);
+		if((nobuffer && Bflush(&out) < 0) || n != sz)
 			break;
 	}
 	Bflush(&out);