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