Mercurial > mplayer.hg
annotate libmpcodecs/vd_qtvideo.c @ 26253:114c217e8652
38% synced with r22753
author | ptt |
---|---|
date | Thu, 27 Mar 2008 18:38:38 +0000 |
parents | e402c7730fcf |
children | 3a2e8ae7c548 |
rev | line source |
---|---|
8160 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
21263
db9754cebfab
Move #include <QuickTime/ImageCodec.h> before internal headers
uau
parents:
18771
diff
changeset
|
3 #include <inttypes.h> |
8160 | 4 |
5 #include "config.h" | |
6 | |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
7 #ifdef HAVE_QUICKTIME |
21263
db9754cebfab
Move #include <QuickTime/ImageCodec.h> before internal headers
uau
parents:
18771
diff
changeset
|
8 #include <QuickTime/ImageCodec.h> |
db9754cebfab
Move #include <QuickTime/ImageCodec.h> before internal headers
uau
parents:
18771
diff
changeset
|
9 #define dump_ImageDescription(x) |
21264
a5daafb2c201
Fix previous broken vd_qtvideo.c commit which failed on MACOSX
uau
parents:
21263
diff
changeset
|
10 #endif |
21263
db9754cebfab
Move #include <QuickTime/ImageCodec.h> before internal headers
uau
parents:
18771
diff
changeset
|
11 |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
21264
diff
changeset
|
12 #include "loader/wine/windef.h" |
8160 | 13 |
14 #include "mp_msg.h" | |
15 #include "vd_internal.h" | |
16 | |
9405
a4444e7ee56a
real cygwin support by Sascha Sommer <saschasommer@freenet.de>
alex
parents:
8473
diff
changeset
|
17 #ifdef WIN32_LOADER |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
21264
diff
changeset
|
18 #include "loader/ldt_keeper.h" |
8451 | 19 #endif |
20 | |
8160 | 21 static vd_info_t info = { |
22 "Quicktime Video decoder", | |
23 "qtvideo", | |
24 "A'rpi", | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
25 "Sascha Sommer", |
8160 | 26 "win32" |
27 }; | |
28 | |
29 LIBVD_EXTERN(qtvideo) | |
30 | |
17012 | 31 #include "bswap.h" |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
32 |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
33 #ifndef HAVE_QUICKTIME |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
21264
diff
changeset
|
34 #include "loader/qtx/qtxsdk/components.h" |
21264
a5daafb2c201
Fix previous broken vd_qtvideo.c commit which failed on MACOSX
uau
parents:
21263
diff
changeset
|
35 |
8160 | 36 HMODULE WINAPI LoadLibraryA(LPCSTR); |
37 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR); | |
38 int WINAPI FreeLibrary(HMODULE); | |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
39 #endif |
8160 | 40 |
41 //static ComponentDescription desc; // for FindNextComponent() | |
42 static ComponentInstance ci=NULL; // codec handle | |
43 //static CodecInfo cinfo; // for ImageCodecGetCodecInfo() | |
44 //Component prev=NULL; | |
45 //ComponentResult cres; // | |
46 static CodecCapabilities codeccap; // for decpar | |
47 static CodecDecompressParams decpar; // for ImageCodecPreDecompress() | |
48 //static ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() | |
49 static Rect OutBufferRect; //the dimensions of our GWorld | |
50 | |
51 static GWorldPtr OutBufferGWorld = NULL;//a GWorld is some kind of description for a drawing environment | |
52 static ImageDescriptionHandle framedescHandle; | |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
53 static HINSTANCE qtime_qts; // handle to the preloaded quicktime.qts |
8160 | 54 static HMODULE handler; |
55 | |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
56 #ifndef HAVE_QUICKTIME |
8160 | 57 static Component (*FindNextComponent)(Component prev,ComponentDescription* desc); |
58 static OSErr (*GetComponentInfo)(Component prev,ComponentDescription* desc,Handle h1,Handle h2,Handle h3); | |
59 static long (*CountComponents)(ComponentDescription* desc); | |
60 static OSErr (*InitializeQTML)(long flags); | |
61 static OSErr (*EnterMovies)(void); | |
62 static ComponentInstance (*OpenComponent)(Component c); | |
63 static ComponentResult (*ImageCodecInitialize)(ComponentInstance ci, | |
64 ImageSubCodecDecompressCapabilities * cap); | |
65 static ComponentResult (*ImageCodecBeginBand)(ComponentInstance ci, | |
66 CodecDecompressParams * params, | |
67 ImageSubCodecDecompressRecord * drp, | |
68 long flags); | |
69 static ComponentResult (*ImageCodecDrawBand)(ComponentInstance ci, | |
70 ImageSubCodecDecompressRecord * drp); | |
71 static ComponentResult (*ImageCodecEndBand)(ComponentInstance ci, | |
72 ImageSubCodecDecompressRecord * drp, | |
73 OSErr result, | |
74 long flags); | |
75 static ComponentResult (*ImageCodecGetCodecInfo)(ComponentInstance ci, | |
76 CodecInfo * info); | |
77 static ComponentResult (*ImageCodecPreDecompress)(ComponentInstance ci, | |
78 CodecDecompressParams * params); | |
79 static ComponentResult (*ImageCodecBandDecompress)(ComponentInstance ci, | |
80 CodecDecompressParams * params); | |
81 static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld); | |
82 static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw, | |
83 OSType pixelFormat, | |
84 const Rect *boundsRect, | |
85 CTabHandle cTable, | |
86 /*GDHandle*/void* aGDevice, //unused anyway | |
87 GWorldFlags flags, | |
88 void *baseAddr, | |
89 long rowBytes); | |
90 static OSErr (*NewHandleClear)(Size byteCount); | |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
91 #endif /* #ifndef HAVE_QUICKTIME */ |
8160 | 92 |
93 // to set/get/query special features/parameters | |
94 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
95 return CONTROL_UNKNOWN; | |
96 } | |
97 | |
25962 | 98 static int codec_initialized=0; |
8160 | 99 |
100 // init driver | |
101 static int init(sh_video_t *sh){ | |
102 long result = 1; | |
103 ComponentResult cres; | |
104 ComponentDescription desc; | |
105 Component prev=NULL; | |
106 CodecInfo cinfo; // for ImageCodecGetCodecInfo() | |
107 ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() | |
108 | |
25962 | 109 codec_initialized = 0; |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
110 #ifdef HAVE_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
111 EnterMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
112 #else |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
113 |
9405
a4444e7ee56a
real cygwin support by Sascha Sommer <saschasommer@freenet.de>
alex
parents:
8473
diff
changeset
|
114 #ifdef WIN32_LOADER |
8270 | 115 Setup_LDT_Keeper(); |
116 #endif | |
117 | |
14528
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
118 //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
119 qtime_qts = LoadLibraryA("QuickTime.qts"); |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
120 if(!qtime_qts){ |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
121 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" ); |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
122 return 0; |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
123 } |
860f06087aac
preload quicktime.qts, this allows us to ignore the hardcoded path inside the dlls so that quicktime.qts doesn't need to be in the windows system dir, patch by Gianluigi Tiesi <mplayer at netfarm.it>, comments by myself
faust3
parents:
13606
diff
changeset
|
124 |
8160 | 125 handler = LoadLibraryA("qtmlClient.dll"); |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
126 if(!handler){ |
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
127 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n"); |
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
128 return 0; |
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
129 } |
8160 | 130 |
8451 | 131 InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML"); |
132 EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies"); | |
133 FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent"); | |
134 CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents"); | |
135 GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo"); | |
136 OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent"); | |
137 ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize"); | |
138 ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo"); | |
139 ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand"); | |
140 ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress"); | |
141 ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress"); | |
142 GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap"); | |
143 QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr"); | |
144 NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear"); | |
8160 | 145 // = GetProcAddress(handler, ""); |
146 | |
147 if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){ | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
148 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n"); |
8160 | 149 return 0; |
150 } | |
151 | |
8162
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
152 result=InitializeQTML(6+16); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
153 // result=InitializeQTML(0); |
17366 | 154 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result); |
8162
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
155 // result=EnterMovies(); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
156 // printf("EnterMovies->%d\n",result); |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
157 #endif /* HAVE_QUICKTIME */ |
8160 | 158 |
8428 | 159 #if 0 |
160 memset(&desc,0,sizeof(desc)); | |
161 while((prev=FindNextComponent(prev,&desc))){ | |
162 ComponentDescription desc2; | |
163 unsigned char* c1=&desc2.componentType; | |
164 unsigned char* c2=&desc2.componentSubType; | |
165 memset(&desc2,0,sizeof(desc2)); | |
166 // printf("juhee %p (%p)\n",prev,&desc); | |
167 GetComponentInfo(prev,&desc2,NULL,NULL,NULL); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
168 mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n", |
8428 | 169 c1[3],c1[2],c1[1],c1[0], |
170 c2[3],c2[2],c2[1],c2[0], | |
171 desc2.componentType,desc2.componentSubType, | |
172 desc2.componentFlags); | |
173 } | |
174 #endif | |
175 | |
176 | |
8160 | 177 memset(&desc,0,sizeof(desc)); |
178 desc.componentType= (((unsigned char)'i')<<24)| | |
179 (((unsigned char)'m')<<16)| | |
180 (((unsigned char)'d')<<8)| | |
181 (((unsigned char)'c')); | |
8282 | 182 #if 0 |
8160 | 183 desc.componentSubType= |
184 (((unsigned char)'S'<<24))| | |
185 (((unsigned char)'V')<<16)| | |
186 (((unsigned char)'Q')<<8)| | |
187 (((unsigned char)'3')); | |
8282 | 188 #else |
189 desc.componentSubType = bswap_32(sh->format); | |
190 #endif | |
8160 | 191 desc.componentManufacturer=0; |
192 desc.componentFlags=0; | |
193 desc.componentFlagsMask=0; | |
194 | |
17366 | 195 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc)); |
8160 | 196 prev=FindNextComponent(NULL,&desc); |
197 if(!prev){ | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
198 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n"); |
8282 | 199 return(0); |
8160 | 200 } |
17366 | 201 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev); |
8160 | 202 |
203 ci=OpenComponent(prev); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
204 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci); |
8160 | 205 |
206 memset(&icap,0,sizeof(icap)); | |
207 cres=ImageCodecInitialize(ci,&icap); | |
17366 | 208 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize); |
8160 | 209 |
210 memset(&cinfo,0,sizeof(cinfo)); | |
211 cres=ImageCodecGetCodecInfo(ci,&cinfo); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
212 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", |
8160 | 213 cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
214 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], |
8160 | 215 ((unsigned char*)&cinfo.typeName)+1); |
216 | |
217 //make a yuy2 gworld | |
218 OutBufferRect.top=0; | |
219 OutBufferRect.left=0; | |
220 OutBufferRect.right=sh->disp_w; | |
221 OutBufferRect.bottom=sh->disp_h; | |
222 | |
223 //Fill the imagedescription for our SVQ3 frame | |
224 //we can probably get this from Demuxer | |
225 #if 0 | |
226 framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200); | |
227 printf("framedescHandle=%p *p=%p\n",framedescHandle,*framedescHandle); | |
228 { FILE* f=fopen("/root/.wine/fake_windows/IDesc","r"); | |
229 if(!f) printf("filenot found: IDesc\n"); | |
230 fread(*framedescHandle,sizeof(ImageDescription)+200,1,f); | |
231 fclose(f); | |
232 } | |
233 #else | |
8471 | 234 if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
235 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize); |
8301 | 236 framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize); |
237 memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize); | |
8471 | 238 dump_ImageDescription(*framedescHandle); |
8160 | 239 #endif |
240 //Find codecscomponent for video decompression | |
241 // result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor ); | |
242 // printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor); | |
243 | |
13188 | 244 sh->context = (void *)kYUVSPixelFormat; |
8301 | 245 #if 1 |
8282 | 246 { |
247 int imgfmt = sh->codec->outfmt[sh->outfmtidx]; | |
248 int qt_imgfmt; | |
249 switch(imgfmt) | |
250 { | |
251 case IMGFMT_YUY2: | |
252 qt_imgfmt = kYUVSPixelFormat; | |
253 break; | |
254 case IMGFMT_YVU9: | |
8301 | 255 qt_imgfmt = 0x73797639; //kYVU9PixelFormat; |
256 break; | |
257 case IMGFMT_YV12: | |
258 qt_imgfmt = 0x79343230; | |
8282 | 259 break; |
260 case IMGFMT_UYVY: | |
261 qt_imgfmt = kUYVY422PixelFormat; | |
262 break; | |
263 case IMGFMT_YVYU: | |
264 qt_imgfmt = kYVYU422PixelFormat; | |
265 imgfmt = IMGFMT_YUY2; | |
266 break; | |
267 case IMGFMT_RGB16: | |
268 qt_imgfmt = k16LE555PixelFormat; | |
269 break; | |
270 case IMGFMT_BGR24: | |
271 qt_imgfmt = k24BGRPixelFormat; | |
272 break; | |
273 case IMGFMT_BGR32: | |
274 qt_imgfmt = k32BGRAPixelFormat; | |
275 break; | |
276 case IMGFMT_RGB32: | |
277 qt_imgfmt = k32RGBAPixelFormat; | |
278 break; | |
279 default: | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
280 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n"); |
8282 | 281 return(0); |
282 } | |
17366 | 283 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt); |
13188 | 284 sh->context = (void *)qt_imgfmt; |
8282 | 285 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0; |
286 } | |
287 #else | |
8160 | 288 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
8282 | 289 #endif |
8160 | 290 |
291 return 1; | |
292 } | |
293 | |
294 // uninit driver | |
295 static void uninit(sh_video_t *sh){ | |
26216
e402c7730fcf
Introduce HAVE_QUICKTIME definition and use it where appropriate.
diego
parents:
25962
diff
changeset
|
296 #ifdef HAVE_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
297 ExitMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
298 #endif |
8160 | 299 } |
300 | |
301 // decode a frame | |
302 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
303 long result = 1; | |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
304 int i; |
8160 | 305 mp_image_t* mpi; |
306 ComponentResult cres; | |
8473 | 307 |
308 if(len<=0) return NULL; // skipped frame | |
8160 | 309 |
310 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, | |
311 sh->disp_w, sh->disp_h); | |
312 if(!mpi) return NULL; | |
313 | |
314 decpar.data = (char*)data; | |
315 decpar.bufferSize = len; | |
316 (**framedescHandle).dataSize=len; | |
317 | |
25962 | 318 if(!codec_initialized){ |
8160 | 319 result = QTNewGWorldFromPtr( |
320 &OutBufferGWorld, | |
8282 | 321 // kYUVSPixelFormat, //pixel format of new GWorld == YUY2 |
13188 | 322 (OSType)sh->context, |
8160 | 323 &OutBufferRect, //we should benchmark if yvu9 is faster for svq3, too |
324 0, | |
325 0, | |
326 0, | |
327 mpi->planes[0], | |
328 mpi->stride[0]); | |
17366 | 329 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"NewGWorldFromPtr returned:%ld\n",65536-(result&0xffff)); |
8282 | 330 // if (65536-(result&0xFFFF) != 10000) |
331 // return NULL; | |
8160 | 332 |
333 // printf("IDesc=%d\n",sizeof(ImageDescription)); | |
334 | |
335 decpar.imageDescription = framedescHandle; | |
336 decpar.startLine=0; | |
337 decpar.stopLine=(**framedescHandle).height; | |
338 decpar.frameNumber = 1; //1 | |
339 // decpar.conditionFlags=0xFFD; // first | |
340 // decpar.callerFlags=0x2001; // first | |
341 decpar.matrixFlags = 0; | |
342 decpar.matrixType = 0; | |
343 decpar.matrix = 0; | |
344 decpar.capabilities=&codeccap; | |
345 // decpar.accuracy = 0x1680000; //codecNormalQuality; | |
346 decpar.accuracy = codecNormalQuality; | |
8431 | 347 // decpar.port = OutBufferGWorld; |
8160 | 348 // decpar.preferredOffscreenPixelSize=17207; |
349 | |
350 // decpar.sequenceID=malloc(1000); | |
351 // memset(decpar.sequenceID,0,1000); | |
352 | |
353 // SrcRect.top=17207; | |
354 // SrcRect.left=0; | |
355 // SrcRect.right=0;//image_width; | |
356 // SrcRect.bottom=0;//image_height; | |
357 | |
358 // decpar.srcRect = SrcRect; | |
359 decpar.srcRect = OutBufferRect; | |
360 | |
361 decpar.transferMode = srcCopy; | |
362 decpar.dstPixMap = **GetGWorldPixMap( OutBufferGWorld);//destPixmap; | |
363 | |
364 cres=ImageCodecPreDecompress(ci,&decpar); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
365 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%X\n",cres); |
8430 | 366 |
367 if(decpar.wantedDestinationPixelTypes) | |
368 { OSType *p=*(decpar.wantedDestinationPixelTypes); | |
369 if(p) while(*p){ | |
17366 | 370 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"supported csp: 0x%08X %.4s\n",*p,(char *)p); |
8430 | 371 ++p; |
372 } | |
373 } | |
374 | |
8160 | 375 |
376 // decpar.conditionFlags=0x10FFF; // first | |
377 // decpar.preferredOffscreenPixelSize=17207; | |
378 | |
379 // decpar.conditionFlags=0x10FFD; // first | |
380 | |
381 // cres=ImageCodecPreDecompress(ci,&decpar); | |
382 // printf("ImageCodecPreDecompress cres=0x%X\n",cres); | |
383 | |
384 | |
25962 | 385 codec_initialized=1; |
8160 | 386 } |
387 | |
388 #if 0 | |
389 if(decpar.frameNumber==124){ | |
390 decpar.frameNumber=1; | |
391 cres=ImageCodecPreDecompress(ci,&decpar); | |
17366 | 392 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%lX\n",cres); |
8160 | 393 } |
394 #endif | |
395 | |
396 cres=ImageCodecBandDecompress(ci,&decpar); | |
397 | |
398 ++decpar.frameNumber; | |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
399 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
400 if(cres&0xFFFF){ |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
401 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecBandDecompress cres=0x%X (-0x%X) %d\n",cres,-cres,cres); |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
402 return NULL; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
403 } |
8160 | 404 |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
405 // for(i=0;i<8;i++) |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
406 // printf("img_base[%d]=%p\n",i,((int*)decpar.dstPixMap.baseAddr)[i]); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
407 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
408 if((int)sh->context==0x73797639){ // Sorenson 16-bit YUV -> std YVU9 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
409 |
8451 | 410 short *src0=(short *)((char*)decpar.dstPixMap.baseAddr+0x20); |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
411 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
412 for(i=0;i<mpi->h;i++){ |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
413 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
414 unsigned char* dst=mpi->planes[0]+i*mpi->stride[0]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
415 unsigned short* src=src0+i*((mpi->w+15)&(~15)); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
416 for(x=0;x<mpi->w;x++) dst[x]=src[x]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
417 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
418 src0+=((mpi->w+15)&(~15))*((mpi->h+15)&(~15)); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
419 for(i=0;i<mpi->h/4;i++){ |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
420 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
421 unsigned char* dst=mpi->planes[1]+i*mpi->stride[1]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
422 unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
423 for(x=0;x<mpi->w/4;x++) dst[x]=src[x]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
424 src+=((mpi->w+63)&(~63))/4; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
425 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
426 src0+=(((mpi->w+63)&(~63))/4)*(((mpi->h+63)&(~63))/4); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
427 for(i=0;i<mpi->h/4;i++){ |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
428 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
429 unsigned char* dst=mpi->planes[2]+i*mpi->stride[2]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
430 unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4); |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
431 for(x=0;x<mpi->w/4;x++) dst[x]=src[x]; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
432 src+=((mpi->w+63)&(~63))/4; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
433 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
434 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
435 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
436 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
437 |
8160 | 438 return mpi; |
439 } |