[svn] / trunk / vfw / src / config.c Repository:
ViewVC logotype

Diff of /trunk/vfw/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30, Sat Mar 16 11:40:48 2002 UTC revision 361, Mon Aug 5 18:26:31 2002 UTC
# Line 23  Line 23 
23   *   *
24   *      History:   *      History:
25   *   *
26     *      15.06.2002      added bframes options
27     *      21.04.2002      fixed custom matrix support, tried to get dll size down
28     *      17.04.2002      re-enabled lumi masking in 1st pass
29     *      15.04.2002      updated cbr support
30     *      07.04.2002      min keyframe interval checkbox
31     *                              2-pass max bitrate and overflow customization
32     *      04.04.2002      interlacing support
33     *                              hinted ME support
34     *      24.03.2002      daniel smith <danielsmith@astroboymail.com>
35     *                              added Foxer's new CBR engine
36     *                              - cbr_buffer is being used as reaction delay (quick hack)
37     *      23.03.2002      daniel smith <danielsmith@astroboymail.com>
38     *                              added load defaults button
39     *                              merged foxer's alternative 2-pass code (2-pass alt tab)
40     *                              added proper tooltips
41     *                              moved registry data into reg_ints/reg_strs arrays
42     *                              added DEBUGERR output on errors instead of returning
43   *      16.03.2002      daniel smith <danielsmith@astroboymail.com>   *      16.03.2002      daniel smith <danielsmith@astroboymail.com>
44   *                              rewrote/restructured most of file   *                              rewrote/restructured most of file
45   *                              added tooltips (kind of - dirty message hook method)   *                              added tooltips (kind of - dirty message hook method)
# Line 42  Line 59 
59  #include <commctrl.h>  #include <commctrl.h>
60  #include <shlobj.h>  #include <shlobj.h>
61  #include <prsht.h>  #include <prsht.h>
62    #ifdef _SMP
63    #include <pthread.h>
64    #endif
65    
66  #include "codec.h"  #include "codec.h"
67  #include "config.h"  #include "config.h"
# Line 49  Line 69 
69  #include "resource.h"  #include "resource.h"
70    
71    
72    
73    /* registry info structs */
74    
75    CONFIG reg;
76    
77    REG_INT const reg_ints[] = {
78            {"mode",                                        &reg.mode,                                              DLG_MODE_CBR},
79            {"quality",                                     &reg.quality,                                   85},
80            {"quant",                                       &reg.quant,                                             5},
81            {"rc_bitrate",                          &reg.rc_bitrate,                                900000},
82            {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor,      16},
83            {"rc_averaging_period",         &reg.rc_averaging_period,               100},
84            {"rc_buffer",                           &reg.rc_buffer,                                 100},
85    
86            {"motion_search",                       &reg.motion_search,                             5},
87            {"quant_type",                          &reg.quant_type,                                0},
88            {"fourcc_used",                         &reg.fourcc_used,                               0},
89            {"max_key_interval",            &reg.max_key_interval,                  300},
90            {"min_key_interval",            &reg.min_key_interval,                  1},
91            {"lum_masking",                         &reg.lum_masking,                               0},
92            {"interlacing",                         &reg.interlacing,                               0},
93    //added by koepi for gruel's greyscale_mode
94            {"greyscale",                           &reg.greyscale,                                 0},
95    // end of koepi's additions
96    #ifdef BFRAMES
97            {"max_bframes",                         &reg.max_bframes,                               -1},
98            {"bquant_ratio",                        &reg.bquant_ratio,                              200},
99            {"packed",                                      &reg.packed,                                    0},
100            {"dx50bvop",                            &reg.dx50bvop,                                  0},
101            {"debug",                                       &reg.debug,                                             0},
102            {"frame_drop_ratio",            &reg.frame_drop_ratio,                  0},
103    #endif
104    
105            {"min_iquant",                          &reg.min_iquant,                                1},
106            {"max_iquant",                          &reg.max_iquant,                                31},
107            {"min_pquant",                          &reg.min_pquant,                                1},
108            {"max_pquant",                          &reg.max_pquant,                                31},
109    
110            {"desired_size",                        &reg.desired_size,                              570000},
111            {"keyframe_boost",                      &reg.keyframe_boost,                    20},
112            {"discard1pass",                        &reg.discard1pass,                              1},
113            {"dummy2pass",                          &reg.dummy2pass,                                0},
114    // added by koepi for new two-pass curve treatment
115            {"kftreshold",                          &reg.kftreshold,                                10},
116            {"kfreduction",                         &reg.kfreduction,                               30},
117    // end of koepi's additions
118            {"curve_compression_high",      &reg.curve_compression_high,    25},
119            {"curve_compression_low",       &reg.curve_compression_low,             10},
120            {"use_alt_curve",                       &reg.use_alt_curve,                             0},
121            {"alt_curve_use_auto",          &reg.alt_curve_use_auto,                1},
122            {"alt_curve_auto_str",          &reg.alt_curve_auto_str,                50},
123            {"alt_curve_use_auto_bonus_bias",       &reg.alt_curve_use_auto_bonus_bias,     1},
124            {"alt_curve_bonus_bias",        &reg.alt_curve_bonus_bias,              50},
125            {"alt_curve_type",                      &reg.alt_curve_type,                    1},
126            {"alt_curve_high_dist",         &reg.alt_curve_high_dist,               300},
127            {"alt_curve_low_dist",          &reg.alt_curve_low_dist,                300},
128            {"alt_curve_min_rel_qual",      &reg.alt_curve_min_rel_qual,    50},
129            {"bitrate_payback_delay",       &reg.bitrate_payback_delay,             240},
130            {"bitrate_payback_method",      &reg.bitrate_payback_method,    0},
131            {"twopass_max_bitrate",         &reg.twopass_max_bitrate,               10000 * CONFIG_KBPS},
132            {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},
133            {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},
134            {"hinted_me",                           &reg.hinted_me,                                 0},
135    
136            {"credits_start",                       &reg.credits_start,                             0},
137            {"credits_start_begin",         &reg.credits_start_begin,               0},
138            {"credits_start_end",           &reg.credits_start_end,                 0},
139            {"credits_end",                         &reg.credits_end,                               0},
140            {"credits_end_begin",           &reg.credits_end_begin,                 0},
141            {"credits_end_end",                     &reg.credits_end_end,                   0},
142    
143    // added by koepi for greyscale credits
144            {"credits_greyscale",           &reg.credits_greyscale,                 0},
145    // end of koepi's addition
146            {"credits_mode",                        &reg.credits_mode,                              0},
147            {"credits_rate",                        &reg.credits_rate,                              20},
148            {"credits_quant_i",                     &reg.credits_quant_i,                   20},
149            {"credits_quant_p",                     &reg.credits_quant_p,                   20},
150            {"credits_start_size",          &reg.credits_start_size,                10000},
151            {"credits_end_size",            &reg.credits_end_size,                  10000}
152    };
153    
154    REG_STR const reg_strs[] = {
155            {"hintfile",                            reg.hintfile,                                   CONFIG_HINTFILE},
156            {"stats1",                                      reg.stats1,                                             CONFIG_2PASS_1_FILE},
157            {"stats2",                                      reg.stats2,                                             CONFIG_2PASS_2_FILE}
158    //      {"build",                                       reg.build,                                              XVID_BUILD}
159    };
160    
161  /* get config settings from registry */  /* get config settings from registry */
162    
 #define REG_GET_N(X, Y, Z) size=sizeof(int);if(RegQueryValueEx(hKey, X, 0, 0, (LPBYTE)&Y, &size) != ERROR_SUCCESS) {Y=Z;}  
 #define REG_GET_S(X, Y, Z) size=MAX_PATH;if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {lstrcpy(Y, Z);}  
