shithub: aacenc

Download patch

ref: 58547908ce3d5c6f0b79153d015cc6f699f6eb30
parent: a3dfc26b9bead7bc4eb223913a58fc3639d399fd
author: menno <menno>
date: Mon Jan 14 13:55:39 EST 2002

Changes in bitrate field

--- a/plugins/cooledit/FAAD.rc
+++ b/plugins/cooledit/FAAD.rc
@@ -7,8 +7,9 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+//#include "afxres.h"
 
+
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
 
@@ -51,10 +52,12 @@
                     WS_TABSTOP,59,33,45,10
     CONTROL         "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX | 
                     WS_DISABLED | WS_TABSTOP,59,46,67,10
-    COMBOBOX        IDC_CB_BITRATE,124,68,48,30,CBS_DROPDOWNLIST | 
-                    WS_VSCROLL | WS_TABSTOP
-    COMBOBOX        IDC_CB_BANDWIDTH,124,85,48,30,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
+    EDITTEXT        IDC_CB_BITRATE,124,68,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_CB_BANDWIDTH,124,85,40,14,ES_AUTOHSCROLL
+//    COMBOBOX        IDC_CB_BITRATE,124,68,40,59,CBS_DROPDOWNLIST | 
+//                    WS_VSCROLL | WS_TABSTOP
+//    COMBOBOX        IDC_CB_BANDWIDTH,124,85,40,59,CBS_DROPDOWN | WS_VSCROLL | 
+//                    WS_TABSTOP
     DEFPUSHBUTTON   "OK",IDOK,64,108,36,14
     PUSHBUTTON      "Cancel",IDCANCEL,100,108,36,14
     PUSHBUTTON      "About",IDC_BTN_ABOUT,136,108,36,14
@@ -61,8 +64,8 @@
     GROUPBOX        "AAC type",IDC_STATIC,4,18,48,38
     GROUPBOX        "Profile",IDC_STATIC,4,63,48,59
     LTEXT           "Bitrate per channel",IDC_STATIC,59,73,60,8
-    LTEXT           "Bandwidth (0=full)",IDC_STATIC,59,89,57,8
-    CONTROL         104,IDC_IMG_LOGO,"Static",SS_BITMAP,136,4,36,23
+    LTEXT           "Bandwidth",IDC_STATIC,59,89,57,8
+    CONTROL         IDC_IMG_LOGO,"Static",SS_BITMAP,136,4,36,23
 END
 
 
@@ -127,7 +130,6 @@
 //
 // Bitmap
 //
-
 IDB_LOGO                BITMAP  DISCARDABLE     "Logo.bmp"
 #endif    // Italian (Italy) resources
 /////////////////////////////////////////////////////////////////////////////
--- a/plugins/cooledit/faac.c
+++ b/plugins/cooledit/faac.c
@@ -14,283 +14,285 @@
 
 typedef struct output_tag  // any special vars associated with output file
 {
- FILE  *fFile;         
- DWORD lSize;
- long  lSamprate;
- WORD  wBitsPerSample;
- WORD  wChannels;
-// DWORD dwDataOffset;
-// BOOL  bWrittenHeader;
- char  szNAME[256];
+	FILE  *fFile;         
+	DWORD lSize;
+	long  lSamprate;
+	WORD  wBitsPerSample;
+	WORD  wChannels;
+//	DWORD dwDataOffset;
+//	BOOL  bWrittenHeader;
+	char  szNAME[256];
 
- faacEncHandle hEncoder;
- unsigned char *bitbuf;
- DWORD maxBytesOutput;
- long  samplesInput;
- BYTE  bStopEnc;
-} MYOUTPUT;
+	faacEncHandle hEncoder;
+	unsigned char *bitbuf;
+	DWORD maxBytesOutput;
+	long  samplesInput;
+	BYTE  bStopEnc;
+}MYOUTPUT;
 
 
-#define DISABLE_LTP \
-{ \
-	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
-	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
-	{ \
-		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
-		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
-	} \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
-}
 
 __declspec(dllexport) BOOL FAR PASCAL DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 {
 DWORD dwOptions=(DWORD)lParam;
 
- switch(Message)
- {
-  case WM_INITDIALOG:
-	  {
-      char buf[10];
+char szTemp[64];
 
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"18");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"20");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"32");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"40");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"48");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"56");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"64");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"96");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"112");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"128");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"160");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"192");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"256");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 8, 0);
+	switch(Message)
+	{
+		case WM_INITDIALOG:
+		{
+			char buf[10];
+			int br;
 
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"0");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"4000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"16000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"22050");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
+//			if(!((dwOptions>>23)&1))
+			{
+				config_init();
+				config_read(&dwOptions);
+			}
 
-//       if(!((dwOptions>>23)&1))
-	   {
-        config_init();
-        config_read(&dwOptions);
-	   }
+			if(dwOptions)
+			{
+				char Enabled=!(dwOptions&1);
+				CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
+//				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
+//				EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
 
-	   if(dwOptions)
-	   {
-       char Enabled=!(dwOptions&1);
-		CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
+				if(((dwOptions>>29)&7)==MPEG4)
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+				else
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
 
-	    if(((dwOptions>>29)&7)==MPEG4)
-	     CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-		else
-		 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
+				switch((dwOptions>>27)&3)
+				{
+					case 0:
+						CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
+						break;
+					case 1:
+						CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE);
+						break;
+					case 2:
+						CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+						break;
+					case 3:
+						CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+						if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) &&
+								IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+						{
+							CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
+							CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+							CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
+							EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+						}
+						break;
+				}
 
-		switch((dwOptions>>27)&3)
-		{
-		 case 0:
-              CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-		      break;
-		 case 1:
-              CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-		      break;
-		 case 2:
-              CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-		      break;
-		  case 3:
-			   CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			   DISABLE_LTP
-		       break;
+				CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, (dwOptions>>26)&1);
+				CheckDlgButton(hWndDlg, IDC_USETNS, (dwOptions>>25)&1);
+				CheckDlgButton(hWndDlg, IDC_USELFE, (dwOptions>>24)&1);
+
+				for(br=0; br<=((dwOptions>>16)&255) ; br++)
+				{
+					if(br == ((dwOptions>>16)&255))
+						sprintf(szTemp, "%d", br*1000);
+				}
+
+				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, szTemp);
+
+				for(br=0; br<=((dwOptions>>1)&0x0000ffff) ; br++)
+				{
+					if(br == ((dwOptions>>1)&0x0000ffff))
+						sprintf(szTemp, "%d", br);
+				}
+
+				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, szTemp);
+
+				break;
+			} // End dwOptions
+
+			CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
+			CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
+			CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
+
+			switch((long)lParam)
+			{
+				case IDC_RADIO_MPEG4:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
+				case IDC_RADIO_MPEG2:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					{
+						CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
+						EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+					}
+					break;
+				case IDC_RADIO_MAIN:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+					break;
+				case IDC_RADIO_LOW:
+					CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+					break;
+				case IDC_RADIO_SSR:
+					CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+					break;
+				case IDC_RADIO_LTP:
+					CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+					break;
+				case IDC_CHK_AUTOCFG:
+					CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
+				default:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+					CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+					break;
+			}         
 		}
+		break; // End of WM_INITDIALOG                                 
 
-		CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, (dwOptions>>26)&1);
-        CheckDlgButton(hWndDlg, IDC_USETNS, (dwOptions>>25)&1);
-        CheckDlgButton(hWndDlg, IDC_USELFE, (dwOptions>>24)&1);
+		case WM_CLOSE:
+//			Closing the Dialog behaves the same as Cancel               
+			PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
+			break; // End of WM_CLOSE                                      
 
-        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, (dwOptions>>19)&31, 0);
-//        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, (dwOptions>>1)&0x0000ffff, 0);
-		sprintf(buf,"%lu",(dwOptions>>1)&0x0000ffff);
-        SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
-		break;
-	   } // End dwOptions
+		case WM_COMMAND:
+			switch(LOWORD(wParam))
+			{
+				case IDC_CHK_AUTOCFG:
+				{
+					char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
+//					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
+//					EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
 
-       CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
+						EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+					else
+					{
+						CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+						CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);
+						EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+					}
+					break;
+				}
+				break;
 
