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

Diff of /vfw/src/config.c

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

revision 1.3, Sat Mar 16 11:40:48 2002 UTC revision 1.20.2.6, Sat Dec 14 06:09:33 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 33  Line 50 
50   *              now get Core Version use xvid_init()   *              now get Core Version use xvid_init()
51   *      05.03.2002  Min Chen <chenm001@163.com>   *      05.03.2002  Min Chen <chenm001@163.com>
52   *                              Add Core version display to about box   *                              Add Core version display to about box
53   *      01.12.2001      inital version; (c)2001 peter ross <suxen_drol@hotmail.com>   *      01.12.2001      inital version; (c)2001 peter ross <pross@xvid.org>
54   *   *
55   *************************************************************************/   *************************************************************************/
56    
# 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 <xvid.h>       // XviD API
67    
68  #include "codec.h"  #include "codec.h"
69  #include "config.h"  #include "config.h"
 #include "xvid.h"  // cpu masks  
70  #include "resource.h"  #include "resource.h"
71    
72    
73    
74    /* registry info structs */
75    
76    CONFIG reg;
77    
78    REG_INT const reg_ints[] = {
79            {"mode",                                        &reg.mode,                                              DLG_MODE_CBR},
80            {"quality",                                     &reg.quality,                                   85},
81            {"quant",                                       &reg.quant,                                             5},
82            {"rc_bitrate",                          &reg.rc_bitrate,                                900000},
83            {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor,      16},
84            {"rc_averaging_period",         &reg.rc_averaging_period,               100},
85            {"rc_buffer",                           &reg.rc_buffer,                                 100},
86    
87            {"motion_search",                       &reg.motion_search,                             6},
88            {"quant_type",                          &reg.quant_type,                                0},
89            {"fourcc_used",                         &reg.fourcc_used,                               0},
90            {"max_key_interval",            &reg.max_key_interval,                  300},
91            {"min_key_interval",            &reg.min_key_interval,                  1},
92            {"lum_masking",                         &reg.lum_masking,                               0},
93            {"interlacing",                         &reg.interlacing,                               0},
94            {"qpel",                                        &reg.qpel,                                              0},
95            {"gmc",                                         &reg.gmc,                                               0},
96            {"chromame",                            &reg.chromame,                                  0},
97    //added by koepi for gruel's greyscale_mode
98            {"greyscale",                           &reg.greyscale,                                 0},
99    // end of koepi's additions
100            {"max_bframes",                         &reg.max_bframes,                               -1},
101            {"bquant_ratio",                        &reg.bquant_ratio,                              150},
102            {"bquant_offset",                       &reg.bquant_offset,                             100},
103            {"packed",                                      &reg.packed,                                    0},
104            {"dx50bvop",                            &reg.dx50bvop,                                  1},
105            {"debug",                                       &reg.debug,                                             0},
106            {"reduced_resolution",          &reg.reduced_resolution,                0},
107            {"frame_drop_ratio",            &reg.frame_drop_ratio,                  0},
108    
109            {"min_iquant",                          &reg.min_iquant,                                2},
110            {"max_iquant",                          &reg.max_iquant,                                31},
111            {"min_pquant",                          &reg.min_pquant,                                2},
112            {"max_pquant",                          &reg.max_pquant,                                31},
113    
114            {"desired_size",                        &reg.desired_size,                              570000},
115            {"keyframe_boost",                      &reg.keyframe_boost,                    0},
116            {"discard1pass",                        &reg.discard1pass,                              1},
117            {"dummy2pass",                          &reg.dummy2pass,                                0},
118    // added by koepi for new two-pass curve treatment
119            {"kftreshold",                          &reg.kftreshold,                                10},
120            {"kfreduction",                         &reg.kfreduction,                               20},
121    // end of koepi's additions
122            {"curve_compression_high",      &reg.curve_compression_high,    0},
123            {"curve_compression_low",       &reg.curve_compression_low,             0},
124            {"use_alt_curve",                       &reg.use_alt_curve,                             0},
125            {"alt_curve_use_auto",          &reg.alt_curve_use_auto,                1},
126            {"alt_curve_auto_str",          &reg.alt_curve_auto_str,                30},
127            {"alt_curve_use_auto_bonus_bias",       &reg.alt_curve_use_auto_bonus_bias,     1},
128            {"alt_curve_bonus_bias",        &reg.alt_curve_bonus_bias,              50},
129            {"alt_curve_type",                      &reg.alt_curve_type,                    1},
130            {"alt_curve_high_dist",         &reg.alt_curve_high_dist,               500},
131            {"alt_curve_low_dist",          &reg.alt_curve_low_dist,                90},
132            {"alt_curve_min_rel_qual",      &reg.alt_curve_min_rel_qual,    50},
133            {"bitrate_payback_delay",       &reg.bitrate_payback_delay,             250},
134            {"bitrate_payback_method",      &reg.bitrate_payback_method,    0},
135            {"twopass_max_bitrate",         &reg.twopass_max_bitrate,               10000 * CONFIG_KBPS},
136            {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},
137            {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},
138            {"hinted_me",                           &reg.hinted_me,                                 0},
139    
140            {"credits_start",                       &reg.credits_start,                             0},
141            {"credits_start_begin",         &reg.credits_start_begin,               0},
142            {"credits_start_end",           &reg.credits_start_end,                 0},
143            {"credits_end",                         &reg.credits_end,                               0},
144            {"credits_end_begin",           &reg.credits_end_begin,                 0},
145            {"credits_end_end",                     &reg.credits_end_end,                   0},
146    
147    // added by koepi for greyscale credits
148            {"credits_greyscale",           &reg.credits_greyscale,                 0},
149    // end of koepi's addition
150            {"credits_mode",                        &reg.credits_mode,                              0},
151            {"credits_rate",                        &reg.credits_rate,                              20},
152            {"credits_quant_i",                     &reg.credits_quant_i,                   20},
153            {"credits_quant_p",                     &reg.credits_quant_p,                   20},
154            {"credits_start_size",          &reg.credits_start_size,                10000},
155            {"credits_end_size",            &reg.credits_end_size,                  10000},
156    
157            /* decoder */
158            {"deblock_y",                           &reg.deblock_y,                                 0},
159            {"deblock_uv",                          &reg.deblock_uv,                                0}
160    };
161    
162    REG_STR const reg_strs[] = {
163            {"hintfile",                            reg.hintfile,                                   CONFIG_HINTFILE},
164            {"stats1",                                      reg.stats1,                                             CONFIG_2PASS_1_FILE},
165            {"stats2",                                      reg.stats2,                                             CONFIG_2PASS_2_FILE}
166    //      {"build",                                       reg.build,                                              XVID_BUILD}
167    };
168    
169  /* get config settings from registry */  /* get config settings from registry */
170    
 #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);}  
