shithub: aacenc

Download patch

ref: b981f2d661960a144752f7094fab783e17c363be
parent: ef32d5a8a81741b07fcd235e07690aeccafa5f72
author: stux <stux>
date: Sat Aug 2 07:32:10 EDT 2003

added config.inputFormat, and associated defines and code, faac now handles native endian 16bit, 24bit and float input. Added faacEncGetDecoderSpecificInfo to the dll exports, needed for MP4. Updated DLL .dsp to compile without error. Updated CFG_VERSION to 102. Version number might need to be updated as the API has technically changed. Did not update libfaac.pdf

--- a/include/faac.h
+++ b/include/faac.h
@@ -16,7 +16,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: faac.h,v 1.28 2003/07/10 19:16:01 knik Exp $
+ * $Id: faac.h,v 1.29 2003/08/02 11:32:10 stux Exp $
  */
 
 #ifndef FAACLIB_H
@@ -37,7 +37,7 @@
   #endif
 #endif
 
-#define FAAC_CFG_VERSION 101
+#define FAAC_CFG_VERSION 102
 
 /* MPEG ID's */
 #define MPEG2 1
@@ -49,6 +49,13 @@
 #define SSR  2
 #define LTP  3
 
+/* Input Formats */
+#define FAAC_INPUT_NULL		0
+#define FAAC_INPUT_16BIT	1
+#define FAAC_INPUT_24BIT	2
+#define FAAC_INPUT_32BIT	3
+#define FAAC_INPUT_FLOAT	4
+
 typedef struct faacEncConfiguration
 {
     /* config version */
@@ -99,6 +106,16 @@
 	} *psymodellist;
 	// selected index in psymodellist
 	unsigned int psymodelidx;
+
+	/* 
+		PCM Sample Input Format
+		0	FAAC_INPUT_NULL			invalid, signifies a misconfigured config
+		1	FAAC_INPUT_16BIT		native endian 16bit
+		2	FAAC_INPUT_24BIT		native endian 24bit in 24 bits		(not implemented)
+		3	FAAC_INPUT_32BIT		native endian 24bit in 32 bits		(DEFAULT)
+		4	FAAC_INPUT_FLOAT		32bit floating point
+	*/
+	unsigned int inputFormat;
 
 } faacEncConfiguration, *faacEncConfigurationPtr;
 
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -16,7 +16,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.c,v 1.38 2003/07/10 19:17:01 knik Exp $
+ * $Id: frame.c,v 1.39 2003/08/02 11:32:10 stux Exp $
  */
 
 /*
@@ -123,6 +123,19 @@
 
 	assert((hEncoder->config.outputFormat == 0) || (hEncoder->config.outputFormat == 1));
 
+	switch( hEncoder->config.inputFormat )
+	{
+		case FAAC_INPUT_16BIT:
+		//case FAAC_INPUT_24BIT:
+		case FAAC_INPUT_32BIT:
+		case FAAC_INPUT_FLOAT:
+			break;
+
+		default:
+			return 0;
+			break;
+	}
+
     /* No SSR supported for now */
     if (hEncoder->config.aacObjectType == SSR)
         return 0;
@@ -279,6 +292,11 @@
 	*/
 	hEncoder->config.outputFormat = 1;
 
+	/*
+		be compatible with software which assumes 24bit in 32bit PCM
+	*/
+	hEncoder->config.inputFormat = FAAC_INPUT_32BIT;
+
     /* find correct sampling rate depending parameters */
     hEncoder->srInfo = &srInfo[hEncoder->sampleRateIdx];
 
@@ -422,13 +440,46 @@
         hEncoder->next2SampleBuff[channel] = hEncoder->next3SampleBuff[channel];
 	hEncoder->next3SampleBuff[channel] = tmp;
 