-	   switch((long)lParam)
-	   {
-	    case IDC_RADIO_MPEG4:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		case IDC_RADIO_MPEG2:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-	         DISABLE_LTP
-			 break;
-		case IDC_RADIO_MAIN:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 break;
-		case IDC_RADIO_LOW:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-			 break;
-		case IDC_RADIO_SSR:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-			 break;
-		case IDC_RADIO_LTP:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			 break;
-		case IDC_CHK_AUTOCFG:
-			 CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		default:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 break;
-	   }         
-	  }
-      break; // End of WM_INITDIALOG                                 
+				case IDOK:
+				{
+					DWORD retVal=0;
+					faacEncConfiguration faacEncCfg;
 
-  case WM_CLOSE:
-       // Closing the Dialog behaves the same as Cancel               
-       PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
-       break; // End of WM_CLOSE                                      
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
+					{
+						faacEncCfg.mpegVersion=MPEG4;
+						retVal|=MPEG4<<29;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2))
+					{
+						faacEncCfg.mpegVersion=MPEG2;
+						retVal|=MPEG2<<29;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
+					{
+						faacEncCfg.aacObjectType=MAIN;
+						retVal|=MAIN<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
+					{
+						faacEncCfg.aacObjectType=LOW;
+						retVal|=LOW<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
+					{
+						faacEncCfg.aacObjectType=SSR;
+						retVal|=SSR<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					{
+						faacEncCfg.aacObjectType=LTP;
+						retVal|=LTP<<27;
+					}
 
-  case WM_COMMAND:
-	   switch(LOWORD(wParam))
-       {
-	   case IDC_CHK_AUTOCFG:
-		   {
-           char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-//      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-//      		EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
-      		EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
-			if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
-				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-			else
-				DISABLE_LTP
-			break;
-		   }
-           break;
+					faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.allowMidside<<26;
+					faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.useTns<<25;
+					faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.useLfe<<24;
 
-	   case IDOK:
-		   {
-		   DWORD retVal=0;
-           faacEncConfiguration faacEncCfg;
+					GetDlgItemText(hWndDlg, IDC_CB_BITRATE, szTemp, sizeof(szTemp));
+					faacEncCfg.bitRate = atoi(szTemp);
+					retVal|=((faacEncCfg.bitRate/1000)&255)<<16;
+					GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, szTemp, sizeof(szTemp));
+					faacEncCfg.bandWidth = atoi(szTemp);
+					retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
 
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
-			  {
-               faacEncCfg.mpegVersion=MPEG4;
-			   retVal|=MPEG4<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2))
-			  {
-               faacEncCfg.mpegVersion=MPEG2;
-			   retVal|=MPEG2<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-			  {
-               faacEncCfg.aacObjectType=MAIN;
-			   retVal|=MAIN<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-			  {
-               faacEncCfg.aacObjectType=LOW;
-			   retVal|=LOW<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-			  {
-               faacEncCfg.aacObjectType=SSR;
-			   retVal|=SSR<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-			  {
-               faacEncCfg.aacObjectType=LTP;
-			   retVal|=LTP<<27;
-			  }
+					if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
+						retVal|=1;
 
-              faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.allowMidside<<26;
-              faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useTns<<25;
-              faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useLfe<<24;
+					config_write(retVal);
 			  
-			  faacEncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
-			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_GETCURSEL, 0, 0)&31)<<19;
-              //retVal|=faacEncCfg.bitRate;
-			  faacEncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
-//			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_GETCURSEL, 0, 0)&0x0000ffff)<<1;
-			  retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
-             
-			  if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
-			   retVal|=1;
+//					retVal|=1<<23; // CFG has been written
 
-              config_write(retVal);
-			  
-//			  retVal|=1<<23; // CFG has been written
+					EndDialog(hWndDlg, retVal);
+				}
+				break;
 
-              EndDialog(hWndDlg, retVal);
-             }
-             break;
+				case IDCANCEL:
+//			Ignore data values entered into the controls        
+//			and dismiss the dialog window returning FALSE       
+					EndDialog(hWndDlg, FALSE);
+					break;
 
-        case IDCANCEL:
-             // Ignore data values entered into the controls        
-             // and dismiss the dialog window returning FALSE       
-             EndDialog(hWndDlg, FALSE);
-             break;
-
-		case IDC_BTN_ABOUT:
-           	 {
-		     char buf[256];
- 			  sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
+				case IDC_BTN_ABOUT:
+				{
+					char buf[256];
+					sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
 				          PI_VER,
 		 	              FAACENC_VERSION,
 						  __DATE__
 						  );
-		      MessageBox(hWndDlg, buf, "About", MB_OK);
-             }
-             break;
+					MessageBox(hWndDlg, buf, "About", MB_OK);
+				}
+				break;
 
-		case IDC_RADIO_MPEG4:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
+				case IDC_RADIO_MPEG4:
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
 
-		case IDC_RADIO_MPEG2:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
-			 DISABLE_LTP
-			 break;
-       }
-       break; // End of WM_COMMAND                                 
-  default: return FALSE;
- }
- return TRUE;
+				case IDC_RADIO_MPEG2:
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+					CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);
+					CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+					break;
+			}
+		break; // End of WM_COMMAND                                 
+		default: return FALSE;
+	}
+	return TRUE;
 } // End of DIALOGSMsgProc                                      
 
 
@@ -300,21 +302,20 @@
 long nDialogReturn=0;
 FARPROC lpfnDIALOGMsgProc;
 	
- lpfnDIALOGMsgProc=GetProcAddress(hInst,(LPCSTR)MAKELONG(20,0));			
- nDialogReturn=(long)DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)lpfnDIALOGMsgProc, dwOptions);
+	lpfnDIALOGMsgProc=GetProcAddress(hInst,(LPCSTR)MAKELONG(20,0));			
+	nDialogReturn=(long)DialogBoxParam((HINSTANCE)hInst,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)lpfnDIALOGMsgProc, dwOptions);
 
- return nDialogReturn;
+	return nDialogReturn;
 }
 
