📄 config.c
字号:
/************************************************************************** * * 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_dy, pp_duv, pp_dr, pp_fe; /* 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 ============================================================== *//* ===================================================================================== *//* default vbv_occupancy is (64/170)*vbv_buffer_size */const profile_t profiles[] ={/* name p@l, w h fps obj Tvmv vmv vcv ac% vbv pkt kbps flags */ { "Simple @ L0", 0x08, 176, 144, 15, 1, 198, 99, 1485, 100, 10*16368, 2048, 64, 0 }, /* 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, 64, PROFILE_ADAPTQUANT }, { "Simple @ L2", 0x02, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 4096, 128, PROFILE_ADAPTQUANT }, { "Simple @ L3", 0x03, 352, 288, 15, 4, 792, 396, 11880, 100, 40*16368, 8192, 384, PROFILE_ADAPTQUANT }, { "ARTS @ L1", 0x91, 176, 144, 15, 4, 198, 99, 1485, 100, 10*16368, 8192, 64, PROFILE_ARTS }, { "ARTS @ L2", 0x92, 352, 288, 15, 4, 792, 396, 5940, 100, 40*16368, 16384, 128, PROFILE_ARTS }, { "ARTS @ L3", 0x93, 352, 288, 30, 4, 792, 396, 11880, 100, 40*16368, 16384, 384, PROFILE_ARTS }, { "ARTS @ L4", 0x94, 352, 288, 30, 16, 792, 396, 11880, 100, 80*16368, 16384, 2000, PROFILE_ARTS }, { "AS @ L0", 0xf0, 176, 144, 30, 1, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS }, { "AS @ L1", 0xf1, 176, 144, 30, 4, 297, 99, 2970, 100, 10*16368, 2048, 128, PROFILE_AS }, { "AS @ L2", 0xf2, 352, 288, 15, 4, 1188, 396, 5940, 100, 40*16368, 4096, 384, PROFILE_AS }, { "AS @ L3", 0xf3, 352, 288, 30, 4, 1188, 396, 11880, 100, 40*16368, 4096, 768, PROFILE_AS }, /* ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */ { "AS @ L4", 0xf4, 352, 576, 30, 4, 2376, 792, 23760, 50, 80*16368, 8192, 3000, PROFILE_AS }, { "AS @ L5", 0xf5, 720, 576, 30, 4, 4860, 1620, 48600, 25, 112*16368, 16384, 8000, PROFILE_AS },#ifdef DXN_PROFILES { "DXN Handheld", 0x00, 176, 144, 15, -1, 198, 99, 1485, 100, 16*16368, -1, 128, PROFILE_ADAPTQUANT }, { "DXN Portable NTSC", 0x00, 352, 240, 30, -1, 990, 330, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP }, { "DXN Portable PAL", 0x00, 352, 288, 25, -1, 1188, 396, 9900, 100, 64*16368, -1, 768, PROFILE_ADAPTQUANT|PROFILE_BVOP }, { "DXN HT NTSC", 0x00, 720, 480, 30, -1, 4050, 1350, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE }, { "DXN HT PAL", 0x00, 720, 576, 25, -1, 4860, 1620, 40500, 100, 192*16368, -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE }, { "DXN HDTV", 0x00, 1280, 720, 30, -1,10800, 3600, 108000, 100, 384*16368, -1, 8000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },#endif { "(unrestricted)", 0x00, 0, 0, 0, 0, 0, 0, 0, 100, 0*16368, 0, 0, 0xffffffff },};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 5static 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 }, { "(None)", 0, 0 },}; /* ===================================================================================== *//* REGISTRY ============================================================================ *//* ===================================================================================== *//* registry info structs */CONFIG reg;static const REG_INT reg_ints[] = { {"mode", ®.mode, RC_MODE_1PASS}, {"bitrate", ®.bitrate, 700}, {"desired_size", ®.desired_size, 570000}, {"use_2pass_bitrate", ®.use_2pass_bitrate, 0}, {"desired_quant", ®.desired_quant, DEFAULT_QUANT}, /* 100-base float */ /* profile */ {"quant_type", ®.quant_type, 0}, {"lum_masking", ®.lum_masking, 0}, {"interlacing", ®.interlacing, 0}, {"qpel", ®.qpel, 0}, {"gmc", ®.gmc, 0}, {"reduced_resolution", ®.reduced_resolution, 0}, {"use_bvop", ®.use_bvop, 1}, {"max_bframes", ®.max_bframes, 2}, {"bquant_ratio", ®.bquant_ratio, 150}, /* 100-base float */ {"bquant_offset", ®.bquant_offset, 100}, /* 100-base float */ {"packed", ®.packed, 1}, {"closed_gov", ®.closed_gov, 1}, /* aspect ratio */ {"ar_mode", ®.ar_mode, 0}, {"aspect_ratio", ®.display_aspect_ratio, 0}, {"par_x", ®.par_x, 1}, {"par_y", ®.par_y, 1}, {"ar_x", ®.ar_x, 4}, {"ar_y", ®.ar_y, 3}, /* zones */ {"num_zones", ®.num_zones, 1}, /* single pass */ {"rc_reaction_delay_factor",®.rc_reaction_delay_factor, 16}, {"rc_averaging_period", ®.rc_averaging_period, 100}, {"rc_buffer", ®.rc_buffer, 100}, /* 2pass1 */ {"discard1pass", ®.discard1pass, 1}, {"full1pass", ®.full1pass, 0}, /* 2pass2 */ {"keyframe_boost", ®.keyframe_boost, 10}, {"kfreduction", ®.kfreduction, 20}, {"kfthreshold", ®.kfthreshold, 1}, {"curve_compression_high", ®.curve_compression_high, 0}, {"curve_compression_low", ®.curve_compression_low, 0}, {"overflow_control_strength", ®.overflow_control_strength, 5}, {"twopass_max_overflow_improvement", ®.twopass_max_overflow_improvement, 5}, {"twopass_max_overflow_degradation", ®.twopass_max_overflow_degradation, 5}, /* bitrate calculator */ {"container_type", ®.container_type, 1}, {"target_size", ®.target_size, 650 * 1024}, {"subtitle_size", ®.subtitle_size, 0}, {"hours", ®.hours, 1}, {"minutes", ®.minutes, 30}, {"seconds", ®.seconds, 0}, {"fps", ®.fps, 2}, {"audio_mode", ®.audio_mode, 0}, {"audio_type", ®.audio_type, 0}, {"audio_rate", ®.audio_rate, 128}, {"audio_size", ®.audio_size, 0}, /* motion */ {"motion_search", ®.motion_search, 6}, {"vhq_mode", ®.vhq_mode, 1}, {"chromame", ®.chromame, 1}, {"cartoon_mode", ®.cartoon_mode, 0}, {"turbo", ®.turbo, 0}, {"max_key_interval", ®.max_key_interval, 300}, {"frame_drop_ratio", ®.frame_drop_ratio, 0}, /* quant */ {"min_iquant", ®.min_iquant, 1}, {"max_iquant", ®.max_iquant, 31}, {"min_pquant", ®.min_pquant, 1}, {"max_pquant", ®.max_pquant, 31}, {"min_bquant", ®.min_bquant, 1}, {"max_bquant", ®.max_bquant, 31}, {"trellis_quant", ®.trellis_quant, 0}, /* debug */ {"fourcc_used", ®.fourcc_used, 0}, {"debug", ®.debug, 0x0}, {"vop_debug", ®.vop_debug, 0}, {"display_status", ®.display_status, 1}, /* decoder, shared with dshow */ {"Deblock_Y", &pp_dy, 0}, {"Deblock_UV", &pp_duv, 0}, {"Dering", &pp_dr, 0}, {"FilmEffect", &pp_fe, 0}, };static const REG_STR reg_strs[] = { {"profile", reg.profile_name, "AS @ L5"}, {"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},};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)));}#define XVID_DLL_NAME "xvidcore.dll"void config_reg_get(CONFIG * config){ char tmp[32]; HKEY hKey; DWORD size; int i,j; xvid_gbl_info_t info; HINSTANCE m_hdll; memset(&info, 0, sizeof(info)); info.version = XVID_VERSION; m_hdll = LoadLibrary(XVID_DLL_NAME); if (m_hdll != NULL) { ((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global")) (0, XVID_GBL_INFO, &info, NULL); FreeLibrary(m_hdll); } reg.cpu = info.cpu_flags; reg.num_threads = info.num_threads; RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey); /* read integer values */ for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) { size = sizeof(int); if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS) { *reg_ints[i].config_int = reg_ints[i].def; } } /* read string values */ for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) { size = MAX_PATH; if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS) { memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH); } } reg.profile = 0; for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) { if (lstrcmpi(profiles[i].name, reg.profile_name) == 0) { reg.profile = i; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -