📄 config.c
字号:
SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, LOWORD(wParam), 100)); } else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_PARX || LOWORD(wParam)==IDC_PARY)) { if (5 == SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_GETCURSEL, 0, 0)) { if(LOWORD(wParam)==IDC_PARX) psi->config->par_x = config_get_uint(hDlg, LOWORD(wParam), psi->config->par_x); else psi->config->par_y = config_get_uint(hDlg, LOWORD(wParam), psi->config->par_y); } } else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_BITRATE_SSIZE || LOWORD(wParam)==IDC_BITRATE_HOURS || LOWORD(wParam)==IDC_BITRATE_MINUTES || LOWORD(wParam)==IDC_BITRATE_SECONDS || LOWORD(wParam)==IDC_BITRATE_ASIZE)) { adv_mode(hDlg, psi->idd, psi->config); } else return 0; break; case WM_HSCROLL : if((HWND)lParam == GetDlgItem(hDlg, IDC_ZONE_SLIDER)) { int idc = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT) ? IDC_ZONE_WEIGHT : IDC_ZONE_QUANT; set_dlgitem_float(hDlg, idc, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0) ); break; } return 0; case WM_NOTIFY : switch (((NMHDR *)lParam)->code) { case PSN_SETACTIVE : DPRINTF("PSN_SET"); adv_upload(hDlg, psi->idd, psi->config); adv_mode(hDlg, psi->idd, psi->config); SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); break; case PSN_KILLACTIVE : DPRINTF("PSN_KILL"); adv_download(hDlg, psi->idd, psi->config); SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); break; case PSN_APPLY : DPRINTF("PSN_APPLY"); psi->config->save = TRUE; SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); break; } break; default : return 0; } return 1;}/* load advanced options property sheet returns true, if the user accepted the changes or fasle if changes were canceled. */#ifndef PSH_NOCONTEXTHELP#define PSH_NOCONTEXTHELP 0x02000000#endifstatic BOOL adv_dialog(HWND hParent, CONFIG * config, const int * dlgs, int size){ PROPSHEETINFO psi[6]; PROPSHEETPAGE psp[6]; PROPSHEETHEADER psh; CONFIG temp; int i; config->save = FALSE; memcpy(&temp, config, sizeof(CONFIG)); for (i=0; i<size; i++) { psp[i].dwSize = sizeof(PROPSHEETPAGE); psp[i].dwFlags = 0; psp[i].hInstance = g_hInst; psp[i].pfnDlgProc = adv_proc; psp[i].lParam = (LPARAM)&psi[i]; psp[i].pfnCallback = NULL; psp[i].pszTemplate = MAKEINTRESOURCE(dlgs[i]); psi[i].idd = dlgs[i]; psi[i].config = &temp; } psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_NOCONTEXTHELP; psh.hwndParent = hParent; psh.hInstance = g_hInst; psh.pszCaption = (LPSTR) "XviD Configuration"; psh.nPages = size; psh.nStartPage = 0; psh.ppsp = (LPCPROPSHEETPAGE)&psp; psh.pfnCallback = NULL; PropertySheet(&psh); if (temp.save) memcpy(config, &temp, sizeof(CONFIG)); return temp.save;}/* ===================================================================================== *//* MAIN DIALOG ========================================================================= *//* ===================================================================================== */static void main_insert_zone(HWND hDlg, zone_t * s, int i, BOOL insert){ char tmp[32]; wsprintf(tmp,"%i",s->frame); if (insert) { LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE; lvi.state = 0; lvi.stateMask = 0; lvi.iImage = 0; lvi.pszText = tmp; lvi.cchTextMax = strlen(tmp); lvi.iItem = i; lvi.iSubItem = 0; ListView_InsertItem(hDlg, &lvi); }else{ ListView_SetItemText(hDlg, i, 0, tmp); } if (s->mode == RC_ZONE_WEIGHT) { sprintf(tmp,"W %.2f",(float)s->weight/100); }else if (s->mode == RC_ZONE_QUANT) { sprintf(tmp,"Q %.2f",(float)s->quant/100); }else { strcpy(tmp,"EXT"); } ListView_SetItemText(hDlg, i, 1, tmp); tmp[0] = '\0'; if (s->type==XVID_TYPE_IVOP) strcat(tmp, "K "); if (s->greyscale) strcat(tmp, "G "); if (s->chroma_opt) strcat(tmp, "C "); ListView_SetItemText(hDlg, i, 2, tmp);}static void main_mode(HWND hDlg, CONFIG * config){ const int profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0); const int rc_mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); /* enable target rate/size control only for 1pass and 2pass modes*/ const int target_en = rc_mode==RC_MODE_1PASS || rc_mode==RC_MODE_2PASS2; const int target_en_slider = rc_mode==RC_MODE_1PASS || (rc_mode==RC_MODE_2PASS2 && config->use_2pass_bitrate); char buf[16]; int max; g_use_bitrate = config->use_2pass_bitrate; if (g_use_bitrate) { SetDlgItemText(hDlg, IDC_BITRATE_S, "Target bitrate (kbps):"); wsprintf(buf, "%i kbps", DEFAULT_MIN_KBPS); SetDlgItemText(hDlg, IDC_BITRATE_MIN, buf); max = profiles[profile].max_bitrate; if (max == 0) max = DEFAULT_MAX_KBPS; wsprintf(buf, "%i kbps", max); SetDlgItemText(hDlg, IDC_BITRATE_MAX, buf); SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(DEFAULT_MIN_KBPS, max)); SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) ); } else if (rc_mode==RC_MODE_2PASS2) { SetDlgItemText(hDlg, IDC_BITRATE_S, "Target size (kbytes):"); } else if (rc_mode==RC_MODE_1PASS) { SetDlgItemText(hDlg, IDC_BITRATE_S, "Target quantizer:"); SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(100, 3100)); SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_BITRATE, DEFAULT_QUANT )); SetDlgItemText(hDlg, IDC_BITRATE_MIN, "1 (maximum quality)"); SetDlgItemText(hDlg, IDC_BITRATE_MAX, "(smallest file) 31"); } EnableDlgWindow(hDlg, IDC_BITRATE_S, target_en); EnableDlgWindow(hDlg, IDC_BITRATE, target_en); EnableDlgWindow(hDlg, IDC_BITRATE_ADV, target_en); EnableDlgWindow(hDlg, IDC_BITRATE_MIN, target_en_slider); EnableDlgWindow(hDlg, IDC_BITRATE_MAX, target_en_slider); EnableDlgWindow(hDlg, IDC_SLIDER, target_en_slider);}static void main_upload(HWND hDlg, CONFIG * config){ SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0); SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0); g_use_bitrate = config->use_2pass_bitrate; if (g_use_bitrate) { SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE); } else if (config->mode == RC_MODE_2PASS2) { SetDlgItemInt(hDlg, IDC_BITRATE, config->desired_size, FALSE); } else if (config->mode == RC_MODE_1PASS) { set_dlgitem_float(hDlg, IDC_BITRATE, config->desired_quant); } zones_update(hDlg, config);}/* downloads data from main dialog */static void main_download(HWND hDlg, CONFIG * config){ config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0); config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0); if (g_use_bitrate) { config->bitrate = config_get_uint(hDlg, IDC_BITRATE, config->bitrate); } else if (config->mode == RC_MODE_2PASS2) { config->desired_size = config_get_uint(hDlg, IDC_BITRATE, config->desired_size); } else if (config->mode == RC_MODE_1PASS) { config->desired_quant = get_dlgitem_float(hDlg, IDC_BITRATE, config->desired_quant); }}/* main dialog proc */static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL, IDD_AR };static const int single_dlgs[] = { IDD_RC_CBR };static const int pass1_dlgs[] = { IDD_RC_2PASS1 };static const int pass2_dlgs[] = { IDD_RC_2PASS2 };static const int bitrate_dlgs[] = { IDD_BITRATE };static const int zone_dlgs[] = { IDD_ZONE };static const int decoder_dlgs[] = { IDD_DEC };static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG};BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){ CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA); unsigned int i; switch (uMsg) { case WM_INITDIALOG : SetWindowLong(hDlg, GWL_USERDATA, lParam); config = (CONFIG*)lParam; for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) SendDlgItemMessage(hDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name); SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Single pass"); SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 1st pass"); SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 2nd pass");#ifdef _DEBUG SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null test speed");#endif InitCommonControls(); if ((g_hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, g_hInst, NULL))) { SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0)); SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400); EnumChildWindows(hDlg, enum_tooltips, 0); } SetClassLong(GetDlgItem(hDlg, IDC_BITRATE_S), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); { DWORD ext_style = ListView_GetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES)); ext_style |= LVS_EX_FULLROWSELECT | LVS_EX_FLATSB ; ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES), ext_style); } { typedef struct { char * name; int value; } char_int_t; const static char_int_t columns[] = { {"Frame #", 64}, {"Weight/Quant", 82}, {"Modifiers", 120}}; LVCOLUMN lvc; int i; /* Initialize the LVCOLUMN structure. */ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.fmt = LVCFMT_LEFT; /* Add the columns. */ for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) { lvc.pszText = (char*)columns[i].name; lvc.cchTextMax = strlen(columns[i].name); lvc.iSubItem = i; lvc.cx = columns[i].value; /* column width, pixels */ ListView_InsertColumn(GetDlgItem(hDlg,IDC_ZONES), i, &lvc); } } /* XXX: main_mode needs RC_MODE_xxx, main_upload needs g_use_bitrate set correctly... */ main_upload(hDlg, config); main_mode(hDlg, config); main_upload(hDlg, config); break; case WM_NOTIFY : { NMHDR * n = (NMHDR*)lParam; if (n->code == NM_DBLCLK) { NMLISTVIEW * nmlv = (NMLISTVIEW*) lParam; config->cur_zone = nmlv->iItem; main_download(hDlg, config); if (config->cur_zone >= 0 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) { zones_update(hDlg, config); } break; } break; } case WM_COMMAND : if (HIWORD(wParam) == BN_CLICKED) { switch(LOWORD(wParam)) { case IDC_PROFILE_ADV : main_download(hDlg, config); adv_dialog(hDlg, config, profile_dlgs, sizeof(profile_dlgs)/sizeof(int)); SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0); main_mode(hDlg, config); break; case IDC_MODE_ADV : main_download(hDlg, config); if (config->mode == RC_MODE_1PASS) { adv_dialog(hDlg, config, single_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -