[svn] / branches / dev-api-4 / xvidcore / vfw / src / config.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/vfw/src/config.c

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

revision 889, Sat Feb 22 08:24:01 2003 UTC revision 1272, Thu Dec 18 01:19:45 2003 UTC
# Line 60  Line 60 
60  #include <shlobj.h>  #include <shlobj.h>
61  #include <prsht.h>  #include <prsht.h>
62    
63  #include <xvid.h>       // XviD API  #include <stdio.h>  /* sprintf */
64    #include <xvid.h>       /* XviD API */
65    
66  #include "codec.h"  #include "debug.h"
67  #include "config.h"  #include "config.h"
68  #include "resource.h"  #include "resource.h"
69    
70    
71    #define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z;
72    #define IsDlgChecked(hwnd,idc)  (IsDlgButtonChecked(hwnd,idc) == BST_CHECKED)
73    #define CheckDlg(hwnd,idc,value) CheckDlgButton(hwnd,idc, value?BST_CHECKED:BST_UNCHECKED)
74    #define EnableDlgWindow(hwnd,idc,state) EnableWindow(GetDlgItem(hwnd,idc),state)
75    
76  /* registry info structs */  HINSTANCE g_hInst;
77    HWND g_hTooltip;
78    
79    /* enumerates child windows, assigns tooltips */
80    BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)
81    {
82            char help[500];
83    
84        if (LoadString(g_hInst, GetDlgCtrlID(hWnd), help, 500))
85            {
86                    TOOLINFO ti;
87                    ti.cbSize = sizeof(TOOLINFO);
88                    ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
89                    ti.hwnd = GetParent(hWnd);
90                    ti.uId  = (LPARAM)hWnd;
91                    ti.lpszText = help;
92                    SendMessage(g_hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);
93            }
94    
95            return TRUE;
96    }
97    
98    
99    /* ===================================================================================== */
100    /* MPEG-4 PROFILES/LEVELS ============================================================== */
101    /* ===================================================================================== */
102    
103    
104    
105    /* default vbv_occupancy is (64/170)*vbv_buffer_size */
106    
107    const profile_t profiles[] =
108    {
109    /*    name                 p@l,    w    h  fps  obj  Tvmv  vmv    vcv   ac%     vbv      pkt   kbps  flags */
110        { "Simple @ L0",       0x08,  176, 144, 15,  1,  198,   99,   1485, 100,  10*16368,  2048,   64, 0 },
111            /* simple@l0: max f_code=1, intra_dc_vlc_threshold=0 */
112            /* if ac preidition is used, adaptive quantization must not be used */
113            /* <=qcif must be used */
114            { "Simple @ L1",       0x01,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  2048,   64, PROFILE_ADAPTQUANT },
115            { "Simple @ L2",       0x02,  352, 288, 15,  4,  792,  396,   5940, 100,  40*16368,  4096,  128, PROFILE_ADAPTQUANT },
116            { "Simple @ L3",       0x03,  352, 288, 15,  4,  792,  396,  11880, 100,  40*16368,  8192,  384, PROFILE_ADAPTQUANT },
117    
118            { "ARTS @ L1",         0x91,  176, 144, 15,  4,  198,   99,   1485, 100,  10*16368,  8192,   64, PROFILE_ARTS },
119            { "ARTS @ L2",         0x92,  352, 288, 15,  4,  792,  396,   5940, 100,  40*16368, 16384,  128, PROFILE_ARTS },
120            { "ARTS @ L3",         0x93,  352, 288, 30,  4,  792,  396,  11880, 100,  40*16368, 16384,  384, PROFILE_ARTS },
121            { "ARTS @ L4",         0x94,  352, 288, 30, 16,  792,  396,  11880, 100,  80*16368, 16384, 2000, PROFILE_ARTS },
122    
123            { "AS @ L0",           0xf0,  176, 144, 30,  1,  297,   99,   2970, 100,  10*16368,  2048,  128, PROFILE_AS },
124            { "AS @ L1",           0xf1,  176, 144, 30,  4,  297,   99,   2970, 100,  10*16368,  2048,  128, PROFILE_AS },
125            { "AS @ L2",           0xf2,  352, 288, 15,  4, 1188,  396,   5940, 100,  40*16368,  4096,  384, PROFILE_AS },
126            { "AS @ L3",           0xf3,  352, 288, 30,  4, 1188,  396,  11880, 100,  40*16368,  4096,  768, PROFILE_AS },
127     /*  ISMA Profile 1, (ASP) @ L3b (CIF, 1.5 Mb/s) CIF(352x288), 30fps, 1.5Mbps max ??? */
128            { "AS @ L4",           0xf4,  352, 576, 30,  4, 2376,  792,  23760,  50,  80*16368,  8192, 3000, PROFILE_AS },
129            { "AS @ L5",           0xf5,  720, 576, 30,  4, 4860, 1620,  48600,  25, 112*16368, 16384, 8000, PROFILE_AS },
130    
131    #ifdef DXN_PROFILES
132            { "DXN Handheld",          0x00,  176, 144, 15, -1,  198,   99,   1485, 100,  16*16368,    -1,  128, PROFILE_ADAPTQUANT },
133            { "DXN Portable NTSC", 0x00,  352, 240, 30, -1,  990,  330,   9900, 100,  64*16368,    -1,  768, PROFILE_ADAPTQUANT|PROFILE_BVOP },
134            { "DXN Portable PAL",  0x00,  352, 288, 25, -1, 1188,  396,   9900, 100,  64*16368,    -1,  768, PROFILE_ADAPTQUANT|PROFILE_BVOP },
135            { "DXN HT NTSC",           0x00,  720, 480, 30, -1, 4050, 1350,  40500, 100, 192*16368,    -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
136            { "DXN HT PAL",        0x00,  720, 576, 25, -1, 4860, 1620,  40500, 100, 192*16368,    -1, 4000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
137            { "DXN HDTV",          0x00, 1280, 720, 30, -1,10800, 3600, 108000, 100, 384*16368,    -1, 8000, PROFILE_ADAPTQUANT|PROFILE_BVOP|PROFILE_INTERLACE },
138    #endif
139        { "(unrestricted)",    0x00,    0,   0,  0,  0,    0,    0,      0, 100,   0*16368,     0,    0, 0xffffffff },
140    };
141    
142    
143    /* ===================================================================================== */
144    /* REGISTRY ============================================================================ */
145    /* ===================================================================================== */
146    
147    /* registry info structs */
148  CONFIG reg;  CONFIG reg;
149    
150  REG_INT const reg_ints[] = {  static const REG_INT reg_ints[] = {
151          {"mode",                                        &reg.mode,                                              DLG_MODE_CBR},          {"mode",                                        &reg.mode,                                              RC_MODE_1PASS},
152          {"quality",                                     &reg.quality,                                   85},          {"bitrate",                                     &reg.bitrate,                                   700},
153          {"quant",                                       &reg.quant,                                             5},      {"desired_size",                    &reg.desired_size,                              570000},
154          {"rc_bitrate",                          &reg.rc_bitrate,                                900000},      {"use_2pass_bitrate",       &reg.use_2pass_bitrate,         0},
         {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor,      16},  
         {"rc_averaging_period",         &reg.rc_averaging_period,               100},  
         {"rc_buffer",                           &reg.rc_buffer,                                 100},  
155    
156          {"motion_search",                       &reg.motion_search,                             6},      /* profile */
157          {"quant_type",                          &reg.quant_type,                                0},          {"quant_type",                          &reg.quant_type,                                0},
         {"fourcc_used",                         &reg.fourcc_used,                               0},  
         {"vhq_mode",                            &reg.vhq_mode,                                  0},  
         {"max_key_interval",            &reg.max_key_interval,                  300},  
         {"min_key_interval",            &reg.min_key_interval,                  1},  
158          {"lum_masking",                         &reg.lum_masking,                               0},          {"lum_masking",                         &reg.lum_masking,                               0},
159          {"interlacing",                         &reg.interlacing,                               0},          {"interlacing",                         &reg.interlacing,                               0},
160          {"qpel",                                        &reg.qpel,                                              0},          {"qpel",                                        &reg.qpel,                                              0},
161          {"gmc",                                         &reg.gmc,                                               0},          {"gmc",                                         &reg.gmc,                                               0},
         {"chromame",                            &reg.chromame,                                  0},  
 //added by koepi for gruel's greyscale_mode  
         {"greyscale",                           &reg.greyscale,                                 0},  
 // end of koepi's additions  
         {"max_bframes",                         &reg.max_bframes,                               -1},  
         {"bquant_ratio",                        &reg.bquant_ratio,                              150},  
         {"bquant_offset",                       &reg.bquant_offset,                             100},  
         {"packed",                                      &reg.packed,                                    0},  
         {"dx50bvop",                            &reg.dx50bvop,                                  1},  
         {"debug",                                       &reg.debug,                                             0},  
162          {"reduced_resolution",          &reg.reduced_resolution,                0},          {"reduced_resolution",          &reg.reduced_resolution,                0},
163          {"chroma_opt",                          &reg.chroma_opt,                                0},      {"use_bvop",                                &reg.use_bvop,                          0},
164            {"max_bframes",                         &reg.max_bframes,                               2},
165            {"bquant_ratio",                        &reg.bquant_ratio,                              150},   /* 100-base float */
166            {"bquant_offset",                       &reg.bquant_offset,                             100},   /* 100-base float */
167            {"packed",                                      &reg.packed,                                    0},
168            {"closed_gov",                          &reg.closed_gov,                                1},
169            {"aspect_ratio",                        &reg.display_aspect_ratio,              0},
170    
171        /* zones */
172        {"num_zones",               &reg.num_zones,                 1},
173    
174        /* single pass */
175            {"rc_reaction_delay_factor",&reg.rc_reaction_delay_factor,      16},
176            {"rc_averaging_period",         &reg.rc_averaging_period,               100},
177            {"rc_buffer",                           &reg.rc_buffer,                         100},
178    
179        /* 2pass1 */
180        {"discard1pass",                    &reg.discard1pass,                              1},
181    
182        /* 2pass2 */
183            {"keyframe_boost",                      &reg.keyframe_boost,                    0},
184            {"kfreduction",                         &reg.kfreduction,                               20},
185            {"kfthreshold",                         &reg.kfthreshold,                               1},
186            {"curve_compression_high",      &reg.curve_compression_high,    0},
187            {"curve_compression_low",       &reg.curve_compression_low,             0},
188            {"overflow_control_strength", &reg.overflow_control_strength, 5},
189            {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 5},
190            {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 5},
191    
192        /* motion */
193        {"motion_search",                   &reg.motion_search,                             6},
194            {"vhq_mode",                            &reg.vhq_mode,                                  0},
195        {"chromame",                                &reg.chromame,                                  0},
196        {"cartoon_mode",                    &reg.cartoon_mode,                              0},
197            {"max_key_interval",            &reg.max_key_interval,                  300},
198          {"frame_drop_ratio",            &reg.frame_drop_ratio,                  0},          {"frame_drop_ratio",            &reg.frame_drop_ratio,                  0},
199    
200        /* quant */
201          {"min_iquant",                          &reg.min_iquant,                                2},          {"min_iquant",                          &reg.min_iquant,                                2},
202          {"max_iquant",                          &reg.max_iquant,                                31},          {"max_iquant",                          &reg.max_iquant,                                31},
203          {"min_pquant",                          &reg.min_pquant,                                2},          {"min_pquant",                          &reg.min_pquant,                                2},
204          {"max_pquant",                          &reg.max_pquant,                                31},          {"max_pquant",                          &reg.max_pquant,                                31},
205            {"min_bquant",                          &reg.min_bquant,                                2},
206            {"max_bquant",                          &reg.max_bquant,                                31},
207        {"trellis_quant",           &reg.trellis_quant,             0},
208    
209          {"desired_size",                        &reg.desired_size,                              570000},      /* debug */
210          {"keyframe_boost",                      &reg.keyframe_boost,                    0},      {"fourcc_used",                             &reg.fourcc_used,                               0},
211          {"discard1pass",                        &reg.discard1pass,                              1},      {"debug",                                   &reg.debug,                                             0x0},
212          {"dummy2pass",                          &reg.dummy2pass,                                0},      {"vop_debug",                               &reg.vop_debug,                                 0},
213  // added by koepi for new two-pass curve treatment      {"display_status",          &reg.display_status,            1},
214          {"kftreshold",                          &reg.kftreshold,                                10},  };
215          {"kfreduction",                         &reg.kfreduction,                               20},  
216  // end of koepi's additions  static const REG_STR reg_strs[] = {
217          {"curve_compression_high",      &reg.curve_compression_high,    0},          {"profile",                                     reg.profile_name,                               "(unrestricted)"},
218          {"curve_compression_low",       &reg.curve_compression_low,             0},      {"stats",                                   reg.stats,                                              CONFIG_2PASS_FILE},
219          {"use_alt_curve",                       &reg.use_alt_curve,                             0},  };
220          {"alt_curve_use_auto",          &reg.alt_curve_use_auto,                1},  
221          {"alt_curve_auto_str",          &reg.alt_curve_auto_str,                30},  
222          {"alt_curve_use_auto_bonus_bias",       &reg.alt_curve_use_auto_bonus_bias,     1},  zone_t stmp;
223          {"alt_curve_bonus_bias",        &reg.alt_curve_bonus_bias,              50},  static const REG_INT reg_zone[] = {
224          {"alt_curve_type",                      &reg.alt_curve_type,                    1},      {"zone%i_frame",            &stmp.frame,                     0},
225          {"alt_curve_high_dist",         &reg.alt_curve_high_dist,               500},      {"zone%i_mode",             &stmp.mode,                      RC_ZONE_WEIGHT},
226          {"alt_curve_low_dist",          &reg.alt_curve_low_dist,                90},      {"zone%i_weight",           &stmp.weight,                    100},      /* 100-base float */
227          {"alt_curve_min_rel_qual",      &reg.alt_curve_min_rel_qual,    50},      {"zone%i_quant",            &stmp.quant,                     500},      /* 100-base float */
228          {"bitrate_payback_delay",       &reg.bitrate_payback_delay,             250},      {"zone%i_type",             &stmp.type,                      XVID_TYPE_AUTO},
229          {"bitrate_payback_method",      &reg.bitrate_payback_method,    0},      {"zone%i_greyscale",        &stmp.greyscale,                 0},
230          {"twopass_max_bitrate",         &reg.twopass_max_bitrate,               10000 * CONFIG_KBPS},      {"zone%i_chroma_opt",       &stmp.chroma_opt,                0},
231          {"twopass_max_overflow_improvement", &reg.twopass_max_overflow_improvement, 60},      {"zone%i_bvop_threshold",   &stmp.bvop_threshold,            0},
232          {"twopass_max_overflow_degradation", &reg.twopass_max_overflow_degradation, 60},  };
233          {"hinted_me",                           &reg.hinted_me,                                 0},  
234    static const BYTE default_qmatrix_intra[] = {
235          {"credits_start",                       &reg.credits_start,                             0},          8, 17,18,19,21,23,25,27,
236          {"credits_start_begin",         &reg.credits_start_begin,               0},          17,18,19,21,23,25,27,28,
237          {"credits_start_end",           &reg.credits_start_end,                 0},          20,21,22,23,24,26,28,30,
238          {"credits_end",                         &reg.credits_end,                               0},          21,22,23,24,26,28,30,32,
239          {"credits_end_begin",           &reg.credits_end_begin,                 0},          22,23,24,26,28,30,32,35,
240          {"credits_end_end",                     &reg.credits_end_end,                   0},          23,24,26,28,30,32,35,38,
241            25,26,28,30,32,35,38,41,
242  // added by koepi for greyscale credits          27,28,30,32,35,38,41,45
         {"credits_greyscale",           &reg.credits_greyscale,                 0},  
 // end of koepi's addition  
         {"credits_mode",                        &reg.credits_mode,                              0},  
         {"credits_rate",                        &reg.credits_rate,                              20},  
         {"credits_quant_i",                     &reg.credits_quant_i,                   20},  
         {"credits_quant_p",                     &reg.credits_quant_p,                   20},  
         {"credits_start_size",          &reg.credits_start_size,                10000},  
         {"credits_end_size",            &reg.credits_end_size,                  10000},  
   
         /* decoder */  
         {"deblock_y",                           &reg.deblock_y,                                 0},  
         {"deblock_uv",                          &reg.deblock_uv,                                0}  
243  };  };
244    
245  REG_STR const reg_strs[] = {  static const BYTE default_qmatrix_inter[] = {
246          {"hintfile",                            reg.hintfile,                                   CONFIG_HINTFILE},          16,17,18,19,20,21,22,23,
247          {"stats1",                                      reg.stats1,                                             CONFIG_2PASS_1_FILE},          17,18,19,20,21,22,23,24,
248          {"stats2",                                      reg.stats2,                                             CONFIG_2PASS_2_FILE}          18,19,20,21,22,23,24,25,
249  //      {"build",                                       reg.build,                                              XVID_BUILD}          19,20,21,22,23,24,26,27,
250            20,21,22,23,25,26,27,28,
251            21,22,23,24,26,27,28,30,
252            22,23,24,26,27,28,30,31,
253            23,24,25,27,28,30,31,33
254  };  };
255    
256  /* get config settings from registry */  
257    
258  #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)));}
259    
260  void config_reg_get(CONFIG * config)  void config_reg_get(CONFIG * config)
261  {  {
262        char tmp[32];
263          HKEY hKey;          HKEY hKey;
264          DWORD size;          DWORD size;
265      int i;      int i,j;
266          xvid_gbl_info_t info;          xvid_gbl_info_t info;
267    
268          memset(&info, 0, sizeof(info));          memset(&info, 0, sizeof(info));
# Line 184  Line 273 
273    
274          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);
275    
276          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)      /* read integer values */
277          {          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) {
278                  size = sizeof(int);                  size = sizeof(int);
279            if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS) {
                 if (RegQueryValueEx(hKey, reg_ints[i].reg_value, 0, 0, (LPBYTE)reg_ints[i].config_int, &size) != ERROR_SUCCESS)  
                 {  
280                          *reg_ints[i].config_int = reg_ints[i].def;                          *reg_ints[i].config_int = reg_ints[i].def;
281                  }                  }
282          }          }
283    
284          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)      /* read string values */
285          {          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) {
286                  size = MAX_PATH;                  size = MAX_PATH;
287                    if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS) {
                 if (RegQueryValueEx(hKey, reg_strs[i].reg_value, 0, 0, (LPBYTE)reg_strs[i].config_str, &size) != ERROR_SUCCESS)  
                 {  
288                          memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);                          memcpy(reg_strs[i].config_str, reg_strs[i].def, MAX_PATH);
289                  }                  }
290          }          }
291    
292          {      reg.profile = 0;
293                  BYTE default_qmatrix_intra[] = {      for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++) {
294                          8, 17,18,19,21,23,25,27,          if (strcmpi(profiles[i].name, reg.profile_name) == 0) {
295                          17,18,19,21,23,25,27,28,              reg.profile = i;
296                          20,21,22,23,24,26,28,30,          }
297                          21,22,23,24,26,28,30,32,      }
                         22,23,24,26,28,30,32,35,  
                         23,24,26,28,30,32,35,38,  
                         25,26,28,30,32,35,38,41,  
                         27,28,30,32,35,38,41,45  
                 };  