163  #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 REG_GET_B(X, Y, Z) size=sizeof((Z));if(RegQueryValueEx(hKey, X, 0, 0, Y, &size) != ERROR_SUCCESS) {memcpy(Y, Z, sizeof((Z)));}
164    
165  void config_reg_get(CONFIG * config)  void config_reg_get(CONFIG * config)
# Line 60  Line 167 
167          HKEY hKey;          HKEY hKey;
168          DWORD size;          DWORD size;
169          XVID_INIT_PARAM init_param;          XVID_INIT_PARAM init_param;
170            int i;
171    
172          init_param.cpu_flags = 0;          init_param.cpu_flags = XVID_CPU_CHKONLY;
173          xvid_init(0, 0, &init_param, NULL);          xvid_init(0, 0, &init_param, NULL);
174          config->cpu = init_param.cpu_flags;          reg.cpu = init_param.cpu_flags;
175    
176    #ifdef _SMP
177            reg.num_threads = pthread_num_processors_np();
178    #endif
179    
180          RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey);          RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT "\\" XVID_REG_CHILD, 0, KEY_READ, &hKey);
181    
182          REG_GET_N("mode",                                       config->mode,                                   DLG_MODE_CBR);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
183          REG_GET_N("bitrate",                            config->bitrate,                                900000);          {
184          REG_GET_N("quality",                            config->quality,                                85);                  size = sizeof(int);
185          REG_GET_N("quant",                                      config->quant,                                  5);  
186          REG_GET_N("rc_buffersize",                      config->rc_buffersize,                  2048000);                  if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS)
187                    {
188          REG_GET_N("motion_search",                      config->motion_search,                  5);                          *reg_ints[i].config_int = reg_ints[i].def;
189          REG_GET_N("quant_type",                         config->quant_type,                             0);                  }
190          REG_GET_N("fourcc_used",                        config->fourcc_used,                    0);          }
191          REG_GET_N("max_key_interval",           config->max_key_interval,               300);  
192          REG_GET_N("lum_masking",                        config->lum_masking,                    0);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
193            {
194          REG_GET_N("min_iquant",                         config->min_iquant,                             1);                  size = MAX_PATH;
195          REG_GET_N("max_iquant",                         config->max_iquant,                             31);  
196          REG_GET_N("min_pquant",                         config->min_pquant,                             1);                  if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS)
197          REG_GET_N("max_pquant",                         config->max_pquant,                             31);                  {
198                            memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
199          REG_GET_N("desired_size",                       config->desired_size,                   570000);                  }
200          REG_GET_N("keyframe_boost",                     config->keyframe_boost,                 20);          }
         REG_GET_N("min_key_interval",           config->min_key_interval,               6);  
         REG_GET_N("discard1pass",                       config->discard1pass,                   1);  
         REG_GET_N("dummy2pass",                         config->dummy2pass,                             0);  
         REG_GET_N("curve_compression_high", config->curve_compression_high,     25);  
         REG_GET_N("curve_compression_low",      config->curve_compression_low,  10);  
         REG_GET_N("bitrate_payback_delay",      config->bitrate_payback_delay,  240);  
         REG_GET_N("bitrate_payback_method",     config->bitrate_payback_method, 0);  
         REG_GET_S("stats1",                                     config->stats1,                                 CONFIG_2PASS_1_FILE);  
         REG_GET_S("stats2",                                     config->stats2,                                 CONFIG_2PASS_2_FILE);  
   
         REG_GET_N("credits_start",                      config->credits_start,                  0);  
         REG_GET_N("credits_start_begin",        config->credits_start_begin,    0);  
         REG_GET_N("credits_start_end",          config->credits_start_end,              0);  
         REG_GET_N("credits_end",                        config->credits_end,                    0);  
         REG_GET_N("credits_end_begin",          config->credits_end_begin,              0);  
         REG_GET_N("credits_end_end",            config->credits_end_end,                0);  
   
         REG_GET_N("credits_mode",                       config->credits_mode,                   0);  
         REG_GET_N("credits_rate",                       config->credits_rate,                   20);  
         REG_GET_N("credits_quant_i",            config->credits_quant_i,                20);  
         REG_GET_N("credits_quant_p",            config->credits_quant_p,                20);  
         REG_GET_N("credits_start_size",         config->credits_start_size,             10000);  
         REG_GET_N("credits_end_size",           config->credits_end_size,               10000);  
