Mercurial > mplayer.hg
annotate loader/vfl.c @ 1373:d1d37abe6389
only FAQ and SOUNDCARDS stuff not formatted/missing
author | gabucino |
---|---|
date | Sat, 21 Jul 2001 13:24:41 +0000 |
parents | cca0d2481b7e |
children | ce45cce7f7a5 |
rev | line source |
---|---|
1 | 1 /* |
2 * Copyright 1998 Marcus Meissner | |
3 */ | |
4 #include <config.h> | |
5 | |
6 #include <stdio.h> | |
1312 | 7 #include <stdlib.h> |
1 | 8 #include <string.h> |
9 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
10 #include "win32.h" |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
11 #include "loader.h" |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
12 |
1 | 13 #include "wine/winbase.h" |
14 #include "wine/windef.h" | |
15 #include "wine/winuser.h" | |
16 #include "wine/vfw.h" | |
17 #include "wine/winestring.h" | |
18 #include "wine/driver.h" | |
19 #include "wine/avifmt.h" | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
20 #include "driver.h" |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
21 |
1 | 22 |
23 #define FIXME_(X) printf | |
24 #define FIXME printf | |
25 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
26 #define OpenDriverA DrvOpen |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
27 #define CloseDriver DrvClose |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
28 |
1 | 29 long VFWAPI VideoForWindowsVersion(void); |
30 | |
31 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
32 #if 1 |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
33 /* |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
34 * STORE_ALL/REST_ALL seems like an attempt to workaround problems due to |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
35 * WINAPI/no-WINAPI bustage. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
36 * |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
37 * There should be no need for the STORE_ALL/REST_ALL hack once all |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
38 * function definitions agree with their prototypes (WINAPI-wise) and |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
39 * we make sure, that we do not call these functions without a proper |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
40 * prototype in scope. |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
41 */ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
42 #define STORE_ALL /**/ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
43 #define REST_ALL /**/ |
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
44 #else |
1 | 45 #define STORE_ALL \ |
46 __asm__ ( \ | |
47 "push %%ebx\n\t" \ | |
48 "push %%ecx\n\t" \ | |
49 "push %%edx\n\t" \ | |
50 "push %%esi\n\t" \ | |
51 "push %%edi\n\t"::) | |
52 | |
53 #define REST_ALL \ | |
54 __asm__ ( \ | |
55 "pop %%edi\n\t" \ | |
56 "pop %%esi\n\t" \ | |
57 "pop %%edx\n\t" \ | |
58 "pop %%ecx\n\t" \ | |
59 "pop %%ebx\n\t"::) | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
60 #endif |
1 | 61 |
62 | |
63 /*********************************************************************** | |
64 * VideoForWindowsVersion [MSVFW.2][MSVIDEO.2] | |
65 * Returns the version in major.minor form. | |
66 * In Windows95 this returns 0x040003b6 (4.950) | |
67 */ | |
68 long VideoForWindowsVersion(void) { | |
69 return 0x040003B6; /* 4.950 */ | |
70 } | |
71 | |
72 /* system.ini: [drivers] */ | |
73 | |
74 /*********************************************************************** | |
75 * ICInfo [MSVFW.33] | |
76 * Get information about an installable compressor. Return TRUE if there | |
77 * is one. | |
78 */ | |
79 int VFWAPI | |
80 ICInfo( | |
81 long fccType, /* [in] type of compressor ('vidc') */ | |
82 long fccHandler, /* [in] <n>th compressor */ | |
83 ICINFO *lpicinfo /* [out] information about compressor */ | |
84 ) { | |
85 char type[5]; | |
86 | |
87 memcpy(type,&fccType,4);type[4]=0; | |
88 | |
89 /* does OpenDriver/CloseDriver */ | |
90 lpicinfo->dwSize = sizeof(ICINFO); | |
91 lpicinfo->fccType = fccType; | |
92 lpicinfo->dwFlags = 0; | |
93 /* | |
94 if (GetPrivateProfileStringA("drivers32",NULL,NULL,buf,2000,"system.ini")) { | |
95 char *s = buf; | |
96 while (*s) { | |
97 if (!lstrncmpiA(type,s,4)) { | |
98 if(!fccHandler--) { | |
99 lpicinfo->fccHandler = mmioStringToFOURCCA(s+5,0); | |
100 return TRUE; | |
101 } | |
102 } | |
103 s=s+lstrlenA(s)+1; | |
104 } | |
105 } | |
106 */ | |
107 return TRUE; | |
108 } | |
109 | |
110 /*********************************************************************** | |
111 * ICOpen [MSVFW.37] | |
112 * Opens an installable compressor. Return special handle. | |
113 */ | |
114 HIC VFWAPI | |
115 ICOpen(long fccType,long fccHandler,unsigned int wMode) { | |
116 char type[5],handler[5],codecname[20]; | |
117 ICOPEN icopen; | |
118 HDRVR hdrv; | |
119 WINE_HIC *whic; | |
120 | |
121 memcpy(type,&fccType,4);type[4]=0; | |
122 memcpy(handler,&fccHandler,4);handler[4]=0; | |
123 | |
1096 | 124 snprintf(codecname,20,"%s.%s",type,handler); |
1 | 125 |
126 /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the | |
127 * same layout as ICOPEN | |
128 */ | |
129 icopen.fccType = fccType; | |
130 icopen.fccHandler = fccHandler; | |
131 icopen.dwSize = sizeof(ICOPEN); | |
132 icopen.dwFlags = wMode; | |
133 /* FIXME: do we need to fill out the rest too? */ | |
134 // hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen); | |
135 hdrv=OpenDriverA((long)&icopen); | |
136 /* | |
137 if (!hdrv) { | |
138 if (!strcasecmp(type,"vids")) { | |
1096 | 139 snprintf(codecname,20,"vidc.%s",handler); |
1 | 140 fccType = mmioFOURCC('v','i','d','c'); |
141 } | |
142 // hdrv=OpenDriverA(codecname,"drivers32",(long)&icopen); | |
143 hdrv=OpenDriverA((long)&icopen); | |
144 */ | |
145 if (!hdrv) | |
146 return 0; | |
147 // } | |
148 whic = (WINE_HIC*)my_mreq(sizeof(WINE_HIC), 0); | |
149 whic->hdrv = hdrv; | |
150 whic->driverproc= ((DRVR*)hdrv)->DriverProc; | |
151 // whic->private = ICSendMessage((HIC)whic,DRV_OPEN,0,(long)&icopen); | |
152 whic->private = ((DRVR*)hdrv)->dwDriverID; | |
153 return (HIC)whic; | |
154 } | |
155 | |
156 /*********************************************************************** | |
157 * ICOpenFunction [MSVFW.38] | |
158 */ | |
159 HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, | |
160 void* lpfnHandler) { | |
161 char type[5],handler[5]; | |
162 HIC hic; | |
163 WINE_HIC *whic; | |
164 | |
165 memcpy(type,&fccType,4);type[4]=0; | |
166 memcpy(handler,&fccHandler,4);handler[4]=0; | |
167 FIXME("(%s,%s,%d,%p), stub!\n",type,handler,wMode,lpfnHandler); | |
168 hic = ICOpen(fccType,fccHandler,wMode); | |
169 if (!hic) | |
170 return hic; | |
171 whic = (WINE_HIC*)hic; | |
172 whic->driverproc = (DRIVERPROC)lpfnHandler; | |
173 return hic; | |
174 } | |
175 | |
176 | |
177 /*********************************************************************** | |
178 * ICGetInfo [MSVFW.30] | |
179 */ | |
180 LRESULT VFWAPI | |
181 ICGetInfo(HIC hic,ICINFO *picinfo,long cb) { | |
182 LRESULT ret; | |
183 | |
184 ret = ICSendMessage(hic,ICM_GETINFO,(long)picinfo,cb); | |
185 | |
186 return ret; | |
187 } | |
188 | |
189 /*********************************************************************** | |
190 * ICLocate [MSVFW.35] | |
191 */ | |
192 HIC VFWAPI | |
193 ICLocate( | |
194 long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, | |
195 LPBITMAPINFOHEADER lpbiOut, short wMode | |
196 ) { | |
197 char type[5],handler[5]; | |
198 HIC hic; | |
199 long querymsg; | |
200 | |
201 switch (wMode) { | |
202 case ICMODE_FASTCOMPRESS: | |
203 case ICMODE_COMPRESS: | |
204 querymsg = ICM_COMPRESS_QUERY; | |
205 break; | |
206 case ICMODE_DECOMPRESS: | |
207 case ICMODE_FASTDECOMPRESS: | |
208 querymsg = ICM_DECOMPRESS_QUERY; | |
209 break; | |
210 case ICMODE_DRAW: | |
211 querymsg = ICM_DRAW_QUERY; | |
212 break; | |
213 default: | |
214 FIXME("Unknown mode (%d)\n",wMode); | |
215 return 0; | |
216 } | |
217 | |
218 /* Easy case: handler/type match, we just fire a query and return */ | |
219 hic = ICOpen(fccType,fccHandler,wMode); | |
220 if (hic) { | |
221 if (!ICSendMessage(hic,querymsg,(long)lpbiIn,(long)lpbiOut)) | |
222 return hic; | |
223 ICClose(hic); | |
224 } | |
225 type[4]='\0';memcpy(type,&fccType,4); | |
226 handler[4]='\0';memcpy(handler,&fccHandler,4); | |
227 if (fccType==streamtypeVIDEO) { | |
228 hic = ICLocate(ICTYPE_VIDEO,fccHandler,lpbiIn,lpbiOut,wMode); | |
229 if (hic) | |
230 return hic; | |
231 } | |
232 FIXME("(%s,%s,%p,%p,0x%04x),unhandled!\n",type,handler,lpbiIn,lpbiOut,wMode); | |
233 return 0; | |
234 } | |
235 | |
236 /*********************************************************************** | |
237 * ICCompress [MSVFW.23] | |
238 */ | |
239 long VFWAPIV | |
240 ICCompress( | |
241 HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData, | |
242 LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid, | |
243 long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality, | |
244 LPBITMAPINFOHEADER lpbiPrev,void* lpPrev | |
245 ) { | |
246 ICCOMPRESS iccmp; | |
247 | |
248 iccmp.dwFlags = dwFlags; | |
249 | |
250 iccmp.lpbiOutput = lpbiOutput; | |
251 iccmp.lpOutput = lpData; | |
252 iccmp.lpbiInput = lpbiInput; | |
253 iccmp.lpInput = lpBits; | |
254 | |
255 iccmp.lpckid = lpckid; | |
256 iccmp.lpdwFlags = lpdwFlags; | |
257 iccmp.lFrameNum = lFrameNum; | |
258 iccmp.dwFrameSize = dwFrameSize; | |
259 iccmp.dwQuality = dwQuality; | |
260 iccmp.lpbiPrev = lpbiPrev; | |
261 iccmp.lpPrev = lpPrev; | |
262 return ICSendMessage(hic,ICM_COMPRESS,(long)&iccmp,sizeof(iccmp)); | |
263 } | |
264 | |
265 /*********************************************************************** | |
266 * ICDecompress [MSVFW.26] | |
267 */ | |
268 long VFWAPIV | |
269 ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits) { | |
270 ICDECOMPRESS icd; | |
271 int result; | |
272 icd.dwFlags = dwFlags; | |
273 icd.lpbiInput = lpbiFormat; | |
274 icd.lpInput = lpData; | |
275 | |
276 icd.lpbiOutput = lpbi; | |
277 icd.lpOutput = lpBits; | |
278 icd.ckid = 0; | |
279 STORE_ALL; | |
280 result=ICSendMessage(hic,ICM_DECOMPRESS,(long)&icd,sizeof(icd)); | |
281 REST_ALL; | |
282 return result; | |
283 } | |
284 | |
285 /*********************************************************************** | |
1297 | 286 * ICDecompressEx [MSVFW.26] |
287 */ | |
288 long VFWAPIV | |
289 ICDecompressEx(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits) { | |
290 ICDECOMPRESSEX icd; | |
291 int result; | |
292 | |
293 icd.dwFlags = dwFlags; | |
294 | |
295 icd.lpbiSrc = lpbiFormat; | |
296 icd.lpSrc = lpData; | |
297 | |
298 icd.lpbiDst = lpbi; | |
299 icd.lpDst = lpBits; | |
300 | |
301 icd.xSrc=icd.ySrc=0; | |
302 icd.dxSrc=lpbiFormat->biWidth; | |
303 icd.dySrc=abs(lpbiFormat->biHeight); | |
304 | |
305 icd.xDst=icd.yDst=0; | |
306 icd.dxDst=lpbi->biWidth; | |
307 icd.dyDst=abs(lpbi->biHeight); | |
308 | |
309 //icd.ckid = 0; | |
310 STORE_ALL; | |
311 result=ICSendMessage(hic,ICM_DECOMPRESSEX,(long)&icd,sizeof(icd)); | |
312 REST_ALL; | |
313 return result; | |
314 } | |
315 | |
316 long VFWAPIV | |
317 ICUniversalEx(HIC hic,int command,LPBITMAPINFOHEADER lpbiFormat,LPBITMAPINFOHEADER lpbi) { | |
318 ICDECOMPRESSEX icd; | |
319 int result; | |
320 | |
321 icd.dwFlags = 0; | |
322 | |
323 icd.lpbiSrc = lpbiFormat; | |
324 icd.lpSrc = 0; | |
325 | |
326 icd.lpbiDst = lpbi; | |
327 icd.lpDst = 0; | |
328 | |
329 icd.xSrc=icd.ySrc=0; | |
330 icd.dxSrc=lpbiFormat->biWidth; | |
331 icd.dySrc=abs(lpbiFormat->biHeight); | |
332 | |
333 icd.xDst=icd.yDst=0; | |
334 icd.dxDst=lpbi->biWidth; | |
335 icd.dyDst=abs(lpbi->biHeight); | |
336 | |
337 //icd.ckid = 0; | |
338 STORE_ALL; | |
339 result=ICSendMessage(hic,command,(long)&icd,sizeof(icd)); | |
340 REST_ALL; | |
341 return result; | |
342 } | |
343 | |
344 | |
345 /*********************************************************************** | |
1 | 346 * ICSendMessage [MSVFW.40] |
347 */ | |
348 LRESULT VFWAPI | |
349 ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) { | |
350 LRESULT ret; | |
351 WINE_HIC *whic = (WINE_HIC*)hic; | |
352 char qw[200]; | |
353 | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
354 #if 0 |
1 | 355 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw)); |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
356 #endif |
1 | 357 STORE_ALL; |
358 /*__asm__ | |
359 ( | |
360 "pushl %eax\n\t" | |
361 "movl $0xf,%eax\n\t" | |
362 "movw %ax, %fs\n\t" | |
363 "popl %eax\n\t" | |
364 );*/ | |
365 ret = whic->driverproc(whic->private,1,msg,lParam1,lParam2); | |
366 REST_ALL; | |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
367 #if 0 |
1 | 368 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw)); |
1307
d8c1b0b38edc
Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents:
1297
diff
changeset
|
369 #endif |
1 | 370 // } else |
371 | |
372 // ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2); | |
373 // TRACE(" -> 0x%08lx\n",ret); | |
374 return ret; | |
375 } | |
376 | |
377 | |
378 /*********************************************************************** | |
379 * ICClose [MSVFW.22] | |
380 */ | |
381 LRESULT VFWAPI ICClose(HIC hic) { | |
382 WINE_HIC *whic = (WINE_HIC*)hic; | |
383 /* FIXME: correct? */ | |
384 // CloseDriver(whic->hdrv,0,0); | |
385 DrvClose(whic->hdrv); | |
386 //#warning FIXME: DrvClose | |
387 my_release(whic); | |
388 return 0; | |
389 } | |
390 int VFWAPI ICDoSomething() | |
391 { | |
392 return 0; | |
393 } | |
394 |