Thread: [artoolkit-commits] artoolkit/lib/SRC/VideoMacOSX video.c, 1.17, 1.18
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2006-06-08 22:05:13
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32233 Modified Files: video.c Log Message: Don't return a copy of the acquired image if running on an Intel Mac. Index: video.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX/video.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** video.c 24 May 2006 03:35:18 -0000 1.17 --- video.c 8 Jun 2006 22:05:08 -0000 1.18 *************** *** 93,97 **** // ============================================================================ ! #define AR_VIDEO_DEBUG_BUFFERCOPY // Uncomment to have ar2VideoGetImage() return a copy of video pixel data. //#define AR_VIDEO_SUPPORT_OLD_QUICKTIME // Uncomment to allow use of non-thread safe QuickTime (pre-6.4). #define AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE --- 93,99 ---- // ============================================================================ ! #ifndef __i386__ // Hack: don't do buffercopy on Intel Macs. ! # define AR_VIDEO_DEBUG_BUFFERCOPY // Uncomment to have ar2VideoGetImage() return a copy of video pixel data. ! #endif //#define AR_VIDEO_SUPPORT_OLD_QUICKTIME // Uncomment to allow use of non-thread safe QuickTime (pre-6.4). #define AR_VIDEO_DEBUG_FIX_DUAL_PROCESSOR_RACE *************** *** 162,169 **** long bufSize; // PRL. ARUint8* bufPixels; // PRL. ! #ifdef AR_VIDEO_DEBUG_BUFFERCOPY ARUint8* bufPixelsCopy1; // PRL. ARUint8* bufPixelsCopy2; // PRL. - #endif // AR_VIDEO_DEBUG_BUFFERCOPY int grabber; // PRL. MatrixRecordPtr scaleMatrixPtr; // PRL. --- 164,170 ---- long bufSize; // PRL. ARUint8* bufPixels; // PRL. ! int bufCopyFlag; // PRL ARUint8* bufPixelsCopy1; // PRL. ARUint8* bufPixelsCopy2; // PRL. int grabber; // PRL. MatrixRecordPtr scaleMatrixPtr; // PRL. *************** *** 1363,1366 **** --- 1364,1373 ---- //vid->timeScale = 0; vid->grabber = grabber; + #ifdef AR_VIDEO_DEBUG_BUFFERCOPY + vid->bufCopyFlag = 1; + #else + vid->bufCopyFlag = 0; + #endif // AR_VIDEO_DEBUG_BUFFERCOPY + if(!(vid->pVdg = vdgAllocAndInit(grabber))) { *************** *** 1446,1455 **** vid->bufSize = vid->height * vid->rowBytes; if (!(vid->bufPixels = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! #ifdef AR_VIDEO_DEBUG_BUFFERCOPY ! // And another two buffers for OpenGL to read out of. ! if (!(vid->bufPixelsCopy1 = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! if (!(vid->bufPixelsCopy2 = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! #endif // AR_VIDEO_DEBUG_BUFFERCOPY ! // Wrap a GWorld around the pixel buffer. err_s = QTNewGWorldFromPtr(&(vid->pGWorld), // returned GWorld pixFormat, // format of pixels --- 1453,1462 ---- vid->bufSize = vid->height * vid->rowBytes; if (!(vid->bufPixels = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! if (vid->bufCopyFlag) { ! // And another two buffers for OpenGL to read out of. ! if (!(vid->bufPixelsCopy1 = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! if (!(vid->bufPixelsCopy2 = (ARUint8 *)valloc(vid->bufSize * sizeof(ARUint8)))) exit (1); ! } ! // Wrap a GWorld around the pixel buffer. err_s = QTNewGWorldFromPtr(&(vid->pGWorld), // returned GWorld pixFormat, // format of pixels *************** *** 1519,1526 **** DisposeGWorld(vid->pGWorld); out5: ! #ifdef AR_VIDEO_DEBUG_BUFFERCOPY ! free(vid->bufPixelsCopy2); ! free(vid->bufPixelsCopy1); ! #endif // AR_VIDEO_DEBUG_BUFFERCOPY free(vid->bufPixels); if (vid->scaleMatrixPtr) free(vid->scaleMatrixPtr); --- 1526,1533 ---- DisposeGWorld(vid->pGWorld); out5: ! if (vid->bufCopyFlag) { ! free(vid->bufPixelsCopy2); ! free(vid->bufPixelsCopy1); ! } free(vid->bufPixels); if (vid->scaleMatrixPtr) free(vid->scaleMatrixPtr); *************** *** 1579,1592 **** } ! #ifdef AR_VIDEO_DEBUG_BUFFERCOPY ! if (vid->bufPixelsCopy2) { ! free(vid->bufPixelsCopy2); ! vid->bufPixelsCopy2 = NULL; ! } ! if (vid->bufPixelsCopy1) { ! free(vid->bufPixelsCopy1); ! vid->bufPixelsCopy1 = NULL; } - #endif // AR_VIDEO_DEBUG_BUFFERCOPY if (vid->bufPixels) { free(vid->bufPixels); --- 1586,1599 ---- } ! if (vid->bufCopyFlag) { ! if (vid->bufPixelsCopy2) { ! free(vid->bufPixelsCopy2); ! vid->bufPixelsCopy2 = NULL; ! } ! if (vid->bufPixelsCopy1) { ! free(vid->bufPixelsCopy1); ! vid->bufPixelsCopy1 = NULL; ! } } if (vid->bufPixels) { free(vid->bufPixels); *************** *** 1802,1818 **** // of problems and which can now be avoided after rewriting the // various bits of the toolkit to cope. ! #ifdef AR_VIDEO_DEBUG_BUFFERCOPY ! if (vid->status & AR_VIDEO_STATUS_BIT_BUFFER) { ! memcpy((void *)(vid->bufPixelsCopy2), (void *)(vid->bufPixels), vid->bufSize); ! pix = vid->bufPixelsCopy2; ! vid->status &= ~AR_VIDEO_STATUS_BIT_BUFFER; // Clear buffer bit. } else { ! memcpy((void *)(vid->bufPixelsCopy1), (void *)(vid->bufPixels), vid->bufSize); ! pix = vid->bufPixelsCopy1; ! vid->status |= AR_VIDEO_STATUS_BIT_BUFFER; // Set buffer bit. } - #else - pix = vid->bufPixels; - #endif // AR_VIDEO_DEBUG_BUFFERCOPY vid->status &= ~AR_VIDEO_STATUS_BIT_READY; // Clear ready bit. --- 1809,1825 ---- // of problems and which can now be avoided after rewriting the // various bits of the toolkit to cope. ! if (vid->bufCopyFlag) { ! if (vid->status & AR_VIDEO_STATUS_BIT_BUFFER) { ! memcpy((void *)(vid->bufPixelsCopy2), (void *)(vid->bufPixels), vid->bufSize); ! pix = vid->bufPixelsCopy2; ! vid->status &= ~AR_VIDEO_STATUS_BIT_BUFFER; // Clear buffer bit. ! } else { ! memcpy((void *)(vid->bufPixelsCopy1), (void *)(vid->bufPixels), vid->bufSize); ! pix = vid->bufPixelsCopy1; ! vid->status |= AR_VIDEO_STATUS_BIT_BUFFER; // Set buffer bit. ! } } else { ! pix = vid->bufPixels; } vid->status &= ~AR_VIDEO_STATUS_BIT_READY; // Clear ready bit. |