201    
202          {          {
203                  BYTE default_qmatrix_intra[] = {                  BYTE default_qmatrix_intra[] = {
# Line 133  Line 222 
222                          23,24,25,27,28,30,31,33                          23,24,25,27,28,30,31,33
223                  };                  };
224    
225                  REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra);                  REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);
226                  REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter);                  REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);
227          }          }
228    
229            memcpy(config, &reg, sizeof(CONFIG));
230    
231          RegCloseKey(hKey);          RegCloseKey(hKey);
232  }  }
233    
234    
235  /* put config settings in registry */  /* put config settings in registry */
236    
 #define REG_SET_N(X, Y) RegSetValueEx(hKey, X, 0, REG_DWORD, (LPBYTE)&Y, sizeof(int))  
 #define REG_SET_S(X, Y) RegSetValueEx(hKey, X, 0, REG_SZ, Y, lstrlen(Y)+1)  
237  #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y)))  #define REG_SET_B(X, Y) RegSetValueEx(hKey, X, 0, REG_BINARY, Y, sizeof((Y)))
238    
239  void config_reg_set(CONFIG * config)  void config_reg_set(CONFIG * config)
240  {  {
241          HKEY hKey;          HKEY hKey;
242          DWORD dispo;          DWORD dispo;
243            int i;
244    
245          if (RegCreateKeyEx(          if (RegCreateKeyEx(
246                          XVID_REG_KEY,                          XVID_REG_KEY,
# Line 167  Line 257 
257                  return;                  return;
258          }          }
259    
260          REG_SET_N("mode",                                       config->mode);          memcpy(&reg, config, sizeof(CONFIG));
261          REG_SET_N("bitrate",                            config->bitrate);  
262          REG_SET_N("quality",                            config->quality);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
263          REG_SET_N("quant",                                      config->quant);          {
264          REG_SET_N("rc_buffersize",                      config->rc_buffersize);                  RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));
265            }
266          REG_SET_N("motion_search",                      config->motion_search);  
267          REG_SET_N("quant_type",                         config->quant_type);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
268          REG_SET_N("fourcc_used",                        config->fourcc_used);          {
269          REG_SET_N("max_key_interval",           config->max_key_interval);                  RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);
270          REG_SET_N("lum_masking",                        config->lum_masking);          }
271    
272          REG_SET_N("min_iquant",                         config->min_iquant);          REG_SET_B("qmatrix_intra", reg.qmatrix_intra);
273          REG_SET_N("max_iquant",                         config->max_iquant);          REG_SET_B("qmatrix_inter", reg.qmatrix_inter);
         REG_SET_N("min_pquant",                         config->min_pquant);  
         REG_SET_N("max_pquant",                         config->max_pquant);  
         REG_SET_B("qmatrix_intra",                      config->qmatrix_intra);  
         REG_SET_B("qmatrix_inter",                      config->qmatrix_inter);  
   
         REG_SET_N("desired_size",                       config->desired_size);  
         REG_SET_N("keyframe_boost",                     config->keyframe_boost);  
         REG_SET_N("min_key_interval",           config->min_key_interval);  
         REG_SET_N("discard1pass",                       config->discard1pass);  
         REG_SET_N("dummy2pass",                         config->dummy2pass);  
         REG_SET_N("curve_compression_high",     config->curve_compression_high);  
         REG_SET_N("curve_compression_low",      config->curve_compression_low);  
         REG_SET_N("bitrate_payback_delay",      config->bitrate_payback_delay);  
         REG_SET_N("bitrate_payback_method",     config->bitrate_payback_method);  
         REG_SET_S("stats1",                                     config->stats1);  
         REG_SET_S("stats2",                                     config->stats2);  
   
         REG_SET_N("credits_start",                      config->credits_start);  
         REG_SET_N("credits_start_begin",        config->credits_start_begin);  
         REG_SET_N("credits_start_end",          config->credits_start_end);  
         REG_SET_N("credits_end",                        config->credits_end);  
         REG_SET_N("credits_end_begin",          config->credits_end_begin);  
         REG_SET_N("credits_end_end",            config->credits_end_end);  
   
         REG_SET_N("credits_mode",                       config->credits_mode);  
         REG_SET_N("credits_rate",                       config->credits_rate);  
         REG_SET_N("credits_quant_i",            config->credits_quant_i);  
         REG_SET_N("credits_quant_p",            config->credits_quant_p);  
         REG_SET_N("credits_start_size",         config->credits_start_size);  
         REG_SET_N("credits_end_size",           config->credits_end_size);  
274    
275          RegCloseKey(hKey);          RegCloseKey(hKey);
276  }  }
# Line 228  Line 288 
288                  return;                  return;
289          }          }
290    
291          if (RegDeleteKey(XVID_REG_KEY, XVID_REG_CHILD))          if (RegDeleteKey(hKey, XVID_REG_CHILD))
292          {          {
293                  DEBUG1("Couldn't delete registry key - ", GetLastError());                  DEBUG1("Couldn't delete registry key - ", GetLastError());
294                  return;                  return;
295          }          }
296    
297            RegCloseKey(hKey);
298          config_reg_get(config);          config_reg_get(config);
299            config_reg_set(config);
300  }  }
301    
302    
303  /* leaves current config value if dialog item is empty */  /* leaves current config value if dialog item is empty */
304    
305  int config_get_int(HWND hDlg, UINT item, int config)  int config_get_int(HWND hDlg, INT item, int config)
306    {
307            BOOL success = FALSE;
308    
309            int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
310    
311            return (success) ? tmp : config;
312    }
313    
314    
315    int config_get_uint(HWND hDlg, UINT item, int config)
316  {  {
317          BOOL success = FALSE;          BOOL success = FALSE;
318    
# Line 258  Line 330 
330          {          {
331          default :          default :
332          case DLG_MODE_CBR :          case DLG_MODE_CBR :
333                  config->bitrate = config_get_int(hDlg, IDC_VALUE, config->bitrate) * CONFIG_KBPS;                  config->rc_bitrate = config_get_uint(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS;
334                  break;                  break;
335    
336          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
337                  config->quality = config_get_int(hDlg, IDC_VALUE, config->quality);                  config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality);
338                  break;                  break;
339    
340          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
341                  config->quant = config_get_int(hDlg, IDC_VALUE, config->quant);                  config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant);
342                  break;                  break;
343    
344          case DLG_MODE_2PASS_2_INT :          case DLG_MODE_2PASS_2_INT :
345                  config->desired_size = config_get_int(hDlg, IDC_VALUE, config->desired_size);                  config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size);
346                  break;                  break;
347          }          }
348    
349          config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);          config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
         config->rc_buffersize = config_get_int(hDlg, IDC_CBRBUFFER, config->rc_buffersize);  