171  #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)));}
172    
173  void config_reg_get(CONFIG * config)  void config_reg_get(CONFIG * config)
# Line 60  Line 175 
175          HKEY hKey;          HKEY hKey;
176          DWORD size;          DWORD size;
177          XVID_INIT_PARAM init_param;          XVID_INIT_PARAM init_param;
178            int i;
179    
180          init_param.cpu_flags = 0;          init_param.cpu_flags = XVID_CPU_CHKONLY;
181          xvid_init(0, 0, &init_param, NULL);          xvid_init(0, 0, &init_param, NULL);
182          config->cpu = init_param.cpu_flags;          reg.cpu = init_param.cpu_flags;
183    
184    #ifdef _SMP
185            reg.num_threads = pthread_num_processors_np();
186    #endif
187    
188          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);
189    
190          REG_GET_N("mode",                                       config->mode,                                   DLG_MODE_CBR);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
191          REG_GET_N("bitrate",                            config->bitrate,                                900000);          {
192          REG_GET_N("quality",                            config->quality,                                85);                  size = sizeof(int);
193          REG_GET_N("quant",                                      config->quant,                                  5);  
194          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)
195                    {
196          REG_GET_N("motion_search",                      config->motion_search,                  5);                          *reg_ints[i].config_int = reg_ints[i].def;
197          REG_GET_N("quant_type",                         config->quant_type,                             0);                  }
198          REG_GET_N("fourcc_used",                        config->fourcc_used,                    0);          }
199          REG_GET_N("max_key_interval",           config->max_key_interval,               300);  
200          REG_GET_N("lum_masking",                        config->lum_masking,                    0);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
201            {
202          REG_GET_N("min_iquant",                         config->min_iquant,                             1);                  size = MAX_PATH;
203          REG_GET_N("max_iquant",                         config->max_iquant,                             31);  
204          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)
205          REG_GET_N("max_pquant",                         config->max_pquant,                             31);                  {
206                            memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
207          REG_GET_N("desired_size",                       config->desired_size,                   570000);                  }
208          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);  
209    
210          {          {
211                  BYTE default_qmatrix_intra[] = {                  BYTE default_qmatrix_intra[] = {
# Line 133  Line 230 
230                          23,24,25,27,28,30,31,33                          23,24,25,27,28,30,31,33
231                  };                  };
232    
233                  REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra);                  REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);
234                  REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter);                  REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);
235          }          }
236    
237            memcpy(config, &reg, sizeof(CONFIG));
238    
239          RegCloseKey(hKey);          RegCloseKey(hKey);
240  }  }
241    
242    
243  /* put config settings in registry */  /* put config settings in registry */
244    
 #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)  
