[svn] / trunk / xvidcore / vfw / src / driverproc.c Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/vfw/src/driverproc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1520 - (view) (download)

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

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