[svn] / branches / dev-api-4 / xvidcore / vfw / src / driverproc.c Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/vfw/src/driverproc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1171 - (view) (download)

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

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4