Parent Directory | Revision Log
Revision 1.5 - (view) (download)
1 : | edgomez | 1.2 | /***************************************************************************** |
2 : | * | ||
3 : | * XVID MPEG-4 VFW FRONTEND | ||
4 : | * - driverproc main - | ||
5 : | * | ||
6 : | * Copyright(C) 2001-2003 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 : | syskin | 1.5 | * $Id: driverproc.c,v 1.4 2004/04/05 20:36:37 edgomez Exp $ |
23 : | edgomez | 1.2 | * |
24 : | ****************************************************************************/ | ||
25 : | |||
26 : | #include <windows.h> | ||
27 : | #include <vfw.h> | ||
28 : | #include "vfwext.h" | ||
29 : | |||
30 : | #include "debug.h" | ||
31 : | #include "codec.h" | ||
32 : | #include "config.h" | ||
33 : | #include "status.h" | ||
34 : | #include "resource.h" | ||
35 : | |||
36 : | edgomez | 1.4 | static int clean_dll_bindings(CODEC* codec); |
37 : | edgomez | 1.2 | |
38 : | BOOL WINAPI DllMain( | ||
39 : | HANDLE hModule, | ||
40 : | DWORD ul_reason_for_call, | ||
41 : | LPVOID lpReserved) | ||
42 : | { | ||
43 : | g_hInst = (HINSTANCE) hModule; | ||
44 : | return TRUE; | ||
45 : | } | ||
46 : | |||
47 : | /* __declspec(dllexport) */ LRESULT WINAPI DriverProc( | ||
48 : | DWORD dwDriverId, | ||
49 : | HDRVR hDriver, | ||
50 : | UINT uMsg, | ||
51 : | LPARAM lParam1, | ||
52 : | LPARAM lParam2) | ||
53 : | { | ||
54 : | CODEC * codec = (CODEC *)dwDriverId; | ||
55 : | |||
56 : | switch(uMsg) | ||
57 : | { | ||
58 : | |||
59 : | /* driver primitives */ | ||
60 : | |||
61 : | case DRV_LOAD : | ||
62 : | case DRV_FREE : | ||
63 : | return DRV_OK; | ||
64 : | |||
65 : | case DRV_OPEN : | ||
66 : | DPRINTF("DRV_OPEN"); | ||
67 : | edgomez | 1.3 | |
68 : | edgomez | 1.2 | { |
69 : | ICOPEN * icopen = (ICOPEN *)lParam2; | ||
70 : | |||
71 : | if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) | ||
72 : | { | ||
73 : | return DRV_CANCEL; | ||
74 : | } | ||
75 : | |||
76 : | codec = malloc(sizeof(CODEC)); | ||
77 : | |||
78 : | if (codec == NULL) | ||
79 : | { | ||
80 : | if (icopen != NULL) | ||
81 : | { | ||
82 : | icopen->dwError = ICERR_MEMORY; | ||
83 : | } | ||
84 : | return 0; | ||
85 : | } | ||
86 : | |||
87 : | edgomez | 1.3 | memset(codec, 0, sizeof(CODEC)); |
88 : | edgomez | 1.2 | |
89 : | codec->status.hDlg = NULL; | ||
90 : | codec->config.ci_valid = 0; | ||
91 : | codec->ehandle = codec->dhandle = NULL; | ||
92 : | codec->fbase = 25; | ||
93 : | codec->fincr = 1; | ||
94 : | config_reg_get(&codec->config); | ||
95 : | |||
96 : | #if 0 | ||
97 : | /* bad things happen if this piece of code is activated */ | ||
98 : | if (lstrcmp(XVID_BUILD, codec->config.build)) | ||
99 : | { | ||
100 : | config_reg_default(&codec->config); | ||
101 : | } | ||
102 : | #endif | ||
103 : | |||
104 : | if (icopen != NULL) | ||
105 : | { | ||
106 : | icopen->dwError = ICERR_OK; | ||
107 : | } | ||
108 : | return (LRESULT)codec; | ||
109 : | } | ||
110 : | |||
111 : | case DRV_CLOSE : | ||
112 : | DPRINTF("DRV_CLOSE"); | ||
113 : | /* compress_end/decompress_end don't always get called */ | ||
114 : | compress_end(codec); | ||
115 : | decompress_end(codec); | ||
116 : | edgomez | 1.4 | clean_dll_bindings(codec); |
117 : | edgomez | 1.2 | status_destroy_always(&codec->status); |
118 : | free(codec); | ||
119 : | return DRV_OK; | ||
120 : | |||
121 : | case DRV_DISABLE : | ||
122 : | case DRV_ENABLE : | ||
123 : | return DRV_OK; | ||
124 : | |||
125 : | case DRV_INSTALL : | ||
126 : | case DRV_REMOVE : | ||
127 : | return DRV_OK; | ||
128 : | |||
129 : | case DRV_QUERYCONFIGURE : | ||
130 : | case DRV_CONFIGURE : | ||
131 : | return DRV_CANCEL; | ||
132 : | |||
133 : | |||
134 : | /* info */ | ||
135 : | |||
136 : | case ICM_GETINFO : | ||
137 : | DPRINTF("ICM_GETINFO"); | ||
138 : | { | ||
139 : | ICINFO *icinfo = (ICINFO *)lParam1; | ||
140 : | |||
141 : | icinfo->fccType = ICTYPE_VIDEO; | ||
142 : | icinfo->fccHandler = FOURCC_XVID; | ||
143 : | icinfo->dwFlags = | ||
144 : | VIDCF_FASTTEMPORALC | | ||
145 : | VIDCF_FASTTEMPORALD | | ||
146 : | VIDCF_COMPRESSFRAMES; | ||
147 : | |||
148 : | icinfo->dwVersion = 0; | ||
149 : | icinfo->dwVersionICM = ICVERSION; | ||
150 : | |||
151 : | wcscpy(icinfo->szName, XVID_NAME_L); | ||
152 : | wcscpy(icinfo->szDescription, XVID_DESC_L); | ||
153 : | |||
154 : | return lParam2; /* size of struct */ | ||
155 : | } | ||
156 : | |||
157 : | /* state control */ | ||
158 : | |||
159 : | case ICM_ABOUT : | ||
160 : | DPRINTF("ICM_ABOUT"); | ||
161 : | DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0); | ||
162 : | return ICERR_OK; | ||
163 : | |||
164 : | case ICM_CONFIGURE : | ||
165 : | DPRINTF("ICM_CONFIGURE"); | ||
166 : | if (lParam1 != -1) | ||
167 : | { | ||
168 : | CONFIG temp; | ||
169 : | |||
170 : | codec->config.save = FALSE; | ||
171 : | memcpy(&temp, &codec->config, sizeof(CONFIG)); | ||
172 : | |||
173 : | DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp); | ||
174 : | |||
175 : | if (temp.save) | ||
176 : | { | ||
177 : | memcpy(&codec->config, &temp, sizeof(CONFIG)); | ||
178 : | config_reg_set(&codec->config); | ||
179 : | } | ||
180 : | } | ||
181 : | return ICERR_OK; | ||
182 : | |||
183 : | case ICM_GETSTATE : | ||
184 : | DPRINTF("ICM_GETSTATE"); | ||
185 : | if ((void*)lParam1 == NULL) | ||
186 : | { | ||
187 : | return sizeof(CONFIG); | ||
188 : | } | ||
189 : | memcpy((void*)lParam1, &codec->config, sizeof(CONFIG)); | ||
190 : | return ICERR_OK; | ||
191 : | |||
192 : | case ICM_SETSTATE : | ||
193 : | DPRINTF("ICM_SETSTATE"); | ||
194 : | if ((void*)lParam1 == NULL) | ||
195 : | { | ||
196 : | DPRINTF("ICM_SETSTATE : DEFAULT"); | ||
197 : | config_reg_get(&codec->config); | ||
198 : | return 0; | ||
199 : | } | ||
200 : | memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG)); | ||
201 : | return 0; /* sizeof(CONFIG); */ | ||
202 : | |||
203 : | /* not sure the difference, private/public data? */ | ||
204 : | |||
205 : | case ICM_GET : | ||
206 : | case ICM_SET : | ||
207 : | return ICERR_OK; | ||
208 : | |||
209 : | |||
210 : | /* older-stype config */ | ||
211 : | |||
212 : | case ICM_GETDEFAULTQUALITY : | ||
213 : | case ICM_GETQUALITY : | ||
214 : | case ICM_SETQUALITY : | ||
215 : | case ICM_GETBUFFERSWANTED : | ||
216 : | case ICM_GETDEFAULTKEYFRAMERATE : | ||
217 : | return ICERR_UNSUPPORTED; | ||
218 : | |||
219 : | |||
220 : | /* compressor */ | ||
221 : | |||
222 : | case ICM_COMPRESS_QUERY : | ||
223 : | DPRINTF("ICM_COMPRESS_QUERY"); | ||
224 : | return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
225 : | |||
226 : | case ICM_COMPRESS_GET_FORMAT : | ||
227 : | DPRINTF("ICM_COMPRESS_GET_FORMAT"); | ||
228 : | return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
229 : | |||
230 : | case ICM_COMPRESS_GET_SIZE : | ||
231 : | DPRINTF("ICM_COMPRESS_GET_SIZE"); | ||
232 : | return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
233 : | |||
234 : | case ICM_COMPRESS_FRAMES_INFO : | ||
235 : | DPRINTF("ICM_COMPRESS_FRAMES_INFO"); | ||
236 : | return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1); | ||
237 : | |||
238 : | case ICM_COMPRESS_BEGIN : | ||
239 : | DPRINTF("ICM_COMPRESS_BEGIN"); | ||
240 : | return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
241 : | |||
242 : | case ICM_COMPRESS_END : | ||
243 : | DPRINTF("ICM_COMPRESS_END"); | ||
244 : | return compress_end(codec); | ||
245 : | |||
246 : | case ICM_COMPRESS : | ||
247 : | DPRINTF("ICM_COMPRESS"); | ||
248 : | return compress(codec, (ICCOMPRESS *)lParam1); | ||
249 : | |||
250 : | /* decompressor */ | ||
251 : | |||
252 : | case ICM_DECOMPRESS_QUERY : | ||
253 : | DPRINTF("ICM_DECOMPRESS_QUERY"); | ||
254 : | return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
255 : | |||
256 : | case ICM_DECOMPRESS_GET_FORMAT : | ||
257 : | DPRINTF("ICM_DECOMPRESS_GET_FORMAT"); | ||
258 : | return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
259 : | |||
260 : | case ICM_DECOMPRESS_BEGIN : | ||
261 : | DPRINTF("ICM_DECOMPRESS_BEGIN"); | ||
262 : | return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
263 : | |||
264 : | case ICM_DECOMPRESS_END : | ||
265 : | DPRINTF("ICM_DECOMPRESS_END"); | ||
266 : | return decompress_end(codec); | ||
267 : | |||
268 : | case ICM_DECOMPRESS : | ||
269 : | DPRINTF("ICM_DECOMPRESS"); | ||
270 : | return decompress(codec, (ICDECOMPRESS *)lParam1); | ||
271 : | |||
272 : | case ICM_DECOMPRESS_GET_PALETTE : | ||
273 : | case ICM_DECOMPRESS_SET_PALETTE : | ||
274 : | case ICM_DECOMPRESSEX_QUERY: | ||
275 : | case ICM_DECOMPRESSEX_BEGIN: | ||
276 : | case ICM_DECOMPRESSEX_END: | ||
277 : | case ICM_DECOMPRESSEX: | ||
278 : | return ICERR_UNSUPPORTED; | ||
279 : | |||
280 : | /* VFWEXT entry point */ | ||
281 : | case ICM_USER+0x0fff : | ||
282 : | if (lParam1 == VFWEXT_CONFIGURE_INFO) { | ||
283 : | VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2; | ||
284 : | DPRINTF("%i %i %i %i %i %i", | ||
285 : | info->ciWidth, info->ciHeight, | ||
286 : | info->ciRate, info->ciScale, | ||
287 : | info->ciActiveFrame, info->ciFrameCount); | ||
288 : | |||
289 : | codec->config.ci_valid = 1; | ||
290 : | memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T)); | ||
291 : | return ICERR_OK; | ||
292 : | } | ||
293 : | return ICERR_UNSUPPORTED; | ||
294 : | |||
295 : | default: | ||
296 : | syskin | 1.5 | if (uMsg < DRV_USER) |
297 : | return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); | ||
298 : | else | ||
299 : | return ICERR_UNSUPPORTED; | ||
300 : | edgomez | 1.2 | } |
301 : | } | ||
302 : | |||
303 : | void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow) | ||
304 : | { | ||
305 : | DWORD dwDriverId; | ||
306 : | |||
307 : | dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); | ||
308 : | if (dwDriverId != (DWORD)NULL) | ||
309 : | { | ||
310 : | DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); | ||
311 : | DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); | ||
312 : | } | ||
313 : | edgomez | 1.4 | } |
314 : | |||
315 : | static int clean_dll_bindings(CODEC* codec) | ||
316 : | { | ||
317 : | if(codec->m_hdll) | ||
318 : | { | ||
319 : | FreeLibrary(codec->m_hdll); | ||
320 : | codec->m_hdll = NULL; | ||
321 : | codec->xvid_global_func = NULL; | ||
322 : | codec->xvid_encore_func = NULL; | ||
323 : | codec->xvid_decore_func = NULL; | ||
324 : | codec->xvid_plugin_single_func = NULL; | ||
325 : | codec->xvid_plugin_2pass1_func = NULL; | ||
326 : | codec->xvid_plugin_2pass2_func = NULL; | ||
327 : | codec->xvid_plugin_lumimasking_func = NULL; | ||
328 : | codec->xvid_plugin_psnr_func = NULL; | ||
329 : | } | ||
330 : | return 0; | ||
331 : | edgomez | 1.2 | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |