[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 102, Fri Apr 5 14:42:37 2002 UTC
# Line 23  Line 23 
23   *   *
24   *      History:   *      History:
25   *   *
26     *      04.04.2002      interlacing support
27     *                              hinted ME support
28     *      24.03.2002      daniel smith <danielsmith@astroboymail.com>
29     *                              added Foxer's new CBR engine
30     *                              - cbr_buffer is being used as reaction delay (quick hack)
31     *      23.03.2002      daniel smith <danielsmith@astroboymail.com>
32     *                              added load defaults button
33     *                              merged foxer's alternative 2-pass code (2-pass alt tab)
34     *                              added proper tooltips
35     *                              moved registry data into reg_ints/reg_strs arrays
36     *                              added DEBUGERR output on errors instead of returning
37   *      16.03.2002      daniel smith <danielsmith@astroboymail.com>   *      16.03.2002      daniel smith <danielsmith@astroboymail.com>
38   *                              rewrote/restructured most of file   *                              rewrote/restructured most of file
39   *                              added tooltips (kind of - dirty message hook method)   *                              added tooltips (kind of - dirty message hook method)
# Line 49  Line 60 
60  #include "resource.h"  #include "resource.h"
61    
62    
63    /* registry info structs */
64    
65    CONFIG reg;
66    
67    REG_INT const reg_ints[] = {
68            {"mode",                                        &reg.mode,                                              DLG_MODE_CBR},
69            {"bitrate",                                     &reg.bitrate,                                   900000},
70            {"quality",                                     &reg.quality,                                   85},
71            {"quant",                                       &reg.quant,                                             5},
72            {"rc_buffersize",                       &reg.rc_buffersize,                             16},
73    
74            {"motion_search",                       &reg.motion_search,                             5},
75            {"quant_type",                          &reg.quant_type,                                0},
76            {"fourcc_used",                         &reg.fourcc_used,                               0},
77            {"max_key_interval",            &reg.max_key_interval,                  300},
78            {"lum_masking",                         &reg.lum_masking,                               0},
79            {"interlacing",                         &reg.interlacing,                               0},
80    
81            {"min_iquant",                          &reg.min_iquant,                                1},
82            {"max_iquant",                          &reg.max_iquant,                                31},
83            {"min_pquant",                          &reg.min_pquant,                                1},
84            {"max_pquant",                          &reg.max_pquant,                                31},
85    
86            {"desired_size",                        &reg.desired_size,                              570000},
87            {"keyframe_boost",                      &reg.keyframe_boost,                    20},
88            {"min_key_interval",            &reg.min_key_interval,                  6},
89            {"discard1pass",                        &reg.discard1pass,                              1},
90            {"dummy2pass",                          &reg.dummy2pass,                                0},
91            {"curve_compression_high",      &reg.curve_compression_high,    25},
92            {"curve_compression_low",       &reg.curve_compression_low,             10},
93            {"use_alt_curve",                       &reg.use_alt_curve,                             0},
94            {"alt_curve_use_auto",          &reg.alt_curve_use_auto,                1},
95            {"alt_curve_auto_str",          &reg.alt_curve_auto_str,                50},
96            {"alt_curve_use_auto_bonus_bias",       &reg.alt_curve_use_auto_bonus_bias,     1},
97            {"alt_curve_bonus_bias",        &reg.alt_curve_bonus_bias,              50},
98            {"alt_curve_type",                      &reg.alt_curve_type,                    1},
99            {"alt_curve_high_dist",         &reg.alt_curve_high_dist,               300},
100            {"alt_curve_low_dist",          &reg.alt_curve_low_dist,                300},
101            {"alt_curve_min_rel_qual",      &reg.alt_curve_min_rel_qual,    50},
102            {"bitrate_payback_delay",       &reg.bitrate_payback_delay,             240},
103            {"bitrate_payback_method",      &reg.bitrate_payback_method,    0},
104            {"hinted_me",                           &reg.hinted_me,                                 0},
105    
106            {"credits_start",                       &reg.credits_start,                             0},
107            {"credits_start_begin",         &reg.credits_start_begin,               0},
108            {"credits_start_end",           &reg.credits_start_end,                 0},
109            {"credits_end",                         &reg.credits_end,                               0},
110            {"credits_end_begin",           &reg.credits_end_begin,                 0},
111            {"credits_end_end",                     &reg.credits_end_end,                   0},
112    
113            {"credits_mode",                        &reg.credits_mode,                              0},
114            {"credits_rate",                        &reg.credits_rate,                              20},
115            {"credits_quant_i",                     &reg.credits_quant_i,                   20},
116            {"credits_quant_p",                     &reg.credits_quant_p,                   20},
117            {"credits_start_size",          &reg.credits_start_size,                10000},
118            {"credits_end_size",            &reg.credits_end_size,                  10000}
119    };
120    
121    REG_STR const reg_strs[] = {
122            {"hintfile",                            reg.hintfile,                                   CONFIG_HINTFILE},
123            {"stats1",                                      reg.stats1,                                             CONFIG_2PASS_1_FILE},
124            {"stats2",                                      reg.stats2,                                             CONFIG_2PASS_2_FILE}
125    //      {"build",                                       reg.build,                                              XVID_BUILD}
126    };
127    
128  /* get config settings from registry */  /* get config settings from registry */
129    
 #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);}  
130  #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)));}
131    
132  void config_reg_get(CONFIG * config)  void config_reg_get(CONFIG * config)
# Line 60  Line 134 
134          HKEY hKey;          HKEY hKey;
135          DWORD size;          DWORD size;
136          XVID_INIT_PARAM init_param;          XVID_INIT_PARAM init_param;
137            int i;
138    
139          init_param.cpu_flags = 0;          init_param.cpu_flags = 0;
140          xvid_init(0, 0, &init_param, NULL);          xvid_init(0, 0, &init_param, NULL);
# Line 67  Line 142 
142    
143          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);
144    
145          REG_GET_N("mode",                                       config->mode,                                   DLG_MODE_CBR);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
146          REG_GET_N("bitrate",                            config->bitrate,                                900000);          {
147          REG_GET_N("quality",                            config->quality,                                85);                  size = sizeof(int);
148          REG_GET_N("quant",                                      config->quant,                                  5);  
149          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)
150                    {
151          REG_GET_N("motion_search",                      config->motion_search,                  5);                          *reg_ints[i].config_int = reg_ints[i].def;
152          REG_GET_N("quant_type",                         config->quant_type,                             0);                  }
153          REG_GET_N("fourcc_used",                        config->fourcc_used,                    0);          }
154          REG_GET_N("max_key_interval",           config->max_key_interval,               300);  
155          REG_GET_N("lum_masking",                        config->lum_masking,                    0);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
156            {
157          REG_GET_N("min_iquant",                         config->min_iquant,                             1);                  size = MAX_PATH;
158          REG_GET_N("max_iquant",                         config->max_iquant,                             31);  
159          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)
160          REG_GET_N("max_pquant",                         config->max_pquant,                             31);                  {
161                            memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
162          REG_GET_N("desired_size",                       config->desired_size,                   570000);                  }
163          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);  
164    
165          {          {
166                  BYTE default_qmatrix_intra[] = {                  BYTE default_qmatrix_intra[] = {
# Line 133  Line 185 
185                          23,24,25,27,28,30,31,33                          23,24,25,27,28,30,31,33
186                  };                  };
187    
188                  REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra);                  REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);
189                  REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter);                  REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);
190          }          }
191    
192            memcpy(config, &reg, sizeof(CONFIG));
193    
194          RegCloseKey(hKey);          RegCloseKey(hKey);
195  }  }
196    
197    
198  /* put config settings in registry */  /* put config settings in registry */
199    
 #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)  