350  }  }
351    
352    
# Line 294  Line 365 
365    
366          case DLG_MODE_CBR :          case DLG_MODE_CBR :
367                  text = "Bitrate (Kbps):";                  text = "Bitrate (Kbps):";
368                  value = config->bitrate / CONFIG_KBPS;                  value = config->rc_bitrate / CONFIG_KBPS;
369                  break;                  break;
370    
371          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
# Line 318  Line 389 
389    
390          EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);          EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);
391          EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled);          EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled);
         EnableWindow(GetDlgItem(hDlg, IDC_CBRBUFFER_STATIC), (config->mode == DLG_MODE_CBR));  
         EnableWindow(GetDlgItem(hDlg, IDC_CBRBUFFER), (config->mode == DLG_MODE_CBR));  
392  }  }
393    
394    
# Line 340  Line 409 
409          case DLG_MODE_CBR :          case DLG_MODE_CBR :
410                  text = "Bitrate (Kbps):";                  text = "Bitrate (Kbps):";
411                  range = MAKELONG(0,10000);                  range = MAKELONG(0,10000);
412                  pos = config->bitrate / CONFIG_KBPS;                  pos = config->rc_bitrate / CONFIG_KBPS;
413                  break;                  break;
414    
415          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
# Line 394  Line 463 
463          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);
464          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);
465          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);
466            psp[DLG_2PASSALT].pszTemplate   = MAKEINTRESOURCE(IDD_2PASSALT);
467          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);
468          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);
469    
# Line 421  Line 491 
491  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))
492  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)
493    
494    #define MOD_CBR
495    
496  void adv_mode(HWND hDlg, int mode)  void adv_mode(HWND hDlg, int mode)
497  {  {
498          // create arrays of controls to be disabled for each mode          // create arrays of controls to be disabled for each mode
499          const int cbr_disable[] = {          const short twopass_disable[] = {
500                  IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,                  IDC_KFBOOST, IDC_DUMMY2PASS, IDC_USEALT,
501    // added by koepi for new curve treatment
502                    IDC_KFTRESHOLD, IDC_KFREDUCTION,
503    //end of koepi's additions
504                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,
505                  IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,                  IDC_STATS2, IDC_STATS2_BROWSE,
506            };
507    
508            const short cbr_disable[] = {
509                    IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
510                  IDC_CREDITS_START, IDC_CREDITS_END, IDC_CREDITS_START_BEGIN, IDC_CREDITS_START_END,                  IDC_CREDITS_START, IDC_CREDITS_END, IDC_CREDITS_START_BEGIN, IDC_CREDITS_START_END,
511                  IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,                  IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,
512                  IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,                  IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,
513                  IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE, IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP,                  IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,
514                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE, IDC_CREDITS_GREYSCALE
515          };          };
516    
517          const int qual_disable[] = {          const short qual_disable[] = {
518                  IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,                  IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
519                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,                  IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,  
520                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
521          };          };
522    
523          const int quant_disable[] = {          const short quant_disable[] = {
524                    IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
525                    IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
526                  IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,                  IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,
                 IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,  
                 IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,  
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,  
527                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
528          };          };
529    
530          const int twopass1_disable[] = {          const short twopass1_disable[] = {
531                  IDC_LUMMASK, IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,                  IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
532                  IDC_KFBOOST, IDC_DUMMY2PASS,                  IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,
                 IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,  
                 IDC_STATS2, IDC_STATS2_BROWSE,  
533                  IDC_CREDITS_RATE_RADIO, IDC_CREDITS_RATE, IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC,                  IDC_CREDITS_RATE_RADIO, IDC_CREDITS_RATE, IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC,
534                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
535          };          };
536    
537          const int twopass2_ext_disable[] = {          const short twopass2_ext_disable[] = {
538                    IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
539                  IDC_CREDITS_RATE_RADIO, IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC,                  IDC_CREDITS_RATE_RADIO, IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC,
540                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,
541                  IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
542          };          };
543    
544          const int twopass2_int_disable[] = {          const short twopass2_int_disable[] = {
545                    IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
546                  IDC_STATS2, IDC_STATS2_BROWSE                  IDC_STATS2, IDC_STATS2_BROWSE
547          };          };
548    
549          // store pointers in order so we can lookup using config->mode          // store pointers in order so we can lookup using config->mode
550          const int* modes[] = {          const short* modes[] = {
551                  cbr_disable, qual_disable, quant_disable,                  cbr_disable, qual_disable, quant_disable,
552                  twopass1_disable, twopass2_ext_disable, twopass2_int_disable                  twopass1_disable, twopass2_ext_disable, twopass2_int_disable
553          };          };
554    
555          // ditto modes[]          // ditto modes[]
556          const int lengths[] = {          const int lengths[] = {
557                  sizeof(cbr_disable)/sizeof(int), sizeof(qual_disable)/sizeof(int),                  sizeof(cbr_disable)/sizeof(short), sizeof(qual_disable)/sizeof(short),
558                  sizeof(quant_disable)/sizeof(int), sizeof(twopass1_disable)/sizeof(int),                  sizeof(quant_disable)/sizeof(short), sizeof(twopass1_disable)/sizeof(short),
559                  sizeof(twopass2_ext_disable)/sizeof(int), sizeof(twopass2_int_disable)/sizeof(int)                  sizeof(twopass2_ext_disable)/sizeof(short), sizeof(twopass2_int_disable)/sizeof(short), 0
560          };          };
561    
562          int i;          int i;
563            int hinted_me, use_alt, use_alt_auto, use_alt_auto_bonus;
564            int credits_start, credits_end, credits_rate, credits_quant, credits_size;
565            int cpu_force;
566    
567          // first perform checkbox-based enable/disable          // first perform checkbox-based enable/disable
568          CONTROLDLG(IDC_CREDITS_START_BEGIN,     ISDLGSET(IDC_CREDITS_START));          hinted_me = ISDLGSET(IDC_HINTEDME);
569          CONTROLDLG(IDC_CREDITS_START_END,       ISDLGSET(IDC_CREDITS_START));          CONTROLDLG(IDC_HINTFILE,                        hinted_me);
570            CONTROLDLG(IDC_HINT_BROWSE,                     hinted_me);
571          CONTROLDLG(IDC_CREDITS_END_BEGIN,       ISDLGSET(IDC_CREDITS_END));  
572          CONTROLDLG(IDC_CREDITS_END_END,         ISDLGSET(IDC_CREDITS_END));          use_alt                         = ISDLGSET(IDC_USEALT) && (mode == DLG_MODE_2PASS_2_EXT || mode == DLG_MODE_2PASS_2_INT);
573            use_alt_auto            = ISDLGSET(IDC_USEAUTO);
574          CONTROLDLG(IDC_CREDITS_RATE,            ISDLGSET(IDC_CREDITS_RATE_RADIO));          use_alt_auto_bonus      = ISDLGSET(IDC_USEAUTOBONUS);
575          CONTROLDLG(IDC_CREDITS_QUANTI,          ISDLGSET(IDC_CREDITS_QUANT_RADIO));          CONTROLDLG(IDC_USEAUTO,                         use_alt);
576          CONTROLDLG(IDC_CREDITS_QUANTP,          ISDLGSET(IDC_CREDITS_QUANT_RADIO));          CONTROLDLG(IDC_AUTOSTR,                         use_alt && use_alt_auto);
577          CONTROLDLG(IDC_CREDITS_START_SIZE,      ISDLGSET(IDC_CREDITS_SIZE_RADIO));          CONTROLDLG(IDC_USEAUTOBONUS,            use_alt);
578          CONTROLDLG(IDC_CREDITS_END_SIZE,        ISDLGSET(IDC_CREDITS_SIZE_RADIO));          CONTROLDLG(IDC_BONUSBIAS,                       use_alt && !use_alt_auto_bonus);
579            CONTROLDLG(IDC_CURVETYPE,                       use_alt);
580          CONTROLDLG(IDC_CPU_MMX,                         ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_ALTCURVEHIGH,            use_alt);
581          CONTROLDLG(IDC_CPU_MMXEXT,                      ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_ALTCURVELOW,                     use_alt);
582          CONTROLDLG(IDC_CPU_SSE,                         ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_MINQUAL,                         use_alt && !use_alt_auto);
583          CONTROLDLG(IDC_CPU_SSE2,                        ISDLGSET(IDC_CPU_FORCE));  
584          CONTROLDLG(IDC_CPU_3DNOW,                       ISDLGSET(IDC_CPU_FORCE));          credits_start           = ISDLGSET(IDC_CREDITS_START);
585          CONTROLDLG(IDC_CPU_3DNOWEXT,            ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_CREDITS_START_BEGIN,     credits_start);
586            CONTROLDLG(IDC_CREDITS_START_END,       credits_start);
587    
588            credits_end                     = ISDLGSET(IDC_CREDITS_END);
589            CONTROLDLG(IDC_CREDITS_END_BEGIN,       credits_end);
590            CONTROLDLG(IDC_CREDITS_END_END,         credits_end);
591    
592            credits_rate            = ISDLGSET(IDC_CREDITS_RATE_RADIO);
593            credits_quant           = ISDLGSET(IDC_CREDITS_QUANT_RADIO);
594            credits_size            = ISDLGSET(IDC_CREDITS_SIZE_RADIO);
595            CONTROLDLG(IDC_CREDITS_RATE,            credits_rate);
596            CONTROLDLG(IDC_CREDITS_QUANTI,          credits_quant);
597            CONTROLDLG(IDC_CREDITS_QUANTP,          credits_quant);
598            CONTROLDLG(IDC_CREDITS_START_SIZE,      credits_size);
599            CONTROLDLG(IDC_CREDITS_END_SIZE,        credits_size);
600    
601            cpu_force                       = ISDLGSET(IDC_CPU_FORCE);
602            CONTROLDLG(IDC_CPU_MMX,                         cpu_force);
603            CONTROLDLG(IDC_CPU_MMXEXT,                      cpu_force);
604            CONTROLDLG(IDC_CPU_SSE,                         cpu_force);
605            CONTROLDLG(IDC_CPU_SSE2,                        cpu_force);
606            CONTROLDLG(IDC_CPU_3DNOW,                       cpu_force);
607            CONTROLDLG(IDC_CPU_3DNOWEXT,            cpu_force);
608    
609          // now perform codec mode enable/disable          // now perform codec mode enable/disable
610          for (i=0 ; i<lengths[mode] ; ++i)          for (i=0 ; i<lengths[mode] ; ++i)
611          {          {
612                  EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);                  EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);
613          }          }
614    
615            if (mode != DLG_MODE_2PASS_2_EXT && mode != DLG_MODE_2PASS_2_INT)
616            {
617                    for (i=0 ; i<sizeof(twopass_disable)/sizeof(short) ; ++i)
618                    {
619                            EnableWindow(GetDlgItem(hDlg, twopass_disable[i]), FALSE);
620                    }
621            }
622  }  }
623    
624    
# Line 523  Line 633 
633                  SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);                  SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
634                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
635                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
636                    SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);
637                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);
638                    CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);
639    // added by koepi for gruel's greyscale_mode
640                    CheckDlgButton(hDlg, IDC_GREYSCALE, config->greyscale ? BST_CHECKED : BST_UNCHECKED);
641    // end of koepi's addition
642    #ifdef BFRAMES
643                    SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, TRUE);
644                    SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE);
645                    CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED);
646                    CheckDlgButton(hDlg, IDC_DX50BVOP, config->dx50bvop ? BST_CHECKED : BST_UNCHECKED);
647                    CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED);
648    #endif
649                  break;                  break;
650    
651          case DLG_QUANT :          case DLG_QUANT :
# Line 535  Line 657 
657    
658          case DLG_2PASS :          case DLG_2PASS :
659                  SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);                  SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);
                 SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);  