245  #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)))
246    
247  void config_reg_set(CONFIG * config)  void config_reg_set(CONFIG * config)
248  {  {
249          HKEY hKey;          HKEY hKey;
250          DWORD dispo;          DWORD dispo;
251            int i;
252    
253          if (RegCreateKeyEx(          if (RegCreateKeyEx(
254                          XVID_REG_KEY,                          XVID_REG_KEY,
# Line 167  Line 265 
265                  return;                  return;
266          }          }
267    
268          REG_SET_N("mode",                                       config->mode);          memcpy(&reg, config, sizeof(CONFIG));
269          REG_SET_N("bitrate",                            config->bitrate);  
270          REG_SET_N("quality",                            config->quality);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
271          REG_SET_N("quant",                                      config->quant);          {
272          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));
273            }
274          REG_SET_N("motion_search",                      config->motion_search);  
275          REG_SET_N("quant_type",                         config->quant_type);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
276          REG_SET_N("fourcc_used",                        config->fourcc_used);          {
277          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);
278          REG_SET_N("lum_masking",                        config->lum_masking);          }
279    
280          REG_SET_N("min_iquant",                         config->min_iquant);          REG_SET_B("qmatrix_intra", reg.qmatrix_intra);
281          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);  
282    
283          RegCloseKey(hKey);          RegCloseKey(hKey);
284  }  }
# Line 228  Line 296 
296                  return;                  return;
297          }          }
298    
299          if (RegDeleteKey(XVID_REG_KEY, XVID_REG_CHILD))          if (RegDeleteKey(hKey, XVID_REG_CHILD))
300          {          {
301                  DEBUG1("Couldn't delete registry key - ", GetLastError());                  DEBUG1("Couldn't delete registry key - ", GetLastError());
302                  return;                  return;
303          }          }
304    
305            RegCloseKey(hKey);
306          config_reg_get(config);          config_reg_get(config);
307            config_reg_set(config);
308  }  }
309    
310    
311  /* leaves current config value if dialog item is empty */  /* leaves current config value if dialog item is empty */
312    
313  int config_get_int(HWND hDlg, UINT item, int config)  int config_get_int(HWND hDlg, INT item, int config)
314    {
315            BOOL success = FALSE;
316    
317            int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
318    
319            return (success) ? tmp : config;
320    }
321    
322    
323    int config_get_uint(HWND hDlg, UINT item, int config)
324  {  {
325          BOOL success = FALSE;          BOOL success = FALSE;
326    
# Line 258  Line 338 
338          {          {
339          default :          default :
340          case DLG_MODE_CBR :          case DLG_MODE_CBR :
341                  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;
342                  break;                  break;
343    
344          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
345                  config->quality = config_get_int(hDlg, IDC_VALUE, config->quality);                  config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality);
346                  break;                  break;
347    
348          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
349                  config->quant = config_get_int(hDlg, IDC_VALUE, config->quant);                  config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant);
350                  break;                  break;
351    
352          case DLG_MODE_2PASS_2_INT :          case DLG_MODE_2PASS_2_INT :
353                  config->desired_size = config_get_int(hDlg, IDC_VALUE, config->desired_size);                  config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size);
354                  break;                  break;
355          }          }
356    
357          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);  
358  }  }
359    
360    
# Line 294  Line 373 
373    
374          case DLG_MODE_CBR :          case DLG_MODE_CBR :
375                  text = "Bitrate (Kbps):";                  text = "Bitrate (Kbps):";
376                  value = config->bitrate / CONFIG_KBPS;                  value = config->rc_bitrate / CONFIG_KBPS;
377                  break;                  break;
378    
379          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
# Line 318  Line 397 
397    
398          EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);          EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);
399          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));  
400  }  }
401    
402    
# Line 340  Line 417 
417          case DLG_MODE_CBR :          case DLG_MODE_CBR :
418                  text = "Bitrate (Kbps):";                  text = "Bitrate (Kbps):";
419                  range = MAKELONG(0,10000);                  range = MAKELONG(0,10000);
420                  pos = config->bitrate / CONFIG_KBPS;                  pos = config->rc_bitrate / CONFIG_KBPS;
421                  break;                  break;
422    
423          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
# Line 394  Line 471 
471          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);
472          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);
473          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);
474            psp[DLG_2PASSALT].pszTemplate   = MAKEINTRESOURCE(IDD_2PASSALT);
475          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);
476          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);
477    
# Line 421  Line 499 
499  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))
500  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)
501    
502    #define MOD_CBR
503    
504  void adv_mode(HWND hDlg, int mode)  void adv_mode(HWND hDlg, int mode)
505  {  {
506          // create arrays of controls to be disabled for each mode          // create arrays of controls to be disabled for each mode
507          const int cbr_disable[] = {          const short twopass_disable[] = {
508                  IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,                  IDC_KFBOOST, IDC_DUMMY2PASS, IDC_USEALT,
509    // added by koepi for new curve treatment
510                    IDC_KFTRESHOLD, IDC_KFREDUCTION,
511    //end of koepi's additions
512                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,
513                  IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,                  IDC_STATS2, IDC_STATS2_BROWSE,
514            };
515    
516            const short cbr_disable[] = {
517                    IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
518                  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,
519                  IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,                  IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,
520                  IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,                  IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,
521                  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,
522                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE, IDC_CREDITS_GREYSCALE, IDC_HINTFILE
523          };          };
524    
525          const int qual_disable[] = {          const short qual_disable[] = {
526                  IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,                  IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
527                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,                  IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
528                  IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,
529                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_HINTFILE
530          };          };
531    
532          const int quant_disable[] = {          const short quant_disable[] = {
533                    IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,
534                    IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
535                  IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,                  IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,
536                  IDC_KFBOOST, IDC_MINKEY, IDC_DISCARD1PASS, IDC_DUMMY2PASS,                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,
537                  IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,                  IDC_HINTFILE
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_STATS2, IDC_STATS2_BROWSE,  
                 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE  
538          };          };
539    
540          const int twopass1_disable[] = {          const short twopass1_disable[] = {
541                  IDC_LUMMASK, IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,                  IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
542                  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,  
543                  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,
544                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
545          };          };
546    
547          const int twopass2_ext_disable[] = {          const short twopass2_ext_disable[] = {
548                  IDC_CREDITS_RATE_RADIO, IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC,                  IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
549                    IDC_CREDITS_RATE_RADIO,
550                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,                  IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,
551                  IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE                  IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE
552          };          };
553    
554          const int twopass2_int_disable[] = {          const short twopass2_int_disable[] = {
555                    IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,
556                  IDC_STATS2, IDC_STATS2_BROWSE                  IDC_STATS2, IDC_STATS2_BROWSE
557          };          };
558    
559          // store pointers in order so we can lookup using config->mode          // store pointers in order so we can lookup using config->mode
560          const int* modes[] = {          const short* modes[] = {
561                  cbr_disable, qual_disable, quant_disable,                  cbr_disable, qual_disable, quant_disable,
562                  twopass1_disable, twopass2_ext_disable, twopass2_int_disable                  twopass1_disable, twopass2_ext_disable, twopass2_int_disable
563          };          };
564    
565          // ditto modes[]          // ditto modes[]
566          const int lengths[] = {          const int lengths[] = {
567                  sizeof(cbr_disable)/sizeof(int), sizeof(qual_disable)/sizeof(int),                  sizeof(cbr_disable)/sizeof(short), sizeof(qual_disable)/sizeof(short),
568                  sizeof(quant_disable)/sizeof(int), sizeof(twopass1_disable)/sizeof(int),                  sizeof(quant_disable)/sizeof(short), sizeof(twopass1_disable)/sizeof(short),
569                  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
570          };          };
571    
572          int i;          int i;
573            int hinted_me, use_alt, use_alt_auto, use_alt_auto_bonus;
574            int credits_start, credits_end, credits_rate, credits_quant, credits_size;
575            int cpu_force;
576    
577          // first perform checkbox-based enable/disable          // first perform checkbox-based enable/disable
578          CONTROLDLG(IDC_CREDITS_START_BEGIN,     ISDLGSET(IDC_CREDITS_START));          hinted_me = ISDLGSET(IDC_HINTEDME);
579          CONTROLDLG(IDC_CREDITS_START_END,       ISDLGSET(IDC_CREDITS_START));          CONTROLDLG(IDC_HINTFILE,                        hinted_me);
580            CONTROLDLG(IDC_HINT_BROWSE,                     hinted_me);
581          CONTROLDLG(IDC_CREDITS_END_BEGIN,       ISDLGSET(IDC_CREDITS_END));  
582          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);
583            use_alt_auto            = ISDLGSET(IDC_USEAUTO);
584          CONTROLDLG(IDC_CREDITS_RATE,            ISDLGSET(IDC_CREDITS_RATE_RADIO));          use_alt_auto_bonus      = ISDLGSET(IDC_USEAUTOBONUS);
585          CONTROLDLG(IDC_CREDITS_QUANTI,          ISDLGSET(IDC_CREDITS_QUANT_RADIO));          CONTROLDLG(IDC_USEAUTO,                         use_alt);
586          CONTROLDLG(IDC_CREDITS_QUANTP,          ISDLGSET(IDC_CREDITS_QUANT_RADIO));          CONTROLDLG(IDC_AUTOSTR,                         use_alt && use_alt_auto);
587          CONTROLDLG(IDC_CREDITS_START_SIZE,      ISDLGSET(IDC_CREDITS_SIZE_RADIO));          CONTROLDLG(IDC_USEAUTOBONUS,            use_alt);
588          CONTROLDLG(IDC_CREDITS_END_SIZE,        ISDLGSET(IDC_CREDITS_SIZE_RADIO));          CONTROLDLG(IDC_BONUSBIAS,                       use_alt && !use_alt_auto_bonus);
589            CONTROLDLG(IDC_CURVETYPE,                       use_alt);
590          CONTROLDLG(IDC_CPU_MMX,                         ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_ALTCURVEHIGH,            use_alt);
591          CONTROLDLG(IDC_CPU_MMXEXT,                      ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_ALTCURVELOW,                     use_alt);
592          CONTROLDLG(IDC_CPU_SSE,                         ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_MINQUAL,                         use_alt && !use_alt_auto);
593          CONTROLDLG(IDC_CPU_SSE2,                        ISDLGSET(IDC_CPU_FORCE));  
594          CONTROLDLG(IDC_CPU_3DNOW,                       ISDLGSET(IDC_CPU_FORCE));          credits_start           = ISDLGSET(IDC_CREDITS_START);
595          CONTROLDLG(IDC_CPU_3DNOWEXT,            ISDLGSET(IDC_CPU_FORCE));          CONTROLDLG(IDC_CREDITS_START_BEGIN,     credits_start);
596            CONTROLDLG(IDC_CREDITS_START_END,       credits_start);
597    
598            credits_end                     = ISDLGSET(IDC_CREDITS_END);
599            CONTROLDLG(IDC_CREDITS_END_BEGIN,       credits_end);
600            CONTROLDLG(IDC_CREDITS_END_END,         credits_end);
601    
602            credits_rate            = ISDLGSET(IDC_CREDITS_RATE_RADIO);
603            credits_quant           = ISDLGSET(IDC_CREDITS_QUANT_RADIO);
604            credits_size            = ISDLGSET(IDC_CREDITS_SIZE_RADIO);
605            CONTROLDLG(IDC_CREDITS_RATE,            credits_rate);
606            CONTROLDLG(IDC_CREDITS_QUANTI,          credits_quant);
607            CONTROLDLG(IDC_CREDITS_QUANTP,          credits_quant);
608            CONTROLDLG(IDC_CREDITS_START_SIZE,      credits_size);
609            CONTROLDLG(IDC_CREDITS_END_SIZE,        credits_size);
610    
611            cpu_force                       = ISDLGSET(IDC_CPU_FORCE);
612            CONTROLDLG(IDC_CPU_MMX,                         cpu_force);
613            CONTROLDLG(IDC_CPU_MMXEXT,                      cpu_force);
614            CONTROLDLG(IDC_CPU_SSE,                         cpu_force);
615            CONTROLDLG(IDC_CPU_SSE2,                        cpu_force);
616            CONTROLDLG(IDC_CPU_3DNOW,                       cpu_force);
617            CONTROLDLG(IDC_CPU_3DNOWEXT,            cpu_force);
618    
619          // now perform codec mode enable/disable          // now perform codec mode enable/disable
620          for (i=0 ; i<lengths[mode] ; ++i)          for (i=0 ; i<lengths[mode] ; ++i)
621          {          {
622                  EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);                  EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);
623          }          }
624    
625            if (mode != DLG_MODE_2PASS_2_EXT && mode != DLG_MODE_2PASS_2_INT)
626            {
627                    for (i=0 ; i<sizeof(twopass_disable)/sizeof(short) ; ++i)
628                    {
629                            EnableWindow(GetDlgItem(hDlg, twopass_disable[i]), FALSE);
630                    }
631            }
632  }  }
633    
634    
# Line 523  Line 643 
643                  SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);                  SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
644                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
645                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
646                    SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);
647                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);
648                    CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);
649    
650                    CheckDlgButton(hDlg, IDC_QPEL, config->qpel ? BST_CHECKED : BST_UNCHECKED);
651                    CheckDlgButton(hDlg, IDC_GMC, config->gmc ? BST_CHECKED : BST_UNCHECKED);
652                    CheckDlgButton(hDlg, IDC_CHROMAME, config->chromame ? BST_CHECKED : BST_UNCHECKED);
653    // added by koepi for gruel's greyscale_mode
654                    CheckDlgButton(hDlg, IDC_GREYSCALE, config->greyscale ? BST_CHECKED : BST_UNCHECKED);
655    // end of koepi's addition
656                    SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, TRUE);
657                    SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE);
658                    SetDlgItemInt(hDlg, IDC_BQUANTOFFSET, config->bquant_offset, FALSE);
659                    CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED);
660                    CheckDlgButton(hDlg, IDC_DX50BVOP, config->dx50bvop ? BST_CHECKED : BST_UNCHECKED);
661                    CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED);
662    
663                    CheckDlgButton(hDlg, IDC_REDUCED, config->reduced_resolution ? BST_CHECKED : BST_UNCHECKED);
664                  break;                  break;
665    
666          case DLG_QUANT :          case DLG_QUANT :
# Line 535  Line 672 
672    
673          case DLG_2PASS :          case DLG_2PASS :
674                  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);  
675                  CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);
676                  CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);
677    // added by koepi for new 2pass curve treatment
678                    SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);
679                    SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
680    // end of koepi's additions
681                  SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);                  SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
682                  SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);                  SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
683                  SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);                  SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);
684                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));
685                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));
686    
687                    CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED);
688                    SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile);
689                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);
690                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);
691                  break;                  break;
692    
693            case DLG_2PASSALT :
694                    CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);
695    
696                    SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);
697                    SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);
698                    SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);
699                    SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);
700    
701                    CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);
702                    SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);
703    
704                    CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);
705                    SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);
706    
707                    SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE);
708                    SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
709                    SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
710                    break;
711    
712          case DLG_CREDITS :          case DLG_CREDITS :
713                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);
714                  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 717 
717                  SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);
718                  SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);
719    
720    // added by koepi for credits greyscale
721                    CheckDlgButton(hDlg, IDC_CREDITS_GREYSCALE, config->credits_greyscale ? BST_CHECKED : BST_UNCHECKED);
722    // end of koepi's addition
723                  SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);
724                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);
725                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);
# Line 587  Line 750 
750    
751                  CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,                  CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
752                          config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );                          config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
753    
754    #ifdef _SMP
755                    SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
756    #endif
757                    SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
758                    SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
759                    SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
760                    SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
761                  break;                  break;
762          }          }
763  }  }
# Line 606  Line 777 
777                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
778                  config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);                  config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
779                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
780                  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);
781                    config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);
782                  config->lum_masking = ISDLGSET(IDC_LUMMASK);                  config->lum_masking = ISDLGSET(IDC_LUMMASK);
783                    config->interlacing = ISDLGSET(IDC_INTERLACING);
784    
785                    config->qpel = ISDLGSET(IDC_QPEL);
786                    config->gmc = ISDLGSET(IDC_GMC);
787                    config->chromame = ISDLGSET(IDC_CHROMAME);
788    // added by koepi for gruel's greyscale_mode
789                    config->greyscale = ISDLGSET(IDC_GREYSCALE);
790    // end of koepi's addition
791                    config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes);
792                    config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
793                    config->bquant_offset = config_get_uint(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
794                    config->packed = ISDLGSET(IDC_PACKED);
795                    config->dx50bvop = ISDLGSET(IDC_DX50BVOP);
796                    config->debug = ISDLGSET(IDC_DEBUG);
797                    config->reduced_resolution = ISDLGSET(IDC_REDUCED);
798                  break;                  break;
799    
800          case DLG_QUANT :          case DLG_QUANT :
801                  config->min_iquant = config_get_int(hDlg, IDC_MINIQUANT, config->min_iquant);                  config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
802                  config->max_iquant = config_get_int(hDlg, IDC_MAXIQUANT, config->max_iquant);                  config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
803                  config->min_pquant = config_get_int(hDlg, IDC_MINPQUANT, config->min_pquant);                  config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
804                  config->max_pquant = config_get_int(hDlg, IDC_MAXPQUANT, config->max_pquant);                  config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
805    
806                  CONSTRAINVAL(config->min_iquant, 1, 31);                  CONSTRAINVAL(config->min_iquant, 1, 31);
807                  CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);                  CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
# Line 624  Line 811 
811    
812          case DLG_2PASS :          case DLG_2PASS :
813                  config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);                  config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
814                  config->min_key_interval = config_get_int(hDlg, IDC_MINKEY, config->min_key_interval);  // added by koepi for the new 2pass curve treatment
815                    config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);
816                    config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
817    //end of koepi's additions
818                  config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);                  config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);
819                  config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);                  config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);
820                  config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);                  config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
821                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
822                  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);
823                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);
824                    config->hinted_me = ISDLGSET(IDC_HINTEDME);
825    
826                    if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0)
827                    {
828                            lstrcpy(config->hintfile, CONFIG_HINTFILE);
829                    }
830                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)
831                  {                  {
832                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);
# Line 647  Line 842 
842                  CONSTRAINVAL(config->curve_compression_low, 0, 100);                  CONSTRAINVAL(config->curve_compression_low, 0, 100);
843                  break;                  break;
844    
845            case DLG_2PASSALT :
846                    config->use_alt_curve = ISDLGSET(IDC_USEALT);
847    
848                    config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO);
849                    config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);
850    
851                    config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS);
852                    config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);
853    
854                    config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);
855                    config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);
856                    config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);
857                    config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);
858    
859                    config->twopass_max_bitrate /= CONFIG_KBPS;
860                    config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate);
861                    config->twopass_max_bitrate *= CONFIG_KBPS;
862                    config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
863                    config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
864    
865                    CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
866                    CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
867                    break;
868    
869          case DLG_CREDITS :          case DLG_CREDITS :
870                  config->credits_start = ISDLGSET(IDC_CREDITS_START);                  config->credits_start = ISDLGSET(IDC_CREDITS_START);
871                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);
872                  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);
873                  config->credits_end = ISDLGSET(IDC_CREDITS_END);                  config->credits_end = ISDLGSET(IDC_CREDITS_END);
874                  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);
875                  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);
876    
877                  config->credits_rate = config_get_int(hDlg, IDC_CREDITS_RATE, config->credits_rate);  // added by koepi for gruel's greyscale_mode
878                  config->credits_quant_i = config_get_int(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i);                  config->credits_greyscale = ISDLGSET(IDC_CREDITS_GREYSCALE);
879                  config->credits_quant_p = config_get_int(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);  // end of koepi's addition
880                  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);
881                  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);
882                    config->credits_quant_p = config_get_uint(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);
883                    config->credits_start_size = config_get_uint(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size);
884                    config->credits_end_size = config_get_uint(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size);
885    
886                  config->credits_mode = 0;                  config->credits_mode = 0;
887                  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 913 
913                  config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;                  config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;
914                  config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;                  config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;
915                  config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;                  config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;
916    
917    #ifdef _SMP
918                    config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
919    #endif
920                    config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
921                    config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
922                    config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
923                    config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
924                  break;                  break;
925          }          }
926  }  }
# Line 716  Line 946 
946          {          {
947                  int temp;                  int temp;
948    
949                  temp = config_get_int(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);                  temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
950                  CONSTRAINVAL(temp, 1, 255);                  CONSTRAINVAL(temp, 1, 255);
951                  temp = config->qmatrix_intra[i];                  config->qmatrix_intra[i] = temp;
952    
953                  temp = config_get_int(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);                  temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
954                  CONSTRAINVAL(temp, 1, 255);                  CONSTRAINVAL(temp, 1, 255);
955                  temp = config->qmatrix_inter[i];                  config->qmatrix_inter[i] = temp;
956          }          }
957  }  }
958    
 /* monitor mouse events to dialog controls for help text */  