298    
299                  BYTE default_qmatrix_inter[] = {      memcpy(config, &reg, sizeof(CONFIG));
                         16,17,18,19,20,21,22,23,  
                         17,18,19,20,21,22,23,24,  
                         18,19,20,21,22,23,24,25,  
                         19,20,21,22,23,24,26,27,  
                         20,21,22,23,25,26,27,28,  
                         21,22,23,24,26,27,28,30,  
                         22,23,24,26,27,28,30,31,  
                         23,24,25,27,28,30,31,33  
                 };  
300    
301                  REG_GET_B("qmatrix_intra", reg.qmatrix_intra, default_qmatrix_intra);  
302                  REG_GET_B("qmatrix_inter", reg.qmatrix_inter, default_qmatrix_inter);      /* read quant matrices */
303            REG_GET_B("qmatrix_intra", config->qmatrix_intra, default_qmatrix_intra);
304            REG_GET_B("qmatrix_inter", config->qmatrix_inter, default_qmatrix_inter);
305    
306    
307        /* read zones */
308        if (config->num_zones>MAX_ZONES) {
309            config->num_zones=MAX_ZONES;
310        }else if (config->num_zones<=0) {
311            config->num_zones = 1;
312          }          }
313    
314          memcpy(config, &reg, sizeof(CONFIG));      for (i=0; i<config->num_zones; i++) {
315                for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++)  {
316                        size = sizeof(int);
317    
318                wsprintf(tmp, reg_zone[j].reg_value, i);
319                        if (RegQueryValueEx(hKey, tmp, 0, 0, (LPBYTE)reg_zone[j].config_int, &size) != ERROR_SUCCESS)
320                                *reg_zone[j].config_int = reg_zone[j].def;
321                }
322    
323            memcpy(&config->zones[i], &stmp, sizeof(zone_t));
324        }
325    
326          RegCloseKey(hKey);          RegCloseKey(hKey);
327  }  }
# Line 243  Line 333 
333    
334  void config_reg_set(CONFIG * config)  void config_reg_set(CONFIG * config)
335  {  {
336        char tmp[64];
337          HKEY hKey;          HKEY hKey;
338          DWORD dispo;          DWORD dispo;
339          int i;          int i,j;
340    
341          if (RegCreateKeyEx(          if (RegCreateKeyEx(
342                          XVID_REG_KEY,                          XVID_REG_KEY,
# Line 258  Line 349 
349                          &hKey,                          &hKey,
350                          &dispo) != ERROR_SUCCESS)                          &dispo) != ERROR_SUCCESS)
351          {          {
352                  DEBUG1("Couldn't create XVID_REG_SUBKEY - ", GetLastError());                  DPRINTF("Couldn't create XVID_REG_SUBKEY - GetLastError=%i", GetLastError());
353                  return;                  return;
354          }          }
355    
356          memcpy(&reg, config, sizeof(CONFIG));          memcpy(&reg, config, sizeof(CONFIG));
357    
358          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT) ; ++i)      /* set integer values */
359          {          for (i=0 ; i<sizeof(reg_ints)/sizeof(REG_INT); i++) {
360                  RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));                  RegSetValueEx(hKey, reg_ints[i].reg_value, 0, REG_DWORD, (LPBYTE)reg_ints[i].config_int, sizeof(int));
361          }          }
362    
363          for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR) ; ++i)      /* set string values */
364          {      strcpy(reg.profile_name, profiles[reg.profile].name);
365            for (i=0 ; i<sizeof(reg_strs)/sizeof(REG_STR); i++) {
366                  RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);                  RegSetValueEx(hKey, reg_strs[i].reg_value, 0, REG_SZ, reg_strs[i].config_str, lstrlen(reg_strs[i].config_str)+1);
367          }          }
368    
369          REG_SET_B("qmatrix_intra", reg.qmatrix_intra);      /* set quant matrices */
370          REG_SET_B("qmatrix_inter", reg.qmatrix_inter);          REG_SET_B("qmatrix_intra", config->qmatrix_intra);
371            REG_SET_B("qmatrix_inter", config->qmatrix_inter);
372    
373        /* set seections */
374        for (i=0; i<config->num_zones; i++) {
375            memcpy(&stmp, &config->zones[i], sizeof(zone_t));
376                for (j=0; j<sizeof(reg_zone)/sizeof(REG_INT); j++)  {
377                wsprintf(tmp, reg_zone[j].reg_value, i);
378                    RegSetValueEx(hKey, tmp, 0, REG_DWORD, (LPBYTE)reg_zone[j].config_int, sizeof(int));
379                }
380        }
381    
382          RegCloseKey(hKey);          RegCloseKey(hKey);
383  }  }
# Line 287  Line 389 
389  {  {
390          HKEY hKey;          HKEY hKey;
391    
392          if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey))          if (RegOpenKeyEx(XVID_REG_KEY, XVID_REG_PARENT, 0, KEY_ALL_ACCESS, &hKey)) {
393          {                  DPRINTF("Couldn't open registry key for deletion - GetLastError=%i", GetLastError());
                 DEBUG1("Couldn't open registry key for deletion - ", GetLastError());  
394                  return;                  return;
395          }          }
396    
397          if (RegDeleteKey(hKey, XVID_REG_CHILD))          if (RegDeleteKey(hKey, XVID_REG_CHILD)) {
398          {                  DPRINTF("Couldn't delete registry key - GetLastError=%i", GetLastError());
                 DEBUG1("Couldn't delete registry key - ", GetLastError());  
399                  return;                  return;
400          }          }
401    
# Line 306  Line 406 
406    
407    
408  /* leaves current config value if dialog item is empty */  /* leaves current config value if dialog item is empty */
   
409  int config_get_int(HWND hDlg, INT item, int config)  int config_get_int(HWND hDlg, INT item, int config)
410  {  {
411          BOOL success = FALSE;          BOOL success = FALSE;
   
412          int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);          int tmp = GetDlgItemInt(hDlg, item, &success, TRUE);
   
413          return (success) ? tmp : config;          return (success) ? tmp : config;
414  }  }
415    
# Line 320  Line 417 
417  int config_get_uint(HWND hDlg, UINT item, int config)  int config_get_uint(HWND hDlg, UINT item, int config)
418  {  {
419          BOOL success = FALSE;          BOOL success = FALSE;
   
420          int tmp = GetDlgItemInt(hDlg, item, &success, FALSE);          int tmp = GetDlgItemInt(hDlg, item, &success, FALSE);
   
421          return (success) ? tmp : config;          return (success) ? tmp : config;
422  }  }
423    
424    
425  /* downloads data from main dialog */  /* we use "100 base" floats */
426    
427  void main_download(HWND hDlg, CONFIG * config)  #define FLOAT_BUF_SZ    20
428  {  int get_dlgitem_float(HWND hDlg, UINT item, int def)
         switch(config->mode)  
429          {          {
430          default :          char buf[FLOAT_BUF_SZ];
         case DLG_MODE_CBR :  
                 config->rc_bitrate = config_get_uint(hDlg, IDC_VALUE, config->rc_bitrate) * CONFIG_KBPS;  
                 break;  
   
         case DLG_MODE_VBR_QUAL :  
                 config->quality = config_get_uint(hDlg, IDC_VALUE, config->quality);  
                 break;  
431    
432          case DLG_MODE_VBR_QUANT :      if (GetDlgItemText(hDlg, item, buf, FLOAT_BUF_SZ) == 0)
433                  config->quant = config_get_uint(hDlg, IDC_VALUE, config->quant);          return def;
                 break;  
434    
435          case DLG_MODE_2PASS_2_INT :          return (int)(atof(buf)*100);
                 config->desired_size = config_get_uint(hDlg, IDC_VALUE, config->desired_size);  
                 break;  
436          }          }
437    
438          config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);  void set_dlgitem_float(HWND hDlg, UINT item, int value)
439    {
440            char buf[FLOAT_BUF_SZ];
441        sprintf(buf, "%.2f", (float)value/100);
442        SetDlgItemText(hDlg, item, buf);
443  }  }
444    
445    
446  /* updates the edit box */  #define HEX_BUF_SZ  16
447    unsigned int get_dlgitem_hex(HWND hDlg, UINT item, unsigned int def)
 void main_value(HWND hDlg, CONFIG* config)  
 {  
         char* text;  
         int value;  
         int enabled = TRUE;  
   
         switch (config->mode)  
448          {          {
449          default :          char buf[HEX_BUF_SZ];
450                  enabled = FALSE;      unsigned int value;
   
         case DLG_MODE_CBR :  
                 text = "Bitrate (Kbps):";  
                 value = config->rc_bitrate / CONFIG_KBPS;  
                 break;  
   
         case DLG_MODE_VBR_QUAL :  
                 text = "Quality:";  
                 value = config->quality;  
                 break;  
451    
452          case DLG_MODE_VBR_QUANT :      if (GetDlgItemText(hDlg, item, buf, HEX_BUF_SZ) == 0)
453                  text = "Quantizer:";          return def;
                 value = config->quant;  
                 break;  
454    
455          case DLG_MODE_2PASS_2_INT :      if (sscanf(buf,"0x%x", &value)==1 || sscanf(buf,"%x", &value)==1) {
456                  text = "Desired size (Kbtyes):";          return value;
                 value = config->desired_size;  
                 break;  
457          }          }
458    
459          SetDlgItemText(hDlg, IDC_VALUE_STATIC, text);      return def;
         SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);  
   
         EnableWindow(GetDlgItem(hDlg, IDC_VALUE_STATIC), enabled);  
         EnableWindow(GetDlgItem(hDlg, IDC_VALUE), enabled);  
460  }  }
461    
462    void set_dlgitem_hex(HWND hDlg, UINT item, int value)
 /* updates the slider */  
   
 void main_slider(HWND hDlg, CONFIG * config)  
 {  
         char* text;  
         long range;  
         int pos;  
         int enabled = TRUE;  
   
         switch (config->mode)  
463          {          {
464          default :          char buf[HEX_BUF_SZ];
465                  enabled = FALSE;      wsprintf(buf, "0x%x", value);
466        SetDlgItemText(hDlg, item, buf);
467    }
468    
469          case DLG_MODE_CBR :  /* ===================================================================================== */
470                  text = "Bitrate (Kbps):";  /* QUANT MATRIX DIALOG ================================================================= */
471                  range = MAKELONG(0,10000);  /* ===================================================================================== */
                 pos = config->rc_bitrate / CONFIG_KBPS;  
                 break;  
472    
473          case DLG_MODE_VBR_QUAL :  void quant_upload(HWND hDlg, CONFIG* config)
474                  text = "Quality:";  {
475                  range = MAKELONG(0,100);          int i;
                 pos = config->quality;  
                 break;  
476    
477          case DLG_MODE_VBR_QUANT :          for (i=0 ; i<64; i++) {
478                  text = "Quantizer:";                  SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE);
479                  range = MAKELONG(1,31);                  SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE);
                 pos = config->quant;  
                 break;  
480          }          }
   
         SetDlgItemText(hDlg, IDC_SLIDER_STATIC, text);  
         SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, range);  
         SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, pos);  
   
         EnableWindow(GetDlgItem(hDlg, IDC_SLIDER_STATIC), enabled);  
         EnableWindow(GetDlgItem(hDlg, IDC_SLIDER), enabled);  
481  }  }
482    
483    
484  /* load advanced options property sheet */  void quant_download(HWND hDlg, CONFIG* config)
   
 void adv_dialog(HWND hParent, CONFIG * config)  
485  {  {
         PROPSHEETINFO psi[DLG_COUNT];  
         PROPSHEETPAGE psp[DLG_COUNT];  
         PROPSHEETHEADER psh;  
         CONFIG temp;  
486          int i;          int i;
487    
488          config->save = FALSE;          for (i=0; i<64; i++) {
489          memcpy(&temp, config, sizeof(CONFIG));                  int temp;
   
         for (i=0 ; i<DLG_COUNT ; ++i)  
         {  
                 psp[i].dwSize = sizeof(PROPSHEETPAGE);  
                 psp[i].dwFlags = 0;  
                 psp[i].hInstance = hInst;  
                 psp[i].pfnDlgProc = adv_proc;  
                 psp[i].lParam = (LPARAM)&psi[i];  
                 psp[i].pfnCallback = NULL;  
   
                 psi[i].page = i;  
                 psi[i].config = &temp;  
         }  
   
         psp[DLG_GLOBAL].pszTemplate             = MAKEINTRESOURCE(IDD_GLOBAL);  
         psp[DLG_QUANT].pszTemplate              = MAKEINTRESOURCE(IDD_QUANT);  
         psp[DLG_2PASS].pszTemplate              = MAKEINTRESOURCE(IDD_2PASS);  
         psp[DLG_2PASSALT].pszTemplate   = MAKEINTRESOURCE(IDD_2PASSALT);  
         psp[DLG_CREDITS].pszTemplate    = MAKEINTRESOURCE(IDD_CREDITS);  
         psp[DLG_CPU].pszTemplate                = MAKEINTRESOURCE(IDD_CPU);  
   
         psh.dwSize = sizeof(PROPSHEETHEADER);  
         psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;  
         psh.hwndParent = hParent;  
         psh.hInstance = hInst;  
         psh.pszCaption = (LPSTR) "XviD Configuration";  
         psh.nPages = DLG_COUNT;  
         psh.nStartPage = DLG_GLOBAL;  
         psh.ppsp = (LPCPROPSHEETPAGE)&psp;  
         psh.pfnCallback = NULL;  
490    
491          PropertySheet(&psh);                  temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);
492                    CONSTRAINVAL(temp, 1, 255);
493                    config->qmatrix_intra[i] = temp;
494    
495          if (temp.save)                  temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);
496          {                  CONSTRAINVAL(temp, 1, 255);
497                  memcpy(config, &temp, sizeof(CONFIG));                  config->qmatrix_inter[i] = temp;
498          }          }
499  }  }
500    
501    
502  /* enable/disable advanced controls based on encoder mode */  void quant_loadsave(HWND hDlg, CONFIG * config, int save)
   
 #define CONTROLDLG(X,Y) EnableWindow(GetDlgItem(hDlg, (X)), (Y))  
 #define ISDLGSET(X)     (IsDlgButtonChecked(hDlg, (X)) == BST_CHECKED)  
   
 #define MOD_CBR  
   
 void adv_mode(HWND hDlg, int mode)  
503  {  {
504          // create arrays of controls to be disabled for each mode          char file[MAX_PATH];
505          const short twopass_disable[] = {      OPENFILENAME ofn;
506                  IDC_KFBOOST, IDC_DUMMY2PASS, IDC_USEALT,          HANDLE hFile;
507  // added by koepi for new curve treatment          DWORD read=128, wrote=0;
508                  IDC_KFTRESHOLD, IDC_KFREDUCTION,          BYTE quant_data[128];
 //end of koepi's additions  
                 IDC_CURVECOMPH, IDC_CURVECOMPL, IDC_PAYBACK, IDC_PAYBACKBIAS, IDC_PAYBACKPROP,  
                 IDC_STATS2, IDC_STATS2_BROWSE,  
         };  
   
         const short cbr_disable[] = {  
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,  
                 IDC_CREDITS_START, IDC_CREDITS_END, IDC_CREDITS_START_BEGIN, IDC_CREDITS_START_END,  
                 IDC_CREDITS_END_BEGIN, IDC_CREDITS_END_END, IDC_CREDITS_RATE_RADIO,  
                 IDC_CREDITS_QUANT_RADIO, IDC_CREDITS_QUANT_STATIC, IDC_CREDITS_SIZE_RADIO,  
                 IDC_CREDITS_QUANTI, IDC_CREDITS_QUANTP, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,  
                 IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE, IDC_CREDITS_GREYSCALE, IDC_HINTFILE  
         };  
   
         const short qual_disable[] = {  
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,  
                 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,  
                 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,  
                 IDC_HINTFILE  
         };  
   
         const short quant_disable[] = {  
                 IDC_STATS1, IDC_STATS1_BROWSE, IDC_DISCARD1PASS, IDC_HINTEDME,  
                 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,  
                 IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,  
                 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE,  
                 IDC_HINTFILE  
         };  
   
         const short twopass1_disable[] = {  
                 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,  
                 IDC_MINIQUANT, IDC_MAXIQUANT, IDC_MINPQUANT, IDC_MAXPQUANT,  
                 IDC_CREDITS_RATE_RADIO, IDC_CREDITS_RATE, IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC,  
                 IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE  
         };  
   
         const short twopass2_ext_disable[] = {  
                 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,  
                 IDC_CREDITS_RATE_RADIO,  
                 IDC_CREDITS_SIZE_RADIO, IDC_CREDITS_END_STATIC, IDC_CREDITS_RATE,  
                 IDC_CREDITS_START_SIZE, IDC_CREDITS_END_SIZE  
         };  
   
         const short twopass2_int_disable[] = {  
                 IDC_CBR_REACTIONDELAY, IDC_CBR_AVERAGINGPERIOD, IDC_CBR_BUFFER,  
                 IDC_STATS2, IDC_STATS2_BROWSE  
         };  
509    
510          // store pointers in order so we can lookup using config->mode          strcpy(file, "\\matrix");
511          const short* modes[] = {          memset(&ofn, 0, sizeof(OPENFILENAME));
512                  cbr_disable, qual_disable, quant_disable,          ofn.lStructSize = sizeof(OPENFILENAME);
                 twopass1_disable, twopass2_ext_disable, twopass2_int_disable  
         };  
513    
514          // ditto modes[]          ofn.hwndOwner = hDlg;
515          const int lengths[] = {          ofn.lpstrFilter = "All files (*.*)\0*.*\0\0";
516                  sizeof(cbr_disable)/sizeof(short), sizeof(qual_disable)/sizeof(short),          ofn.lpstrFile = file;
517                  sizeof(quant_disable)/sizeof(short), sizeof(twopass1_disable)/sizeof(short),          ofn.nMaxFile = MAX_PATH;
518                  sizeof(twopass2_ext_disable)/sizeof(short), sizeof(twopass2_int_disable)/sizeof(short), 0          ofn.Flags = OFN_PATHMUSTEXIST;
         };  
519    
520          int i;          if (save) {
521          int hinted_me, use_alt, use_alt_auto, use_alt_auto_bonus;                  ofn.Flags |= OFN_OVERWRITEPROMPT;
522          int credits_start, credits_end, credits_rate, credits_quant, credits_size;                  if (GetSaveFileName(&ofn)) {
523          int cpu_force;                          hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
524    
525          // first perform checkbox-based enable/disable                          quant_download(hDlg, config);
526          hinted_me = ISDLGSET(IDC_HINTEDME);                          memcpy(quant_data, config->qmatrix_intra, 64);
527          CONTROLDLG(IDC_HINTFILE,                        hinted_me);                          memcpy(quant_data+64, config->qmatrix_inter, 64);
         CONTROLDLG(IDC_HINT_BROWSE,                     hinted_me);  
   
         use_alt                         = ISDLGSET(IDC_USEALT) && (mode == DLG_MODE_2PASS_2_EXT || mode == DLG_MODE_2PASS_2_INT);  
         use_alt_auto            = ISDLGSET(IDC_USEAUTO);  
         use_alt_auto_bonus      = ISDLGSET(IDC_USEAUTOBONUS);  
         CONTROLDLG(IDC_USEAUTO,                         use_alt);  
         CONTROLDLG(IDC_AUTOSTR,                         use_alt && use_alt_auto);  
         CONTROLDLG(IDC_USEAUTOBONUS,            use_alt);  
         CONTROLDLG(IDC_BONUSBIAS,                       use_alt && !use_alt_auto_bonus);  
         CONTROLDLG(IDC_CURVETYPE,                       use_alt);  
         CONTROLDLG(IDC_ALTCURVEHIGH,            use_alt);  
         CONTROLDLG(IDC_ALTCURVELOW,                     use_alt);  
         CONTROLDLG(IDC_MINQUAL,                         use_alt && !use_alt_auto);  
   
         credits_start           = ISDLGSET(IDC_CREDITS_START);  
         CONTROLDLG(IDC_CREDITS_START_BEGIN,     credits_start);  
         CONTROLDLG(IDC_CREDITS_START_END,       credits_start);  
   
         credits_end                     = ISDLGSET(IDC_CREDITS_END);  
         CONTROLDLG(IDC_CREDITS_END_BEGIN,       credits_end);  
         CONTROLDLG(IDC_CREDITS_END_END,         credits_end);  
   
         credits_rate            = ISDLGSET(IDC_CREDITS_RATE_RADIO);  
         credits_quant           = ISDLGSET(IDC_CREDITS_QUANT_RADIO);  
         credits_size            = ISDLGSET(IDC_CREDITS_SIZE_RADIO);  
         CONTROLDLG(IDC_CREDITS_RATE,            credits_rate);  
         CONTROLDLG(IDC_CREDITS_QUANTI,          credits_quant);  
         CONTROLDLG(IDC_CREDITS_QUANTP,          credits_quant);  
         CONTROLDLG(IDC_CREDITS_START_SIZE,      credits_size);  
         CONTROLDLG(IDC_CREDITS_END_SIZE,        credits_size);  
   
         cpu_force                       = ISDLGSET(IDC_CPU_FORCE);  
         CONTROLDLG(IDC_CPU_MMX,                         cpu_force);  
         CONTROLDLG(IDC_CPU_MMXEXT,                      cpu_force);  
         CONTROLDLG(IDC_CPU_SSE,                         cpu_force);  
         CONTROLDLG(IDC_CPU_SSE2,                        cpu_force);  
         CONTROLDLG(IDC_CPU_3DNOW,                       cpu_force);  
         CONTROLDLG(IDC_CPU_3DNOWEXT,            cpu_force);  
   
         // now perform codec mode enable/disable  
         for (i=0 ; i<lengths[mode] ; ++i)  
         {  
                 EnableWindow(GetDlgItem(hDlg, modes[mode][i]), FALSE);  
         }  
528    
529          if (mode != DLG_MODE_2PASS_2_EXT && mode != DLG_MODE_2PASS_2_INT)                          if (hFile == INVALID_HANDLE_VALUE) {
530          {                                  DPRINTF("Couldn't save quant matrix");
531                  for (i=0 ; i<sizeof(twopass_disable)/sizeof(short) ; ++i)                          }else{
532                  {                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0)) {
533                          EnableWindow(GetDlgItem(hDlg, twopass_disable[i]), FALSE);                                          DPRINTF("Couldnt write quant matrix");
534                  }                  }
535          }          }
536                            CloseHandle(hFile);
537  }  }
538            }else{
539                    ofn.Flags |= OFN_FILEMUSTEXIST;
540                    if (GetOpenFileName(&ofn)) {
541                            hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
542    
543                            if (hFile == INVALID_HANDLE_VALUE) {
544  /* upload config data into dialog */                                  DPRINTF("Couldn't load quant matrix");
545                            } else {
546  void adv_upload(HWND hDlg, int page, CONFIG * config)                                  if (!ReadFile(hFile, quant_data, 128, &read, 0)) {
547  {                                          DPRINTF("Couldnt read quant matrix");
548          switch (page)                                  }else{
549          {                                          memcpy(config->qmatrix_intra, quant_data, 64);
550          case DLG_GLOBAL :                                          memcpy(config->qmatrix_inter, quant_data+64, 64);
551                  SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0);                                          quant_upload(hDlg, config);
                 SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);  
                 SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);  
                 SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0);  
                 SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);  
                 SetDlgItemInt(hDlg, IDC_MINKEY, config->min_key_interval, FALSE);  
                 CheckDlgButton(hDlg, IDC_LUMMASK, config->lum_masking ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_INTERLACING, config->interlacing ? BST_CHECKED : BST_UNCHECKED);  
   
                 CheckDlgButton(hDlg, IDC_QPEL, config->qpel ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_GMC, config->gmc ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CHROMAME, config->chromame ? BST_CHECKED : BST_UNCHECKED);  
 // added by koepi for gruel's greyscale_mode  
                 CheckDlgButton(hDlg, IDC_GREYSCALE, config->greyscale ? BST_CHECKED : BST_UNCHECKED);  
 // end of koepi's addition  
                 SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, TRUE);  
                 SetDlgItemInt(hDlg, IDC_BQUANTRATIO, config->bquant_ratio, FALSE);  
                 SetDlgItemInt(hDlg, IDC_BQUANTOFFSET, config->bquant_offset, FALSE);  
                 CheckDlgButton(hDlg, IDC_PACKED, config->packed ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_DX50BVOP, config->dx50bvop ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_DEBUG, config->debug ? BST_CHECKED : BST_UNCHECKED);  
   
                 CheckDlgButton(hDlg, IDC_REDUCED, config->reduced_resolution ? BST_CHECKED : BST_UNCHECKED);  
                 break;  
   
         case DLG_QUANT :  
                 SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE);  
                 SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE);  
                 SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE);  
                 SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE);  
                 break;  
   
         case DLG_2PASS :  
                 SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);  
                 CheckDlgButton(hDlg, IDC_DISCARD1PASS, config->discard1pass ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_DUMMY2PASS, config->dummy2pass ? BST_CHECKED : BST_UNCHECKED);  
 // added by koepi for new 2pass curve treatment  
                 SetDlgItemInt(hDlg, IDC_KFTRESHOLD, config->kftreshold, FALSE);  
                 SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);  
 // end of koepi's additions  
                 SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);  
                 SetDlgItemInt(hDlg, IDC_PAYBACK, config->bitrate_payback_delay, FALSE);  
                 CheckDlgButton(hDlg, IDC_PAYBACKBIAS, (config->bitrate_payback_method == 0));  
                 CheckDlgButton(hDlg, IDC_PAYBACKPROP, (config->bitrate_payback_method == 1));  
   
                 CheckDlgButton(hDlg, IDC_HINTEDME, config->hinted_me ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile);  
                 SetDlgItemText(hDlg, IDC_STATS1, config->stats1);  
                 SetDlgItemText(hDlg, IDC_STATS2, config->stats2);  
                 break;  
   
         case DLG_2PASSALT :  
                 CheckDlgButton(hDlg, IDC_USEALT, config->use_alt_curve ? BST_CHECKED : BST_UNCHECKED);  
   
                 SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_SETCURSEL, config->alt_curve_type, 0);  
                 SetDlgItemInt(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist, FALSE);  
                 SetDlgItemInt(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist, FALSE);  
                 SetDlgItemInt(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual, FALSE);  
   
                 CheckDlgButton(hDlg, IDC_USEAUTO, config->alt_curve_use_auto ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemInt(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str, FALSE);  
   
                 CheckDlgButton(hDlg, IDC_USEAUTOBONUS, config->alt_curve_use_auto_bonus_bias ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemInt(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias, FALSE);  
   
                 SetDlgItemInt(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate / CONFIG_KBPS, FALSE);  
                 SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);  
                 SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);  
                 break;  
   
         case DLG_CREDITS :  
                 CheckDlgButton(hDlg, IDC_CREDITS_START, config->credits_start ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, config->credits_start_begin, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_START_END, config->credits_start_end, FALSE);  
                 CheckDlgButton(hDlg, IDC_CREDITS_END, config->credits_end ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_END_END, config->credits_end_end, FALSE);  
   
 // added by koepi for credits greyscale  
                 CheckDlgButton(hDlg, IDC_CREDITS_GREYSCALE, config->credits_greyscale ? BST_CHECKED : BST_UNCHECKED);  
 // end of koepi's addition  
                 SetDlgItemInt(hDlg, IDC_CREDITS_RATE, config->credits_rate, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size, FALSE);  
   
                 if (config->credits_mode == CREDITS_MODE_RATE)  
                 {  
                         CheckDlgButton(hDlg, IDC_CREDITS_RATE_RADIO, BST_CHECKED);  
552                  }                  }
                 else if (config->credits_mode == CREDITS_MODE_QUANT)  
                 {  
                         CheckDlgButton(hDlg, IDC_CREDITS_QUANT_RADIO, BST_CHECKED);  
553                  }                  }
554                  else    // CREDITS_MODE_SIZE                          CloseHandle(hFile);
                 {  
                         CheckDlgButton(hDlg, IDC_CREDITS_SIZE_RADIO, BST_CHECKED);  
555                  }                  }
                 break;  
   
         case DLG_CPU :  
                 CheckDlgButton(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX) ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT) ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE) ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2) ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW) ? BST_CHECKED : BST_UNCHECKED);  
                 CheckDlgButton(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT) ? BST_CHECKED : BST_UNCHECKED);  
   
                 CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,  
                         config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );  
   
                 SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);  
                 CheckDlgButton(hDlg, IDC_CHROMA_OPT, (config->chroma_opt) ? BST_CHECKED : BST_UNCHECKED);  
                 SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);  
                 SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);  
                 break;  
