Merge documentation/status/lzexpand into the lzexpand source.
[wine/multimedia.git] / dlls / msvideo / msvideo16.c
blob64d39b063313d17a90a069a307b0af9dff936edc
1 /*
2 * msvideo 16-bit functions
4 * Copyright 1998 Marcus Meissner
5 * Copyright 2000 Bradley Baetz
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define COM_NO_WINDOWS_H
23 #include <stdio.h>
24 #include <string.h>
26 #include "msvideo_private.h"
27 #include "winver.h"
28 #include "winnls.h"
29 #include "vfw16.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msvideo);
35 /***********************************************************************
36 * DrawDibOpen [MSVIDEO.102]
38 HDRAWDIB16 VFWAPI DrawDibOpen16(void)
40 return HDRAWDIB_16(DrawDibOpen());
43 /***********************************************************************
44 * DrawDibClose [MSVIDEO.103]
46 BOOL16 VFWAPI DrawDibClose16(HDRAWDIB16 hdd)
48 return DrawDibClose(HDRAWDIB_32(hdd));
51 /************************************************************************
52 * DrawDibBegin [MSVIDEO.104]
54 BOOL16 VFWAPI DrawDibBegin16(HDRAWDIB16 hdd, HDC16 hdc, INT16 dxDst,
55 INT16 dyDst, LPBITMAPINFOHEADER lpbi, INT16 dxSrc,
56 INT16 dySrc, UINT16 wFlags)
58 return DrawDibBegin(HDRAWDIB_32(hdd), HDC_32(hdc), dxDst, dyDst, lpbi,
59 dxSrc, dySrc, wFlags);
62 /***********************************************************************
63 * DrawDibEnd [MSVIDEO.105]
65 BOOL16 VFWAPI DrawDibEnd16(HDRAWDIB16 hdd)
67 return DrawDibEnd(HDRAWDIB_32(hdd));
70 /**********************************************************************
71 * DrawDibDraw [MSVIDEO.106]
73 BOOL16 VFWAPI DrawDibDraw16(HDRAWDIB16 hdd, HDC16 hdc, INT16 xDst, INT16 yDst,
74 INT16 dxDst, INT16 dyDst, LPBITMAPINFOHEADER lpbi,
75 LPVOID lpBits, INT16 xSrc, INT16 ySrc, INT16 dxSrc,
76 INT16 dySrc, UINT16 wFlags)
78 return DrawDibDraw(HDRAWDIB_32(hdd), HDC_32(hdc), xDst, yDst, dxDst,
79 dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags);
82 /***********************************************************************
83 * DrawDibGetPalette [MSVIDEO.108]
85 HPALETTE16 VFWAPI DrawDibGetPalette16(HDRAWDIB16 hdd)
87 return HPALETTE_16(DrawDibGetPalette(HDRAWDIB_32(hdd)));
90 /***********************************************************************
91 * DrawDibSetPalette [MSVIDEO.110]
93 BOOL16 VFWAPI DrawDibSetPalette16(HDRAWDIB16 hdd, HPALETTE16 hpal)
95 return DrawDibSetPalette(HDRAWDIB_32(hdd), HPALETTE_32(hpal));
98 /***********************************************************************
99 * DrawDibRealize [MSVIDEO.112]
101 UINT16 VFWAPI DrawDibRealize16(HDRAWDIB16 hdd, HDC16 hdc,
102 BOOL16 fBackground)
104 return (UINT16)DrawDibRealize(HDRAWDIB_32(hdd), HDC_32(hdc), fBackground);
107 /*************************************************************************
108 * DrawDibStart [MSVIDEO.118]
110 BOOL16 VFWAPI DrawDibStart16(HDRAWDIB16 hdd, DWORD rate)
112 return DrawDibStart(HDRAWDIB_32(hdd), rate);
115 /*************************************************************************
116 * DrawDibStop [MSVIDEO.119]
118 BOOL16 DrawDibStop16(HDRAWDIB16 hdd)
120 return DrawDibStop(HDRAWDIB_32(hdd));
123 /***********************************************************************
124 * ICOpen [MSVIDEO.203]
126 HIC16 VFWAPI ICOpen16(DWORD fccType, DWORD fccHandler, UINT16 wMode)
128 return HIC_16(ICOpen(fccType, fccHandler, wMode));
131 /***********************************************************************
132 * ICClose [MSVIDEO.204]
134 LRESULT WINAPI ICClose16(HIC16 hic)
136 return ICClose(HIC_32(hic));
139 /***********************************************************************
140 * _ICMessage [MSVIDEO.207]
142 LRESULT VFWAPIV ICMessage16( HIC16 hic, UINT16 msg, UINT16 cb, VA_LIST16 valist )
144 LPWORD lpData;
145 SEGPTR segData;
146 LRESULT ret;
147 UINT16 i;
149 lpData = HeapAlloc(GetProcessHeap(), 0, cb);
151 TRACE("0x%08lx, %u, %u, ...)\n", (DWORD) hic, msg, cb);
153 for (i = 0; i < cb / sizeof(WORD); i++)
155 lpData[i] = VA_ARG16(valist, WORD);
158 segData = MapLS(lpData);
159 ret = ICSendMessage16(hic, msg, segData, (DWORD) cb);
160 UnMapLS(segData);
161 HeapFree(GetProcessHeap(), 0, lpData);
162 return ret;
165 /***********************************************************************
166 * ICGetInfo [MSVIDEO.212]
168 LRESULT VFWAPI ICGetInfo16(HIC16 hic, ICINFO16 * picinfo, DWORD cb)
170 LRESULT ret;
172 TRACE("(0x%08lx,%p,%ld)\n", (DWORD) hic, picinfo, cb);
173 ret = ICSendMessage16(hic, ICM_GETINFO, (DWORD) picinfo, cb);
174 TRACE(" -> 0x%08lx\n", ret);
175 return ret;
178 /***********************************************************************
179 * ICLocate [MSVIDEO.213]
181 HIC16 VFWAPI ICLocate16(DWORD fccType, DWORD fccHandler,
182 LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut,
183 WORD wFlags)
185 return HIC_16(ICLocate(fccType, fccHandler, lpbiIn, lpbiOut, wFlags));
188 /***********************************************************************
189 * _ICCompress [MSVIDEO.224]
191 DWORD VFWAPIV ICCompress16(HIC16 hic, DWORD dwFlags,
192 LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData,
193 LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits,
194 LPDWORD lpckid, LPDWORD lpdwFlags,
195 LONG lFrameNum, DWORD dwFrameSize,
196 DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev,
197 LPVOID lpPrev)
199 DWORD ret;
200 ICCOMPRESS iccmp;
201 SEGPTR seg_iccmp;
203 TRACE("(0x%08lx,%ld,%p,%p,%p,%p,...)\n", (DWORD) hic, dwFlags,
204 lpbiOutput, lpData, lpbiInput, lpBits);
206 iccmp.dwFlags = dwFlags;
208 iccmp.lpbiOutput = lpbiOutput;
209 iccmp.lpOutput = lpData;
210 iccmp.lpbiInput = lpbiInput;
211 iccmp.lpInput = lpBits;
213 iccmp.lpckid = lpckid;
214 iccmp.lpdwFlags = lpdwFlags;
215 iccmp.lFrameNum = lFrameNum;
216 iccmp.dwFrameSize = dwFrameSize;
217 iccmp.dwQuality = dwQuality;
218 iccmp.lpbiPrev = lpbiPrev;
219 iccmp.lpPrev = lpPrev;
220 seg_iccmp = MapLS(&iccmp);
221 ret = ICSendMessage16(hic, ICM_COMPRESS, seg_iccmp, sizeof(ICCOMPRESS));
222 UnMapLS(seg_iccmp);
223 return ret;
226 /***********************************************************************
227 * _ICDecompress [MSVIDEO.230]
229 DWORD VFWAPIV ICDecompress16(HIC16 hic, DWORD dwFlags,
230 LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData,
231 LPBITMAPINFOHEADER lpbi, LPVOID lpBits)
233 ICDECOMPRESS icd;
234 SEGPTR segptr;
235 DWORD ret;
237 TRACE("(0x%08lx,%ld,%p,%p,%p,%p)\n", (DWORD) hic, dwFlags, lpbiFormat,
238 lpData, lpbi, lpBits);
240 icd.dwFlags = dwFlags;
241 icd.lpbiInput = lpbiFormat;
242 icd.lpInput = lpData;
243 icd.lpbiOutput = lpbi;
244 icd.lpOutput = lpBits;
245 icd.ckid = 0;
246 segptr = MapLS(&icd);
247 ret = ICSendMessage16(hic, ICM_DECOMPRESS, segptr, sizeof(ICDECOMPRESS));
248 UnMapLS(segptr);
249 return ret;
252 /***********************************************************************
253 * _ICDrawBegin [MSVIDEO.232]
255 DWORD VFWAPIV ICDrawBegin16(HIC16 hic, /* [in] */
256 DWORD dwFlags, /* [in] flags */
257 HPALETTE16 hpal, /* [in] palette to draw with */
258 HWND16 hwnd, /* [in] window to draw to */
259 HDC16 hdc, /* [in] HDC to draw to */
260 INT16 xDst, /* [in] destination rectangle */
261 INT16 yDst, /* [in] */
262 INT16 dxDst, /* [in] */
263 INT16 dyDst, /* [in] */
264 LPBITMAPINFOHEADER lpbi, /* [in] format of frame to draw NOTE: SEGPTR */
265 INT16 xSrc, /* [in] source rectangle */
266 INT16 ySrc, /* [in] */
267 INT16 dxSrc, /* [in] */
268 INT16 dySrc, /* [in] */
269 DWORD dwRate, /* [in] frames/second = (dwRate/dwScale) */
270 DWORD dwScale) /* [in] */
272 DWORD ret;
273 ICDRAWBEGIN16 icdb;
274 SEGPTR seg_icdb;
276 TRACE ("(0x%08lx,%ld,0x%08lx,0x%08lx,0x%08lx,%u,%u,%u,%u,%p,%u,%u,%u,%u,%ld,%ld)\n",
277 (DWORD) hic, dwFlags, (DWORD) hpal, (DWORD) hwnd, (DWORD) hdc,
278 xDst, yDst, dxDst, dyDst, lpbi, xSrc, ySrc, dxSrc, dySrc, dwRate,
279 dwScale);
281 icdb.dwFlags = dwFlags;
282 icdb.hpal = hpal;
283 icdb.hwnd = hwnd;
284 icdb.hdc = hdc;
285 icdb.xDst = xDst;
286 icdb.yDst = yDst;
287 icdb.dxDst = dxDst;
288 icdb.dyDst = dyDst;
289 icdb.lpbi = lpbi; /* Keep this as SEGPTR for the mapping code to deal with */
290 icdb.xSrc = xSrc;
291 icdb.ySrc = ySrc;
292 icdb.dxSrc = dxSrc;
293 icdb.dySrc = dySrc;
294 icdb.dwRate = dwRate;
295 icdb.dwScale = dwScale;
296 seg_icdb = MapLS(&icdb);
297 ret = (DWORD) ICSendMessage16(hic, ICM_DRAW_BEGIN, seg_icdb,
298 sizeof(ICDRAWBEGIN16));
299 UnMapLS(seg_icdb);
300 return ret;
303 /***********************************************************************
304 * _ICDraw [MSVIDEO.234]
306 DWORD VFWAPIV ICDraw16(HIC16 hic, DWORD dwFlags,
307 LPVOID lpFormat, /* [???] NOTE: SEGPTR */
308 LPVOID lpData, /* [???] NOTE: SEGPTR */
309 DWORD cbData, LONG lTime)
311 DWORD ret;
312 ICDRAW icd;
313 SEGPTR seg_icd;
315 TRACE("(0x%08lx,0x%08lx,%p,%p,%ld,%ld)\n", (DWORD) hic, dwFlags,
316 lpFormat, lpData, cbData, lTime);
317 icd.dwFlags = dwFlags;
318 icd.lpFormat = lpFormat;
319 icd.lpData = lpData;
320 icd.cbData = cbData;
321 icd.lTime = lTime;
322 seg_icd = MapLS(&icd);
323 ret = ICSendMessage16(hic, ICM_DRAW, seg_icd, sizeof(ICDRAW));
324 UnMapLS(seg_icd);
325 return ret;
328 /***********************************************************************
329 * ICGetDisplayFormat [MSVIDEO.239]
331 HIC16 VFWAPI ICGetDisplayFormat16(HIC16 hic, LPBITMAPINFOHEADER lpbiIn,
332 LPBITMAPINFOHEADER lpbiOut, INT16 depth,
333 INT16 dx, INT16 dy)
335 return HIC_16(ICGetDisplayFormat(HIC_32(hic), lpbiIn, lpbiOut, depth,
336 dx, dy));
339 #define COPY(x,y) (x->y = x##16->y);
340 #define COPYPTR(x,y) (x->y = MapSL((SEGPTR)x##16->y));
342 /******************************************************************
343 * MSVIDEO_MapICDEX16To32
347 static LPVOID MSVIDEO_MapICDEX16To32(LPDWORD lParam)
349 LPVOID ret;
351 ICDECOMPRESSEX *icdx = HeapAlloc(GetProcessHeap(), 0, sizeof(ICDECOMPRESSEX));
352 ICDECOMPRESSEX16 *icdx16 = MapSL(*lParam);
353 ret = icdx16;
355 COPY(icdx, dwFlags);
356 COPYPTR(icdx, lpbiSrc);
357 COPYPTR(icdx, lpSrc);
358 COPYPTR(icdx, lpbiDst);
359 COPYPTR(icdx, lpDst);
360 COPY(icdx, xDst);
361 COPY(icdx, yDst);
362 COPY(icdx, dxDst);
363 COPY(icdx, dyDst);
364 COPY(icdx, xSrc);
365 COPY(icdx, ySrc);
366 COPY(icdx, dxSrc);
367 COPY(icdx, dySrc);
369 *lParam = (DWORD)(icdx);
370 return ret;
373 /******************************************************************
374 * MSVIDEO_MapMsg16To32
378 static LPVOID MSVIDEO_MapMsg16To32(UINT msg, LPDWORD lParam1, LPDWORD lParam2)
380 LPVOID ret = 0;
382 TRACE("Mapping %d\n", msg);
384 switch (msg)
386 case DRV_LOAD:
387 case DRV_ENABLE:
388 case DRV_CLOSE:
389 case DRV_DISABLE:
390 case DRV_FREE:
391 case ICM_ABOUT:
392 case ICM_CONFIGURE:
393 case ICM_COMPRESS_END:
394 case ICM_DECOMPRESS_END:
395 case ICM_DECOMPRESSEX_END:
396 case ICM_SETQUALITY:
397 case ICM_DRAW_START_PLAY:
398 case ICM_DRAW_STOP_PLAY:
399 case ICM_DRAW_REALIZE:
400 case ICM_DRAW_RENDERBUFFER:
401 case ICM_DRAW_END:
402 break;
403 case DRV_OPEN:
404 case ICM_GETDEFAULTQUALITY:
405 case ICM_GETQUALITY:
406 case ICM_SETSTATE:
407 case ICM_DRAW_WINDOW:
408 case ICM_GETBUFFERSWANTED:
409 *lParam1 = (DWORD)MapSL(*lParam1);
410 break;
411 case ICM_GETINFO:
413 ICINFO *ici = HeapAlloc(GetProcessHeap(), 0, sizeof(ICINFO));
414 ICINFO16 *ici16;
416 ici16 = MapSL(*lParam1);
417 ret = ici16;
419 ici->dwSize = sizeof(ICINFO);
420 COPY(ici, fccType);
421 COPY(ici, fccHandler);
422 COPY(ici, dwFlags);
423 COPY(ici, dwVersion);
424 COPY(ici, dwVersionICM);
425 MultiByteToWideChar( CP_ACP, 0, ici16->szName, -1, ici->szName, 16 );
426 MultiByteToWideChar( CP_ACP, 0, ici16->szDescription, -1, ici->szDescription, 128 );
427 MultiByteToWideChar( CP_ACP, 0, ici16->szDriver, -1, ici->szDriver, 128 );
428 *lParam1 = (DWORD)(ici);
429 *lParam2 = sizeof(ICINFO);
431 break;
432 case ICM_COMPRESS:
434 ICCOMPRESS *icc = HeapAlloc(GetProcessHeap(), 0, sizeof(ICCOMPRESS));
435 ICCOMPRESS *icc16;
437 icc16 = MapSL(*lParam1);
438 ret = icc16;
440 COPY(icc, dwFlags);
441 COPYPTR(icc, lpbiOutput);
442 COPYPTR(icc, lpOutput);
443 COPYPTR(icc, lpbiInput);
444 COPYPTR(icc, lpInput);
445 COPYPTR(icc, lpckid);
446 COPYPTR(icc, lpdwFlags);
447 COPY(icc, lFrameNum);
448 COPY(icc, dwFrameSize);
449 COPY(icc, dwQuality);
450 COPYPTR(icc, lpbiPrev);
451 COPYPTR(icc, lpPrev);
453 *lParam1 = (DWORD)(icc);
454 *lParam2 = sizeof(ICCOMPRESS);
456 break;
457 case ICM_DECOMPRESS:
459 ICDECOMPRESS *icd = HeapAlloc(GetProcessHeap(), 0, sizeof(ICDECOMPRESS));
460 ICDECOMPRESS *icd16; /* Same structure except for the pointers */
462 icd16 = MapSL(*lParam1);
463 ret = icd16;
465 COPY(icd, dwFlags);
466 COPYPTR(icd, lpbiInput);
467 COPYPTR(icd, lpInput);
468 COPYPTR(icd, lpbiOutput);
469 COPYPTR(icd, lpOutput);
470 COPY(icd, ckid);
472 *lParam1 = (DWORD)(icd);
473 *lParam2 = sizeof(ICDECOMPRESS);
475 break;
476 case ICM_COMPRESS_BEGIN:
477 case ICM_COMPRESS_GET_FORMAT:
478 case ICM_COMPRESS_GET_SIZE:
479 case ICM_COMPRESS_QUERY:
480 case ICM_DECOMPRESS_GET_FORMAT:
481 case ICM_DECOMPRESS_QUERY:
482 case ICM_DECOMPRESS_BEGIN:
483 case ICM_DECOMPRESS_SET_PALETTE:
484 case ICM_DECOMPRESS_GET_PALETTE:
485 *lParam1 = (DWORD)MapSL(*lParam1);
486 *lParam2 = (DWORD)MapSL(*lParam2);
487 break;
488 case ICM_DECOMPRESSEX_QUERY:
489 if ((*lParam2 != sizeof(ICDECOMPRESSEX16)) && (*lParam2 != 0))
490 WARN("*lParam2 has unknown value %p\n", (ICDECOMPRESSEX16*)*lParam2);
491 /* FIXME: *lParm2 is meant to be 0 or an ICDECOMPRESSEX16*, but is sizeof(ICDECOMRPESSEX16)
492 * This is because of ICMessage(). Special case it?
494 LPVOID* addr = HeapAlloc(GetProcessHeap(), 0, 2*sizeof(LPVOID));
495 addr[0] = MSVIDEO_MapICDEX16To32(lParam1);
496 if (*lParam2)
497 addr[1] = MSVIDEO_MapICDEX16To32(lParam2);
498 else
499 addr[1] = 0;
501 ret = addr;
503 break;*/
504 case ICM_DECOMPRESSEX_BEGIN:
505 case ICM_DECOMPRESSEX:
506 ret = MSVIDEO_MapICDEX16To32(lParam1);
507 *lParam2 = sizeof(ICDECOMPRESSEX);
508 break;
509 case ICM_DRAW_BEGIN:
511 ICDRAWBEGIN *icdb = HeapAlloc(GetProcessHeap(), 0, sizeof(ICDRAWBEGIN));
512 ICDRAWBEGIN16 *icdb16 = MapSL(*lParam1);
513 ret = icdb16;
515 COPY(icdb, dwFlags);
516 icdb->hpal = HPALETTE_32(icdb16->hpal);
517 icdb->hwnd = HWND_32(icdb16->hwnd);
518 icdb->hdc = HDC_32(icdb16->hdc);
519 COPY(icdb, xDst);
520 COPY(icdb, yDst);
521 COPY(icdb, dxDst);
522 COPY(icdb, dyDst);
523 COPYPTR(icdb, lpbi);
524 COPY(icdb, xSrc);
525 COPY(icdb, ySrc);
526 COPY(icdb, dxSrc);
527 COPY(icdb, dySrc);
528 COPY(icdb, dwRate);
529 COPY(icdb, dwScale);
531 *lParam1 = (DWORD)(icdb);
532 *lParam2 = sizeof(ICDRAWBEGIN);
534 break;
535 case ICM_DRAW_SUGGESTFORMAT:
537 ICDRAWSUGGEST *icds = HeapAlloc(GetProcessHeap(), 0, sizeof(ICDRAWSUGGEST));
538 ICDRAWSUGGEST16 *icds16 = MapSL(*lParam1);
540 ret = icds16;
542 COPY(icds, dwFlags);
543 COPYPTR(icds, lpbiIn);
544 COPYPTR(icds, lpbiSuggest);
545 COPY(icds, dxSrc);
546 COPY(icds, dySrc);
547 COPY(icds, dxDst);
548 COPY(icds, dyDst);
549 icds->hicDecompressor = HIC_32(icds16->hicDecompressor);
551 *lParam1 = (DWORD)(icds);
552 *lParam2 = sizeof(ICDRAWSUGGEST);
554 break;
555 case ICM_DRAW:
557 ICDRAW *icd = HeapAlloc(GetProcessHeap(), 0, sizeof(ICDRAW));
558 ICDRAW *icd16 = MapSL(*lParam1);
559 ret = icd16;
561 COPY(icd, dwFlags);
562 COPYPTR(icd, lpFormat);
563 COPYPTR(icd, lpData);
564 COPY(icd, cbData);
565 COPY(icd, lTime);
567 *lParam1 = (DWORD)(icd);
568 *lParam2 = sizeof(ICDRAW);
570 break;
571 case ICM_DRAW_START:
572 case ICM_DRAW_STOP:
573 break;
574 default:
575 FIXME("%d is not yet handled. Expect a crash.\n", msg);
577 return ret;
580 #undef COPY
581 #undef COPYPTR
583 /******************************************************************
584 * MSVIDEO_UnmapMsg16To32
588 static void MSVIDEO_UnmapMsg16To32(UINT msg, LPVOID data16, LPDWORD lParam1, LPDWORD lParam2)
590 TRACE("Unmapping %d\n", msg);
592 #define UNCOPY(x, y) (x##16->y = x->y);
594 switch (msg)
596 case ICM_GETINFO:
598 ICINFO *ici = (ICINFO*)(*lParam1);
599 ICINFO16 *ici16 = (ICINFO16*)data16;
601 UNCOPY(ici, fccType);
602 UNCOPY(ici, fccHandler);
603 UNCOPY(ici, dwFlags);
604 UNCOPY(ici, dwVersion);
605 UNCOPY(ici, dwVersionICM);
606 WideCharToMultiByte( CP_ACP, 0, ici->szName, -1, ici16->szName,
607 sizeof(ici16->szName), NULL, NULL );
608 ici16->szName[sizeof(ici16->szName)-1] = 0;
609 WideCharToMultiByte( CP_ACP, 0, ici->szDescription, -1, ici16->szDescription,
610 sizeof(ici16->szDescription), NULL, NULL );
611 ici16->szDescription[sizeof(ici16->szDescription)-1] = 0;
612 /* This just gives garbage for some reason - BB
613 lstrcpynWtoA(ici16->szDriver, ici->szDriver, 128);*/
615 HeapFree(GetProcessHeap(), 0, ici);
617 break;
618 case ICM_DECOMPRESS_QUERY:
620 LPVOID* x = data16;
621 HeapFree(GetProcessHeap(), 0, x[0]);
622 if (x[1])
623 HeapFree(GetProcessHeap(), 0, x[1]);
625 break;*/
626 case ICM_COMPRESS:
627 case ICM_DECOMPRESS:
628 case ICM_DECOMPRESSEX_QUERY:
629 case ICM_DECOMPRESSEX_BEGIN:
630 case ICM_DECOMPRESSEX:
631 case ICM_DRAW_BEGIN:
632 case ICM_DRAW_SUGGESTFORMAT:
633 case ICM_DRAW:
634 HeapFree(GetProcessHeap(), 0, data16);
635 break;
636 default:
637 ERR("Unmapping unmapped msg %d\n", msg);
639 #undef UNCOPY
642 /***********************************************************************
643 * ICInfo [MSVIDEO.200]
645 BOOL16 VFWAPI ICInfo16(DWORD fccType, DWORD fccHandler, ICINFO16 *lpicinfo)
647 BOOL16 ret;
648 LPVOID lpv;
649 DWORD lParam = (DWORD)lpicinfo;
650 DWORD size = ((ICINFO*)(MapSL((SEGPTR)lpicinfo)))->dwSize;
652 /* Use the mapping functions to map the ICINFO structure */
653 lpv = MSVIDEO_MapMsg16To32(ICM_GETINFO, &lParam, &size);
655 ret = ICInfo(fccType, fccHandler, (ICINFO*)lParam);
657 MSVIDEO_UnmapMsg16To32(ICM_GETINFO, lpv, &lParam, &size);
659 return ret;
662 /******************************************************************
663 * IC_Callback3216
667 static LRESULT CALLBACK IC_Callback3216(HIC hic, HDRVR hdrv, UINT msg, DWORD lp1, DWORD lp2)
669 WINE_HIC* whic;
670 LRESULT ret = 0;
671 WORD args[8];
673 whic = MSVIDEO_GetHicPtr(hic);
674 if (whic)
676 switch (msg)
678 case DRV_OPEN:
679 lp2 = (DWORD)MapLS((void*)lp2);
680 break;
682 args[7] = HIWORD(hic);
683 args[6] = LOWORD(hic);
684 args[5] = HDRVR_16(whic->hdrv);
685 args[4] = msg;
686 args[3] = HIWORD(lp1);
687 args[2] = LOWORD(lp1);
688 args[1] = HIWORD(lp2);
689 args[0] = LOWORD(lp2);
690 WOWCallback16Ex( (DWORD)whic->driverproc16, WCB16_PASCAL, sizeof(args), args, &ret );
692 switch (msg)
694 case DRV_OPEN:
695 UnMapLS(lp2);
696 break;
699 else ret = ICERR_BADHANDLE;
700 return ret;
703 /***********************************************************************
704 * ICOpenFunction [MSVIDEO.206]
706 HIC16 VFWAPI ICOpenFunction16(DWORD fccType, DWORD fccHandler, UINT16 wMode, FARPROC16 lpfnHandler)
708 HIC hic32;
710 hic32 = MSVIDEO_OpenFunction(fccType, fccHandler, wMode,
711 (DRIVERPROC)IC_Callback3216, (DWORD)lpfnHandler);
712 return HIC_16(hic32);
715 /***********************************************************************
716 * ICSendMessage [MSVIDEO.205]
718 LRESULT VFWAPI ICSendMessage16(HIC16 hic, UINT16 msg, DWORD lParam1, DWORD lParam2)
720 LRESULT ret = ICERR_BADHANDLE;
721 WINE_HIC* whic;
723 whic = MSVIDEO_GetHicPtr(HIC_32(hic));
724 if (whic)
726 /* we've got a 16 bit driver proc... call it directly */
727 if (whic->driverproc16)
729 WORD args[8];
731 /* FIXME: original code was passing hdrv first and hic second */
732 /* but this doesn't match what IC_Callback3216 does */
733 args[7] = HIWORD(hic);
734 args[6] = LOWORD(hic);
735 args[5] = HDRVR_16(whic->hdrv);
736 args[4] = msg;
737 args[3] = HIWORD(lParam1);
738 args[2] = LOWORD(lParam1);
739 args[1] = HIWORD(lParam2);
740 args[0] = LOWORD(lParam2);
741 WOWCallback16Ex( (DWORD)whic->driverproc16, WCB16_PASCAL, sizeof(args), args, &ret );
743 else
745 /* map the message for a 32 bit infrastructure, and pass it along */
746 void* data16 = MSVIDEO_MapMsg16To32(msg, &lParam1, &lParam2);
748 ret = MSVIDEO_SendMessage(whic, msg, lParam1, lParam2);
749 if (data16)
750 MSVIDEO_UnmapMsg16To32(msg, data16, &lParam1, &lParam2);
753 return ret;
756 /***********************************************************************
757 * VideoCapDriverDescAndVer [MSVIDEO.22]
759 DWORD WINAPI VideoCapDriverDescAndVer16(WORD nr, LPSTR buf1, WORD buf1len,
760 LPSTR buf2, WORD buf2len)
762 DWORD verhandle;
763 WORD xnr = nr;
764 DWORD infosize;
765 UINT subblocklen;
766 char *s, buf[2000], fn[260];
767 LPBYTE infobuf;
768 LPVOID subblock;
770 TRACE("(%d,%p,%d,%p,%d)\n", nr, buf1, buf1len, buf2, buf2len);
771 if (GetPrivateProfileStringA("drivers32", NULL, NULL, buf, sizeof(buf), "system.ini"))
773 s = buf;
774 while (*s)
776 if (!strncasecmp(s, "vid", 3))
778 if (!xnr) break;
779 xnr--;
781 s = s + strlen(s) + 1; /* either next char or \0 */
784 else
785 return 20; /* hmm, out of entries even if we don't have any */
786 if (xnr)
788 FIXME("No more VID* entries found\n");
789 return 20;
791 GetPrivateProfileStringA("drivers32", s, NULL, fn, sizeof(fn), "system.ini");
792 infosize = GetFileVersionInfoSizeA(fn, &verhandle);
793 if (!infosize)
795 TRACE("%s has no fileversioninfo.\n", fn);
796 return 18;
798 infobuf = HeapAlloc(GetProcessHeap(), 0, infosize);
799 if (GetFileVersionInfoA(fn, verhandle, infosize, infobuf))
801 char vbuf[200];
802 /* Yes, two space behind : */
803 /* FIXME: test for buflen */
804 sprintf(vbuf, "Version: %d.%d.%d.%d\n",
805 ((WORD*)infobuf)[0x0f],
806 ((WORD*)infobuf)[0x0e],
807 ((WORD*)infobuf)[0x11],
808 ((WORD*)infobuf)[0x10]
810 TRACE("version of %s is %s\n", fn, vbuf);
811 strncpy(buf2, vbuf, buf2len);
813 else
815 TRACE("GetFileVersionInfoA failed for %s.\n", fn);
816 strncpy(buf2, fn, buf2len); /* msvideo.dll appears to copy fn*/
818 /* FIXME: language problem? */
819 if (VerQueryValueA( infobuf,
820 "\\StringFileInfo\\040904E4\\FileDescription",
821 &subblock,
822 &subblocklen
825 TRACE("VQA returned %s\n", (LPCSTR)subblock);
826 strncpy(buf1, subblock, buf1len);
828 else
830 TRACE("VQA did not return on query \\StringFileInfo\\040904E4\\FileDescription?\n");
831 strncpy(buf1, fn, buf1len); /* msvideo.dll appears to copy fn*/
833 HeapFree(GetProcessHeap(), 0, infobuf);
834 return 0;
837 /******************************************************************
838 * IC_CallTo16
842 static LRESULT CALLBACK IC_CallTo16(HDRVR hdrv, HIC hic, UINT msg, LPARAM lp1, LPARAM lp2)
844 #if 0
845 WINE_HIC* whic = IC_GetPtr(hic);
846 LRESULT ret = 0;
849 if (whic->driverproc)
851 ret = whic->driverproc(hic, whic->hdrv, msg, lParam1, lParam2);
853 else
855 ret = SendDriverMessage(whic->hdrv, msg, lParam1, lParam2);
857 #else
858 FIXME("No 32=>16 conversion yet\n");
859 #endif
860 return 0;
863 /**************************************************************************
864 * DllEntryPoint (MSVIDEO.300)
866 * MSVIDEO DLL entry point
869 BOOL WINAPI VIDEO_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
870 WORD wHeapSize, DWORD dwReserved1, WORD wReserved2)
872 switch (fdwReason)
874 case DLL_PROCESS_ATTACH:
875 /* hook in our 16 bit management functions */
876 pFnCallTo16 = IC_CallTo16;
877 break;
878 case DLL_PROCESS_DETACH:
879 /* remove our 16 bit management functions */
880 pFnCallTo16 = NULL;
881 break;
882 case DLL_THREAD_ATTACH:
883 case DLL_THREAD_DETACH:
884 break;
886 return TRUE;