959    
960  HHOOK hHook;  /* enumerates child windows, assigns tooltips */
961  HWND hParent;  
962    BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
963    {
964            char help[500];
965    
966  LRESULT CALLBACK msg_proc(int nCode, WPARAM wParam, LPARAM lParam)          if (LoadString(hInst, GetDlgCtrlID(hWnd), help, 500))
967  {  {
968          MSG* pmsg = (MSG *)lParam;                  TOOLINFO ti;
969    
970                    ti.cbSize = sizeof(TOOLINFO);
971                    ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
972                    ti.hwnd = GetParent(hWnd);
973                    ti.uId  = (LPARAM)hWnd;
974                    ti.lpszText = help;
975    
976                    SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
977            }
978    
979            return TRUE;
980    }
981    
982    
983          if (pmsg->message == WM_MOUSEMOVE)  
984    /* --- decoder options dialog  --- */
985    
986    #define DEC_DLG_COUNT   1
987    #define DEC_DLG_POSTPROC        0
988    
989    /* decoder dialog: upload config data */
990    
991    void dec_upload(HWND hDlg, int page, CONFIG * config)
992          {          {
993                  if (pmsg->hwnd == hParent)          switch (page)
994                  {                  {
995                          SetDlgItemText(hParent, IDC_STATIC_HELP, XVID_HELP);          case DEC_DLG_POSTPROC :
996                    CheckDlgButton(hDlg, IDC_DEBLOCK_Y,  config->deblock_y ? BST_CHECKED : BST_UNCHECKED);
997                    CheckDlgButton(hDlg, IDC_DEBLOCK_UV, config->deblock_uv ? BST_CHECKED : BST_UNCHECKED);
998                    break;
999                  }                  }
1000                  else if (IsChild(hParent, pmsg->hwnd))  }
1001    
1002    
1003    /* dec dialog: download config data */
1004    
1005    void dec_download(HWND hDlg, int page, CONFIG * config)
1006                  {                  {
1007                          char *message;          switch (page)
1008                          char help[500];          {
1009            case DEC_DLG_POSTPROC :
1010                    config->deblock_y = ISDLGSET(IDC_DEBLOCK_Y);
1011                    config->deblock_uv = ISDLGSET(IDC_DEBLOCK_UV);
1012                    break;
1013            }
1014    }
1015    
1016                          int mode = SendDlgItemMessage(hParent, IDC_MODE, CB_GETCURSEL, 0, 0);  /* decoder dialog proc */
                         int item = GetDlgCtrlID(pmsg->hwnd);  
1017    
1018                          if (item == IDC_VALUE || item == IDC_SLIDER)  BOOL CALLBACK dec_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1019                          {                          {
1020                                  switch (mode)          PROPSHEETINFO *psi;
1021    
1022            psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);
1023    
1024            switch (uMsg)
1025                                  {                                  {
1026                                  case DLG_MODE_2PASS_2_INT :          case WM_INITDIALOG :
1027                                          if (item == IDC_VALUE)                  psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
1028    
1029                    SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
1030    
1031                    if (hTooltip)
1032                                          {                                          {
1033                                                  message = "Set the desired video size in Kilobytes";                          EnumChildWindows(hDlg, enum_tooltips, 0);
                                                 break;  
1034                                          }                                          }
1035                                  default :  
1036                                  case DLG_MODE_CBR :                  dec_upload(hDlg, psi->page, psi->config);
                                         message = "Set the target video bitrate";  
1037                                          break;                                          break;
1038    
1039                                  case DLG_MODE_VBR_QUAL :          case WM_NOTIFY :
1040                                          message = "Set the target video quality";                  switch (((NMHDR *)lParam)->code)
1041                    {
1042                    case PSN_KILLACTIVE :
1043                            /* validate */
1044                            dec_download(hDlg, psi->page, psi->config);
1045                            SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1046                                          break;                                          break;
1047    
1048                                  case DLG_MODE_VBR_QUANT :                  case PSN_APPLY :
1049                                          message = "Set the fixed quantizer for encoding";                          /* apply */
1050                            dec_download(hDlg, psi->page, psi->config);
1051                            SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1052                            psi->config->save = TRUE;
1053                            break;
1054                    }
1055                                          break;                                          break;
1056    
1057            default :
1058                    return 0;
1059                                  }                                  }
1060                                  lstrcpy(help, message);  
1061            return 1;
1062                          }                          }
1063                          else if (!LoadString(hInst, GetDlgCtrlID(pmsg->hwnd), help, 500))  
1064    
1065    void dec_dialog(HWND hParent, CONFIG * config)
1066    {
1067            PROPSHEETINFO psi[DEC_DLG_COUNT];
1068            PROPSHEETPAGE psp[DEC_DLG_COUNT];
1069            PROPSHEETHEADER psh;
1070            CONFIG temp;
1071            int i;
1072    
1073            config->save = FALSE;
1074            memcpy(&temp, config, sizeof(CONFIG));
1075    
1076            for (i=0 ; i<DEC_DLG_COUNT ; ++i)
1077                          {                          {
1078                                  lstrcpy(help, XVID_HELP);                  psp[i].dwSize = sizeof(PROPSHEETPAGE);
1079                    psp[i].dwFlags = 0;
1080                    psp[i].hInstance = hInst;
1081                    psp[i].pfnDlgProc = dec_proc;
1082                    psp[i].lParam = (LPARAM)&psi[i];
1083                    psp[i].pfnCallback = NULL;
1084    
1085                    psi[i].page = i;
1086                    psi[i].config = &temp;
1087                          }                          }
1088    
1089                          SetDlgItemText(hParent, IDC_STATIC_HELP, help);          psp[DEC_DLG_POSTPROC].pszTemplate = MAKEINTRESOURCE(IDD_POSTPROC);
1090    
1091            psh.dwSize = sizeof(PROPSHEETHEADER);
1092            psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
1093            psh.hwndParent = hParent;
1094            psh.hInstance = hInst;
1095            psh.pszCaption = (LPSTR) "XviD Configuration";
1096            psh.nPages = DEC_DLG_COUNT;
1097            psh.nStartPage = DEC_DLG_POSTPROC;
1098            psh.ppsp = (LPCPROPSHEETPAGE)&psp;
1099            psh.pfnCallback = NULL;
1100    
1101            PropertySheet(&psh);
1102    
1103            if (temp.save)
1104            {
1105                    memcpy(config, &temp, sizeof(CONFIG));
1106                  }                  }
1107          }          }
1108    
         return (CallNextHookEx(hHook, nCode, wParam, lParam));  
 }  