556          }          }
557  }  }
558    
559    /* quantization matrix dialog proc */
560    
561  /* download config data from dialog  BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
562     replaces invalid values instead of alerting user for now  {
563  */          CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
   
 #define CONSTRAINVAL(X,Y,Z) if((X)<(Y)) X=Y; if((X)>(Z)) X=Z;  
564    
565  void adv_download(HWND hDlg, int page, CONFIG * config)          switch (uMsg)
566  {  {
567          switch (page)          case WM_INITDIALOG :
568                    SetWindowLong(hDlg, GWL_USERDATA, lParam);
569                    config = (CONFIG*)lParam;
570                    quant_upload(hDlg, config);
571    
572                    if (g_hTooltip)
573          {          {
574          case DLG_GLOBAL :                          EnumChildWindows(hDlg, enum_tooltips, 0);
575                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);                  }
                 config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);  
                 config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);  
                 config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0);  
                 config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);  
                 config->min_key_interval = config_get_uint(hDlg, IDC_MINKEY, config->min_key_interval);  
                 config->lum_masking = ISDLGSET(IDC_LUMMASK);  
                 config->interlacing = ISDLGSET(IDC_INTERLACING);  
   
                 config->qpel = ISDLGSET(IDC_QPEL);  
                 config->gmc = ISDLGSET(IDC_GMC);  
                 config->chromame = ISDLGSET(IDC_CHROMAME);  
 // added by koepi for gruel's greyscale_mode  
                 config->greyscale = ISDLGSET(IDC_GREYSCALE);  
 // end of koepi's addition  
                 config->max_bframes = config_get_int(hDlg, IDC_MAXBFRAMES, config->max_bframes);  
                 config->bquant_ratio = config_get_uint(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);  
                 config->bquant_offset = config_get_uint(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);  
                 config->packed = ISDLGSET(IDC_PACKED);  
                 config->dx50bvop = ISDLGSET(IDC_DX50BVOP);  
                 config->debug = ISDLGSET(IDC_DEBUG);  
                 config->reduced_resolution = ISDLGSET(IDC_REDUCED);  
576                  break;                  break;
577    
578          case DLG_QUANT :          case WM_COMMAND :
                 config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);  
                 config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);  
                 config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);  
                 config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);  
579    
580                  CONSTRAINVAL(config->min_iquant, 1, 31);          if (HIWORD(wParam) == BN_CLICKED) {
581                  CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);              switch(LOWORD(wParam)) {
582                  CONSTRAINVAL(config->min_pquant, 1, 31);              case IDOK :
583                  CONSTRAINVAL(config->max_pquant, config->min_pquant, 31);                              quant_download(hDlg, config);
584                                EndDialog(hDlg, IDOK);
585                  break;                  break;
586    
587          case DLG_2PASS :              case IDCANCEL :
588                  config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);                  EndDialog(hDlg, IDCANCEL);
589  // added by koepi for the new 2pass curve treatment                  break;
                 config->kftreshold = GetDlgItemInt(hDlg, IDC_KFTRESHOLD, NULL, FALSE);  
                 config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);  
 //end of koepi's additions  
                 config->discard1pass = ISDLGSET(IDC_DISCARD1PASS);  
                 config->dummy2pass = ISDLGSET(IDC_DUMMY2PASS);  
                 config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);  
                 config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);  
                 config->bitrate_payback_delay = config_get_uint(hDlg, IDC_PAYBACK, config->bitrate_payback_delay);  
                 config->bitrate_payback_method = ISDLGSET(IDC_PAYBACKPROP);  
                 config->hinted_me = ISDLGSET(IDC_HINTEDME);  
590    
591                  if (GetDlgItemText(hDlg, IDC_HINTFILE, config->hintfile, MAX_PATH) == 0)              case IDC_SAVE :
592                  {                  quant_loadsave(hDlg, config, 1);
593                          lstrcpy(config->hintfile, CONFIG_HINTFILE);                  break;
                 }  
                 if (GetDlgItemText(hDlg, IDC_STATS1, config->stats1, MAX_PATH) == 0)  
                 {  
                         lstrcpy(config->stats1, CONFIG_2PASS_1_FILE);  
                 }  
                 if (GetDlgItemText(hDlg, IDC_STATS2, config->stats2, MAX_PATH) == 0)  
                 {  
                         lstrcpy(config->stats2, CONFIG_2PASS_2_FILE);  
                 }  
594    
595                  CONSTRAINVAL(config->bitrate_payback_delay, 1, 10000);              case IDC_LOAD :
596                  CONSTRAINVAL(config->keyframe_boost, 0, 1000);                  quant_loadsave(hDlg, config, 0);
                 CONSTRAINVAL(config->curve_compression_high, 0, 100);  
                 CONSTRAINVAL(config->curve_compression_low, 0, 100);  
597                  break;                  break;
598    
599          case DLG_2PASSALT :              default :
600                  config->use_alt_curve = ISDLGSET(IDC_USEALT);                  return FALSE;
601                }
602                break;
603            }
604            return FALSE;
605    
606                  config->alt_curve_use_auto = ISDLGSET(IDC_USEAUTO);          default :
607                  config->alt_curve_auto_str = config_get_uint(hDlg, IDC_AUTOSTR, config->alt_curve_auto_str);                  return FALSE;
608            }
609    
610                  config->alt_curve_use_auto_bonus_bias = ISDLGSET(IDC_USEAUTOBONUS);          return TRUE;
611                  config->alt_curve_bonus_bias = config_get_uint(hDlg, IDC_BONUSBIAS, config->alt_curve_bonus_bias);  }
612    
                 config->alt_curve_type = SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_GETCURSEL, 0, 0);  
                 config->alt_curve_high_dist = config_get_uint(hDlg, IDC_ALTCURVEHIGH, config->alt_curve_high_dist);  
                 config->alt_curve_low_dist = config_get_uint(hDlg, IDC_ALTCURVELOW, config->alt_curve_low_dist);  
                 config->alt_curve_min_rel_qual = config_get_uint(hDlg, IDC_MINQUAL, config->alt_curve_min_rel_qual);  
   
                 config->twopass_max_bitrate /= CONFIG_KBPS;  
                 config->twopass_max_bitrate = config_get_uint(hDlg, IDC_MAXBITRATE, config->twopass_max_bitrate);  
                 config->twopass_max_bitrate *= CONFIG_KBPS;  
                 config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);  
                 config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);  
613    
614                  CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);  /* ===================================================================================== */
615                  CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);  /* ADVANCED DIALOG PAGES ================================================================ */
616                  break;  /* ===================================================================================== */
617    
618    /* initialise pages */
619    void adv_init(HWND hDlg, int idd, CONFIG * config)
620    {
621            unsigned int i;
622    
623        switch(idd) {
624        case IDD_PROFILE :
625                    for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
626                            SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
627                    SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263");
628                    SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");
629                    SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");
630    
631          case DLG_CREDITS :                  SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"1:1 (Default)");
632                  config->credits_start = ISDLGSET(IDC_CREDITS_START);                  SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"4:3 (Anamorph)");
633                  config->credits_start_begin = GetDlgItemInt(hDlg, IDC_CREDITS_START_BEGIN, NULL, FALSE);                  SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"16:9 (Anamorph)");
634                  config->credits_start_end = config_get_uint(hDlg, IDC_CREDITS_START_END, config->credits_start_end);                  /* reserved for future use if acceptance is there for DAR */
635                  config->credits_end = ISDLGSET(IDC_CREDITS_END);  #if 0
636                  config->credits_end_begin = config_get_uint(hDlg, IDC_CREDITS_END_BEGIN, config->credits_end_begin);                  SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_ADDSTRING, 0, (LPARAM)"Custom");
637                  config->credits_end_end = config_get_uint(hDlg, IDC_CREDITS_END_END, config->credits_end_end);  #endif
638            break;
639    
640  // added by koepi for gruel's greyscale_mode      case IDD_LEVEL :
641                  config->credits_greyscale = ISDLGSET(IDC_CREDITS_GREYSCALE);                  for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
642  // end of koepi's addition                          SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
643                  config->credits_rate = config_get_uint(hDlg, IDC_CREDITS_RATE, config->credits_rate);          break;
                 config->credits_quant_i = config_get_uint(hDlg, IDC_CREDITS_QUANTI, config->credits_quant_i);  
                 config->credits_quant_p = config_get_uint(hDlg, IDC_CREDITS_QUANTP, config->credits_quant_p);  
                 config->credits_start_size = config_get_uint(hDlg, IDC_CREDITS_START_SIZE, config->credits_start_size);  
                 config->credits_end_size = config_get_uint(hDlg, IDC_CREDITS_END_SIZE, config->credits_end_size);  
644    
645                  config->credits_mode = 0;      case IDD_ZONE :
646                  config->credits_mode = ISDLGSET(IDC_CREDITS_RATE_RADIO) ? CREDITS_MODE_RATE : config->credits_mode;          EnableDlgWindow(hDlg, IDC_ZONE_FETCH, config->ci_valid);
647                  config->credits_mode = ISDLGSET(IDC_CREDITS_QUANT_RADIO) ? CREDITS_MODE_QUANT : config->credits_mode;          break;
                 config->credits_mode = ISDLGSET(IDC_CREDITS_SIZE_RADIO) ? CREDITS_MODE_SIZE : config->credits_mode;  
648    
649                  CONSTRAINVAL(config->credits_rate, 1, 100);      case IDD_MOTION :
650                  CONSTRAINVAL(config->credits_quant_i, 1, 31);                  SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None");
651                  CONSTRAINVAL(config->credits_quant_p, 1, 31);                  SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low");
652                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low");
653                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium");
654                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High");
655                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High");
656                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High");
657    
658                  if (config->credits_start_begin > config->credits_start_end)                  SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off");
659                  {                  SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision");
660                          config->credits_start_begin = config->credits_start_end;                  SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search");
661                          config->credits_start = 0;                  SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search");
662                  }                  SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search");
                 if (config->credits_end_begin > config->credits_end_end)  
                 {  
                         config->credits_end_begin = config->credits_end_end;  
                         config->credits_end = 0;  
                 }  
663                  break;                  break;
664    
665          case DLG_CPU :      case IDD_DEBUG :
666                  config->cpu = 0;                  /* force threads disabled */
667                  config->cpu |= ISDLGSET(IDC_CPU_MMX) ? XVID_CPU_MMX : 0;                  EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);
668                  config->cpu |= ISDLGSET(IDC_CPU_MMXEXT) ? XVID_CPU_MMXEXT: 0;                  EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);
                 config->cpu |= ISDLGSET(IDC_CPU_SSE) ? XVID_CPU_SSE: 0;  
                 config->cpu |= ISDLGSET(IDC_CPU_SSE2) ? XVID_CPU_SSE2: 0;  
                 config->cpu |= ISDLGSET(IDC_CPU_3DNOW) ? XVID_CPU_3DNOW: 0;  
                 config->cpu |= ISDLGSET(IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT: 0;  
                 config->cpu |= ISDLGSET(IDC_CPU_FORCE) ? XVID_CPU_FORCE : 0;  
669    
670                  config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");
671                  config->chroma_opt = ISDLGSET(IDC_CHROMA_OPT);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");
672                  config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");
                 config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);  
                 config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);  
                 config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);  
