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

📄 config.c

📁 这是一个压缩解压包,用C语言进行编程的,里面有详细的源代码.
💻 C
📖 第 1 页 / 共 5 页
字号:
/************************************************************************** * *	XVID VFW FRONTEND *	config * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2 of the License, or *	(at your option) any later version. * *	This program 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 General Public License for more details. * *	You should have received a copy of the GNU General Public License *	along with this program; if not, write to the Free Software *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *************************************************************************//************************************************************************** * *	History: * *	15.06.2002	added bframes options *	21.04.2002	fixed custom matrix support, tried to get dll size down *	17.04.2002	re-enabled lumi masking in 1st pass *	15.04.2002	updated cbr support *	07.04.2002	min keyframe interval checkbox *				2-pass max bitrate and overflow customization *	04.04.2002	interlacing support *				hinted ME support *	24.03.2002	daniel smith <danielsmith@astroboymail.com> *				added Foxer's new CBR engine *				- cbr_buffer is being used as reaction delay (quick hack) *	23.03.2002	daniel smith <danielsmith@astroboymail.com> *				added load defaults button *				merged foxer's alternative 2-pass code (2-pass alt tab) *				added proper tooltips *				moved registry data into reg_ints/reg_strs arrays *				added DEBUGERR output on errors instead of returning *	16.03.2002	daniel smith <danielsmith@astroboymail.com> *				rewrote/restructured most of file *				added tooltips (kind of - dirty message hook method) *				split tabs into a main dialog / advanced prop sheet *				advanced controls are now enabled/disabled by mode *				added modulated quantization, DX50 fourcc *	11.03.2002  Min Chen <chenm001@163.com> *			  now get Core Version use xvid_init() *	05.03.2002  Min Chen <chenm001@163.com> *				Add Core version display to about box *	01.12.2001	inital version; (c)2001 peter ross <pross@xvid.org> * *************************************************************************/#include <windows.h>#include <commctrl.h>#include <stdio.h>  /* sprintf */#include <xvid.h>	/* XviD API */#include "debug.h"#include "config.h"#include "resource.h"#define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z;#define IsDlgChecked(hwnd,idc)	(IsDlgButtonChecked(hwnd,idc) == BST_CHECKED)#define CheckDlg(hwnd,idc,value) CheckDlgButton(hwnd,idc, value?BST_CHECKED:BST_UNCHECKED)#define EnableDlgWindow(hwnd,idc,state) EnableWindow(GetDlgItem(hwnd,idc),state)static void zones_update(HWND hDlg, CONFIG * config);HINSTANCE g_hInst;HWND g_hTooltip;static int g_use_bitrate = 1;int pp_brightness, pp_dy, pp_duv, pp_fe, pp_dry, pp_druv; /* decoder options *//* enumerates child windows, assigns tooltips */BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam){	char help[500];	if (LoadString(g_hInst, GetDlgCtrlID(hWnd), help, 500))	{		TOOLINFO ti;		ti.cbSize = sizeof(TOOLINFO);		ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;		ti.hwnd = GetParent(hWnd);		ti.uId	= (LPARAM)hWnd;		ti.lpszText = help;		SendMessage(g_hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);	}	return TRUE;}/* ===================================================================================== *//* MPEG-4 PROFILES/LEVELS ============================================================== *//* ===================================================================================== *//* #define EXTRA_PROFILES *//* default vbv_occupancy is (64/170)*vbv_buffer_size */#define PROFILE_S       (PROFILE_4MV)#define PROFILE_ARTS		(PROFILE_4MV|PROFILE_ADAPTQUANT)#define PROFILE_AS			(PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_MPEGQUANT|PROFILE_INTERLACE|PROFILE_QPEL|PROFILE_GMC)const profile_t profiles[] ={/*  name                p@l    w    h    fps  obj Tvmv vmv    vcv    ac%   vbv        pkt     bps    vbv_peak dbf flags */  { "Simple @ L0",      0x08,  176, 144, 15,  1,  198,   99,   1485, 100,  10*16368,  2048,   64000,        0, -1, PROFILE_S },  /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */  /* if ac preidition is used, adaptive quantization must not be used */  /* <=qcif must be used */  { "Simple @ L1",      0x01,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  2048,   64000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },  { "Simple @ L2",      0x02,  352, 288, 15,  4,  792,  396,   5940, 100,  40*16368,  4096,  128000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },  { "Simple @ L3",      0x03,  352, 288, 15,  4,  792,  396,  11880, 100,  40*16368,  8192,  384000,        0, -1, PROFILE_S|PROFILE_ADAPTQUANT },#if 0 /* since rrv encoding is no longer support, these profiles have little use */  { "ARTS @ L1",        0x91,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  8192,   64000,        0, -1, PROFILE_ARTS },  { "ARTS @ L2",        0x92,  352, 288, 15,  4,  792,  396,   5940, 100,  40*16368, 16384,  128000,        0, -1, PROFILE_ARTS },  { "ARTS @ L3",        0x93,  352, 288, 30,  4,  792,  396,  11880, 100,  40*16368, 16384,  384000,        0, -1, PROFILE_ARTS },  { "ARTS @ L4",        0x94,  352, 288, 30, 16,  792,  396,  11880, 100,  80*16368, 16384, 2000000,        0, -1, PROFILE_ARTS },#endif  { "Advanced Simple @ L0",          0xf0,  176, 144, 30,  1,  297,   99,   2970, 100,  10*16368,  2048,  128000,        0, -1, PROFILE_AS },  { "Advanced Simple @ L1",          0xf1,  176, 144, 30,  4,  297,   99,   2970, 100,  10*16368,  2048,  128000,        0, -1, PROFILE_AS },  { "Advanced Simple @ L2",          0xf2,  352, 288, 15,  4, 1188,  396,   5940, 100,  40*16368,  4096,  384000,        0, -1, PROFILE_AS },  { "Advanced Simple @ L3",          0xf3,  352, 288, 30,  4, 1188,  396,  11880, 100,  40*16368,  4096,  768000,        0, -1, PROFILE_AS }, /*  ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */  { "Advanced Simple @ L4",          0xf4,  352, 576, 30,  4, 2376,  792,  23760,  50,  80*16368,  8192, 3000000,        0, -1, PROFILE_AS },  { "Advanced Simple @ L5",          0xf5,  720, 576, 30,  4, 4860, 1620,  48600,  25, 112*16368, 16384, 8000000,        0, -1, PROFILE_AS },#ifndef EXTRA_PROFILES  { "Mobile",            0x00,  352, 240, 30,  1,  990,  330,  36000, 100,  128*8192,    -1, 1334850,  8000000,  5, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_MPEGQUANT|PROFILE_QPEL },  { "Portable",          0x00,  640, 480, 30,  1, 3600, 1200,  36000, 100,  384*8192,    -1, 4854000,  8000000,  5, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_MPEGQUANT|PROFILE_QPEL|PROFILE_INTERLACE },  { "Home",              0x00,  720, 576, 25,  1, 4860, 1620,  40500, 100,  384*8192,    -1, 4854000,  8000000,  5, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_MPEGQUANT|PROFILE_QPEL|PROFILE_INTERLACE },  { "Highdef",           0x00, 1280, 720, 30,  1,10800, 3600, 108000, 100,  768*8192,    -1, 9708400, 16000000,  5, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_MPEGQUANT|PROFILE_QPEL|PROFILE_INTERLACE },#else  { "Handheld",			 0x00,  176, 144, 15,  1,  198,   99,   1485, 100,   32*8192,    -1,  537600,   800000,  0, PROFILE_ADAPTQUANT|PROFILE_EXTRA },  { "Portable NTSC",	 0x00,  352, 240, 30,  1,  990,  330,  36000, 100,  384*8192,    -1, 4854000,  8000000,  1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_EXTRA },  { "Portable PAL",		 0x00,  352, 288, 25,  1, 1188,  396,  36000, 100,  384*8192,    -1, 4854000,  8000000,  1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_EXTRA },  { "Home Theatre NTSC", 0x00,  720, 480, 30,  1, 4050, 1350,  40500, 100,  384*8192,    -1, 4854000,  8000000,  1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_INTERLACE|PROFILE_EXTRA },  { "Home Theatre PAL",  0x00,  720, 576, 25,  1, 4860, 1620,  40500, 100,  384*8192,    -1, 4854000,  8000000,  1, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_INTERLACE|PROFILE_EXTRA },  { "HDTV",				 0x00, 1280, 720, 30,  1,10800, 3600, 108000, 100,  768*8192,    -1, 9708400, 16000000,  2, PROFILE_4MV|PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_PACKED|PROFILE_INTERLACE|PROFILE_EXTRA },#endif  { "(unrestricted)",   0x00,    0,   0,  0,  0,    0,    0,      0, 100,   0*16368,    -1,       0,        0, -1, 0xffffffff & ~(PROFILE_EXTRA | PROFILE_PACKED)},};const quality_t quality_table[] = {    /* name                 |  m  vhq  bf cme  tbo  kfi  fdr  | iquant pquant bquant trellis */  { "Real-time",               1,  0,  0,  0,  0,  300,  0,     1, 31, 1, 31, 1, 31,   0   },  { QUALITY_GENERAL_STRING,    6,  1,  0,  1,  0,  300,  0,     1, 31, 1, 31, 1, 31,   1   },};const int quality_table_num = sizeof(quality_table)/sizeof(quality_t);typedef struct {	char * name;	float value;} named_float_t;static const named_float_t video_fps_list[] = {	{  "15.0",				15.0F	},	{  "23.976 (FILM)",		23.976F	},	{  "25.0 (PAL)",		25.0F	},	{  "29.97 (NTSC)",		29.970F	},	{  "30.0",				30.0F	},	{  "50.0 (HD PAL)",		50.0F	},	{  "59.94 (HD NTSC)",	59.940F	},	{  "60.0",				60.0F	},};typedef struct {	char * name;	int avi_interval;		/* audio overhead intervals (milliseconds) */	float mkv_multiplier;	/* mkv multiplier */} named_int_t;#define NO_AUDIO	7static const named_int_t audio_type_list[] = {	{	"MP3-CBR",		1000,	48000/1152/6					},	{	"MP3-VBR",		  24,	48000/1152/6					},	{	"OGG",	   /*?*/1000,	48000*(0.7F/1024 + 0.3F/180) 	},	{	"AC3",			  64,	48000/1536/6					},	{	"DTS",			  21,	/*?*/48000/1152/6				},	{	"AAC",			  21,	48000/1024/6					},	{	"HE-AAC",		  42,	48000/1024/6					},	{	"(None)",		   0,	0								},};		/* ===================================================================================== *//* REGISTRY ============================================================================ *//* ===================================================================================== *//* registry info structs */CONFIG reg;static const REG_INT reg_ints[] = {	{"mode",					&reg.mode,						RC_MODE_1PASS},	{"bitrate",					&reg.bitrate,					700},	{"desired_size",			&reg.desired_size,				570000},	{"use_2pass_bitrate",		&reg.use_2pass_bitrate,			0},	{"desired_quant",			&reg.desired_quant,				DEFAULT_QUANT}, /* 100-base float */	/* profile */	{"quant_type",				&reg.quant_type,				0},	{"lum_masking",				&reg.lum_masking,				0},	{"interlacing",				&reg.interlacing,				0},	{"tff",						&reg.tff,						0},	{"qpel",					&reg.qpel,						0},	{"gmc",						&reg.gmc,						0},	{"use_bvop",				&reg.use_bvop,					1},	{"max_bframes",				&reg.max_bframes,				2},	{"bquant_ratio",			&reg.bquant_ratio,				150},   /* 100-base float */	{"bquant_offset",			&reg.bquant_offset,				100},   /* 100-base float */	{"packed",					&reg.packed,					1},	/* aspect ratio */	{"ar_mode",					&reg.ar_mode,					0},	{"aspect_ratio",			&reg.display_aspect_ratio,		0},	{"par_x",					&reg.par_x,						1},	{"par_y",					&reg.par_y,						1},	{"ar_x",					&reg.ar_x,						4},	{"ar_y",					&reg.ar_y,						3},	/* zones */	{"num_zones",				&reg.num_zones,					1},	/* single pass */	{"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor,	16},	{"rc_averaging_period",		&reg.rc_averaging_period,		100},	{"rc_buffer",				&reg.rc_buffer,					100},	/* 2pass1 */	{"discard1pass",			&reg.discard1pass,				1},	{"full1pass",				&reg.full1pass,					0},	/* 2pass2 */	{"keyframe_boost",			&reg.keyframe_boost,			10},	{"kfreduction",				&reg.kfreduction,				20},	{"kfthreshold",				&reg.kfthreshold,				1},	{"curve_compression_high",	&reg.curve_compression_high,	0},	{"curve_compression_low",	&reg.curve_compression_low,		0},	{"overflow_control_strength", &reg.overflow_control_strength, 5},	{"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 5},	{"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 5},	/* bitrate calculator */	{"container_type",			&reg.container_type,			1},	{"target_size",				&reg.target_size,				650 * 1024},	{"subtitle_size",			&reg.subtitle_size,				0},	{"hours",        			&reg.hours,						1},	{"minutes",        			&reg.minutes,					30},	{"seconds",        			&reg.seconds,					0},	{"fps",	        			&reg.fps,						2},	{"audio_mode",				&reg.audio_mode,				0},	{"audio_type",				&reg.audio_type,				0},	{"audio_rate",				&reg.audio_rate,				128},	{"audio_size",				&reg.audio_size,				0},	/* motion */	{"motion_search",			&reg.quality_user.motion_search,				6},	{"vhq_mode",				&reg.quality_user.vhq_mode,					1},	{"vhq_bframe",				&reg.quality_user.vhq_bframe,				0},	{"chromame",				&reg.quality_user.chromame,					1},	{"turbo",					&reg.quality_user.turbo,						0},	{"max_key_interval",		&reg.quality_user.max_key_interval,			300},	{"frame_drop_ratio",		&reg.quality_user.frame_drop_ratio,			0},	/* quant */	{"min_iquant",				&reg.quality_user.min_iquant,				1},	{"max_iquant",				&reg.quality_user.max_iquant,				31},	{"min_pquant",				&reg.quality_user.min_pquant,				1},	{"max_pquant",				&reg.quality_user.max_pquant,				31},	{"min_bquant",				&reg.quality_user.min_bquant,				1},	{"max_bquant",				&reg.quality_user.max_bquant,				31},	{"trellis_quant",			&reg.quality_user.trellis_quant,				1},	/* debug */	{"fourcc_used",				&reg.fourcc_used,				0},	{"debug",					&reg.debug,						0x0},	{"vop_debug",				&reg.vop_debug,					0},	{"display_status",			&reg.display_status,			1},		/* decoder, shared with dshow */	{"Brightness",				&pp_brightness,					0},	{"Deblock_Y",				&pp_dy,							0},	{"Deblock_UV",				&pp_duv,						0},	{"Dering_Y",				&pp_dry,						0},	{"Dering_UV",				&pp_druv,						0},	{"FilmEffect",				&pp_fe,							0},	};static const REG_STR reg_strs[] = {	{"profile",					reg.profile_name,				"(unrestricted)"},  {"quality",         reg.quality_name,       QUALITY_GENERAL_STRING},	{"stats",					reg.stats,						CONFIG_2PASS_FILE},};zone_t stmp;static const REG_INT reg_zone[] = {	{"zone%i_frame",			&stmp.frame,					0},	{"zone%i_mode",				&stmp.mode,						RC_ZONE_WEIGHT},	{"zone%i_weight",			&stmp.weight,					100},	  /* 100-base float */	{"zone%i_quant",			&stmp.quant,					500},	  /* 100-base float */	{"zone%i_type",				&stmp.type,						XVID_TYPE_AUTO},	{"zone%i_greyscale",		&stmp.greyscale,				0},	{"zone%i_chroma_opt",		&stmp.chroma_opt,				0},	{"zone%i_bvop_threshold",   &stmp.bvop_threshold,			0},	{"zone%i_cartoon_mode",		&stmp.cartoon_mode,				0},};static const BYTE default_qmatrix_intra[] = {	8, 17,18,19,21,23,25,27,	17,18,19,21,23,25,27,28,	20,21,22,23,24,26,28,30,	21,22,23,24,26,28,30,32,	22,23,24,26,28,30,32,35,	23,24,26,28,30,32,35,38,	25,26,28,30,32,35,38,41,	27,28,30,32,35,38,41,45};static const BYTE default_qmatrix_inter[] = {	16,17,18,19,20,21,22,23,	17,18,19,20,21,22,23,24,	18,19,20,21,22,23,24,25,	19,20,21,22,23,24,26,27,	20,21,22,23,25,26,27,28,	21,22,23,24,26,27,28,30,	22,23,24,26,27,28,30,31,	23,24,25,27,28,30,31,33};#define REG_GET_B(X, Y, Z) size=sizeof((Z));if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {memcpy(Y, Z, sizeof((Z)));}

⌨️ 快捷键说明

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