예제 #1
0
void _HYPlatformGraphicPane::_SavePicture	(_String prompt)
{
	InitializeQTExporters  ();
	if (graphicsFormats.lLength)
	{
		_String filePath;
		long 	menuChoice = SaveFileWithPopUp (filePath,
											      savePicPrompt,prompt,savePicAs,graphicsFormats);
	
		if (menuChoice>=0)
		{
			ComponentInstance grexc = OpenComponent ((Component)qtGrexComponents(menuChoice));
			GraphicsExportSetInputGWorld (grexc,thePane);
			FSSpec  fs;
			Str255	buff;
			StringToStr255 (filePath,buff);
			FSMakeFSSpec(0,0,buff,&fs);
			GraphicsExportSetOutputFile (grexc,&fs);
			GraphicsExportRequestSettings (grexc,nil,nil); 		
			unsigned long dummy;
			OSType t,c;		
			GraphicsExportGetDefaultFileTypeAndCreator (grexc,&t,&c);                           
			GraphicsExportSetOutputFileTypeAndCreator (grexc,t,c);
			GraphicsExportDoExport (grexc,&dummy);			
            CloseComponent (grexc);
        }
    }
}				
예제 #2
0
ComponentInstance	SMACIMAsdec::InitializeIMAAudioDecoder(Component inDecoderComponent, const AudioStreamBasicDescription& inFormat)
{
	UInt32 theSize;
	ComponentInstance theDecoder = OpenComponent(inDecoderComponent);
	ThrowIf(theDecoder == NULL, badComponentInstance, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't open the component");
	
	//	first, give the decoder the info we have
	theSize = sizeof(AudioStreamBasicDescription);
	ComponentResult theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentInputFormat, theSize, &inFormat);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the input format");
		
	//	now find out what it can output
	theError = AudioCodecGetPropertyInfo(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, NULL);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output format list size");
	
	UInt32 theNumberAvailableOutputFormats = theSize / sizeof(AudioStreamBasicDescription);
	AudioStreamBasicDescription* theAvailableOutputFormats = new AudioStreamBasicDescription[theNumberAvailableOutputFormats];
	
	try
	{
		theSize = theNumberAvailableOutputFormats * sizeof(AudioStreamBasicDescription);
		theError = AudioCodecGetProperty(theDecoder, kAudioCodecPropertySupportedOutputFormats, &theSize, theAvailableOutputFormats);
		ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error getting the available output formats");
	
		//	find an acceptable output format
		AudioStreamBasicDescription* theOutputFormat = FindNEFloatFormat(theAvailableOutputFormats, theNumberAvailableOutputFormats);
		ThrowIf(theOutputFormat == NULL, badFormat, "SMACIMAsdec::InitializeIMAAudioDecoder: couldn't find an acceptable output format");
		
		// finish filling out the output format
		theOutputFormat->mSampleRate = inFormat.mSampleRate;
		theOutputFormat->mChannelsPerFrame = inFormat.mChannelsPerFrame;
		theOutputFormat->mBytesPerFrame = 4 * inFormat.mChannelsPerFrame;
		theOutputFormat->mFormatID = kAudioFormatLinearPCM;
		theOutputFormat->mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
		theOutputFormat->mBytesPerPacket = 4 * inFormat.mChannelsPerFrame;
		theOutputFormat->mFramesPerPacket = 1;
		theOutputFormat->mBitsPerChannel = 32;

		//	tell the decoder about it
		theSize = sizeof(AudioStreamBasicDescription);
		theError = AudioCodecSetProperty(theDecoder, kAudioCodecPropertyCurrentOutputFormat, theSize, theOutputFormat);
		ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error setting the output format");
		
		delete[] theAvailableOutputFormats;
		theAvailableOutputFormats = NULL;
	}
	catch(...)
	{
		delete[] theAvailableOutputFormats;
		throw;
	}
	
	//	finally initialize the decoder
	theError = AudioCodecInitialize(theDecoder, NULL, NULL, NULL, 0);
	ThrowIfError(theError, (CAException)theError, "SMACIMAsdec::InitializeIMAAudioDecoder: got an error initializing the decoder");
	
	return theDecoder;
}
예제 #3
0
// 2.
// Create the Video Digitizer (using GWorld Pixmap as target mamory)
void QuicktimeLiveImageStream::createVideoDigitizer()
{
    // #define videoDigitizerComponentType = 'vdig'
    ComponentDescription video_component_description;
    video_component_description.componentType         = 'vdig'; /* A unique 4-byte code indentifying the command set */
    video_component_description.componentSubType      = 0;      /* Particular flavor of this instance */
    video_component_description.componentManufacturer = 0;      /* Vendor indentification */
    video_component_description.componentFlags        = 0;      /* 8 each for Component,Type,SubType,Manuf/revision */
    video_component_description.componentFlagsMask    = 0;      /* Mask for specifying which flags to consider in search, zero during registration */
    long num_video_components = CountComponents (&video_component_description);
    OSG_DEBUG << " available Video DigitizerComponents : " << num_video_components << std::endl;
    if (num_video_components)
    {
        Component aComponent = 0;
        short     aDeviceID  = 0;
        do
        {
            ComponentDescription full_video_component_description = video_component_description;
            aComponent = FindNextComponent(aComponent, &full_video_component_description);
            if (aComponent && (aDeviceID == m_videoDeviceID))
            {
                OSG_DEBUG << "Component" << std::endl;
                OSErr                err;
                Handle compName = NewHandle(256);
                Handle compInfo = NewHandle(256);
                err = GetComponentInfo( aComponent, &full_video_component_description, compName,compInfo,0);
                OSG_DEBUG << "    Name: " << pstr_printable((StringPtr)*compName) << std::endl;
                OSG_DEBUG << "    Desc: " << pstr_printable((StringPtr)*compInfo) << std::endl;
                //Capabilities
                VideoDigitizerComponent component_instance = OpenComponent(aComponent);
                m_vdig = component_instance;
                //Setup
                // Onscreen
                // Check capability and setting of Sequence Grabber
                GDHandle origDevice;
                CGrafPtr origPort;
                GetGWorld (&origPort, &origDevice);
                VideoDigitizerError error;
                Rect                destinationBounds;
                destinationBounds.left   = 0;
                destinationBounds.top    = 0;
                destinationBounds.right  = m_videoRectWidth;
                destinationBounds.bottom = m_videoRectHeight;                    
                error = VDSetPlayThruDestination(m_vdig, m_pixmap, &destinationBounds, 0, 0);
                //error = VDSetPlayThruGlobalRect(m_vdig, (GrafPtr)origPort, &destinationBounds);
                if (error != noErr)
                {
                    OSG_FATAL << "VDSetPlayThruDestination : error" << std::endl;
                }
                print_video_component_capability(component_instance);
                break;
            }
            ++aDeviceID;
        }
        while (0 != aComponent);
     }
}
예제 #4
0
static PyObject *CmpObj_OpenComponent(ComponentObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	ComponentInstance _rv;
#ifndef OpenComponent
	PyMac_PRECHECK(OpenComponent);
#endif
	if (!PyArg_ParseTuple(_args, ""))
		return NULL;
	_rv = OpenComponent(_self->ob_itself);
	_res = Py_BuildValue("O&",
	                     CmpInstObj_New, _rv);
	return _res;
}
// 1.
// Create the Sequence Grabber (using GWorld as target memory)
void QuicktimeLiveImageStream::createSequenceGrabber()
{
    ComponentDescription sg_component_description;

    sg_component_description.componentType         = SeqGrabComponentType; /* A unique 4-byte code indentifying the command set */
    sg_component_description.componentSubType      = 0L;      /* Particular flavor of this instance */
    sg_component_description.componentManufacturer = 'appl';  /* Vendor indentification */
    sg_component_description.componentFlags        = 0L;      /* 8 each for Component,Type,SubType,Manuf/revision */
    sg_component_description.componentFlagsMask    = 0L;      /* Mask for specifying which flags to consider in search, zero during registration */
    long num_sg_components = CountComponents (&sg_component_description);
    if (num_sg_components)
    {
        Component            aComponent                    = 0;
        ComponentDescription full_sg_component_description = sg_component_description;
        aComponent = FindNextComponent(aComponent, &full_sg_component_description);
        if (aComponent)
        {
            m_gSeqGrabber = OpenComponent(aComponent);
            // If we got a sequence grabber, set it up
            if (m_gSeqGrabber != 0L)
            {
                // Check capability and setting of Sequence Grabber
                GDHandle origDevice;
                CGrafPtr origPort;
                // Create GWorld
                GetGWorld (&origPort, &origDevice);
                SetGWorld (m_gw, NULL); // set current graphics port to offscreen
                // Initialize the sequence grabber
                ComponentResult result = noErr;
                result = SGInitialize (m_gSeqGrabber);
                if (result == noErr)
                {
                    // Set GWorld
                    result = SGSetGWorld(m_gSeqGrabber, (CGrafPtr)m_gw, 0);
                    if (result != noErr)
                    {
                        OSG_FATAL << "Could not set GWorld on SG" << std::endl;
                    }
                }

                // Set GWorld back
                SetGWorld(origPort, origDevice);
            }
        }
    }
}
예제 #6
0
//------------------------------------------------------
bool ofVideoGrabber::qtInitSeqGrabber(){

		if (bSgInited != true){

			OSErr err = noErr;

			ComponentDescription	theDesc;
			Component				sgCompID;

			// this crashes when we get to
			// SGNewChannel
			// we get -9405 as error code for the channel
			// -----------------------------------------
			// gSeqGrabber = OpenDefaultComponent(SeqGrabComponentType, 0);

			// this seems to work instead (got it from hackTV)
			// -----------------------------------------
			theDesc.componentType = SeqGrabComponentType;
			theDesc.componentSubType = NULL;
			theDesc.componentManufacturer = 'appl';
			theDesc.componentFlags = NULL;
			theDesc.componentFlagsMask = NULL;
			sgCompID = FindNextComponent (NULL, &theDesc);
			// -----------------------------------------

			if (sgCompID == NULL){
				ofLog(OF_LOG_ERROR, "error:FindNextComponent did not return a valid component");
				return false;
			}

			gSeqGrabber = OpenComponent(sgCompID);

			err = GetMoviesError();
			if (gSeqGrabber == NULL || err) {
				ofLog(OF_LOG_ERROR, "error: can't get default sequence grabber component");
				return false;
			}

			err = SGInitialize(gSeqGrabber);
			if (err != noErr) {
				ofLog(OF_LOG_ERROR, "error: can't initialize sequence grabber component");
				return false;
			}

			err = SGSetDataRef(gSeqGrabber, 0, 0, seqGrabDontMakeMovie);
			if (err != noErr) {
				ofLog(OF_LOG_ERROR, "error: can't set the destination data reference");
				return false;
			}

			// windows crashes w/ out gworld, make a dummy for now...
			// this took a long time to figure out.
			err = SGSetGWorld(gSeqGrabber, 0, 0);
			if (err != noErr) {
				ofLog(OF_LOG_ERROR, "error: setting up the gworld");
				return false;
			}

			err = SGNewChannel(gSeqGrabber, VideoMediaType, &(gVideoChannel));
			if (err != noErr) {
				ofLog(OF_LOG_ERROR, "error: creating a channel.  Check if you have any qt capable cameras attached");
				return false;
			}

			bSgInited = true;
			return true;
		}

		return false;
}
예제 #7
0
// 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;
}
예제 #8
0
파일: MovDecoder.cpp 프로젝트: EQ4/neonv2
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;
}
예제 #9
0
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(&params, 0, sizeof(CodecDecompressParams)); */
/*   GST_LOG ("calling imagecodecpredecompress"); */
/*   if (ImageCodecPreDecompress (instance, &params) != noErr) { */
/*     GST_WARNING ("Error in ImageCodecPreDecompress"); */
/*     goto beach; */
/*   } */

/*   GST_INFO ("sequenceID : %d", params.sequenceID); */

  ret = TRUE;

beach:
  /* Free instance */
  CloseComponent (instance);
  return TRUE;
}
예제 #10
0
OSErr QTDR_CopyRemoteFileToLocalFile (char *theURL, FSSpecPtr theFile)
{
	Handle				myReaderRef = NULL;			// data reference for the remote file
	Handle				myWriterRef = NULL;			// data reference for the local file
	ComponentResult		myErr = badComponentType;

	//////////
	//
	// create the local file with the desired type and creator
	//
	//////////
	
	// delete the target local file, if it already exists;
	// if it doesn't exist yet, we'll get an error (fnfErr), which we just ignore
	FSpDelete(theFile);
	
	myErr = FSpCreate(theFile, kTransFileCreator, kTransFileType, smSystemScript);
	if (myErr != noErr)
		goto bail;
	
	//////////
	//
	// create data references for the remote file and the local file
	//
	//////////
	
	myReaderRef = QTDR_MakeURLDataRef(theURL);
    if (myReaderRef == NULL)
    	goto bail;

	myWriterRef = QTDR_MakeFileDataRef(theFile);
    if (myWriterRef == NULL)
    	goto bail;

	//////////
	//
	// find and open the URL and file data handlers; connect the data references to them
	//
	//////////
	
	gDataReader = OpenComponent(GetDataHandler(myReaderRef, URLDataHandlerSubType, kDataHCanRead));
	if (gDataReader == NULL)
		goto bail;

	gDataWriter = OpenComponent(GetDataHandler(myWriterRef, rAliasType, kDataHCanWrite));
	if (gDataWriter == NULL)
		goto bail;
		
	// set the data reference for the URL data handler
	myErr = DataHSetDataRef(gDataReader, myReaderRef);
	if (myErr != noErr)
		goto bail;
	
	// set the data reference for the file data handler
	myErr = DataHSetDataRef(gDataWriter, myWriterRef);
	if (myErr != noErr)
		goto bail;
	
	//////////
	//
	// allocate a data buffer; the URL data handler copies data into this buffer,
	// and the file data handler copies data out of it
	//
	//////////
	
	gDataBuffer = NewPtrClear(kDataBufferSize);
	myErr = MemError();
	if (myErr != noErr)
		goto bail;
		
	//////////
	//
	// connect to the remote and local files
	//
	//////////
	
	// open a read-only path to the remote data reference
	myErr = DataHOpenForRead(gDataReader);
	if (myErr != noErr)
		goto bail;

	// get the size of the remote file
	myErr = DataHGetFileSize(gDataReader, &gBytesToTransfer); 
	if (myErr != noErr)
		goto bail;
	
	// open a write-only path to the local data reference
	myErr = DataHOpenForWrite(gDataWriter);
	if (myErr != noErr)
		goto bail;
		
	//////////
	//
	// start reading and writing data
	//
	//////////
	
	gDoneTransferring = false;
	gBytesTransferred = 0L;
	
	gReadDataHCompletionUPP = NewDataHCompletionUPP(QTDR_ReadDataCompletionProc);
	gWriteDataHCompletionUPP = NewDataHCompletionUPP(QTDR_WriteDataCompletionProc);
		
	// start retrieving the data; we do this by calling our own write completion routine,
	// pretending that we've just successfully finished writing 0 bytes of data
	QTDR_WriteDataCompletionProc(gDataBuffer, 0L, noErr);

bail:
	// if we encountered any error, close the data handler components
	if (myErr != noErr)
		QTDR_CloseDownHandlers();
	
	return((OSErr)myErr);
}