-__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput, 
-	SPECIALDATA * psp)
+__declspec(dllexport) DWORD FAR PASCAL FilterWriteFirstSpecialData(HANDLE hInput, SPECIALDATA * psp)
 {
- return 0;
+	return 0;
 }
 
 __declspec(dllexport) DWORD FAR PASCAL FilterWriteNextSpecialData(HANDLE hInput, SPECIALDATA * psp)
 {	
- return 0;
+	return 0;
 // only has 1 special data!  Otherwise we would use psp->hSpecialData
 // as either a counter to know which item to retrieve next, or as a
 // structure with other state information in it.
@@ -321,189 +322,150 @@
 }
 
 __declspec(dllexport) DWORD FAR PASCAL FilterWriteSpecialData(HANDLE hOutput,
-	LPCSTR szListType, LPCSTR szType, char * pData,DWORD dwSize)
+			LPCSTR szListType, LPCSTR szType, char * pData,DWORD dwSize)
 {
- return 0;
+	return 0;
 }
 
 __declspec(dllexport) void FAR PASCAL CloseFilterOutput(HANDLE hOutput)
 {
- if(hOutput)
- {
- MYOUTPUT *mo;
-  mo=(MYOUTPUT *)GlobalLock(hOutput);
+	if(hOutput)
+	{
+		MYOUTPUT *mo;
+		mo=(MYOUTPUT *)GlobalLock(hOutput);
 
- if(mo->fFile)
- {
-  fclose(mo->fFile);
-  mo->fFile=0;
- }
+		if(mo->fFile)
+		{
+			fclose(mo->fFile);
+			mo->fFile=0;
+		}
 
- if(mo->hEncoder)
-  faacEncClose(mo->hEncoder);
+		if(mo->hEncoder)
+			faacEncClose(mo->hEncoder);
 
- if(mo->bitbuf)
- {
-  free(mo->bitbuf);
-  mo->bitbuf=0;
- }
+		if(mo->bitbuf)
+		{
+			free(mo->bitbuf);
+			mo->bitbuf=0;
+		}
 
-  GlobalUnlock(hOutput);
-  GlobalFree(hOutput);
- }
+		GlobalUnlock(hOutput);
+		GlobalFree(hOutput);
+	}
 }              
 
 __declspec(dllexport) HANDLE FAR PASCAL OpenFilterOutput(LPSTR lpstrFilename,long lSamprate,WORD wBitsPerSample,WORD wChannels,long lSize, long far *lpChunkSize, DWORD dwOptions)
 {
-HANDLE        hOutput;
-faacEncHandle hEncoder;
-FILE          *outfile;
-unsigned char *bitbuf;
-DWORD         maxBytesOutput;
-long          samplesInput;
-int           bytesEncoded;
+HANDLE			hOutput;
+faacEncHandle	hEncoder;
+FILE			*outfile;
+unsigned char	*bitbuf;
+DWORD			maxBytesOutput;
+long			samplesInput;
+int				bytesEncoded;
+int				br;
+				char szTemp[64];
 
-//    if(!((dwOptions>>23)&1))
+//	if(!((dwOptions>>23)&1))
 	{
-     config_init();
-     config_read(&dwOptions);
+		config_init();
+		config_read(&dwOptions);
 	}
 
-// open the aac output file 
+//	open the aac output file 
 	if(!(outfile=fopen(lpstrFilename, "wb")))
 	{
-     MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
-	 return 0;
+		MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
+		return 0;
 	}
 
-// open the encoder library
+//	open the encoder library
 	if(!(hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
 	{
-	 MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
-	 fclose(outfile);
-	 return 0;
+		MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
+		fclose(outfile);
+		return 0;
 	}
 
 	if(!(bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
 	{
-	 MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
-     faacEncClose(hEncoder);
-	 fclose(outfile);
-	 return 0;
+		MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
+		faacEncClose(hEncoder);
+		fclose(outfile);
+		return 0;
 	}
 
 	*lpChunkSize=samplesInput*2;
 
-    hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,sizeof(MYOUTPUT));
-    if(hOutput)
-    {
-	MYOUTPUT *mo;
-	 mo=(MYOUTPUT *)GlobalLock(hOutput);
-	 mo->fFile=outfile;
-	 mo->lSize=lSize;
-	 mo->lSamprate=lSamprate;
-	 mo->wBitsPerSample=wBitsPerSample;
-	 mo->wChannels=wChannels;
-//	 mo->dwDataOffset=0; // ???
-//	 mo->bWrittenHeader=0;
-	 strcpy(mo->szNAME,lpstrFilename);
+	hOutput=GlobalAlloc(GMEM_MOVEABLE|GMEM_SHARE,sizeof(MYOUTPUT));
+	if(hOutput)
+	{
+		MYOUTPUT *mo;
+		mo=(MYOUTPUT *)GlobalLock(hOutput);
+		mo->fFile=outfile;
+		mo->lSize=lSize;
+		mo->lSamprate=lSamprate;
+		mo->wBitsPerSample=wBitsPerSample;
+		mo->wChannels=wChannels;
+//		mo->dwDataOffset=0; // ???
+//		mo->bWrittenHeader=0;
+		strcpy(mo->szNAME,lpstrFilename);
 
-	 mo->hEncoder=hEncoder;
-     mo->bitbuf=bitbuf;
-	 mo->maxBytesOutput=maxBytesOutput;
-	 mo->samplesInput=samplesInput;
-	 mo->bStopEnc=0;
+		mo->hEncoder=hEncoder;
+		mo->bitbuf=bitbuf;
+		mo->maxBytesOutput=maxBytesOutput;
+		mo->samplesInput=samplesInput;
+		mo->bStopEnc=0;
 
-	 GlobalUnlock(hOutput);
-    }
+		GlobalUnlock(hOutput);
+	}
 	else
 	{
-	 MessageBox(0, "hOutput=NULL", "FAAC interface", MB_OK);
-     faacEncClose(hEncoder);
-	 fclose(outfile);
-	 free(bitbuf);
-	 return 0;
+		MessageBox(0, "hOutput=NULL", "FAAC interface", MB_OK);
+		faacEncClose(hEncoder);
+		fclose(outfile);
+		free(bitbuf);
+		return 0;
 	}
 
 	if(dwOptions && !(dwOptions&1))
 	{
-    faacEncConfigurationPtr myFormat;
-     myFormat=faacEncGetCurrentConfiguration(hEncoder);
+		faacEncConfigurationPtr myFormat;
+		myFormat=faacEncGetCurrentConfiguration(hEncoder);
 
-     myFormat->mpegVersion=(dwOptions>>29)&7;
-	 myFormat->aacObjectType=(dwOptions>>27)&3;
-	 myFormat->allowMidside=(dwOptions>>26)&1;
-	 myFormat->useTns=(dwOptions>>25)&1;
-	 myFormat->useLfe=(dwOptions>>24)&1;
-	 switch((dwOptions>>19)&31)
-	 {
-	  case 0:
-           myFormat->bitRate=8000;
-		   break;
-	  case 1:
-           myFormat->bitRate=18000;
-		   break;
-	  case 2:
-           myFormat->bitRate=20000;
-		   break;
-	  case 3:
-           myFormat->bitRate=24000;
-		   break;
-	  case 4:
-           myFormat->bitRate=32000;
-		   break;
-	  case 5:
-           myFormat->bitRate=40000;
-		   break;
-	  case 6:
-           myFormat->bitRate=48000;
-		   break;
-	  case 7:
-           myFormat->bitRate=56000;
-		   break;
-	  case 8:
-           myFormat->bitRate=64000;
-		   break;
-	  case 9:
-           myFormat->bitRate=96000;
-		   break;
-	  case 10:
-           myFormat->bitRate=112000;
-		   break;
-	  case 11:
-           myFormat->bitRate=128000;
-		   break;
-	  case 12:
-           myFormat->bitRate=160000;
-		   break;
-	  case 13:
-           myFormat->bitRate=192000;
-		   break;
-	  case 14:
-           myFormat->bitRate=256000;
-		   break;
-	 }
-     myFormat->bandWidth=(dwOptions>>1)&0x0000ffff;
-     if(!myFormat->bandWidth)
-	  myFormat->bandWidth=lSamprate/2;
+		myFormat->mpegVersion=(dwOptions>>29)&7;
+		myFormat->aacObjectType=(dwOptions>>27)&3;
+		myFormat->allowMidside=(dwOptions>>26)&1;
+		myFormat->useTns=(dwOptions>>25)&1;
+		myFormat->useLfe=(dwOptions>>24)&1;
 
-	 if(!faacEncSetConfiguration(hEncoder, myFormat))
-	 {
-      MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
-      faacEncClose(hEncoder);
-	  fclose(outfile);
-	  free(bitbuf);
-      GlobalFree(hOutput);
-	  return 0;
-	 }
+		for(br=0; br<=((dwOptions>>16)&255) ; br++)
+		{
+			if(br == ((dwOptions>>16)&255))
+				myFormat->bitRate=br*1000;
+		}
+
+		myFormat->bandWidth=(dwOptions>>1)&0x0000ffff;
+		if(!myFormat->bandWidth)
+		myFormat->bandWidth=lSamprate/2;
+
+		if(!faacEncSetConfiguration(hEncoder, myFormat))
+		{
+			MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
+			faacEncClose(hEncoder);
+			fclose(outfile);
+			free(bitbuf);
+			GlobalFree(hOutput);
+			return 0;
+		}
 	}
 
 // init flushing process
-    bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
-    if(bytesEncoded>0)
-	 fwrite(bitbuf, 1, bytesEncoded, outfile);
+	bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
+	if(bytesEncoded>0)
+		fwrite(bitbuf, 1, bytesEncoded, outfile);
 
-    return hOutput;
+	return hOutput;
 }
 
 __declspec(dllexport) DWORD FAR PASCAL WriteFilterOutput(HANDLE hOutput, unsigned char far *buf, long lBytes)
@@ -511,39 +473,39 @@
 int bytesWritten;
 int bytesEncoded;
 
- if(hOutput)
- { 
- MYOUTPUT far *mo;
-  mo=(MYOUTPUT far *)GlobalLock(hOutput);
+	if(hOutput)
+	{ 
+		MYOUTPUT far *mo;
+		mo=(MYOUTPUT far *)GlobalLock(hOutput);
 
-  if(!mo->bStopEnc)
-  {
+		if(!mo->bStopEnc)
+		{
 // call the actual encoding routine
-   bytesEncoded=faacEncEncode(mo->hEncoder, (short *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
-   if(bytesEncoded<1) // end of flushing process
-   {
-    if(bytesEncoded<0)
-	{
-     MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
-     mo->bStopEnc=1;
-	}
-	bytesWritten=lBytes ? 1 : 0; // bytesWritten==0 stops CoolEdit...
-    GlobalUnlock(hOutput);
-    return bytesWritten;
-   }
+			bytesEncoded=faacEncEncode(mo->hEncoder, (short *)buf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+			if(bytesEncoded<1) // end of flushing process
+			{
+				if(bytesEncoded<0)
+				{
+					MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
+					mo->bStopEnc=1;
+				}
+				bytesWritten=lBytes ? 1 : 0; // bytesWritten==0 stops CoolEdit...
+				GlobalUnlock(hOutput);
+				return bytesWritten;
+			}
 // write bitstream to aac file 
-   bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
-   if(bytesWritten!=bytesEncoded)
-   {
-    MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
-    mo->bStopEnc=1;
-    GlobalUnlock(hOutput);
-    return 0;
-   }
+			bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+			if(bytesWritten!=bytesEncoded)
+			{
+				MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
+				mo->bStopEnc=1;
+				GlobalUnlock(hOutput);
+				return 0;
+			}
 
-   GlobalUnlock(hOutput);
-  }
- }
+			GlobalUnlock(hOutput);
+		}
+	}
 
- return bytesWritten;
+	return bytesWritten;
 }
--- a/plugins/winamp/FAAC.rc
+++ b/plugins/winamp/FAAC.rc
@@ -7,8 +7,9 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+//#include "afxres.h"
 
+
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS
 
@@ -51,10 +52,12 @@
                     WS_TABSTOP,59,33,45,10
     CONTROL         "Use LFE channel",IDC_USELFE,"Button",BS_AUTOCHECKBOX | 
                     WS_DISABLED | WS_TABSTOP,59,46,67,10
-    COMBOBOX        IDC_CB_BITRATE,126,68,48,30,CBS_DROPDOWNLIST | 
-                    WS_VSCROLL | WS_TABSTOP
-    COMBOBOX        IDC_CB_BANDWIDTH,126,85,48,30,CBS_DROPDOWN | WS_VSCROLL | 
-                    WS_TABSTOP
+    EDITTEXT        IDC_CB_BITRATE,126,68,40,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_CB_BANDWIDTH,126,85,40,14,ES_AUTOHSCROLL
+//    COMBOBOX        IDC_CB_BITRATE,126,68,40,59,CBS_DROPDOWNLIST | 
+//                    WS_VSCROLL | WS_TABSTOP
+//    COMBOBOX        IDC_CB_BANDWIDTH,126,85,40,59,CBS_DROPDOWN | WS_VSCROLL | 
+//                    WS_TABSTOP
     EDITTEXT        IDC_E_BROWSE,57,103,94,14,ES_AUTOHSCROLL
     PUSHBUTTON      "Browse",IDC_BTN_BROWSE,156,103,18,14,BS_BITMAP
     DEFPUSHBUTTON   "OK",IDOK,66,123,36,14
@@ -63,8 +66,8 @@
     GROUPBOX        "AAC type",IDC_STATIC,4,18,48,38
     GROUPBOX        "Profile",IDC_STATIC,4,63,48,59
     LTEXT           "Bitrate per channel",IDC_STATIC,59,73,60,8
-    LTEXT           "Bandwidth (0=full)",IDC_STATIC,59,89,57,8
-    CONTROL         104,IDC_IMG_LOGO,"Static",SS_BITMAP,138,4,36,23
+    LTEXT           "Bandwidth",IDC_STATIC,59,89,57,8
+    CONTROL         104,"Static",IDC_IMG_LOGO,138,4,36,23,SS_BITMAP
 END
 
 
--- a/plugins/winamp/Out_faac.c
+++ b/plugins/winamp/Out_faac.c
@@ -68,23 +68,23 @@
 	OUT_VER,
 	"Freeware AAC encoder " PI_VER,
 	34,
-    NULL, // hmainwindow
-    NULL, // hdllinstance
-    Config,
-    About,
-    Init,
-    Quit,
-    Open,
-    Close,
-    Write,
-    CanWrite,
-    IsPlaying,
-    Pause,
-    SetVolume,
-    SetPan,
-    Flush,
-    GetWrittenTime,
-    GetWrittenTime
+	NULL, // hmainwindow
+	NULL, // hdllinstance
+	Config,
+	About,
+	Init,
+	Quit,
+	Open,
+	Close,
+	Write,
+	CanWrite,
+	IsPlaying,
+	Pause,
+	SetVolume,
+	SetPan,
+	Flush,
+	GetWrittenTime,
+	GetWrittenTime
 };
 
 __declspec( dllexport ) Out_Module * winampGetOutModule()
@@ -96,66 +96,66 @@
 
 BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ulReason, LPVOID lpReserved)
 {
-   switch(ulReason)
-   {
-      case DLL_PROCESS_ATTACH:
-           DisableThreadLibraryCalls(hInst);
-           if(!hBmBrowse)
-            hBmBrowse=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BROWSE));
-         /* Code from LibMain inserted here.  Return TRUE to keep the
-            DLL loaded or return FALSE to fail loading the DLL.
+	switch(ulReason)
+	{
+		case DLL_PROCESS_ATTACH:
+			DisableThreadLibraryCalls(hInst);
+			if(!hBmBrowse)
+				hBmBrowse=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BROWSE));
+			/* 	Code from LibMain inserted here.  Return TRUE to keep the
+				DLL loaded or return FALSE to fail loading the DLL.
  
-            You may have to modify the code in your original LibMain to
-            account for the fact that it may be called more than once.
-            You will get one DLL_PROCESS_ATTACH for each process that
-            loads the DLL. This is different from LibMain which gets
-            called only once when the DLL is loaded. The only time this
-            is critical is when you are using shared data sections.
-            If you are using shared data sections for statically
-            allocated data, you will need to be careful to initialize it
-            only once. Check your code carefully.
+				You may have to modify the code in your original LibMain to
+				account for the fact that it may be called more than once.
+				You will get one DLL_PROCESS_ATTACH for each process that
+				loads the DLL. This is different from LibMain which gets
+				called only once when the DLL is loaded. The only time this
+				is critical is when you are using shared data sections.
+				If you are using shared data sections for statically
+				allocated data, you will need to be careful to initialize it
+				only once. Check your code carefully.
  
-            Certain one-time initializations may now need to be done for
-            each process that attaches. You may also not need code from
-            your original LibMain because the operating system may now
-            be doing it for you.
-         */
-         break;
+				Certain one-time initializations may now need to be done for
+				each process that attaches. You may also not need code from
+				your original LibMain because the operating system may now
+				be doing it for you.
+			*/
+			break;
  
-      case DLL_THREAD_ATTACH:
-         /* Called each time a thread is created in a process that has
-            already loaded (attached to) this DLL. Does not get called
-            for each thread that exists in the process before it loaded
-            the DLL.
+		case DLL_THREAD_ATTACH:
+			/* 	Called each time a thread is created in a process that has
+				already loaded (attached to) this DLL. Does not get called
+				for each thread that exists in the process before it loaded
+				the DLL.
  
-            Do thread-specific initialization here.
-         */
-         break;
+				Do thread-specific initialization here.
+			*/
+			break;
  
-      case DLL_THREAD_DETACH:
-         /* Same as above, but called when a thread in the process
-            exits.
+		case DLL_THREAD_DETACH:
+			/* 	Same as above, but called when a thread in the process
+				exits.
  
-            Do thread-specific cleanup here.
-         */
-         break;
+				Do thread-specific cleanup here.
+			*/
+			break;
  
-      case DLL_PROCESS_DETACH:
-           if(hBmBrowse)
-           {
-            DeleteObject(hBmBrowse);
-            hBmBrowse=NULL;
-           }
-         /* Code from _WEP inserted here.  This code may (like the
-            LibMain) not be necessary.  Check to make certain that the
-            operating system is not doing it for you.
-         */
-         break;
-   }
+		case DLL_PROCESS_DETACH:
+			if(hBmBrowse)
+			{
+				DeleteObject(hBmBrowse);
+				hBmBrowse=NULL;
+			}
+			/* 	Code from _WEP inserted here.  This code may (like the
+				LibMain) not be necessary.  Check to make certain that the
+				operating system is not doing it for you.
+			*/
+			break;
+	}
  
-   /* The return value is only used for DLL_PROCESS_ATTACH; all other
-      conditions are ignored.  */
-   return TRUE;   // successful DLL_PROCESS_ATTACH
+	/* 	The return value is only used for DLL_PROCESS_ATTACH; all other
+		conditions are ignored.  */
+	return TRUE;   // successful DLL_PROCESS_ATTACH
 }
 
 
