1
|
1 /*
|
|
2 * Copyright 1998 Marcus Meissner
|
|
3 */
|
|
4 #include <config.h>
|
|
5
|
|
6 #include <stdio.h>
|
|
7 #include <string.h>
|
|
8
|
|
9 #include "wine/winbase.h"
|
|
10 #include "wine/windef.h"
|
|
11 #include "wine/winuser.h"
|
|
12 #include "wine/vfw.h"
|
|
13 #include "wine/winestring.h"
|
|
14 #include "wine/driver.h"
|
|
15 #include "wine/avifmt.h"
|
|
16
|
|
17 #define FIXME_(X) printf
|
|
18 #define FIXME printf
|
|
19
|
|
20 long VFWAPI VideoForWindowsVersion(void);
|
|
21
|
|
22 extern void* my_mreq(int size, int to_zero);
|
|
23 extern void DrvClose(HDRVR hdrvr);
|
597
|
24 extern int my_release(void* memory);
|
1
|
25
|
|
26 long VFWAPIV ICDecompress(HIC hic,long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData,LPBITMAPINFOHEADER lpbi,void* lpBits);
|
|
27
|
|
28 WIN_BOOL VFWAPI ICInfo(long fccType, long fccHandler, ICINFO * lpicinfo);
|
|
29 LRESULT VFWAPI ICGetInfo(HIC hic,ICINFO *picinfo, long cb);
|
|
30 HIC VFWAPI ICOpen(long fccType, long fccHandler, UINT wMode);
|
|
31 HIC VFWAPI ICOpenFunction(long fccType, long fccHandler, unsigned int wMode, void* lpfnHandler);
|
|
32
|
|
33 LRESULT VFWAPI ICClose(HIC hic);
|
|
34 LRESULT VFWAPI ICSendMessage(HIC hic, unsigned int msg, long dw1, long dw2);
|
|
35 HIC VFWAPI ICLocate(long fccType, long fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, short wFlags);
|
|
36
|
|
37 #define OpenDriverA DrvOpen
|
|
38 extern HDRVR VFWAPI DrvOpen(long);
|
|
39 #define STORE_ALL \
|
|
40 __asm__ ( \
|
|
41 "push %%ebx\n\t" \
|
|
42 "push %%ecx\n\t" \
|
|
43 "push %%edx\n\t" \
|
|
44 "push %%esi\n\t" \
|
|
45 "push %%edi\n\t"::)
|
|
46
|
|
47 #define REST_ALL \
|
|
48 __asm__ ( \
|
|
49 "pop %%edi\n\t" \
|
|
50 "pop %%esi\n\t" \
|
|
51 "pop %%edx\n\t" \
|
|
52 "pop %%ecx\n\t" \
|
|
53 "pop %%ebx\n\t"::)
|
|
54
|
|
55
|
|
56 typedef struct {
|
|
57 unsigned int uDriverSignature;
|
|
58 void* hDriverModule;
|
|
59 DRIVERPROC DriverProc;
|
|
60 long dwDriverID;
|
|
61 } DRVR;
|
|
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 /***********************************************************************
|
|
286 * ICSendMessage [MSVFW.40]
|
|
287 */
|
|
288 LRESULT VFWAPI
|
|
289 ICSendMessage(HIC hic,unsigned int msg,long lParam1,long lParam2) {
|
|
290 LRESULT ret;
|
|
291 WINE_HIC *whic = (WINE_HIC*)hic;
|
|
292 char qw[200];
|
|
293
|
|
294 __asm__ __volatile__ ("fsave (%0)\n\t": :"r"(&qw));
|
|
295 STORE_ALL;
|
|
296 /*__asm__
|
|
297 (
|
|
298 "pushl %eax\n\t"
|
|
299 "movl $0xf,%eax\n\t"
|
|
300 "movw %ax, %fs\n\t"
|
|
301 "popl %eax\n\t"
|
|
302 );*/
|
|
303 ret = whic->driverproc(whic->private,1,msg,lParam1,lParam2);
|
|
304 REST_ALL;
|
|
305 __asm__ __volatile__ ("frstor (%0)\n\t": :"r"(&qw));
|
|
306 // } else
|
|
307
|
|
308 // ret = SendDriverMessage(whic->hdrv,msg,lParam1,lParam2);
|
|
309 // TRACE(" -> 0x%08lx\n",ret);
|
|
310 return ret;
|
|
311 }
|
|
312
|
|
313
|
|
314 /***********************************************************************
|
|
315 * ICClose [MSVFW.22]
|
|
316 */
|
|
317 LRESULT VFWAPI ICClose(HIC hic) {
|
|
318 WINE_HIC *whic = (WINE_HIC*)hic;
|
|
319 /* FIXME: correct? */
|
|
320 // CloseDriver(whic->hdrv,0,0);
|
|
321 DrvClose(whic->hdrv);
|
|
322 //#warning FIXME: DrvClose
|
|
323 my_release(whic);
|
|
324 return 0;
|
|
325 }
|
|
326 int VFWAPI ICDoSomething()
|
|
327 {
|
|
328 return 0;
|
|
329 }
|
|
330
|