1109    
1110    
1111  /* main dialog proc */  /* main dialog proc */
# Line 809  Line 1130 
1130                  SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");                  SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");
1131    
1132                  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);  
   
                 hHook = SetWindowsHookEx(WH_GETMESSAGE, msg_proc, 0, GetCurrentThreadId());  
1133    
1134                  main_slider(hDlg, config);                  InitCommonControls();
                 main_value(hDlg, config);  
                 break;  
1135    
1136          case WM_ACTIVATE :                  if (hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
1137                  if (LOWORD(wParam) != WA_INACTIVE)                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1138                                    NULL, NULL, hInst, NULL))
1139                  {                  {
1140                          hParent = hDlg;                          SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1141                            SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1142                            SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1143    
1144                            EnumChildWindows(hDlg, enum_tooltips, 0);
1145                  }                  }
                 return 0;  
1146    
1147          case WM_DESTROY :                  main_slider(hDlg, config);
1148                  UnhookWindowsHookEx(hHook);                  main_value(hDlg, config);
1149                  break;                  break;
1150    
1151          case WM_HSCROLL :          case WM_HSCROLL :
# Line 856  Line 1175 
1175                                  config_reg_set(config);                                  config_reg_set(config);
1176                          }                          }
1177                  }                  }
1178                    else if (LOWORD(wParam) == IDC_DECODER && HIWORD(wParam) == BN_CLICKED)
1179                    {
1180                            dec_dialog(hDlg, config);
1181    
1182                            if (config->save)
1183                            {
1184                                    config_reg_set(config);
1185                            }
1186                    }
1187                    else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)
1188                    {
1189                            config_reg_default(config);
1190    
1191                            SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1192    
1193                            main_slider(hDlg, config);
1194                            main_value(hDlg, config);
1195                    }
1196                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)
1197                  {                  {
1198                          int value = config_get_int(hDlg, IDC_VALUE, 1);                          int value = config_get_uint(hDlg, IDC_VALUE, 1);
1199                          int max = 1;                          int max = 1;
1200    
1201                          max = (config->mode == DLG_MODE_CBR) ? 10000 :                          max = (config->mode == DLG_MODE_CBR) ? 10000 :
# Line 930  Line 1267 
1267                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");
1268                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");
1269                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"Modulated");                          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"Modulated");
1270                            SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"New Modulated HQ");
1271    
1272                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
1273                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
1274                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
1275    
1276                            /* XXX: reduced resolution is not ready for prime-time */
1277                            ShowWindow(GetDlgItem(hDlg, IDC_REDUCED), SW_HIDE);
1278                    }
1279                    else if (psi->page == DLG_2PASSALT)
1280                    {
1281                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");
1282                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");
1283                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");
1284                    }
1285                    else if (psi->page == DLG_CPU)
1286                    {
1287    #ifndef _SMP
1288                            EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
1289                            EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
1290    #endif
1291                    }
1292    
1293                    if (hTooltip)
1294                    {
1295                            EnumChildWindows(hDlg, enum_tooltips, 0);
1296                  }                  }
1297    
                 SetDlgItemText(hDlg, IDC_STATIC_HELP, XVID_HELP);  
