shithub: aacenc

Download patch

ref: 5b1678897ed42a02e3f3062483d0f390511dd91a
parent: c667f476304a883690f03799c9051983935c383c
author: menno <menno>
date: Sun Dec 19 08:50:42 EST 1999

Changed InputBuffer into double instead of float (less conversions)

--- a/aacenc.h
+++ b/aacenc.h
@@ -33,7 +33,7 @@
 	int use_MS;
 	int use_IS;
 	int profile;
-	float **inputBuffer;
+	double **inputBuffer;
 } faacAACStream;
 
 typedef struct {
--- a/encoder.c
+++ b/encoder.c
@@ -27,11 +27,11 @@
 	int startupNumFrame;
 
 	as = malloc( sizeof(faacAACStream));
-	if ((as->inputBuffer = (float**)malloc( ac->channels*sizeof(float*)))==NULL)
+	if ((as->inputBuffer = (double**)malloc( ac->channels*sizeof(double*)))==NULL)
 		return NULL;
 	for (ch=0; ch < ac->channels; ch++)
 	{
-		if ((as->inputBuffer[ch]=(float*)malloc( 1024*sizeof(float)))==NULL)
+		if ((as->inputBuffer[ch]=(double*)malloc( 1024*sizeof(double)))==NULL)
 			return NULL;
 	}
 
@@ -107,24 +107,26 @@
 	}
 
 	// Process Buffer
-	if (as->channels == 2)
-	{
-		if (Samples > 0)
-			for (i = 0; i < 1024; i++)
-			{
-				as->inputBuffer[0][i] = *Buffer++;
-				as->inputBuffer[1][i] = *Buffer++;
-			}
-		else // (Samples == 0) when called by faacEncodeFinish
-			for (i = 0; i < 1024; i++)
-			{
-				as->inputBuffer[0][i] = 0;
-				as->inputBuffer[1][i] = 0;
-			}
-	} else {
-		// No mono supported yet (basically only a problem with decoder
-		// the encoder in fact supports it).
-		return FERROR;
+	if (Buffer) {
+		if (as->channels == 2)
+		{
+			if (Samples > 0)
+				for (i = 0; i < 1024; i++)
+				{
+					as->inputBuffer[0][i] = *Buffer++;
+					as->inputBuffer[1][i] = *Buffer++;
+				}
+				else // (Samples == 0) when called by faacEncodeFinish
+					for (i = 0; i < 1024; i++)
+					{
+						as->inputBuffer[0][i] = 0;
+						as->inputBuffer[1][i] = 0;
+					}
+		} else {
+			// No mono supported yet (basically only a problem with decoder
+			// the encoder in fact supports it).
+			return FERROR;
+		}
 	}
 
 	if (as->is_first_frame) {