@@ -173,275 +173,263 @@
 #define DISABLE_LTP \
 { \
 	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2) && \
-	   IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
+		IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP)) \
 	{ \
 		CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE); \
 		CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE); \
 	} \
-    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
+	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE); \
 }
 
 static BOOL CALLBACK DIALOGMsgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
 {
- switch(Message)
- {
-  case WM_INITDIALOG:
-	  {
-      char buf[10];
-	   SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);
-       SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
+	switch(Message)
+	{
+		case WM_INITDIALOG:
+		{
+			char buf[10];
+			int br;
+			char szTemp[64];
 
-	   SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"18");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"20");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"32");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"40");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"48");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"56");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"64");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"96");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"112");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"128");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"160");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"192");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"256");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 8, 0);
+			if(dwOptions)
+			{
+				char Enabled=!(dwOptions&1);
+				CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
+//				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
+//				EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
+				EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
 
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"0");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"4000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"8000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"16000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"22050");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"24000");
-       SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, 0, 0);
+					if(((dwOptions>>29)&7)==MPEG4)
+						CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+					else
+						CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
 
-	   if(dwOptions)
-	   {
-       char Enabled=!(dwOptions&1);
-		CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, dwOptions&1);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-//        EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
-        EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
+				switch((dwOptions>>27)&3)
+					{
+						case 0:
+							CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+							break;
+						case 1:
+							CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+							break;
+						case 2:
+							CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+							break;
+						case 3:
+							CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+							DISABLE_LTP
+							break;
+					}
 