200  #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)))
201    
202  void config_reg_set(CONFIG * config)  void config_reg_set(CONFIG * config)
203  {  {
204          HKEY hKey;          HKEY hKey;
205          DWORD dispo;          DWORD dispo;
206            int i;
207    
208          if (RegCreateKeyEx(          if (RegCreateKeyEx(
209                          XVID_REG_KEY,                          XVID_REG_KEY,
# Line 167  Line 220 
220                  return;                  return;
221          }          }
222    
223          REG_SET_N("mode",                                       config->mode);          memcpy(&reg, config, sizeof(CONFIG));
224          REG_SET_N("bitrate",                            config->bitrate);  
225          REG_SET_N("quality",                            config->quality);          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)
226          REG_SET_N("quant",                                      config->quant);          {
227          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));
228            }
229          REG_SET_N("motion_search",                      config->motion_search);  
230          REG_SET_N("quant_type",                         config->quant_type);          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)
231          REG_SET_N("fourcc_used",                        config->fourcc_used);          {
232          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);
233          REG_SET_N("lum_masking",                        config->lum_masking);          }
234    
235          REG_SET_N("min_iquant",                         config->min_iquant);          REG_SET_B("qmatrix_intra", reg.qmatrix_intra);
236          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);  
237    
238          RegCloseKey(hKey);          RegCloseKey(hKey);
239  }  }
# Line 228  Line 251 
251                  return;                  return;
252          }          }
253    
254          if (RegDeleteKey(XVID_REG_KEY, XVID_REG_CHILD))          if (RegDeleteKey(hKey, XVID_REG_CHILD))
255          {          {
256                  DEBUG1("Couldn't delete registry key - ", GetLastError());                  DEBUG1("Couldn't delete registry key - ", GetLastError());
257                  return;                  return;
258          }          }
259    
260            RegCloseKey(hKey);
261          config_reg_get(config);          config_reg_get(config);
262            config_reg_set(config);
263  }  }
264    
265    
# Line 394  Line 419 
419          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);          psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);
420          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);          psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);
421          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);          psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);
422            psp[DLG_2PASSALT].pszTemplate   = MAKEINTRESOURCE(IDD_2PASSALT);
423          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);          psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);
424          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);          psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);
425    
# Line 421  Line 447 
447  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))  #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))
448  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)  #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)
449    
450    #define MOD_CBR
451    
452  void adv_mode(HWND hDlg, int mode)  void adv_mode(HWND hDlg, int mode)
453  {  {
454          // create arrays of controls to be disabled for each mode          // create arrays of controls to be disabled for each mode
# Line 485  Line 513 
513          int i;          int i;
514    
515          // first perform checkbox-based enable/disable          // first perform checkbox-based enable/disable
516            CONTROLDLG(IDC_HINTFILE,                        ISDLGSET(IDC_HINTEDME));
517            CONTROLDLG(IDC_HINT_BROWSE,                     ISDLGSET(IDC_HINTEDME));
518    
519            CONTROLDLG(IDC_USEAUTO,                         ISDLGSET(IDC_USEALT));
520            CONTROLDLG(IDC_AUTOSTR,                         ISDLGSET(IDC_USEALT) && ISDLGSET(IDC_USEAUTO));
521            CONTROLDLG(IDC_USEAUTOBONUS,            ISDLGSET(IDC_USEALT));
522            CONTROLDLG(IDC_BONUSBIAS,                       (ISDLGSET(IDC_USEALT) && !(ISDLGSET(IDC_USEAUTOBONUS))));
523            CONTROLDLG(IDC_CURVETYPE,                       ISDLGSET(IDC_USEALT));
524            CONTROLDLG(IDC_ALTCURVEHIGH,            ISDLGSET(IDC_USEALT));
525            CONTROLDLG(IDC_ALTCURVELOW,                     ISDLGSET(IDC_USEALT));
526            CONTROLDLG(IDC_MINQUAL,                         ISDLGSET(IDC_USEALT) && !(ISDLGSET(IDC_USEAUTO)));
527    
528          CONTROLDLG(IDC_CREDITS_START_BEGIN,     ISDLGSET(IDC_CREDITS_START));          CONTROLDLG(IDC_CREDITS_START_BEGIN,     ISDLGSET(IDC_CREDITS_START));
529          CONTROLDLG(IDC_CREDITS_START_END,       ISDLGSET(IDC_CREDITS_START));          CONTROLDLG(IDC_CREDITS_START_END,       ISDLGSET(IDC_CREDITS_START));
530    
# Line 524  Line 564 
564                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
565                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);                  SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
566                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);
567                    CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);
568                  break;                  break;
569    
570          case DLG_QUANT :          case DLG_QUANT :
# Line 545  Line 586 
586                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));                  CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));
587                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));                  CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));
588    
589                    CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED);
590                    SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile);
591                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);                  SetDlgItemText(hDlg, IDC_STATS1, config->stats1);
592                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);                  SetDlgItemText(hDlg, IDC_STATS2, config->stats2);
593                  break;                  break;
594    
595            case DLG_2PASSALT :
596                    CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);
597    
598                    SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);
599                    SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);
600                    SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);
601                    SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);
602    
603                    CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);
604                    SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);
605    
606                    CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);
607                    SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);
608                    break;
609    
610          case DLG_CREDITS :          case DLG_CREDITS :
611                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);                  CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);
612                  SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);                  SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);
# Line 608  Line 666 
666                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);                  config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
667                  config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval);                  config->max_key_interval = config_get_int(hDlg, IDC_MAXKEY, config->max_key_interval);
668                  config->lum_masking = ISDLGSET(IDC_LUMMASK);                  config->lum_masking = ISDLGSET(IDC_LUMMASK);
669                    config->interlacing = ISDLGSET(IDC_INTERLACING);
670                  break;                  break;
671    
672          case DLG_QUANT :          case DLG_QUANT :
# Line 631  Line 690 
690                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
691                  config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);                  config->bitrate_payback_delay = config_get_int(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);
692                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);                  config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);
693                    config->hinted_me = ISDLGSET(IDC_HINTEDME);
694    
695                    if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0)
696                    {
697                            lstrcpy(config->hintfile, CONFIG_HINTFILE);
698                    }
699                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)                  if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)
700                  {                  {
701                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);                          lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);
# Line 647  Line 711 
711                  CONSTRAINVAL(config->curve_compression_low, 0, 100);                  CONSTRAINVAL(config->curve_compression_low, 0, 100);
712                  break;                  break;
713    
714            case DLG_2PASSALT :
715                    config->use_alt_curve = ISDLGSET(IDC_USEALT);
716    
717                    config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO);
718                    config->alt_curve_auto_str = config_get_int(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);
719    
720                    config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS);
721                    config->alt_curve_bonus_bias = config_get_int(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);
722    
723                    config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);
724                    config->alt_curve_high_dist = config_get_int(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);
725                    config->alt_curve_low_dist = config_get_int(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);
726                    config->alt_curve_min_rel_qual = config_get_int(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);
727                    break;
728    
729          case DLG_CREDITS :          case DLG_CREDITS :
730                  config->credits_start = ISDLGSET(IDC_CREDITS_START);                  config->credits_start = ISDLGSET(IDC_CREDITS_START);
731                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);
# Line 726  Line 805 
805          }          }
806  }  }
807    
 /* monitor mouse events to dialog controls for help text */  
