[artoolkit-commits] artoolkit/lib/SRC/VideoMacOSX video.c,1.6,1.7
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2005-03-24 00:34:52
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7420 Modified Files: video.c Log Message: Tidy up error some error handling. Index: video.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX/video.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** video.c 16 Mar 2005 04:42:06 -0000 1.6 --- video.c 24 Mar 2005 00:34:30 -0000 1.7 *************** *** 210,226 **** } if (!seqGrab) { ! fprintf(stderr, "Failed to open the sequence grabber.\n"); goto endFunc; } // initialize the default sequence grabber component ! if(err = SGInitialize(seqGrab)) { ! fprintf(stderr, "SGInitialize err=%ld\n", err); goto endFunc; } // This should be defaulted to the current port according to QT doco ! if (err = SGSetGWorld(seqGrab, GetWindowPort(pWindow), NULL)) { ! fprintf(stderr, "SGSetGWorld err=%ld\n", err); goto endFunc; } --- 210,226 ---- } if (!seqGrab) { ! fprintf(stderr, "MakeSequenceGrabber(): Failed to open a sequence grabber component.\n"); goto endFunc; } // initialize the default sequence grabber component ! if ((err = SGInitialize(seqGrab))) { ! fprintf(stderr, "MakeSequenceGrabber(): SGInitialize err=%ld\n", err); goto endFunc; } // This should be defaulted to the current port according to QT doco ! if ((err = SGSetGWorld(seqGrab, GetWindowPort(pWindow), NULL))) { ! fprintf(stderr, "MakeSequenceGrabber(): SGSetGWorld err=%ld\n", err); goto endFunc; } *************** *** 231,250 **** // your data function, but does not write any data to the movie file // writeType will always be set to seqGrabWriteAppend ! if (err = SGSetDataRef(seqGrab, ! 0, ! 0, ! seqGrabDontMakeMovie)) ! { ! fprintf(stderr, "SGSetGWorld err=%ld\n", err); goto endFunc; } endFunc: ! if (err && (seqGrab != NULL)) { // clean up on failure ! CloseComponent(seqGrab); ! seqGrab = NULL; ! } ! return seqGrab; } --- 231,246 ---- // your data function, but does not write any data to the movie file // writeType will always be set to seqGrabWriteAppend ! if ((err = SGSetDataRef(seqGrab, 0, 0, seqGrabDontMakeMovie))) { ! fprintf(stderr, "MakeSequenceGrabber(): SGSetDataRef err=%ld\n", err); goto endFunc; } endFunc: ! if (err && (seqGrab != NULL)) { // clean up on failure ! CloseComponent(seqGrab); ! seqGrab = NULL; ! } ! return (seqGrab); } *************** *** 258,280 **** ComponentResult err = noErr; ! if (err = SGNewChannel(seqGrab, VideoMediaType, psgchanVideo)) { ! fprintf(stderr, "SGNewChannel err=%ld\n", err); goto endFunc; } ! // err = SGSetChannelBounds(*sgchanVideo, rect); // set usage for new video channel to avoid playthrough // note we don't set seqGrabPlayDuringRecord ! if (err = SGSetChannelUsage(*psgchanVideo, flags | seqGrabRecord)) { ! fprintf(stderr, "SGSetChannelUsage err=%ld\n", err); goto endFunc; } endFunc: ! if ((err != noErr) && psgchanVideo) { ! // clean up on failure ! SGDisposeChannel(seqGrab, *psgchanVideo); ! *psgchanVideo = NULL; ! } return err; --- 254,276 ---- ComponentResult err = noErr; ! if ((err = SGNewChannel(seqGrab, VideoMediaType, psgchanVideo))) { ! fprintf(stderr, "MakeSequenceGrabChannel(): SGNewChannel err=%ld\n", err); goto endFunc; } ! //err = SGSetChannelBounds(*sgchanVideo, rect); // set usage for new video channel to avoid playthrough // note we don't set seqGrabPlayDuringRecord ! if ((err = SGSetChannelUsage(*psgchanVideo, flags | seqGrabRecord))) { ! fprintf(stderr, "MakeSequenceGrabChannel(): SGSetChannelUsage err=%ld\n", err); goto endFunc; } endFunc: ! if ((err != noErr) && psgchanVideo) { ! // clean up on failure ! SGDisposeChannel(seqGrab, *psgchanVideo); ! *psgchanVideo = NULL; ! } return err; *************** *** 286,302 **** // Extract information from the SG ! if (err = SGGetVideoCompressor ( pVdg->sgchanVideo, ! &pVdg->cpDepth, ! &pVdg->cpCompressor, ! &pVdg->cpSpatialQuality, ! &pVdg->cpTemporalQuality, ! &pVdg->cpKeyFrameRate )) ! { fprintf(stderr, "SGGetVideoCompressor err=%ld\n", err); goto endFunc; } ! if (err = SGGetFrameRate(pVdg->sgchanVideo, &pVdg->cpFrameRate)) ! { fprintf(stderr, "SGGetFrameRate err=%ld\n", err); goto endFunc; --- 282,296 ---- // Extract information from the SG ! if (err = SGGetVideoCompressor (pVdg->sgchanVideo, ! &pVdg->cpDepth, ! &pVdg->cpCompressor, ! &pVdg->cpSpatialQuality, ! &pVdg->cpTemporalQuality, ! &pVdg->cpKeyFrameRate)) { fprintf(stderr, "SGGetVideoCompressor err=%ld\n", err); goto endFunc; } ! if (err = SGGetFrameRate(pVdg->sgchanVideo, &pVdg->cpFrameRate)) { fprintf(stderr, "SGGetFrameRate err=%ld\n", err); goto endFunc; *************** *** 304,309 **** // Get the selected vdig from the SG ! if (!(pVdg->vdCompInst = SGGetVideoDigitizerComponent(pVdg->sgchanVideo))) ! { fprintf(stderr, "SGGetVideoDigitizerComponent error\n"); goto endFunc; --- 298,302 ---- // Get the selected vdig from the SG ! if (!(pVdg->vdCompInst = SGGetVideoDigitizerComponent(pVdg->sgchanVideo))) { fprintf(stderr, "SGGetVideoDigitizerComponent error\n"); goto endFunc; *************** *** 311,315 **** endFunc: ! return err; } --- 304,308 ---- endFunc: ! return (err); } *************** *** 331,335 **** } ! if (err = MakeSequenceGrabChannel(pVdg->seqGrab, &pVdg->sgchanVideo)) { fprintf(stderr, "MakeSequenceGrabChannel err=%d.\n", err); free(pVdg); --- 324,328 ---- } ! if ((err = MakeSequenceGrabChannel(pVdg->seqGrab, &pVdg->sgchanVideo))) { fprintf(stderr, "MakeSequenceGrabChannel err=%d.\n", err); free(pVdg); *************** *** 426,430 **** VDSetCompressionOnOff(false) */ ! OSErr err; Rect maxRect; --- 419,423 ---- VDSetCompressionOnOff(false) */ ! VideoDigitizerError err; Rect maxRect; *************** *** 432,457 **** // make sure this is a compressed source only ! if (err = VDGetDigitizerInfo(pVdg->vdCompInst, &info)) ! { ! if (!(info.outputCapabilityFlags & digiOutDoesCompress)) ! { ! fprintf(stderr, "VDGetDigitizerInfo: not a compressed source device.\n"); goto endFunc; } ! } // VDGetCompressTypes() // tells you the supported types ! // Apple's SoftVDig doesn't seem to like these calls ! if (err = VDCaptureStateChanging( pVdg->vdCompInst, vdFlagCaptureSetSettingsBegin)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDCaptureStateChanging err=%d\n", err); ! // goto endFunc; } ! if (err = VDGetMaxSrcRect( pVdg->vdCompInst, currentIn, &maxRect)) ! { ! fprintf(stderr, "VDGetMaxSrcRect err=%d\n", err); ! // goto endFunc; } --- 425,451 ---- // make sure this is a compressed source only ! if ((err = VDGetDigitizerInfo(pVdg->vdCompInst, &info))) { ! fprintf(stderr, "vdgPreflightGrabbing(): VDGetDigitizerInfo err=%ld\n", err); ! goto endFunc; ! } else { ! if (!(info.outputCapabilityFlags & digiOutDoesCompress)) { ! fprintf(stderr, "vdgPreflightGrabbing(): VDGetDigitizerInfo reports device is not a compressed source.\n"); ! err = digiUnimpErr; // We don't support non-compressed sources. goto endFunc; } ! } // VDGetCompressTypes() // tells you the supported types ! // Tell the vDig we're starting to change several settings. ! // Apple's SoftVDig doesn't seem to like these calls. ! if ((err = VDCaptureStateChanging(pVdg->vdCompInst, vdFlagCaptureSetSettingsBegin))) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDCaptureStateChanging err=%ld (Ignored.)\n", err); ! //goto endFunc; } ! if ((err = VDGetMaxSrcRect(pVdg->vdCompInst, currentIn, &maxRect))) { ! fprintf(stderr, "vdgPreflightGrabbing(): VDGetMaxSrcRect err=%ld (Ignored.)\n", err); ! //goto endFunc; } *************** *** 460,480 **** // we're setting digitization size rather than compression size here... // Apple vdigs don't like this call ! if (err = VDSetDigitizerRect( pVdg->vdCompInst, &maxRect)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDSetDigitizerRect err=%d\n", err); ! // goto endFunc; } ! if (err = VDSetCompressionOnOff( pVdg->vdCompInst, 1)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDSetCompressionOnOff err=%d\n", err); ! // goto endFunc; } // We could try to force the frame rate here... necessary for ASC softvdig ! if (err = VDSetFrameRate( pVdg->vdCompInst, 0)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDSetFrameRate err=%d\n", err); ! // goto endFunc; } --- 454,471 ---- // we're setting digitization size rather than compression size here... // Apple vdigs don't like this call ! if (err = VDSetDigitizerRect( pVdg->vdCompInst, &maxRect)) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDSetDigitizerRect err=%ld (Ignored.)\n", err); ! //goto endFunc; } ! if (err = VDSetCompressionOnOff( pVdg->vdCompInst, 1)) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDSetCompressionOnOff err=%ld (Ignored.)\n", err); ! //goto endFunc; } // We could try to force the frame rate here... necessary for ASC softvdig ! if (err = VDSetFrameRate(pVdg->vdCompInst, 0)) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDSetFrameRate err=%ld (Ignored.)\n", err); ! //goto endFunc; } *************** *** 486,533 **** // we'll get 640x480 frames returned instead (which use 4:1:1 encoding on // the wire rather than 4:2:2) ! if (err = VDSetCompression( pVdg->vdCompInst, ! 0, //'yuv2' ! 0, ! &maxRect, ! 0, //codecNormalQuality, ! 0, //codecNormalQuality, ! 0)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDSetCompression err=%d\n", err); ! // goto endFunc; } ! if (err = VDCaptureStateChanging(pVdg->vdCompInst, ! vdFlagCaptureLowLatency)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDCaptureStateChanging err=%d\n", err); ! // goto endFunc; } ! ! if (err = VDCaptureStateChanging(pVdg->vdCompInst, vdFlagCaptureSetSettingsEnd)) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDCaptureStateChanging err=%d\n", err); ! // goto endFunc; } ! if (err = VDResetCompressSequence( pVdg->vdCompInst )) ! { ! if (err != digiUnimpErr) fprintf(stderr, "VDResetCompressSequence err=%d\n", err); ! // goto endFunc; } pVdg->vdImageDesc = (ImageDescriptionHandle)NewHandle(0); ! if (err = VDGetImageDescription( pVdg->vdCompInst, pVdg->vdImageDesc)) ! { ! fprintf(stderr, "VDGetImageDescription err=%d\n", err); ! // goto endFunc; } // From Steve Sisak: find out if Digitizer is cropping for you. ! if (err = VDGetDigitizerRect( pVdg->vdCompInst, &pVdg->vdDigitizerRect)) ! { ! fprintf(stderr, "VDGetDigitizerRect err=%d\n", err); ! // goto endFunc; } --- 477,517 ---- // we'll get 640x480 frames returned instead (which use 4:1:1 encoding on // the wire rather than 4:2:2) ! if (err = VDSetCompression(pVdg->vdCompInst, ! 0, //'yuv2' ! 0, ! &maxRect, ! 0, //codecNormalQuality, ! 0, //codecNormalQuality, ! 0)) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDSetCompression err=%ld (Ignored.)\n", err); ! //goto endFunc; } ! if (err = VDCaptureStateChanging(pVdg->vdCompInst, vdFlagCaptureLowLatency)) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDCaptureStateChanging err=%ld (Ignored.)\n", err); ! //goto endFunc; } ! // Tell the vDig we've finished changing settings. ! if ((err = VDCaptureStateChanging(pVdg->vdCompInst, vdFlagCaptureSetSettingsEnd))) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDCaptureStateChanging err=%ld (Ignored.)\n", err); ! //goto endFunc; } ! if ((err = VDResetCompressSequence( pVdg->vdCompInst))) { ! if (err != digiUnimpErr) fprintf(stderr, "vdgPreflightGrabbing(): VDResetCompressSequence err=%ld (Ignored.)\n", err); ! //goto endFunc; } pVdg->vdImageDesc = (ImageDescriptionHandle)NewHandle(0); ! if ((err = VDGetImageDescription(pVdg->vdCompInst, pVdg->vdImageDesc))) { ! fprintf(stderr, "vdgPreflightGrabbing(): VDGetImageDescription err=%ld (Ignored.)\n", err); ! //goto endFunc; } // From Steve Sisak: find out if Digitizer is cropping for you. ! if ((err = VDGetDigitizerRect(pVdg->vdCompInst, &pVdg->vdDigitizerRect))) { ! fprintf(stderr, "vdgPreflightGrabbing(): VDGetDigitizerRect err=%ld (Ignored.)\n", err); ! //goto endFunc; } *************** *** 535,539 **** endFunc: ! return err; } --- 519,523 ---- endFunc: ! return (err); } *************** *** 548,559 **** pMilliSecPerFrame, pFramesPerSecond, ! pBytesPerSecond)) ! { ! fprintf(stderr, "VDGetDataRate err=%ld\n", err); goto endFunc; } endFunc: ! return err; } --- 532,542 ---- pMilliSecPerFrame, pFramesPerSecond, ! pBytesPerSecond)) { ! fprintf(stderr, "vdgGetDataRate(): VDGetDataRate err=%ld\n", err); goto endFunc; } endFunc: ! return (err); } *************** *** 1348,1362 **** if(!(vid->pVdg = vdgAllocAndInit(grabber))) { ! fprintf(stderr, "vdgAllocAndInit err=%ld\n", err); goto out1; } if (err = vdgRequestSettings(vid->pVdg, showDialog, gVidCount)) { ! fprintf(stderr, "vdgRequestSettings err=%ld\n", err); goto out2; } if (err = vdgPreflightGrabbing(vid->pVdg)) { ! fprintf(stderr, "vdgPreflightGrabbing err=%ld\n", err); goto out2; } --- 1331,1345 ---- if(!(vid->pVdg = vdgAllocAndInit(grabber))) { ! fprintf(stderr, "ar2VideoOpen(): vdgAllocAndInit err=%ld\n", err); goto out1; } if (err = vdgRequestSettings(vid->pVdg, showDialog, gVidCount)) { ! fprintf(stderr, "ar2VideoOpen(): vdgRequestSettings err=%ld\n", err); goto out2; } if (err = vdgPreflightGrabbing(vid->pVdg)) { ! fprintf(stderr, "ar2VideoOpen(): vdgPreflightGrabbing err=%ld\n", err); goto out2; } *************** *** 1368,1372 **** &vid->frameRate, &vid->bytesPerSecond)) { ! fprintf(stderr, "vdgGetDataRate err=%ld\n", err); //goto out2; } --- 1351,1355 ---- &vid->frameRate, &vid->bytesPerSecond)) { ! fprintf(stderr, "ar2VideoOpen(): vdgGetDataRate err=%ld\n", err); //goto out2; } *************** *** 1393,1397 **** vid->vdImageDesc = (ImageDescriptionHandle)NewHandle(0); if (err = vdgGetImageDescription(vid->pVdg, vid->vdImageDesc)) { ! fprintf(stderr, "vdgGetImageDescription err=%ld\n", err); goto out3; } --- 1376,1380 ---- vid->vdImageDesc = (ImageDescriptionHandle)NewHandle(0); if (err = vdgGetImageDescription(vid->pVdg, vid->vdImageDesc)) { ! fprintf(stderr, "ar2VideoOpen(): vdgGetImageDescription err=%ld\n", err); goto out3; } *************** *** 1468,1472 **** // Set the decompression destination to the offscreen GWorld. if (err_s = vdgSetDestination(vid->pVdg, vid->pGWorld)) { ! fprintf(stderr, "vdgGetImageDescription err=%d\n", err_s); goto out6; } --- 1451,1455 ---- // Set the decompression destination to the offscreen GWorld. if (err_s = vdgSetDestination(vid->pVdg, vid->pGWorld)) { ! fprintf(stderr, "ar2VideoOpen(): vdgSetDestination err=%d\n", err_s); goto out6; } |