-	    if(((dwOptions>>29)&7)==MPEG4)
-	     CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-		else
-		 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-
-		switch((dwOptions>>27)&3)
-		{
-		 case 0:
-              CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-		      break;
-		 case 1:
-              CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-		      break;
-		 case 2:
-              CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-		      break;
-		  case 3:
-               CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			   DISABLE_LTP
-		       break;
-		}
+				CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, (dwOptions>>26)&1);
+				CheckDlgButton(hWndDlg, IDC_USETNS, (dwOptions>>25)&1);
+				CheckDlgButton(hWndDlg, IDC_USELFE, (dwOptions>>24)&1);
 
-		CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, (dwOptions>>26)&1);
-        CheckDlgButton(hWndDlg, IDC_USETNS, (dwOptions>>25)&1);
-        CheckDlgButton(hWndDlg, IDC_USELFE, (dwOptions>>24)&1);
+				for(br=0; br<=((dwOptions>>16)&255) ; br++)
+				{
+					if(br == ((dwOptions>>16)&255))
+						sprintf(szTemp, "%d", br*1000);
+				}
 
-        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, (dwOptions>>19)&31, 0);
-//        SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_SETCURSEL, (dwOptions>>6)&31, 0);
-		sprintf(buf,"%lu",(dwOptions>>1)&0x0000ffff);
-        SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, buf);
-		break;
-	   } // End dwOptions
+				SetDlgItemText(hWndDlg, IDC_CB_BITRATE, szTemp);
 
-	   CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
-       CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
+				for(br=0; br<=((dwOptions>>1)&0x0000ffff) ; br++)
+				{
+					if(br == ((dwOptions>>1)&0x0000ffff))
+						sprintf(szTemp, "%d", br);
+				}
+
+				SetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, szTemp);
+
+				break;
+			} // End dwOptions
+
+			CheckDlgButton(hWndDlg, IDC_ALLOWMIDSIDE, TRUE);
+			CheckDlgButton(hWndDlg, IDC_USETNS, TRUE);
+			CheckDlgButton(hWndDlg, IDC_USELFE, FALSE);
        
-	   switch((long)lParam)
-	   {
-	    case IDC_RADIO_MPEG4:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		case IDC_RADIO_MPEG2:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
-	         DISABLE_LTP
-			 break;
-		case IDC_RADIO_MAIN:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 break;
-		case IDC_RADIO_LOW:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
-			 break;
-		case IDC_RADIO_SSR:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
-			 break;
-		case IDC_RADIO_LTP:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
-			 break;
-		case IDC_CHK_AUTOCFG:
-			 CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
-		default:
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
-			 CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
-			 break;
-	   }         
-	  }
-      break; // End of WM_INITDIALOG                                 
+			switch((long)lParam)
+			{
+				case IDC_RADIO_MPEG4:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
+				case IDC_RADIO_MPEG2:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);
+					DISABLE_LTP
+					break;
+				case IDC_RADIO_MAIN:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+					break;
+				case IDC_RADIO_LOW:
+					CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);
+					break;
+				case IDC_RADIO_SSR:
+					CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);
+					break;
+				case IDC_RADIO_LTP:
+					CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);
+					break;
+				case IDC_CHK_AUTOCFG:
+					CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
+				default:
+					CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);
+					CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);
+					break;
+			}         
+		}
+			break; // End of WM_INITDIALOG                                 
 
-  case WM_CLOSE:
-       // Closing the Dialog behaves the same as Cancel               
-       PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
-       break; // End of WM_CLOSE                                      
+		case WM_CLOSE:
+       			// 	Closing the Dialog behaves the same as Cancel               
+			PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
+			break; // End of WM_CLOSE                                      
 
-  case WM_COMMAND:
-	   switch(LOWORD(wParam))
-       {
-        case IDC_CHK_AUTOCFG:
+		case WM_COMMAND:
+			switch(LOWORD(wParam))
 			{
-            char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
-      	 	 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
-//      		 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
-//      		 EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
-      		 EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
-			 if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
-				EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
-			 else
-				DISABLE_LTP
-			}
-            break;
+				case IDC_CHK_AUTOCFG:
+				{
+					char Enabled=!IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled);
+//					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_ALLOWMIDSIDE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_USETNS), Enabled);
+//					EnableWindow(GetDlgItem(hWndDlg, IDC_USELFE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled);
+					EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled);
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
+						EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled);
+					else
+						DISABLE_LTP
+				}
+					break;
 
-	    case IDC_BTN_BROWSE:
-             {
-             char name[MAX_PATH];
-             BROWSEINFO bi;
-             ITEMIDLIST *idlist;
-	          bi.hwndOwner = hWndDlg;
-	          bi.pidlRoot = 0;
-	          bi.pszDisplayName = name;
-	          bi.lpszTitle = "Select a directory for AAC-MPEG4 file output:";
-	          bi.ulFlags = BIF_RETURNONLYFSDIRS;
-	          bi.lpfn = BrowseCallbackProc;
-	          bi.lParam = 0;
-	          idlist = SHBrowseForFolder( &bi );
-	          if (idlist) 
-	           SHGetPathFromIDList( idlist, config_AACoutdir );
+				case IDC_BTN_BROWSE:
+				{
+					char name[MAX_PATH];
+					BROWSEINFO bi;
+					ITEMIDLIST *idlist;
+					bi.hwndOwner = hWndDlg;
+					bi.pidlRoot = 0;
+					bi.pszDisplayName = name;
+					bi.lpszTitle = "Select a directory for AAC-MPEG4 file output:";
+					bi.ulFlags = BIF_RETURNONLYFSDIRS;
+					bi.lpfn = BrowseCallbackProc;
+					bi.lParam = 0;
+					idlist = SHBrowseForFolder( &bi );
+					if (idlist) 
+						SHGetPathFromIDList( idlist, config_AACoutdir );
 
-              SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
-			 }
-			 break;
+					SetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir);
+				}
+					break;
 
