Parent Directory | Revision Log
Revision 61 - (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 : | * 01.12.2001 inital version; (c)2001 peter ross <suxen_drol@hotmail.com> | ||
27 : | * | ||
28 : | *************************************************************************/ | ||
29 : | |||
30 : | #include <windows.h> | ||
31 : | #include <vfw.h> | ||
32 : | |||
33 : | #include "codec.h" | ||
34 : | #include "config.h" | ||
35 : | #include "resource.h" | ||
36 : | |||
37 : | |||
38 : | BOOL APIENTRY DllMain( | ||
39 : | HANDLE hModule, | ||
40 : | DWORD ul_reason_for_call, | ||
41 : | LPVOID lpReserved) | ||
42 : | { | ||
43 : | hInst = (HINSTANCE) hModule; | ||
44 : | return TRUE; | ||
45 : | } | ||
46 : | |||
47 : | |||
48 : | |||
49 : | __declspec(dllexport) LRESULT WINAPI DriverProc( | ||
50 : | DWORD dwDriverId, | ||
51 : | HDRVR hDriver, | ||
52 : | UINT uMsg, | ||
53 : | LPARAM lParam1, | ||
54 : | LPARAM lParam2) | ||
55 : | { | ||
56 : | CODEC * codec = (CODEC *)dwDriverId; | ||
57 : | |||
58 : | switch(uMsg) | ||
59 : | { | ||
60 : | |||
61 : | /* driver primitives */ | ||
62 : | |||
63 : | case DRV_LOAD : | ||
64 : | case DRV_FREE : | ||
65 : | DRV_OK; | ||
66 : | |||
67 : | case DRV_OPEN : | ||
68 : | DEBUG("DRV_OPEN"); | ||
69 : | { | ||
70 : | ICOPEN * icopen = (ICOPEN *)lParam2; | ||
71 : | |||
72 : | h | 30 | if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO) |
73 : | { | ||
74 : | Isibaar | 3 | return DRV_CANCEL; |
75 : | } | ||
76 : | h | 61 | |
77 : | Isibaar | 3 | codec = malloc(sizeof(CODEC)); |
78 : | h | 61 | |
79 : | Isibaar | 3 | if (codec == NULL) |
80 : | { | ||
81 : | h | 30 | if (icopen != NULL) |
82 : | { | ||
83 : | Isibaar | 3 | icopen->dwError = ICERR_MEMORY; |
84 : | } | ||
85 : | return 0; | ||
86 : | } | ||
87 : | h | 61 | |
88 : | Isibaar | 3 | codec->ehandle = codec->dhandle = NULL; |
89 : | config_reg_get(&codec->config); | ||
90 : | |||
91 : | h | 61 | /* bad things happen if this is uncommented |
92 : | if (lstrcmp(XVID_BUILD, codec->config.build)) | ||
93 : | { | ||
94 : | config_reg_default(&codec->config); | ||
95 : | } | ||
96 : | */ | ||
97 : | |||
98 : | h | 30 | if (icopen != NULL) |
99 : | { | ||
100 : | Isibaar | 3 | icopen->dwError = ICERR_OK; |
101 : | } | ||
102 : | return (LRESULT)codec; | ||
103 : | } | ||
104 : | |||
105 : | case DRV_CLOSE : | ||
106 : | DEBUG("DRV_CLOSE"); | ||
107 : | // compress_end/decompress_end don't always get called | ||
108 : | compress_end(codec); | ||
109 : | decompress_end(codec); | ||
110 : | free(codec); | ||
111 : | return DRV_OK; | ||
112 : | |||
113 : | case DRV_DISABLE : | ||
114 : | case DRV_ENABLE : | ||
115 : | return DRV_OK; | ||
116 : | |||
117 : | case DRV_INSTALL : | ||
118 : | case DRV_REMOVE : | ||
119 : | return DRV_OK; | ||
120 : | |||
121 : | case DRV_QUERYCONFIGURE : | ||
122 : | case DRV_CONFIGURE : | ||
123 : | return DRV_CANCEL; | ||
124 : | |||
125 : | |||
126 : | /* info */ | ||
127 : | |||
128 : | case ICM_GETINFO : | ||
129 : | DEBUG("ICM_GETINFO"); | ||
130 : | { | ||
131 : | ICINFO *icinfo = (ICINFO *)lParam1; | ||
132 : | |||
133 : | icinfo->fccType = ICTYPE_VIDEO; | ||
134 : | icinfo->fccHandler = FOURCC_XVID; | ||
135 : | icinfo->dwFlags = | ||
136 : | VIDCF_FASTTEMPORALC | | ||
137 : | VIDCF_FASTTEMPORALD | | ||
138 : | VIDCF_COMPRESSFRAMES; | ||
139 : | |||
140 : | icinfo->dwVersion = 0; | ||
141 : | icinfo->dwVersionICM = ICVERSION; | ||
142 : | |||
143 : | wcscpy(icinfo->szName, XVID_NAME_L); | ||
144 : | wcscpy(icinfo->szDescription, XVID_DESC_L); | ||
145 : | |||
146 : | return lParam2; /* size of struct */ | ||
147 : | } | ||
148 : | h | 30 | DEBUG("ICM_GETINFO end"); |
149 : | Isibaar | 3 | |
150 : | |||
151 : | /* state control */ | ||
152 : | |||
153 : | case ICM_ABOUT : | ||
154 : | h | 30 | DEBUG("ICM_ABOUT"); |
155 : | DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0); | ||
156 : | return ICERR_OK; | ||
157 : | Isibaar | 3 | |
158 : | h | 30 | case ICM_CONFIGURE : |
159 : | Isibaar | 3 | DEBUG("ICM_CONFIGURE"); |
160 : | h | 30 | if (lParam1 != -1) |
161 : | { | ||
162 : | CONFIG temp; | ||
163 : | Isibaar | 3 | |
164 : | h | 30 | codec->config.save = FALSE; |
165 : | memcpy(&temp, &codec->config, sizeof(CONFIG)); | ||
166 : | Isibaar | 3 | |
167 : | h | 30 | DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp); |
168 : | Isibaar | 3 | |
169 : | h | 30 | if (temp.save) |
170 : | { | ||
171 : | Isibaar | 3 | memcpy(&codec->config, &temp, sizeof(CONFIG)); |
172 : | h | 30 | config_reg_set(&codec->config); |
173 : | Isibaar | 3 | } |
174 : | } | ||
175 : | return ICERR_OK; | ||
176 : | |||
177 : | case ICM_GETSTATE : | ||
178 : | DEBUG("ICM_GETSTATE"); | ||
179 : | h | 30 | if ((void*)lParam1 == NULL) |
180 : | { | ||
181 : | Isibaar | 3 | return sizeof(CONFIG); |
182 : | } | ||
183 : | memcpy((void*)lParam1, &codec->config, sizeof(CONFIG)); | ||
184 : | return ICERR_OK; | ||
185 : | |||
186 : | case ICM_SETSTATE : | ||
187 : | DEBUG("ICM_SETSTATE"); | ||
188 : | h | 30 | if ((void*)lParam1 == NULL) |
189 : | { | ||
190 : | Isibaar | 3 | DEBUG("ICM_SETSTATE : DEFAULT"); |
191 : | config_reg_get(&codec->config); | ||
192 : | return 0; | ||
193 : | } | ||
194 : | memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG)); | ||
195 : | return 0; // sizeof(CONFIG); | ||
196 : | |||
197 : | /* not sure the difference, private/public data? */ | ||
198 : | |||
199 : | case ICM_GET : | ||
200 : | case ICM_SET : | ||
201 : | return ICERR_OK; | ||
202 : | |||
203 : | |||
204 : | /* older-stype config */ | ||
205 : | |||
206 : | case ICM_GETDEFAULTQUALITY : | ||
207 : | case ICM_GETQUALITY : | ||
208 : | case ICM_SETQUALITY : | ||
209 : | case ICM_GETBUFFERSWANTED : | ||
210 : | case ICM_GETDEFAULTKEYFRAMERATE : | ||
211 : | return ICERR_UNSUPPORTED; | ||
212 : | |||
213 : | |||
214 : | /* compressor */ | ||
215 : | |||
216 : | case ICM_COMPRESS_QUERY : | ||
217 : | DEBUG("ICM_COMPRESS_QUERY"); | ||
218 : | return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
219 : | |||
220 : | case ICM_COMPRESS_GET_FORMAT : | ||
221 : | DEBUG("ICM_COMPRESS_GET_FORMAT"); | ||
222 : | return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
223 : | |||
224 : | case ICM_COMPRESS_GET_SIZE : | ||
225 : | DEBUG("ICM_COMPRESS_GET_SIZE"); | ||
226 : | return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
227 : | |||
228 : | case ICM_COMPRESS_FRAMES_INFO : | ||
229 : | DEBUG("ICM_COMPRESS_FRAMES_INFO"); | ||
230 : | return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1); | ||
231 : | |||
232 : | case ICM_COMPRESS_BEGIN : | ||
233 : | DEBUG("ICM_COMPRESS_BEGIN"); | ||
234 : | return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
235 : | |||
236 : | case ICM_COMPRESS_END : | ||
237 : | DEBUG("ICM_COMPRESS_END"); | ||
238 : | return compress_end(codec); | ||
239 : | |||
240 : | case ICM_COMPRESS : | ||
241 : | DEBUG("ICM_COMPRESS"); | ||
242 : | return compress(codec, (ICCOMPRESS *)lParam1); | ||
243 : | |||
244 : | /* decompressor */ | ||
245 : | |||
246 : | case ICM_DECOMPRESS_QUERY : | ||
247 : | DEBUG("ICM_DECOMPRESS_QUERY"); | ||
248 : | return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
249 : | |||
250 : | case ICM_DECOMPRESS_GET_FORMAT : | ||
251 : | DEBUG("ICM_DECOMPRESS_GET_FORMAT"); | ||
252 : | return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
253 : | |||
254 : | case ICM_DECOMPRESS_BEGIN : | ||
255 : | DEBUG("ICM_DECOMPRESS_BEGIN"); | ||
256 : | return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); | ||
257 : | |||
258 : | case ICM_DECOMPRESS_END : | ||
259 : | DEBUG("ICM_DECOMPRESS_END"); | ||
260 : | return decompress_end(codec); | ||
261 : | |||
262 : | case ICM_DECOMPRESS : | ||
263 : | DEBUG("ICM_DECOMPRESS"); | ||
264 : | return decompress(codec, (ICDECOMPRESS *)lParam1); | ||
265 : | |||
266 : | case ICM_DECOMPRESS_GET_PALETTE : | ||
267 : | case ICM_DECOMPRESS_SET_PALETTE : | ||
268 : | case ICM_DECOMPRESSEX_QUERY: | ||
269 : | case ICM_DECOMPRESSEX_BEGIN: | ||
270 : | case ICM_DECOMPRESSEX_END: | ||
271 : | case ICM_DECOMPRESSEX: | ||
272 : | return ICERR_UNSUPPORTED; | ||
273 : | |||
274 : | default: | ||
275 : | return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); | ||
276 : | } | ||
277 : | } |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |