shithub: aacenc

Download patch

ref: 33a424159664eb248f31d57bb2016d27f0fc5174
parent: ec18632864c90594c2ba541b5883e10851688784
author: menno <menno>
date: Wed Apr 11 09:50:31 EDT 2001

Fixed MPEG4 object type problem

--- a/frontend/faacgui.rc
+++ b/frontend/faacgui.rc
@@ -92,11 +92,12 @@
     CONTROL         "Use LTP",IDC_USELTP,"Button",BS_AUTOCHECKBOX | 
                     BS_LEFTTEXT | WS_TABSTOP,13,100,71,10
     RTEXT           "-",IDC_COMPILEDATE,196,160,63,8
-    GROUPBOX        "AAC Profile",IDC_STATIC,203,71,50,46
-    CONTROL         "Main",IDC_MAIN,"Button",BS_AUTORADIOBUTTON,210,92,31,10
-    CONTROL         "LC",IDC_LC,"Button",BS_AUTORADIOBUTTON,210,81,25,10
+    GROUPBOX        "AAC Profile",IDC_STATIC,200,71,53,46
+    CONTROL         "Main LTP",IDC_MAIN,"Button",BS_AUTORADIOBUTTON,204,92,
+                    47,10
+    CONTROL         "LC",IDC_LC,"Button",BS_AUTORADIOBUTTON,204,81,25,10
     CONTROL         "SSR",IDC_SSR,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,
-                    210,103,31,10
+                    204,103,31,10
 END
 
 
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: main.c,v 1.12 2001/03/19 20:53:37 menno Exp $
+ * $Id: main.c,v 1.13 2001/04/11 13:50:31 menno Exp $
  */
 
 #ifdef _WIN32
