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