1 |
/************************************************************************** |
/***************************************************************************** |
2 |
* |
* |
3 |
* XVID VFW FRONTEND |
* XVID MPEG-4 VFW FRONTEND |
4 |
* driverproc main |
* - 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 |
* 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 |
* it under the terms of the GNU General Public License as published by |
17 |
* |
* |
18 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
19 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
* |
|
|
*************************************************************************/ |
|
|
|
|
|
/************************************************************************** |
|
21 |
* |
* |
22 |
* History: |
* $Id: driverproc.c,v 1.1.2.7 2004-01-03 12:06:11 syskin Exp $ |
23 |
* |
* |
24 |
* 31.08.2002 Configure() export |
****************************************************************************/ |
|
* 01.12.2001 inital version; (c)2001 peter ross <pross@xvid.org> |
|
|
* |
|
|
*************************************************************************/ |
|
25 |
|
|
26 |
#include <windows.h> |
#include <windows.h> |
27 |
#include <vfw.h> |
#include <vfw.h> |
28 |
|
#include "vfwext.h" |
29 |
|
|
30 |
|
#include "debug.h" |
31 |
#include "codec.h" |
#include "codec.h" |
32 |
#include "config.h" |
#include "config.h" |
33 |
|
#include "status.h" |
34 |
#include "resource.h" |
#include "resource.h" |
35 |
|
|
36 |
|
|
39 |
DWORD ul_reason_for_call, |
DWORD ul_reason_for_call, |
40 |
LPVOID lpReserved) |
LPVOID lpReserved) |
41 |
{ |
{ |
42 |
hInst = (HINSTANCE) hModule; |
g_hInst = (HINSTANCE) hModule; |
43 |
return TRUE; |
return TRUE; |
44 |
} |
} |
45 |
|
|
46 |
|
extern HINSTANCE m_hdll; |
47 |
|
|
48 |
/* __declspec(dllexport) */ LRESULT WINAPI DriverProc( |
/* __declspec(dllexport) */ LRESULT WINAPI DriverProc( |
49 |
DWORD dwDriverId, |
DWORD dwDriverId, |
64 |
return DRV_OK; |
return DRV_OK; |
65 |
|
|
66 |
case DRV_OPEN : |
case DRV_OPEN : |
67 |
DEBUG("DRV_OPEN"); |
DPRINTF("DRV_OPEN"); |
68 |
|
m_hdll = NULL; |
69 |
{ |
{ |
70 |
ICOPEN * icopen = (ICOPEN *)lParam2; |
ICOPEN * icopen = (ICOPEN *)lParam2; |
71 |
|
|
85 |
return 0; |
return 0; |
86 |
} |
} |
87 |
|
|
88 |
|
|
89 |
|
codec->status.hDlg = NULL; |
90 |
|
codec->config.ci_valid = 0; |
91 |
codec->ehandle = codec->dhandle = NULL; |
codec->ehandle = codec->dhandle = NULL; |
92 |
codec->fbase = 25; |
codec->fbase = 25; |
93 |
codec->fincr = 1; |
codec->fincr = 1; |
94 |
config_reg_get(&codec->config); |
config_reg_get(&codec->config); |
95 |
|
|
96 |
/* bad things happen if this is uncommented |
#if 0 |
97 |
|
/* bad things happen if this piece of code is activated */ |
98 |
if (lstrcmp(XVID_BUILD, codec->config.build)) |
if (lstrcmp(XVID_BUILD, codec->config.build)) |
99 |
{ |
{ |
100 |
config_reg_default(&codec->config); |
config_reg_default(&codec->config); |
101 |
} |
} |
102 |
*/ |
#endif |
103 |
|
|
104 |
if (icopen != NULL) |
if (icopen != NULL) |
105 |
{ |
{ |
109 |
} |
} |
110 |
|
|
111 |
case DRV_CLOSE : |
case DRV_CLOSE : |
112 |
DEBUG("DRV_CLOSE"); |
DPRINTF("DRV_CLOSE"); |
113 |
// compress_end/decompress_end don't always get called |
/* compress_end/decompress_end don't always get called */ |
114 |
compress_end(codec); |
compress_end(codec); |
115 |
decompress_end(codec); |
decompress_end(codec); |
116 |
|
status_destroy_always(&codec->status); |
117 |
free(codec); |
free(codec); |
118 |
return DRV_OK; |
return DRV_OK; |
119 |
|
|
133 |
/* info */ |
/* info */ |
134 |
|
|
135 |
case ICM_GETINFO : |
case ICM_GETINFO : |
136 |
DEBUG("ICM_GETINFO"); |
DPRINTF("ICM_GETINFO"); |
137 |
{ |
{ |
138 |
ICINFO *icinfo = (ICINFO *)lParam1; |
ICINFO *icinfo = (ICINFO *)lParam1; |
139 |
|
|
156 |
/* state control */ |
/* state control */ |
157 |
|
|
158 |
case ICM_ABOUT : |
case ICM_ABOUT : |
159 |
DEBUG("ICM_ABOUT"); |
DPRINTF("ICM_ABOUT"); |
160 |
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0); |
DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0); |
161 |
return ICERR_OK; |
return ICERR_OK; |
162 |
|
|
163 |
case ICM_CONFIGURE : |
case ICM_CONFIGURE : |
164 |
DEBUG("ICM_CONFIGURE"); |
DPRINTF("ICM_CONFIGURE"); |
165 |
if (lParam1 != -1) |
if (lParam1 != -1) |
166 |
{ |
{ |
167 |
CONFIG temp; |
CONFIG temp; |
169 |
codec->config.save = FALSE; |
codec->config.save = FALSE; |
170 |
memcpy(&temp, &codec->config, sizeof(CONFIG)); |
memcpy(&temp, &codec->config, sizeof(CONFIG)); |
171 |
|
|
172 |
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp); |
DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp); |
173 |
|
|
174 |
if (temp.save) |
if (temp.save) |
175 |
{ |
{ |
180 |
return ICERR_OK; |
return ICERR_OK; |
181 |
|
|
182 |
case ICM_GETSTATE : |
case ICM_GETSTATE : |
183 |
DEBUG("ICM_GETSTATE"); |
DPRINTF("ICM_GETSTATE"); |
184 |
if ((void*)lParam1 == NULL) |
if ((void*)lParam1 == NULL) |
185 |
{ |
{ |
186 |
return sizeof(CONFIG); |
return sizeof(CONFIG); |
189 |
return ICERR_OK; |
return ICERR_OK; |
190 |
|
|
191 |
case ICM_SETSTATE : |
case ICM_SETSTATE : |
192 |
DEBUG("ICM_SETSTATE"); |
DPRINTF("ICM_SETSTATE"); |
193 |
if ((void*)lParam1 == NULL) |
if ((void*)lParam1 == NULL) |
194 |
{ |
{ |
195 |
DEBUG("ICM_SETSTATE : DEFAULT"); |
DPRINTF("ICM_SETSTATE : DEFAULT"); |
196 |
config_reg_get(&codec->config); |
config_reg_get(&codec->config); |
197 |
return 0; |
return 0; |
198 |
} |
} |
199 |
memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG)); |
memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG)); |
200 |
return 0; // sizeof(CONFIG); |
return 0; /* sizeof(CONFIG); */ |
201 |
|
|
202 |
/* not sure the difference, private/public data? */ |
/* not sure the difference, private/public data? */ |
203 |
|
|
219 |
/* compressor */ |
/* compressor */ |
220 |
|
|
221 |
case ICM_COMPRESS_QUERY : |
case ICM_COMPRESS_QUERY : |
222 |
DEBUG("ICM_COMPRESS_QUERY"); |
DPRINTF("ICM_COMPRESS_QUERY"); |
223 |
return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
224 |
|
|
225 |
case ICM_COMPRESS_GET_FORMAT : |
case ICM_COMPRESS_GET_FORMAT : |
226 |
DEBUG("ICM_COMPRESS_GET_FORMAT"); |
DPRINTF("ICM_COMPRESS_GET_FORMAT"); |
227 |
return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
228 |
|
|
229 |
case ICM_COMPRESS_GET_SIZE : |
case ICM_COMPRESS_GET_SIZE : |
230 |
DEBUG("ICM_COMPRESS_GET_SIZE"); |
DPRINTF("ICM_COMPRESS_GET_SIZE"); |
231 |
return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
232 |
|
|
233 |
case ICM_COMPRESS_FRAMES_INFO : |
case ICM_COMPRESS_FRAMES_INFO : |
234 |
DEBUG("ICM_COMPRESS_FRAMES_INFO"); |
DPRINTF("ICM_COMPRESS_FRAMES_INFO"); |
235 |
return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1); |
return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1); |
236 |
|
|
237 |
case ICM_COMPRESS_BEGIN : |
case ICM_COMPRESS_BEGIN : |
238 |
DEBUG("ICM_COMPRESS_BEGIN"); |
DPRINTF("ICM_COMPRESS_BEGIN"); |
239 |
return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
240 |
|
|
241 |
case ICM_COMPRESS_END : |
case ICM_COMPRESS_END : |
242 |
DEBUG("ICM_COMPRESS_END"); |
DPRINTF("ICM_COMPRESS_END"); |
243 |
return compress_end(codec); |
return compress_end(codec); |
244 |
|
|
245 |
case ICM_COMPRESS : |
case ICM_COMPRESS : |
246 |
DEBUG("ICM_COMPRESS"); |
DPRINTF("ICM_COMPRESS"); |
247 |
return compress(codec, (ICCOMPRESS *)lParam1); |
return compress(codec, (ICCOMPRESS *)lParam1); |
248 |
|
|
249 |
/* decompressor */ |
/* decompressor */ |
250 |
|
|
251 |
case ICM_DECOMPRESS_QUERY : |
case ICM_DECOMPRESS_QUERY : |
252 |
DEBUG("ICM_DECOMPRESS_QUERY"); |
DPRINTF("ICM_DECOMPRESS_QUERY"); |
253 |
return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
254 |
|
|
255 |
case ICM_DECOMPRESS_GET_FORMAT : |
case ICM_DECOMPRESS_GET_FORMAT : |
256 |
DEBUG("ICM_DECOMPRESS_GET_FORMAT"); |
DPRINTF("ICM_DECOMPRESS_GET_FORMAT"); |
257 |
return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
258 |
|
|
259 |
case ICM_DECOMPRESS_BEGIN : |
case ICM_DECOMPRESS_BEGIN : |
260 |
DEBUG("ICM_DECOMPRESS_BEGIN"); |
DPRINTF("ICM_DECOMPRESS_BEGIN"); |
261 |
return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2); |
262 |
|
|
263 |
case ICM_DECOMPRESS_END : |
case ICM_DECOMPRESS_END : |
264 |
DEBUG("ICM_DECOMPRESS_END"); |
DPRINTF("ICM_DECOMPRESS_END"); |
265 |
return decompress_end(codec); |
return decompress_end(codec); |
266 |
|
|
267 |
case ICM_DECOMPRESS : |
case ICM_DECOMPRESS : |
268 |
DEBUG("ICM_DECOMPRESS"); |
DPRINTF("ICM_DECOMPRESS"); |
269 |
return decompress(codec, (ICDECOMPRESS *)lParam1); |
return decompress(codec, (ICDECOMPRESS *)lParam1); |
270 |
|
|
271 |
case ICM_DECOMPRESS_GET_PALETTE : |
case ICM_DECOMPRESS_GET_PALETTE : |
276 |
case ICM_DECOMPRESSEX: |
case ICM_DECOMPRESSEX: |
277 |
return ICERR_UNSUPPORTED; |
return ICERR_UNSUPPORTED; |
278 |
|
|
279 |
|
/* VFWEXT entry point */ |
280 |
|
case ICM_USER+0x0fff : |
281 |
|
if (lParam1 == VFWEXT_CONFIGURE_INFO) { |
282 |
|
VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2; |
283 |
|
DPRINTF("%i %i %i %i %i %i", |
284 |
|
info->ciWidth, info->ciHeight, |
285 |
|
info->ciRate, info->ciScale, |
286 |
|
info->ciActiveFrame, info->ciFrameCount); |
287 |
|
|
288 |
|
codec->config.ci_valid = 1; |
289 |
|
memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T)); |
290 |
|
return ICERR_OK; |
291 |
|
} |
292 |
|
return ICERR_UNSUPPORTED; |
293 |
|
|
294 |
default: |
default: |
295 |
return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); |
return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2); |
296 |
} |
} |
304 |
dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); |
dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0); |
305 |
if (dwDriverId != (DWORD)NULL) |
if (dwDriverId != (DWORD)NULL) |
306 |
{ |
{ |
307 |
DriverProc(dwDriverId, 0, ICM_CONFIGURE, 0, 0); |
DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0); |
308 |
DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); |
DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0); |
309 |
} |
} |
310 |
} |
} |