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