673                  break;                  break;
674          }          }
675  }  }
676    
677    
678  void quant_upload(HWND hDlg, CONFIG* config)  /* enable/disable controls based on encoder-mode or user selection */
 {  
         int i;  
679    
680          for (i=0 ; i<64 ; ++i)  void adv_mode(HWND hDlg, int idd, CONFIG * config)
681          {          {
682                  SetDlgItemInt(hDlg, IDC_QINTRA00 + i, config->qmatrix_intra[i], FALSE);      int profile;
683                  SetDlgItemInt(hDlg, IDC_QINTER00 + i, config->qmatrix_inter[i], FALSE);      int weight_en, quant_en;
684        int cpu_force;
685        int custom_quant, bvops;
686    
687        switch(idd) {
688        case IDD_PROFILE :
689            profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0);
690            EnableDlgWindow(hDlg, IDC_BVOP, profiles[profile].flags&PROFILE_BVOP);
691    
692            EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT);
693            EnableDlgWindow(hDlg, IDC_QUANTTYPE_S, profiles[profile].flags&PROFILE_MPEGQUANT);
694            EnableDlgWindow(hDlg, IDC_QUANTTYPE, profiles[profile].flags&PROFILE_MPEGQUANT);
695            custom_quant = (profiles[profile].flags&PROFILE_MPEGQUANT) && SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0)==QUANT_MODE_CUSTOM;
696            EnableDlgWindow(hDlg, IDC_QUANTMATRIX, custom_quant);
697            EnableDlgWindow(hDlg, IDC_LUMMASK, profiles[profile].flags&PROFILE_ADAPTQUANT);
698            EnableDlgWindow(hDlg, IDC_INTERLACING, profiles[profile].flags&PROFILE_INTERLACE);
699            EnableDlgWindow(hDlg, IDC_QPEL, profiles[profile].flags&PROFILE_QPEL);
700            EnableDlgWindow(hDlg, IDC_GMC, profiles[profile].flags&PROFILE_GMC);
701            EnableDlgWindow(hDlg, IDC_REDUCED, profiles[profile].flags&PROFILE_REDUCED);
702    
703            bvops = (profiles[profile].flags&PROFILE_BVOP) && IsDlgChecked(hDlg, IDC_BVOP);
704                    EnableDlgWindow(hDlg, IDC_MAXBFRAMES,       bvops);
705                    EnableDlgWindow(hDlg, IDC_BQUANTRATIO,      bvops);
706                    EnableDlgWindow(hDlg, IDC_BQUANTOFFSET,     bvops);
707                    EnableDlgWindow(hDlg, IDC_MAXBFRAMES_S,     bvops);
708                    EnableDlgWindow(hDlg, IDC_BQUANTRATIO_S,    bvops);
709                    EnableDlgWindow(hDlg, IDC_BQUANTOFFSET_S,   bvops);
710                    EnableDlgWindow(hDlg, IDC_PACKED,           bvops);
711                    EnableDlgWindow(hDlg, IDC_CLOSEDGOV,        bvops);
712    
713        case IDD_LEVEL :
714            profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0);
715            SetDlgItemInt(hDlg, IDC_LEVEL_WIDTH, profiles[profile].width, FALSE);
716            SetDlgItemInt(hDlg, IDC_LEVEL_HEIGHT, profiles[profile].height, FALSE);
717            SetDlgItemInt(hDlg, IDC_LEVEL_FPS, profiles[profile].fps, FALSE);
718            SetDlgItemInt(hDlg, IDC_LEVEL_VMV, profiles[profile].max_vmv_buffer_sz, FALSE);
719            SetDlgItemInt(hDlg, IDC_LEVEL_VCV, profiles[profile].vcv_decoder_rate, FALSE);
720            SetDlgItemInt(hDlg, IDC_LEVEL_VBV, profiles[profile].max_vbv_size, FALSE);
721            SetDlgItemInt(hDlg, IDC_LEVEL_BITRATE, profiles[profile].max_bitrate, FALSE);
722            break;
723    
724        case IDD_ZONE :
725            weight_en = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT);
726            quant_en =   IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT);
727            EnableDlgWindow(hDlg, IDC_ZONE_WEIGHT, weight_en);
728            EnableDlgWindow(hDlg, IDC_ZONE_QUANT, quant_en);
729            EnableDlgWindow(hDlg, IDC_ZONE_SLIDER, weight_en|quant_en);
730    
731            if (weight_en) {
732                    SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(001,200));
733                SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, 100));
734                SetDlgItemText(hDlg, IDC_ZONE_MIN, "0.01");
735                SetDlgItemText(hDlg, IDC_ZONE_MAX, "2.00");
736            }else if (quant_en) {
737                SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(100,3100));
738                SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE, get_dlgitem_float(hDlg, IDC_ZONE_QUANT, 100));
739                SetDlgItemText(hDlg, IDC_ZONE_MIN, "1");
740                SetDlgItemText(hDlg, IDC_ZONE_MAX, "31");
741            }
742    
743            bvops = (profiles[config->profile].flags&PROFILE_BVOP) && config->use_bvop;
744            EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD_S, bvops);
745            EnableDlgWindow(hDlg, IDC_ZONE_BVOPTHRESHOLD, bvops);
746            break;
747    
748        case IDD_DEBUG :
749                cpu_force                   = IsDlgChecked(hDlg, IDC_CPU_FORCE);
750                EnableDlgWindow(hDlg, IDC_CPU_MMX,          cpu_force);
751                EnableDlgWindow(hDlg, IDC_CPU_MMXEXT,       cpu_force);
752                EnableDlgWindow(hDlg, IDC_CPU_SSE,          cpu_force);
753                EnableDlgWindow(hDlg, IDC_CPU_SSE2,         cpu_force);
754                EnableDlgWindow(hDlg, IDC_CPU_3DNOW,        cpu_force);
755                EnableDlgWindow(hDlg, IDC_CPU_3DNOWEXT,     cpu_force);
756            break;
757          }          }
758  }  }
759    
760    
761  void quant_download(HWND hDlg, CONFIG* config)  /* upload config data into dialog */
762    void adv_upload(HWND hDlg, int idd, CONFIG * config)
763  {  {
764          int i;          switch (idd)
   
         for (i=0 ; i<64 ; ++i)  
765          {          {
766                  int temp;          case IDD_PROFILE :
767                    SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_SETCURSEL, config->profile, 0);
768    
769                  temp = config_get_uint(hDlg, i + IDC_QINTRA00, config->qmatrix_intra[i]);          SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_SETCURSEL, config->quant_type, 0);
770                  CONSTRAINVAL(temp, 1, 255);          CheckDlg(hDlg, IDC_LUMMASK, config->lum_masking);
771                  config->qmatrix_intra[i] = temp;                  CheckDlg(hDlg, IDC_INTERLACING, config->interlacing);
772            CheckDlg(hDlg, IDC_QPEL, config->qpel);
773                  temp = config_get_uint(hDlg, i + IDC_QINTER00, config->qmatrix_inter[i]);                  CheckDlg(hDlg, IDC_GMC, config->gmc);
774                  CONSTRAINVAL(temp, 1, 255);              CheckDlg(hDlg, IDC_REDUCED, config->reduced_resolution);
775                  config->qmatrix_inter[i] = temp;          CheckDlg(hDlg, IDC_BVOP, config->use_bvop);
776          }  
777  }          SetDlgItemInt(hDlg, IDC_MAXBFRAMES, config->max_bframes, FALSE);
778            set_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
779                    set_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
780            CheckDlg(hDlg, IDC_PACKED, config->packed);
781                    CheckDlg(hDlg, IDC_CLOSEDGOV, config->closed_gov);
782            SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_SETCURSEL, (config->display_aspect_ratio), 0);
783                    break;
784    
785        case IDD_LEVEL :
786            SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_SETCURSEL, config->profile, 0);
787            break;
788    
789  /* enumerates child windows, assigns tooltips */          case IDD_RC_CBR :
790                    SetDlgItemInt(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor, FALSE);
791                    SetDlgItemInt(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period, FALSE);
792                    SetDlgItemInt(hDlg, IDC_CBR_BUFFER, config->rc_buffer, FALSE);
793                    break;
794    
795  BOOL CALLBACK enum_tooltips(HWND hWnd, LPARAM lParam)      case IDD_RC_2PASS1 :
796  {          SetDlgItemText(hDlg, IDC_STATS, config->stats);
797          char help[500];          CheckDlg(hDlg, IDC_DISCARD1PASS, config->discard1pass);
798            break;
799    
800          if (LoadString(hInst, GetDlgCtrlID(hWnd), help, 500))          case IDD_RC_2PASS2 :
801          {                  SetDlgItemText(hDlg, IDC_STATS, config->stats);
802                  TOOLINFO ti;          SetDlgItemInt(hDlg, IDC_KFBOOST, config->keyframe_boost, FALSE);
803                    SetDlgItemInt(hDlg, IDC_KFREDUCTION, config->kfreduction, FALSE);
804    
805                  ti.cbSize = sizeof(TOOLINFO);                  SetDlgItemInt(hDlg, IDC_OVERFLOW_CONTROL_STRENGTH, config->overflow_control_strength, FALSE);
806                  ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;          SetDlgItemInt(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement, FALSE);
807                  ti.hwnd = GetParent(hWnd);                  SetDlgItemInt(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation, FALSE);
                 ti.uId  = (LPARAM)hWnd;  
                 ti.lpszText = help;  
808    
809                  SendMessage(hTooltip, TTM_ADDTOOL, 0, (LPARAM)&ti);                  SetDlgItemInt(hDlg, IDC_CURVECOMPH, config->curve_compression_high, FALSE);
810          }                  SetDlgItemInt(hDlg, IDC_CURVECOMPL, config->curve_compression_low, FALSE);
811                    SetDlgItemInt(hDlg, IDC_MINKEY, config->kfthreshold, FALSE);
812                    break;
813    
814          return TRUE;      case IDD_ZONE :
815  }          SetDlgItemInt(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame, FALSE);
816    
817            CheckDlgButton(hDlg, IDC_ZONE_MODE_WEIGHT,   config->zones[config->cur_zone].mode == RC_ZONE_WEIGHT);
818            CheckDlgButton(hDlg, IDC_ZONE_MODE_QUANT,         config->zones[config->cur_zone].mode == RC_ZONE_QUANT);
819    
820            set_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight);
821            set_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant);
822    
823  /* --- decoder options dialog  --- */          CheckDlgButton(hDlg, IDC_ZONE_FORCEIVOP, config->zones[config->cur_zone].type==XVID_TYPE_IVOP);
824            CheckDlgButton(hDlg, IDC_ZONE_GREYSCALE, config->zones[config->cur_zone].greyscale);
825            CheckDlgButton(hDlg, IDC_ZONE_CHROMAOPT, config->zones[config->cur_zone].chroma_opt);
826    
827  #define DEC_DLG_COUNT   1          SetDlgItemInt(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold, TRUE);
828  #define DEC_DLG_POSTPROC        0          break;
829    
830  /* decoder dialog: upload config data */          case IDD_MOTION :
831                    SendDlgItemMessage(hDlg, IDC_MOTION, CB_SETCURSEL, config->motion_search, 0);
832                    SendDlgItemMessage(hDlg, IDC_VHQ, CB_SETCURSEL, config->vhq_mode, 0);
833            CheckDlg(hDlg, IDC_CHROMAME, config->chromame);
834            CheckDlg(hDlg, IDC_CARTOON, config->cartoon_mode);
835                    SetDlgItemInt(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio, FALSE);
836                    SetDlgItemInt(hDlg, IDC_MAXKEY, config->max_key_interval, FALSE);
837            break;
838    
839  void dec_upload(HWND hDlg, int page, CONFIG * config)          case IDD_QUANT :
840  {                  SetDlgItemInt(hDlg, IDC_MINIQUANT, config->min_iquant, FALSE);
841          switch (page)                  SetDlgItemInt(hDlg, IDC_MAXIQUANT, config->max_iquant, FALSE);
842          {                  SetDlgItemInt(hDlg, IDC_MINPQUANT, config->min_pquant, FALSE);
843          case DEC_DLG_POSTPROC :                  SetDlgItemInt(hDlg, IDC_MAXPQUANT, config->max_pquant, FALSE);
844                  CheckDlgButton(hDlg, IDC_DEBLOCK_Y,  config->deblock_y ? BST_CHECKED : BST_UNCHECKED);                  SetDlgItemInt(hDlg, IDC_MINBQUANT, config->min_bquant, FALSE);
845                  CheckDlgButton(hDlg, IDC_DEBLOCK_UV, config->deblock_uv ? BST_CHECKED : BST_UNCHECKED);                  SetDlgItemInt(hDlg, IDC_MAXBQUANT, config->max_bquant, FALSE);
846            CheckDlg(hDlg, IDC_TRELLISQUANT, config->trellis_quant);
847                  break;                  break;
         }  
 }  
848    
849            case IDD_DEBUG :
850                    CheckDlg(hDlg, IDC_CPU_MMX, (config->cpu & XVID_CPU_MMX));
851                    CheckDlg(hDlg, IDC_CPU_MMXEXT, (config->cpu & XVID_CPU_MMXEXT));
852                    CheckDlg(hDlg, IDC_CPU_SSE, (config->cpu & XVID_CPU_SSE));
853                    CheckDlg(hDlg, IDC_CPU_SSE2, (config->cpu & XVID_CPU_SSE2));
854                    CheckDlg(hDlg, IDC_CPU_3DNOW, (config->cpu & XVID_CPU_3DNOW));
855                    CheckDlg(hDlg, IDC_CPU_3DNOWEXT, (config->cpu & XVID_CPU_3DNOWEXT));
856    
857  /* dec dialog: download config data */                  CheckRadioButton(hDlg, IDC_CPU_AUTO, IDC_CPU_FORCE,
858                            config->cpu & XVID_CPU_FORCE ? IDC_CPU_FORCE : IDC_CPU_AUTO );
859    
860  void dec_download(HWND hDlg, int page, CONFIG * config)                  SetDlgItemInt(hDlg, IDC_NUMTHREADS, config->num_threads, FALSE);
861  {  
862          switch (page)                  SendDlgItemMessage(hDlg, IDC_FOURCC, CB_SETCURSEL, config->fourcc_used, 0);
863          {          set_dlgitem_hex(hDlg, IDC_DEBUG, config->debug);
864          case DEC_DLG_POSTPROC :                  CheckDlg(hDlg, IDC_VOPDEBUG, config->vop_debug);
865                  config->deblock_y = ISDLGSET(IDC_DEBLOCK_Y);          CheckDlg(hDlg, IDC_DISPLAY_STATUS, config->display_status);
                 config->deblock_uv = ISDLGSET(IDC_DEBLOCK_UV);  
866                  break;                  break;
867          }          }
868  }  }
869    
 /* decoder dialog proc */  
870    
871  BOOL CALLBACK dec_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  /* download config data from dialog */
 {  
         PROPSHEETINFO *psi;  
872    
873          psi = (PROPSHEETINFO*)GetWindowLong(hDlg, GWL_USERDATA);  void adv_download(HWND hDlg, int idd, CONFIG * config)
   
         switch (uMsg)  
874          {          {
875          case WM_INITDIALOG :          switch (idd)
                 psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;  
   
                 SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);  
   
                 if (hTooltip)  
876                  {                  {
877                          EnumChildWindows(hDlg, enum_tooltips, 0);          case IDD_PROFILE :
878                  }                  config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE_PROFILE, CB_GETCURSEL, 0, 0);
879    
880                  dec_upload(hDlg, psi->page, psi->config);          config->quant_type = SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_GETCURSEL, 0, 0);
881            config->lum_masking = IsDlgChecked(hDlg, IDC_LUMMASK);
882                    config->interlacing = IsDlgChecked(hDlg, IDC_INTERLACING);
883            config->qpel = IsDlgChecked(hDlg, IDC_QPEL);
884                    config->gmc = IsDlgChecked(hDlg, IDC_GMC);
885                    config->reduced_resolution = IsDlgChecked(hDlg, IDC_REDUCED);
886    
887            config->use_bvop = IsDlgChecked(hDlg, IDC_BVOP);
888                    config->max_bframes = config_get_uint(hDlg, IDC_MAXBFRAMES, config->max_bframes);
889                    config->bquant_ratio = get_dlgitem_float(hDlg, IDC_BQUANTRATIO, config->bquant_ratio);
890                    config->bquant_offset = get_dlgitem_float(hDlg, IDC_BQUANTOFFSET, config->bquant_offset);
891                    config->packed = IsDlgChecked(hDlg, IDC_PACKED);
892                    config->closed_gov = IsDlgChecked(hDlg, IDC_CLOSEDGOV);
893            config->display_aspect_ratio = SendDlgItemMessage(hDlg, IDC_ASPECT_RATIO, CB_GETCURSEL, 0, 0);
894                  break;                  break;
895    
896          case WM_NOTIFY :      case IDD_LEVEL :
897                  switch (((NMHDR *)lParam)->code)          config->profile = SendDlgItemMessage(hDlg, IDC_LEVEL_PROFILE, CB_GETCURSEL, 0, 0);
                 {  
                 case PSN_KILLACTIVE :  
                         /* validate */  
                         dec_download(hDlg, psi->page, psi->config);  
                         SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);  
898                          break;                          break;
899    
900                  case PSN_APPLY :          case IDD_RC_CBR :
901                          /* apply */                  config->rc_reaction_delay_factor = config_get_uint(hDlg, IDC_CBR_REACTIONDELAY, config->rc_reaction_delay_factor);
902                          dec_download(hDlg, psi->page, psi->config);                  config->rc_averaging_period = config_get_uint(hDlg, IDC_CBR_AVERAGINGPERIOD, config->rc_averaging_period);
903                          SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);                  config->rc_buffer = config_get_uint(hDlg, IDC_CBR_BUFFER, config->rc_buffer);
                         psi->config->save = TRUE;  
                         break;  
                 }  