-        if (samplesInput == 0) { /* start flushing*/
+        if (samplesInput == 0)
+		{ 
+			/* start flushing*/
             for (i = 0; i < FRAME_LEN; i++)
                 hEncoder->next3SampleBuff[channel][i] = 0.0;
-        } else {
-            for (i = 0; i < (int)(samplesInput/numChannels); i++)
-                hEncoder->next3SampleBuff[channel][i] =
-		(1.0/256) * (double)inputBuffer[(i*numChannels)+channel];
+        } 
+		else 
+		{ 
+			/* handle the various input formats */
+			switch( hEncoder->config.inputFormat )
+			{
+				case FAAC_INPUT_16BIT:
+					for (i = 0; i < (int)(samplesInput/numChannels); i++)
+					{
+						hEncoder->next3SampleBuff[channel][i] =
+							(double)((short*)inputBuffer)[(i*numChannels)+channel];
+					}
+					break;
+
+				case FAAC_INPUT_32BIT:
+					for (i = 0; i < (int)(samplesInput/numChannels); i++)
+					{
+						hEncoder->next3SampleBuff[channel][i] =
+							(1.0/256) *  (double)inputBuffer[(i*numChannels)+channel];
+					}
+					break;
+
+				case FAAC_INPUT_FLOAT:
+					for (i = 0; i < (int)(samplesInput/numChannels); i++)
+					{
+						hEncoder->next3SampleBuff[channel][i] =
+							((float*)inputBuffer)[(i*numChannels)+channel];
+					}
+					break;
+
+				default:
+					return -1; /* invalid input format */
+					break;
+			}
+
             for (i = (int)(samplesInput/numChannels); i < FRAME_LEN; i++)
                 hEncoder->next3SampleBuff[channel][i] = 0.0;
         }
@@ -777,6 +828,9 @@
 
 /*
 $Log: frame.c,v $
+Revision 1.39  2003/08/02 11:32:10  stux
+added config.inputFormat, and associated defines and code, faac now handles native endian 16bit, 24bit and float input. Added faacEncGetDecoderSpecificInfo to the dll exports, needed for MP4. Updated DLL .dsp to compile without error. Updated CFG_VERSION to 102. Version number might need to be updated as the API has technically changed. Did not update libfaac.pdf
+
 Revision 1.38  2003/07/10 19:17:01  knik
 24-bit input
 
--- a/libfaac/frame.h
+++ b/libfaac/frame.h
@@ -16,7 +16,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.h,v 1.20 2003/07/10 19:17:44 knik Exp $
+ * $Id: frame.h,v 1.21 2003/08/02 11:32:10 stux Exp $
  */
 
 #ifndef FRAME_H
@@ -59,7 +59,7 @@
   #endif
 #endif
 
-#define FAAC_CFG_VERSION 101
+#define FAAC_CFG_VERSION 102
 
 typedef struct {
   psymodel_t *model;
@@ -66,6 +66,13 @@
   char *name;
 } psymodellist_t;
 
+/* Input Formats */
+#define FAAC_INPUT_NULL		0
+#define FAAC_INPUT_16BIT	1
+#define FAAC_INPUT_24BIT	2
+#define FAAC_INPUT_32BIT	3
+#define FAAC_INPUT_FLOAT	4
+
 typedef struct faacEncConfiguration
 {
     /* config version */
@@ -113,6 +120,16 @@
 	const psymodellist_t *psymodellist;
 	// selected index in psymodellist
 	unsigned int psymodelidx;
+
+	/* 
+		PCM Sample Input Format
+		0	FAAC_INPUT_NULL			invalid, signifies a misconfigured config
+		1	FAAC_INPUT_16BIT		native endian 16bit
+		2	FAAC_INPUT_24BIT		native endian 24bit in 24 bits		(not implemented)
+		3	FAAC_INPUT_32BIT		native endian 24bit in 32 bits		(DEFAULT)
+		4	FAAC_INPUT_FLOAT		32bit floating point
+	*/
+	unsigned int inputFormat;
 
 } faacEncConfiguration, *faacEncConfigurationPtr;
 
--- a/libfaac/libfaac.def
+++ b/libfaac/libfaac.def
@@ -8,3 +8,4 @@
 faacEncSetConfiguration          @3
 faacEncEncode                    @4
 faacEncClose                     @5
+faacEncGetDecoderSpecificInfo	 @6
--- a/libfaac/libfaac_dll.dsp
+++ b/libfaac/libfaac_dll.dsp
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=xicl6.exe
+CPP=cl.exe
 MTL=midl.exe
 RSC=rc.exe
 
@@ -51,7 +51,7 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
 # ADD LINK32 /nologo /dll /machine:I386 /out:"ReleaseDLL/libfaac.dll"
 
@@ -77,7 +77,7 @@
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LINK32=xilink6.exe
+LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 /nologo /dll /debug /machine:I386 /out:"DebugDLL/libfaac.dll" /pdbtype:sept
 
@@ -124,15 +124,11 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\joint.c
-# End Source File
-# Begin Source File
-
 SOURCE=.\ltp.c
 # End Source File
 # Begin Source File
 
-SOURCE=.\psychiso.c
+SOURCE=.\midside.c
 # End Source File
 # Begin Source File
 
@@ -200,6 +196,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\midside.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\psych.h
 # End Source File
 # Begin Source File
@@ -209,6 +209,10 @@
 # Begin Source File
 
 SOURCE=.\util.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\version.h
 # End Source File
 # End Group
 # Begin Source File