944 lines · 31.5 KB · C++
RawDownload
/*CFAAC - set of classes to import/export .aac/.mp4 filesCopyright (C) 2004 Antonio Foranna This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation.	This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.		You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.			The author can be contacted at:ntnfrn_email-temp@yahoo.it*/ #include <windows.h>#include <shlobj.h>		// Browse#include <shellapi.h>	// ShellExecute#include <Commdlg.h>#include "resource.h"#include "Defines.h"	// my defines#include "CTag.h"#include "Cfaac.h"#include "EncDialog.h" #include <commctrl.h>#include <id3v2tag.h>#include <..\..\common\id3lib\win32\config.h> // ID3LIB_FULLNAME // ********************************************************************************************* #ifdef USE_OUTPUT_FOLDERextern char	config_AACoutdir[MAX_PATH];#endif extern HINSTANCE hInstance;extern HBITMAP hBmBrowse; // ********************************************************************************************* /*DWORD PackCfg(MY_ENC_CFG *cfg){DWORD dwOptions=0; 	if(cfg->AutoCfg)		dwOptions=1<<31;	dwOptions|=(DWORD)cfg->EncCfg.mpegVersion<<30;	dwOptions|=(DWORD)cfg->EncCfg.aacObjectType<<28;	dwOptions|=(DWORD)cfg->EncCfg.allowMidside<<27;	dwOptions|=(DWORD)cfg->EncCfg.useTns<<26;	dwOptions|=(DWORD)cfg->EncCfg.useLfe<<25;	dwOptions|=(DWORD)cfg->EncCfg.outputFormat<<24;	if(cfg->UseQuality)		dwOptions|=(((DWORD)cfg->EncCfg.quantqual>>1)&0xff)<<16; // [2,512]	else		dwOptions|=(((DWORD)cfg->EncCfg.bitRate>>1)&0xff)<<16; // [2,512]	if(cfg->UseQuality)		dwOptions|=1<<15;	dwOptions|=((DWORD)cfg->EncCfg.bandWidth>>1)&&0x7fff; // [0,65536] 	return dwOptions;}// ----------------------------------------------------------------------------------------------- void UnpackCfg(MY_ENC_CFG *cfg, DWORD dwOptions){	cfg->AutoCfg=dwOptions>>31;	cfg->EncCfg.mpegVersion=(dwOptions>>30)&1;	cfg->EncCfg.aacObjectType=(dwOptions>>28)&3;	cfg->EncCfg.allowMidside=(dwOptions>>27)&1;	cfg->EncCfg.useTns=(dwOptions>>26)&1;	cfg->EncCfg.useLfe=(dwOptions>>25)&1;	cfg->EncCfg.outputFormat=(dwOptions>>24)&1;	cfg->EncCfg.bitRate=((dwOptions>>16)&0xff)<<1;	cfg->UseQuality=(dwOptions>>15)&1;	cfg->EncCfg.bandWidth=(dwOptions&0x7fff)<<1;}*/// ----------------------------------------------------------------------------------------------- #define INIT_CB(hWnd,nID,list,FillList,IdSelected) \{ \	if(FillList) \		for(int i=0; list[i]; i++) \			SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)list[i]); \	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \}// ----------------------------------------------------------------------------------------------- #define INIT_CB_GENRES(hWnd,nID,ID3Genres,IdSelected) \{ \	for(int i=0; i<(sizeof(ID3Genres)/sizeof(ID3Genres[0])); i++) \		SendMessage(GetDlgItem(hWnd, nID), CB_ADDSTRING, 0, (LPARAM)ID3Genres[i].name); \	SendMessage(GetDlgItem(hWnd, nID), CB_SETCURSEL, IdSelected, 0); \}// ----------------------------------------------------------------------------------------------- #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); \}// ----------------------------------------------------------------------------------------------- //        EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_SSR), Enabled);//        EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled);#define DISABLE_CTRLS_ENC(Enabled) \{ \	CheckDlgButton(hWndDlg,IDC_CHK_AUTOCFG, !Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG4), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MPEG2), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_RAW), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_ADTS), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_ALLOWMIDSIDE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USETNS), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_USELFE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_QUALITY), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BITRATE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_BANDWIDTH), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_QUALITY), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_BITRATE), Enabled); \    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_MAIN), Enabled); \    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LOW), Enabled); \    EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \	if(IsDlgButtonChecked(hWndDlg,IDC_RADIO_MPEG4)) \		EnableWindow(GetDlgItem(hWndDlg, IDC_RADIO_LTP), Enabled); \	else \		DISABLE_LTP \}// ----------------------------------------------------------------------------------------------- #define ENABLE_TAG(Enabled) \{ \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTIST), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TITLE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ALBUM), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_YEAR), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CB_GENRE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_WRITER), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMMENT), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_TRACK), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_ARTFILE), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), Enabled); \}// ----------------------------------------------------------------------------------------------- #define ENABLE_AACTAGS(Enabled) \{ \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_COMPILATION), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_CHK_COMPILATION), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NTRACKS), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_DISK), Enabled); \	EnableWindow(GetDlgItem(hWndDlg, IDC_E_NDISKS), Enabled); \}// ----------------------------------------------------------------------------------------------- #ifdef USE_OUTPUT_FOLDERstatic int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData){	if (uMsg == BFFM_INITIALIZED)	{		SetWindowText(hwnd,"Select folder");		SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData);	}	return 0;}#else	#ifdef USE_IMPORT_TAG	static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)	{		if (uMsg == BFFM_INITIALIZED)		{			SetWindowText(hwnd,"Select folder");			SendMessage(hwnd,BFFM_SETSELECTION,(WPARAM)TRUE,(LPARAM)lpData);		}		return 0;	}	#endif#endif // ----------------------------------------------------------------------------------------------- BOOL DialogMsgProcAbout(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam){	switch(Message)	{	case WM_INITDIALOG:		{		char buf[512];		char *faac_id_string, *faac_copyright_string; 		sprintf(buf,					APP_NAME " plugin " APP_VER " by Antonio Foranna\n\n"					"Libraries used:\n"					"\tlibfaac v%s\n"					"\tFAAD2 v" FAAD2_VERSION "\n"					"\t" MPEG4IP_PACKAGE " v" MPEG4IP_VERSION "\n"					"\t" ID3LIB_FULLNAME "\n\n"					"This code is given with FAAC package and does not contain executables.\n"					"This program is free software and can be distributed/modifyed under the terms of the GNU General Public License.\n"					"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.\n\n"					"Compiled on %s\n",				(faacEncGetVersion(&faac_id_string, &faac_copyright_string)==FAAC_CFG_VERSION) ? faac_id_string : " wrong libfaac version",					__DATE__					);			SetDlgItemText(hWndDlg, IDC_L_ABOUT, buf);		}		break;	case WM_COMMAND:		switch(LOWORD(wParam))		{		case IDOK:			EndDialog(hWndDlg, TRUE);			break;        case IDCANCEL:			// Ignore data values entered into the controls and dismiss the dialog window returning FALSE			EndDialog(hWndDlg, FALSE);			break;		case IDC_AUDIOCODING:			ShellExecute(hWndDlg, NULL, "http://www.audiocoding.com", NULL, NULL, SW_SHOW);			break;		case IDC_MPEG4IP:			ShellExecute(hWndDlg, NULL, "http://www.mpeg4ip.net", NULL, NULL, SW_SHOW);			break;		case IDC_ID3:			ShellExecute(hWndDlg, NULL, "http://id3lib.sourceforge.net", NULL, NULL, SW_SHOW);			break;		case IDC_EMAIL:			ShellExecute(hWndDlg, NULL, "mailto:ntnfrn_email-temp@yahoo.it", NULL, NULL, SW_SHOW);			break;		}		break;	default: 		return FALSE;	} 	return TRUE;}// ----------------------------------------------------------------------------------------------- // ripped from id3v2tag.cID3GENRES ID3Genres[]={    123,    "Acapella",    34,     "Acid",    74,     "Acid Jazz",    73,     "Acid Punk",    99,     "Acoustic",    20,     "Alternative",    40,     "AlternRock",    26,     "Ambient",    90,     "Avantgarde",    116,    "Ballad",    41,     "Bass",    85,     "Bebob",    96,     "Big Band",    89,     "Bluegrass",    0,      "Blues",    107,    "Booty Bass",    65,     "Cabaret",    88,     "Celtic",    104,    "Chamber Music",    102,    "Chanson",    97,     "Chorus",    61,     "Christian Rap",    1,      "Classic Rock",    32,     "Classical",    112,    "Club",    57,     "Comedy",    2,      "Country",    58,     "Cult",    3,      "Dance",    125,    "Dance Hall",    50,     "Darkwave",    254,    "Data",    22,     "Death Metal",    4,      "Disco",    55,     "Dream",    122,    "Drum Solo",    120,    "Duet",    98,     "Easy Listening",    52,     "Electronic",    48,     "Ethnic",    124,    "Euro-House",    25,     "Euro-Techno",    54,     "Eurodance",    84,     "Fast Fusion",    80,     "Folk",    81,     "Folk-Rock",    115,    "Folklore",    119,    "Freestyle",    5,      "Funk",    30,     "Fusion",    36,     "Game",    59,     "Gangsta",    38,     "Gospel",    49,     "Gothic",    91,     "Gothic Rock",    6,      "Grunge",    79,     "Hard Rock",    7,      "Hip-Hop",    35,     "House",    100,    "Humour",    19,     "Industrial",    33,     "Instrumental",    46,     "Instrumental Pop",    47,     "Instrumental Rock",    8,      "Jazz",    29,     "Jazz+Funk",    63,     "Jungle",    86,     "Latin",    71,     "Lo-Fi",    45,     "Meditative",    9,      "Metal",    77,     "Musical",    82,     "National Folk",    64,     "Native American",    10,     "New Age",    66,     "New Wave",    39,     "Noise",    255,    "Not Set",    11,     "Oldies",    103,    "Opera",    12,     "Other",    75,     "Polka",    13,     "Pop",    62,     "Pop/Funk",    53,     "Pop-Folk",    109,    "Porn Groove",    117,    "Power Ballad",    23,     "Pranks",    108,    "Primus",    92,     "Progressive Rock",    67,     "Psychadelic",    93,     "Psychedelic Rock",    43,     "Punk",    121,    "Punk Rock",    14,     "R&B",    15,     "Rap",    68,     "Rave",    16,     "Reggae",    76,     "Retro",    87,     "Revival",    118,    "Rhythmic Soul",    17,     "Rock",    78,     "Rock & Roll",    114,    "Samba",    110,    "Satire",    69,     "Showtunes",    21,     "Ska",    111,    "Slow Jam",    95,     "Slow Rock",    105,    "Sonata",    42,     "Soul",    37,     "Sound Clip",    24,     "Soundtrack",    56,     "Southern Rock",    44,     "Space",    101,    "Speech",    83,     "Swing",    94,     "Symphonic Rock",    106,    "Symphony",    113,    "Tango",    18,     "Techno",    51,     "Techno-Industrial",    60,     "Top 40",    70,     "Trailer",    31,     "Trance",    72,     "Tribal",    27,     "Trip-Hop",    28,     "Vocal"}; BOOL CALLBACK DIALOGMsgProcEnc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam){	switch(Message)	{	case WM_INITDIALOG:		{		char buf[50];		char FillList=wParam||lParam ? 1 : 0;		char *Quality[]={"Default (100)","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","200","300","400","500",0};		char *BitRate[]={"Auto","8","16","18","20","24","32","40","48","56","64","80","96","112","128","160","192","224","256","320","384",0};		char *BandWidth[]={"Auto","Full","4000","8000","11025","16000","22050","24000","32000","44100","48000",0};		char *Ext[]={".aac",".mp4",".m4a",".m4b",0};		CMyEncCfg cfg(false);			//			sprintf(Quality[0]+8,"%3d",3); 			SetWindowPos(GetDlgItem(hWndDlg,IDC_CHK_TAG),GetDlgItem(hWndDlg,IDC_GRP_TAG),0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); 			INIT_CB(hWndDlg,IDC_CB_QUALITY,Quality,FillList,0);			INIT_CB(hWndDlg,IDC_CB_BITRATE,BitRate,FillList,0);			INIT_CB(hWndDlg,IDC_CB_BANDWIDTH,BandWidth,FillList,0);			INIT_CB(hWndDlg,IDC_CB_EXT,Ext,FillList,0); 			INIT_CB_GENRES(hWndDlg,IDC_CB_GENRE,ID3Genres,0); 			SendMessage(GetDlgItem(hWndDlg, IDC_BTN_ARTFILE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);#ifdef USE_OUTPUT_FOLDER						SendMessage(GetDlgItem(hWndDlg, IDC_BTN_BROWSE), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hBmBrowse);			if(!cfg.OutDir || !*cfg.OutDir)			{				GetCurrentDirectory(MAX_PATH,config_AACoutdir);				FREE_ARRAY(cfg.OutDir);				cfg.OutDir=strdup(config_AACoutdir);			}			else				strcpy(config_AACoutdir,cfg.OutDir);			SetDlgItemText(hWndDlg, IDC_E_BROWSE, cfg.OutDir);#else			ShowWindow(GetDlgItem(hWndDlg, IDC_BTN_BROWSE),SW_HIDE);			ShowWindow(GetDlgItem(hWndDlg, IDC_E_BROWSE),SW_HIDE);			ShowWindow(GetDlgItem(hWndDlg, IDC_L_BROWSE),SW_HIDE);#endif			CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,FALSE);			CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,FALSE);			if(cfg.EncCfg.mpegVersion==MPEG4)				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG4,TRUE);			else				CheckDlgButton(hWndDlg,IDC_RADIO_MPEG2,TRUE);						CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,FALSE);			CheckDlgButton(hWndDlg,IDC_RADIO_LOW,FALSE);			CheckDlgButton(hWndDlg,IDC_RADIO_SSR,FALSE);			CheckDlgButton(hWndDlg,IDC_RADIO_LTP,FALSE);			switch(cfg.EncCfg.aacObjectType)			{			case MAIN:				CheckDlgButton(hWndDlg,IDC_RADIO_MAIN,TRUE);				break;			case LOW:				CheckDlgButton(hWndDlg,IDC_RADIO_LOW,TRUE);				break;			case SSR:				CheckDlgButton(hWndDlg,IDC_RADIO_SSR,TRUE);				break;			case LTP:				CheckDlgButton(hWndDlg,IDC_RADIO_LTP,TRUE);				DISABLE_LTP				break;			}						CheckDlgButton(hWndDlg,IDC_RADIO_RAW,FALSE);			CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,FALSE);			switch(cfg.EncCfg.outputFormat)			{			case RAW:				CheckDlgButton(hWndDlg,IDC_RADIO_RAW,TRUE);				break;			case ADTS:				CheckDlgButton(hWndDlg,IDC_RADIO_ADTS,TRUE);				break;			}						CheckDlgButton(hWndDlg, IDC_CHK_ALLOWMIDSIDE, cfg.EncCfg.allowMidside);			CheckDlgButton(hWndDlg, IDC_CHK_USETNS, cfg.EncCfg.useTns);			CheckDlgButton(hWndDlg, IDC_CHK_USELFE, cfg.EncCfg.useLfe); 			if(cfg.UseQuality)				CheckDlgButton(hWndDlg,IDC_RADIO_QUALITY,TRUE);			else				CheckDlgButton(hWndDlg,IDC_RADIO_BITRATE,TRUE); 			switch(cfg.EncCfg.quantqual)			{			case 100:				SendMessage(GetDlgItem(hWndDlg, IDC_CB_QUALITY), CB_SETCURSEL, 0, 0);				break;			default:				if(cfg.EncCfg.quantqual<10)					cfg.EncCfg.quantqual=10;				if(cfg.EncCfg.quantqual>500)					cfg.EncCfg.quantqual=500;				sprintf(buf,"%lu",cfg.EncCfg.quantqual);				SetDlgItemText(hWndDlg, IDC_CB_QUALITY, buf);				break;			}			switch(cfg.EncCfg.bitRate)			{			case 0:				SendMessage(GetDlgItem(hWndDlg, IDC_CB_BITRATE), CB_SETCURSEL, 0, 0);				break;			default:

Lines 1–500 of 944.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t