660                  CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);
661                  CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);
662    // added by koepi for new 2pass curve treatment
663                    SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);
664                    SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
665    // end of koepi's additions
666                  SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);                  SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
667                  SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);                  SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
668                  SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);                  SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);
669                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));
670                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));
671    
672                    CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED);
673                    SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile);
674                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);
675                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);
676                  break;                  break;
677    
678            case DLG_2PASSALT :
679                    CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);
680    
681                    SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);
682                    SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);
683                    SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);
684                    SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);
685    
686                    CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);
687                    SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);
688    
689                    CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);
690                    SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);
691    
692                    SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE);
693                    SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
694                    SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
695                    break;
696    
697          case DLG_CREDITS :          case DLG_CREDITS :
698                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);
699                  SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);
# Line 557  Line 702 
702                  SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);
703                  SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);
704    
705    // added by koepi for credits greyscale
706                    CheckDlgButton(hDlg, IDC_CREDITS_GREYSCALE, config->credits_greyscale ? BST_CHECKED : BST_UNCHECKED);
707    // end of koepi's addition
708                  SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);
709                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);
710                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);
# Line 587  Line 735 
735    
736                  CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,                  CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
737                          config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );                          config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
738    
739    #ifdef _SMP
740                    SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
741    #endif
742    
743    #ifdef BFRAMES
744                    SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
745    #endif
746    
747                    SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
748                    SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
749                    SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
750                  break;                  break;
751          }          }
752  }  }
# Line 606  Line 766 
766                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
767                  config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);                  config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
768                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
769                  config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval);                  config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);
770                    config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);
771                  config->lum_masking = ISDLGSET(IDC_LUMMASK);                  config->lum_masking = ISDLGSET(IDC_LUMMASK);
772                    config->interlacing = ISDLGSET(IDC_INTERLACING);
773    // added by koepi for gruel's greyscale_mode
774                    config->greyscale = ISDLGSET(IDC_GREYSCALE);
775    // end of koepi's addition
776    #ifdef BFRAMES
777                    config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes);
778                    config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
779                    config->packed = ISDLGSET(IDC_PACKED);
780                    config->dx50bvop = ISDLGSET(IDC_DX50BVOP);
781                    config->debug = ISDLGSET(IDC_DEBUG);
782    #endif
783                  break;                  break;
784    
785          case DLG_QUANT :          case DLG_QUANT :
786                  config->min_iquant = config_get_int(hDlg, IDC_MINIQUANT, config->min_iquant);                  config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
787                  config->max_iquant = config_get_int(hDlg, IDC_MAXIQUANT, config->max_iquant);                  config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
788                  config->min_pquant = config_get_int(hDlg, IDC_MINPQUANT, config->min_pquant);                  config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
789                  config->max_pquant = config_get_int(hDlg, IDC_MAXPQUANT, config->max_pquant);                  config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
790    
791                  CONSTRAINVAL(config->min_iquant, 1, 31);                  CONSTRAINVAL(config->min_iquant, 1, 31);
792                  CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);                  CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
# Line 624  Line 796 
796    
797          case DLG_2PASS :          case DLG_2PASS :
798                  config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);                  config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
799                  config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->min_key_interval);  // added by koepi for the new 2pass curve treatment
800                    config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);
801                    config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
802    //end of koepi's additions
803                  config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);                  config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);
804                  config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);                  config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);
805                  config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);                  config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
806                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
807                  config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);                  config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);
808                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);
809                    config->hinted_me = ISDLGSET(IDC_HINTEDME);
810    
811                    if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0)
812                    {
813                            lstrcpy(config->hintfile, CONFIG_HINTFILE);
814                    }
815                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)
816                  {                  {
817                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);
# Line 647  Line 827 
827                  CONSTRAINVAL(config->curve_compression_low, 0, 100);                  CONSTRAINVAL(config->curve_compression_low, 0, 100);
828                  break;                  break;
829    
830            case DLG_2PASSALT :
831                    config->use_alt_curve = ISDLGSET(IDC_USEALT);
832    
833                    config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO);
834                    config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);
835    
836                    config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS);
837                    config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);
838    
839                    config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);
840                    config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);
841                    config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);
842                    config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);
843    
844                    config->twopass_max_bitrate /= CONFIG_KBPS;
845                    config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate);
846                    config->twopass_max_bitrate *= CONFIG_KBPS;
847                    config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
848                    config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
849    
850                    CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
851                    CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
852                    break;
853    
854          case DLG_CREDITS :          case DLG_CREDITS :
855                  config->credits_start = ISDLGSET(IDC_CREDITS_START);                  config->credits_start = ISDLGSET(IDC_CREDITS_START);
856                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);
857                  config->credits_start_end = config_get_int(hDlg, IDC_CREDITS_START_END, config->credits_start_end);                  config->credits_start_end = config_get_uint(hDlg, IDC_CREDITS_START_END, config->credits_start_end);
858                  config->credits_end = ISDLGSET(IDC_CREDITS_END);                  config->credits_end = ISDLGSET(IDC_CREDITS_END);
859                  config->credits_end_begin = config_get_int(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin);                  config->credits_end_begin = config_get_uint(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin);
860                  config->credits_end_end = config_get_int(hDlg, IDC_CREDITS_END_END, config->credits_end_end);                  config->credits_end_end = config_get_uint(hDlg, IDC_CREDITS_END_END, config->credits_end_end);
861    
862                  config->credits_rate = config_get_int(hDlg, IDC_CREDITS_RATE, config->credits_rate);  // added by koepi for gruel's greyscale_mode
863                  config->credits_quant_i = config_get_int(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i);                  config->credits_greyscale = ISDLGSET(IDC_CREDITS_GREYSCALE);
864                  config->credits_quant_p = config_get_int(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);  // end of koepi's addition
865                  config->credits_start_size = config_get_int(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size);                  config->credits_rate = config_get_uint(hDlg, IDC_CREDITS_RATE, config->credits_rate);
866                  config->credits_end_size = config_get_int(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size);                  config->credits_quant_i = config_get_uint(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i);
867                    config->credits_quant_p = config_get_uint(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);
868                    config->credits_start_size = config_get_uint(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size);
869                    config->credits_end_size = config_get_uint(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size);
870    
871                  config->credits_mode = 0;                  config->credits_mode = 0;
872                  config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode;                  config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode;
# Line 691  Line 898 
898                  config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;                  config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;
899                  config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;                  config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;
900                  config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;                  config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;
901    
902    #ifdef _SMP
903                    config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
904    #endif
905    #ifdef BFRAMES
906                    config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
907    #endif
908    
909                    config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
910                    config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
911                    config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
912                  break;                  break;
913          }          }
914  }  }
# Line 716  Line 934 
934          {          {
935                  int temp;                  int temp;
936    
937                  temp = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);                  temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
938                  CONSTRAINVAL(temp, 1, 255);                  CONSTRAINVAL(temp, 1, 255);
939                  temp = config->qmatrix_intra[i];                  config->qmatrix_intra[i] = temp;
940    
941                  temp = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);                  temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
942                  CONSTRAINVAL(temp, 1, 255);                  CONSTRAINVAL(temp, 1, 255);
943                  temp = config->qmatrix_inter[i];                  config->qmatrix_inter[i] = temp;
944          }          }
945  }  }
946    
 /* monitor mouse events to dialog controls for help text */  
   
 HHOOK hHook;  
 HWND hParent;  
