Mercurial > mplayer.hg
annotate libmpcodecs/vd_qtvideo.c @ 8241:2cba733ff903
Polish manual update to version 0.90-pre10 (when 1.0 ?? ;-)
MPlayer user from Poland:
Konrad Materka (zorg) < kmaterka@wp.pl >
Adrain Pawlik (imoteph) < imoteph@wp.pl >
author | gabucino |
---|---|
date | Wed, 20 Nov 2002 21:35:18 +0000 |
parents | ec8636e02720 |
children | badd24741e4a |
rev | line source |
---|---|
8160 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "config.h" | |
5 | |
6 #ifdef USE_QTX_CODECS | |
7 | |
8 #include "mp_msg.h" | |
9 #include "vd_internal.h" | |
10 | |
11 static vd_info_t info = { | |
12 "Quicktime Video decoder", | |
13 "qtvideo", | |
14 "A'rpi", | |
15 "Faust3", | |
16 "win32" | |
17 }; | |
18 | |
19 LIBVD_EXTERN(qtvideo) | |
20 | |
21 #include "components.h" | |
22 | |
23 //#include "wine/windef.h" | |
24 | |
25 HMODULE WINAPI LoadLibraryA(LPCSTR); | |
26 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); | |
27 int WINAPI FreeLibrary(HMODULE); | |
28 | |
29 //static ComponentDescription desc; // for FindNextComponent() | |
30 static ComponentInstance ci=NULL; // codec handle | |
31 //static CodecInfo cinfo; // for ImageCodecGetCodecInfo() | |
32 //Component prev=NULL; | |
33 //ComponentResult cres; // | |
34 static CodecCapabilities codeccap; // for decpar | |
35 static CodecDecompressParams decpar; // for ImageCodecPreDecompress() | |
36 //static ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() | |
37 static Rect OutBufferRect; //the dimensions of our GWorld | |
38 | |
39 static GWorldPtr OutBufferGWorld = NULL;//a GWorld is some kind of description for a drawing environment | |
40 static ImageDescriptionHandle framedescHandle; | |
41 //static HINSTANCE qtml_dll; | |
42 static HMODULE handler; | |
43 | |
44 static Component (*FindNextComponent)(Component prev,ComponentDescription* desc); | |
45 static OSErr (*GetComponentInfo)(Component prev,ComponentDescription* desc,Handle h1,Handle h2,Handle h3); | |
46 static long (*CountComponents)(ComponentDescription* desc); | |
47 static OSErr (*InitializeQTML)(long flags); | |
48 static OSErr (*EnterMovies)(void); | |
49 static ComponentInstance (*OpenComponent)(Component c); | |
50 static ComponentResult (*ImageCodecInitialize)(ComponentInstance ci, | |
51 ImageSubCodecDecompressCapabilities * cap); | |
52 static ComponentResult (*ImageCodecBeginBand)(ComponentInstance ci, | |
53 CodecDecompressParams * params, | |
54 ImageSubCodecDecompressRecord * drp, | |
55 long flags); | |
56 static ComponentResult (*ImageCodecDrawBand)(ComponentInstance ci, | |
57 ImageSubCodecDecompressRecord * drp); | |
58 static ComponentResult (*ImageCodecEndBand)(ComponentInstance ci, | |
59 ImageSubCodecDecompressRecord * drp, | |
60 OSErr result, | |
61 long flags); | |
62 static ComponentResult (*ImageCodecGetCodecInfo)(ComponentInstance ci, | |
63 CodecInfo * info); | |
64 static ComponentResult (*ImageCodecPreDecompress)(ComponentInstance ci, | |
65 CodecDecompressParams * params); | |
66 static ComponentResult (*ImageCodecBandDecompress)(ComponentInstance ci, | |
67 CodecDecompressParams * params); | |
68 static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld); | |
69 static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw, | |
70 OSType pixelFormat, | |
71 const Rect *boundsRect, | |
72 CTabHandle cTable, | |
73 /*GDHandle*/void* aGDevice, //unused anyway | |
74 GWorldFlags flags, | |
75 void *baseAddr, | |
76 long rowBytes); | |
77 static OSErr (*NewHandleClear)(Size byteCount); | |
78 | |
79 | |
80 // to set/get/query special features/parameters | |
81 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
82 return CONTROL_UNKNOWN; | |
83 } | |
84 | |
85 static int codec_inited=0; | |
86 | |
87 // init driver | |
88 static int init(sh_video_t *sh){ | |
89 long result = 1; | |
90 ComponentResult cres; | |
91 ComponentDescription desc; | |
92 Component prev=NULL; | |
93 CodecInfo cinfo; // for ImageCodecGetCodecInfo() | |
94 ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() | |
95 | |
96 handler = LoadLibraryA("qtmlClient.dll"); | |
97 | |
98 InitializeQTML = GetProcAddress(handler, "InitializeQTML"); | |
99 EnterMovies = GetProcAddress(handler, "EnterMovies"); | |
100 FindNextComponent = GetProcAddress(handler, "FindNextComponent"); | |
101 CountComponents = GetProcAddress(handler, "CountComponents"); | |
102 GetComponentInfo = GetProcAddress(handler, "GetComponentInfo"); | |
103 OpenComponent = GetProcAddress(handler, "OpenComponent"); | |
104 ImageCodecInitialize = GetProcAddress(handler, "ImageCodecInitialize"); | |
105 ImageCodecGetCodecInfo = GetProcAddress(handler, "ImageCodecGetCodecInfo"); | |
106 ImageCodecBeginBand = GetProcAddress(handler, "ImageCodecBeginBand"); | |
107 ImageCodecPreDecompress = GetProcAddress(handler, "ImageCodecPreDecompress"); | |
108 ImageCodecBandDecompress = GetProcAddress(handler, "ImageCodecBandDecompress"); | |
109 GetGWorldPixMap = GetProcAddress(handler, "GetGWorldPixMap"); | |
110 QTNewGWorldFromPtr = GetProcAddress(handler, "QTNewGWorldFromPtr"); | |
111 NewHandleClear = GetProcAddress(handler, "NewHandleClear"); | |
112 // = GetProcAddress(handler, ""); | |
113 | |
114 if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){ | |
115 printf("invalid qt DLL!\n"); | |
116 return 0; | |
117 } | |
118 | |
8162
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
119 result=InitializeQTML(6+16); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
120 // result=InitializeQTML(0); |
8160 | 121 printf("InitializeQTML returned %i\n",result); |
8162
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
122 // result=EnterMovies(); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
123 // printf("EnterMovies->%d\n",result); |
8160 | 124 |
125 memset(&desc,0,sizeof(desc)); | |
126 desc.componentType= (((unsigned char)'i')<<24)| | |
127 (((unsigned char)'m')<<16)| | |
128 (((unsigned char)'d')<<8)| | |
129 (((unsigned char)'c')); | |
130 desc.componentSubType= | |
131 (((unsigned char)'S'<<24))| | |
132 (((unsigned char)'V')<<16)| | |
133 (((unsigned char)'Q')<<8)| | |
134 (((unsigned char)'3')); | |
135 desc.componentManufacturer=0; | |
136 desc.componentFlags=0; | |
137 desc.componentFlagsMask=0; | |
138 | |
139 printf("Count = %d\n",CountComponents(&desc)); | |
140 #if 0 | |
141 memset(&desc,0,sizeof(desc)); | |
142 while((prev=FindNextComponent(prev,&desc))){ | |
143 unsigned char* c1=&desc2.componentType; | |
144 unsigned char* c2=&desc2.componentSubType; | |
145 memset(&desc2,0,sizeof(desc2)); | |
146 printf("juhee %p (%p)\n",prev,&desc); | |
147 GetComponentInfo(prev,&desc2,NULL,NULL,NULL); | |
148 printf("DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n", | |
149 c1[3],c1[2],c1[1],c1[0], | |
150 c2[3],c2[2],c2[1],c2[0], | |
151 desc2.componentType,desc2.componentSubType, | |
152 desc2.componentFlags); | |
153 } | |
154 #endif | |
155 | |
156 prev=FindNextComponent(NULL,&desc); | |
157 if(!prev){ | |
158 printf("Cannot find requested component\n"); | |
159 exit(1); | |
160 } | |
161 printf("Found it! ID = 0x%X\n",prev); | |
162 | |
163 ci=OpenComponent(prev); | |
164 printf("ci=%p\n",ci); | |
165 | |
166 memset(&icap,0,sizeof(icap)); | |
167 cres=ImageCodecInitialize(ci,&icap); | |
168 printf("ImageCodecInitialize->%p size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize); | |
169 | |
170 memset(&cinfo,0,sizeof(cinfo)); | |
171 cres=ImageCodecGetCodecInfo(ci,&cinfo); | |
172 printf("Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", | |
173 cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); | |
174 printf("Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], | |
175 ((unsigned char*)&cinfo.typeName)+1); | |
176 | |
177 //make a yuy2 gworld | |
178 OutBufferRect.top=0; | |
179 OutBufferRect.left=0; | |
180 OutBufferRect.right=sh->disp_w; | |
181 OutBufferRect.bottom=sh->disp_h; | |
182 | |
183 //Fill the imagedescription for our SVQ3 frame | |
184 //we can probably get this from Demuxer | |
185 #if 0 | |
186 framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200); | |
187 printf("framedescHandle=%p *p=%p\n",framedescHandle,*framedescHandle); | |
188 { FILE* f=fopen("/root/.wine/fake_windows/IDesc","r"); | |
189 if(!f) printf("filenot found: IDesc\n"); | |
190 fread(*framedescHandle,sizeof(ImageDescription)+200,1,f); | |
191 fclose(f); | |
192 } | |
193 #else | |
194 framedescHandle=&(sh->ImageDesc); | |
195 #endif | |
196 //Find codecscomponent for video decompression | |
197 // result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor ); | |
198 // printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor); | |
199 | |
200 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; | |
201 | |
202 return 1; | |
203 } | |
204 | |
205 // uninit driver | |
206 static void uninit(sh_video_t *sh){ | |
207 } | |
208 | |
209 // decode a frame | |
210 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
211 long result = 1; | |
212 mp_image_t* mpi; | |
213 ComponentResult cres; | |
214 | |
215 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, | |
216 sh->disp_w, sh->disp_h); | |
217 if(!mpi) return NULL; | |
218 | |
219 decpar.data = (char*)data; | |
220 decpar.bufferSize = len; | |
221 (**framedescHandle).dataSize=len; | |
222 | |
223 if(!codec_inited){ | |
224 result = QTNewGWorldFromPtr( | |
225 &OutBufferGWorld, | |
226 kYUVSPixelFormat, //pixel format of new GWorld == YUY2 | |
227 &OutBufferRect, //we should benchmark if yvu9 is faster for svq3, too | |
228 0, | |
229 0, | |
230 0, | |
231 mpi->planes[0], | |
232 mpi->stride[0]); | |
233 printf("NewGWorldFromPtr returned:%i\n",result); | |
234 | |
235 // printf("IDesc=%d\n",sizeof(ImageDescription)); | |
236 | |
237 decpar.imageDescription = framedescHandle; | |
238 decpar.startLine=0; | |
239 decpar.stopLine=(**framedescHandle).height; | |
240 decpar.frameNumber = 1; //1 | |
241 // decpar.conditionFlags=0xFFD; // first | |
242 // decpar.callerFlags=0x2001; // first | |
243 decpar.matrixFlags = 0; | |
244 decpar.matrixType = 0; | |
245 decpar.matrix = 0; | |
246 decpar.capabilities=&codeccap; | |
247 // decpar.accuracy = 0x1680000; //codecNormalQuality; | |
248 decpar.accuracy = codecNormalQuality; | |
249 decpar.port = OutBufferGWorld; | |
250 // decpar.preferredOffscreenPixelSize=17207; | |
251 | |
252 // decpar.sequenceID=malloc(1000); | |
253 // memset(decpar.sequenceID,0,1000); | |
254 | |
255 // SrcRect.top=17207; | |
256 // SrcRect.left=0; | |
257 // SrcRect.right=0;//image_width; | |
258 // SrcRect.bottom=0;//image_height; | |
259 | |
260 // decpar.srcRect = SrcRect; | |
261 decpar.srcRect = OutBufferRect; | |
262 | |
263 decpar.transferMode = srcCopy; | |
264 decpar.dstPixMap = **GetGWorldPixMap( OutBufferGWorld);//destPixmap; | |
265 | |
266 cres=ImageCodecPreDecompress(ci,&decpar); | |
267 printf("ImageCodecPreDecompress cres=0x%X\n",cres); | |
268 | |
269 // decpar.conditionFlags=0x10FFF; // first | |
270 // decpar.preferredOffscreenPixelSize=17207; | |
271 | |
272 // decpar.conditionFlags=0x10FFD; // first | |
273 | |
274 // cres=ImageCodecPreDecompress(ci,&decpar); | |
275 // printf("ImageCodecPreDecompress cres=0x%X\n",cres); | |
276 | |
277 | |
278 codec_inited=1; | |
279 } | |
280 | |
281 #if 0 | |
282 if(decpar.frameNumber==124){ | |
283 decpar.frameNumber=1; | |
284 cres=ImageCodecPreDecompress(ci,&decpar); | |
285 printf("ImageCodecPreDecompress cres=0x%X\n",cres); | |
286 } | |
287 #endif | |
288 | |
289 cres=ImageCodecBandDecompress(ci,&decpar); | |
8188 | 290 if(cres&0xFFFF) printf("ImageCodecBandDecompress cres=0x%X (-0x%X) %d\n",cres,-cres,cres); |
8160 | 291 |
292 ++decpar.frameNumber; | |
293 | |
294 return mpi; | |
295 } | |
296 #endif |