[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 1994 - (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 : syskin 1561 REG_GET_N("Brightness", g_config.nBrightness, 0)
48 : edgomez 1382 REG_GET_N("Deblock_Y", g_config.nDeblock_Y, 0)
49 :     REG_GET_N("Deblock_UV", g_config.nDeblock_UV, 0)
50 : syskin 1437 REG_GET_N("Dering_Y", g_config.nDering_Y, 0)
51 :     REG_GET_N("Dering_UV", g_config.nDering_UV, 0)
52 : edgomez 1382 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 : suxen_drol 1636 REG_GET_N("Decoder_Aspect_Ratio", g_config.aspect_ratio, 0)
58 : Isibaar 1912 REG_GET_N("num_threads", g_config.num_threads, 0)
59 : Isibaar 1916 REG_GET_N("cpu_flags", g_config.cpu, 0)
60 : edgomez 1382
61 :     RegCloseKey(hKey);
62 :     }
63 :    
64 :     void SaveRegistryInfo()
65 :     {
66 :     HKEY hKey;
67 :     DWORD dispo;
68 :    
69 :     if (RegCreateKeyEx(
70 :     XVID_REG_KEY,
71 :     XVID_REG_SUBKEY,
72 :     0,
73 :     XVID_REG_CLASS,
74 :     REG_OPTION_NON_VOLATILE,
75 :     KEY_WRITE,
76 :     0,
77 :     &hKey,
78 :     &dispo) != ERROR_SUCCESS)
79 :     {
80 :     OutputDebugString("Couldn't create XVID_REG_SUBKEY");
81 :     return;
82 :     }
83 :    
84 :     REG_SET_N("Brightness", g_config.nBrightness);
85 :     REG_SET_N("Deblock_Y", g_config.nDeblock_Y);
86 :     REG_SET_N("Deblock_UV", g_config.nDeblock_UV);
87 : syskin 1437 REG_SET_N("Dering_Y", g_config.nDering_Y);
88 :     REG_SET_N("Dering_UV", g_config.nDering_UV);
89 : edgomez 1382 REG_SET_N("FilmEffect", g_config.nFilmEffect);
90 :     REG_SET_N("ForceColorspace", g_config.nForceColorspace);
91 :     REG_SET_N("FlipVideo", g_config.nFlipVideo);
92 :     REG_SET_N("Supported_4CC", g_config.supported_4cc);
93 :     REG_SET_N("Videoinfo_Compat", g_config.videoinfo_compat);
94 : suxen_drol 1636 REG_SET_N("Decoder_Aspect_Ratio", g_config.aspect_ratio);
95 : Isibaar 1916 REG_SET_N("num_threads", g_config.num_threads);
96 : edgomez 1382
97 :     RegCloseKey(hKey);
98 :     }
99 :    
100 :    
101 :    
102 : Isibaar 1827 INT_PTR CALLBACK adv_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
103 : edgomez 1382 {
104 :     HWND hBrightness;
105 :    
106 :     switch ( uMsg )
107 :     {
108 :     case WM_DESTROY:
109 :     {
110 : Isibaar 1827 LPARAM nForceColorspace;
111 :     LPARAM aspect_ratio;
112 : syskin 1488
113 : edgomez 1382 nForceColorspace = SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_GETCURSEL, 0, 0);
114 :     if ( g_config.nForceColorspace != nForceColorspace )
115 :     {
116 : Isibaar 1802 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);
117 : edgomez 1382 }
118 : Isibaar 1827 g_config.nForceColorspace = (int) nForceColorspace;
119 : syskin 1488
120 :     aspect_ratio = SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_GETCURSEL, 0, 0);
121 :     if ( g_config.aspect_ratio != aspect_ratio )
122 :     {
123 : Isibaar 1802 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);
124 : syskin 1488 }
125 : Isibaar 1827 g_config.aspect_ratio = (int) aspect_ratio;
126 : edgomez 1382 SaveRegistryInfo();
127 :     }
128 :     break;
129 :    
130 :     case WM_INITDIALOG:
131 : Isibaar 1994 {
132 :     xvid_gbl_info_t info;
133 :     char core[100];
134 :     HINSTANCE m_hdll;
135 : edgomez 1382
136 : Isibaar 1994 memset(&info, 0, sizeof(info));
137 :     info.version = XVID_VERSION;
138 :    
139 :     m_hdll = LoadLibrary(XVID_DLL_NAME);
140 :     if (m_hdll != NULL) {
141 :    
142 :     ((int (__cdecl *)(void *, int, void *, void *))GetProcAddress(m_hdll, "xvid_global"))
143 :     (0, XVID_GBL_INFO, &info, NULL);
144 :    
145 :     wsprintf(core, "Xvid MPEG-4 Video Codec v%d.%d.%d",
146 :     XVID_VERSION_MAJOR(info.actual_version),
147 :     XVID_VERSION_MINOR(info.actual_version),
148 :     XVID_VERSION_PATCH(info.actual_version));
149 :    
150 :     FreeLibrary(m_hdll);
151 :     } else {
152 :     wsprintf(core, "xvidcore.dll not found!");
153 :     }
154 :    
155 :     SetDlgItemText(hwnd, IDC_CORE, core);
156 :     }
157 :    
158 : edgomez 1382 // Load Force Colorspace Box
159 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"No Force");
160 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YV12");
161 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YUY2");
162 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB24");
163 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB32");
164 :    
165 :     // Select Colorspace
166 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
167 :    
168 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
169 : suxen_drol 1397 SendMessage(hBrightness, TBM_SETRANGE, (WPARAM)TRUE, (LPARAM)MAKELONG(-96, 96));
170 :     SendMessage(hBrightness, TBM_SETTICFREQ, (WPARAM)16, (LPARAM)0);
171 :     SendMessage(hBrightness, TBM_SETPOS, (WPARAM)TRUE, (LPARAM) g_config.nBrightness);
172 : edgomez 1382
173 : syskin 1488 // Load Aspect Ratio Box
174 : Isibaar 1949 SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (MPEG-4 first)");
175 : syskin 1498 SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"Auto (external first)");
176 : syskin 1488 SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"4:3");
177 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"16:9");
178 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_ADDSTRING, 0, (LPARAM)"2.35:1");
179 :    
180 :     // Select Aspect Ratio
181 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
182 :    
183 :    
184 : edgomez 1382 // Load Buttons
185 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
186 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
187 : syskin 1437 SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
188 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
189 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
190 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
191 :    
192 :     // 4CC checkbuttons
193 :     SendMessage(GetDlgItem(hwnd, IDC_DIVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DIVX, 0);
194 : Isibaar 1949 SendMessage(GetDlgItem(hwnd, IDC_3IVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_3IVX, 0);
195 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_MP4V), BM_SETCHECK, g_config.supported_4cc & SUPPORT_MP4V, 0);
196 :     SendMessage(GetDlgItem(hwnd, IDC_COMPAT), BM_SETCHECK, g_config.videoinfo_compat, 0);
197 :    
198 : syskin 1437 EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
199 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
200 :    
201 : syskin 1498 EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
202 : syskin 1488
203 : edgomez 1382 // Set Date & Time of Compilation
204 :     DPRINTF("(%s %s)", __DATE__, __TIME__);
205 :     break;
206 :    
207 :     case WM_COMMAND:
208 :     switch ( wParam )
209 :     {
210 :     case IDC_RESET:
211 :     ZeroMemory(&g_config, sizeof(CONFIG));
212 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
213 : suxen_drol 1397 SendMessage(hBrightness, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) g_config.nBrightness);
214 : edgomez 1382 // Load Buttons
215 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
216 :     SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
217 : syskin 1437 SendMessage(GetDlgItem(hwnd, IDC_DERINGY), BM_SETCHECK, g_config.nDering_Y, 0);
218 :     SendMessage(GetDlgItem(hwnd, IDC_DERINGUV), BM_SETCHECK, g_config.nDering_UV, 0);
219 : edgomez 1382 SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
220 :     SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
221 :     g_config.nForceColorspace = 0;
222 :     SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
223 : syskin 1488 g_config.aspect_ratio = 0;
224 :     SendMessage(GetDlgItem(hwnd, IDC_USE_AR), CB_SETCURSEL, g_config.aspect_ratio, 0);
225 : edgomez 1382 break;
226 :     case IDC_DEBLOCK_Y:
227 :     g_config.nDeblock_Y = !g_config.nDeblock_Y;
228 :     break;
229 :     case IDC_DEBLOCK_UV:
230 :     g_config.nDeblock_UV = !g_config.nDeblock_UV;
231 :     break;
232 : syskin 1437 case IDC_DERINGY:
233 :     g_config.nDering_Y = !g_config.nDering_Y;
234 : edgomez 1382 break;
235 : syskin 1437 case IDC_DERINGUV:
236 :     g_config.nDering_UV = !g_config.nDering_UV;
237 :     break;
238 : edgomez 1382 case IDC_FILMEFFECT:
239 :     g_config.nFilmEffect = !g_config.nFilmEffect;
240 :     break;
241 :     case IDC_FLIPVIDEO:
242 :     g_config.nFlipVideo = !g_config.nFlipVideo;
243 :     break;
244 :     case IDC_DIVX:
245 :     g_config.supported_4cc ^= SUPPORT_DIVX;
246 :     break;
247 : Isibaar 1949 case IDC_3IVX:
248 :     g_config.supported_4cc ^= SUPPORT_3IVX;
249 : edgomez 1382 break;
250 :     case IDC_MP4V:
251 :     g_config.supported_4cc ^= SUPPORT_MP4V;
252 :     break;
253 :     case IDC_COMPAT:
254 :     g_config.videoinfo_compat = !g_config.videoinfo_compat;
255 :     break;
256 :     default :
257 :     return FALSE;
258 :     }
259 : syskin 1437 EnableWindow(GetDlgItem(hwnd,IDC_DERINGY),g_config.nDeblock_Y);
260 :     EnableWindow(GetDlgItem(hwnd,IDC_DERINGUV),g_config.nDeblock_UV);
261 : syskin 1498
262 :     EnableWindow(GetDlgItem(hwnd, IDC_USE_AR), !g_config.videoinfo_compat);
263 :    
264 : edgomez 1382 SaveRegistryInfo();
265 : syskin 1437
266 :    
267 : edgomez 1382 break;
268 :     case WM_NOTIFY:
269 :     hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
270 : Isibaar 1827 g_config.nBrightness = (int) SendMessage(hBrightness, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL);
271 : edgomez 1382 SaveRegistryInfo();
272 :     break;
273 :     default :
274 :     return FALSE;
275 :     }
276 :    
277 :     return TRUE; /* ok */
278 :     }
279 :    
280 :    
281 :    
282 :    
283 :    

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