947    
948  LRESULT CALLBACK msg_proc(int nCode, WPARAM wParam, LPARAM lParam)  /* enumerates child windows, assigns tooltips */
 {  
         MSG* pmsg = (MSG *)lParam;  
949    
950          if (pmsg->message == WM_MOUSEMOVE)  BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
         {  
                 if (pmsg->hwnd == hParent)  
951                  {                  {
                         SetDlgItemText(hParent, IDC_STATIC_HELP, XVID_HELP);  
                 }  
                 else if (IsChild(hParent, pmsg->hwnd))  
                 {  
                         char *message;  
952                          char help[500];                          char help[500];
953    
954                          int mode = SendDlgItemMessage(hParent, IDC_MODE, CB_GETCURSEL, 0, 0);          if (LoadString(hInst, GetDlgCtrlID(hWnd), help, 500))
                         int item = GetDlgCtrlID(pmsg->hwnd);  
   
                         if (item == IDC_VALUE || item == IDC_SLIDER)  
                         {  
                                 switch (mode)  
955                                  {                                  {
956                                  case DLG_MODE_2PASS_2_INT :                  TOOLINFO ti;
                                         if (item == IDC_VALUE)  
                                         {  
                                                 message = "Set the desired video size in Kilobytes";  
                                                 break;  
                                         }  
                                 default :  
                                 case DLG_MODE_CBR :  
                                         message = "Set the target video bitrate";  
                                         break;  
957    
958                                  case DLG_MODE_VBR_QUAL :                  ti.cbSize = sizeof(TOOLINFO);
959                                          message = "Set the target video quality";                  ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
960                                          break;                  ti.hwnd = GetParent(hWnd);
961                    ti.uId  = (LPARAM)hWnd;
962                                  case DLG_MODE_VBR_QUANT :                  ti.lpszText = help;
                                         message = "Set the fixed quantizer for encoding";  
                                         break;  
                                 }  
                                 lstrcpy(help, message);  
                         }  
                         else if (!LoadString(hInst, GetDlgCtrlID(pmsg->hwnd), help, 500))  
                         {  
                                 lstrcpy(help, XVID_HELP);  
                         }  
963    
964                          SetDlgItemText(hParent, IDC_STATIC_HELP, help);                  SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
                 }  
965          }          }
966    
967          return (CallNextHookEx(hHook, nCode, wParam, lParam));          return TRUE;
968  }  }
969    
970    
# Line 809  Line 990 
990                  SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");                  SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");
991    
992                  SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);                  SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
                 SetDlgItemInt(hDlg, IDC_CBRBUFFER, config->rc_buffersize, FALSE);  
                 SetDlgItemText(hDlg, IDC_STATIC_HELP, XVID_HELP);  