@@ -74,7 +74,7 @@
 	{
 		printf("USAGE: %s -options infile outfile\n", argv[0]);
 		printf("Options:\n");
-		printf("  -pX   AAC profile, X=L gives LC, X=M gives MAIN\n");
+		printf("  -pX   AAC object type, X=L gives LC, X=M gives MAIN with LTP\n");
 		printf("  -nm   Don\'t use mid/side coding\n");
 		printf("  -tns  Use TNS coding\n");
 		printf("  -ltp  Use LTP coding\n");
@@ -120,9 +120,9 @@
 				switch(argv[i][1]) {
 				case 'p': case 'P':
 					if ((argv[i][2] == 'l') || (argv[i][2] == 'L'))
-						myFormat->aacProfile = LOW;
+						myFormat->aacObjectType = LOW;
 					else if ((argv[i][2] == 'm') || (argv[i][2] == 'M'))
-						myFormat->aacProfile = MAIN;
+						myFormat->aacObjectType = LTP;
 				break;
 				case 't': case 'T':
 					if ((argv[i][2] == 'n') || (argv[i][2] == 'N'))
--- a/frontend/maingui.c
+++ b/frontend/maingui.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: maingui.c,v 1.12 2001/03/12 20:12:37 menno Exp $
+ * $Id: maingui.c,v 1.13 2001/04/11 13:50:31 menno Exp $
  */
 
 #include <windows.h>
@@ -158,9 +158,9 @@
 			config->useTns = IsDlgButtonChecked(hWnd, IDC_USETNS) == BST_CHECKED ? 1 : 0;
 			config->useLfe = IsDlgButtonChecked(hWnd, IDC_USELFE) == BST_CHECKED ? 1 : 0;
 			config->useLtp = IsDlgButtonChecked(hWnd, IDC_USELTP) == BST_CHECKED ? 1 : 0;
-			config->aacProfile = IsDlgButtonChecked(hWnd, IDC_LC) == BST_CHECKED ? LOW : 0;
-			config->aacProfile = IsDlgButtonChecked(hWnd, IDC_MAIN) == BST_CHECKED ? MAIN : 0;
-			config->aacProfile = IsDlgButtonChecked(hWnd, IDC_SSR) == BST_CHECKED ? SSR : 0;
+			config->aacObjectType = IsDlgButtonChecked(hWnd, IDC_LC) == BST_CHECKED ? LOW : 0;
+			config->aacObjectType = IsDlgButtonChecked(hWnd, IDC_MAIN) == BST_CHECKED ? LTP : 0;
+			config->aacObjectType = IsDlgButtonChecked(hWnd, IDC_SSR) == BST_CHECKED ? SSR : 0;
 			GetDlgItemText(hWnd, IDC_BITRATE, szTemp, sizeof(szTemp));
 			config->bitRate = atoi(szTemp);
 			GetDlgItemText(hWnd, IDC_BANDWIDTH, szTemp, sizeof(szTemp));
--- a/include/faac.h
+++ b/include/faac.h
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: faac.h,v 1.5 2001/03/12 20:12:37 menno Exp $
+ * $Id: faac.h,v 1.6 2001/04/11 13:50:31 menno Exp $
  */
 
 #ifndef FAACLIB_H
@@ -40,15 +40,16 @@
 #define FAACENC_VERSION 1.0
 #define FAACENC_VERSIONB 1 /* If 1 this version is still in beta */
 
-/* AAC profiles */
+/* AAC object types */
 #define MAIN 0
 #define LOW  1
 #define SSR  2
+#define LTP  3
 
 typedef struct faacEncConfiguration
 {
-	/* AAC profile */
-	unsigned int aacProfile;
+	/* AAC object type */
+	unsigned int aacObjectType;
 
 	/* Allow mid/side coding */
 	unsigned int allowMidside;
--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bitstream.c,v 1.11 2001/04/03 19:32:13 menno Exp $
+ * $Id: bitstream.c,v 1.12 2001/04/11 13:50:31 menno Exp $
  */
 
 #include <stdlib.h>
@@ -187,7 +187,7 @@
 #endif
 		PutBit(bitStream, 0, 2); /* layer == 0 */
 		PutBit(bitStream, 1, 1); /* protection absent */
-		PutBit(bitStream, hEncoder->config.aacProfile, 2); /* profile */
+		PutBit(bitStream, hEncoder->config.aacObjectType, 2); /* profile */
 		PutBit(bitStream, hEncoder->sampleRateIdx, 4); /* sampling rate */
 		PutBit(bitStream, 0, 1); /* private bit */
 		PutBit(bitStream, hEncoder->numChannels, 3); /* ch. config (must be > 0) */
--- a/libfaac/bitstream.h
+++ b/libfaac/bitstream.h
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: bitstream.h,v 1.3 2001/02/28 18:39:34 menno Exp $
+ * $Id: bitstream.h,v 1.4 2001/04/11 13:50:31 menno Exp $
  */
 
 #ifndef BITSTREAM_H
@@ -96,10 +96,11 @@
 #define ID_FIL 6
 #define ID_END 7
 
-/* AAC profiles */
+/* AAC object types */
 #define MAIN 0
 #define LOW  1
 #define SSR  2
+#define LTP  3
 
 
 #define BYTE_NUMBIT 8		/* bits in byte (char) */
--- a/libfaac/coder.h
+++ b/libfaac/coder.h
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: coder.h,v 1.4 2001/03/05 11:33:37 menno Exp $
+ * $Id: coder.h,v 1.5 2001/04/11 13:50:31 menno Exp $
  */
 
 #ifndef CODER_H
@@ -105,7 +105,7 @@
 	int delay[MAX_SHORT_WINDOWS];
 	int global_pred_flag;
 	int side_info;
-	short *buffer;
+	double *buffer;
 	double *mdct_predicted;
 
 	double *time_buffer;
--- a/libfaac/frame.c
+++ b/libfaac/frame.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.c,v 1.16 2001/03/19 13:19:29 menno Exp $
+ * $Id: frame.c,v 1.17 2001/04/11 13:50:31 menno Exp $
  */
 
 /*
@@ -58,10 +58,10 @@
 	hEncoder->config.useLfe = config->useLfe;
 	hEncoder->config.useTns = config->useTns;
 	hEncoder->config.useLtp = config->useLtp;
-	hEncoder->config.aacProfile = config->aacProfile;
+	hEncoder->config.aacObjectType = config->aacObjectType;
 
-	 /* No SSR supported yet */
-	if ((hEncoder->config.aacProfile != MAIN)&&(hEncoder->config.aacProfile != LOW))
+	 /* No SSR / MAIN supported for now */
+	if ((hEncoder->config.aacObjectType != LTP)&&(hEncoder->config.aacObjectType != LOW))
 		return 0;
 
 	/* Re-init TNS for new profile */
@@ -103,7 +103,7 @@
 	hEncoder->flushFrame = 0;
 
 	/* Default configuration */
-	hEncoder->config.aacProfile = MAIN;
+	hEncoder->config.aacObjectType = LTP;
 	hEncoder->config.allowMidside = 1;
 	hEncoder->config.useLfe = 0;
 	hEncoder->config.useTns = 0;
@@ -193,7 +193,7 @@
 	CoderInfo *coderInfo = hEncoder->coderInfo;
 	unsigned int numChannels = hEncoder->numChannels;
 	unsigned int sampleRate = hEncoder->sampleRate;
-	unsigned int aacProfile = hEncoder->config.aacProfile;
+	unsigned int aacObjectType = hEncoder->config.aacObjectType;
 	unsigned int useLfe = hEncoder->config.useLfe;
 	unsigned int useTns = hEncoder->config.useTns;
 	unsigned int useLtp = hEncoder->config.useLtp;
@@ -346,7 +346,7 @@
 			tnsInfo_for_LTP = NULL;
 
 		if(channelInfo[channel].present && (!channelInfo[channel].lfe) &&
-			(coderInfo[channel].block_type != ONLY_SHORT_WINDOW) && (useLtp)) 
+			(coderInfo[channel].block_type != ONLY_SHORT_WINDOW) && (useLtp) && (aacObjectType == LTP)) 
 		{
 			LtpEncode(hEncoder,
 				&coderInfo[channel],
@@ -392,7 +392,7 @@
 			else
 				tnsDecInfo = NULL;
 			
-			if ((!channelInfo[channel].lfe) && (useLtp)) {  /* no reconstruction needed for LFE channel*/
+			if ((!channelInfo[channel].lfe) && (useLtp) && (aacObjectType == LTP)) {  /* no reconstruction needed for LFE channel*/
 
 				LtpReconstruct(&coderInfo[channel], &(coderInfo[channel].ltpInfo),
 					coderInfo[channel].requantFreq);
--- a/libfaac/frame.h
+++ b/libfaac/frame.h
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: frame.h,v 1.8 2001/03/12 20:12:37 menno Exp $
+ * $Id: frame.h,v 1.9 2001/04/11 13:50:31 menno Exp $
  */
 
 #ifndef FRAME_H
@@ -46,8 +46,8 @@
 
 typedef struct faacEncConfiguration
 {
-	/* AAC profile */
-	unsigned int aacProfile;
+	/* AAC object type */
+	unsigned int aacObjectType;
 
 	/* Allow mid/side coding */
 	unsigned int allowMidside;
--- a/libfaac/ltp.c
+++ b/libfaac/ltp.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: ltp.c,v 1.3 2001/03/12 16:58:37 menno Exp $
+ * $Id: ltp.c,v 1.4 2001/04/11 13:50:31 menno Exp $
  */
 
 #include <stdio.h>
@@ -123,7 +123,7 @@
 	return (num_bit);
 }
 
-static void prediction(short *buffer, double *predicted_samples, double *weight, int lag,
+static void prediction(double *buffer, double *predicted_samples, double *weight, int lag,
 				int flen)
 {
 	int i, offset;
@@ -161,7 +161,7 @@
 	*freq = codebook[*ltp_idx];
 }
 
-static int pitch(double *sb_samples, short *x_buffer, int flen, int lag0, int lag1, 
+static int pitch(double *sb_samples, double *x_buffer, int flen, int lag0, int lag1, 
 		  double *predicted_samples, double *gain, int *cb_idx)
 {
 	int i, j, delay;
@@ -287,7 +287,7 @@
 	for (channel = 0; channel < hEncoder->numChannels; channel++) {
 		LtpInfo *ltpInfo = &(hEncoder->coderInfo[channel].ltpInfo);
 
-		ltpInfo->buffer = AllocMemory(NOK_LT_BLEN * sizeof(short));
+		ltpInfo->buffer = AllocMemory(NOK_LT_BLEN * sizeof(double));
 		ltpInfo->mdct_predicted = AllocMemory(2*BLOCK_LEN_LONG*sizeof(double));
 		ltpInfo->time_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));
 		ltpInfo->ltp_overlap_buffer = AllocMemory(BLOCK_LEN_LONG*sizeof(double));
@@ -409,10 +409,7 @@
 
 	for(i = 0; i < block_size_long; i++) 
 	{
-		ltpInfo->buffer[NOK_LT_BLEN - 2 * block_size_long + i] = 
-			(short)double_to_int(time_signal[i]);
-
-		ltpInfo->buffer[NOK_LT_BLEN - block_size_long + i] = 
-			(short)double_to_int(overlap_signal[i]);
+		ltpInfo->buffer[NOK_LT_BLEN - 2 * block_size_long + i] = time_signal[i];
+		ltpInfo->buffer[NOK_LT_BLEN - block_size_long + i] = overlap_signal[i];
 	}
 }
--- a/libfaac/tns.c
+++ b/libfaac/tns.c
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * $Id: tns.c,v 1.4 2001/04/10 18:48:58 menno Exp $
+ * $Id: tns.c,v 1.5 2001/04/11 13:50:31 menno Exp $
  */
 
 #include <math.h>
@@ -59,13 +59,14 @@
 {
 	unsigned int channel;
 	int fsIndex = hEncoder->sampleRateIdx;
-	int profile = hEncoder->config.aacProfile;
+	int profile = hEncoder->config.aacObjectType;
 
 	for (channel = 0; channel < hEncoder->numChannels; channel++) {
 		TnsInfo *tnsInfo = &hEncoder->coderInfo[channel].tnsInfo;
 
 		switch( profile ) {
-		case MAIN :
+		case MAIN:
+		case LTP:
 			tnsInfo->tnsMaxBandsLong = tnsMaxBandsLongMainLow[fsIndex];
 			tnsInfo->tnsMaxBandsShort = tnsMaxBandsShortMainLow[fsIndex];
 #ifdef MPEG2AAC
--- a/wingui/EncoderJobProcessingManager.cpp
+++ b/wingui/EncoderJobProcessingManager.cpp
@@ -267,8 +267,12 @@
 			pEncConfig->useLfe = poJob->GetUseLfe() ? 1 : 0;
 			pEncConfig->bitRate = poJob->GetBitRate();
 			pEncConfig->bandWidth = poJob->GetBandwidth();
-			pEncConfig->aacProfile = GetAacProfileConstant(poJob->GetAacProfile());
+			pEncConfig->aacObjectType = GetAacProfileConstant(poJob->GetAacProfile());
 
+			/* temp fix for MPEG4 LTP object type */
+			if (pEncConfig->aacObjectType == 1)
+				pEncConfig->aacObjectType = 3;
+
 			if (!faacEncSetConfiguration(hEncoder, pEncConfig))
 			{
 				faacEncClose(hEncoder);
@@ -421,7 +425,7 @@
 		}
 	case CEncoderJob::eAacProfileMain:
 		{
-			return MAIN;
+			return LTP;
 		}
 	case CEncoderJob::eAacProfileSsr:
 		{
--- a/wingui/faac_wingui.rc
+++ b/wingui/faac_wingui.rc
@@ -102,11 +102,11 @@
                     WS_TABSTOP,24,72,44,10
     CONTROL         "Use LFE",IDC_CHECKUSELFE,"Button",BS_AUTOCHECKBOX | 
                     WS_DISABLED | WS_TABSTOP,24,83,43,10
-    GROUPBOX        "AAC Profile",IDC_STATIC,133,46,47,48
+    GROUPBOX        "AAC Profile",IDC_STATIC,133,46,59,48
     CONTROL         "LC",IDC_RADIOAACPROFILELC,"Button",BS_AUTORADIOBUTTON | 
                     WS_GROUP | WS_TABSTOP,142,58,25,10
-    CONTROL         "Main",IDC_RADIOAACPROFILEMAIN,"Button",
-                    BS_AUTORADIOBUTTON,142,69,31,10
+    CONTROL         "Main LTP",IDC_RADIOAACPROFILEMAIN,"Button",
+                    BS_AUTORADIOBUTTON,142,69,47,10
     CONTROL         "SSR",IDC_RADIOAACPROFILESSR,"Button",BS_AUTORADIOBUTTON | 
                     WS_DISABLED,142,79,31,10
     DEFPUSHBUTTON   "Enter Attractor",IDC_BUTTON1,198,112,50,14,NOT 
@@ -185,7 +185,7 @@
     WS_SYSMENU
 EXSTYLE WS_EX_APPWINDOW
 CAPTION "winfaac"
-FONT 8, "MS Sans Serif"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
 BEGIN
     DEFPUSHBUTTON   "Bye",IDOK,422,216,50,14
     CONTROL         "List1",IDC_LISTJOBS,"SysListView32",LVS_REPORT | 
@@ -838,7 +838,7 @@
 STRINGTABLE DISCARDABLE 
 BEGIN
     IDS_AacProfileLc        "LC"
-    IDS_AacProfileMain      "Main"
+    IDS_AacProfileMain      "Main LTP"
     IDS_AacProfileSsr       "Ssr"
     IDS_DetailedEncoderJobDescriptionString 
                             "%s -> %s\nProfile: %s\nParameters: %d bit/s - %d Hz"