808    
809  HHOOK hHook;  /* enumerates child windows, assigns tooltips */
 HWND hParent;  
810    
811  LRESULT CALLBACK msg_proc(int nCode, WPARAM wParam, LPARAM lParam)  BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
812  {  {
         MSG* pmsg = (MSG *)lParam;  
   
         if (pmsg->message == WM_MOUSEMOVE)  
         {  
                 if (pmsg->hwnd == hParent)  
                 {  
                         SetDlgItemText(hParent, IDC_STATIC_HELP, XVID_HELP);  
                 }  
                 else if (IsChild(hParent, pmsg->hwnd))  
                 {  
                         char *message;  
813                          char help[500];                          char help[500];
814    
815                          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)  
816                          {                          {
817                                  switch (mode)                  TOOLINFO ti;
                                 {  
                                 case DLG_MODE_2PASS_2_INT :  
                                         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;  
818    
819                                  case DLG_MODE_VBR_QUAL :                  ti.cbSize = sizeof(TOOLINFO);
820                                          message = "Set the target video quality";                  ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
821                                          break;                  ti.hwnd = GetParent(hWnd);
822                    ti.uId  = (LPARAM)hWnd;
823                    ti.lpszText = help;
824    
825                                  case DLG_MODE_VBR_QUANT :                  SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
                                         message = "Set the fixed quantizer for encoding";  
                                         break;  
                                 }  
                                 lstrcpy(help, message);  
                         }  
                         else if (!LoadString(hInst, GetDlgCtrlID(pmsg->hwnd), help, 500))  
                         {  
                                 lstrcpy(help, XVID_HELP);  
                         }  
   
                         SetDlgItemText(hParent, IDC_STATIC_HELP, help);  
                 }  
826          }          }
827    
828          return (CallNextHookEx(hHook, nCode, wParam, lParam));          return TRUE;
829  }  }
830    
831    
# Line 810  Line 852 
852    
853                  SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);                  SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
854                  SetDlgItemInt(hDlg, IDC_CBRBUFFER, config->rc_buffersize, FALSE);                  SetDlgItemInt(hDlg, IDC_CBRBUFFER, config->rc_buffersize, FALSE);
                 SetDlgItemText(hDlg, IDC_STATIC_HELP, XVID_HELP);  
   
                 hHook = SetWindowsHookEx(WH_GETMESSAGE, msg_proc, 0, GetCurrentThreadId());  