1298                  adv_upload(hDlg, psi->page, psi->config);                  adv_upload(hDlg, psi->page, psi->config);
1299                  adv_mode(hDlg, psi->config->mode);                  adv_mode(hDlg, psi->config->mode);
1300                  break;                  break;
# Line 946  Line 1304 
1304                  {                  {
1305                          switch (LOWORD(wParam))                          switch (LOWORD(wParam))
1306                          {                          {
1307                            case IDC_HINTEDME :
1308                            case IDC_USEALT :
1309                            case IDC_USEAUTO :
1310                            case IDC_USEAUTOBONUS :
1311                          case IDC_CREDITS_START :                          case IDC_CREDITS_START :
1312                          case IDC_CREDITS_END :                          case IDC_CREDITS_END :
1313                          case IDC_CREDITS_RATE_RADIO :                          case IDC_CREDITS_RATE_RADIO :
# Line 957  Line 1319 
1319                                  break;                                  break;
1320                          }                          }
1321                  }                  }
1322                  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)
1323                  {                  {
1324                          OPENFILENAME ofn;                          OPENFILENAME ofn;
1325                          char tmp[MAX_PATH];                          char tmp[MAX_PATH];
# Line 974  Line 1336 
1336                          ofn.nMaxFile = MAX_PATH;                          ofn.nMaxFile = MAX_PATH;
1337                          ofn.Flags = OFN_PATHMUSTEXIST;                          ofn.Flags = OFN_PATHMUSTEXIST;
1338    
1339                          // display save box for stats1 using 1st-pass                          if (LOWORD(wParam) == IDC_HINT_BROWSE)
1340                          if (LOWORD(wParam) == IDC_STATS1_BROWSE &&                          {
1341                                    ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0";
1342                                    if (GetOpenFileName(&ofn))
1343                                    {
1344                                            SetDlgItemText(hDlg, IDC_HINTFILE, tmp);
1345                                    }
1346                            }
1347                            else if (LOWORD(wParam) == IDC_STATS1_BROWSE &&
1348                                  psi->config->mode == DLG_MODE_2PASS_1)                                  psi->config->mode == DLG_MODE_2PASS_1)
1349                          {                          {
1350                                  ofn.Flags |= OFN_OVERWRITEPROMPT;                                  ofn.Flags |= OFN_OVERWRITEPROMPT;
# Line 1001  Line 1370 
1370          case WM_NOTIFY :          case WM_NOTIFY :
1371                  switch (((NMHDR *)lParam)->code)                  switch (((NMHDR *)lParam)->code)
1372                  {                  {
                 case PSN_SETACTIVE :  
                         hParent = hDlg;  
                         break;  
   
1373                  case PSN_KILLACTIVE :                  case PSN_KILLACTIVE :
1374                          /* validate */                          /* validate */
1375                          adv_download(hDlg, psi->page, psi->config);                          adv_download(hDlg, psi->page, psi->config);
# Line 1040  Line 1405 
1405                  SetWindowLong(hDlg, GWL_USERDATA, lParam);                  SetWindowLong(hDlg, GWL_USERDATA, lParam);
1406                  config = (CONFIG*)lParam;                  config = (CONFIG*)lParam;
1407                  quant_upload(hDlg, config);                  quant_upload(hDlg, config);
                 break;  
1408    
1409          case WM_ACTIVATE :                  if (hTooltip)
                 if (LOWORD(wParam) != WA_INACTIVE)  
1410                  {                  {
1411                          hParent = hDlg;                          EnumChildWindows(hDlg, enum_tooltips, 0);
1412                  }                  }
1413                  return 0;                  break;
1414    
1415          case WM_COMMAND :          case WM_COMMAND :
1416                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
# Line 1091  Line 1454 
1454    
1455                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1456                                          {                                          {
1457                                                  DEBUG("Couldn't save quant matrix");                                                  DEBUGERR("Couldn't save quant matrix");
1458                                          }                                          }
1459                                          else                                          else
1460                                          {                                          {
1461                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))
1462                                                  {                                                  {
1463                                                          DEBUG("Couldnt write quant matrix");                                                          DEBUGERR("Couldnt write quant matrix");
1464                                                  }                                                  }
1465                                          }                                          }
1466    
# Line 1113  Line 1476 
1476    
1477                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1478                                          {                                          {
1479                                                  DEBUG("Couldn't load quant matrix");                                                  DEBUGERR("Couldn't load quant matrix");
1480                                          }                                          }
1481                                          else                                          else
1482                                          {                                          {
1483                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))
1484                                                  {                                                  {
1485                                                          DEBUG("Couldnt read quant matrix");                                                          DEBUGERR("Couldnt read quant matrix");
1486                                                  }                                                  }
1487                                                  else                                                  else
1488                                                  {                                                  {
# Line 1156  Line 1519 
1519                          HFONT hFont;                          HFONT hFont;
1520                          LOGFONT lfData;                          LOGFONT lfData;
1521    
1522                          SetDlgItemText(hDlg, IDC_BUILD, __TIME__ ", " __DATE__);                          SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1523                            SetDlgItemText(hDlg, IDC_SPECIAL_BUILD, XVID_SPECIAL_BUILD);
1524    
1525                            init_param.cpu_flags = XVID_CPU_CHKONLY;
1526                          xvid_init(NULL, 0, &init_param, 0);                          xvid_init(NULL, 0, &init_param, 0);
1527                          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));
1528                          SetDlgItemText(hDlg, IDC_CORE, core);                          SetDlgItemText(hDlg, IDC_CORE, core);

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.20.2.6

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