-		case IDC_E_BROWSE:
-             GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir,256);
-			 break;
+				case IDC_E_BROWSE:
+					GetDlgItemText(hWndDlg, IDC_E_BROWSE, config_AACoutdir,256);
+					break;
 
-	    case IDOK:
-           	 {
-			 DWORD retVal=0;
-             faacEncConfiguration faacEncCfg;
+				case IDOK:
+				{
+					char szTemp[64];
+					DWORD retVal=0;
+					faacEncConfiguration faacEncCfg;
 
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
-			  {
-               faacEncCfg.mpegVersion=MPEG4;
-			   retVal|=MPEG4<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2))
-			  {
-               faacEncCfg.mpegVersion=MPEG2;
-			   retVal|=MPEG2<<29;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
-			  {
-               faacEncCfg.aacObjectType=MAIN;
-			   retVal|=MAIN<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
-			  {
-               faacEncCfg.aacObjectType=LOW;
-			   retVal|=LOW<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
-			  {
-               faacEncCfg.aacObjectType=SSR;
-			   retVal|=SSR<<27;
-			  }
-              if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
-			  {
-               faacEncCfg.aacObjectType=LTP;
-			   retVal|=LTP<<27;
-			  }
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4))
+					{
+						faacEncCfg.mpegVersion=MPEG4;
+						retVal|=MPEG4<<29;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG2))
+					{
+						faacEncCfg.mpegVersion=MPEG2;
+						retVal|=MPEG2<<29;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MAIN))
+					{
+						faacEncCfg.aacObjectType=MAIN;
+						retVal|=MAIN<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LOW))
+					{
+						faacEncCfg.aacObjectType=LOW;
+						retVal|=LOW<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_SSR))
+					{
+						faacEncCfg.aacObjectType=SSR;
+						retVal|=SSR<<27;
+					}
+					if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_LTP))
+					{
+						faacEncCfg.aacObjectType=LTP;
+						retVal|=LTP<<27;
+					}
 
-              faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.allowMidside<<26;
-              faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useTns<<25;
-              faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
-              retVal|=faacEncCfg.useLfe<<24;
+					faacEncCfg.allowMidside=IsDlgButtonChecked(hWndDlg, IDC_ALLOWMIDSIDE) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.allowMidside<<26;
+					faacEncCfg.useTns=IsDlgButtonChecked(hWndDlg, IDC_USETNS) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.useTns<<25;
+					faacEncCfg.useLfe=IsDlgButtonChecked(hWndDlg, IDC_USELFE) == BST_CHECKED ? 1 : 0;
+					retVal|=faacEncCfg.useLfe<<24;
 			  
-			  faacEncCfg.bitRate=GetDlgItemInt(hWndDlg, IDC_CB_BITRATE, 0, FALSE);
-			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_GETCURSEL, 0, 0)&31)<<19;
-              //retVal|=faacEncCfg.bitRate;
-			  faacEncCfg.bandWidth=GetDlgItemInt(hWndDlg, IDC_CB_BANDWIDTH, 0, FALSE);
-//			  retVal|=(SendMessage(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), CB_GETCURSEL, 0, 0)&31)<<6;
-			  retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
+					GetDlgItemText(hWndDlg, IDC_CB_BITRATE, szTemp, sizeof(szTemp));
+					faacEncCfg.bitRate = atoi(szTemp);
+					retVal|=((faacEncCfg.bitRate/1000)&255)<<16;
+					GetDlgItemText(hWndDlg, IDC_CB_BANDWIDTH, szTemp, sizeof(szTemp));
+					faacEncCfg.bandWidth = atoi(szTemp);
+					retVal|=(faacEncCfg.bandWidth&0x0000ffff)<<1;
 
-			  if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
-			   retVal|=1;
+					if(IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG))
+						retVal|=1;
 
-			  EndDialog(hWndDlg, retVal);
-             }
-             break;
+					EndDialog(hWndDlg, retVal);
+				}
+					break;
 
-        case IDCANCEL:
-             // Ignore data values entered into the controls        
-             // and dismiss the dialog window returning FALSE       
-             EndDialog(hWndDlg, FALSE);
-             break;
+				case IDCANCEL:
+				// 	Ignore data values entered into the controls        
+				// 	and dismiss the dialog window returning FALSE       
+					EndDialog(hWndDlg, FALSE);
+					break;
 
-		case IDC_BTN_ABOUT:
-           	 {
-		     char buf[256];
- 			  sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
-				          PI_VER,
-		 	              FAACENC_VERSION,
-						  __DATE__
-						  );
-		      MessageBox(hWndDlg, buf, "About", MB_OK);
-             }
-             break;
+				case IDC_BTN_ABOUT:
+				{
+					char buf[256];
+					sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
+						PI_VER,
+						FAACENC_VERSION,
+						__DATE__
+						);
+					MessageBox(hWndDlg, buf, "About", MB_OK);
+				}
+					break;
 
-		case IDC_RADIO_MPEG4:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
-			 break;
+				case IDC_RADIO_MPEG4:
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), !IsDlgButtonChecked(hWndDlg,IDC_CHK_AUTOCFG));
+					break;
 
-		case IDC_RADIO_MPEG2:
-	         EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
-			 DISABLE_LTP
-			 break;
-       }
-       break; // End of WM_COMMAND                                 
-  default: return FALSE;
- }
+				case IDC_RADIO_MPEG2:
+					EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), FALSE);
+					DISABLE_LTP
+					break;
+			}
+				break; // End of WM_COMMAND                                 
+		default: return FALSE;
+	}
  return TRUE;
 } // End of DIALOGSMsgProc                                      
 
@@ -449,24 +437,24 @@
 
 void Config(HWND hWnd)
 {
- dwOptions=DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_COMPRESSION), hWnd, DIALOGMsgProc);
-// dwOptions=DialogBoxParam((HINSTANCE)out.hDllInstance,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
- config_write();
+	dwOptions=DialogBox(out.hDllInstance, MAKEINTRESOURCE(IDD_COMPRESSION), hWnd, DIALOGMsgProc);
+//	dwOptions=DialogBoxParam((HINSTANCE)out.hDllInstance,(LPCSTR)MAKEINTRESOURCE(IDD_COMPRESSION), (HWND)hWnd, (DLGPROC)DIALOGMsgProc, dwOptions);
+	config_write();
 }
 
 void About(HWND hwnd)
 {
-char buf[256];
- sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
-	         PI_VER,
-             FAACENC_VERSION,
-			 __DATE__);
- MessageBox(hwnd, buf, "About", MB_OK);
+	char buf[256];
+	sprintf(buf,"AAC-MPEG4 encoder plug-in %s\nThis plugin uses FAAC encoder engine v%g\n\nCompiled on %s\n",
+		PI_VER,
+		FAACENC_VERSION,
+		__DATE__);
+	MessageBox(hwnd, buf, "About", MB_OK);
 }
 
 void Init()
 {
- config_read();
+	config_read();
 }
 
 void Quit()
@@ -491,17 +479,17 @@
 
 int Open(int lSamprate, int wChannels, int wBitsPerSample, int bufferlenms, int prebufferms)
 {
-//HANDLE        hOutput;
-faacEncHandle hEncoder;
-FILE          *outfile;
-unsigned char *bitbuf;
-DWORD         maxBytesOutput;
-long          samplesInput;
-int           bytesEncoded;
+//	HANDLE		hOutput;
+	faacEncHandle	hEncoder;
+	FILE		*outfile;
+	unsigned char	*bitbuf;
+	DWORD		maxBytesOutput;
+	long		samplesInput;
+	int		bytesEncoded;
+	int		br;
 
-
-	char *t,*p;
-	char temp2[MAX_PATH],lpstrFilename[MAX_PATH];
+	char		*t,*p;
+	char		temp2[MAX_PATH],lpstrFilename[MAX_PATH];
 	GetWindowText(out.hMainWindow,temp2,sizeof(temp2));
 	t=temp2;
 
@@ -513,14 +501,11 @@
 		char *p1,*p2;
 		p1=lpstrFilename;
 		p2=temp2;
-		while (*p2) *p1++=*p2++;
+		while (*p2) *p1++ = *p2++;
 		*p1=0;
 		p1 = temp2+1;
 		p2 = lpstrFilename;
-		while (*p2)
-		{
-			*p1++ = *p2++;
-		}
+		while (*p2) *p1++ = *p2++;
 		*p1=0;
 		temp2[0] = '0';
 	}