993    
994                  hHook = SetWindowsHookEx(WH_GETMESSAGE, msg_proc, 0, GetCurrentThreadId());                  InitCommonControls();
   
                 main_slider(hDlg, config);  
                 main_value(hDlg, config);  
                 break;  
995    
996          case WM_ACTIVATE :                  if (hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
997                  if (LOWORD(wParam) != WA_INACTIVE)                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
998                                    NULL, NULL, hInst, NULL))
999                  {                  {
1000                          hParent = hDlg;                          SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1001                            SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1002                            SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1003    
1004                            EnumChildWindows(hDlg, enum_tooltips, 0);
1005                  }                  }
                 return 0;  
1006    
1007          case WM_DESTROY :                  main_slider(hDlg, config);
1008                  UnhookWindowsHookEx(hHook);                  main_value(hDlg, config);
1009                  break;                  break;
1010    
1011          case WM_HSCROLL :          case WM_HSCROLL :
# Line 856  Line 1035 
1035                                  config_reg_set(config);                                  config_reg_set(config);
1036                          }                          }
1037                  }                  }
1038                    else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)
1039                    {
1040                            config_reg_default(config);
1041    
1042                            SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1043    
1044                            main_slider(hDlg, config);
1045                            main_value(hDlg, config);
1046                    }
1047                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)
1048                  {                  {
1049                          int value = config_get_int(hDlg, IDC_VALUE, 1);                          int value = config_get_uint(hDlg, IDC_VALUE, 1);
1050                          int max = 1;                          int max = 1;
1051    
1052                          max = (config->mode == DLG_MODE_CBR) ? 10000 :                          max = (config->mode == DLG_MODE_CBR) ? 10000 :
# Line 934  Line 1122 
1122                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
1123                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
1124                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
1125    
1126    #ifndef BFRAMES
1127                            EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC1), FALSE);
1128                            EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC2), FALSE);
1129                            EnableWindow(GetDlgItem(hDlg, IDC_BSTATIC3), FALSE);
1130                            EnableWindow(GetDlgItem(hDlg, IDC_MAXBFRAMES), FALSE);
1131                            EnableWindow(GetDlgItem(hDlg, IDC_BQUANTRATIO), FALSE);
1132                            EnableWindow(GetDlgItem(hDlg, IDC_PACKED), FALSE);
1133                            EnableWindow(GetDlgItem(hDlg, IDC_DX50BVOP), FALSE);
1134                            EnableWindow(GetDlgItem(hDlg, IDC_DEBUG), FALSE);
1135    #endif
1136                    }
1137                    else if (psi->page == DLG_2PASSALT)
1138                    {
1139                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");
1140                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");
1141                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");
1142                    }
1143                    else if (psi->page == DLG_CPU)
1144                    {
1145    #ifndef _SMP
1146    
1147                            EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
1148                            EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
1149    #endif
1150    #ifndef BFRAMES
1151                            EnableWindow(GetDlgItem(hDlg, IDC_FRAMEDROP_STATIC), FALSE);
1152                            EnableWindow(GetDlgItem(hDlg, IDC_FRAMEDROP), FALSE);
1153    #endif
1154                    }
1155    
1156                    if (hTooltip)
1157                    {
1158                            EnumChildWindows(hDlg, enum_tooltips, 0);
1159                  }                  }
1160    
                 SetDlgItemText(hDlg, IDC_STATIC_HELP, XVID_HELP);  
