Parent Directory | Revision Log
Revision 3 - (view) (download)
1 : | Isibaar | 3 | /************************************************************************** |
2 : | * | ||
3 : | * XVID VFW FRONTEND | ||
4 : | * driverproc main | ||
5 : | * | ||
6 : | * This program is free software; you can redistribute it and/or modify | ||
7 : | * it under the terms of the GNU General Public License as published by | ||
8 : | * the Free Software Foundation; either version 2 of the License, or | ||
9 : | * (at your option) any later version. | ||
10 : | * | ||
11 : | * This program is distributed in the hope that it will be useful, | ||
12 : | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 : | * GNU General Public License for more details. | ||
15 : | * | ||
16 : | * You should have received a copy of the GNU General Public License | ||
17 : | * along with this program; if not, write to the Free Software | ||
18 : | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 : | * | ||
20 : | *************************************************************************/ | ||
21 : | |||
22 : | /************************************************************************** | ||
23 : | * | ||
24 : | * History: | ||
25 : | * | ||
26 : | * ... ??? | ||
27 : | * 01.12.2001 inital version; (c)2001 peter ross <suxen_drol@hotmail.com> | ||
28 : | * | ||
29 : | *************************************************************************/ | ||
30 : | |||
31 : | #include <windows.h> | ||
32 : | #include <vfw.h> | ||
33 : | |||
34 : | #include "codec.h" | ||
35 : | #include "config.h" | ||
36 : | #include "resource.h" | ||
37 : | |||
38 : | |||
39 : | BOOL APIENTRY DllMain( | ||
40 : | HANDLE hModule, | ||
41 : | DWORD ul_reason_for_call, | ||
42 : | LPVOID lpReserved) | ||
43 : | { | ||
44 : | hInst = (HINSTANCE) hModule; | ||
45 : | return TRUE; | ||
46 : | } | ||
47 : | |||
48 : | |||
49 : | |||
50 : | __declspec(dllexport) LRESULT WINAPI DriverProc( | ||
51 : | DWORD dwDriverId, | ||
52 : | HDRVR hDriver, | ||
53 : | UINT uMsg, | ||
54 : | LPARAM lParam1, | ||
55 : | LPARAM lParam2) | ||
56 : | { | ||
57 : | CODEC * codec = (CODEC *)dwDriverId; | ||
58 : | CONFIG temp; | ||
59 : | |||
60 : | switch(uMsg) | ||
61 : | { | ||
62 : | |||
63 : | /* driver primitives */ | ||
64 : | |||
65 : | case DRV_LOAD : | ||
66 : | case DRV_FREE : | ||
67 : | DRV_OK; | ||
68 : | |||
69 : | case DRV_OPEN : | ||
70 : | DEBUG("DRV_OPEN"); | ||
71 : | { | ||
72 : | ICOPEN * icopen = (ICOPEN *)lParam2; | ||
73 : | |||
74 : | if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) { | ||
75 : | return DRV_CANCEL; | ||
76 : | } | ||
77 : | codec = malloc(sizeof(CODEC)); | ||
78 : | if (codec == NULL) | ||
79 : | { | ||
80 : | if (icopen != NULL) { | ||
81 : | icopen->dwError = ICERR_MEMORY; | ||
82 : | } | ||
83 : | return 0; | ||
84 : | } | ||
85 : | codec->ehandle = codec->dhandle = NULL; | ||
86 : | config_reg_get(&codec->config); | ||
87 : | |||
88 : | if (icopen != NULL) { | ||
89 : | icopen->dwError = ICERR_OK; | ||
90 : | } | ||
91 : | return (LRESULT)codec; | ||
92 : | } | ||
93 : | |||
94 : | case DRV_CLOSE : | ||
95 : | DEBUG("DRV_CLOSE"); | ||
96 : | // compress_end/decompress_end don't always get called | ||
97 : | compress_end(codec); | ||
98 : | decompress_end(codec); | ||
99 : | free(codec); | ||
100 : | return DRV_OK; | ||
101 : | |||
102 : | case DRV_DISABLE : | ||
103 : | case DRV_ENABLE : | ||
104 : | return DRV_OK; | ||
105 : | |||
106 : | case DRV_INSTALL : | ||
107 : | case DRV_REMOVE : | ||
108 : | return DRV_OK; | ||
109 : | |||
110 : | case DRV_QUERYCONFIGURE : | ||
111 : | case DRV_CONFIGURE : | ||
112 : | return DRV_CANCEL; | ||
113 : | |||
114 : | |||
115 : | /* info */ | ||
116 : | |||
117 : | case ICM_GETINFO : | ||
118 : | DEBUG("ICM_GETINFO"); | ||
119 : | { | ||
120 : | ICINFO *icinfo = (ICINFO *)lParam1; | ||
121 : | |||
122 : | icinfo->fccType = ICTYPE_VIDEO; | ||
123 : | icinfo->fccHandler = FOURCC_XVID; | ||
124 : | icinfo->dwFlags = | ||
125 : | VIDCF_FASTTEMPORALC | | ||
126 : | VIDCF_FASTTEMPORALD | | ||
127 : | VIDCF_COMPRESSFRAMES; | ||
128 : | |||
129 : | icinfo->dwVersion = 0; | ||
130 : | icinfo->dwVersionICM = ICVERSION; | ||
131 : | |||
132 : | wcscpy(icinfo->szName, XVID_NAME_L); | ||
133 : | wcscpy(icinfo->szDescription, XVID_DESC_L); | ||
134 : | |||
135 : | return lParam2; /* size of struct */ | ||
136 : | } | ||
137 : | |||
138 : | |||
139 : | /* state control */ | ||
140 : | |||
141 : | case ICM_ABOUT : | ||
142 : | case ICM_CONFIGURE : | ||
143 : | |||
144 : | DEBUG("ICM_CONFIGURE"); | ||
145 : | |||
146 : | codec->config.save = FALSE; | ||
147 : | memcpy(&temp, &codec->config, sizeof(CONFIG)); | ||
148 : | |||
149 : | if (lParam1 != -1) { | ||
150 : | PROPSHEETINFO psi[DLG_COUNT]; | ||
151 : | PROPSHEETPAGE psp[DLG_COUNT]; | ||
152 : | PROPSHEETHEADER psh; | ||
153 : | |||
154 : | psp[DLG_MAIN].dwSize = sizeof(PROPSHEETPAGE); | ||
155 : | psp[DLG_MAIN].dwFlags = 0; | ||
156 : | psp[DLG_MAIN].hInstance = hInst; | ||
157 : | psp[DLG_MAIN].pszTemplate = MAKEINTRESOURCE(IDD_MAIN); | ||
158 : | psp[DLG_MAIN].pfnDlgProc = config_proc; | ||
159 : | psi[DLG_MAIN].page = DLG_MAIN; | ||
160 : | psi[DLG_MAIN].config = &temp; | ||
161 : | psp[DLG_MAIN].lParam = (LPARAM)&psi[DLG_MAIN]; | ||
162 : | psp[DLG_MAIN].pfnCallback = NULL; | ||
163 : | |||
164 : | psp[DLG_ADV].dwSize = sizeof(PROPSHEETPAGE); | ||
165 : | psp[DLG_ADV].dwFlags = 0; | ||
166 : | psp[DLG_ADV].hInstance = hInst; | ||
167 : | psp[DLG_ADV].pszTemplate = MAKEINTRESOURCE(IDD_ADV); | ||
168 : | psp[DLG_ADV].pfnDlgProc = config_proc; | ||
169 : | psi[DLG_ADV].page = DLG_ADV; | ||
170 : | psi[DLG_ADV].config = &temp; | ||
171 : | psp[DLG_ADV].lParam = (LPARAM)&psi[DLG_ADV]; | ||
172 : | psp[DLG_ADV].pfnCallback = NULL; | ||
173 : | |||
174 : | psp[DLG_DEBUG].dwSize = sizeof(PROPSHEETPAGE); | ||
175 : | psp[DLG_DEBUG].dwFlags = 0; | ||
176 : | psp[DLG_DEBUG].hInstance = hInst; | ||
177 : | psp[DLG_DEBUG].pszTemplate = MAKEINTRESOURCE(IDD_DEBUG); | ||
178 : | psp[DLG_DEBUG].pfnDlgProc = config_proc; | ||
179 : | psi[DLG_DEBUG].page = DLG_DEBUG; | ||
180 : | psi[DLG_DEBUG].config = &temp; | ||
181 : | psp[DLG_DEBUG].lParam = (LPARAM)&psi[DLG_DEBUG]; | ||
182 : | psp[DLG_DEBUG].pfnCallback = NULL; | ||
183 : | |||
184 : | psp[DLG_CPU].dwSize = sizeof(PROPSHEETPAGE); | ||
185 : | psp[DLG_CPU].dwFlags = 0; | ||
186 : | psp[DLG_CPU].hInstance = hInst; | ||
187 : | psp[DLG_CPU].pszTemplate = MAKEINTRESOURCE(IDD_CPU); | ||
188 : | psp[DLG_CPU].pfnDlgProc = config_proc; | ||
189 : | psi[DLG_CPU].page = DLG_CPU; | ||
190 : | psi[DLG_CPU].config = &temp; | ||
191 : | psp[DLG_CPU].lParam = (LPARAM)&psi[DLG_CPU]; | ||
192 : | psp[DLG_CPU].pfnCallback = NULL; | ||
193 : | |||
194 : | psp[DLG_ABOUT].dwSize = sizeof(PROPSHEETPAGE); | ||
195 : | psp[DLG_ABOUT].dwFlags = 0; | ||
196 : | psp[DLG_ABOUT].hInstance = hInst; | ||
197 : | psp[DLG_ABOUT].pszTemplate = MAKEINTRESOURCE(IDD_ABOUT); | ||
198 : | psp[DLG_ABOUT].pfnDlgProc = config_proc; | ||
199 : | psi[DLG_ABOUT].page = DLG_ABOUT; | ||
200 : | psi[DLG_ABOUT].config = &temp; | ||
201 : | psp[DLG_ABOUT].lParam = (LPARAM)&psi[DLG_ABOUT]; | ||
202 : | psp[DLG_ABOUT].pfnCallback = NULL; | ||
203 : | |||
204 : | psh.dwSize = sizeof(PROPSHEETHEADER); | ||
205 : | psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; | ||
206 : | psh.hwndParent = (HWND)lParam1; | ||
207 : | psh.hInstance = hInst; | ||
208 : | psh.pszCaption = (LPSTR) "XviD Configuration"; | ||
209 : | psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); | ||
210 : | psh.nStartPage = (uMsg == ICM_CONFIGURE ? DLG_MAIN : DLG_ABOUT); | ||
211 : | psh.ppsp = (LPCPROPSHEETPAGE)&psp; | ||
212 : | psh.pfnCallback = NULL; | ||
213 : | |||
214 : | PropertySheet(&psh); | ||
215 : | |||
216 : | if(temp.save) { | ||
217 : | memcpy(&codec->config, &temp, sizeof(CONFIG)); | ||
218 : | } | ||
219 : | } | ||
220 : | return ICERR_OK; | ||
221 : | |||
222 : | case ICM_GETSTATE : | ||
223 : | DEBUG("ICM_GETSTATE"); | ||
224 : | if ((void*)lParam1 == NULL) { | ||
225 : | return sizeof(CONFIG); | ||
226 : | } | ||
227 : | memcpy((void*)lParam1, &codec->config, sizeof(CONFIG)); | ||
228 : | return ICERR_OK; | ||
229 : | |||
230 : | case ICM_SETSTATE : | ||
231 : | DEBUG("ICM_SETSTATE"); | ||
232 : | if ((void*)lParam1 == NULL) { | ||
233 : | DEBUG("ICM_SETSTATE : DEFAULT"); | ||
234 : | config_reg_get(&codec->config); | ||
235 : | return 0; | ||
236 : | } | ||
237 : | memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG)); | ||
238 : | return 0; // sizeof(CONFIG); | ||
239 : | |||
240 : | /* not sure the difference, private/public data? */ | ||
241 : | |||
242 : | case ICM_GET : | ||
243 : | case ICM_SET : | ||
244 : | return ICERR_OK; | ||
245 : | |||
246 : | |||
247 : | /* older-stype config */ | ||
248 : | |||
249 : | case ICM_GETDEFAULTQUALITY : | ||
250 : | case ICM_GETQUALITY : | ||
251 : | case ICM_SETQUALITY : | ||
252 : | case ICM_GETBUFFERSWANTED : | ||
253 : | case ICM_GETDEFAULTKEYFRAMERATE : | ||
254 : | return ICERR_UNSUPPORTED; | ||
255 : | |||
256 : | |||
257 : | /* compressor */ | ||
258 : | |||
259 : | case ICM_COMPRESS_QUERY : | ||
260 : | DEBUG("ICM_COMPRESS_QUERY"); | ||
261 : | return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
262 : | |||
263 : | case ICM_COMPRESS_GET_FORMAT : | ||
264 : | DEBUG("ICM_COMPRESS_GET_FORMAT"); | ||
265 : | return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
266 : | |||
267 : | case ICM_COMPRESS_GET_SIZE : | ||
268 : | DEBUG("ICM_COMPRESS_GET_SIZE"); | ||
269 : | return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
270 : | |||
271 : | case ICM_COMPRESS_FRAMES_INFO : | ||
272 : | DEBUG("ICM_COMPRESS_FRAMES_INFO"); | ||
273 : | return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1); | ||
274 : | |||
275 : | case ICM_COMPRESS_BEGIN : | ||
276 : | DEBUG("ICM_COMPRESS_BEGIN"); | ||
277 : | return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
278 : | |||
279 : | case ICM_COMPRESS_END : | ||
280 : | DEBUG("ICM_COMPRESS_END"); | ||
281 : | return compress_end(codec); | ||
282 : | |||
283 : | case ICM_COMPRESS : | ||
284 : | DEBUG("ICM_COMPRESS"); | ||
285 : | return compress(codec, (ICCOMPRESS *)lParam1); | ||
286 : | |||
287 : | /* decompressor */ | ||
288 : | |||
289 : | case ICM_DECOMPRESS_QUERY : | ||
290 : | DEBUG("ICM_DECOMPRESS_QUERY"); | ||
291 : | return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
292 : | |||
293 : | case ICM_DECOMPRESS_GET_FORMAT : | ||
294 : | DEBUG("ICM_DECOMPRESS_GET_FORMAT"); | ||
295 : | return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
296 : | |||
297 : | case ICM_DECOMPRESS_BEGIN : | ||
298 : | DEBUG("ICM_DECOMPRESS_BEGIN"); | ||
299 : | return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
300 : | |||
301 : | case ICM_DECOMPRESS_END : | ||
302 : | DEBUG("ICM_DECOMPRESS_END"); | ||
303 : | return decompress_end(codec); | ||
304 : | |||
305 : | case ICM_DECOMPRESS : | ||
306 : | DEBUG("ICM_DECOMPRESS"); | ||
307 : | return decompress(codec, (ICDECOMPRESS *)lParam1); | ||
308 : | |||
309 : | case ICM_DECOMPRESS_GET_PALETTE : | ||
310 : | case ICM_DECOMPRESS_SET_PALETTE : | ||
311 : | case ICM_DECOMPRESSEX_QUERY: | ||
312 : | case ICM_DECOMPRESSEX_BEGIN: | ||
313 : | case ICM_DECOMPRESSEX_END: | ||
314 : | case ICM_DECOMPRESSEX: | ||
315 : | return ICERR_UNSUPPORTED; | ||
316 : | |||
317 : | default: | ||
318 : | return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); | ||
319 : | } | ||
320 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |