~ft/aacenc

71bcced2e52c711bf56e1afb6bb9899e0dcfa843 — Sigrid Solveig Haflínudóttir 10 months ago 54d7f35 master
remove all the DSE nonsense
1 files changed, 5 insertions(+), 25 deletions(-)

M frontend/aacenc.c
M frontend/aacenc.c => frontend/aacenc.c +5 -25
@@ 43,14 43,13 @@ usage(void)
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 @@ main(int argc, char **argv)
	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 @@ main(int argc, char **argv)

	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 @@ main(int argc, char **argv)
		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);