| 1 | /* $Id: avifile.cpp,v 1.3 1999-10-03 20:20:57 sandervl Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright 1999 Marcus Meissner
|
|---|
| 4 | */
|
|---|
| 5 | #include <string.h>
|
|---|
| 6 | #include <stdio.h>
|
|---|
| 7 | #include <assert.h>
|
|---|
| 8 |
|
|---|
| 9 | #include <os2win.h>
|
|---|
| 10 | #define CINTERFACE
|
|---|
| 11 | #define ICOM_CINTERFACE 1
|
|---|
| 12 | #define INITGUID
|
|---|
| 13 |
|
|---|
| 14 | #include "winbase.h"
|
|---|
| 15 | #include "vfw.h"
|
|---|
| 16 | #include "wine/winestring.h"
|
|---|
| 17 | #include "driver.h"
|
|---|
| 18 | #include "mmsystem.h"
|
|---|
| 19 | #include "winerror.h"
|
|---|
| 20 | #include "debugstr.h"
|
|---|
| 21 | #include "debugtools.h"
|
|---|
| 22 |
|
|---|
| 23 | #include <misc.h>
|
|---|
| 24 |
|
|---|
| 25 | DECLARE_DEBUG_CHANNEL(avifile)
|
|---|
| 26 | DECLARE_DEBUG_CHANNEL(msvideo)
|
|---|
| 27 | DECLARE_DEBUG_CHANNEL(relay)
|
|---|
| 28 |
|
|---|
| 29 | static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj);
|
|---|
| 30 | static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface);
|
|---|
| 31 | static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface);
|
|---|
| 32 | static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size);
|
|---|
| 33 | static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam);
|
|---|
| 34 | static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi);
|
|---|
| 35 | static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size);
|
|---|
| 36 | static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size);
|
|---|
| 37 | static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface);
|
|---|
| 38 | static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam);
|
|---|
| 39 |
|
|---|
| 40 | struct ICOM_VTABLE(IAVIFile) iavift = {
|
|---|
| 41 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 42 | IAVIFile_fnQueryInterface,
|
|---|
| 43 | IAVIFile_fnAddRef,
|
|---|
| 44 | IAVIFile_fnRelease,
|
|---|
| 45 | IAVIFile_fnInfo,
|
|---|
| 46 | IAVIFile_fnGetStream,
|
|---|
| 47 | IAVIFile_fnCreateStream,
|
|---|
| 48 | IAVIFile_fnWriteData,
|
|---|
| 49 | IAVIFile_fnReadData,
|
|---|
| 50 | IAVIFile_fnEndRecord,
|
|---|
| 51 | IAVIFile_fnDeleteStream
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj);
|
|---|
| 55 | static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface);
|
|---|
| 56 | static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface);
|
|---|
| 57 | static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2);
|
|---|
| 58 | static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size);
|
|---|
| 59 | static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags);
|
|---|
| 60 | static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize);
|
|---|
| 61 | static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize);
|
|---|
| 62 | static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread);
|
|---|
| 63 | static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten);
|
|---|
| 64 | static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples);
|
|---|
| 65 | static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread);
|
|---|
| 66 | static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size);
|
|---|
| 67 | static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen);
|
|---|
| 68 |
|
|---|
| 69 | struct ICOM_VTABLE(IAVIStream) iavist = {
|
|---|
| 70 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 71 | IAVIStream_fnQueryInterface,
|
|---|
| 72 | IAVIStream_fnAddRef,
|
|---|
| 73 | IAVIStream_fnRelease,
|
|---|
| 74 | IAVIStream_fnCreate,
|
|---|
| 75 | IAVIStream_fnInfo,
|
|---|
| 76 | IAVIStream_fnFindSample,
|
|---|
| 77 | IAVIStream_fnReadFormat,
|
|---|
| 78 | IAVIStream_fnSetFormat,
|
|---|
| 79 | IAVIStream_fnRead,
|
|---|
| 80 | IAVIStream_fnWrite,
|
|---|
| 81 | IAVIStream_fnDelete,
|
|---|
| 82 | IAVIStream_fnReadData,
|
|---|
| 83 | IAVIStream_fnWriteData,
|
|---|
| 84 | IAVIStream_fnSetInfo
|
|---|
| 85 | };
|
|---|
| 86 |
|
|---|
| 87 | typedef struct IAVIStreamImpl {
|
|---|
| 88 | /* IUnknown stuff */
|
|---|
| 89 | ICOM_VTABLE(IAVIStream)* lpvtbl;
|
|---|
| 90 | DWORD ref;
|
|---|
| 91 | /* IAVIStream stuff */
|
|---|
| 92 | LPVOID lpInputFormat;
|
|---|
| 93 | DWORD inputformatsize;
|
|---|
| 94 | BOOL iscompressing;
|
|---|
| 95 | DWORD curframe;
|
|---|
| 96 |
|
|---|
| 97 | /* Compressor stuff */
|
|---|
| 98 | HIC hic;
|
|---|
| 99 | LPVOID lpCompressFormat;
|
|---|
| 100 | ICINFO icinfo;
|
|---|
| 101 | DWORD compbufsize;
|
|---|
| 102 | LPVOID compbuffer;
|
|---|
| 103 |
|
|---|
| 104 | DWORD decompbufsize;
|
|---|
| 105 | LPVOID decompbuffer;
|
|---|
| 106 | LPVOID decompformat;
|
|---|
| 107 | AVICOMPRESSOPTIONS aco;
|
|---|
| 108 |
|
|---|
| 109 | LPVOID lpPrev; /* pointer to decompressed frame later */
|
|---|
| 110 | LPVOID lpPrevFormat; /* pointer to decompressed info later */
|
|---|
| 111 | } IAVIStreamImpl;
|
|---|
| 112 |
|
|---|
| 113 | void WINAPI
|
|---|
| 114 | AVIFileInit(void) {
|
|---|
| 115 | FIXME_(avifile)("(),stub!\n");
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | typedef struct IAVIFileImpl {
|
|---|
| 119 | /* IUnknown stuff */
|
|---|
| 120 | ICOM_VTABLE(IAVIFile)* lpvtbl;
|
|---|
| 121 | DWORD ref;
|
|---|
| 122 | /* IAVIFile stuff... */
|
|---|
| 123 | } IAVIFileImpl;
|
|---|
| 124 |
|
|---|
| 125 | static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj) {
|
|---|
| 126 | ICOM_THIS(IAVIFileImpl,iface);
|
|---|
| 127 | char xrefiid[50];
|
|---|
| 128 |
|
|---|
| 129 | WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
|
|---|
| 130 | TRACE_(relay)("(%p)->QueryInterface(%s,%p)\n",This,xrefiid,obj);
|
|---|
| 131 | if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
|
|---|
| 132 | !memcmp(&IID_IAVIFile,refiid,sizeof(IID_IAVIFile))
|
|---|
| 133 | ) {
|
|---|
| 134 | *obj = iface;
|
|---|
| 135 | return S_OK;
|
|---|
| 136 | }
|
|---|
| 137 | return OLE_E_ENUM_NOMORE;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface) {
|
|---|
| 141 | ICOM_THIS(IAVIFileImpl,iface);
|
|---|
| 142 |
|
|---|
| 143 | FIXME_(relay)("(%p)->AddRef()\n",iface);
|
|---|
| 144 | return ++(This->ref);
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface) {
|
|---|
| 148 | ICOM_THIS(IAVIFileImpl,iface);
|
|---|
| 149 |
|
|---|
| 150 | FIXME_(relay)("(%p)->Release()\n",iface);
|
|---|
| 151 | if (!--(This->ref)) {
|
|---|
| 152 | HeapFree(GetProcessHeap(),0,iface);
|
|---|
| 153 | return 0;
|
|---|
| 154 | }
|
|---|
| 155 | return This->ref;
|
|---|
| 156 | }
|
|---|
| 157 |
|
|---|
| 158 | static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size) {
|
|---|
| 159 | FIXME_(avifile)("(%p)->Info(%p,%ld)\n",iface,afi,size);
|
|---|
| 160 |
|
|---|
| 161 | /* FIXME: fill out struct? */
|
|---|
| 162 | return E_FAIL;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
|
|---|
| 166 | FIXME_(avifile)("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam);
|
|---|
| 167 | /* FIXME: create interface etc. */
|
|---|
| 168 | return E_FAIL;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
|
|---|
| 172 | ICOM_THIS(IAVIStreamImpl,iface);
|
|---|
| 173 | char fcc[5];
|
|---|
| 174 | IAVIStreamImpl *istream;
|
|---|
| 175 |
|
|---|
| 176 | FIXME_(avifile)("(%p,%p,%p)\n",This,avis,asi);
|
|---|
| 177 | istream = (IAVIStreamImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIStreamImpl));
|
|---|
| 178 | istream->ref = 1;
|
|---|
| 179 | istream->lpvtbl = &iavist;
|
|---|
| 180 | fcc[4]='\0';
|
|---|
| 181 | memcpy(fcc,(char*)&(asi->fccType),4);
|
|---|
| 182 | FIXME_(avifile)("\tfccType '%s'\n",fcc);
|
|---|
| 183 | memcpy(fcc,(char*)&(asi->fccHandler),4);
|
|---|
| 184 | FIXME_(avifile)("\tfccHandler '%s'\n",fcc);
|
|---|
| 185 | FIXME_(avifile)("\tdwFlags 0x%08lx\n",asi->dwFlags);
|
|---|
| 186 | FIXME_(avifile)("\tdwCaps 0x%08lx\n",asi->dwCaps);
|
|---|
| 187 | FIXME_(avifile)("\tname '%s'\n",debugstr_w(asi->szName));
|
|---|
| 188 |
|
|---|
| 189 | istream->curframe = 0;
|
|---|
| 190 | *avis = (PAVISTREAM)istream;
|
|---|
| 191 | return S_OK;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size) {
|
|---|
| 195 | FIXME_(avifile)("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,ckid,lpData,size);
|
|---|
| 196 | /* FIXME: write data to file */
|
|---|
| 197 | return E_FAIL;
|
|---|
| 198 | }
|
|---|
| 199 |
|
|---|
| 200 | static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size) {
|
|---|
| 201 | FIXME_(avifile)("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,ckid,lpData,size);
|
|---|
| 202 | /* FIXME: read at most size bytes from file */
|
|---|
| 203 | return E_FAIL;
|
|---|
| 204 | }
|
|---|
| 205 |
|
|---|
| 206 | static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface) {
|
|---|
| 207 | FIXME_(avifile)("(%p)->EndRecord()\n",iface);
|
|---|
| 208 | /* FIXME: end record? */
|
|---|
| 209 | return E_FAIL;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam) {
|
|---|
| 213 | FIXME_(avifile)("(%p)->DeleteStream(0x%08lx,%ld)\n",iface,fccType,lParam);
|
|---|
| 214 | /* FIXME: delete stream? */
|
|---|
| 215 | return E_FAIL;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | HRESULT WINAPI AVIFileOpenA(
|
|---|
| 219 | PAVIFILE * ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler
|
|---|
| 220 | ) {
|
|---|
| 221 | char buf[80];
|
|---|
| 222 | IAVIFileImpl *iavi;
|
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 | if (HIWORD(lpHandler))
|
|---|
| 226 | WINE_StringFromCLSID(lpHandler,buf);
|
|---|
| 227 | else
|
|---|
| 228 | sprintf(buf,"<clsid-0x%04lx>",(DWORD)lpHandler);
|
|---|
| 229 |
|
|---|
| 230 | FIXME_(avifile)("(%p,%s,0x%08lx,%s),stub!\n",ppfile,szFile,(DWORD)uMode,buf);
|
|---|
| 231 | iavi = (IAVIFileImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIFileImpl));
|
|---|
| 232 | iavi->ref = 1;
|
|---|
| 233 | iavi->lpvtbl = &iavift;
|
|---|
| 234 | *ppfile = (PAVIFILE)iavi;
|
|---|
| 235 | return S_OK;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj) {
|
|---|
| 239 | ICOM_THIS(IAVIStreamImpl,iface);
|
|---|
| 240 | char xrefiid[50];
|
|---|
| 241 |
|
|---|
| 242 | WINE_StringFromCLSID((LPCLSID)refiid,xrefiid);
|
|---|
| 243 | TRACE_(relay)("(%p)->QueryInterface(%s,%p)\n",This,xrefiid,obj);
|
|---|
| 244 | if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
|
|---|
| 245 | !memcmp(&IID_IAVIStream,refiid,sizeof(IID_IAVIStream))
|
|---|
| 246 | ) {
|
|---|
| 247 | *obj = This;
|
|---|
| 248 | return S_OK;
|
|---|
| 249 | }
|
|---|
| 250 | /* can return IGetFrame interface too */
|
|---|
| 251 | return OLE_E_ENUM_NOMORE;
|
|---|
| 252 | }
|
|---|
| 253 |
|
|---|
| 254 | static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface) {
|
|---|
| 255 | ICOM_THIS(IAVIStreamImpl,iface);
|
|---|
| 256 |
|
|---|
| 257 | FIXME_(relay)("(%p)->AddRef()\n",iface);
|
|---|
| 258 | return ++(This->ref);
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) {
|
|---|
| 262 | ICOM_THIS(IAVIStreamImpl,iface);
|
|---|
| 263 |
|
|---|
| 264 | FIXME_(relay)("(%p)->Release()\n",iface);
|
|---|
| 265 | if (!--(This->ref)) {
|
|---|
| 266 | HeapFree(GetProcessHeap(),0,This);
|
|---|
| 267 | return 0;
|
|---|
| 268 | }
|
|---|
| 269 | return This->ref;
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2) {
|
|---|
| 273 | FIXME_(avifile)("(%p)->Create(0x%08lx,0x%08lx)\n",iface,lParam1,lParam2);
|
|---|
| 274 | return E_FAIL;
|
|---|
| 275 | }
|
|---|
| 276 |
|
|---|
| 277 | static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size) {
|
|---|
| 278 | FIXME_(avifile)("(%p)->Info(%p,%ld)\n",iface,psi,size);
|
|---|
| 279 | return E_FAIL;
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags) {
|
|---|
| 283 | FIXME_(avifile)("(%p)->FindSample(%ld,0x%08lx)\n",iface,pos,flags);
|
|---|
| 284 | return E_FAIL;
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 | static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize) {
|
|---|
| 288 | FIXME_(avifile)("(%p)->ReadFormat(%ld,%p,%p)\n",iface,pos,format,formatsize);
|
|---|
| 289 | return E_FAIL;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | /*****************************************************************************
|
|---|
| 293 | * [IAVIStream::SetFormat]
|
|---|
| 294 | */
|
|---|
| 295 | static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize) {
|
|---|
| 296 | IAVIStreamImpl *as = (IAVIStreamImpl*)iface;
|
|---|
| 297 |
|
|---|
| 298 | FIXME_(avifile)("(%p)->SetFormat(%ld,%p,%ld)\n",iface,pos,format,formatsize);
|
|---|
| 299 | if (as->lpInputFormat) HeapFree(GetProcessHeap(),0,as->lpInputFormat);
|
|---|
| 300 | as->inputformatsize = formatsize;
|
|---|
| 301 | as->lpInputFormat = HeapAlloc(GetProcessHeap(),0,formatsize);
|
|---|
| 302 | memcpy(as->lpInputFormat,format,formatsize);
|
|---|
| 303 | if (as->iscompressing) {
|
|---|
| 304 | int xsize;
|
|---|
| 305 | /* Set up the Compressor part */
|
|---|
| 306 | xsize = ICCompressGetFormatSize(as->hic,as->lpInputFormat);
|
|---|
| 307 | as->lpCompressFormat = HeapAlloc(GetProcessHeap(),0,xsize);
|
|---|
| 308 | ICCompressGetFormat(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
|---|
| 309 | ICCompressBegin(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
|---|
| 310 | as->compbufsize = ICCompressGetSize(as->hic,as->lpInputFormat,as->lpCompressFormat);
|
|---|
| 311 | as->compbuffer = HeapAlloc(GetProcessHeap(),0,as->compbufsize);
|
|---|
| 312 |
|
|---|
| 313 | /* Set up the Decompressor part (for prev frames?) */
|
|---|
| 314 | xsize=ICDecompressGetFormatSize(as->hic,as->lpCompressFormat);
|
|---|
| 315 | as->decompformat = HeapAlloc(GetProcessHeap(),0,xsize);
|
|---|
| 316 | ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
|
|---|
| 317 | as->decompbufsize=((LPBITMAPINFOHEADER)as->decompbuffer)->biSizeImage;
|
|---|
| 318 | as->decompbuffer = HeapReAlloc(GetProcessHeap(),0,as->decompbuffer,as->decompbufsize);
|
|---|
| 319 | memset(as->decompbuffer,0xff,as->decompbufsize);
|
|---|
| 320 | assert(HeapValidate(GetProcessHeap(),0,NULL));
|
|---|
| 321 |
|
|---|
| 322 | ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat);
|
|---|
| 323 | ICDecompressBegin(as->hic,as->lpCompressFormat,as->decompformat);
|
|---|
| 324 | as->lpPrev = as->lpPrevFormat = NULL;
|
|---|
| 325 | }
|
|---|
| 326 | return S_OK;
|
|---|
| 327 | }
|
|---|
| 328 |
|
|---|
| 329 | static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
|
|---|
| 330 | FIXME_(avifile)("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",iface,start,samples,buffer,buffersize,bytesread,samplesread);
|
|---|
| 331 | return E_FAIL;
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 | static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
|
|---|
| 335 | IAVIStreamImpl *as = (IAVIStreamImpl*)iface;
|
|---|
| 336 | DWORD ckid,xflags;
|
|---|
| 337 |
|
|---|
| 338 | FIXME_(avifile)("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
|
|---|
| 339 |
|
|---|
| 340 | ICCompress(
|
|---|
| 341 | as->hic,flags,
|
|---|
| 342 | (LPBITMAPINFOHEADER)as->lpCompressFormat,
|
|---|
| 343 | as->compbuffer,
|
|---|
| 344 | (LPBITMAPINFOHEADER)as->lpInputFormat,
|
|---|
| 345 | buffer,
|
|---|
| 346 | &ckid,&xflags,
|
|---|
| 347 | as->curframe,0xffffff/*framesize*/,as->aco.dwQuality,
|
|---|
| 348 | (LPBITMAPINFOHEADER)as->lpPrevFormat,as->lpPrev
|
|---|
| 349 | );
|
|---|
| 350 | ICDecompress(
|
|---|
| 351 | as->hic,
|
|---|
| 352 | flags, /* FIXME: check */
|
|---|
| 353 | (LPBITMAPINFOHEADER)as->lpCompressFormat,
|
|---|
| 354 | as->compbuffer,
|
|---|
| 355 | (LPBITMAPINFOHEADER)as->decompformat,
|
|---|
| 356 | as->decompbuffer
|
|---|
| 357 | );
|
|---|
| 358 | /* We now have a prev format for the next compress ... */
|
|---|
| 359 | as->lpPrevFormat = as->decompformat;
|
|---|
| 360 | as->lpPrev = as->decompbuffer;
|
|---|
| 361 | return S_OK;
|
|---|
| 362 | }
|
|---|
| 363 |
|
|---|
| 364 | static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples) {
|
|---|
| 365 | FIXME_(avifile)("(%p)->Delete(%ld,%ld)\n",iface,start,samples);
|
|---|
| 366 | return E_FAIL;
|
|---|
| 367 | }
|
|---|
| 368 | static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread) {
|
|---|
| 369 | FIXME_(avifile)("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,fcc,lp,lpread);
|
|---|
| 370 | return E_FAIL;
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size) {
|
|---|
| 374 | FIXME_(avifile)("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,fcc,lp,size);
|
|---|
| 375 | return E_FAIL;
|
|---|
| 376 | }
|
|---|
| 377 |
|
|---|
| 378 | static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen) {
|
|---|
| 379 | FIXME_(avifile)("(%p)->SetInfo(%p,%ld)\n",iface,info,infolen);
|
|---|
| 380 | return E_FAIL;
|
|---|
| 381 | }
|
|---|
| 382 |
|
|---|
| 383 | HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE iface,PAVISTREAM *ppavi,AVISTREAMINFOA * psi) {
|
|---|
| 384 | AVISTREAMINFOW psiw;
|
|---|
| 385 |
|
|---|
| 386 | /* Only the szName at the end is different */
|
|---|
| 387 | memcpy(&psiw,psi,sizeof(*psi)-sizeof(psi->szName));
|
|---|
| 388 | lstrcpynAtoW(psiw.szName,psi->szName,sizeof(psi->szName));
|
|---|
| 389 | return iface->lpvtbl->fnCreateStream(iface,ppavi,&psiw);
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | HRESULT WINAPI AVIFileCreateStreamW(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) {
|
|---|
| 393 | return iface->lpvtbl->fnCreateStream(iface,avis,asi);
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 | HRESULT WINAPI AVIFileGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) {
|
|---|
| 398 | return iface->lpvtbl->fnGetStream(iface,avis,fccType,lParam);
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | HRESULT WINAPI AVIFileInfoA(PAVIFILE iface,LPAVIFILEINFOA afi,LONG size) {
|
|---|
| 402 | AVIFILEINFOW afiw;
|
|---|
| 403 | HRESULT hres;
|
|---|
| 404 |
|
|---|
| 405 | if (size < sizeof(AVIFILEINFOA))
|
|---|
| 406 | return AVIERR_BADSIZE;
|
|---|
| 407 | hres = iface->lpvtbl->fnInfo(iface,&afiw,sizeof(afiw));
|
|---|
| 408 | memcpy(afi,&afiw,sizeof(*afi)-sizeof(afi->szFileType));
|
|---|
| 409 | lstrcpynWtoA(afi->szFileType,afiw.szFileType,sizeof(afi->szFileType));
|
|---|
| 410 | return hres;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | HRESULT WINAPI AVIStreamInfoW(PAVISTREAM iface,AVISTREAMINFOW *asi,LONG
|
|---|
| 414 | size) {
|
|---|
| 415 | return iface->lpvtbl->fnInfo(iface,asi,size);
|
|---|
| 416 | }
|
|---|
| 417 |
|
|---|
| 418 | HRESULT WINAPI AVIStreamInfoA(PAVISTREAM iface,AVISTREAMINFOA *asi,LONG
|
|---|
| 419 | size) {
|
|---|
| 420 | AVISTREAMINFOW asiw;
|
|---|
| 421 | HRESULT hres;
|
|---|
| 422 |
|
|---|
| 423 | if (size<sizeof(AVISTREAMINFOA))
|
|---|
| 424 | return AVIERR_BADSIZE;
|
|---|
| 425 | hres = iface->lpvtbl->fnInfo(iface,&asiw,sizeof(asiw));
|
|---|
| 426 | memcpy(asi,&asiw,sizeof(asiw)-sizeof(asiw.szName));
|
|---|
| 427 | lstrcpynWtoA(asi->szName,asiw.szName,sizeof(asi->szName));
|
|---|
| 428 | return hres;
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | HRESULT WINAPI AVIFileInfoW(PAVIFILE iface,LPAVIFILEINFOW afi,LONG size) {
|
|---|
| 432 | return iface->lpvtbl->fnInfo(iface,afi,size);
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler) {
|
|---|
| 436 | char fcc[5];
|
|---|
| 437 | IAVIStreamImpl *as;
|
|---|
| 438 | FIXME_(avifile)("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler);
|
|---|
| 439 | fcc[4]='\0';
|
|---|
| 440 | memcpy(fcc,&(aco->fccType),4);
|
|---|
| 441 | FIXME_(avifile)("\tfccType: '%s'\n",fcc);
|
|---|
| 442 | memcpy(fcc,&(aco->fccHandler),4);
|
|---|
| 443 | FIXME_(avifile)("\tfccHandler: '%s'\n",fcc);
|
|---|
| 444 | FIXME_(avifile)("\tdwFlags: 0x%08lx\n",aco->dwFlags);
|
|---|
| 445 |
|
|---|
| 446 | /* we just create a duplicate for now */
|
|---|
| 447 | ((IUnknown*)ppsSource)->lpvtbl->fnAddRef((IUnknown*)ppsSource);
|
|---|
| 448 | *ppsCompressed = ppsSource;
|
|---|
| 449 | as = (IAVIStreamImpl*)ppsSource;
|
|---|
| 450 |
|
|---|
| 451 | /* this is where the fun begins. Open a compressor and prepare it. */
|
|---|
| 452 | as->hic = ICOpen(aco->fccType,aco->fccHandler,ICMODE_COMPRESS);
|
|---|
| 453 |
|
|---|
| 454 | /* May happen. for instance if the codec is not able to compress */
|
|---|
| 455 | if (!as->hic)
|
|---|
| 456 | return AVIERR_UNSUPPORTED;
|
|---|
| 457 |
|
|---|
| 458 | ICGetInfo(as->hic,&(as->icinfo),sizeof(ICINFO));
|
|---|
| 459 | FIXME_(avifile)("Opened compressor: '%s' '%s'\n",debugstr_w(as->icinfo.szName),debugstr_w(as->icinfo.szDescription));
|
|---|
| 460 | as->iscompressing = TRUE;
|
|---|
| 461 | memcpy(&(as->aco),aco,sizeof(*aco));
|
|---|
| 462 | if (as->icinfo.dwFlags & VIDCF_COMPRESSFRAMES) {
|
|---|
| 463 | ICCOMPRESSFRAMES icf;
|
|---|
| 464 |
|
|---|
| 465 | /* now what to fill in there ... Hmm */
|
|---|
| 466 | memset(&icf,0,sizeof(icf));
|
|---|
| 467 | icf.lDataRate = aco->dwBytesPerSecond;
|
|---|
| 468 | icf.lQuality = aco->dwQuality;
|
|---|
| 469 | icf.lKeyRate = aco->dwKeyFrameEvery;
|
|---|
| 470 |
|
|---|
| 471 | icf.GetData = (LONG (_stdcall *)(LPARAM,LONG,LPVOID,LONG)) 0xdead4242;
|
|---|
| 472 | icf.PutData = (LONG (_stdcall *)(LPARAM,LONG,LPVOID,LONG)) 0xdead4243;
|
|---|
| 473 | ICSendMessage(as->hic,ICM_COMPRESS_FRAMES_INFO,(LPARAM)&icf,sizeof(icf));
|
|---|
| 474 | }
|
|---|
| 475 | return S_OK;
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG formatsize) {
|
|---|
| 479 | return iface->lpvtbl->fnSetFormat(iface,pos,format,formatsize);
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG *formatsize) {
|
|---|
| 483 | return iface->lpvtbl->fnReadFormat(iface,pos,format,formatsize);
|
|---|
| 484 | }
|
|---|
| 485 |
|
|---|
| 486 | HRESULT WINAPI AVIStreamWrite(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) {
|
|---|
| 487 | return iface->lpvtbl->fnWrite(iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten);
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | HRESULT WINAPI AVIStreamRead(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) {
|
|---|
| 491 | return iface->lpvtbl->fnRead(iface,start,samples,buffer,buffersize,bytesread,samplesread);
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| 494 | HRESULT WINAPI AVIStreamWriteData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG size) {
|
|---|
| 495 | return iface->lpvtbl->fnWriteData(iface,fcc,lp,size);
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | HRESULT WINAPI AVIStreamReadData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG *lpread) {
|
|---|
| 499 | return iface->lpvtbl->fnReadData(iface,fcc,lp,lpread);
|
|---|
| 500 | }
|
|---|
| 501 |
|
|---|
| 502 | LONG WINAPI AVIStreamStart(PAVISTREAM iface) {
|
|---|
| 503 | AVISTREAMINFOW si;
|
|---|
| 504 |
|
|---|
| 505 | iface->lpvtbl->fnInfo(iface,&si,sizeof(si));
|
|---|
| 506 | return si.dwStart;
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | LONG WINAPI AVIStreamLength(PAVISTREAM iface) {
|
|---|
| 510 | AVISTREAMINFOW si;
|
|---|
| 511 | HRESULT ret;
|
|---|
| 512 |
|
|---|
| 513 | ret = iface->lpvtbl->fnInfo(iface,&si,sizeof(si));
|
|---|
| 514 | if (ret) /* error */
|
|---|
| 515 | return 1;
|
|---|
| 516 | return si.dwLength;
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | ULONG WINAPI AVIStreamRelease(PAVISTREAM iface) {
|
|---|
| 520 | return ((LPUNKNOWN)iface)->lpvtbl->fnRelease((LPUNKNOWN)iface);
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM iface,LPBITMAPINFOHEADER bmi) {
|
|---|
| 524 | FIXME_(msvideo)("(%p)->(%p),stub!\n",iface,bmi);
|
|---|
| 525 | return NULL;
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pg,LONG pos) {
|
|---|
| 529 | return pg->lpvtbl->fnGetFrame(pg,pos);
|
|---|
| 530 | }
|
|---|
| 531 |
|
|---|
| 532 | HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pg) {
|
|---|
| 533 | if (pg) ((LPUNKNOWN)pg)->lpvtbl->fnRelease((LPUNKNOWN)pg);
|
|---|
| 534 | return 0;
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | ULONG WINAPI AVIFileRelease(PAVIFILE iface) {
|
|---|
| 538 | return ((LPUNKNOWN)iface)->lpvtbl->fnRelease((LPUNKNOWN)iface);
|
|---|
| 539 | }
|
|---|
| 540 |
|
|---|
| 541 | void WINAPI AVIFileExit(void) {
|
|---|
| 542 | FIXME_(avifile)("(), stub.\n");
|
|---|
| 543 | }
|
|---|