Mercurial > mplayer.hg
annotate libmpcodecs/vd_qtvideo.c @ 28064:4d76c7e31760
Simplify, do not duplicate buffer size calculation
author | reimar |
---|---|
date | Fri, 05 Dec 2008 20:50:43 +0000 |
parents | 078b68af5df0 |
children | 504aa3e3076a |
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 | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
7 #ifdef CONFIG_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 | |
26542
3a2e8ae7c548
Consistently #include mpbswap.h instead of bswap.h everywhere.
diego
parents:
26216
diff
changeset
|
31 #include "mpbswap.h" |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
32 |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
33 #ifndef CONFIG_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 | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
56 #ifndef CONFIG_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 (*ImageCodecGetCodecInfo)(ComponentInstance ci, | |
70 CodecInfo * info); | |
71 static ComponentResult (*ImageCodecPreDecompress)(ComponentInstance ci, | |
72 CodecDecompressParams * params); | |
73 static ComponentResult (*ImageCodecBandDecompress)(ComponentInstance ci, | |
74 CodecDecompressParams * params); | |
75 static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld); | |
76 static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw, | |
77 OSType pixelFormat, | |
78 const Rect *boundsRect, | |
79 CTabHandle cTable, | |
80 /*GDHandle*/void* aGDevice, //unused anyway | |
81 GWorldFlags flags, | |
82 void *baseAddr, | |
83 long rowBytes); | |
84 static OSErr (*NewHandleClear)(Size byteCount); | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
85 #endif /* #ifndef CONFIG_QUICKTIME */ |
8160 | 86 |
87 // to set/get/query special features/parameters | |
88 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
89 return CONTROL_UNKNOWN; | |
90 } | |
91 | |
25962 | 92 static int codec_initialized=0; |
8160 | 93 |
94 // init driver | |
95 static int init(sh_video_t *sh){ | |
96 long result = 1; | |
97 ComponentResult cres; | |
98 ComponentDescription desc; | |
99 Component prev=NULL; | |
100 CodecInfo cinfo; // for ImageCodecGetCodecInfo() | |
101 ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() | |
102 | |
25962 | 103 codec_initialized = 0; |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
104 #ifdef CONFIG_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
105 EnterMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
106 #else |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
107 |
9405
a4444e7ee56a
real cygwin support by Sascha Sommer <saschasommer@freenet.de>
alex
parents:
8473
diff
changeset
|
108 #ifdef WIN32_LOADER |
8270 | 109 Setup_LDT_Keeper(); |
110 #endif | |
111 | |
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
|
112 //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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 } |
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 |
8160 | 119 handler = LoadLibraryA("qtmlClient.dll"); |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
120 if(!handler){ |
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
121 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
|
122 return 0; |
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
123 } |
8160 | 124 |
8451 | 125 InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML"); |
126 EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies"); | |
127 FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent"); | |
128 CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents"); | |
129 GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo"); | |
130 OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent"); | |
131 ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize"); | |
132 ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo"); | |
133 ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand"); | |
134 ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress"); | |
135 ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress"); | |
136 GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap"); | |
137 QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr"); | |
138 NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear"); | |
8160 | 139 // = GetProcAddress(handler, ""); |
140 | |
141 if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){ | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
142 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n"); |
8160 | 143 return 0; |
144 } | |
145 | |
8162
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
146 result=InitializeQTML(6+16); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
147 // result=InitializeQTML(0); |
17366 | 148 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
|
149 // result=EnterMovies(); |
98951b7331e1
no need to EnterMovies(), do minimal InitializeQTML only
arpi
parents:
8160
diff
changeset
|
150 // printf("EnterMovies->%d\n",result); |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
151 #endif /* CONFIG_QUICKTIME */ |
8160 | 152 |
8428 | 153 #if 0 |
154 memset(&desc,0,sizeof(desc)); | |
155 while((prev=FindNextComponent(prev,&desc))){ | |
156 ComponentDescription desc2; | |
157 unsigned char* c1=&desc2.componentType; | |
158 unsigned char* c2=&desc2.componentSubType; | |
159 memset(&desc2,0,sizeof(desc2)); | |
160 // printf("juhee %p (%p)\n",prev,&desc); | |
161 GetComponentInfo(prev,&desc2,NULL,NULL,NULL); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
162 mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n", |
8428 | 163 c1[3],c1[2],c1[1],c1[0], |
164 c2[3],c2[2],c2[1],c2[0], | |
165 desc2.componentType,desc2.componentSubType, | |
166 desc2.componentFlags); | |
167 } | |
168 #endif | |
169 | |
170 | |
8160 | 171 memset(&desc,0,sizeof(desc)); |
172 desc.componentType= (((unsigned char)'i')<<24)| | |
173 (((unsigned char)'m')<<16)| | |
174 (((unsigned char)'d')<<8)| | |
175 (((unsigned char)'c')); | |
8282 | 176 #if 0 |
8160 | 177 desc.componentSubType= |
178 (((unsigned char)'S'<<24))| | |
179 (((unsigned char)'V')<<16)| | |
180 (((unsigned char)'Q')<<8)| | |
181 (((unsigned char)'3')); | |
8282 | 182 #else |
183 desc.componentSubType = bswap_32(sh->format); | |
184 #endif | |
8160 | 185 desc.componentManufacturer=0; |
186 desc.componentFlags=0; | |
187 desc.componentFlagsMask=0; | |
188 | |
17366 | 189 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc)); |
8160 | 190 prev=FindNextComponent(NULL,&desc); |
191 if(!prev){ | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
192 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26542
diff
changeset
|
193 return 0; |
8160 | 194 } |
17366 | 195 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev); |
8160 | 196 |
197 ci=OpenComponent(prev); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
198 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci); |
8160 | 199 |
200 memset(&icap,0,sizeof(icap)); | |
201 cres=ImageCodecInitialize(ci,&icap); | |
17366 | 202 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize); |
8160 | 203 |
204 memset(&cinfo,0,sizeof(cinfo)); | |
205 cres=ImageCodecGetCodecInfo(ci,&cinfo); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
206 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", |
8160 | 207 cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
208 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], |
8160 | 209 ((unsigned char*)&cinfo.typeName)+1); |
210 | |
211 //make a yuy2 gworld | |
212 OutBufferRect.top=0; | |
213 OutBufferRect.left=0; | |
214 OutBufferRect.right=sh->disp_w; | |
215 OutBufferRect.bottom=sh->disp_h; | |
216 | |
217 //Fill the imagedescription for our SVQ3 frame | |
218 //we can probably get this from Demuxer | |
219 #if 0 | |
220 framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200); | |
221 printf("framedescHandle=%p *p=%p\n",framedescHandle,*framedescHandle); | |
222 { FILE* f=fopen("/root/.wine/fake_windows/IDesc","r"); | |
223 if(!f) printf("filenot found: IDesc\n"); | |
224 fread(*framedescHandle,sizeof(ImageDescription)+200,1,f); | |
225 fclose(f); | |
226 } | |
227 #else | |
8471 | 228 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
|
229 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize); |
8301 | 230 framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize); |
231 memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize); | |
8471 | 232 dump_ImageDescription(*framedescHandle); |
8160 | 233 #endif |
234 //Find codecscomponent for video decompression | |
235 // result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor ); | |
236 // printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor); | |
237 | |
13188 | 238 sh->context = (void *)kYUVSPixelFormat; |
8301 | 239 #if 1 |
8282 | 240 { |
241 int imgfmt = sh->codec->outfmt[sh->outfmtidx]; | |
242 int qt_imgfmt; | |
243 switch(imgfmt) | |
244 { | |
245 case IMGFMT_YUY2: | |
246 qt_imgfmt = kYUVSPixelFormat; | |
247 break; | |
248 case IMGFMT_YVU9: | |
8301 | 249 qt_imgfmt = 0x73797639; //kYVU9PixelFormat; |
250 break; | |
251 case IMGFMT_YV12: | |
252 qt_imgfmt = 0x79343230; | |
8282 | 253 break; |
254 case IMGFMT_UYVY: | |
255 qt_imgfmt = kUYVY422PixelFormat; | |
256 break; | |
257 case IMGFMT_YVYU: | |
258 qt_imgfmt = kYVYU422PixelFormat; | |
259 imgfmt = IMGFMT_YUY2; | |
260 break; | |
261 case IMGFMT_RGB16: | |
262 qt_imgfmt = k16LE555PixelFormat; | |
263 break; | |
264 case IMGFMT_BGR24: | |
265 qt_imgfmt = k24BGRPixelFormat; | |
266 break; | |
267 case IMGFMT_BGR32: | |
268 qt_imgfmt = k32BGRAPixelFormat; | |
269 break; | |
270 case IMGFMT_RGB32: | |
271 qt_imgfmt = k32RGBAPixelFormat; | |
272 break; | |
273 default: | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
274 mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n"); |
26754
63630c09e237
cosmetics: Remove pointless parentheses from return calls.
diego
parents:
26542
diff
changeset
|
275 return 0; |
8282 | 276 } |
17366 | 277 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt); |
13188 | 278 sh->context = (void *)qt_imgfmt; |
8282 | 279 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0; |
280 } | |
281 #else | |
8160 | 282 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; |
8282 | 283 #endif |
8160 | 284 |
285 return 1; | |
286 } | |
287 | |
288 // uninit driver | |
289 static void uninit(sh_video_t *sh){ | |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
26754
diff
changeset
|
290 #ifdef CONFIG_QUICKTIME |
9502
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
291 ExitMovies(); |
241bba8f60e8
MACOSX support patch, based on Dan Christiansens work
alex
parents:
9405
diff
changeset
|
292 #endif |
8160 | 293 } |
294 | |
295 // decode a frame | |
296 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
297 long result = 1; | |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
298 int i; |
8160 | 299 mp_image_t* mpi; |
300 ComponentResult cres; | |
8473 | 301 |
302 if(len<=0) return NULL; // skipped frame | |
8160 | 303 |
304 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE, | |
305 sh->disp_w, sh->disp_h); | |
306 if(!mpi) return NULL; | |
307 | |
308 decpar.data = (char*)data; | |
309 decpar.bufferSize = len; | |
310 (**framedescHandle).dataSize=len; | |
311 | |
25962 | 312 if(!codec_initialized){ |
8160 | 313 result = QTNewGWorldFromPtr( |
314 &OutBufferGWorld, | |
8282 | 315 // kYUVSPixelFormat, //pixel format of new GWorld == YUY2 |
13188 | 316 (OSType)sh->context, |
8160 | 317 &OutBufferRect, //we should benchmark if yvu9 is faster for svq3, too |
318 0, | |
319 0, | |
320 0, | |
321 mpi->planes[0], | |
322 mpi->stride[0]); | |
17366 | 323 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"NewGWorldFromPtr returned:%ld\n",65536-(result&0xffff)); |
8282 | 324 // if (65536-(result&0xFFFF) != 10000) |
325 // return NULL; | |
8160 | 326 |
327 // printf("IDesc=%d\n",sizeof(ImageDescription)); | |
328 | |
329 decpar.imageDescription = framedescHandle; | |
330 decpar.startLine=0; | |
331 decpar.stopLine=(**framedescHandle).height; | |
332 decpar.frameNumber = 1; //1 | |
333 // decpar.conditionFlags=0xFFD; // first | |
334 // decpar.callerFlags=0x2001; // first | |
335 decpar.matrixFlags = 0; | |
336 decpar.matrixType = 0; | |
337 decpar.matrix = 0; | |
338 decpar.capabilities=&codeccap; | |
339 // decpar.accuracy = 0x1680000; //codecNormalQuality; | |
340 decpar.accuracy = codecNormalQuality; | |
8431 | 341 // decpar.port = OutBufferGWorld; |
8160 | 342 // decpar.preferredOffscreenPixelSize=17207; |
343 | |
344 // decpar.sequenceID=malloc(1000); | |
345 // memset(decpar.sequenceID,0,1000); | |
346 | |
347 // SrcRect.top=17207; | |
348 // SrcRect.left=0; | |
349 // SrcRect.right=0;//image_width; | |
350 // SrcRect.bottom=0;//image_height; | |
351 | |
352 // decpar.srcRect = SrcRect; | |
353 decpar.srcRect = OutBufferRect; | |
354 | |
355 decpar.transferMode = srcCopy; | |
356 decpar.dstPixMap = **GetGWorldPixMap( OutBufferGWorld);//destPixmap; | |
357 | |
358 cres=ImageCodecPreDecompress(ci,&decpar); | |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
359 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%X\n",cres); |
8430 | 360 |
361 if(decpar.wantedDestinationPixelTypes) | |
362 { OSType *p=*(decpar.wantedDestinationPixelTypes); | |
363 if(p) while(*p){ | |
17366 | 364 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"supported csp: 0x%08X %.4s\n",*p,(char *)p); |
8430 | 365 ++p; |
366 } | |
367 } | |
368 | |
8160 | 369 |
370 // decpar.conditionFlags=0x10FFF; // first | |
371 // decpar.preferredOffscreenPixelSize=17207; | |
372 | |
373 // decpar.conditionFlags=0x10FFD; // first | |
374 | |
375 // cres=ImageCodecPreDecompress(ci,&decpar); | |
376 // printf("ImageCodecPreDecompress cres=0x%X\n",cres); | |
377 | |
378 | |
25962 | 379 codec_initialized=1; |
8160 | 380 } |
381 | |
382 #if 0 | |
383 if(decpar.frameNumber==124){ | |
384 decpar.frameNumber=1; | |
385 cres=ImageCodecPreDecompress(ci,&decpar); | |
17366 | 386 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%lX\n",cres); |
8160 | 387 } |
388 #endif | |
389 | |
390 cres=ImageCodecBandDecompress(ci,&decpar); | |
391 | |
392 ++decpar.frameNumber; | |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
393 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
394 if(cres&0xFFFF){ |
12194
81f8e4f97b38
printf -> mp_msg, error msg when qtmlClient.dll is missing
faust3
parents:
9502
diff
changeset
|
395 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
|
396 return NULL; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
397 } |
8160 | 398 |
8321
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
399 // for(i=0;i<8;i++) |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
400 // 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
|
401 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
402 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
|
403 |
8451 | 404 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
|
405 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
406 for(i=0;i<mpi->h;i++){ |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
407 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
408 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
|
409 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
|
410 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
|
411 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
412 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
|
413 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
|
414 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 src+=((mpi->w+63)&(~63))/4; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
419 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
420 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
|
421 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
|
422 int x; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
423 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
|
424 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
|
425 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
|
426 src+=((mpi->w+63)&(~63))/4; |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
427 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
428 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
429 } |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
430 |
ca24204fb547
SVQ1 support (ugly hack... - really we need 'syuv' support in swscaler :))
arpi
parents:
8301
diff
changeset
|
431 |
8160 | 432 return mpi; |
433 } |