904                  break;                  break;
905    
906          default :          case IDD_RC_2PASS1 :
907                  return 0;          if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
908          }                          lstrcpy(config->stats, CONFIG_2PASS_FILE);
909            config->discard1pass = IsDlgChecked(hDlg, IDC_DISCARD1PASS);
910          return 1;          break;
 }  
   
911    
912  void dec_dialog(HWND hParent, CONFIG * config)      case IDD_RC_2PASS2 :
913  {          if (GetDlgItemText(hDlg, IDC_STATS, config->stats, MAX_PATH) == 0)
914          PROPSHEETINFO psi[DEC_DLG_COUNT];                          lstrcpy(config->stats, CONFIG_2PASS_FILE);
         PROPSHEETPAGE psp[DEC_DLG_COUNT];  
         PROPSHEETHEADER psh;  
         CONFIG temp;  
         int i;  
915    
916          config->save = FALSE;          config->keyframe_boost = GetDlgItemInt(hDlg, IDC_KFBOOST, NULL, FALSE);
917          memcpy(&temp, config, sizeof(CONFIG));                  config->kfreduction = GetDlgItemInt(hDlg, IDC_KFREDUCTION, NULL, FALSE);
918                    CONSTRAINVAL(config->keyframe_boost, 0, 1000);
919    
920          for (i=0 ; i<DEC_DLG_COUNT ; ++i)                  config->overflow_control_strength = GetDlgItemInt(hDlg, IDC_OVERFLOW_CONTROL_STRENGTH, NULL, FALSE);
921          {                  config->twopass_max_overflow_improvement = config_get_uint(hDlg, IDC_OVERIMP, config->twopass_max_overflow_improvement);
922                  psp[i].dwSize = sizeof(PROPSHEETPAGE);                  config->twopass_max_overflow_degradation = config_get_uint(hDlg, IDC_OVERDEG, config->twopass_max_overflow_degradation);
923                  psp[i].dwFlags = 0;                  CONSTRAINVAL(config->twopass_max_overflow_improvement, 1, 80);
924                  psp[i].hInstance = hInst;                  CONSTRAINVAL(config->twopass_max_overflow_degradation, 1, 80);
925                  psp[i].pfnDlgProc = dec_proc;                  CONSTRAINVAL(config->overflow_control_strength, 0, 100);
                 psp[i].lParam = (LPARAM)&psi[i];  
                 psp[i].pfnCallback = NULL;  
926    
927                  psi[i].page = i;                  config->curve_compression_high = GetDlgItemInt(hDlg, IDC_CURVECOMPH, NULL, FALSE);
928                  psi[i].config = &temp;                  config->curve_compression_low = GetDlgItemInt(hDlg, IDC_CURVECOMPL, NULL, FALSE);
929          }                  CONSTRAINVAL(config->curve_compression_high, 0, 100);
930                    CONSTRAINVAL(config->curve_compression_low, 0, 100);
931    
932          psp[DEC_DLG_POSTPROC].pszTemplate = MAKEINTRESOURCE(IDD_POSTPROC);                  config->kfthreshold = config_get_uint(hDlg, IDC_MINKEY, config->kfthreshold);
933    
934          psh.dwSize = sizeof(PROPSHEETHEADER);                  break;
         psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;  
         psh.hwndParent = hParent;  
         psh.hInstance = hInst;  
         psh.pszCaption = (LPSTR) "XviD Configuration";  
         psh.nPages = DEC_DLG_COUNT;  
         psh.nStartPage = DEC_DLG_POSTPROC;  
         psh.ppsp = (LPCPROPSHEETPAGE)&psp;  
         psh.pfnCallback = NULL;  
935    
936          PropertySheet(&psh);      case IDD_ZONE :
937            config->zones[config->cur_zone].frame = config_get_uint(hDlg, IDC_ZONE_FRAME, config->zones[config->cur_zone].frame);
938    
939          if (temp.save)          if (IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT)) {
940          {              config->zones[config->cur_zone].mode = RC_ZONE_WEIGHT;
941                  memcpy(config, &temp, sizeof(CONFIG));          }else if (IsDlgChecked(hDlg, IDC_ZONE_MODE_QUANT)) {
942          }              config->zones[config->cur_zone].mode = RC_ZONE_QUANT;
943  }  }
944    
945            config->zones[config->cur_zone].weight = get_dlgitem_float(hDlg, IDC_ZONE_WEIGHT, config->zones[config->cur_zone].weight);
946            config->zones[config->cur_zone].quant =  get_dlgitem_float(hDlg, IDC_ZONE_QUANT, config->zones[config->cur_zone].quant);
947    
948            config->zones[config->cur_zone].type = IsDlgButtonChecked(hDlg, IDC_ZONE_FORCEIVOP)?XVID_TYPE_IVOP:XVID_TYPE_AUTO;
949            config->zones[config->cur_zone].greyscale = IsDlgButtonChecked(hDlg, IDC_ZONE_GREYSCALE);
950            config->zones[config->cur_zone].chroma_opt = IsDlgButtonChecked(hDlg, IDC_ZONE_CHROMAOPT);
951    
952  /* main dialog proc */          config->zones[config->cur_zone].bvop_threshold = config_get_int(hDlg, IDC_ZONE_BVOPTHRESHOLD, config->zones[config->cur_zone].bvop_threshold);
   
 BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  
 {  
         CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);  
   
         switch (uMsg)  
         {  
         case WM_INITDIALOG :  
                 SetWindowLong(hDlg, GWL_USERDATA, lParam);  
   
                 config = (CONFIG*)lParam;  
   
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - CBR");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quality");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"1 Pass - quantizer");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 1st pass");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Ext.");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"2 Pass - 2nd pass Int.");  
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null - test speed");  
   
                 SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);  
   
                 InitCommonControls();  
   
                 if ((hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,  
                                 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,  
                                 NULL, NULL, hInst, NULL)))  
                 {  
                         SetWindowPos(hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);  
                         SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));  
                         SendMessage(hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);  
   
                         EnumChildWindows(hDlg, enum_tooltips, 0);  
                 }  
   
                 main_slider(hDlg, config);  
                 main_value(hDlg, config);  
953                  break;                  break;
954    
955          case WM_HSCROLL :          case IDD_MOTION :
956                  if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER))                  config->motion_search = SendDlgItemMessage(hDlg, IDC_MOTION, CB_GETCURSEL, 0, 0);
957                  {                  config->vhq_mode = SendDlgItemMessage(hDlg, IDC_VHQ, CB_GETCURSEL, 0, 0);
958                          SetDlgItemInt(hDlg, IDC_VALUE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE);                  config->chromame = IsDlgChecked(hDlg, IDC_CHROMAME);
959                  }                  config->cartoon_mode = IsDlgChecked(hDlg, IDC_CARTOON);
                 else  
                 {  
                         return 0;  
                 }  
                 break;  
960    
961          case WM_COMMAND :          config->frame_drop_ratio = config_get_uint(hDlg, IDC_FRAMEDROP, config->frame_drop_ratio);
                 if (LOWORD(wParam) == IDC_MODE && HIWORD(wParam) == LBN_SELCHANGE)  
                 {  
                         main_download(hDlg, config);  
                         main_slider(hDlg, config);  
                         main_value(hDlg, config);  
                 }  
                 else if (LOWORD(wParam) == IDC_ADVANCED && HIWORD(wParam) == BN_CLICKED)  
                 {  
                         adv_dialog(hDlg, config);  
962    
963                          if (config->save)                  config->max_key_interval = config_get_uint(hDlg, IDC_MAXKEY, config->max_key_interval);
964                          {                  break;
                                 config_reg_set(config);  
                         }  
                 }  
                 else if (LOWORD(wParam) == IDC_DECODER && HIWORD(wParam) == BN_CLICKED)  
                 {  
                         dec_dialog(hDlg, config);  
965    
966                          if (config->save)          case IDD_QUANT :
967                          {                  config->min_iquant = config_get_uint(hDlg, IDC_MINIQUANT, config->min_iquant);
968                                  config_reg_set(config);                  config->max_iquant = config_get_uint(hDlg, IDC_MAXIQUANT, config->max_iquant);
969                          }                  config->min_pquant = config_get_uint(hDlg, IDC_MINPQUANT, config->min_pquant);
970                  }                  config->max_pquant = config_get_uint(hDlg, IDC_MAXPQUANT, config->max_pquant);
971                  else if (LOWORD(wParam) == IDC_DEFAULTS && HIWORD(wParam) == BN_CLICKED)                  config->min_bquant = config_get_uint(hDlg, IDC_MINBQUANT, config->min_bquant);
972                  {                  config->max_bquant = config_get_uint(hDlg, IDC_MAXBQUANT, config->max_bquant);
                         config_reg_default(config);  
973    
974                          SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);                  CONSTRAINVAL(config->min_iquant, 1, 31);
975                    CONSTRAINVAL(config->max_iquant, config->min_iquant, 31);
976                    CONSTRAINVAL(config->min_pquant, 1, 31);
977                    CONSTRAINVAL(config->max_pquant, config->min_pquant, 31);
978                    CONSTRAINVAL(config->min_bquant, 1, 31);
979                    CONSTRAINVAL(config->max_bquant, config->min_bquant, 31);
980    
981                          main_slider(hDlg, config);          config->trellis_quant = IsDlgChecked(hDlg, IDC_TRELLISQUANT);
982                          main_value(hDlg, config);                  break;
                 }  
                 else if (HIWORD(wParam) == EN_UPDATE && LOWORD(wParam) == IDC_VALUE)  
                 {  
                         int value = config_get_uint(hDlg, IDC_VALUE, 1);  
                         int max = 1;  
983    
984                          max = (config->mode == DLG_MODE_CBR) ? 10000 :          case IDD_DEBUG :
985                                  ((config->mode == DLG_MODE_VBR_QUAL) ? 100 :                  config->cpu = 0;
986                                  ((config->mode == DLG_MODE_VBR_QUANT) ? 31 : 1<<30));                  config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMX)      ? XVID_CPU_MMX : 0;
987                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_MMXEXT)   ? XVID_CPU_MMXEXT : 0;
988                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE)      ? XVID_CPU_SSE : 0;
989                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_SSE2)     ? XVID_CPU_SSE2 : 0;
990                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOW)    ? XVID_CPU_3DNOW : 0;
991                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_3DNOWEXT) ? XVID_CPU_3DNOWEXT : 0;
992                    config->cpu |= IsDlgChecked(hDlg, IDC_CPU_FORCE)    ? XVID_CPU_FORCE : 0;
993    
994                          if (value < 1)                  config->num_threads = config_get_uint(hDlg, IDC_NUMTHREADS, config->num_threads);
                         {  
                                 value = 1;  
                         }  
                         if (value > max)  
                         {  
                                 value = max;  
                                 SetDlgItemInt(hDlg, IDC_VALUE, value, FALSE);  
                         }  
995    
996                          if (config->mode != DLG_MODE_2PASS_2_INT)          config->fourcc_used = SendDlgItemMessage(hDlg, IDC_FOURCC, CB_GETCURSEL, 0, 0);
997                          {          config->debug = get_dlgitem_hex(hDlg, IDC_DEBUG, config->debug);
998                                  SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE, value);          config->vop_debug = IsDlgChecked(hDlg, IDC_VOPDEBUG);
999                          }          config->display_status = IsDlgChecked(hDlg, IDC_DISPLAY_STATUS);
                 }  
                 else if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)  
                 {  
                         main_download(hDlg, config);  
                         config->save = TRUE;  
                         EndDialog(hDlg, IDOK);  
                 }  
                 else if (LOWORD(wParam) == IDCANCEL)  
                 {  
                         config->save = FALSE;  
                         EndDialog(hDlg, IDCANCEL);  
                 }  
1000                  break;                  break;
   
         default :  
                 return 0;  
1001          }          }
   
         return 1;  
1002  }  }
1003    
1004    
1005    
1006  /* advanced dialog proc */  /* advanced dialog proc */
1007    
1008  BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  BOOL CALLBACK adv_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
# Line 1246  Line 1014 
1014          switch (uMsg)          switch (uMsg)
1015          {          {
1016          case WM_INITDIALOG :          case WM_INITDIALOG :
1017                  psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;                  psi = (PROPSHEETINFO*) ((LPPROPSHEETPAGE)lParam)->lParam;
1018                    SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);
                 SetWindowLong(hDlg, GWL_USERDATA, (LPARAM)psi);  
   
                 if (psi->page == DLG_GLOBAL)  
                 {  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"0 - None");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"1 - Very Low");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"2 - Low");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"3 - Medium");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"4 - High");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"5 - Very High");  
                         SendDlgItemMessage(hDlg, IDC_MOTION, CB_ADDSTRING, 0, (LPARAM)"6 - Ultra High");  
   
                         SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"H.263");  
                         SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG");  
                         SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"MPEG-Custom");  
                         SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"Modulated");  
                         SendDlgItemMessage(hDlg, IDC_QUANTTYPE, CB_ADDSTRING, 0, (LPARAM)"New Modulated HQ");  
   
                         SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"XVID");  
                         SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DIVX");  
                         SendDlgItemMessage(hDlg, IDC_FOURCC, CB_ADDSTRING, 0, (LPARAM)"DX50");  
   
                         SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"0 - Off");  
                         SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"1 - Mode Decision");  
                         SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"2 - Limited Search");  
                         SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"3 - Medium Search");  
                         SendDlgItemMessage(hDlg, IDC_VHQ, CB_ADDSTRING, 0, (LPARAM)"4 - Wide Search");  
                         /* XXX: reduced resolution is not ready for prime-time */  
                         ShowWindow(GetDlgItem(hDlg, IDC_REDUCED), SW_HIDE);  
                 }  
                 else if (psi->page == DLG_2PASSALT)  
                 {  
                         SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Low");  
                         SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"Medium");  
                         SendDlgItemMessage(hDlg, IDC_CURVETYPE, CB_ADDSTRING, 0, (LPARAM)"High");  
                 }  
                 else if (psi->page == DLG_CPU)  
                 {  
                         EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS_STATIC), FALSE);  
                         EnableWindow(GetDlgItem(hDlg, IDC_NUMTHREADS), FALSE);  
                 }  
1019    
1020                  if (hTooltip)                  if (g_hTooltip)
                 {  
1021                          EnumChildWindows(hDlg, enum_tooltips, 0);                          EnumChildWindows(hDlg, enum_tooltips, 0);
                 }  
1022    
1023                  adv_upload(hDlg, psi->page, psi->config);          adv_init(hDlg, psi->idd, psi->config);
                 adv_mode(hDlg, psi->config->mode);  
