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

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