@@ -536,7 +521,7 @@
 		if (*p == '.' || *p == '/' || *p == '\\' || *p == '*' || 
 			*p == '?' || *p == ':' || *p == '+' || *p == '\"' || 
 			*p == '\'' || *p == '|' || *p == '<' || *p == '>') *p = '_';
-		p=CharNext(p);
+			p=CharNext(p);
 	}
 
 	p=config_AACoutdir;
@@ -551,7 +536,7 @@
 	else
 		wsprintf(lpstrFilename,"%s\\%s.aac",config_AACoutdir,temp2);
 
- 	w_offset = writtentime = 0;
+	w_offset = writtentime = 0;
 	numchan = wChannels;
 	srate = lSamprate;
 	bps = wBitsPerSample;
@@ -561,148 +546,107 @@
 	/* open the aac output file */
 	if(!(outfile=fopen(lpstrFilename, "wb")))
 	{
-     MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
-	 return -1;
+		MessageBox(0, "Can't create file", "FAAC interface", MB_OK);
+		return -1;
 	}
 
 	/* open the encoder library */
 	if(!(hEncoder=faacEncOpen(lSamprate, wChannels, &samplesInput, &maxBytesOutput)))
 	{
-	 MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
-	 fclose(outfile);
-	 return -1;
+		MessageBox(0, "Can't init library", "FAAC interface", MB_OK);
+		fclose(outfile);
+		return -1;
 	}
 
 	if(!(bitbuf=(unsigned char*)malloc(maxBytesOutput*sizeof(unsigned char))))
 	{
-	 MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
-     faacEncClose(hEncoder);
-	 fclose(outfile);
-	 return -1;
+		MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
+		faacEncClose(hEncoder);
+		fclose(outfile);
+		return -1;
 	}
 
 	if(!(mo->inbuf=(unsigned char*)malloc(samplesInput*sizeof(short))))
 	{
-	 MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
-     faacEncClose(hEncoder);
-	 fclose(outfile);
-	 free(bitbuf);
-	 return -1;
+		MessageBox(0, "Memory allocation error: output buffer", "FAAC interface", MB_OK);
+		faacEncClose(hEncoder);
+		fclose(outfile);
+		free(bitbuf);
+		return -1;
 	}
 
-	 mo->fFile=outfile;
-//	 mo->lSize=lSize;
-	 mo->lSamprate=lSamprate;
-	 mo->wBitsPerSample=wBitsPerSample;
-	 mo->wChannels=wChannels;
-	 strcpy(mo->szNAME,lpstrFilename);
+	mo->fFile=outfile;
+//	mo->lSize=lSize;
+	mo->lSamprate=lSamprate;
+	mo->wBitsPerSample=wBitsPerSample;
+	mo->wChannels=wChannels;
+	strcpy(mo->szNAME,lpstrFilename);
 
-	 mo->hEncoder=hEncoder;
-     mo->bitbuf=bitbuf;
-	 mo->maxBytesOutput=maxBytesOutput;
-	 mo->samplesInput=samplesInput;
-	 mo->bStopEnc=0;
+	mo->hEncoder=hEncoder;
+	mo->bitbuf=bitbuf;
+	mo->maxBytesOutput=maxBytesOutput;
+	mo->samplesInput=samplesInput;
+	mo->bStopEnc=0;
 
 
 	if(dwOptions && !(dwOptions&1))
 	{
-    faacEncConfigurationPtr myFormat;
-     myFormat=faacEncGetCurrentConfiguration(hEncoder);
+		faacEncConfigurationPtr myFormat;
+		myFormat=faacEncGetCurrentConfiguration(hEncoder);
 
-	 myFormat->mpegVersion=(dwOptions>>29)&7;
-	 myFormat->aacObjectType=(dwOptions>>27)&3;
-	 myFormat->allowMidside=(dwOptions>>26)&1;
-	 myFormat->useTns=(dwOptions>>25)&1;
-	 myFormat->useLfe=(dwOptions>>24)&1;
-	 switch((dwOptions>>19)&31)
-	 {
-	  case 0:
-           myFormat->bitRate=8000;
-		   break;
-	  case 1:
-           myFormat->bitRate=18000;
-		   break;
-	  case 2:
-           myFormat->bitRate=20000;
-		   break;
-	  case 3:
-           myFormat->bitRate=24000;
-		   break;
-	  case 4:
-           myFormat->bitRate=32000;
-		   break;
-	  case 5:
-           myFormat->bitRate=40000;
-		   break;
-	  case 6:
-           myFormat->bitRate=48000;
-		   break;
-	  case 7:
-           myFormat->bitRate=56000;
-		   break;
-	  case 8:
-           myFormat->bitRate=64000;
-		   break;
-	  case 9:
-           myFormat->bitRate=96000;
-		   break;
-	  case 10:
-           myFormat->bitRate=112000;
-		   break;
-	  case 11:
-           myFormat->bitRate=128000;
-		   break;
-	  case 12:
-           myFormat->bitRate=160000;
-		   break;
-	  case 13:
-           myFormat->bitRate=192000;
-		   break;
-	  case 14:
-           myFormat->bitRate=256000;
-		   break;
-	 }
-     myFormat->bandWidth=(dwOptions>>1)&0x0000ffff;
-     if(!myFormat->bandWidth)
-	  myFormat->bandWidth=mo->lSamprate/2;
+		myFormat->mpegVersion=(dwOptions>>29)&7;
+		myFormat->aacObjectType=(dwOptions>>27)&3;
+		myFormat->allowMidside=(dwOptions>>26)&1;
+		myFormat->useTns=(dwOptions>>25)&1;
+		myFormat->useLfe=(dwOptions>>24)&1;
 
-	 if(!faacEncSetConfiguration(hEncoder, myFormat))
-	 {
-      MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
-      faacEncClose(hEncoder);
-	  fclose(outfile);
-	  free(bitbuf);
-      free(mo->inbuf);
-//      GlobalFree(hOutput);
-	  return -1;
-	 }
-/*	{
-faacEncConfigurationPtr myFormat;
-     myFormat=faacEncGetCurrentConfiguration(hEncoder);
+		for(br=0; br<=((dwOptions>>16)&255) ; br++)
+		{
+			if(br == ((dwOptions>>16)&255))
+				myFormat->bitRate=br*1000;
+		}
 
-	 myFormat->mpegVersion=faacEncCfg.mpegVersion;
-	 myFormat->aacObjectType=faacEncCfg.aacObjectType;
-	 myFormat->allowMidside=faacEncCfg.allowMidside;
-	 myFormat->useLfe=faacEncCfg.useLfe;
-	 myFormat->useTns=faacEncCfg.useTns;
-	 myFormat->bandWidth=faacEncCfg.bandWidth;
-	 myFormat->bitRate=faacEncCfg.bitRate;
+		myFormat->bandWidth=(dwOptions>>1)&0x0000ffff;
+		if(!myFormat->bandWidth)
+			myFormat->bandWidth=mo->lSamprate/2;
 
-	 if(!faacEncSetConfiguration(hEncoder, myFormat))
-	 {
-      MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
-      faacEncClose(hEncoder);
-	  fclose(outfile);
-	  free(bitbuf);
-      free(mo->inbuf);
-      GlobalFree(hOutput);
-	  return -1;
-	 }*/
+		if(!faacEncSetConfiguration(hEncoder, myFormat))
+		{
+			MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
+			faacEncClose(hEncoder);
+			fclose(outfile);
+			free(bitbuf);
+			free(mo->inbuf);
+//			GlobalFree(hOutput);
+			return -1;
+		}
+/*		{
+		faacEncConfigurationPtr myFormat;
+		myFormat=faacEncGetCurrentConfiguration(hEncoder);
+
+		myFormat->mpegVersion=faacEncCfg.mpegVersion;
+		myFormat->aacObjectType=faacEncCfg.aacObjectType;
+		myFormat->allowMidside=faacEncCfg.allowMidside;
+		myFormat->useLfe=faacEncCfg.useLfe;
+		myFormat->useTns=faacEncCfg.useTns;
+		myFormat->bandWidth=faacEncCfg.bandWidth;
+		myFormat->bitRate=faacEncCfg.bitRate;
+
+		if(!faacEncSetConfiguration(hEncoder, myFormat))
+		{
+			MessageBox(0, "Unsupported parameters", "FAAC interface", MB_OK);
+			faacEncClose(hEncoder);
+			fclose(outfile);
+			free(bitbuf);
+			free(mo->inbuf);
+			GlobalFree(hOutput);
+			return -1;
+		}*/
 	}
 
