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

📄 aencodeproperties.cpp

📁 音频编码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        0,        0,        SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);    /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */	ti.cbSize		= sizeof(TOOLINFO);	ti.uFlags		= TTF_SUBCLASS | TTF_IDISHWND;	ti.hwnd			= HwndDlg;	ti.lpszText		= LPSTR_TEXTCALLBACK;        /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */	for(i=0; i<sizeof Tooltips/sizeof Tooltips[0]; ++i) {		ti.uId			= (WPARAM)GetDlgItem(HwndDlg, Tooltips[i].id);		if (ti.uId)			SendMessage(ToolTipWnd, TTM_ADDTOOL, 0, (LPARAM)&ti);	}my_debug.OutPut("call UpdateConfigs");	UpdateConfigs(HwndDlg);my_debug.OutPut("call UpdateDlgFromValue");	UpdateDlgFromValue(HwndDlg);	my_debug.OutPut("finished InitConfigDlg");	return true;}bool AEncodeProperties::UpdateDlgFromValue(HWND HwndDlg){	// get all the required strings//	TCHAR Version[5];//	LoadString(hDllInstance, IDS_STRING_VERSION, Version, 5);	int i;	// Check boxes if required	::CheckDlgButton( HwndDlg, IDC_CHECK_CHECKSUM,     GetCRCMode()        ?BST_CHECKED:BST_UNCHECKED );	::CheckDlgButton( HwndDlg, IDC_CHECK_ORIGINAL,     GetOriginalMode()   ?BST_CHECKED:BST_UNCHECKED );	::CheckDlgButton( HwndDlg, IDC_CHECK_PRIVATE,      GetPrivateMode()    ?BST_CHECKED:BST_UNCHECKED );	::CheckDlgButton( HwndDlg, IDC_CHECK_COPYRIGHT,    GetCopyrightMode()  ?BST_CHECKED:BST_UNCHECKED );	::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_SMART,    GetSmartOutputMode()?BST_CHECKED:BST_UNCHECKED );	::CheckDlgButton( HwndDlg, IDC_CHECK_ENC_ABR,      GetAbrOutputMode()  ?BST_CHECKED:BST_UNCHECKED );//	::CheckDlgButton( HwndDlg, IDC_CHECK_RESERVOIR,    !GetNoBiResMode() ?BST_CHECKED:BST_UNCHECKED );//	::CheckDlgButton( HwndDlg, IDC_CHECK_XINGVBR,      GetXingFrameMode()?BST_CHECKED:BST_UNCHECKED );//	::CheckDlgButton( HwndDlg, IDC_CHECK_RESAMPLE,     GetResampleMode() ?BST_CHECKED:BST_UNCHECKED );//	::CheckDlgButton( HwndDlg, IDC_CHECK_CHANNELFORCE, bForceChannel     ?BST_CHECKED:BST_UNCHECKED );		// Add required channel modes	for (i=0;i<GetChannelLentgh();i++)	{		if (i == nChannelIndex)		{			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO), CB_SETCURSEL, i, NULL);			break;		}	}	// Add VBR Quality	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_SETPOS, TRUE, AverageBitrate_Min);	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_SETPOS, TRUE, AverageBitrate_Max);	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_SETPOS, TRUE, AverageBitrate_Step);	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_SAMPLE), TBM_SETPOS, TRUE, AverageBitrate_Max);	UpdateDlgFromSlides(HwndDlg);	EnableAbrOptions(HwndDlg, GetAbrOutputMode());//	UpdateAbrSteps(AverageBitrate_Min, AverageBitrate_Max, AverageBitrate_Step);	// Add all possible re-sampling freq/*	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_SETCURSEL, nSamplingFreqIndex, NULL);		// Add required bitrates	for (i=0;i<GetBitrateLentgh();i++)	{		if (i == nMinBitrateIndex)		{			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE), CB_SETCURSEL, i, NULL);			break;		}	}	// Add bitrates to the VBR combo box too	for (i=0;i<GetBitrateLentgh();i++)	{		if (i == nMaxBitrateIndex)		{			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_SETCURSEL, i, NULL);			break;		}	}//	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETRANGE, TRUE, MAKELONG(0,9));	char tmp[3];	wsprintf(tmp,"%d",VbrQuality);	SetWindowText(GetDlgItem( HwndDlg, IDC_CONFIG_QUALITY), tmp);	SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_SETPOS, TRUE, VbrQuality);		wsprintf(tmp,"%d",AverageBitrate);	SetWindowText(GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmp);		// Display VBR settings if needed	AEncodeProperties::DisplayVbrOptions(HwndDlg, mBRmode);	// Display Resample settings if needed	if (GetResampleMode())	{		::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), TRUE);	}	else	{		::EnableWindow(::GetDlgItem(HwndDlg,IDC_COMBO_SAMPLEFREQ), FALSE);	}	// Add presets	for (i=0;i<GetPresetLentgh();i++)	{		if (i == nPresetIndex)		{			SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET), CB_SETCURSEL, i, NULL);			break;		}	}	// Add User configs//	SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SETTINGS), CB_RESETCONTENT , NULL, NULL);	::SetWindowText(::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), OutputDir.c_str());*/	/**		\todo Select the right saved config	*/	return true;}bool AEncodeProperties::UpdateValueFromDlg(HWND HwndDlg){	nChannelIndex      = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_ENC_STEREO),   CB_GETCURSEL, NULL, NULL);//	nMinBitrateIndex   = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_BITRATE),    CB_GETCURSEL, NULL, NULL);//	nMaxBitrateIndex   = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_MAXBITRATE), CB_GETCURSEL, NULL, NULL);//	nPresetIndex       = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_PRESET),     CB_GETCURSEL, NULL, NULL);//	VbrQuality         = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_QUALITY), TBM_GETPOS , NULL, NULL);//	nSamplingFreqIndex = SendMessage(GetDlgItem( HwndDlg, IDC_COMBO_SAMPLEFREQ), CB_GETCURSEL, NULL, NULL);	bCRC          = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHECKSUM)     == BST_CHECKED);	bCopyright    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_COPYRIGHT)    == BST_CHECKED);	bOriginal     = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ORIGINAL)     == BST_CHECKED);	bPrivate      = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_PRIVATE)      == BST_CHECKED);	bSmartOutput  = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_SMART)    == BST_CHECKED);	bAbrOutput    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_ENC_ABR)      == BST_CHECKED);//	bNoBitRes     =!(::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESERVOIR)    == BST_CHECKED);//	bXingFrame    = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_XINGVBR)      == BST_CHECKED);//	bResample     = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_RESAMPLE)     == BST_CHECKED);//	bForceChannel = (::IsDlgButtonChecked( HwndDlg, IDC_CHECK_CHANNELFORCE) == BST_CHECKED);	AverageBitrate_Min  = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MIN), TBM_GETPOS , NULL, NULL);	AverageBitrate_Max  = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_MAX), TBM_GETPOS , NULL, NULL);	AverageBitrate_Step = SendMessage(GetDlgItem( HwndDlg, IDC_SLIDER_AVERAGE_STEP), TBM_GETPOS , NULL, NULL);	EnableAbrOptions(HwndDlg, bAbrOutput);my_debug.OutPut("nChannelIndex %d, bCRC %d, bCopyright %d, bOriginal %d, bPrivate %d",nChannelIndex, bCRC, bCopyright, bOriginal, bPrivate);/*	char tmpPath[MAX_PATH];	::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_OUTPUTDIR), tmpPath, MAX_PATH);	OutputDir = tmpPath;	if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_CBR) == BST_CHECKED)		mBRmode = BR_CBR;	else if (::IsDlgButtonChecked(HwndDlg, IDC_RADIO_BITRATE_VBR) == BST_CHECKED)		mBRmode = BR_VBR;	else		mBRmode = BR_ABR;		::GetWindowText( ::GetDlgItem( HwndDlg, IDC_EDIT_AVERAGE), tmpPath, MAX_PATH);	AverageBitrate = atoi(tmpPath);	if (AverageBitrate < 8)		AverageBitrate = 8;	if (AverageBitrate > 320)		AverageBitrate = 320;*/	return true;}/*VBRMETHOD AEncodeProperties::GetVBRValue(DWORD & MaxBitrate, int & Quality, DWORD & AbrBitrate, BOOL & VBRHeader, const DWORD MPEG_Version) const{	assert((MPEG_Version == MPEG1) || (MPEG_Version == MPEG2));	assert(nMaxBitrateIndex < sizeof(the_Bitrates));	if (mBRmode == BR_VBR)	{		MaxBitrate = the_Bitrates[nMaxBitrateIndex];		if (MPEG_Version == MPEG1)			MaxBitrate = MaxBitrate>the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1]?MaxBitrate:the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1];		else			MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];		VBRHeader = bXingFrame;		Quality = VbrQuality;		AbrBitrate = 0;		return VBR_METHOD_DEFAULT; // for the moment	} 	else if (mBRmode == BR_ABR)	{		MaxBitrate = the_Bitrates[nMaxBitrateIndex];		if (MPEG_Version == MPEG1)			MaxBitrate = MaxBitrate>the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1]?MaxBitrate:the_MPEG1_Bitrates[sizeof(the_MPEG1_Bitrates)/sizeof(unsigned int)-1];		else			MaxBitrate = MaxBitrate<the_MPEG2_Bitrates[0]?MaxBitrate:the_MPEG2_Bitrates[0];		VBRHeader = bXingFrame;		Quality = 0;		AbrBitrate = AverageBitrate*1000;		return VBR_METHOD_ABR;	}	else	{		return VBR_METHOD_NONE;	}}*/void AEncodeProperties::ParamsRestore(){	// use these default parameters in case one is not found	bCopyright    = true;	bCRC          = true;	bOriginal     = true;	bPrivate      = true;	bNoBitRes     = false; // enable bit reservoir	bXingFrame    = true;	bResample     = false;	bForceChannel = false;	bSmartOutput  = true;	bAbrOutput    = true;		AverageBitrate_Min = 80; // a bit lame	AverageBitrate_Max = 160; // a bit lame	AverageBitrate_Step = 8; // a bit lame	SmartRatioMax = 15.0;	nChannelIndex = 2; // joint-stereo	mBRmode       = BR_CBR;	nMinBitrateIndex = 6; // 128 kbps (works for both MPEGI and II)	nMaxBitrateIndex = 4; // 160 kbps (works for both MPEGI and II)	nPresetIndex = 0; // None	VbrQuality = 1; // Quite High//	AverageBitrate = 128; // a bit lame	nSamplingFreqIndex = 1; // 44100//	OutputDir = "c:\\";//	DllLocation = "plugins\\lame_enc.dll";	// get the values from the saved file if possible	if (my_stored_data.LoadFile(my_store_location))	{		TiXmlNode* node;		node = my_stored_data.FirstChild("lame_acm");		TiXmlElement* CurrentNode = node->FirstChildElement("encodings");		std::string CurrentConfig = "";		if (CurrentNode->Attribute("default") != NULL)		{			CurrentConfig = *CurrentNode->Attribute("default");		}/*		// output parameters		TiXmlElement* iterateElmt = node->FirstChildElement("DLL");		if (iterateElmt != NULL)		{			const std::string * tmpname = iterateElmt->Attribute("location");			if (tmpname != NULL)			{				DllLocation = *tmpname;			}		}*/		GetValuesFromKey(CurrentConfig, *CurrentNode);	}	else	{		/**			\todo save the data in the file !		*/	}}void AEncodeProperties::ParamsSave(){/*	save the current parameters in the corresponding subkey		HKEY OssKey;	if (RegCreateKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\MUKOLI\\out_lame", 0, "", REG_OPTION_NON_VOLATILE, KEY_WRITE , NULL, &OssKey, NULL ) == ERROR_SUCCESS) {		if (RegSetValueEx(OssKey, "DLL Location", 0, REG_EXPAND_SZ, (CONST BYTE *)DllLocation, strlen(DllLocation)+1 ) != ERROR_SUCCESS)			return;				RegCloseKey(OssKey); 	}*/}/*void AEncodeProperties::DisplayVbrOptions(const HWND hDialog, const BRMode the_mode){	bool bVBR = false;	bool bABR = false;	switch ( the_mode )	{		case BR_CBR:			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_CBR);			break;		case BR_VBR:			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_VBR);			bVBR = true;			break;		case BR_ABR:			::CheckRadioButton(hDialog, IDC_RADIO_BITRATE_CBR, IDC_RADIO_BITRATE_ABR, IDC_RADIO_BITRATE_ABR);			bABR = true;			break;	}	if(bVBR|bABR)	{		::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Min Bitrate");	}	else	{		::SetWindowText(::GetDlgItem(hDialog,IDC_STATIC_MINBITRATE), "Bitrate");	}	::EnableWindow(::GetDlgItem( hDialog, IDC_CHECK_XINGVBR), bVBR|bABR);	::EnableWindow(::GetDlgItem( hDialog, IDC_COMBO_MAXBITRATE), bVBR|bABR);	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_MAXBITRATE), bVBR|bABR);	::EnableWindow(::GetDlgItem( hDialog, IDC_SLIDER_QUALITY), bVBR);	::EnableWindow(::GetDlgItem( hDialog, IDC_CONFIG_QUALITY), bVBR);	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY), bVBR);	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_LOW), bVBR);	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_VBRQUALITY_HIGH), bVBR);	::EnableWindow(::GetDlgItem( hDialog, IDC_STATIC_ABR), bABR);	::EnableWindow(::GetDlgItem( hDialog, IDC_EDIT_AVERAGE), bABR);}*/AEncodeProperties::AEncodeProperties(HMODULE hModule) :my_debug(ADbg(DEBUG_LEVEL_CREATION)), my_hModule(hModule){	std::string path = "";//	HMODULE htmp = LoadLibrary("out_lame.dll");	if (hModule != NULL)	{		char output[MAX_PATH];		::GetModuleFileName(hModule, output, MAX_PATH);//		::FreeLibrary(htmp);		path = output;	}	my_store_location = path.substr(0,path.find_last_of('\\')+1);	my_store_location += "lame_acm.xml";	my_debug.OutPut("store path = %s",my_store_location.c_str());//#ifdef OLD//	::OutputDebugString(my_store_location.c_str());	// make sure the XML file is present	HANDLE hFile = ::CreateFile(my_store_location.c_str(), 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL );	::CloseHandle(hFile);//#endif // OLD	my_debug.OutPut("AEncodeProperties creation completed (0x%08X)",this);}// Save the values to the right XML saved configvoid AEncodeProperties::SaveValuesToStringKey(const std::string & config_name){	// get the current data in the file to keep them	if (my_stored_data.LoadFile(my_store_location))	{		// check if the Node corresponding to the config_name already exist.		TiXmlNode* node = my_stored_data.FirstChild("lame_acm");		if (node != NULL)		{			TiXmlElement* ConfigNode = node->FirstChildElement("encodings");			if (ConfigNode != NULL)			{				// look all the <config> tags				TiXmlElement* tmpNode = ConfigNode->FirstChildElement("config");				while (tmpNode != NULL)				{					const std::string * tmpname = tmpNode->Attribute("name");					if (tmpname->compare(config_name) == 0)					{						break;					}					tmpNode = tmpNode->NextSiblingElement("config");				}				if (tmpNode == NULL)				{					// Create the node					tmpNode = new TiXmlElement("config");					tmpNode->SetAttribute("name",config_name);					// save data in the node					SaveValuesToElement(tmpNode);					ConfigNode->InsertEndChild(*tmpNode);				}				else				{					// save data in the node					SaveValuesToElement(tmpNode);				}				// and save the file				my_stored_data.SaveFile(my_store_location);			}		}	}}void AEncodeProperties::GetValuesFromKey(const std::string & config_name, const TiXmlNode & parentNode){	TiXmlElement* tmpElt;	TiXmlElement* iterateElmt;	// find the config that correspond to CurrentConfig	iterateElmt = parentNode.FirstChildElement("config");	while (iterateElmt != NULL)	{		const std::string * tmpname = iterateElmt->Attribute("name");		if ((tmpname != NULL) && (tmpname->compare(config_name) == 0))		{			break;		}		iterateElmt = iterateElmt->NextSiblingElement("config");	}	if (iterateElmt != NULL)	{		// get all the parameters saved in this Element		const std::string * tmpname;		// Smart output parameter		tmpElt = iterateElmt->FirstChildElement("Smart");		if (tmpElt != NULL)		{			tmpname = tmpElt->Attribute("use");			if (tmpname != NULL)				bSmartOutput = (tmpname->compare("true") == 0);						tmpname = tmpElt->Attribute("ratio");			if (tmpname != NULL)				SmartRatioMax = atof(tmpname->c_str());		}		// Smart output parameter		tmpElt = iterateElmt->FirstChildElement("ABR");		if (tmpElt != NULL)		{			tmpname = tmpElt->Attribute("use");			if (tmpname != NULL)				bAbrOutput = (tmpname->compare("true") == 0);						tmpname = tmpElt->Attribute("min");			if (tmpname != NULL)				AverageBitrate_Min = atoi(tmpname->c_str());			tmpname = tmpElt->Attribute("max");			if (tmpname != NULL)				AverageBitrate_Max = atoi(tmpname->c_str());			tmpname = tmpElt->Attribute("step");			if (tmpname != NULL)				AverageBitrate_Step = atoi(tmpname->c_str());		}

⌨️ 快捷键说明

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