annotate libmpcodecs/vd_qtvideo.c @ 8287:c3eb28f300d0

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