-    bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
-    if(bytesEncoded>0)
-	 fwrite(bitbuf, 1, bytesEncoded, outfile);
+	bytesEncoded=faacEncEncode(hEncoder, 0, 0, bitbuf, maxBytesOutput); // initializes the flushing process
+	if(bytesEncoded>0)
+		fwrite(bitbuf, 1, bytesEncoded, outfile);
 
 	return 0;
 }
@@ -709,103 +653,102 @@
 
 void Close()
 {
-// Following code crashes winamp. why???
+//	Following code crashes winamp. why???
 
-if(mo->bytes_into_buffer)
- {
-int bytesEncoded;
-  bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->bytes_into_buffer/sizeof(short), mo->bitbuf, mo->maxBytesOutput);
-  if(bytesEncoded>0)
-   fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
- }
+	if(mo->bytes_into_buffer)
+	{
+		int bytesEncoded;
+		bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->bytes_into_buffer/sizeof(short), mo->bitbuf, mo->maxBytesOutput);
+		if(bytesEncoded>0)
+			fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+	}
 
- if(mo->hEncoder)
-  faacEncClose(mo->hEncoder);
- if(mo->fFile)
-  fclose(mo->fFile);
- if(mo->bitbuf)
-  free(mo->bitbuf);
- if(mo->inbuf)
-  free(mo->inbuf);
+	if(mo->hEncoder)
+		faacEncClose(mo->hEncoder);
+	if(mo->fFile)
+		fclose(mo->fFile);
+	if(mo->bitbuf)
+		free(mo->bitbuf);
+	if(mo->inbuf)
+		free(mo->inbuf);
 
-// CloseHandle(outfile);
+//	CloseHandle(outfile);
 }
 
 int Write(char *buf, int len)
 {
-int bytesWritten;
-int bytesEncoded;
-int k,i,shift=0;
+	int bytesWritten;
+	int bytesEncoded;
+	int k,i,shift=0;
 
-  writtentime += len;
+	writtentime += len;
   
-  if(!mo->bStopEnc)
-  {
+	if(!mo->bStopEnc)
+	{
+		if(mo->bytes_into_buffer+len<mo->samplesInput*sizeof(short))
+		{
+			memcpy(mo->inbuf+mo->bytes_into_buffer, buf, len);
+			mo->bytes_into_buffer+=len;
+			return 0;
+		}
+		else
+			if(mo->bytes_into_buffer)
+			{
+				shift=mo->samplesInput*sizeof(short)-mo->bytes_into_buffer;
+				memcpy(mo->inbuf+mo->bytes_into_buffer, buf, shift);
+				mo->bytes_into_buffer+=shift;
+				buf+=shift;
+				len-=shift;
 
-   if(mo->bytes_into_buffer+len<mo->samplesInput*sizeof(short))
-   {
-    memcpy(mo->inbuf+mo->bytes_into_buffer, buf, len);
-	mo->bytes_into_buffer+=len;
-	return 0;
-   }
-   else
-    if(mo->bytes_into_buffer)
-    {
-     shift=mo->samplesInput*sizeof(short)-mo->bytes_into_buffer;
-     memcpy(mo->inbuf+mo->bytes_into_buffer, buf, shift);
-     mo->bytes_into_buffer+=shift;
-     buf+=shift;
-	 len-=shift;
+				bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+				mo->bytes_into_buffer=0;
+				if(bytesEncoded<1) // end of flushing process
+				{
+					if(bytesEncoded<0)
+					{
+						MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
+						mo->bStopEnc=1;
+					}
+					bytesWritten=len ? 0 : -1;
+					return bytesWritten;
+				}
+//				write bitstream to aac file 
+				bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+				if(bytesWritten!=bytesEncoded)
+				{
+					MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
+					mo->bStopEnc=1;
+					return -1;
+				}
+			}
 
-     bytesEncoded=faacEncEncode(mo->hEncoder, (short *)mo->inbuf, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
-	 mo->bytes_into_buffer=0;
-     if(bytesEncoded<1) // end of flushing process
-     {
-      if(bytesEncoded<0)
-	  {
-       MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
-       mo->bStopEnc=1;
-	  }
-	  bytesWritten=len ? 0 : -1;
-      return bytesWritten;
-     }
-// write bitstream to aac file 
-     bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
-     if(bytesWritten!=bytesEncoded)
-     {
-      MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
-      mo->bStopEnc=1;
-      return -1;
-     }
+//		call the actual encoding routine
+		k=len/(mo->samplesInput*sizeof(short));
+		for(i=0; i<k; i++)
+		{
+			bytesEncoded+=faacEncEncode(mo->hEncoder, ((short *)buf)+i*mo->samplesInput, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
+			if(bytesEncoded<1) // end of flushing process
+			{
+				if(bytesEncoded<0)
+				{
+					MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
+					mo->bStopEnc=1;
+				}
+				bytesWritten=len ? 0 : -1;
+				return bytesWritten;
+			}
+//		write bitstream to aac file 
+		bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
+		if(bytesWritten!=bytesEncoded)
+		{
+			MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
+			mo->bStopEnc=1;
+			return -1;
+		}
 	}
 
-// call the actual encoding routine
-   k=len/(mo->samplesInput*sizeof(short));
-   for(i=0; i<k; i++)
-   {
-    bytesEncoded+=faacEncEncode(mo->hEncoder, ((short *)buf)+i*mo->samplesInput, mo->samplesInput, mo->bitbuf, mo->maxBytesOutput);
-    if(bytesEncoded<1) // end of flushing process
-    {
-     if(bytesEncoded<0)
-	 {
-      MessageBox(0, "faacEncEncode() failed", "FAAC interface", MB_OK);
-      mo->bStopEnc=1;
-	 }
-	 bytesWritten=len ? 0 : -1;
-     return bytesWritten;
-    }
-// write bitstream to aac file 
-    bytesWritten=fwrite(mo->bitbuf, 1, bytesEncoded, mo->fFile);
-    if(bytesWritten!=bytesEncoded)
-    {
-     MessageBox(0, "bytesWritten and bytesEncoded are different", "FAAC interface", MB_OK);
-     mo->bStopEnc=1;
-     return -1;
-    }
-   }
-
-   mo->bytes_into_buffer=len%(mo->samplesInput*sizeof(short));
-   memcpy(mo->inbuf, buf+k*mo->samplesInput*sizeof(short), mo->bytes_into_buffer);
+	mo->bytes_into_buffer=len%(mo->samplesInput*sizeof(short));
+	memcpy(mo->inbuf, buf+k*mo->samplesInput*sizeof(short), mo->bytes_into_buffer);
   }
 
   Sleep(0);
@@ -840,10 +783,10 @@
 
 void Flush(int t)
 {
-  int a;
-  w_offset=0;
-  a = t - GetWrittenTime();
-  w_offset=a;
+	int a;
+	w_offset=0;
+	a = t - GetWrittenTime();
+	w_offset=a;
 }
 	
 int GetWrittenTime()