[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 2113 - (view) (download)

1 : Isibaar 2113 /*****************************************************************************
2 :     *
3 :     * XVID MPEG-4 VIDEO CODEC
4 :     * - Configuration processing -
5 :     *
6 :     * Copyright(C) 2002-2012 Peter Ross <pross@xvid.org>
7 :     *
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 :     * $Id$
23 :     *
24 :     ****************************************************************************/
25 :    
26 :     #include <windows.h>
27 :     #include <commctrl.h>
28 :     #include <xvid.h>
29 :     #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 :     REG_GET_N("Brightness", g_config.nBrightness, 0)
48 :     REG_GET_N("Deblock_Y", g_config.nDeblock_Y, 0)
49 :     REG_GET_N("Deblock_UV", g_config.nDeblock_UV, 0)
50 :     REG_GET_N("Dering_Y", g_config.nDering_Y, 0)
51 :     REG_GET_N("Dering_UV", g_config.nDering_UV, 0)
52 :     REG_GET_N("FilmEffect", g_config.nFilmEffect, 0)
53 :     REG_GET_N("ForceColorspace", g_config.nForceColorspace, 0)
54 :     REG_GET_N("FlipVideo", g_config.nFlipVideo, 0)
55 :     REG_GET_N("Supported_4CC", g_config.supported_4cc, 0)
56 :     REG_GET_N("Videoinfo_Compat", g_config.videoinfo_compat, 0)
57 :     REG_GET_N("Decoder_Aspect_Ratio", g_config.aspect_ratio, 0)
58 :     REG_GET_N("num_threads", g_config.num_threads, 0)
59 :     REG_GET_N("cpu_flags", g_config.cpu, 0)
60 :     REG_GET_N("Tray_Icon", g_config.bTrayIcon, 1);
61 :    
62 :     RegCloseKey(hKey);
63 :     }
64 :    
65 :     void SaveRegistryInfo(int perfCount)
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 :     OutputDebugString("Couldn't create XVID_REG_SUBKEY");
82 :     return;
83 :     }
84 :    
85 :     if (perfCount > 0) {
86 :     unsigned int updateCount = 0;
87 :     HKEY hKey2 = hKey;
88 :     DWORD size;
89 :    
90 :     RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);
91 :     REG_GET_N("PerfCount", updateCount, 0);
92 :     RegCloseKey(hKey);
93 :     hKey = hKey2;
94 :     updateCount += perfCount;
95 :     REG_SET_N("PerfCount", updateCount);
96 :     }
97 :     else {
98 :     REG_SET_N("Brightness", g_config.nBrightness);
99 :     REG_SET_N("Deblock_Y", g_config.nDeblock_Y);
100 :     REG_SET_N("Deblock_UV", g_config.nDeblock_UV);
101 :     REG_SET_N("Dering_Y", g_config.nDering_Y);
102 :     REG_SET_N("Dering_UV", g_config.nDering_UV);
103 :     REG_SET_N("FilmEffect", g_config.nFilmEffect);
104 :     REG_SET_N("ForceColorspace", g_config.nForceColorspace);
105 :     REG_SET_N("FlipVideo", g_config.nFlipVideo);
106 :     REG_SET_N("Supported_4CC", g_config.supported_4cc);
107 :     REG_SET_N("Videoinfo_Compat", g_config.videoinfo_compat);
108 :     REG_SET_N("Decoder_Aspect_Ratio", g_config.aspect_ratio);
109 :     REG_SET_N("num_threads", g_config.num_threads);
110 :     REG_SET_N("Tray_Icon", g_config.bTrayIcon);
111 :     }
112 :    
113 :     RegCloseKey(hKey);
114 :     }
115 :    
116 :    
117 :    
118 :     INT_PTR CALLBACK adv_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
119 :     {
120 :     HWND hBrightness;
121 :    
122 :     switch ( uMsg )
123 :     {
124 :     case WM_DESTROY:
125 :     {
126 :     LPARAM nForceColorspace;
127 :     LPARAM aspect_ratio;
128 :    
129 :     nForceColorspace = SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_GETCURSEL, 0, 0);
130 :     if ( g_config.nForceColorspace != nForceColorspace )
131 :     {
132 :     MessageBox(0, "You have changed the output colorspace.\r\nClose the movie and open it for the new colorspace to take effect.", "Xvid DShow", MB_TOPMOST);
133 :     }
134 :     g_config.nForceColorspace = (int) nForceColorspace;
135 :    
136 :     aspect_ratio = SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_GETCURSEL, 0, 0);
137 :     if ( g_config.aspect_ratio != aspect_ratio )
138 :     {
139 :     MessageBox(0, "You have changed the default aspect ratio.\r\nClose the movie and open it for the new aspect ratio to take effect.", "Xvid DShow", MB_TOPMOST);
140 :     }
141 :     g_config.aspect_ratio = (int) aspect_ratio;
142 :     SaveRegistryInfo(0);
143 :     }
144 :     break;
145 :    
146 :     case WM_INITDIALOG:
147 :     {
148 :     xvid_gbl_info_t info;
149 :     char core[100];
150 :     HINSTANCE m_hdll;
151 :    
152 :     memset(&info, 0, sizeof(info));
153 :     info.version = XVID_VERSION;
154 :    
155 :     m_hdll = LoadLibrary(XVID_DLL_NAME);
156 :     if (m_hdll != NULL) {
157 :    
158 :     ((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"))
159 :     (0, XVID_GBL_INFO, &info, NULL);
160 :    
161 :     wsprintf(core, "Xvid MPEG-4 Video Codec v%d.%d.%d",
162 :     XVID_VERSION_MAJOR(info.actual_version),
163 :     XVID_VERSION_MINOR(info.actual_version),
164 :     XVID_VERSION_PATCH(info.actual_version));
165 :    
166 :     FreeLibrary(m_hdll);
167 :     } else {
168 :     wsprintf(core, "xvidcore.dll not found!");
169 :     }
170 :    
171 :     SetDlgItemText(hwnd, IDC_CORE, core);
172 :     }
173 :    
174 :     // Load Force Colorspace Box
175 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"No Force");
176 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YV12");
177 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YUY2");
178 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB24");
179 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB32");
180 :    
181 :     // Select Colorspace
182 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
183 :    
184 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
185 :     SendMessage(hBrightness, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(-96, 96));
186 :     SendMessage(hBrightness, TBM_SETTICFREQ, (WPARAM)16, (LPARAM)0);
187 :     SendMessage(hBrightness, TBM_SETPOS, (WPARAM)TRUE, (LPARAM) g_config.nBrightness);
188 :    
189 :     // Load Aspect Ratio Box
190 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (MPEG-4 first)");
191 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (external first)");
192 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"4:3");
193 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"16:9");
194 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"2.35:1");
195 :    
196 :     // Select Aspect Ratio
197 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
198 :    
199 :    
200 :     // Load Buttons
201 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
202 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
203 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
204 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
205 :     SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
206 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
207 :    
208 :     // 4CC checkbuttons
209 :     SendMessage(GetDlgItem(hwnd, IDC_DIVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DIVX, 0);
210 :     SendMessage(GetDlgItem(hwnd, IDC_3IVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_3IVX, 0);
211 :     SendMessage(GetDlgItem(hwnd, IDC_MP4V), BM_SETCHECK, g_config.supported_4cc & SUPPORT_MP4V, 0);
212 :     SendMessage(GetDlgItem(hwnd, IDC_COMPAT), BM_SETCHECK, g_config.videoinfo_compat, 0);
213 :    
214 :    
215 :     // TrayIcon
216 :     SendMessage(GetDlgItem(hwnd, IDC_TRAYICON), BM_SETCHECK, g_config.bTrayIcon, 0);
217 :    
218 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
219 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
220 :    
221 :     EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
222 :    
223 :     // Set Date & Time of Compilation
224 :     DPRINTF("(%s %s)", __DATE__, __TIME__);
225 :     break;
226 :    
227 :     case WM_COMMAND:
228 :     switch ( wParam )
229 :     {
230 :     case IDC_RESET:
231 :     ZeroMemory(&g_config, sizeof(CONFIG));
232 :     g_config.bTrayIcon = 1;
233 :    
234 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
235 :     SendMessage(hBrightness, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) g_config.nBrightness);
236 :    
237 :     // Load Buttons
238 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
239 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
240 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
241 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
242 :     SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
243 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
244 :     g_config.nForceColorspace = 0;
245 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
246 :     g_config.aspect_ratio = 0;
247 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
248 :     SendMessage(GetDlgItem(hwnd, IDC_TRAYICON), CB_SETCURSEL, g_config.bTrayIcon, 0);
249 :     break;
250 :     case IDC_DEBLOCK_Y:
251 :     g_config.nDeblock_Y = !g_config.nDeblock_Y;
252 :     break;
253 :     case IDC_DEBLOCK_UV:
254 :     g_config.nDeblock_UV = !g_config.nDeblock_UV;
255 :     break;
256 :     case IDC_DERINGY:
257 :     g_config.nDering_Y = !g_config.nDering_Y;
258 :     break;
259 :     case IDC_DERINGUV:
260 :     g_config.nDering_UV = !g_config.nDering_UV;
261 :     break;
262 :     case IDC_FILMEFFECT:
263 :     g_config.nFilmEffect = !g_config.nFilmEffect;
264 :     break;
265 :     case IDC_FLIPVIDEO:
266 :     g_config.nFlipVideo = !g_config.nFlipVideo;
267 :     break;
268 :     case IDC_DIVX:
269 :     g_config.supported_4cc ^= SUPPORT_DIVX;
270 :     break;
271 :     case IDC_3IVX:
272 :     g_config.supported_4cc ^= SUPPORT_3IVX;
273 :     break;
274 :     case IDC_MP4V:
275 :     g_config.supported_4cc ^= SUPPORT_MP4V;
276 :     break;
277 :     case IDC_COMPAT:
278 :     g_config.videoinfo_compat = !g_config.videoinfo_compat;
279 :     break;
280 :     case IDC_TRAYICON:
281 :     g_config.bTrayIcon = !g_config.bTrayIcon;
282 :     break;
283 :     default :
284 :     return FALSE;
285 :     }
286 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
287 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
288 :    
289 :     EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
290 :    
291 :     SaveRegistryInfo(0);
292 :    
293 :    
294 :     break;
295 :     case WM_NOTIFY:
296 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
297 :     g_config.nBrightness = (int) SendMessage(hBrightness, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL);
298 :     SaveRegistryInfo(0);
299 :     break;
300 :     default :
301 :     return FALSE;
302 :     }
303 :    
304 :     return TRUE; /* ok */
305 :     }
306 :    
307 :    
308 :    
309 :    
310 :    

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