855    
856                  main_slider(hDlg, config);                  InitCommonControls();
                 main_value(hDlg, config);  
                 break;  
857    
858          case WM_ACTIVATE :                  if (hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
859                  if (LOWORD(wParam) != WA_INACTIVE)                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
860                                    NULL, NULL, hInst, NULL))
861                  {                  {
862                          hParent = hDlg;                          SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
863                            SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
864                            SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
865    
866                            EnumChildWindows(hDlg, enum_tooltips, 0);
867                  }                  }
                 return 0;  
868    
869          case WM_DESTROY :                  main_slider(hDlg, config);
870                  UnhookWindowsHookEx(hHook);                  main_value(hDlg, config);
871                  break;                  break;
872    
873          case WM_HSCROLL :          case WM_HSCROLL :
# Line 856  Line 897 
897                                  config_reg_set(config);                                  config_reg_set(config);
898                          }                          }
899                  }                  }
900                    else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)
901                    {
902                            config_reg_default(config);
903    
904                            SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
905                            SetDlgItemInt(hDlg, IDC_CBRBUFFER, config->rc_buffersize, FALSE);
906    
907                            main_slider(hDlg, config);
908                            main_value(hDlg, config);
909                    }
910                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)                  else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)
911                  {                  {
912                          int value = config_get_int(hDlg, IDC_VALUE, 1);                          int value = config_get_int(hDlg, IDC_VALUE, 1);
# Line 935  Line 986 
986                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
987                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");                          SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
988                  }                  }
989                    else if (psi->page == DLG_2PASSALT)
990                    {
991                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");
992                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");
993                            SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");
994                    }
995    
996                    if (hTooltip)
997                    {
998                            EnumChildWindows(hDlg, enum_tooltips, 0);
999                    }
1000    
                 SetDlgItemText(hDlg, IDC_STATIC_HELP, XVID_HELP);  