1024                  break;                  break;
1025    
1026          case WM_COMMAND :          case WM_COMMAND :
# Line 1304  Line 1028 
1028                  {                  {
1029                          switch (LOWORD(wParam))                          switch (LOWORD(wParam))
1030                          {                          {
1031                          case IDC_HINTEDME :              case IDC_BVOP :
1032                          case IDC_USEALT :              case IDC_ZONE_MODE_WEIGHT :
1033                          case IDC_USEAUTO :              case IDC_ZONE_MODE_QUANT :
1034                          case IDC_USEAUTOBONUS :              case IDC_ZONE_BVOPTHRESHOLD_ENABLE :
                         case IDC_CREDITS_START :  
                         case IDC_CREDITS_END :  
                         case IDC_CREDITS_RATE_RADIO :  
                         case IDC_CREDITS_QUANT_RADIO :  
                         case IDC_CREDITS_SIZE_RADIO :  
1035                          case IDC_CPU_AUTO :                          case IDC_CPU_AUTO :
1036                          case IDC_CPU_FORCE :                          case IDC_CPU_FORCE :
1037                                  adv_mode(hDlg, psi->config->mode);                                  adv_mode(hDlg, psi->idd, psi->config);
1038                                  break;                                  break;
1039                          }  
1040                  }              case IDC_QUANTMATRIX :
1041                  if ((LOWORD(wParam) == IDC_HINT_BROWSE || LOWORD(wParam) == IDC_STATS1_BROWSE || LOWORD(wParam) == IDC_STATS2_BROWSE) && HIWORD(wParam) == BN_CLICKED)                          DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config);
1042                    break;
1043    
1044                case IDC_STATS_BROWSE :
1045                  {                  {
1046                          OPENFILENAME ofn;                          OPENFILENAME ofn;
1047                          char tmp[MAX_PATH];                          char tmp[MAX_PATH];
                         int hComponent = (LOWORD(wParam) == IDC_STATS1_BROWSE ? IDC_STATS1 : IDC_STATS2);  
1048    
1049                          GetDlgItemText(hDlg, hComponent, tmp, MAX_PATH);                              GetDlgItemText(hDlg, IDC_STATS, tmp, MAX_PATH);
1050    
1051                          memset(&ofn, 0, sizeof(OPENFILENAME));                          memset(&ofn, 0, sizeof(OPENFILENAME));
1052                          ofn.lStructSize = sizeof(OPENFILENAME);                          ofn.lStructSize = sizeof(OPENFILENAME);
# Line 1336  Line 1057 
1057                          ofn.nMaxFile = MAX_PATH;                          ofn.nMaxFile = MAX_PATH;
1058                          ofn.Flags = OFN_PATHMUSTEXIST;                          ofn.Flags = OFN_PATHMUSTEXIST;
1059    
1060                          if (LOWORD(wParam) == IDC_HINT_BROWSE)                  if (psi->idd == IDD_RC_2PASS1) {
                         {  
                                 ofn.lpstrFilter = "motion hints (*.mvh)\0*.mvh\0All files (*.*)\0*.*\0\0";  
                                 if (GetOpenFileName(&ofn))  
                                 {  
                                         SetDlgItemText(hDlg, IDC_HINTFILE, tmp);  
                                 }  
                         }  
                         else if (LOWORD(wParam) == IDC_STATS1_BROWSE &&  
                                 psi->config->mode == DLG_MODE_2PASS_1)  
                         {  
1061                                  ofn.Flags |= OFN_OVERWRITEPROMPT;                                  ofn.Flags |= OFN_OVERWRITEPROMPT;
1062                                  if (GetSaveFileName(&ofn))                  }else{
1063                                  {                      ofn.Flags |= OFN_FILEMUSTEXIST;
                                         SetDlgItemText(hDlg, hComponent, tmp);  
                                 }  
1064                          }                          }
1065                          else  
1066                                if (GetSaveFileName(&ofn))
1067                          {                          {
1068                                  ofn.Flags |= OFN_FILEMUSTEXIST;                                      SetDlgItemText(hDlg, IDC_STATS, tmp);
                                 if (GetOpenFileName(&ofn)) {  
                                         SetDlgItemText(hDlg, hComponent, tmp);  
1069                                  }                                  }
1070                          }                          }
1071    
1072                case IDC_ZONE_FETCH :
1073                    SetDlgItemInt(hDlg, IDC_ZONE_FRAME, psi->config->ci.ciActiveFrame, FALSE);
1074                    break;
1075    
1076                default :
1077                    return TRUE;
1078                  }                  }
1079                  else if (LOWORD(wParam) == IDC_QUANTMATRIX && HIWORD(wParam) == BN_CLICKED)                  }else if (HIWORD(wParam) == LBN_SELCHANGE &&
1080                  {              (LOWORD(wParam) == IDC_PROFILE_PROFILE ||
1081                          DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_QUANTMATRIX), hDlg, quantmatrix_proc, (LPARAM)psi->config);               LOWORD(wParam) == IDC_LEVEL_PROFILE ||
1082                 LOWORD(wParam) == IDC_QUANTTYPE))
1083                    {
1084                adv_mode(hDlg, psi->idd, psi->config);
1085            }else if (HIWORD(wParam) == EN_UPDATE && (LOWORD(wParam)==IDC_ZONE_WEIGHT || LOWORD(wParam)==IDC_ZONE_QUANT)) {
1086    
1087                SendDlgItemMessage(hDlg, IDC_ZONE_SLIDER, TBM_SETPOS, TRUE,
1088                        get_dlgitem_float(hDlg, LOWORD(wParam), 100));
1089            }else {
1090                return 0;
1091                  }                  }
1092                  break;                  break;
1093    
1094            case WM_HSCROLL :
1095                    if((HWND)lParam == GetDlgItem(hDlg, IDC_ZONE_SLIDER)) {
1096                int idc = IsDlgChecked(hDlg, IDC_ZONE_MODE_WEIGHT) ? IDC_ZONE_WEIGHT : IDC_ZONE_QUANT;
1097                set_dlgitem_float(hDlg, idc, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0) );
1098                break;
1099            }
1100            return 0;
1101    
1102    
1103          case WM_NOTIFY :          case WM_NOTIFY :
1104                  switch (((NMHDR *)lParam)->code)                  switch (((NMHDR *)lParam)->code)
1105                  {                  {
1106            case PSN_SETACTIVE :
1107                OutputDebugString("PSN_SET");
1108                adv_upload(hDlg, psi->idd, psi->config);
1109                        adv_mode(hDlg, psi->idd, psi->config);
1110                SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1111                break;
1112    
1113                  case PSN_KILLACTIVE :                  case PSN_KILLACTIVE :
1114                          /* validate */              OutputDebugString("PSN_KILL");
1115                          adv_download(hDlg, psi->page, psi->config);              adv_download(hDlg, psi->idd, psi->config);
1116                          SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);                          SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1117                          break;                          break;
1118    
1119                  case PSN_APPLY :                  case PSN_APPLY :
1120                          /* apply */              OutputDebugString("PSN_APPLY");
                         adv_download(hDlg, psi->page, psi->config);  
                         SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);  
1121                          psi->config->save = TRUE;                          psi->config->save = TRUE;
1122                            SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
1123                          break;                          break;
1124                  }                  }
1125                  break;                  break;
# Line 1393  Line 1132 
1132  }  }
1133    
1134    
 /* quantization matrix dialog proc */  
1135    
1136  BOOL CALLBACK quantmatrix_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  
1137    /* load advanced options property sheet
1138      returns true, if the user accepted the changes
1139      or fasle if changes were canceled.
1140    
1141      */
1142    BOOL adv_dialog(HWND hParent, CONFIG * config, const int * dlgs, int size)
1143    {
1144            PROPSHEETINFO psi[6];
1145            PROPSHEETPAGE psp[6];
1146            PROPSHEETHEADER psh;
1147            CONFIG temp;
1148            int i;
1149    
1150            config->save = FALSE;
1151            memcpy(&temp, config, sizeof(CONFIG));
1152    
1153            for (i=0; i<size; i++)
1154            {
1155                    psp[i].dwSize = sizeof(PROPSHEETPAGE);
1156                    psp[i].dwFlags = 0;
1157                    psp[i].hInstance = g_hInst;
1158                    psp[i].pfnDlgProc = adv_proc;
1159                    psp[i].lParam = (LPARAM)&psi[i];
1160                    psp[i].pfnCallback = NULL;
1161                    psp[i].pszTemplate = MAKEINTRESOURCE(dlgs[i]);
1162    
1163                    psi[i].idd = dlgs[i];
1164                    psi[i].config = &temp;
1165            }
1166    
1167            psh.dwSize = sizeof(PROPSHEETHEADER);
1168            psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
1169            psh.hwndParent = hParent;
1170            psh.hInstance = g_hInst;
1171            psh.pszCaption = (LPSTR) "XviD Configuration";
1172            psh.nPages = size;
1173            psh.nStartPage = 0;
1174            psh.ppsp = (LPCPROPSHEETPAGE)&psp;
1175            psh.pfnCallback = NULL;
1176            PropertySheet(&psh);
1177    
1178        if (temp.save)
1179                    memcpy(config, &temp, sizeof(CONFIG));
1180    
1181        return temp.save;
1182    }
1183    
1184    /* ===================================================================================== */
1185    /* MAIN DIALOG ========================================================================= */
1186    /* ===================================================================================== */
1187    
1188    
1189    void main_insert_zone(HWND hDlg, zone_t * s, int i, BOOL insert)
1190    {
1191        char tmp[32];
1192    
1193        wsprintf(tmp,"%i",s->frame);
1194    
1195        if (insert) {
1196            LVITEM lvi;
1197    
1198            lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE;
1199            lvi.state = 0;
1200            lvi.stateMask = 0;
1201            lvi.iImage = 0;
1202            lvi.pszText = tmp;
1203            lvi.cchTextMax = strlen(tmp);
1204            lvi.iItem = i;
1205            lvi.iSubItem = 0;
1206            ListView_InsertItem(hDlg, &lvi);
1207        }else{
1208            ListView_SetItemText(hDlg, i, 0, tmp);
1209        }
1210    
1211        if (s->mode == RC_ZONE_WEIGHT) {
1212            sprintf(tmp,"%.2f",(float)s->weight/100);
1213        }else if (s->mode == RC_ZONE_QUANT) {
1214            sprintf(tmp,"( %.2f )",(float)s->quant/100);
1215        }else {
1216            strcpy(tmp,"EXT");
1217        }
1218        ListView_SetItemText(hDlg, i, 1, tmp);
1219    
1220        tmp[0] = '\0';
1221        if (s->type==XVID_TYPE_IVOP)
1222            strcat(tmp, "K ");
1223    
1224        if (s->greyscale)
1225            strcat(tmp, "G ");
1226    
1227        if (s->chroma_opt)
1228            strcat(tmp, "C ");
1229    
1230        ListView_SetItemText(hDlg, i, 2, tmp);
1231    }
1232    
1233    static int g_use_bitrate = 1;
1234    
1235    void main_mode(HWND hDlg, CONFIG * config)
1236    {
1237        const int profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0);
1238        const int rc_mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
1239        /* enable target rate/size control only for 1pass and 2pass  modes*/
1240        const int target_en = rc_mode==RC_MODE_1PASS || rc_mode==RC_MODE_2PASS2;
1241    
1242        char buf[16];
1243        int max;
1244    
1245        g_use_bitrate = rc_mode==RC_MODE_1PASS || config->use_2pass_bitrate;
1246    
1247        if (g_use_bitrate) {
1248            SetDlgItemText(hDlg, IDC_BITRATE_S, "Target bitrate (kbps):");
1249    
1250            wsprintf(buf, "%i kbps", DEFAULT_MIN_KBPS);
1251            SetDlgItemText(hDlg, IDC_BITRATE_MIN, buf);
1252    
1253            max = profiles[profile].max_bitrate;
1254            if (max == 0) max = DEFAULT_MAX_KBPS;
1255            wsprintf(buf, "%i kbps", max);
1256            SetDlgItemText(hDlg, IDC_BITRATE_MAX, buf);
1257    
1258                SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETRANGE, TRUE, MAKELONG(DEFAULT_MIN_KBPS, max));
1259            SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE,
1260                            config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) );
1261    
1262        }else{
1263            SetDlgItemText(hDlg, IDC_BITRATE_S, "Target size (kbytes):");
1264        }
1265    
1266        EnableDlgWindow(hDlg, IDC_BITRATE_S, target_en);
1267        EnableDlgWindow(hDlg, IDC_BITRATE, target_en);
1268    
1269        EnableDlgWindow(hDlg, IDC_BITRATE_MIN, target_en && g_use_bitrate);
1270        EnableDlgWindow(hDlg, IDC_BITRATE_MAX, target_en && g_use_bitrate);
1271        EnableDlgWindow(hDlg, IDC_SLIDER, target_en && g_use_bitrate);
1272    }
1273    
1274    
1275    
1276    void main_upload(HWND hDlg, CONFIG * config)
1277    {
1278        int i;
1279    
1280        SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1281            SendDlgItemMessage(hDlg, IDC_MODE, CB_SETCURSEL, config->mode, 0);
1282    
1283        if (g_use_bitrate) {
1284            SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE);
1285        }else{
1286            SetDlgItemInt(hDlg, IDC_BITRATE, config->desired_size, FALSE);
1287        }
1288    
1289        ListView_DeleteAllItems(GetDlgItem(hDlg,IDC_ZONES));
1290        for (i=0; i < config->num_zones; i++) {
1291            main_insert_zone(GetDlgItem(hDlg,IDC_ZONES), &config->zones[i], i, TRUE);
1292        }
1293    }
1294    
1295    
1296    /* downloads data from main dialog */
1297    void main_download(HWND hDlg, CONFIG * config)
1298    {
1299        config->profile = SendDlgItemMessage(hDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0);
1300            config->mode = SendDlgItemMessage(hDlg, IDC_MODE, CB_GETCURSEL, 0, 0);
1301    
1302        if (g_use_bitrate) {
1303            config->bitrate = config_get_uint(hDlg, IDC_BITRATE, config->bitrate);
1304        }else{
1305            config->desired_size = config_get_uint(hDlg, IDC_BITRATE, config->desired_size);
1306        }
1307    }
1308    
1309    
1310    /* main dialog proc */
1311    
1312    static const int profile_dlgs[] = { IDD_PROFILE, IDD_LEVEL };
1313    static const int single_dlgs[] = { IDD_RC_CBR };
1314    static const int pass1_dlgs[] = { IDD_RC_2PASS1 };
1315    static const int pass2_dlgs[] = { IDD_RC_2PASS2 };
1316    static const int zone_dlgs[] = { IDD_ZONE };
1317    static const int bitrate_dlgs[] = { IDD_CALC };
1318    static const int adv_dlgs[] = { IDD_MOTION, IDD_QUANT, IDD_DEBUG};
1319    
1320    
1321    BOOL CALLBACK main_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1322  {  {
1323          CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);          CONFIG* config = (CONFIG*)GetWindowLong(hDlg, GWL_USERDATA);
1324        unsigned int i;
1325    
1326          switch (uMsg)          switch (uMsg)
1327          {          {
1328          case WM_INITDIALOG :          case WM_INITDIALOG :
1329                  SetWindowLong(hDlg, GWL_USERDATA, lParam);                  SetWindowLong(hDlg, GWL_USERDATA, lParam);
1330                  config = (CONFIG*)lParam;                  config = (CONFIG*)lParam;
                 quant_upload(hDlg, config);  
1331    
1332                  if (hTooltip)                  for (i=0; i<sizeof(profiles)/sizeof(profile_t); i++)
1333                            SendDlgItemMessage(hDlg, IDC_PROFILE, CB_ADDSTRING, 0, (LPARAM)profiles[i].name);
1334    
1335            SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Single pass");
1336                    SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 1st pass");
1337                    SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Twopass - 2nd pass");
1338    #ifdef _DEBUG
1339            SendDlgItemMessage(hDlg, IDC_MODE, CB_ADDSTRING, 0, (LPARAM)"Null test speed");
1340    #endif
1341    
1342                    InitCommonControls();
1343    
1344                    if ((g_hTooltip = CreateWindow(TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP,
1345                                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
1346                                    NULL, NULL, g_hInst, NULL)))
1347                  {                  {
1348                            SetWindowPos(g_hTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
1349                            SendMessage(g_hTooltip, TTM_SETDELAYTIME, TTDT_AUTOMATIC, MAKELONG(1500, 0));
1350                            SendMessage(g_hTooltip, TTM_SETMAXTIPWIDTH, 0, 400);
1351    
1352                          EnumChildWindows(hDlg, enum_tooltips, 0);                          EnumChildWindows(hDlg, enum_tooltips, 0);
1353                  }                  }
                 break;  
1354    
1355          case WM_COMMAND :          SetClassLong(GetDlgItem(hDlg, IDC_BITRATE_S), GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND));
1356                  if (LOWORD(wParam) == IDOK && HIWORD(wParam) == BN_CLICKED)  
1357                  {                  {
1358                          quant_download(hDlg, config);              DWORD ext_style = ListView_GetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES));
1359                          EndDialog(hDlg, IDOK);              ext_style |= LVS_EX_FULLROWSELECT | LVS_EX_FLATSB ;
1360                ListView_SetExtendedListViewStyle(GetDlgItem(hDlg,IDC_ZONES), ext_style);
1361                  }                  }
1362                  else if (LOWORD(wParam) == IDCANCEL)  
1363                  {                  {
1364                          EndDialog(hDlg, IDCANCEL);              typedef struct {
1365                    char * name;
1366                    int value;
1367                } char_int_t;
1368    
1369                const static char_int_t columns[] = {
1370                    {"Frame #",     64},
1371                    {"Weight (Q)",  72},
1372                    {"Modifiers",   120}};
1373    
1374                LVCOLUMN lvc;
1375                int i;
1376    
1377                /* Initialize the LVCOLUMN structure.  */
1378                lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
1379                lvc.fmt = LVCFMT_LEFT;
1380    
1381                /* Add the columns.  */
1382                for (i=0; i<sizeof(columns)/sizeof(char_int_t); i++) {
1383                    lvc.pszText = (char*)columns[i].name;
1384                    lvc.cchTextMax = strlen(columns[i].name);
1385                    lvc.iSubItem = i;
1386                    lvc.cx = columns[i].value;  /* column width, pixels */
1387                    ListView_InsertColumn(GetDlgItem(hDlg,IDC_ZONES), i, &lvc);
1388                }
1389                  }                  }
1390                  else if ((LOWORD(wParam) == IDC_LOAD || LOWORD(wParam) == IDC_SAVE) && HIWORD(wParam) == BN_CLICKED)  
1391            /* XXX: main_mode needs RC_MODE_xxx, main_upload needs g_use_bitrate set correctly... */
1392            main_upload(hDlg, config);
1393            main_mode(hDlg, config);
1394            main_upload(hDlg, config);
1395                    break;
1396    
1397        case WM_NOTIFY :
1398                  {                  {
1399                          OPENFILENAME ofn;              NMHDR * n = (NMHDR*)lParam;
                         char file[MAX_PATH];  
1400    
1401                          HANDLE hFile;              if (n->code == NM_DBLCLK) {
1402                          DWORD read=128, wrote=0;                   NMLISTVIEW * nmlv = (NMLISTVIEW*) lParam;
1403                          BYTE quant_data[128];                   config->cur_zone = nmlv->iItem;
1404    
1405                          strcpy(file, "\\matrix");                   main_download(hDlg, config);
1406                          memset(&ofn, 0, sizeof(OPENFILENAME));                   if (config->cur_zone >= 0 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) {
1407                          ofn.lStructSize = sizeof(OPENFILENAME);                       main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[config->cur_zone], config->cur_zone, FALSE);
1408                     }
1409                     break;
1410                }
1411    
1412                          ofn.hwndOwner = hDlg;              if (n->code == NM_RCLICK) {
1413                          ofn.lpstrFilter = "All files (*.*)\0*.*\0\0";                  OutputDebugString("Right click");
1414                          ofn.lpstrFile = file;              }
1415                          ofn.nMaxFile = MAX_PATH;          break;
1416                          ofn.Flags = OFN_PATHMUSTEXIST;          }
1417    
1418                          if (LOWORD(wParam) == IDC_SAVE)          case WM_COMMAND :
1419                          {          if (HIWORD(wParam) == BN_CLICKED) {
                                 ofn.Flags |= OFN_OVERWRITEPROMPT;  
                                 if (GetSaveFileName(&ofn))  
                                 {  
                                         hFile = CreateFile(file, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);  
1420    
1421                                          quant_download(hDlg, config);              switch(LOWORD(wParam)) {
1422                                          memcpy(quant_data, config->qmatrix_intra, 64);              case IDC_PROFILE_ADV :
1423                                          memcpy(quant_data+64, config->qmatrix_inter, 64);                  main_download(hDlg, config);
1424                                adv_dialog(hDlg, config, profile_dlgs, sizeof(profile_dlgs)/sizeof(int));
1425    
1426                                          if (hFile == INVALID_HANDLE_VALUE)                  SendDlgItemMessage(hDlg, IDC_PROFILE, CB_SETCURSEL, config->profile, 0);
1427                                          {                  main_mode(hDlg, config);
1428                                                  DEBUGERR("Couldn't save quant matrix");                  break;
1429    
1430                case IDC_MODE_ADV :
1431                    main_download(hDlg, config);
1432                            if (config->mode == RC_MODE_1PASS) {
1433                                        adv_dialog(hDlg, config, single_dlgs, sizeof(single_dlgs)/sizeof(int));
1434                                }else if (config->mode == RC_MODE_2PASS1) {
1435                                        adv_dialog(hDlg, config, pass1_dlgs, sizeof(pass1_dlgs)/sizeof(int));
1436                                }else if (config->mode == RC_MODE_2PASS2) {
1437                                        adv_dialog(hDlg, config, pass2_dlgs, sizeof(pass2_dlgs)/sizeof(int));
1438                                          }                                          }
1439                                          else                  break;
1440                                          {  
1441                                                  if (!WriteFile(hFile, quant_data, 128, &wrote, 0))  
1442                case IDC_BITRATE_S :
1443                    /* alternate between bitrate/desired_length metrics */
1444                    main_download(hDlg, config);
1445                    config->use_2pass_bitrate = !config->use_2pass_bitrate;
1446                    main_mode(hDlg, config);
1447                    main_upload(hDlg, config);
1448                    break;
1449    
1450                case IDC_BITRATE_CALC :
1451                    main_download(hDlg, config);
1452                    adv_dialog(hDlg, config, bitrate_dlgs, sizeof(bitrate_dlgs)/sizeof(int));
1453                    //SetDlgItemInt(hDlg, IDC_BITRATE, config->bitrate, FALSE);
1454                    main_mode(hDlg, config);
1455                    break;
1456    
1457                case IDC_ADD :
1458                                                  {                                                  {
1459                                                          DEBUGERR("Couldnt write quant matrix");                  int i, sel, new_frame;
1460    
1461                    if (config->num_zones >= MAX_ZONES) {
1462                        MessageBox(hDlg, "Exceeded maximum number of zones.\nIncrease config.h:MAX_ZONES and rebuild.", "Warning", 0);
1463                        break;
1464                    }
1465    
1466                    sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1467    
1468                    if (sel<0) {
1469                        if (config->ci_valid && config->ci.ciActiveFrame>0) {
1470                            for(sel=0; sel<config->num_zones-1 && config->zones[sel].frame<config->ci.ciActiveFrame; sel++) ;
1471                            sel--;
1472                            new_frame = config->ci.ciActiveFrame;
1473                        }else{
1474                            sel = config->num_zones-1;
1475                            new_frame = sel<0 ? 0 : config->zones[sel].frame + 1;
1476                                                  }                                                  }
1477                    }else{
1478                        new_frame = config->zones[sel].frame + 1;
1479                                          }                                          }
1480    
1481                                          CloseHandle(hFile);                  for(i=config->num_zones-1; i>sel; i--) {
1482                        config->zones[i+1] = config->zones[i];
1483                                  }                                  }
1484                    config->num_zones++;
1485                    config->zones[sel+1].frame = new_frame;
1486                    config->zones[sel+1].mode = RC_ZONE_WEIGHT;
1487                    config->zones[sel+1].weight = 100;
1488                    config->zones[sel+1].quant = 500;
1489                    config->zones[sel+1].type = XVID_TYPE_AUTO;
1490                    config->zones[sel+1].greyscale = 0;
1491                    config->zones[sel+1].chroma_opt = 0;
1492                    config->zones[sel+1].bvop_threshold = 0;
1493    
1494                    ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0x00000000, LVIS_SELECTED);
1495                    main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[sel+1], sel+1, TRUE);
1496                    ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel+1, 0xffffffff, LVIS_SELECTED);
1497                    break;
1498                          }                          }
                         else  
                         {  
                                 ofn.Flags |= OFN_FILEMUSTEXIST;  
                                 if (GetOpenFileName(&ofn))  
                                 {  
                                         hFile = CreateFile(file, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);  
1499    
1500                                          if (hFile == INVALID_HANDLE_VALUE)              case IDC_REMOVE :
1501                                          {                                          {
1502                                                  DEBUGERR("Couldn't load quant matrix");                  int i, sel;
1503                    sel = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1504    
1505                    if (sel == -1) {
1506                        MessageBox(hDlg, "Nothing selected", "Warning", 0);
1507                        break;
1508                                          }                                          }
1509                                          else  
1510                                          {                  for (i=sel; i<config->num_zones-1; i++) {
1511                                                  if (!ReadFile(hFile, quant_data, 128, &read, 0))                      config->zones[i] = config->zones[i+1];
                                                 {  
                                                         DEBUGERR("Couldnt read quant matrix");  
1512                                                  }                                                  }
1513                                                  else                  config->num_zones--;
1514                                                  {                  ListView_DeleteItem(GetDlgItem(hDlg, IDC_ZONES), sel);
1515                                                          memcpy(config->qmatrix_intra, quant_data, 64);  
1516                                                          memcpy(config->qmatrix_inter, quant_data+64, 64);                  sel--;
1517                                                          quant_upload(hDlg, config);                  if (sel==0 && config->num_zones>1) {
1518                        sel=1;
1519                                                  }                                                  }
1520                    ListView_SetItemState(GetDlgItem(hDlg, IDC_ZONES), sel, 0xffffffff, LVIS_SELECTED);
1521                    break;
1522                                          }                                          }
1523    
1524                                          CloseHandle(hFile);              case IDC_EDIT :
1525                    main_download(hDlg, config);
1526                    config->cur_zone = ListView_GetNextItem(GetDlgItem(hDlg, IDC_ZONES), -1, LVNI_SELECTED);
1527                    if (config->cur_zone != -1 && adv_dialog(hDlg, config, zone_dlgs, sizeof(zone_dlgs)/sizeof(int))) {
1528                        main_insert_zone(GetDlgItem(hDlg, IDC_ZONES), &config->zones[config->cur_zone], config->cur_zone, FALSE);
1529                    }
1530                    break;
1531    
1532                case IDC_ADVANCED :
1533                    main_download(hDlg, config);
1534                    adv_dialog(hDlg, config, adv_dlgs, sizeof(adv_dlgs)/sizeof(int));
1535                    break;
1536    
1537                case IDC_DEFAULTS :
1538                                config_reg_default(config);
1539                    main_upload(hDlg, config);
1540                    break;
1541    
1542                case IDOK :
1543                                main_download(hDlg, config);
1544                                config->save = TRUE;
1545                                EndDialog(hDlg, IDOK);
1546                    break;
1547    
1548                case IDCANCEL :
1549                            config->save = FALSE;
1550                            EndDialog(hDlg, IDCANCEL);
1551                    break;
1552                                  }                                  }
1553            }else if (HIWORD(wParam) == LBN_SELCHANGE &&
1554                (LOWORD(wParam)==IDC_PROFILE || LOWORD(wParam)==IDC_MODE)) {
1555    
1556                main_download(hDlg, config);
1557                main_mode(hDlg, config);
1558                main_upload(hDlg, config);
1559    
1560            }else if (HIWORD(wParam)==EN_UPDATE && LOWORD(wParam)==IDC_BITRATE) {
1561    
1562                if (g_use_bitrate) {
1563                    SendDlgItemMessage(hDlg, IDC_SLIDER, TBM_SETPOS, TRUE,
1564                            config_get_uint(hDlg, IDC_BITRATE, DEFAULT_MIN_KBPS) );
1565                          }                          }
1566    
1567            }else {
1568                return 0;
1569                  }                  }
1570                  break;                  break;
1571    
1572            case WM_HSCROLL :
1573                    if((HWND)lParam == GetDlgItem(hDlg, IDC_SLIDER)) {
1574                SetDlgItemInt(hDlg, IDC_BITRATE, SendMessage((HWND)lParam, TBM_GETPOS, 0, 0), FALSE);
1575                break;
1576            }
1577            return 0;
1578    
1579          default :          default :
1580                  return 0;                  return 0;
1581          }          }
# Line 1506  Line 1584 
1584  }  }
1585    
1586    
1587  /* about dialog proc */  
1588    /* ===================================================================================== */
1589    /* ABOUT DIALOG ======================================================================== */
1590    /* ===================================================================================== */
1591    
1592  BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)  BOOL CALLBACK about_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1593  {  {
# Line 1526  Line 1607 
1607                          info.version = XVID_VERSION;                          info.version = XVID_VERSION;
1608                          xvid_global(0, XVID_GBL_INFO, &info, NULL);                          xvid_global(0, XVID_GBL_INFO, &info, NULL);
1609                          wsprintf(core, "libxvidcore version %d.%d.%d (\"%s\")",                          wsprintf(core, "libxvidcore version %d.%d.%d (\"%s\")",
1610                                  XVID_MAJOR(info.actual_version),                                  XVID_VERSION_MAJOR(info.actual_version),
1611                                  XVID_MINOR(info.actual_version),                                  XVID_VERSION_MINOR(info.actual_version),
1612                                  XVID_PATCH(info.actual_version),                                  XVID_VERSION_PATCH(info.actual_version),
1613                                  info.build);                                  info.build);
1614    
1615                          SetDlgItemText(hDlg, IDC_CORE, core);                          SetDlgItemText(hDlg, IDC_CORE, core);
1616    
1617                          hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L);                          hFont = (HFONT)SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_GETFONT, 0, 0L);
1618    
1619                          if (GetObject(hFont, sizeof(LOGFONT), &lfData))                          if (GetObject(hFont, sizeof(LOGFONT), &lfData)) {
                         {  
1620                                  lfData.lfUnderline = 1;                                  lfData.lfUnderline = 1;
1621    
1622                                  hFont = CreateFontIndirect(&lfData);                                  hFont = CreateFontIndirect(&lfData);
1623                                  if (hFont)                                  if (hFont) {
                                 {  
1624                                          SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L);                                          SendDlgItemMessage(hDlg, IDC_WEBSITE, WM_SETFONT, (WPARAM)hFont, 1L);
1625                                  }                                  }
1626                          }                          }

Legend:
Removed from v.889  
changed lines
  Added in v.1272

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