int MovDecoder_InitSubsystem() { long result = 1; ComponentResult cres; ComponentDescription desc; Component prev=NULL; CodecInfo cinfo; // for ImageCodecGetCodecInfo() //ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll qtime_qts = LoadLibraryA("QuickTime.qts"); if (!qtime_qts) { //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" ); return 0; } handler = LoadLibraryA("qtmlClient.dll"); if(!handler) { //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n"); return 0; } result=InitializeQTML(6+16); //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result); memset(&desc,0,sizeof(desc)); desc.componentType= (((unsigned char)'i')<<24)|(((unsigned char)'m')<<16)|(((unsigned char)'d')<<8)|(((unsigned char)'c')); desc.componentSubType = bswap_32(sh->format); desc.componentManufacturer=0; desc.componentFlags=0; desc.componentFlagsMask=0; // mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc)); prev=FindNextComponent(NULL,&desc); if(!prev) { //mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n"); return(0); } //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev); ci=OpenComponent(prev); //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci); memset(&icap,0,sizeof(icap)); cres=ImageCodecInitialize(ci,&icap); //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize); memset(&cinfo,0,sizeof(cinfo)); cres=ImageCodecGetCodecInfo(ci,&cinfo); //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); //mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], ((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(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize); framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize); memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize); dump_ImageDescription(*framedescHandle); //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); sh->context = (void *)kYUVSPixelFormat; #if 1 { int imgfmt = sh->codec->outfmt[sh->outfmtidx]; int qt_imgfmt; switch(imgfmt) { case IMGFMT_YUY2: qt_imgfmt = kYUVSPixelFormat; break; case IMGFMT_YVU9: qt_imgfmt = 0x73797639; //kYVU9PixelFormat; break; case IMGFMT_YV12: qt_imgfmt = 0x79343230; 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: mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n"); return(0); } mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt); sh->context = (void *)qt_imgfmt; if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0; } return 1; }
// init driver static int init(sh_video_t *sh){ #ifndef CONFIG_QUICKTIME long result = 1; #endif ComponentResult cres; ComponentDescription desc; Component prev=NULL; CodecInfo cinfo; // for ImageCodecGetCodecInfo() ImageSubCodecDecompressCapabilities icap; // for ImageCodecInitialize() codec_initialized = 0; #ifdef CONFIG_QUICKTIME EnterMovies(); #else #ifdef WIN32_LOADER Setup_LDT_Keeper(); #endif //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll qtime_qts = LoadLibraryA("QuickTime.qts"); if(!qtime_qts){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" ); return 0; } handler = LoadLibraryA("qtmlClient.dll"); if(!handler){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n"); return 0; } 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"); // = GetProcAddress(handler, ""); if(!InitializeQTML || !EnterMovies || !FindNextComponent || !ImageCodecBandDecompress){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n"); return 0; } result=InitializeQTML(6+16); // result=InitializeQTML(0); mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %li\n",result); // result=EnterMovies(); // printf("EnterMovies->%d\n",result); #endif /* CONFIG_QUICKTIME */ #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); mp_msg(MSGT_DECVIDEO,MSGL_DGB2,"DESC: %c%c%c%c/%c%c%c%c [0x%X/0x%X] 0x%X\n", c1[3],c1[2],c1[1],c1[0], c2[3],c2[2],c2[1],c2[0], desc2.componentType,desc2.componentSubType, desc2.componentFlags); } #endif memset(&desc,0,sizeof(desc)); desc.componentType= (((unsigned char)'i')<<24)| (((unsigned char)'m')<<16)| (((unsigned char)'d')<<8)| (((unsigned char)'c')); #if 0 desc.componentSubType= (((unsigned char)'S'<<24))| (((unsigned char)'V')<<16)| (((unsigned char)'Q')<<8)| (((unsigned char)'3')); #else desc.componentSubType = bswap_32(sh->format); #endif desc.componentManufacturer=0; desc.componentFlags=0; desc.componentFlagsMask=0; mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Count = %ld\n",CountComponents(&desc)); prev=FindNextComponent(NULL,&desc); if(!prev){ mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Cannot find requested component\n"); return 0; } mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Found it! ID = %p\n",prev); ci=OpenComponent(prev); mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ci=%p\n",ci); memset(&icap,0,sizeof(icap)); cres=ImageCodecInitialize(ci,&icap); mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageCodecInitialize->%#x size=%d (%d)\n",cres,icap.recordSize,icap.decompressRecordSize); memset(&cinfo,0,sizeof(cinfo)); cres=ImageCodecGetCodecInfo(ci,&cinfo); mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Flags: compr: 0x%X decomp: 0x%X format: 0x%X\n", cinfo.compressFlags, cinfo.decompressFlags, cinfo.formatFlags); mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"Codec name: %.*s\n",((unsigned char*)&cinfo.typeName)[0], ((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 if(!sh->ImageDesc) sh->ImageDesc=(sh->bih+1); // hack for SVQ3-in-AVI mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize); framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize); memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize); dump_ImageDescription(*framedescHandle); #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); sh->context = (void *)kYUVSPixelFormat; #if 1 { int imgfmt = sh->codec->outfmt[sh->outfmtidx]; int qt_imgfmt; switch(imgfmt) { case IMGFMT_YUY2: qt_imgfmt = kYUVSPixelFormat; break; case IMGFMT_YVU9: qt_imgfmt = 0x73797639; //kYVU9PixelFormat; break; case IMGFMT_YV12: qt_imgfmt = 0x79343230; 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: mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n"); return 0; } mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt); sh->context = (void *)qt_imgfmt; if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0; } #else if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0; #endif return 1; }
gboolean get_output_info_from_component (Component componentID) { gboolean ret = FALSE; ComponentInstance instance; ImageSubCodecDecompressCapabilities caps; CodecInfo info; GST_LOG ("Creating an instance"); /* 1. Create an instance */ if (!(instance = OpenComponent (componentID))) { GST_WARNING ("Couldn't open component"); return FALSE; } /* 2. initialize */ memset (&caps, 0, sizeof (ImageSubCodecDecompressCapabilities)); if (ImageCodecInitialize (instance, &caps) != noErr) { GST_WARNING ("ImageCodecInitialize() failed"); goto beach; } #if DEBUG_DUMP GST_LOG ("ImageSubCodecDecompressCapabilities"); gst_util_dump_mem ((const guchar *) &caps, sizeof (ImageSubCodecDecompressCapabilities)); #endif GST_LOG ("recordSize:%ld", caps.recordSize); GST_LOG ("decompressRecordSize:%ld", caps.decompressRecordSize); GST_LOG ("canAsync:%d", caps.canAsync); /* 3. Get codec info */ memset (&info, 0, sizeof (CodecInfo)); if (ImageCodecGetCodecInfo (instance, &info) != noErr) { GST_WARNING ("ImageCodecInfo() failed"); goto beach; }; #if DEBUG_DUMP GST_LOG ("CodecInfo"); gst_util_dump_mem ((const guchar *) &info, sizeof (CodecInfo)); #endif GST_LOG ("version:%d", info.version); GST_LOG ("revisionLevel:%d", info.revisionLevel); GST_LOG ("vendor:%" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (info.vendor)); /* Compression flags */ /* Contains flags (see below) that specify the decompression capabilities of * the component. Typically, these flags are of interest only to developers of * image decompressors. */ GST_LOG ("decompressFlags:%lx", info.decompressFlags); if (info.decompressFlags & codecInfoDoes1) GST_LOG ("Depth 1 OK"); if (info.decompressFlags & codecInfoDoes2) GST_LOG ("Depth 2 OK"); if (info.decompressFlags & codecInfoDoes4) GST_LOG ("Depth 4 OK"); if (info.decompressFlags & codecInfoDoes8) GST_LOG ("Depth 8 OK"); if (info.decompressFlags & codecInfoDoes16) GST_LOG ("Depth 16 OK"); if (info.decompressFlags & codecInfoDoes32) GST_LOG ("Depth 32 OK"); GST_LOG ("compressFlags:%lx", info.compressFlags); /* Format FLAGS */ /* Contains flags (see below) that describe the possible format for compressed * data produced by this component and the format of compressed files that the * component can handle during decompression. Typically, these flags are of * interest only to developers of compressor components. */ GST_LOG ("formatFlags:%lx", info.formatFlags); if (info.formatFlags & codecInfoDepth1) GST_LOG ("Depth 1 OK"); if (info.formatFlags & codecInfoDepth2) GST_LOG ("Depth 2 OK"); if (info.formatFlags & codecInfoDepth4) GST_LOG ("Depth 4 OK"); if (info.formatFlags & codecInfoDepth8) GST_LOG ("Depth 8 OK"); if (info.formatFlags & codecInfoDepth16) GST_LOG ("Depth 16 OK"); if (info.formatFlags & codecInfoDepth24) GST_LOG ("Depth 24 OK"); if (info.formatFlags & codecInfoDepth32) GST_LOG ("Depth 32 OK"); if (info.formatFlags & codecInfoDepth33) GST_LOG ("Depth 33 OK"); if (info.formatFlags & codecInfoDepth34) GST_LOG ("Depth 34 OK"); if (info.formatFlags & codecInfoDepth36) GST_LOG ("Depth 36 OK"); if (info.formatFlags & codecInfoDepth40) GST_LOG ("Depth 40 OK"); if (info.formatFlags & codecInfoStoresClut) GST_LOG ("StoresClut OK"); if (info.formatFlags & codecInfoDoesLossless) GST_LOG ("Lossless OK"); if (info.formatFlags & codecInfoSequenceSensitive) GST_LOG ("SequenceSentitive OK"); GST_LOG ("compressionAccuracy:%u", info.compressionAccuracy); GST_LOG ("decompressionAccuracy:%u", info.decompressionAccuracy); GST_LOG ("compressionSpeed:%d", info.compressionSpeed); GST_LOG ("decompressionSpeed:%d", info.decompressionSpeed); GST_LOG ("compressionLevel:%u", info.compressionLevel); GST_LOG ("minimumHeight:%d", info.minimumHeight); GST_LOG ("minimumWidth:%d", info.minimumWidth); /* /\* . Call ImageCodecPreDecompress *\/ */ /* memset(¶ms, 0, sizeof(CodecDecompressParams)); */ /* GST_LOG ("calling imagecodecpredecompress"); */ /* if (ImageCodecPreDecompress (instance, ¶ms) != noErr) { */ /* GST_WARNING ("Error in ImageCodecPreDecompress"); */ /* goto beach; */ /* } */ /* GST_INFO ("sequenceID : %d", params.sequenceID); */ ret = TRUE; beach: /* Free instance */ CloseComponent (instance); return TRUE; }