1001                  adv_upload(hDlg, psi->page, psi->config);                  adv_upload(hDlg, psi->page, psi->config);
1002                  adv_mode(hDlg, psi->config->mode);                  adv_mode(hDlg, psi->config->mode);
1003                  break;                  break;
# Line 946  Line 1007 
1007                  {                  {
1008                          switch (LOWORD(wParam))                          switch (LOWORD(wParam))
1009                          {                          {
1010                            case IDC_HINTEDME :
1011                            case IDC_USEALT :
1012                            case IDC_USEAUTO :
1013                            case IDC_USEAUTOBONUS :
1014                          case IDC_CREDITS_START :                          case IDC_CREDITS_START :
1015                          case IDC_CREDITS_END :                          case IDC_CREDITS_END :
1016                          case IDC_CREDITS_RATE_RADIO :                          case IDC_CREDITS_RATE_RADIO :
# Line 957  Line 1022 
1022                                  break;                                  break;
1023                          }                          }
1024                  }                  }
1025                  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)
1026                  {                  {
1027                          OPENFILENAME ofn;                          OPENFILENAME ofn;
1028                          char tmp[MAX_PATH];                          char tmp[MAX_PATH];
# Line 974  Line 1039 
1039                          ofn.nMaxFile = MAX_PATH;                          ofn.nMaxFile = MAX_PATH;
1040                          ofn.Flags = OFN_PATHMUSTEXIST;                          ofn.Flags = OFN_PATHMUSTEXIST;
1041    
1042                          // display save box for stats1 using 1st-pass                          if (LOWORD(wParam) == IDC_HINT_BROWSE)
1043                          if (LOWORD(wParam) == IDC_STATS1_BROWSE &&                          {
1044                                    ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0";
1045                                    if (GetOpenFileName(&ofn))
1046                                    {
1047                                            SetDlgItemText(hDlg, IDC_HINTFILE, tmp);
1048                                    }
1049                            }
1050                            else if (LOWORD(wParam) == IDC_STATS1_BROWSE &&
1051                                  psi->config->mode == DLG_MODE_2PASS_1)                                  psi->config->mode == DLG_MODE_2PASS_1)
1052                          {                          {
1053                                  ofn.Flags |= OFN_OVERWRITEPROMPT;                                  ofn.Flags |= OFN_OVERWRITEPROMPT;
# Line 1001  Line 1073 
1073          case WM_NOTIFY :          case WM_NOTIFY :
1074                  switch (((NMHDR *)lParam)->code)                  switch (((NMHDR *)lParam)->code)
1075                  {                  {
                 case PSN_SETACTIVE :  
                         hParent = hDlg;  
                         break;  
   
1076                  case PSN_KILLACTIVE :                  case PSN_KILLACTIVE :
1077                          /* validate */                          /* validate */
1078                          adv_download(hDlg, psi->page, psi->config);                          adv_download(hDlg, psi->page, psi->config);
# Line 1040  Line 1108 
1108                  SetWindowLong(hDlg, GWL_USERDATA, lParam);                  SetWindowLong(hDlg, GWL_USERDATA, lParam);
1109                  config = (CONFIG*)lParam;                  config = (CONFIG*)lParam;
1110                  quant_upload(hDlg, config);                  quant_upload(hDlg, config);
                 break;  
1111    
1112          case WM_ACTIVATE :                  if (hTooltip)
                 if (LOWORD(wParam) != WA_INACTIVE)  
1113                  {                  {
1114                          hParent = hDlg;                          EnumChildWindows(hDlg, enum_tooltips, 0);
1115                  }                  }
1116                  return 0;                  break;
1117    
1118          case WM_COMMAND :          case WM_COMMAND :
1119                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)
# Line 1091  Line 1157 
1157    
1158                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1159                                          {                                          {
1160                                                  DEBUG("Couldn't save quant matrix");                                                  DEBUGERR("Couldn't save quant matrix");
1161                                          }                                          }
1162                                          else                                          else
1163                                          {                                          {
1164                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))
1165                                                  {                                                  {
1166                                                          DEBUG("Couldnt write quant matrix");                                                          DEBUGERR("Couldnt write quant matrix");
1167                                                  }                                                  }
1168                                          }                                          }
1169    
# Line 1113  Line 1179 
1179    
1180                                          if (hFile == INVALID_HANDLE_VALUE)                                          if (hFile == INVALID_HANDLE_VALUE)
1181                                          {                                          {
1182                                                  DEBUG("Couldn't load quant matrix");                                                  DEBUGERR("Couldn't load quant matrix");
1183                                          }                                          }
1184                                          else                                          else
1185                                          {                                          {
1186                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))
1187                                                  {                                                  {
1188                                                          DEBUG("Couldnt read quant matrix");                                                          DEBUGERR("Couldnt read quant matrix");
1189                                                  }                                                  }
1190                                                  else                                                  else
1191                                                  {                                                  {
# Line 1156  Line 1222 
1222                          HFONT hFont;                          HFONT hFont;
1223                          LOGFONT lfData;                          LOGFONT lfData;
1224    
1225                          SetDlgItemText(hDlg, IDC_BUILD, __TIME__ ", " __DATE__);                          SetDlgItemText(hDlg, IDC_BUILD, XVID_BUILD);
1226    
1227                          xvid_init(NULL, 0, &init_param, 0);                          xvid_init(NULL, 0, &init_param, 0);
1228                          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));

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

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