config_dlg.cpp 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /****************************************************************************
  2. *
  3. * Module Title : vfw_config_dlg.c
  4. *
  5. * Description : Configuration Parameters dialog module.
  6. *
  7. ****************************************************************************/
  8. /****************************************************************************
  9. * Header Files
  10. ****************************************************************************/
  11. #include <windows.h>
  12. #include <stdio.h>
  13. #include <commctrl.h>
  14. #include "type_aliases.h"
  15. #include "vp60_comp_interface.h"
  16. #include "resource.h" // Must be the version resident in the VCAP dll directory!!!
  17. #include "vpvfwver.h"
  18. #include "vp6vfw.h"
  19. #include "vp60_comp_interface.h"
  20. #include <commdlg.h>
  21. //#include <cderr.h>
  22. extern HINSTANCE hInstance;
  23. void BuildVersionInfo(char *modname,char *VersionInfo,int *vers)
  24. {
  25. // ************************************************************
  26. // The next bit of code reads version information from resource
  27. VersionInfo[0]=0;
  28. char szFullPath[256];
  29. DWORD dwVerHnd;
  30. DWORD dwVerInfoSize;
  31. GetModuleFileName(/*GetModuleHandle(modname)*/hInstance, szFullPath, sizeof(szFullPath));
  32. dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
  33. if (dwVerInfoSize)
  34. {
  35. // If we were able to get the information, process it:
  36. HANDLE hMem;
  37. LPVOID lpvMem;
  38. hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
  39. lpvMem = GlobalLock(hMem);
  40. GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
  41. UINT cchVer = 0;
  42. LPSTR lszVer = NULL;
  43. strcat(VersionInfo, "\r");
  44. VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\FileDescription"), (void **) &lszVer, &cchVer);
  45. strcat(VersionInfo,lszVer);
  46. strcat(VersionInfo, "\r\r");
  47. VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\LegalCopyright"), (void **) &lszVer, &cchVer);
  48. strcat(VersionInfo,lszVer);
  49. strcat(VersionInfo, "\r");
  50. strcat(VersionInfo, " Version ");
  51. VerQueryValue(lpvMem,TEXT("\\StringFileInfo\\040904E4\\ProductVersion"), (void **) &lszVer, &cchVer);
  52. strcat(VersionInfo,lszVer);
  53. GlobalUnlock(hMem);
  54. GlobalFree(hMem);
  55. }
  56. }
  57. BOOL FAR PASCAL Advanced_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
  58. BOOL FAR PASCAL General_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
  59. BOOL FAR PASCAL Settings_ParamsDlgProc( HWND hWndDlg,UINT Message,WPARAM wParam,LPARAM lParam );
  60. BOOL FAR PASCAL Main_ParamsDlgProc( HWND hWndDlg,
  61. UINT Message,
  62. WPARAM wParam,
  63. LPARAM lParam)
  64. {
  65. COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
  66. switch(Message)
  67. {
  68. case WM_NOTIFY:
  69. {
  70. switch(wParam)
  71. {
  72. case IDC_TAB1:
  73. {
  74. NMHDR *msg = (NMHDR *) lParam;
  75. switch(msg->code)
  76. {
  77. case TCN_SELCHANGE:
  78. {
  79. HWND hwndTab = GetDlgItem(hWndDlg, IDC_TAB1);
  80. int whichTab = TabCtrl_GetCurSel(hwndTab);
  81. switch(whichTab)
  82. {
  83. case 2:
  84. {
  85. if(compConfig->PlaceHolder)
  86. DestroyWindow((HWND) compConfig->PlaceHolder);
  87. compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"SETTINGS",hWndDlg,Settings_ParamsDlgProc ,(LPARAM) compConfig);
  88. ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
  89. return TRUE;
  90. }
  91. case 0:
  92. {
  93. if(compConfig->PlaceHolder)
  94. DestroyWindow((HWND) compConfig->PlaceHolder);
  95. compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"GENERAL",hWndDlg,General_ParamsDlgProc ,(LPARAM) compConfig);
  96. ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
  97. return TRUE;
  98. }
  99. case 1:
  100. {
  101. if(compConfig->PlaceHolder)
  102. DestroyWindow((HWND) compConfig->PlaceHolder);
  103. compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"ADVANCED",hWndDlg,Advanced_ParamsDlgProc ,(LPARAM) compConfig);
  104. ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
  105. return TRUE;
  106. }
  107. }
  108. break;
  109. }
  110. }
  111. break;
  112. }
  113. }
  114. return (FALSE);
  115. }
  116. case WM_CTLCOLORSTATIC:
  117. {
  118. HDC hdc = (HDC) wParam;
  119. HWND hwndStatic = (HWND) lParam;
  120. if ( hwndStatic == GetDlgItem ( hWndDlg, IDC_TITLE ) ||
  121. hwndStatic == GetDlgItem ( hWndDlg, IDC_FRAME ) )
  122. {
  123. return (LRESULT) GetStockObject(WHITE_BRUSH); ;
  124. }
  125. }
  126. break;
  127. case WM_INITDIALOG:
  128. {
  129. HWND hwndTab = GetDlgItem(hWndDlg, IDC_TAB1);
  130. TC_ITEM tie;
  131. SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
  132. compConfig = (COMP_CONFIG_VP6 *) lParam;
  133. tie.mask = TCIF_TEXT | TCIF_STATE | TCIF_IMAGE;
  134. tie.iImage = -1;
  135. tie.pszText = "General";
  136. if (TabCtrl_InsertItem(hwndTab, 0, &tie) == -1)
  137. return NULL;
  138. tie.pszText = "Advanced";
  139. if (TabCtrl_InsertItem(hwndTab, 1, &tie) == -1)
  140. return NULL;
  141. tie.pszText = "Settings";
  142. if (TabCtrl_InsertItem(hwndTab, 2, &tie) == -1)
  143. return NULL;
  144. char VersionString[2048]={0};
  145. int vers;
  146. BuildVersionInfo("VP6VFW.DLL",VersionString,&vers);
  147. SetDlgItemText( hWndDlg, IDC_TITLE, VersionString);
  148. compConfig->PlaceHolder = (INT32) CreateDialogParam(hInstance,"GENERAL",hWndDlg,General_ParamsDlgProc ,(LPARAM) compConfig);
  149. ShowWindow((HWND) compConfig->PlaceHolder,SW_SHOW);
  150. return (TRUE);
  151. }
  152. case WM_CLOSE: /* Close the dialog. */
  153. /* Closing the Dialog behaves the same as Cancel */
  154. PostMessage(hWndDlg, WM_COMMAND, IDCANCEL, 0L);
  155. return (TRUE);
  156. case WM_COMMAND: /* A control has been activated. */
  157. switch(LOWORD(wParam))
  158. {
  159. /* OK leaves the current settings in force */
  160. case IDOK:
  161. EndDialog(hWndDlg, IDOK);
  162. break;
  163. case IDCANCEL:
  164. EndDialog(hWndDlg, IDCANCEL);
  165. break;
  166. default:
  167. return (FALSE);
  168. }
  169. return (FALSE);
  170. default:
  171. return (FALSE);
  172. } /* End of Main Dialog case statement. */
  173. return FALSE;
  174. } /* End of WndProc */
  175. BOOL FAR PASCAL General_ParamsDlgProc( HWND hWndDlg,
  176. UINT Message,
  177. WPARAM wParam,
  178. LPARAM lParam)
  179. {
  180. COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
  181. switch(Message)
  182. {
  183. case WM_SETFOCUS:
  184. Message+=0;
  185. break;
  186. case WM_INITDIALOG:
  187. {
  188. SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
  189. compConfig = (COMP_CONFIG_VP6 *) lParam;
  190. // fill mode box
  191. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Realtime / Live Encoding");
  192. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Good Quality Fast Encoding");
  193. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "One Pass - Best Quality");
  194. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - First Pass" );
  195. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - Second Pass - Good Quality");
  196. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_ADDSTRING, 0, (LPARAM) (LPCSTR) "Two Pass - Second Pass - Best Quality");
  197. // set mode
  198. SendDlgItemMessage(hWndDlg, IDD_MODE, CB_SETCURSEL, (LPARAM) compConfig->Mode,0);
  199. // set end usage
  200. switch(compConfig->EndUsage)
  201. {
  202. case 0:
  203. CheckDlgButton( hWndDlg, IDC_ENDUSAGE1, 1);
  204. CheckDlgButton( hWndDlg, IDC_ENDUSAGE2, 0);
  205. break;
  206. default:
  207. CheckDlgButton( hWndDlg, IDC_ENDUSAGE2, 1);
  208. CheckDlgButton( hWndDlg, IDC_ENDUSAGE1, 0);
  209. break;
  210. }
  211. // set material
  212. switch(compConfig->Interlaced)
  213. {
  214. case 1:
  215. CheckDlgButton( hWndDlg, IDC_MATERIAL1, 1);
  216. CheckDlgButton( hWndDlg, IDC_MATERIAL2, 0);
  217. break;
  218. default:
  219. CheckDlgButton( hWndDlg, IDC_MATERIAL2, 1);
  220. CheckDlgButton( hWndDlg, IDC_MATERIAL1, 0);
  221. break;
  222. }
  223. // setup noise reduction slider
  224. SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
  225. // set noise reduction
  226. SetDlgItemInt( hWndDlg, IDC_NOISEREDUCTION, compConfig->NoiseSensitivity, FALSE );
  227. SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETPOS, (WPARAM) TRUE,(LPARAM) compConfig->NoiseSensitivity);
  228. SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETTICFREQ, (WPARAM) 1,(LPARAM) 1);
  229. // set auto keyframe
  230. CheckDlgButton( hWndDlg, IDC_AUTOKEYFRAME_CHECK, (compConfig->AutoKeyFrameEnabled) ? 1 : 0 );
  231. // set max frames btw keys
  232. SetDlgItemInt( hWndDlg, IDC_MAXFRAMESBTWKEYS, compConfig->ForceKeyFrameEvery, FALSE );
  233. return (TRUE);
  234. }
  235. case WM_HSCROLL:
  236. {
  237. // change edit box to match slider
  238. SetDlgItemInt( hWndDlg, IDC_NOISEREDUCTION, SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_GETPOS, 0,0), FALSE );
  239. return (TRUE);
  240. }
  241. case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
  242. // save everything to our structure
  243. compConfig->AutoKeyFrameEnabled = SendDlgItemMessage(hWndDlg, IDC_AUTOKEYFRAME_CHECK, BM_GETCHECK, 0, 0);
  244. compConfig->EndUsage = (END_USAGE) SendDlgItemMessage(hWndDlg, IDC_ENDUSAGE2, BM_GETCHECK, 0, 0);
  245. compConfig->Interlaced = SendDlgItemMessage(hWndDlg, IDC_MATERIAL1, BM_GETCHECK, 0, 0);
  246. compConfig->ForceKeyFrameEvery = GetDlgItemInt(hWndDlg, IDC_MAXFRAMESBTWKEYS, NULL, FALSE );
  247. compConfig->Mode = (MODE) SendDlgItemMessage(hWndDlg, IDD_MODE, CB_GETCURSEL, 0, 0);
  248. compConfig->NoiseSensitivity = GetDlgItemInt(hWndDlg, IDC_NOISEREDUCTION, NULL, FALSE );
  249. return (TRUE);
  250. case WM_COMMAND: /* A control has been activated. */
  251. {
  252. switch(HIWORD(wParam))
  253. {
  254. case EN_KILLFOCUS:
  255. {
  256. // error checking
  257. int value = GetDlgItemInt(hWndDlg, LOWORD(wParam), NULL, FALSE );
  258. switch(LOWORD(wParam))
  259. {
  260. case IDC_NOISEREDUCTION:
  261. {
  262. if(value < 0) value = 0;
  263. if(value > 6) value = 6;
  264. SendDlgItemMessage(hWndDlg, IDC_NOISEREDUCTION_SLIDER, TBM_SETPOS, (WPARAM) TRUE, value );
  265. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  266. break;
  267. }
  268. break;
  269. case IDC_MAXFRAMESBTWKEYS:
  270. {
  271. if(value < 0) value = 0;
  272. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  273. break;
  274. }
  275. default:
  276. return (FALSE);
  277. }
  278. }
  279. }
  280. return (FALSE);
  281. }
  282. default:
  283. return (FALSE);
  284. } /* End of Main Dialog case statement. */
  285. return FALSE;
  286. } /* End of WndProc */
  287. BOOL FAR PASCAL Advanced_ParamsDlgProc( HWND hWndDlg,
  288. UINT Message,
  289. WPARAM wParam,
  290. LPARAM lParam)
  291. {
  292. COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
  293. switch(Message)
  294. {
  295. case WM_INITDIALOG:
  296. {
  297. SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
  298. compConfig = (COMP_CONFIG_VP6 *) lParam;
  299. if ( compConfig->EndUsage == 1)
  300. {
  301. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBITRATE), 0);
  302. EnableWindow(GetDlgItem(hWndDlg, STREAMING_PARAMETERS), 0);
  303. EnableWindow(GetDlgItem(hWndDlg, PEAK_BITRATE), 0);
  304. EnableWindow(GetDlgItem(hWndDlg, PREBUFFER), 0);
  305. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_PREBUFFER), 0);
  306. EnableWindow(GetDlgItem(hWndDlg, OPTIMAL_BUFFER), 0);
  307. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_OPTIMAL), 0);
  308. EnableWindow(GetDlgItem(hWndDlg, MAX_BUFFER), 0);
  309. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBUFFER), 0);
  310. }
  311. if(compConfig->Mode < 4)
  312. {
  313. EnableWindow(GetDlgItem(hWndDlg, TWO_PASS_SECTION_DATARATE), 0);
  314. EnableWindow(GetDlgItem(hWndDlg, VARIABILITY), 0);
  315. EnableWindow(GetDlgItem(hWndDlg, IDC_DATARATEVARIABILITY), 0);
  316. EnableWindow(GetDlgItem(hWndDlg, MIN_SECTION), 0);
  317. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MINBANDWIDTH), 0);
  318. EnableWindow(GetDlgItem(hWndDlg, MAX_SECTION), 0);
  319. EnableWindow(GetDlgItem(hWndDlg, IDC_EDIT_MAXBANDWIDTH), 0);
  320. }
  321. // set buffer stats
  322. SetDlgItemInt( hWndDlg, IDC_EDIT_PREBUFFER, compConfig->StartingBufferLevel, FALSE );
  323. SetDlgItemInt( hWndDlg, IDC_EDIT_OPTIMAL, compConfig->OptimalBufferLevel, FALSE );
  324. SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBUFFER, compConfig->MaximumBufferSize, FALSE );
  325. // setup vbr slider
  326. SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 100));
  327. SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETTICFREQ, (WPARAM) 10,(LPARAM) 10);
  328. // set vbr settings
  329. SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETPOS, (WPARAM) TRUE,(LPARAM) compConfig->TwoPassVBRBias);
  330. SetDlgItemInt( hWndDlg, IDC_DATARATEVARIABILITY, compConfig->TwoPassVBRBias, FALSE );
  331. SetDlgItemInt( hWndDlg, IDC_EDIT_MINBANDWIDTH, compConfig->TwoPassVBRMinSection, FALSE );
  332. SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBANDWIDTH, compConfig->TwoPassVBRMaxSection, FALSE );
  333. SetDlgItemInt( hWndDlg, IDC_EDIT_MAXBITRATE, compConfig->MaxAllowedDatarate, FALSE );
  334. // datarate control options
  335. SetDlgItemInt( hWndDlg, IDC_EDIT_UNDERSHOOT, compConfig->UnderShootPct, FALSE );
  336. // set adjust quantizer control
  337. CheckDlgButton( hWndDlg, IDC_ADJUSTQ_CHECK, (compConfig->FixedQ) ? 0 : 1 );
  338. SetDlgItemInt( hWndDlg, IDC_EDIT_MINQUALITY, compConfig->BestAllowedQ, FALSE );
  339. SetDlgItemInt( hWndDlg, IDC_EDIT_MAXQUALITY, compConfig->Quality, FALSE );
  340. // allowing dropped frames
  341. CheckDlgButton( hWndDlg, IDC_ALLOW_DROPPED_FRAMES_CHECK, (compConfig->AllowDF) ? 1 : 0 );
  342. SetDlgItemInt( hWndDlg, IDC_EDIT_TEMPORAL_DOWN, compConfig->DropFramesWaterMark, FALSE );
  343. // allowing spatial resampling
  344. CheckDlgButton( hWndDlg, IDC_SCALE_CHECK, (compConfig->AllowSpatialResampling) ? 1 : 0 );
  345. SetDlgItemInt( hWndDlg, IDC_EDIT_SPATIAL_DOWN, compConfig->ResampleDownWaterMark, FALSE );
  346. SetDlgItemInt( hWndDlg, IDC_EDIT_SPATIAL_UP, compConfig->ResampleUpWaterMark, FALSE );
  347. return (TRUE);
  348. }
  349. case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
  350. // save everything to our structure
  351. compConfig->StartingBufferLevel = GetDlgItemInt(hWndDlg, IDC_EDIT_PREBUFFER, NULL, FALSE );
  352. compConfig->OptimalBufferLevel = GetDlgItemInt(hWndDlg, IDC_EDIT_OPTIMAL, NULL, FALSE );
  353. compConfig->MaximumBufferSize = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBUFFER, NULL, FALSE );
  354. compConfig->TwoPassVBRBias = GetDlgItemInt(hWndDlg, IDC_DATARATEVARIABILITY, NULL, FALSE );
  355. compConfig->TwoPassVBRMinSection = GetDlgItemInt(hWndDlg, IDC_EDIT_MINBANDWIDTH, NULL, FALSE );
  356. compConfig->TwoPassVBRMaxSection = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBANDWIDTH, NULL, FALSE );
  357. compConfig->MaxAllowedDatarate = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXBITRATE, NULL, FALSE );
  358. compConfig->UnderShootPct = GetDlgItemInt(hWndDlg, IDC_EDIT_UNDERSHOOT, NULL, FALSE );
  359. compConfig->FixedQ = !SendDlgItemMessage(hWndDlg, IDC_ADJUSTQ_CHECK, BM_GETCHECK, 0, 0);
  360. compConfig->BestAllowedQ = GetDlgItemInt(hWndDlg, IDC_EDIT_MINQUALITY, NULL, FALSE );
  361. compConfig->Quality = GetDlgItemInt(hWndDlg, IDC_EDIT_MAXQUALITY, NULL, FALSE );
  362. compConfig->AllowDF = SendDlgItemMessage(hWndDlg, IDC_ALLOW_DROPPED_FRAMES_CHECK, BM_GETCHECK, 0, 0);
  363. compConfig->DropFramesWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_TEMPORAL_DOWN, NULL, FALSE );
  364. compConfig->AllowSpatialResampling = SendDlgItemMessage(hWndDlg, IDC_SCALE_CHECK, BM_GETCHECK, 0, 0);
  365. compConfig->ResampleDownWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_SPATIAL_DOWN, NULL, FALSE );
  366. compConfig->ResampleUpWaterMark = GetDlgItemInt(hWndDlg, IDC_EDIT_SPATIAL_UP, NULL, FALSE );
  367. return (TRUE);
  368. case WM_HSCROLL:
  369. {
  370. // change edit box to match slider
  371. SetDlgItemInt( hWndDlg, IDC_DATARATEVARIABILITY, SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_GETPOS, 0,0), FALSE );
  372. return (TRUE);
  373. }
  374. case WM_COMMAND: /* A control has been activated. */
  375. {
  376. switch(HIWORD(wParam))
  377. {
  378. case EN_KILLFOCUS:
  379. {
  380. // error checking
  381. int value = GetDlgItemInt(hWndDlg, LOWORD(wParam), NULL, FALSE );
  382. switch(LOWORD(wParam))
  383. {
  384. case IDC_DATARATEVARIABILITY:
  385. {
  386. if(value < 0) value = 0;
  387. if(value > 100 ) value = 100;
  388. SendDlgItemMessage(hWndDlg, IDC_DATARATEVARIABILITY_SLIDER, TBM_SETPOS, (WPARAM) TRUE, value );
  389. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  390. break;
  391. }
  392. // save everything to our structure
  393. case IDC_EDIT_PREBUFFER:
  394. {
  395. if(value < 0) value = 0;
  396. if(value > 30 ) value = 30;
  397. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  398. break;
  399. }
  400. case IDC_EDIT_OPTIMAL:
  401. {
  402. if(value < 0) value = 0;
  403. if(value > 30 ) value = 30;
  404. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  405. break;
  406. }
  407. case IDC_EDIT_MAXBUFFER:
  408. {
  409. if(value < 0) value = 0;
  410. if(value > 30 ) value = 30;
  411. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  412. break;
  413. }
  414. case IDC_EDIT_MINBANDWIDTH:
  415. {
  416. if(value < 0) value = 0;
  417. if(value > 100 ) value = 100;
  418. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  419. break;
  420. }
  421. case IDC_EDIT_MAXBANDWIDTH:
  422. {
  423. if(value < 100) value = 100;
  424. if(value > 1000 ) value = 1000;
  425. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  426. break;
  427. }
  428. case IDC_EDIT_UNDERSHOOT:
  429. {
  430. if(value < 50) value = 50;
  431. if(value > 100 ) value = 100;
  432. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  433. break;
  434. }
  435. case IDC_EDIT_MINQUALITY:
  436. {
  437. if(value < 0) value = 0;
  438. if(value > 63 ) value = 63;
  439. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  440. break;
  441. }
  442. case IDC_EDIT_MAXQUALITY:
  443. {
  444. if(value < 0) value = 0;
  445. if(value > 63 ) value = 63;
  446. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  447. break;
  448. }
  449. case IDC_EDIT_TEMPORAL_DOWN :
  450. {
  451. if(value < 0) value = 0;
  452. if(value > 100 ) value = 100;
  453. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  454. break;
  455. }
  456. case IDC_EDIT_SPATIAL_DOWN :
  457. {
  458. if(value < 0) value = 0;
  459. if(value > 100 ) value = 100;
  460. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  461. break;
  462. }
  463. case IDC_EDIT_SPATIAL_UP :
  464. {
  465. if(value < 0) value = 0;
  466. if(value > 100 ) value = 100;
  467. SetDlgItemInt( hWndDlg, LOWORD(wParam), value, FALSE );
  468. break;
  469. }
  470. }
  471. }
  472. default:
  473. return (FALSE);
  474. }
  475. return (FALSE);
  476. }
  477. default:
  478. return (FALSE);
  479. } /* End of Main Dialog case statement. */
  480. return FALSE;
  481. } /* End of WndProc */
  482. BOOL FAR PASCAL Settings_ParamsDlgProc( HWND hWndDlg,
  483. UINT Message,
  484. WPARAM wParam,
  485. LPARAM lParam)
  486. {
  487. COMP_CONFIG_VP6 *compConfig = (COMP_CONFIG_VP6 *)GetWindowLong(hWndDlg,GWL_USERDATA);
  488. switch(Message)
  489. {
  490. case WM_INITDIALOG:
  491. {
  492. SetWindowLong(hWndDlg, GWL_USERDATA, (unsigned long)lParam);
  493. compConfig = (COMP_CONFIG_VP6 *) lParam;
  494. if(!memcmp(compConfig->SettingsFile,compConfig->RootDirectory,strlen(compConfig->RootDirectory)))
  495. {
  496. strcpy(compConfig->SettingsFile,compConfig->SettingsFile+strlen(compConfig->RootDirectory));
  497. }
  498. if(!memcmp(compConfig->SettingsFile+strlen(compConfig->SettingsFile)-4,".vps",4))
  499. {
  500. compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4]=0;
  501. }
  502. SetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile);
  503. SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
  504. WIN32_FIND_DATA wfd;
  505. char FileFilter[512];
  506. strncpy(FileFilter,compConfig->RootDirectory,512);
  507. strcat(FileFilter,"\\*.vps");
  508. HANDLE ffh = FindFirstFile(FileFilter,&wfd);
  509. if( ffh !=INVALID_HANDLE_VALUE)
  510. {
  511. do
  512. {
  513. wfd.cFileName[strlen(wfd.cFileName)-4]=0;
  514. SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_ADDSTRING, 0, (LPARAM) (LPCSTR) wfd.cFileName);
  515. }
  516. while ( FindNextFile(ffh,&wfd));
  517. FindClose(ffh);
  518. }
  519. return (TRUE);
  520. }
  521. case WM_DESTROY: //case WM_CLOSE: /* Close the dialog. */
  522. // save everything to our structure
  523. GetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile,512);
  524. GetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile,512);
  525. if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
  526. {
  527. char tmp[512];
  528. strncpy(tmp,compConfig->SettingsFile,512);
  529. strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
  530. strcat(compConfig->SettingsFile,tmp);
  531. }
  532. if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
  533. {
  534. strcat(compConfig->SettingsFile,".vps");
  535. }
  536. return (TRUE);
  537. case WM_COMMAND: /* A control has been activated. */
  538. {
  539. switch(HIWORD(wParam))
  540. {
  541. case LBN_SELCHANGE :
  542. {
  543. int curSel =SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETCURSEL, 0, 0);
  544. SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETTEXT, curSel, (DWORD) compConfig->SettingsFile);
  545. SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
  546. if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
  547. {
  548. char tmp[512];
  549. strncpy(tmp,compConfig->SettingsFile,512);
  550. strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
  551. strcat(compConfig->SettingsFile,"\\");
  552. strcat(compConfig->SettingsFile,tmp);
  553. }
  554. if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
  555. {
  556. strcat(compConfig->SettingsFile,".vps");
  557. }
  558. FILE *f = fopen(compConfig->SettingsFile,"rb");
  559. if(f)
  560. {
  561. char tmp[512];
  562. HWND still = (HWND) compConfig->PlaceHolder;
  563. strncpy(tmp,compConfig->RootDirectory,512);
  564. fread(compConfig,sizeof COMP_CONFIG_VP6,1,f);
  565. strncpy(compConfig->RootDirectory,tmp,512);
  566. fclose(f);
  567. compConfig->PlaceHolder = (INT32) still;
  568. }
  569. }
  570. case BN_CLICKED:
  571. switch(LOWORD(wParam))
  572. {
  573. case ID_SAVE:
  574. {
  575. FILE *f;
  576. GetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile,512);
  577. GetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile,512);
  578. if(compConfig->SettingsFile[1] != ':' && compConfig->SettingsFile[1] != '\\')
  579. {
  580. char tmp[512];
  581. strncpy(tmp,compConfig->SettingsFile,512);
  582. strncpy(compConfig->SettingsFile,compConfig->RootDirectory,512);
  583. strcat(compConfig->SettingsFile,"\\");
  584. strcat(compConfig->SettingsFile,tmp);
  585. }
  586. if(compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4] != '.' )
  587. {
  588. strcat(compConfig->SettingsFile,".vps");
  589. }
  590. f=fopen(compConfig->SettingsFile,"wb");
  591. if(f)
  592. {
  593. fwrite(compConfig,10+sizeof COMP_CONFIG_VP6,1,f);
  594. fclose(f);
  595. }
  596. int curSel = SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_FINDSTRING, 0, (LPARAM) (LPCSTR) compConfig->SettingsFile );
  597. if( curSel == LB_ERR)
  598. {
  599. WIN32_FIND_DATA wfd;
  600. int curSel = SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_RESETCONTENT, 0, 0 );
  601. char FileFilter[512];
  602. strncpy(FileFilter,compConfig->RootDirectory,512);
  603. strcat(FileFilter,"\\*.vps");
  604. HANDLE ffh = FindFirstFile(FileFilter,&wfd);
  605. if( ffh !=INVALID_HANDLE_VALUE)
  606. {
  607. do
  608. {
  609. wfd.cFileName[strlen(wfd.cFileName)-4]=0;
  610. SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_ADDSTRING, 0, (LPARAM) (LPCSTR) wfd.cFileName);
  611. }
  612. while ( FindNextFile(ffh,&wfd));
  613. FindClose(ffh);
  614. }
  615. }
  616. return TRUE;
  617. };
  618. case ID_DELETE:
  619. {
  620. int curSel =SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_GETCURSEL, 0, 0);
  621. SendDlgItemMessage(hWndDlg, IDC_SETTINGS_LIST, LB_DELETESTRING, curSel, 0);
  622. DeleteFile(compConfig->SettingsFile);
  623. return TRUE;
  624. };
  625. case IDC_LOAD_FIRSTPASS:
  626. {
  627. static TCHAR szFilterLoad[] = TEXT("VP First Pass \0*.vpf\0\0");
  628. OPENFILENAME ofn;
  629. TCHAR szTitle[64];
  630. TCHAR szT[256];
  631. ofn.lStructSize= sizeof(ofn);
  632. ofn.hInstance= 0;
  633. ofn.lpstrFilter= szFilterLoad;
  634. ofn.lpstrCustomFilter= NULL;
  635. ofn.nMaxCustFilter= 0;
  636. ofn.nFilterIndex= 0;
  637. ofn.lpstrFileTitle= szTitle;
  638. ofn.nMaxFileTitle= sizeof(szTitle);
  639. ofn.lpstrInitialDir= compConfig->RootDirectory;
  640. ofn.lpstrTitle= NULL;
  641. ofn.nFileOffset= 0;
  642. ofn.nFileExtension= 0;
  643. ofn.lpstrDefExt= "vps";
  644. ofn.lCustData= 0L;
  645. ofn.lpfnHook= NULL;
  646. ofn.lpTemplateName= NULL;
  647. ofn.hwndOwner= hWndDlg;
  648. ofn.lpstrFile= szT;
  649. ofn.nMaxFile= sizeof(szT);
  650. ofn.Flags= 0;
  651. szTitle[0] = TEXT('\0');
  652. szT[0] = TEXT('\0');
  653. if(GetOpenFileName(&ofn))
  654. {
  655. strncpy(compConfig->FirstPassFile,ofn.lpstrFile,512);
  656. SetDlgItemText(hWndDlg,IDC_FIRSTPASS,compConfig->FirstPassFile);
  657. }
  658. return TRUE;
  659. }
  660. case IDC_LOAD_SETTINGS:
  661. {
  662. static TCHAR szFilterLoad[] = TEXT("VP Setting Files\0*.vps\0\0");
  663. OPENFILENAME ofn;
  664. TCHAR szTitle[64];
  665. TCHAR szT[256];
  666. ofn.lStructSize= sizeof(ofn);
  667. ofn.hInstance= 0;
  668. ofn.lpstrFilter= szFilterLoad;
  669. ofn.lpstrCustomFilter= NULL;
  670. ofn.nMaxCustFilter= 0;
  671. ofn.nFilterIndex= 0;
  672. ofn.lpstrFileTitle= szTitle;
  673. ofn.nMaxFileTitle= sizeof(szTitle);
  674. ofn.lpstrInitialDir= compConfig->RootDirectory;
  675. ofn.lpstrTitle= NULL;
  676. ofn.nFileOffset= 0;
  677. ofn.nFileExtension= 0;
  678. ofn.lpstrDefExt= "vps";
  679. ofn.lCustData= 0L;
  680. ofn.lpfnHook= NULL;
  681. ofn.lpTemplateName= NULL;
  682. ofn.hwndOwner= hWndDlg;
  683. ofn.lpstrFile= szT;
  684. ofn.nMaxFile= sizeof(szT);
  685. ofn.Flags= 0;
  686. szTitle[0] = TEXT('\0');
  687. szT[0] = TEXT('\0');
  688. if(GetOpenFileName(&ofn))
  689. {
  690. strncpy(compConfig->SettingsFile,ofn.lpstrFile,512);
  691. FILE *f = fopen(compConfig->SettingsFile,"rb");
  692. if(f)
  693. {
  694. HWND still = (HWND) compConfig->PlaceHolder;
  695. fread(compConfig,sizeof COMP_CONFIG_VP6,1,f);
  696. fclose(f);
  697. compConfig->PlaceHolder = (INT32) still;
  698. }
  699. if(!memcmp(compConfig->SettingsFile,compConfig->RootDirectory,strlen(compConfig->RootDirectory)))
  700. {
  701. strcpy(compConfig->SettingsFile,compConfig->SettingsFile+strlen(compConfig->RootDirectory));
  702. }
  703. if(!memcmp(compConfig->SettingsFile+strlen(compConfig->SettingsFile)-4,".vps",4))
  704. {
  705. compConfig->SettingsFile[strlen(compConfig->SettingsFile)-4]=0;
  706. }
  707. SetDlgItemText(hWndDlg,IDC_SETTINGSFILE,compConfig->SettingsFile);
  708. }
  709. return TRUE;
  710. }
  711. }
  712. break;
  713. default:
  714. break;
  715. }
  716. }
  717. default:
  718. return (FALSE);
  719. } /* End of Main Dialog case statement. */
  720. return FALSE;
  721. } /* End of WndProc */