⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aencodeproperties.cpp

📁 音频编码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/** * * Lame ACM wrapper, encode/decode MP3 based RIFF/AVI files in MS Windows * *  Copyright (c) 2002 Steve Lhomme <steve.lhomme at free.fr> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */ /*!	\author Steve Lhomme	\version \$Id: AEncodeProperties.cpp,v 1.8 2002/04/08 18:43:30 robux4 Exp $*/#if !defined(STRICT)#define STRICT#endif // !defined(STRICT)#include <windows.h>#include <windowsx.h>#include <shlobj.h>#include <assert.h>#ifdef _MSC_VER// no problem with unknown pragmas#pragma warning(disable: 4068)#endif#include "resource.h"#include <config.h>#include "util.h"#include "adebug.h"#include "AEncodeProperties.h"#include "ACM.h"//#include "AParameters/AParameters.h"#ifndef TTS_BALLOON#define TTS_BALLOON            0x40#endif // TTS_BALLOONconst unsigned int AEncodeProperties::the_Bitrates[18] = {320, 256, 224, 192, 160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8 };const unsigned int AEncodeProperties::the_MPEG1_Bitrates[14] = {320, 256, 224, 192, 160, 128, 112, 96, 80, 64, 56, 48, 40, 32 };const unsigned int AEncodeProperties::the_MPEG2_Bitrates[14] = {160, 144, 128, 112, 96, 80, 64, 56, 48, 40, 32, 24, 16, 8};const unsigned int AEncodeProperties::the_ChannelModes[3] = { STEREO, JOINT_STEREO, DUAL_CHANNEL };//const char         AEncodeProperties::the_Presets[][13] = {"None", "CD", "Studio", "Hi-Fi", "Phone", "Voice", "Radio", "Tape", "FM", "AM", "SW"};//const LAME_QUALTIY_PRESET AEncodeProperties::the_Presets[] = {LQP_NOPRESET, LQP_R3MIX_QUALITY, LQP_NORMAL_QUALITY, LQP_LOW_QUALITY, LQP_HIGH_QUALITY, LQP_VERYHIGH_QUALITY, LQP_VOICE_QUALITY, LQP_PHONE, LQP_SW, LQP_AM, LQP_FM, LQP_VOICE, LQP_RADIO, LQP_TAPE, LQP_HIFI, LQP_CD, LQP_STUDIO};//const unsigned int AEncodeProperties::the_SamplingFreqs[9] = { 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000 };ToolTipItem AEncodeProperties::Tooltips[13]={	{ IDC_CHECK_ENC_ABR, "Allow encoding with an average bitrate\r\ninstead of a constant one.\r\n\r\nIt can improve the quality for the same bitrate." },	{ IDC_CHECK_COPYRIGHT, "Mark the encoded data as copyrighted." },	{ IDC_CHECK_CHECKSUM, "Put a checksum in the encoded data.\r\n\r\nThis can make the file less sensitive to data loss." },	{ IDC_CHECK_ORIGINAL, "Mark the encoded data as an original file." },	{ IDC_CHECK_PRIVATE, "Mark the encoded data as private." },	{ IDC_COMBO_ENC_STEREO, "Select the type of stereo mode used for encoding:\r\n\r\n- Stereo : the usual one\r\n- Joint-Stereo : mix both channel to achieve better compression\r\n- Dual Channel : treat both channel as separate" },	{ IDC_STATIC_DECODING, "Decoding not supported for the moment by the codec." },	{ IDC_CHECK_ENC_SMART, "Disable bitrate when there is too much compression.\r\n(default 1:15 ratio)" },	{ IDC_STATIC_CONFIG_VERSION, "Version of this codec.\r\n\r\nvX.X.X is the version of the codec interface.\r\nX.XX is the version of the encoding engine." },	{ IDC_SLIDER_AVERAGE_MIN, "Select the minimum Average Bitrate allowed." },	{ IDC_SLIDER_AVERAGE_MAX, "Select the maximum Average Bitrate allowed." },	{ IDC_SLIDER_AVERAGE_STEP, "Select the step of Average Bitrate between the min and max.\r\n\r\nA step of 5 between 152 and 165 means you have :\r\n165, 160 and 155" },	{ IDC_SLIDER_AVERAGE_SAMPLE, "Check the resulting values of the (min,max,step) combination.\r\n\r\nUse the keyboard to navigate (right -> left)." },};//int AEncodeProperties::tst = 0;/*#pragma argsusedstatic UINT CALLBACK DLLFindCallback(  HWND hdlg,      // handle to child dialog box  UINT uiMsg,     // message identifier  WPARAM wParam,  // message parameter  LPARAM lParam   // message parameter  ){	UINT result = 0;	switch (uiMsg)	{		case WM_NOTIFY:			OFNOTIFY * info = (OFNOTIFY *)lParam;			if (info->hdr.code == CDN_FILEOK)			{				result = 1; // by default we don't accept the file				// Check if the selected file is a valid DLL with all the required functions				ALameDLL * tstFile = new ALameDLL;				if (tstFile != NULL)				{					if (tstFile->Load(info->lpOFN->lpstrFile))					{						result = 0;					}					delete tstFile;				}				if (result == 1)				{					TCHAR output[250];					::LoadString(AOut::GetInstance(),IDS_STRING_DLL_UNRECOGNIZED,output,250);					AOut::MyMessageBox( output, MB_OK|MB_ICONEXCLAMATION, hdlg);					SetWindowLong(hdlg, DWL_MSGRESULT , -100);				}			}	}	return result;}#pragma argsusedstatic int CALLBACK BrowseFolderCallbackroc(    HWND hwnd,    UINT uMsg,    LPARAM lParam,    LPARAM lpData    ){	AEncodeProperties * the_prop;	the_prop = (AEncodeProperties *) lpData;	if (uMsg == BFFM_INITIALIZED)	{//		char FolderName[MAX_PATH];//		SHGetPathFromIDList((LPITEMIDLIST) lParam,FolderName);//ADbg tst;//tst.OutPut("init folder to %s ",the_prop->GetOutputDirectory());//		CreateFile();		::SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, (LPARAM)the_prop->GetOutputDirectory());	}/* else if (uMsg == BFFM_SELCHANGED)	{		// verify that the folder is writable//		::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable		char FolderName[MAX_PATH];		SHGetPathFromIDList((LPITEMIDLIST) lParam, FolderName);		//		if (CreateFile(FolderName,STANDARD_RIGHTS_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL) == INVALID_HANDLE_VALUE)		if ((GetFileAttributes(FolderName) & FILE_ATTRIBUTE_DIRECTORY) != 0)			::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)1); // enable		else			::SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)0); // disable//ADbg tst;//tst.OutPut("change folder to %s ",FolderName);	}* /	return 0;}*/#pragma argsusedstatic BOOL CALLBACK ConfigProc(  HWND hwndDlg,  // handle to dialog box  UINT uMsg,     // message  WPARAM wParam, // first message parameter  LPARAM lParam  // second message parameter  ){	BOOL bResult;	AEncodeProperties * the_prop;	the_prop = (AEncodeProperties *) GetProp(hwndDlg, "AEncodeProperties-Config");	switch (uMsg) {		case WM_COMMAND:			if (the_prop != NULL)			{				bResult = the_prop->HandleDialogCommand( hwndDlg, wParam, lParam);			}			break;		case WM_INITDIALOG:			assert(the_prop == NULL);			the_prop = (AEncodeProperties *) lParam;			the_prop->my_debug.OutPut("there hwnd = 0x%08X",hwndDlg);			assert(the_prop != NULL);			SetProp(hwndDlg, "AEncodeProperties-Config", the_prop);			the_prop->InitConfigDlg(hwndDlg);			bResult = TRUE;			break;		case WM_HSCROLL:			// check if it's the ABR sliders			if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MIN))			{				the_prop->UpdateDlgFromSlides(hwndDlg);			}			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_MAX))			{				the_prop->UpdateDlgFromSlides(hwndDlg);			}			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_STEP))			{				the_prop->UpdateDlgFromSlides(hwndDlg);			}			else if ((HWND)lParam == GetDlgItem(hwndDlg,IDC_SLIDER_AVERAGE_SAMPLE))			{				the_prop->UpdateDlgFromSlides(hwndDlg);			}			break;		case WM_NOTIFY:			if (TTN_GETDISPINFO == ((LPNMHDR)lParam)->code) {				NMTTDISPINFO *lphdr = (NMTTDISPINFO *)lParam;				UINT id = (lphdr->uFlags & TTF_IDISHWND) ? GetWindowLong((HWND)lphdr->hdr.idFrom, GWL_ID) : lphdr->hdr.idFrom;				*lphdr->lpszText = 0;				SendMessage(lphdr->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 5000);				for(int i=0; i<sizeof AEncodeProperties::Tooltips/sizeof AEncodeProperties::Tooltips[0]; ++i) {					if (id == AEncodeProperties::Tooltips[i].id)						lphdr->lpszText = const_cast<char *>(AEncodeProperties::Tooltips[i].tip);				}				return TRUE;			}			break;		default:			bResult = FALSE; // will be treated by DefWindowProc	}	return bResult;}//////////////////////////////////////////////////////////////////////// Construction/Destruction///////////////////////////////////////////////////////////////////////**	\class AEncodeProperties*/const char * AEncodeProperties::GetChannelModeString(int a_channelID) const{	assert(a_channelID < sizeof(the_ChannelModes));	switch (a_channelID) {		case 0:			return "Stereo";		case 1:			return "Joint-stereo";		case 2:			return "Dual Channel";		default:			assert(a_channelID);			return NULL;	}}const int AEncodeProperties::GetBitrateString(char * string, int string_size, int a_bitrateID) const{	assert(a_bitrateID < sizeof(the_Bitrates));	assert(string != NULL);	if (string_size >= 4)		return wsprintf(string,"%d",the_Bitrates[a_bitrateID]);	else		return -1;}const unsigned int AEncodeProperties::GetChannelModeValue() const{	assert(nChannelIndex < sizeof(the_ChannelModes));	return the_ChannelModes[nChannelIndex];}const unsigned int AEncodeProperties::GetBitrateValue() const{	assert(nMinBitrateIndex < sizeof(the_Bitrates));	return the_Bitrates[nMinBitrateIndex];}inline const int AEncodeProperties::GetBitrateValueMPEG2(DWORD & bitrate) const{	int i;	for (i=0;i<sizeof(the_MPEG2_Bitrates)/sizeof(unsigned int);i++)	{		if (the_MPEG2_Bitrates[i] == the_Bitrates[nMinBitrateIndex])		{			bitrate = the_MPEG2_Bitrates[i];			return 0;		}		else if (the_MPEG2_Bitrates[i] < the_Bitrates[nMinBitrateIndex])		{			bitrate = the_MPEG2_Bitrates[i];			return -1;		}	}		bitrate = 160;	return -1;}inline const int AEncodeProperties::GetBitrateValueMPEG1(DWORD & bitrate) const{	int i;	for (i=sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1;i>=0;i--)	{		if (the_MPEG1_Bitrates[i] == the_Bitrates[nMinBitrateIndex])		{			bitrate = the_MPEG1_Bitrates[i];			return 0;		}		else if (the_MPEG1_Bitrates[i] > the_Bitrates[nMinBitrateIndex])		{			bitrate = the_MPEG1_Bitrates[i];			return 1;		}	}		bitrate = 32;	return 1;}/*const int AEncodeProperties::GetBitrateValue(DWORD & bitrate, const DWORD MPEG_Version) const{	assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));	assert(nMinBitrateIndex < sizeof(the_Bitrates));	if (MPEG_Version == MPEG2)		return GetBitrateValueMPEG2(bitrate);	else		return GetBitrateValueMPEG1(bitrate);}/*const char * AEncodeProperties::GetPresetModeString(const int a_presetID) const{	assert(a_presetID < sizeof(the_Presets));	switch (a_presetID) {		case 1:			return "r3mix";		case 2:			return "Normal";		case 3:			return "Low";		case 4:			return "High";		case 5:			return "Very High";		case 6:			return "Voice";		case 7:			return "Phone";		case 8:			return "SW";		case 9:			return "AM";		case 10:			return "FM";		case 11:			return "Voice";		case 12:			return "Radio";		case 13:			return "Tape";		case 14:			return "Hi-Fi";		case 15:			return "CD";		case 16:			return "Studio";		default:			return "None";	}}const LAME_QUALTIY_PRESET AEncodeProperties::GetPresetModeValue() const{	assert(nPresetIndex < sizeof(the_Presets));	return the_Presets[nPresetIndex];}*/bool AEncodeProperties::Config(const HINSTANCE Hinstance, const HWND HwndParent){	//WM_INITDIALOG ?	// remember the instance to retreive strings//	hDllInstance = Hinstance;	my_debug.OutPut("here");	int ret = ::DialogBoxParam(Hinstance, MAKEINTRESOURCE(IDD_CONFIG), HwndParent, ::ConfigProc, (LPARAM) this);/*	if (ret == -1)	{		LPVOID lpMsgBuf;		FormatMessage( 			FORMAT_MESSAGE_ALLOCATE_BUFFER | 			FORMAT_MESSAGE_FROM_SYSTEM | 			FORMAT_MESSAGE_IGNORE_INSERTS,			NULL,			GetLastError(),			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language			(LPTSTR) &lpMsgBuf,			0,			NULL 		);		// Process any inserts in lpMsgBuf.		// ...		// Display the string.		AOut::MyMessageBox( (LPCTSTR)lpMsgBuf, MB_OK | MB_ICONINFORMATION );		// Free the buffer.		LocalFree( lpMsgBuf );			return false;	}*/		return true;}bool AEncodeProperties::InitConfigDlg(HWND HwndDlg){	// get all the required strings//	TCHAR Version[5];//	LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);	int i;	// Add required channel modes	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_RESETCONTENT , NULL, NULL);	for (i=0;i<GetChannelLentgh();i++)		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_ADDSTRING, NULL, (LPARAM) GetChannelModeString(i));	char tmp[20];	wsprintf(tmp, "v%s",ACM::GetVersionString());	SetWindowText( GetDlgItem( HwndDlg, IDC_STATIC_CONFIG_VERSION), tmp);	// Add all possible re-sampling freq/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_RESETCONTENT , NULL, NULL);	char tmp[10];	for (i=0;i<sizeof(the_SamplingFreqs)/sizeof(unsigned int);i++)	{		wsprintf(tmp, "%d", the_SamplingFreqs[i]);		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_ADDSTRING, NULL, (LPARAM) tmp );	}*/		// Add required bitrates/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_RESETCONTENT , NULL, NULL);	for (i=0;i<GetBitrateLentgh();i++)	{		GetBitrateString(tmp, 5, i);		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );	}	// Add bitrates to the VBR combo box too	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_RESETCONTENT , NULL, NULL);	for (i=0;i<GetBitrateLentgh();i++)	{		GetBitrateString(tmp, 5, i);		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_ADDSTRING, NULL, (LPARAM) tmp );	}	// Add VBR Quality Slider	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));	// Add presets	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_RESETCONTENT , NULL, NULL);	for (i=0;i<GetPresetLentgh();i++)		SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_ADDSTRING, NULL, (LPARAM) GetPresetModeString(i));*/	// Add ABR Sliders	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETRANGE, TRUE, MAKELONG(8,320));	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETRANGE, TRUE, MAKELONG(8,320));	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETRANGE, TRUE, MAKELONG(1,16));	// Tool-Tip initialiasiation	TOOLINFO ti;	HWND ToolTipWnd;	char DisplayStr[30] = "test tooltip";	ToolTipWnd = CreateWindowEx(WS_EX_TOPMOST,        TOOLTIPS_CLASS,        NULL,        WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP|TTS_BALLOON ,		        CW_USEDEFAULT,        CW_USEDEFAULT,        CW_USEDEFAULT,        CW_USEDEFAULT,        HwndDlg,        NULL,        NULL,        NULL        );	SetWindowPos(ToolTipWnd,        HWND_TOPMOST,        0,        0,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -