📄 quicktime.c
字号:
desc.componentSubType = FCC( fcc[0], fcc[1], fcc[2], fcc[3] ); desc.componentManufacturer = 0; desc.componentFlags = 0; desc.componentFlagsMask = 0; if( !( prev = p_sys->FindNextComponent( NULL, &desc ) ) ) { msg_Err( p_dec, "cannot find requested component" ); goto exit_error; } msg_Dbg( p_dec, "component id=0x%p", prev ); p_sys->ci = p_sys->OpenComponent( prev ); msg_Dbg( p_dec, "component instance p=0x%p", p_sys->ci ); memset( &icap, 0, sizeof( ImageSubCodecDecompressCapabilities ) ); cres = p_sys->ImageCodecInitialize( p_sys->ci, &icap ); msg_Dbg( p_dec, "ImageCodecInitialize->0x%X size=%d (%d)\n", (int)cres, (int)icap.recordSize, (int)icap.decompressRecordSize); memset( &cinfo, 0, sizeof( CodecInfo ) ); cres = p_sys->ImageCodecGetCodecInfo( p_sys->ci, &cinfo ); msg_Dbg( p_dec, "Flags: compr: 0x%x decomp: 0x%x format: 0x%x\n", (unsigned int)cinfo.compressFlags, (unsigned int)cinfo.decompressFlags, (unsigned int)cinfo.formatFlags ); msg_Dbg( p_dec, "quicktime_video: Codec name: %.*s\n", ((unsigned char*)&cinfo.typeName)[0], ((unsigned char*)&cinfo.typeName)+1 ); /* make a yuy2 gworld */ p_sys->OutBufferRect.top = 0; p_sys->OutBufferRect.left = 0; p_sys->OutBufferRect.right = p_dec->fmt_in.video.i_width; p_sys->OutBufferRect.bottom = p_dec->fmt_in.video.i_height; /* codec data FIXME use codec not SVQ3 */ msg_Dbg( p_dec, "vide = %d", i_vide ); id = malloc( sizeof( ImageDescription ) + ( i_vide - 70 ) ); if( !id ) goto exit_error; id->idSize = sizeof( ImageDescription ) + ( i_vide - 70 ); id->cType = FCC( fcc[0], fcc[1], fcc[2], fcc[3] ); id->version = GetWBE ( p_vide + 0 ); id->revisionLevel = GetWBE ( p_vide + 2 ); id->vendor = GetDWBE( p_vide + 4 ); id->temporalQuality = GetDWBE( p_vide + 8 ); id->spatialQuality = GetDWBE( p_vide + 12 ); id->width = GetWBE ( p_vide + 16 ); id->height = GetWBE ( p_vide + 18 ); id->hRes = GetDWBE( p_vide + 20 ); id->vRes = GetDWBE( p_vide + 24 ); id->dataSize = GetDWBE( p_vide + 28 ); id->frameCount = GetWBE ( p_vide + 32 ); memcpy( &id->name, p_vide + 34, 32 ); id->depth = GetWBE ( p_vide + 66 ); id->clutID = GetWBE ( p_vide + 68 ); if( i_vide > 70 ) { memcpy( ((char*)&id->clutID) + 2, p_vide + 70, i_vide - 70 ); } msg_Dbg( p_dec, "idSize=%d ver=%d rev=%d vendor=%d tempQ=%d " "spaQ=%d w=%d h=%d dpi=%d%d dataSize=%d depth=%d frameCount=%d clutID=%d", (int)id->idSize, id->version, id->revisionLevel, (int)id->vendor, (int)id->temporalQuality, (int)id->spatialQuality, (int)id->width, (int)id->height, (int)id->hRes, (int)id->vRes, (int)id->dataSize, id->depth, id->frameCount, id->clutID ); p_sys->framedescHandle = (ImageDescriptionHandle) NewHandleClear( id->idSize ); memcpy( *p_sys->framedescHandle, id, id->idSize ); if( p_dec->fmt_in.video.i_width != 0 && p_dec->fmt_in.video.i_height != 0) p_sys->plane = malloc( p_dec->fmt_in.video.i_width * p_dec->fmt_in.video.i_height * 3 ); if( !p_sys->plane ) goto exit_error; i_result = p_sys->QTNewGWorldFromPtr( &p_sys->OutBufferGWorld, /*pixel format of new GWorld==YUY2 */ kYUVSPixelFormat, /* we should benchmark if yvu9 is * faster for svq3, too */ &p_sys->OutBufferRect, 0, 0, 0, p_sys->plane, p_dec->fmt_in.video.i_width * 2 ); msg_Dbg( p_dec, "NewGWorldFromPtr returned:%ld\n", 65536 - ( i_result&0xffff ) ); memset( &p_sys->decpar, 0, sizeof( CodecDecompressParams ) ); p_sys->decpar.imageDescription = p_sys->framedescHandle; p_sys->decpar.startLine = 0; p_sys->decpar.stopLine = ( **p_sys->framedescHandle ).height; p_sys->decpar.frameNumber = 1; p_sys->decpar.matrixFlags = 0; p_sys->decpar.matrixType = 0; p_sys->decpar.matrix = 0; p_sys->decpar.capabilities = &p_sys->codeccap; p_sys->decpar.accuracy = codecNormalQuality; p_sys->decpar.srcRect = p_sys->OutBufferRect; p_sys->decpar.transferMode = srcCopy; p_sys->decpar.dstPixMap = **p_sys->GetGWorldPixMap( p_sys->OutBufferGWorld );/*destPixmap; */ cres = p_sys->ImageCodecPreDecompress( p_sys->ci, &p_sys->decpar ); msg_Dbg( p_dec, "quicktime_video: ImageCodecPreDecompress cres=0x%X\n", (int)cres ); es_format_Init( &p_dec->fmt_out, VIDEO_ES, VLC_FOURCC( 'Y', 'U', 'Y', '2' )); p_dec->fmt_out.video.i_width = p_dec->fmt_in.video.i_width; p_dec->fmt_out.video.i_height= p_dec->fmt_in.video.i_height; p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height; vlc_mutex_unlock( lock ); return VLC_SUCCESS;exit_error:#ifdef LOADER Restore_LDT_Keeper( p_sys->ldt_fs );#endif vlc_mutex_unlock( lock );#endif /* !WIN32 */ return VLC_EGENERIC;}#ifndef WIN32/***************************************************************************** * DecodeVideo: *****************************************************************************/static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block ){ decoder_sys_t *p_sys = p_dec->p_sys; vlc_mutex_t *lock; block_t *p_block; picture_t *p_pic; mtime_t i_pts; ComponentResult cres;#ifdef LOADER /* We must do open and close in the same thread (unless we do * Setup_LDT_Keeper in the main thread before all others */ if( p_sys == NULL ) { if( OpenVideo( p_dec ) ) { /* Fatal */ p_dec->b_error = true; return NULL; } p_sys = p_dec->p_sys; }#endif if( pp_block == NULL || *pp_block == NULL ) { return NULL; } p_block = *pp_block; *pp_block = NULL; i_pts = p_block->i_pts ? p_block->i_pts : p_block->i_dts; if( decoder_GetDisplayDate( p_dec, i_pts ) < mdate() ) { p_sys->i_late++; } else { p_sys->i_late = 0; }#ifndef NDEBUG msg_Dbg( p_dec, "bufsize: %d", (int)p_block->i_buffer);#endif if( p_sys->i_late > 10 ) { msg_Dbg( p_dec, "late buffer dropped (%"PRId64")", i_pts ); block_Release( p_block ); return NULL; } lock = var_AcquireMutex( "qt_mutex" ); if( ( p_pic = p_dec->pf_vout_buffer_new( p_dec ) ) ) { p_sys->decpar.data = (Ptr)p_block->p_buffer; p_sys->decpar.bufferSize = p_block->i_buffer; (**p_sys->framedescHandle).dataSize = p_block->i_buffer; cres = p_sys->ImageCodecBandDecompress( p_sys->ci, &p_sys->decpar ); ++p_sys->decpar.frameNumber; if( cres &0xFFFF ) { msg_Dbg( p_dec, "quicktime_video: ImageCodecBandDecompress" " cres=0x%X (-0x%X) %d :(\n", (int)cres,(int)-cres, (int)cres ); } memcpy( p_pic->p[0].p_pixels, p_sys->plane, p_dec->fmt_in.video.i_width * p_dec->fmt_in.video.i_height * 2 ); p_pic->date = i_pts; } vlc_mutex_unlock( lock ); block_Release( p_block ); return p_pic;}#endif /* !WIN32 *//***************************************************************************** * QTAudioInit: *****************************************************************************/static int QTAudioInit( decoder_t *p_dec ){ decoder_sys_t *p_sys = p_dec->p_sys;#ifdef __APPLE__ p_sys->SoundConverterOpen = (void*)SoundConverterOpen; p_sys->SoundConverterClose = (void*)SoundConverterClose; p_sys->SoundConverterSetInfo = (void*)SoundConverterSetInfo; p_sys->SoundConverterGetBufferSizes = (void*)SoundConverterGetBufferSizes; p_sys->SoundConverterConvertBuffer = (void*)SoundConverterConvertBuffer; p_sys->SoundConverterBeginConversion= (void*)SoundConverterBeginConversion; p_sys->SoundConverterEndConversion = (void*)SoundConverterEndConversion;#else#ifdef LOADER p_sys->ldt_fs = Setup_LDT_Keeper();#endif /* LOADER */ p_sys->qts = LoadLibraryA( "QuickTime.qts" ); if( p_sys->qts == NULL ) { msg_Dbg( p_dec, "failed loading QuickTime.qts" ); return VLC_EGENERIC; } p_sys->qtml = LoadLibraryA( "qtmlClient.dll" ); if( p_sys->qtml == NULL ) { msg_Dbg( p_dec, "failed loading qtmlClient.dll" ); return VLC_EGENERIC; } p_sys->InitializeQTML = (void *)GetProcAddress( p_sys->qtml, "InitializeQTML" ); p_sys->TerminateQTML = (void *)GetProcAddress( p_sys->qtml, "TerminateQTML" ); p_sys->SoundConverterOpen = (void *)GetProcAddress( p_sys->qtml, "SoundConverterOpen" ); p_sys->SoundConverterClose = (void *)GetProcAddress( p_sys->qtml, "SoundConverterClose" ); p_sys->SoundConverterSetInfo = (void *)GetProcAddress( p_sys->qtml, "SoundConverterSetInfo" ); p_sys->SoundConverterGetBufferSizes = (void *)GetProcAddress( p_sys->qtml, "SoundConverterGetBufferSizes" ); p_sys->SoundConverterConvertBuffer = (void *)GetProcAddress( p_sys->qtml, "SoundConverterConvertBuffer" ); p_sys->SoundConverterEndConversion = (void *)GetProcAddress( p_sys->qtml, "SoundConverterEndConversion" ); p_sys->SoundConverterBeginConversion= (void *)GetProcAddress( p_sys->qtml, "SoundConverterBeginConversion"); if( p_sys->InitializeQTML == NULL ) { msg_Err( p_dec, "failed getting proc address InitializeQTML" ); return VLC_EGENERIC; } if( p_sys->SoundConverterOpen == NULL || p_sys->SoundConverterClose == NULL || p_sys->SoundConverterSetInfo == NULL || p_sys->SoundConverterGetBufferSizes == NULL || p_sys->SoundConverterConvertBuffer == NULL || p_sys->SoundConverterEndConversion == NULL || p_sys->SoundConverterBeginConversion == NULL ) { msg_Err( p_dec, "failed getting proc address" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "standard init done" );#endif /* else __APPLE__ */ return VLC_SUCCESS;}#ifndef WIN32/***************************************************************************** * QTVideoInit: *****************************************************************************/static int QTVideoInit( decoder_t *p_dec ){ decoder_sys_t *p_sys = p_dec->p_sys;#ifdef __APPLE__ p_sys->FindNextComponent = (void*)FindNextComponent; p_sys->OpenComponent = (void*)OpenComponent; p_sys->ImageCodecInitialize = (void*)ImageCodecInitialize; p_sys->ImageCodecGetCodecInfo = (void*)ImageCodecGetCodecInfo; p_sys->ImageCodecPreDecompress = (void*)ImageCodecPreDecompress; p_sys->ImageCodecBandDecompress = (void*)ImageCodecBandDecompress; p_sys->GetGWorldPixMap = (void*)GetGWorldPixMap; p_sys->QTNewGWorldFromPtr = (void*)QTNewGWorldFromPtr; p_sys->NewHandleClear = (void*)NewHandleClear;#else#ifdef LOADER p_sys->ldt_fs = Setup_LDT_Keeper();#endif /* LOADER */ p_sys->qts = LoadLibraryA( "QuickTime.qts" ); if( p_sys->qts == NULL ) { msg_Dbg( p_dec, "failed loading QuickTime.qts" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "QuickTime.qts loaded" ); p_sys->qtml = LoadLibraryA( "qtmlClient.dll" ); if( p_sys->qtml == NULL ) { msg_Dbg( p_dec, "failed loading qtmlClient.dll" ); return VLC_EGENERIC; } msg_Dbg( p_dec, "qtmlClient.dll loaded" ); /* (void*) to shut up gcc */ p_sys->InitializeQTML = (void*)GetProcAddress( p_sys->qtml, "InitializeQTML" ); p_sys->FindNextComponent = (void*)GetProcAddress( p_sys->qtml, "FindNextComponent" ); p_sys->OpenComponent = (void*)GetProcAddress( p_sys->qtml, "OpenComponent" ); p_sys->ImageCodecInitialize = (void*)GetProcAddress( p_sys->qtml, "ImageCodecInitialize" ); p_sys->ImageCodecGetCodecInfo = (void*)GetProcAddress( p_sys->qtml, "ImageCodecGetCodecInfo" ); p_sys->ImageCodecPreDecompress = (void*)GetProcAddress( p_sys->qtml, "ImageCodecPreDecompress" ); p_sys->ImageCodecBandDecompress = (void*)GetProcAddress( p_sys->qtml, "ImageCodecBandDecompress" ); p_sys->GetGWorldPixMap = (void*)GetProcAddress( p_sys->qtml, "GetGWorldPixMap" ); p_sys->QTNewGWorldFromPtr = (void*)GetProcAddress( p_sys->qtml, "QTNewGWorldFromPtr" ); p_sys->NewHandleClear = (void*)GetProcAddress( p_sys->qtml, "NewHandleClear" ); if( p_sys->InitializeQTML == NULL ) { msg_Dbg( p_dec, "failed getting proc address InitializeQTML" ); return VLC_EGENERIC; } if( p_sys->FindNextComponent == NULL || p_sys->OpenComponent == NULL || p_sys->ImageCodecInitialize == NULL || p_sys->ImageCodecGetCodecInfo == NULL || p_sys->ImageCodecPreDecompress == NULL || p_sys->ImageCodecBandDecompress == NULL || p_sys->GetGWorldPixMap == NULL || p_sys->QTNewGWorldFromPtr == NULL || p_sys->NewHandleClear == NULL ) { msg_Err( p_dec, "failed getting proc address" ); return VLC_EGENERIC; }#endif /* __APPLE__ */ return VLC_SUCCESS;}#endif /* !WIN32 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -