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

Annotation of /trunk/xvidcore/dshow/src/config.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2022 - (view) (download)

1 : edgomez 1382 /*****************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * - Configuration processing -
5 :     *
6 : Isibaar 1994 * Copyright(C) 2002-2011 Peter Ross <pross@xvid.org>
7 : edgomez 1382 *
8 :     * This program is free software ; you can redistribute it and/or modify
9 :     * it under the terms of the GNU General Public License as published by
10 :     * the Free Software Foundation ; either version 2 of the License, or
11 :     * (at your option) any later version.
12 :     *
13 :     * This program is distributed in the hope that it will be useful,
14 :     * but WITHOUT ANY WARRANTY ; without even the implied warranty of
15 :     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     * GNU General Public License for more details.
17 :     *
18 :     * You should have received a copy of the GNU General Public License
19 :     * along with this program ; if not, write to the Free Software
20 :     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 :     *
22 : Isibaar 1988 * $Id$
23 : edgomez 1382 *
24 :     ****************************************************************************/
25 :    
26 :     #include <windows.h>
27 :     #include <commctrl.h>
28 : Isibaar 1994 #include <xvid.h> // Xvid API
29 : edgomez 1382 #include "config.h"
30 :     #include "debug.h"
31 :     #include "resource.h"
32 :    
33 :    
34 :     // -----------------------------------------
35 :     // global config structure
36 :     CONFIG g_config;
37 :    
38 :    
39 :    
40 :     void LoadRegistryInfo()
41 :     {
42 :     HKEY hKey;
43 :     DWORD size;
44 :     RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);
45 :    
46 :     // Set the default post-processing settings
47 : Isibaar 2018 REG_GET_N(TEXT("Brightness"), g_config.nBrightness, 0)
48 :     REG_GET_N(TEXT("Deblock_Y"), g_config.nDeblock_Y, 0)
49 :     REG_GET_N(TEXT("Deblock_UV"), g_config.nDeblock_UV, 0)
50 :     REG_GET_N(TEXT("Dering_Y"), g_config.nDering_Y, 0)
51 :     REG_GET_N(TEXT("Dering_UV"), g_config.nDering_UV, 0)
52 :     REG_GET_N(TEXT("FilmEffect"), g_config.nFilmEffect, 0)
53 :     REG_GET_N(TEXT("ForceColorspace"), g_config.nForceColorspace, 0)
54 :     REG_GET_N(TEXT("FlipVideo"), g_config.nFlipVideo, 0)
55 :     REG_GET_N(TEXT("Supported_4CC"), g_config.supported_4cc, 0)
56 :     REG_GET_N(TEXT("Videoinfo_Compat"), g_config.videoinfo_compat, 0)
57 :     REG_GET_N(TEXT("Decoder_Aspect_Ratio"), g_config.aspect_ratio, 0)
58 :     REG_GET_N(TEXT("num_threads"), g_config.num_threads, 0)
59 :     REG_GET_N(TEXT("cpu_flags"), g_config.cpu, 0)
60 : Isibaar 2022 REG_GET_N(TEXT("Tray_Icon"), g_config.bTrayIcon, 1);
61 : edgomez 1382
62 :     RegCloseKey(hKey);
63 :     }
64 :    
65 :     void SaveRegistryInfo()
66 :     {
67 :     HKEY hKey;
68 :     DWORD dispo;
69 :    
70 :     if (RegCreateKeyEx(
71 :     XVID_REG_KEY,
72 :     XVID_REG_SUBKEY,
73 :     0,
74 :     XVID_REG_CLASS,
75 :     REG_OPTION_NON_VOLATILE,
76 :     KEY_WRITE,
77 :     0,
78 :     &hKey,
79 :     &dispo) != ERROR_SUCCESS)
80 :     {
81 : Isibaar 2018 OutputDebugString(TEXT("Couldn't create XVID_REG_SUBKEY"));
82 : edgomez 1382 return;
83 :     }
84 :    
85 : Isibaar 2018 REG_SET_N(TEXT("Brightness"), g_config.nBrightness);
86 :     REG_SET_N(TEXT("Deblock_Y"), g_config.nDeblock_Y);
87 :     REG_SET_N(TEXT("Deblock_UV"), g_config.nDeblock_UV);
88 :     REG_SET_N(TEXT("Dering_Y"), g_config.nDering_Y);
89 :     REG_SET_N(TEXT("Dering_UV"), g_config.nDering_UV);
90 :     REG_SET_N(TEXT("FilmEffect"), g_config.nFilmEffect);
91 :     REG_SET_N(TEXT("ForceColorspace"), g_config.nForceColorspace);
92 :     REG_SET_N(TEXT("FlipVideo"), g_config.nFlipVideo);
93 :     REG_SET_N(TEXT("Supported_4CC"), g_config.supported_4cc);
94 :     REG_SET_N(TEXT("Videoinfo_Compat"), g_config.videoinfo_compat);
95 :     REG_SET_N(TEXT("Decoder_Aspect_Ratio"), g_config.aspect_ratio);
96 :     REG_SET_N(TEXT("num_threads"), g_config.num_threads);
97 : Isibaar 2022 REG_SET_N(TEXT("Tray_Icon"), g_config.bTrayIcon);
98 : edgomez 1382
99 :     RegCloseKey(hKey);
100 :     }
101 :    
102 :    
103 :    
104 : Isibaar 1827 INT_PTR CALLBACK adv_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
105 : edgomez 1382 {
106 :     HWND hBrightness;
107 :    
108 : Isibaar 2018 UNREFERENCED_PARAMETER(lParam);
109 : edgomez 1382 switch ( uMsg )
110 :     {
111 :     case WM_DESTROY:
112 :     {
113 : Isibaar 1827 LPARAM nForceColorspace;
114 :     LPARAM aspect_ratio;
115 : syskin 1488
116 : edgomez 1382 nForceColorspace = SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_GETCURSEL, 0, 0);
117 :     if ( g_config.nForceColorspace != nForceColorspace )
118 :     {
119 : Isibaar 2018 MessageBox(0, TEXT("You have changed the output colorspace.\r\nClose the movie and open it for the new colorspace to take effect."), TEXT("Xvid DShow"), MB_TOPMOST);
120 : edgomez 1382 }
121 : Isibaar 1827 g_config.nForceColorspace = (int) nForceColorspace;
122 : syskin 1488
123 :     aspect_ratio = SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_GETCURSEL, 0, 0);
124 :     if ( g_config.aspect_ratio != aspect_ratio )
125 :     {
126 : Isibaar 2018 MessageBox(0, TEXT("You have changed the default aspect ratio.\r\nClose the movie and open it for the new aspect ratio to take effect."), TEXT("Xvid DShow"), MB_TOPMOST);
127 : syskin 1488 }
128 : Isibaar 1827 g_config.aspect_ratio = (int) aspect_ratio;
129 : edgomez 1382 SaveRegistryInfo();
130 :     }
131 :     break;
132 :    
133 :     case WM_INITDIALOG:
134 : Isibaar 1994 {
135 :     xvid_gbl_info_t info;
136 :     char core[100];
137 :     HINSTANCE m_hdll;
138 : edgomez 1382
139 : Isibaar 1994 memset(&info, 0, sizeof(info));
140 :     info.version = XVID_VERSION;
141 :    
142 :     m_hdll = LoadLibrary(XVID_DLL_NAME);
143 :     if (m_hdll != NULL) {
144 :    
145 :     ((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"))
146 :     (0, XVID_GBL_INFO, &info, NULL);
147 :    
148 : Isibaar 2018 wsprintfA(core, "Xvid MPEG-4 Video Codec v%d.%d.%d",
149 : Isibaar 1994 XVID_VERSION_MAJOR(info.actual_version),
150 :     XVID_VERSION_MINOR(info.actual_version),
151 :     XVID_VERSION_PATCH(info.actual_version));
152 :    
153 :     FreeLibrary(m_hdll);
154 :     } else {
155 : Isibaar 2018 wsprintfA(core, "xvidcore.dll not found!");
156 : Isibaar 1994 }
157 :    
158 : Isibaar 2018 SetDlgItemTextA(hwnd, IDC_CORE, core);
159 : Isibaar 1994 }
160 :    
161 : edgomez 1382 // Load Force Colorspace Box
162 : Isibaar 2018 SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)TEXT("No Force"));
163 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)TEXT("YV12"));
164 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)TEXT("YUY2"));
165 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)TEXT("RGB24"));
166 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)TEXT("RGB32"));
167 : edgomez 1382
168 :     // Select Colorspace
169 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
170 :    
171 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
172 : suxen_drol 1397 SendMessage(hBrightness, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(-96, 96));
173 :     SendMessage(hBrightness, TBM_SETTICFREQ, (WPARAM)16, (LPARAM)0);
174 :     SendMessage(hBrightness, TBM_SETPOS, (WPARAM)TRUE, (LPARAM) g_config.nBrightness);
175 : edgomez 1382
176 : syskin 1488 // Load Aspect Ratio Box
177 : Isibaar 2018 SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)TEXT("Auto (MPEG-4 first)"));
178 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)TEXT("Auto (external first)"));
179 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)TEXT("4:3"));
180 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)TEXT("16:9"));
181 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)TEXT("2.35:1"));
182 : syskin 1488
183 :     // Select Aspect Ratio
184 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
185 :    
186 :    
187 : edgomez 1382 // Load Buttons
188 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
189 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
190 : syskin 1437 SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
191 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
192 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
193 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
194 :    
195 :     // 4CC checkbuttons
196 :     SendMessage(GetDlgItem(hwnd, IDC_DIVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DIVX, 0);
197 : Isibaar 1949 SendMessage(GetDlgItem(hwnd, IDC_3IVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_3IVX, 0);
198 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_MP4V), BM_SETCHECK, g_config.supported_4cc & SUPPORT_MP4V, 0);
199 :     SendMessage(GetDlgItem(hwnd, IDC_COMPAT), BM_SETCHECK, g_config.videoinfo_compat, 0);
200 :    
201 : Isibaar 2022 // TrayIcon
202 :     SendMessage(GetDlgItem(hwnd, IDC_TRAYICON), BM_SETCHECK, g_config.bTrayIcon, 0);
203 :    
204 : syskin 1437 EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
205 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
206 :    
207 : syskin 1498 EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
208 : syskin 1488
209 : edgomez 1382 // Set Date & Time of Compilation
210 :     DPRINTF("(%s %s)", __DATE__, __TIME__);
211 :     break;
212 :    
213 :     case WM_COMMAND:
214 :     switch ( wParam )
215 :     {
216 :     case IDC_RESET:
217 :     ZeroMemory(&g_config, sizeof(CONFIG));
218 : Isibaar 2022 g_config.bTrayIcon = 1;
219 :    
220 : edgomez 1382 hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
221 : suxen_drol 1397 SendMessage(hBrightness, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) g_config.nBrightness);
222 : Isibaar 2022
223 : edgomez 1382 // Load Buttons
224 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
225 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
226 : syskin 1437 SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
227 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
228 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
229 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
230 :     g_config.nForceColorspace = 0;
231 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
232 : syskin 1488 g_config.aspect_ratio = 0;
233 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
234 : Isibaar 2022 SendMessage(GetDlgItem(hwnd, IDC_TRAYICON), CB_SETCURSEL, g_config.bTrayIcon, 0);
235 : edgomez 1382 break;
236 :     case IDC_DEBLOCK_Y:
237 :     g_config.nDeblock_Y = !g_config.nDeblock_Y;
238 :     break;
239 :     case IDC_DEBLOCK_UV:
240 :     g_config.nDeblock_UV = !g_config.nDeblock_UV;
241 :     break;
242 : syskin 1437 case IDC_DERINGY:
243 :     g_config.nDering_Y = !g_config.nDering_Y;
244 : edgomez 1382 break;
245 : syskin 1437 case IDC_DERINGUV:
246 :     g_config.nDering_UV = !g_config.nDering_UV;
247 :     break;
248 : edgomez 1382 case IDC_FILMEFFECT:
249 :     g_config.nFilmEffect = !g_config.nFilmEffect;
250 :     break;
251 :     case IDC_FLIPVIDEO:
252 :     g_config.nFlipVideo = !g_config.nFlipVideo;
253 :     break;
254 :     case IDC_DIVX:
255 :     g_config.supported_4cc ^= SUPPORT_DIVX;
256 :     break;
257 : Isibaar 1949 case IDC_3IVX:
258 :     g_config.supported_4cc ^= SUPPORT_3IVX;
259 : edgomez 1382 break;
260 :     case IDC_MP4V:
261 :     g_config.supported_4cc ^= SUPPORT_MP4V;
262 :     break;
263 :     case IDC_COMPAT:
264 :     g_config.videoinfo_compat = !g_config.videoinfo_compat;
265 :     break;
266 : Isibaar 2022 case IDC_TRAYICON:
267 :     g_config.bTrayIcon = !g_config.bTrayIcon;
268 :     break;
269 : edgomez 1382 default :
270 :     return FALSE;
271 :     }
272 : syskin 1437 EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
273 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
274 : syskin 1498
275 :     EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
276 :    
277 : edgomez 1382 SaveRegistryInfo();
278 : syskin 1437
279 :    
280 : edgomez 1382 break;
281 :     case WM_NOTIFY:
282 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
283 : Isibaar 1827 g_config.nBrightness = (int) SendMessage(hBrightness, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL);
284 : edgomez 1382 SaveRegistryInfo();
285 :     break;
286 :     default :
287 :     return FALSE;
288 :     }
289 :    
290 :     return TRUE; /* ok */
291 :     }
292 :    
293 :    
294 :    
295 :    
296 :    

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