3 #include <wine/driver.h>
4 #include <wine/pe_image.h>
5 #include <wine/winreg.h>
28 #define WIN32_PATH GST_WIN32_LIBDIR
31 UINT uDriverSignature;
32 HINSTANCE hDriverModule;
33 DRIVERPROC DriverProc;
41 static DWORD dwDrvID = 0;
43 LRESULT WINAPI SendDriverMessage( HDRVR hDriver, UINT message,
44 LPARAM lParam1, LPARAM lParam2 )
46 DRVR* module=(DRVR*)hDriver;
49 printf("SendDriverMessage: driver %X, message %X, arg1 %X, arg2 %X\n", hDriver, message, lParam1, lParam2);
51 if(module==0)return -1;
52 if(module->hDriverModule==0)return -1;
53 if(module->DriverProc==0)return -1;
55 result=module->DriverProc(module->dwDriverID,1,message,lParam1,lParam2);
58 printf("\t\tResult: %X\n", result);
63 static NPDRVR DrvAlloc(HDRVR*lpDriver, LPUINT lpDrvResult)
66 /* allocate and lock handle */
69 if (*lpDriver = (HDRVR) malloc(sizeof(DRVR)) )
71 if (npDriver = (NPDRVR) *lpDriver)
73 *lpDrvResult = MMSYSERR_NOERROR;
76 free((NPDRVR)*lpDriver);
78 return (*lpDrvResult = MMSYSERR_NOMEM, (NPDRVR) 0);
80 return (*lpDrvResult = MMSYSERR_INVALPARAM, (NPDRVR) 0);
90 static codec_t avi_codecs[]={
91 {0, WIN32_PATH"/divxc32.dll", 0}, //0
92 {0, WIN32_PATH"/ir50_32.dll", 0},
93 {0, WIN32_PATH"/ir41_32.dll", 0},
94 {0, WIN32_PATH"/ir32_32.dll", 0},
95 {0, WIN32_PATH"/mpg4c32.dll", 0},
96 {0, WIN32_PATH"/iccvid.dll", 0}, //5
97 {0, WIN32_PATH"/libvideodll.so", 0},
98 {0, WIN32_PATH"/divxa32.acm", 0},
99 {0, WIN32_PATH"/msadp32.acm", 0},
100 {0, WIN32_PATH"/ativcr1.dll", 0},
101 {0, WIN32_PATH"/ativcr2.dll", 0}, //10
102 {0, WIN32_PATH"/i263_32.drv", 0},
103 {0, WIN32_PATH"/l3codeca.acm", 0},
104 // {0, WIN32_PATH"/atiyvu9.dll", 0},
108 static void DrvFree(HDRVR hDriver)
112 if(((DRVR*)hDriver)->hDriverModule)
113 if(((DRVR*)hDriver)->DriverProc)
114 (((DRVR*)hDriver)->DriverProc)(((DRVR*)hDriver)->dwDriverID, hDriver, DRV_CLOSE, 0, 0);
116 for(i=0; i<sizeof(avi_codecs)/sizeof(avi_codecs[0]); i++)
117 if(avi_codecs[i].handle==((DRVR*)hDriver)->hDriverModule)
119 avi_codecs[i].usage--;
120 if(avi_codecs[i].usage==0)
122 avi_codecs[i].handle=0;
123 if(((DRVR*)hDriver)->hDriverModule)
124 if(((DRVR*)hDriver)->DriverProc)
125 (((DRVR*)hDriver)->DriverProc)(0, hDriver, DRV_FREE, 0, 0);
126 FreeLibrary(((DRVR*)hDriver)->hDriverModule);
128 free((NPDRVR)hDriver);
134 void DrvClose(HDRVR hdrvr)
140 //DrvOpen(LPCSTR lpszDriverName, LPCSTR lpszSectionName, LPARAM lParam2)
141 DrvOpen(LPARAM lParam2)
144 char filename[MAX_PATH], *f;
153 int fccHandler=*((int*)lParam2+2);
154 int fccType=*((int*)lParam2+1);
155 if(fccType==0x63646976)//vidc
158 case mmioFOURCC('D', 'I', 'V', '3'):
159 case mmioFOURCC('D', 'I', 'V', '4'):
160 case mmioFOURCC('d', 'i', 'v', '3'):
161 case mmioFOURCC('d', 'i', 'v', '4'):
162 case mmioFOURCC('M', 'P', '4', '1'):
163 case mmioFOURCC('M', 'P', '4', '2'):
164 case mmioFOURCC('M', 'P', '4', '3'):
165 printf("Video in DivX ;-) format\n");
168 case mmioFOURCC('I', 'V', '5', '0'):
169 case mmioFOURCC('i', 'v', '5', '0'):
170 printf("Video in Indeo Video 5 format\n");
173 case mmioFOURCC('I', 'V', '4', '1'):
174 case mmioFOURCC('i', 'v', '4', '1'):
175 printf("Video in Indeo Video 4.1 format\n");
178 case mmioFOURCC('I', 'V', '3', '2'):
179 case mmioFOURCC('i', 'v', '3', '2'):
180 printf("Video in Indeo Video 3.2 format\n");
184 case mmioFOURCC('m', 'p', '4', '1'):
185 case mmioFOURCC('m', 'p', '4', '2'):
186 case mmioFOURCC('m', 'p', '4', '3'):
187 case mmioFOURCC('M', 'P', 'G', '4'):
188 printf("Video in Microsoft MPEG-4 format\n");
191 case mmioFOURCC('c', 'v', 'i', 'd'):
192 printf("Video in Cinepak format\n");
195 case mmioFOURCC('V', 'C', 'R', '1'):
198 case mmioFOURCC('V', 'C', 'R', '2'):
201 case mmioFOURCC('i', '2', '6', '3'):
202 case mmioFOURCC('I', '2', '6', '3'):
205 // case mmioFOURCC('Y', 'V', 'U', '9'):
209 printf("Unknown codec %X='%c%c%c%c'\n", fccHandler,
210 fccHandler&0xFF, (fccHandler&0xFF00)>>8,
211 (fccHandler&0xFF0000)>>16, (fccHandler&0xFF000000)>>24);
217 case 0x160://DivX audio
218 case 0x161://DivX audio
224 case 0x55://MPEG Layer 3
225 printf("MPEG Layer 3 ( 0x55 )\n");
229 printf("Unknown ACM codec 0x%X\n", fccHandler);
233 if (!(npDriver = DrvAlloc(&hDriver, &uDrvResult)))
236 if(avi_codecs[drv_id].handle==0)
238 if (!(avi_codecs[drv_id].handle=npDriver->hDriverModule = LoadLibraryA(avi_codecs[drv_id].name)))
240 printf("Can't open library %s\n", avi_codecs[drv_id].name);
244 else avi_codecs[drv_id].usage=1;
248 npDriver->hDriverModule=avi_codecs[drv_id].handle;
249 avi_codecs[drv_id].usage++;
258 if(RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\LinuxLoader\\Divx", 0, 0, &newkey)!=0)
260 if(RegQueryValueExA(newkey, "BitRate", 0, 0, &bitrate, &count)!=0)
265 // printf("Setting default bitrate from %f to %d\n",
266 // *(double*)((char*)npDriver->hDriverModule+0x14c0), bitrate);
268 *(double*)((char*)npDriver->hDriverModule+0x14c0)=bitrate;
274 if (!(npDriver->DriverProc = (DRIVERPROC)
275 GetProcAddress(npDriver->hDriverModule, "DriverProc")))
277 printf("Library %s is not a valid codec\n", avi_codecs[drv_id].name);
278 FreeLibrary(npDriver->hDriverModule);
283 TRACE("DriverProc == %X\n", npDriver->DriverProc);
284 npDriver->dwDriverID = ++dwDrvID;
286 if (avi_codecs[drv_id].usage==1)
289 (npDriver->DriverProc)(0, hDriver, DRV_LOAD, 0, 0);
291 TRACE("DRV_LOAD Ok!\n");
293 (npDriver->DriverProc)(0, hDriver, DRV_ENABLE, 0, 0);
295 TRACE("DRV_ENABLE Ok!\n");
300 npDriver->dwDriverID=(npDriver->DriverProc)(npDriver->dwDriverID, hDriver, DRV_OPEN,
301 (LPARAM) (LPSTR) unknown, lParam2);
304 TRACE("DRV_OPEN Ok!(%X)\n", npDriver->dwDriverID);