2002-11-12 00:06:36 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-02-25 15:39:36 +00:00
|
|
|
#if defined(USE_QTX_CODECS) || defined(MACOSX)
|
2004-04-30 10:26:26 +00:00
|
|
|
#include "wine/windef.h"
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
#include "mp_msg.h"
|
|
|
|
#include "vd_internal.h"
|
|
|
|
|
2003-02-12 15:39:59 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-12-14 17:56:35 +00:00
|
|
|
#include "ldt_keeper.h"
|
|
|
|
#endif
|
|
|
|
|
2002-11-12 00:06:36 +00:00
|
|
|
static vd_info_t info = {
|
|
|
|
"Quicktime Video decoder",
|
|
|
|
"qtvideo",
|
|
|
|
"A'rpi",
|
2004-04-13 14:48:31 +00:00
|
|
|
"Sascha Sommer",
|
2002-11-12 00:06:36 +00:00
|
|
|
"win32"
|
|
|
|
};
|
|
|
|
|
|
|
|
LIBVD_EXTERN(qtvideo)
|
|
|
|
|
2002-11-25 18:04:19 +00:00
|
|
|
#include "../bswap.h"
|
2003-02-25 15:39:36 +00:00
|
|
|
|
|
|
|
#ifdef MACOSX
|
|
|
|
#include <QuickTime/ImageCodec.h>
|
|
|
|
#define dump_ImageDescription(x)
|
|
|
|
#else
|
2002-11-24 21:49:52 +00:00
|
|
|
#include "qtx/qtxsdk/components.h"
|
2003-02-25 15:39:36 +00:00
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
|
2003-02-25 15:39:36 +00:00
|
|
|
#ifdef USE_QTX_CODECS
|
2002-11-12 00:06:36 +00:00
|
|
|
//#include "wine/windef.h"
|
|
|
|
|
|
|
|
HMODULE WINAPI LoadLibraryA(LPCSTR);
|
|
|
|
FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
|
|
|
|
int WINAPI FreeLibrary(HMODULE);
|
2003-02-25 15:39:36 +00:00
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
//static ComponentDescription desc; // for FindNextComponent()
|
|
|
|
static ComponentInstance ci=NULL; // codec handle
|
|
|
|
//static CodecInfo cinfo; // for ImageCodecGetCodecInfo()
|
|
|
|
//Component prev=NULL;
|
|
|
|
//ComponentResult cres; //
|
|
|
|
static CodecCapabilities codeccap; // for decpar
|
|
|
|
static CodecDecompressParams decpar; // for ImageCodecPreDecompress()
|
|
|
|
//static ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()
|
|
|
|
static Rect OutBufferRect; //the dimensions of our GWorld
|
|
|
|
|
|
|
|
static GWorldPtr OutBufferGWorld = NULL;//a GWorld is some kind of description for a drawing environment
|
|
|
|
static ImageDescriptionHandle framedescHandle;
|
|
|
|
//static HINSTANCE qtml_dll;
|
|
|
|
static HMODULE handler;
|
|
|
|
|
2003-02-25 15:39:36 +00:00
|
|
|
#ifdef USE_QTX_CODECS
|
2002-11-12 00:06:36 +00:00
|
|
|
static Component (*FindNextComponent)(Component prev,ComponentDescription* desc);
|
|
|
|
static OSErr (*GetComponentInfo)(Component prev,ComponentDescription* desc,Handle h1,Handle h2,Handle h3);
|
|
|
|
static long (*CountComponents)(ComponentDescription* desc);
|
|
|
|
static OSErr (*InitializeQTML)(long flags);
|
|
|
|
static OSErr (*EnterMovies)(void);
|
|
|
|
static ComponentInstance (*OpenComponent)(Component c);
|
|
|
|
static ComponentResult (*ImageCodecInitialize)(ComponentInstance ci,
|
|
|
|
ImageSubCodecDecompressCapabilities * cap);
|
|
|
|
static ComponentResult (*ImageCodecBeginBand)(ComponentInstance ci,
|
|
|
|
CodecDecompressParams * params,
|
|
|
|
ImageSubCodecDecompressRecord * drp,
|
|
|
|
long flags);
|
|
|
|
static ComponentResult (*ImageCodecDrawBand)(ComponentInstance ci,
|
|
|
|
ImageSubCodecDecompressRecord * drp);
|
|
|
|
static ComponentResult (*ImageCodecEndBand)(ComponentInstance ci,
|
|
|
|
ImageSubCodecDecompressRecord * drp,
|
|
|
|
OSErr result,
|
|
|
|
long flags);
|
|
|
|
static ComponentResult (*ImageCodecGetCodecInfo)(ComponentInstance ci,
|
|
|
|
CodecInfo * info);
|
|
|
|
static ComponentResult (*ImageCodecPreDecompress)(ComponentInstance ci,
|
|
|
|
CodecDecompressParams * params);
|
|
|
|
static ComponentResult (*ImageCodecBandDecompress)(ComponentInstance ci,
|
|
|
|
CodecDecompressParams * params);
|
|
|
|
static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld);
|
|
|
|
static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw,
|
|
|
|
OSType pixelFormat,
|
|
|
|
const Rect *boundsRect,
|
|
|
|
CTabHandle cTable,
|
|
|
|
/*GDHandle*/void* aGDevice, //unused anyway
|
|
|
|
GWorldFlags flags,
|
|
|
|
void *baseAddr,
|
|
|
|
long rowBytes);
|
|
|
|
static OSErr (*NewHandleClear)(Size byteCount);
|
2003-02-25 15:39:36 +00:00
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
// to set/get/query special features/parameters
|
|
|
|
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
|
|
return CONTROL_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int codec_inited=0;
|
|
|
|
|
|
|
|
// init driver
|
|
|
|
static int init(sh_video_t *sh){
|
|
|
|
long result = 1;
|
|
|
|
ComponentResult cres;
|
|
|
|
ComponentDescription desc;
|
|
|
|
Component prev=NULL;
|
|
|
|
CodecInfo cinfo; // for ImageCodecGetCodecInfo()
|
|
|
|
ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize()
|
|
|
|
|
2003-02-25 15:39:36 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
EnterMovies();
|
|
|
|
#else
|
|
|
|
|
2003-02-12 15:39:59 +00:00
|
|
|
#ifdef WIN32_LOADER
|
2002-11-24 21:49:52 +00:00
|
|
|
Setup_LDT_Keeper();
|
|
|
|
#endif
|
|
|
|
|
2002-11-12 00:06:36 +00:00
|
|
|
handler = LoadLibraryA("qtmlClient.dll");
|
2004-04-13 14:48:31 +00:00
|
|
|
if(!handler){
|
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
|
|
|
|
return 0;
|
|
|
|
}
|
2002-11-12 00:06:36 +00:00
|
|
|
|
2002-12-14 17:56:35 +00:00
|
|
|
InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
|
|
|
|
EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
|
|
|
|
FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent");
|
|
|
|
CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents");
|
|
|
|
GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo");
|
|
|
|
OpenComponent = (ComponentInstance (*)(Component))GetProcAddress(handler, "OpenComponent");
|
|
|
|
ImageCodecInitialize = (ComponentResult (*)(ComponentInstance,ImageSubCodecDecompressCapabilities *))GetProcAddress(handler, "ImageCodecInitialize");
|
|
|
|
ImageCodecGetCodecInfo = (ComponentResult (*)(ComponentInstance,CodecInfo *))GetProcAddress(handler, "ImageCodecGetCodecInfo");
|
|
|
|
ImageCodecBeginBand = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *,ImageSubCodecDecompressRecord *,long))GetProcAddress(handler, "ImageCodecBeginBand");
|
|
|
|
ImageCodecPreDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecPreDecompress");
|
|
|
|
ImageCodecBandDecompress = (ComponentResult (*)(ComponentInstance,CodecDecompressParams *))GetProcAddress(handler, "ImageCodecBandDecompress");
|
|
|
|
GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
|
|
|
|
QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
|
|
|
|
NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
|
2002-11-12 00:06:36 +00:00
|
|
|
// = GetProcAddress(handler, "");
|
|
|
|
|
|
|
|
if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
|
2002-11-12 00:06:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-11-12 00:13:31 +00:00
|
|
|
result=InitializeQTML(6+16);
|
|
|
|
// result=InitializeQTML(0);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %i\n",result);
|
2002-11-12 00:13:31 +00:00
|
|
|
// result=EnterMovies();
|
|
|
|
// printf("EnterMovies->%d\n",result);
|
2003-02-25 15:39:36 +00:00
|
|
|
#endif /* !MACOSX */
|
2002-11-12 00:06:36 +00:00
|
|
|
|
2002-12-11 21:26:37 +00:00
|
|
|
#if 0
|
|
|
|
memset(&desc,0,sizeof(desc));
|
|
|
|
while((prev=FindNextComponent(prev,&desc))){
|
|
|
|
ComponentDescription desc2;
|
|
|
|
unsigned char* c1=&desc2.componentType;
|
|
|
|
unsigned char* c2=&desc2.componentSubType;
|
|
|
|
memset(&desc2,0,sizeof(desc2));
|
|
|
|
// printf("juhee %p (%p)\n",prev,&desc);
|
|
|
|
GetComponentInfo(prev,&desc2,NULL,NULL,NULL);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n",
|
2002-12-11 21:26:37 +00:00
|
|
|
c1[3],c1[2],c1[1],c1[0],
|
|
|
|
c2[3],c2[2],c2[1],c2[0],
|
|
|
|
desc2.componentType,desc2.componentSubType,
|
|
|
|
desc2.componentFlags);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2002-11-12 00:06:36 +00:00
|
|
|
memset(&desc,0,sizeof(desc));
|
|
|
|
desc.componentType= (((unsigned char)'i')<<24)|
|
|
|
|
(((unsigned char)'m')<<16)|
|
|
|
|
(((unsigned char)'d')<<8)|
|
|
|
|
(((unsigned char)'c'));
|
2002-11-25 18:04:19 +00:00
|
|
|
#if 0
|
2002-11-12 00:06:36 +00:00
|
|
|
desc.componentSubType=
|
|
|
|
(((unsigned char)'S'<<24))|
|
|
|
|
(((unsigned char)'V')<<16)|
|
|
|
|
(((unsigned char)'Q')<<8)|
|
|
|
|
(((unsigned char)'3'));
|
2002-11-25 18:04:19 +00:00
|
|
|
#else
|
|
|
|
desc.componentSubType = bswap_32(sh->format);
|
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
desc.componentManufacturer=0;
|
|
|
|
desc.componentFlags=0;
|
|
|
|
desc.componentFlagsMask=0;
|
|
|
|
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %d\n",CountComponents(&desc));
|
2002-11-12 00:06:36 +00:00
|
|
|
prev=FindNextComponent(NULL,&desc);
|
|
|
|
if(!prev){
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n");
|
2002-11-25 18:04:19 +00:00
|
|
|
return(0);
|
2002-11-12 00:06:36 +00:00
|
|
|
}
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = 0x%X\n",prev);
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
ci=OpenComponent(prev);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci);
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
memset(&icap,0,sizeof(icap));
|
|
|
|
cres=ImageCodecInitialize(ci,&icap);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%p size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize);
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
memset(&cinfo,0,sizeof(cinfo));
|
|
|
|
cres=ImageCodecGetCodecInfo(ci,&cinfo);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n",
|
2002-11-12 00:06:36 +00:00
|
|
|
cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0],
|
2002-11-12 00:06:36 +00:00
|
|
|
((unsigned char*)&cinfo.typeName)+1);
|
|
|
|
|
|
|
|
//make a yuy2 gworld
|
|
|
|
OutBufferRect.top=0;
|
|
|
|
OutBufferRect.left=0;
|
|
|
|
OutBufferRect.right=sh->disp_w;
|
|
|
|
OutBufferRect.bottom=sh->disp_h;
|
|
|
|
|
|
|
|
//Fill the imagedescription for our SVQ3 frame
|
|
|
|
//we can probably get this from Demuxer
|
|
|
|
#if 0
|
|
|
|
framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200);
|
|
|
|
printf("framedescHandle=%p *p=%p\n",framedescHandle,*framedescHandle);
|
|
|
|
{ FILE* f=fopen("/root/.wine/fake_windows/IDesc","r");
|
|
|
|
if(!f) printf("filenot found: IDesc\n");
|
|
|
|
fread(*framedescHandle,sizeof(ImageDescription)+200,1,f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
#else
|
2002-12-16 01:49:39 +00:00
|
|
|
if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
|
2002-11-27 23:47:14 +00:00
|
|
|
framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
|
|
|
|
memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
|
2002-12-16 01:49:39 +00:00
|
|
|
dump_ImageDescription(*framedescHandle);
|
2002-11-12 00:06:36 +00:00
|
|
|
#endif
|
|
|
|
//Find codecscomponent for video decompression
|
|
|
|
// result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor );
|
|
|
|
// printf("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor);
|
|
|
|
|
2004-08-28 20:59:49 +00:00
|
|
|
sh->context = (void *)kYUVSPixelFormat;
|
2002-11-27 23:47:14 +00:00
|
|
|
#if 1
|
2002-11-25 18:04:19 +00:00
|
|
|
{
|
|
|
|
int imgfmt = sh->codec->outfmt[sh->outfmtidx];
|
|
|
|
int qt_imgfmt;
|
|
|
|
switch(imgfmt)
|
|
|
|
{
|
|
|
|
case IMGFMT_YUY2:
|
|
|
|
qt_imgfmt = kYUVSPixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_YVU9:
|
2002-11-27 23:47:14 +00:00
|
|
|
qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
qt_imgfmt = 0x79343230;
|
2002-11-25 18:04:19 +00:00
|
|
|
break;
|
|
|
|
case IMGFMT_UYVY:
|
|
|
|
qt_imgfmt = kUYVY422PixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_YVYU:
|
|
|
|
qt_imgfmt = kYVYU422PixelFormat;
|
|
|
|
imgfmt = IMGFMT_YUY2;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB16:
|
|
|
|
qt_imgfmt = k16LE555PixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
qt_imgfmt = k24BGRPixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR32:
|
|
|
|
qt_imgfmt = k32BGRAPixelFormat;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB32:
|
|
|
|
qt_imgfmt = k32RGBAPixelFormat;
|
|
|
|
break;
|
|
|
|
default:
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
|
2002-11-25 18:04:19 +00:00
|
|
|
return(0);
|
|
|
|
}
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), &qt_imgfmt);
|
2004-08-28 20:59:49 +00:00
|
|
|
sh->context = (void *)qt_imgfmt;
|
2002-11-25 18:04:19 +00:00
|
|
|
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
|
|
|
|
}
|
|
|
|
#else
|
2002-11-12 00:06:36 +00:00
|
|
|
if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
|
2002-11-25 18:04:19 +00:00
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// uninit driver
|
|
|
|
static void uninit(sh_video_t *sh){
|
2003-02-25 15:39:36 +00:00
|
|
|
#ifdef MACOSX
|
|
|
|
ExitMovies();
|
|
|
|
#endif
|
2002-11-12 00:06:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// decode a frame
|
|
|
|
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
|
|
|
|
long result = 1;
|
2002-12-01 00:09:13 +00:00
|
|
|
int i;
|
2002-11-12 00:06:36 +00:00
|
|
|
mp_image_t* mpi;
|
|
|
|
ComponentResult cres;
|
2002-12-16 02:38:37 +00:00
|
|
|
|
|
|
|
if(len<=0) return NULL; // skipped frame
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
|
|
|
|
sh->disp_w, sh->disp_h);
|
|
|
|
if(!mpi) return NULL;
|
|
|
|
|
|
|
|
decpar.data = (char*)data;
|
|
|
|
decpar.bufferSize = len;
|
|
|
|
(**framedescHandle).dataSize=len;
|
|
|
|
|
|
|
|
if(!codec_inited){
|
|
|
|
result = QTNewGWorldFromPtr(
|
|
|
|
&OutBufferGWorld,
|
2002-11-25 18:04:19 +00:00
|
|
|
// kYUVSPixelFormat, //pixel format of new GWorld == YUY2
|
2004-08-28 20:59:49 +00:00
|
|
|
(OSType)sh->context,
|
2002-11-12 00:06:36 +00:00
|
|
|
&OutBufferRect, //we should benchmark if yvu9 is faster for svq3, too
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
mpi->planes[0],
|
|
|
|
mpi->stride[0]);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"NewGWorldFromPtr returned:%d\n",65536-(result&0xffff));
|
2002-11-25 18:04:19 +00:00
|
|
|
// if (65536-(result&0xFFFF) != 10000)
|
|
|
|
// return NULL;
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
// printf("IDesc=%d\n",sizeof(ImageDescription));
|
|
|
|
|
|
|
|
decpar.imageDescription = framedescHandle;
|
|
|
|
decpar.startLine=0;
|
|
|
|
decpar.stopLine=(**framedescHandle).height;
|
|
|
|
decpar.frameNumber = 1; //1
|
|
|
|
// decpar.conditionFlags=0xFFD; // first
|
|
|
|
// decpar.callerFlags=0x2001; // first
|
|
|
|
decpar.matrixFlags = 0;
|
|
|
|
decpar.matrixType = 0;
|
|
|
|
decpar.matrix = 0;
|
|
|
|
decpar.capabilities=&codeccap;
|
|
|
|
// decpar.accuracy = 0x1680000; //codecNormalQuality;
|
|
|
|
decpar.accuracy = codecNormalQuality;
|
2002-12-11 22:07:03 +00:00
|
|
|
// decpar.port = OutBufferGWorld;
|
2002-11-12 00:06:36 +00:00
|
|
|
// decpar.preferredOffscreenPixelSize=17207;
|
|
|
|
|
|
|
|
// decpar.sequenceID=malloc(1000);
|
|
|
|
// memset(decpar.sequenceID,0,1000);
|
|
|
|
|
|
|
|
// SrcRect.top=17207;
|
|
|
|
// SrcRect.left=0;
|
|
|
|
// SrcRect.right=0;//image_width;
|
|
|
|
// SrcRect.bottom=0;//image_height;
|
|
|
|
|
|
|
|
// decpar.srcRect = SrcRect;
|
|
|
|
decpar.srcRect = OutBufferRect;
|
|
|
|
|
|
|
|
decpar.transferMode = srcCopy;
|
|
|
|
decpar.dstPixMap = **GetGWorldPixMap( OutBufferGWorld);//destPixmap;
|
|
|
|
|
|
|
|
cres=ImageCodecPreDecompress(ci,&decpar);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%X\n",cres);
|
2002-12-11 21:39:05 +00:00
|
|
|
|
|
|
|
if(decpar.wantedDestinationPixelTypes)
|
|
|
|
{ OSType *p=*(decpar.wantedDestinationPixelTypes);
|
|
|
|
if(p) while(*p){
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"supported csp: 0x%08X %.4s\n",*p,p);
|
2002-12-11 21:39:05 +00:00
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-12 00:06:36 +00:00
|
|
|
|
|
|
|
// decpar.conditionFlags=0x10FFF; // first
|
|
|
|
// decpar.preferredOffscreenPixelSize=17207;
|
|
|
|
|
|
|
|
// decpar.conditionFlags=0x10FFD; // first
|
|
|
|
|
|
|
|
// cres=ImageCodecPreDecompress(ci,&decpar);
|
|
|
|
// printf("ImageCodecPreDecompress cres=0x%X\n",cres);
|
|
|
|
|
|
|
|
|
|
|
|
codec_inited=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if(decpar.frameNumber==124){
|
|
|
|
decpar.frameNumber=1;
|
|
|
|
cres=ImageCodecPreDecompress(ci,&decpar);
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecPreDecompress cres=0x%X\n",cres);
|
2002-11-12 00:06:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
cres=ImageCodecBandDecompress(ci,&decpar);
|
|
|
|
|
|
|
|
++decpar.frameNumber;
|
2002-12-01 00:09:13 +00:00
|
|
|
|
|
|
|
if(cres&0xFFFF){
|
2004-04-13 14:48:31 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecBandDecompress cres=0x%X (-0x%X) %d\n",cres,-cres,cres);
|
2002-12-01 00:09:13 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// for(i=0;i<8;i++)
|
|
|
|
// printf("img_base[%d]=%p\n",i,((int*)decpar.dstPixMap.baseAddr)[i]);
|
|
|
|
|
|
|
|
if((int)sh->context==0x73797639){ // Sorenson 16-bit YUV -> std YVU9
|
|
|
|
|
2002-12-14 17:56:35 +00:00
|
|
|
short *src0=(short *)((char*)decpar.dstPixMap.baseAddr+0x20);
|
2002-12-01 00:09:13 +00:00
|
|
|
|
|
|
|
for(i=0;i<mpi->h;i++){
|
|
|
|
int x;
|
|
|
|
unsigned char* dst=mpi->planes[0]+i*mpi->stride[0];
|
|
|
|
unsigned short* src=src0+i*((mpi->w+15)&(~15));
|
|
|
|
for(x=0;x<mpi->w;x++) dst[x]=src[x];
|
|
|
|
}
|
|
|
|
src0+=((mpi->w+15)&(~15))*((mpi->h+15)&(~15));
|
|
|
|
for(i=0;i<mpi->h/4;i++){
|
|
|
|
int x;
|
|
|
|
unsigned char* dst=mpi->planes[1]+i*mpi->stride[1];
|
|
|
|
unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4);
|
|
|
|
for(x=0;x<mpi->w/4;x++) dst[x]=src[x];
|
|
|
|
src+=((mpi->w+63)&(~63))/4;
|
|
|
|
}
|
|
|
|
src0+=(((mpi->w+63)&(~63))/4)*(((mpi->h+63)&(~63))/4);
|
|
|
|
for(i=0;i<mpi->h/4;i++){
|
|
|
|
int x;
|
|
|
|
unsigned char* dst=mpi->planes[2]+i*mpi->stride[2];
|
|
|
|
unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4);
|
|
|
|
for(x=0;x<mpi->w/4;x++) dst[x]=src[x];
|
|
|
|
src+=((mpi->w+63)&(~63))/4;
|
|
|
|
}
|
2002-11-12 00:06:36 +00:00
|
|
|
|
2002-12-01 00:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-12 00:06:36 +00:00
|
|
|
return mpi;
|
|
|
|
}
|
|
|
|
#endif
|