1161                  adv_upload(hDlg, psi->page, psi->config);                  adv_upload(hDlg, psi->page, psi->config);
1162                  adv_mode(hDlg, psi->config->mode);                  adv_mode(hDlg, psi->config->mode);
1163                  break;                  break;
# Line 946  Line 1167 
1167                  {                  {
1168                          switch (LOWORD(wParam))                          switch (LOWORD(wParam))
1169                          {                          {
1170                            case IDC_HINTEDME :
1171                            case IDC_USEALT :
1172                            case IDC_USEAUTO :
1173                            case IDC_USEAUTOBONUS :
1174                          case IDC_CREDITS_START :                          case IDC_CREDITS_START :
1175                          case IDC_CREDITS_END :                          case IDC_CREDITS_END :
1176                          case IDC_CREDITS_RATE_RADIO :                          case IDC_CREDITS_RATE_RADIO :
# Line 957  Line 1182 
1182                                  break;                                  break;
1183                          }                          }
1184                  }                  }
1185                  if ((LOWORD(wParam) == IDC_STATS1_BROWSE || LOWORD(wParam) == IDC_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED)                  if ((LOWORD(wParam) == IDC_HINT_BROWSE || LOWORD(wParam) == IDC_STATS1_BROWSE || LOWORD(wParam) == IDC_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED)
1186                  {                  {
1187                          OPENFILENAME ofn;                          OPENFILENAME ofn;
1188                          char tmp[MAX_PATH];                          char tmp[MAX_PATH];
# Line 974  Line 1199 
1199                          ofn.nMaxFile = MAX_PATH;                          ofn.nMaxFile = MAX_PATH;
1200                          ofn.Flags = OFN_PATHMUSTEXIST;                          ofn.Flags = OFN_PATHMUSTEXIST;
1201    
1202                          // display save box for stats1 using 1st-pass                          if (LOWORD(wParam) == IDC_HINT_BROWSE)
1203                          if (LOWORD(wParam) == IDC_STATS1_BROWSE &&                          {
1204                                    ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0";
1205                                    if (GetOpenFileName(&ofn))
1206                                    {
1207                                            SetDlgItemText(hDlg, IDC_HINTFILE, tmp);
1208                                    }
1209                            }
1210                            else if (LOWORD(wParam) == IDC_STATS1_BROWSE &&
1211                                  psi->config->mode == DLG_MODE_2PASS_1)                                  psi->config->mode == DLG_MODE_2PASS_1)
1212                          {                          {
1213                                  ofn.Flags |= OFN_OVERWRITEPROMPT;                                  ofn.Flags |= OFN_OVERWRITEPROMPT;
# Line 1001  Line 1233 
1233          case WM_NOTIFY :          case WM_NOTIFY :
1234                  switch (((NMHDR *)lParam)->code)                  switch (((NMHDR *)lParam)->code)
1235                  {                  {
                 case PSN_SETACTIVE :  
                         hParent = hDlg;  
                         break;  
   
1236                  case PSN_KILLACTIVE :                  case PSN_KILLACTIVE :
1237                          /* validate */                          /* validate */
1238                          adv_download(hDlg, psi->page, psi->config);                          adv_download(hDlg, psi->page, psi->config);
# Line 1040  Line 1268 
1268                  SetWindowLong(hDlg, GWL_USERDATA, lParam);                  SetWindowLong(hDlg, GWL_USERDATA, lParam);
1269                  config = (CONFIG*)lParam;                  config = (CONFIG*)lParam;
1270                  quant_upload(hDlg, config);                  quant_upload(hDlg, config);
                 break;  
1271    
1272          case WM_ACTIVATE :                  if (hTooltip)
                 if (LOWORD(wParam) != WA_INACTIVE)  
1273                  {                  {
1274                          hParent = hDlg;                          EnumChildWindows(hDlg, enum_tooltips, 0);
1275                  }                  }
1276                  return 0;                  break;
1277    
1278          case WM_COMMAND :          case WM_COMMAND :
1279                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
# Line 1091  Line 1317 
1317    
1318                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1319                                          {                                          {
1320                                                  DEBUG("Couldn't save quant matrix");                                                  DEBUGERR("Couldn't save quant matrix");
1321                                          }                                          }
1322                                          else                                          else
1323                                          {                                          {
1324                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))
1325                                                  {                                                  {
1326                                                          DEBUG("Couldnt write quant matrix");                                                          DEBUGERR("Couldnt write quant matrix");
1327                                                  }                                                  }
1328                                          }                                          }
1329    
# Line 1113  Line 1339 
1339    
1340                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1341                                          {                                          {
1342                                                  DEBUG("Couldn't load quant matrix");                                                  DEBUGERR("Couldn't load quant matrix");
1343                                          }                                          }
1344                                          else                                          else
1345                                          {                                          {
1346                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))
1347                                                  {                                                  {
1348                                                          DEBUG("Couldnt read quant matrix");                                                          DEBUGERR("Couldnt read quant matrix");
1349                                                  }                                                  }
1350                                                  else                                                  else
1351                                                  {                                                  {
# Line 1156  Line 1382 
1382                          HFONT hFont;                          HFONT hFont;
1383                          LOGFONT lfData;                          LOGFONT lfData;
1384    
1385                          SetDlgItemText(hDlg, IDC_BUILD, __TIME__ ", " __DATE__);                          SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1386                            SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD);
1387    
1388                            init_param.cpu_flags = XVID_CPU_CHKONLY;
1389                          xvid_init(NULL, 0, &init_param, 0);                          xvid_init(NULL, 0, &init_param, 0);
1390                          wsprintf(core, "Core Version %d.%d", (init_param.api_version>>16),(init_param.api_version&0xFFFFU));                          wsprintf(core, "Core Version %d.%d", (init_param.api_version>>16),(init_param.api_version&0xFFFFU));
1391                          SetDlgItemText(hDlg, IDC_CORE, core);                          SetDlgItemText(hDlg, IDC_CORE, core);

Legend:
Removed from v.30  
changed lines
  Added in v.361

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4