Update of /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv30663/lib/SRC/VideoMacOSX
Modified Files:
video.c
Log Message:
Some cleanup of gstreamer addition, plus new fliph and flipv tokens for Mac video.
Index: video.c
===================================================================
RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/VideoMacOSX/video.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** video.c 23 Jun 2006 06:42:39 -0000 1.20
--- video.c 10 Jul 2006 04:35:17 -0000 1.21
***************
*** 1234,1237 ****
--- 1234,1241 ----
printf(" 32, BGRA, RGBA, ABGR, 24, 24BG, 2vuy, yuvs.\n");
printf(" (See http://developer.apple.com/quicktime/icefloe/dispatch020.html.)\n");
+ printf(" -fliph\n");
+ printf(" Flip camera image horizontally.\n");
+ printf(" -flipv\n");
+ printf(" Flip camera image vertically.\n");
printf("\n");
***************
*** 1250,1253 ****
--- 1254,1258 ----
int showDialog = 1;
int standardDialog = 0;
+ int flipH = 0, flipV = 0;
OSErr err_s = noErr;
ComponentResult err = noErr;
***************
*** 1262,1266 ****
CGrafPtr theSavedPort;
GDHandle theSavedDevice;
- Rect sourceRect = {0, 0};
long cpuType;
--- 1267,1270 ----
***************
*** 1295,1298 ****
--- 1299,1306 ----
} else if (strncmp(a, "-standarddialog", 15) == 0) {
standardDialog = 1;
+ } else if (strncmp(a, "-fliph", 6) == 0) {
+ flipH = 1;
+ } else if (strncmp(a, "-flipv", 6) == 0) {
+ flipV = 1;
} else {
err_i = 1;
***************
*** 1496,1517 ****
(char)(((*(vid->vdImageDesc))->cType >> 0) & 0xFF),
((*vid->vdImageDesc)->width), ((*vid->vdImageDesc)->height));
!
// If a particular size was requested, set the size of the GWorld to
// the request, otherwise set it to the size of the incoming video.
vid->width = (width ? width : (int)((*vid->vdImageDesc)->width));
vid->height = (height ? height : (int)((*vid->vdImageDesc)->height));
! SetRect(&(vid->theRect), 0, 0, (short)vid->width, (short)vid->height);
!
// Make a scaling matrix for the sequence if size of incoming video differs from GWorld dimensions.
if (vid->width != (int)((*vid->vdImageDesc)->width) || vid->height != (int)((*vid->vdImageDesc)->height)) {
- sourceRect.right = (*vid->vdImageDesc)->width;
- sourceRect.bottom = (*vid->vdImageDesc)->height;
arMalloc(vid->scaleMatrixPtr, MatrixRecord, 1);
! RectMatrix(vid->scaleMatrixPtr, &sourceRect, &(vid->theRect));
fprintf(stdout, "Video will be scaled to size %dx%d.\n", vid->width, vid->height);
} else {
! vid->scaleMatrixPtr = NULL;
}
// Allocate buffer for the grabber to write pixel data into, and use
// QTNewGWorldFromPtr() to wrap an offscreen GWorld structure around
--- 1504,1544 ----
(char)(((*(vid->vdImageDesc))->cType >> 0) & 0xFF),
((*vid->vdImageDesc)->width), ((*vid->vdImageDesc)->height));
!
// If a particular size was requested, set the size of the GWorld to
// the request, otherwise set it to the size of the incoming video.
vid->width = (width ? width : (int)((*vid->vdImageDesc)->width));
vid->height = (height ? height : (int)((*vid->vdImageDesc)->height));
! SetRect(&(vid->theRect), 0, 0, (short)vid->width, (short)vid->height);
!
// Make a scaling matrix for the sequence if size of incoming video differs from GWorld dimensions.
+ vid->scaleMatrixPtr = NULL;
+ int doSourceScale;
if (vid->width != (int)((*vid->vdImageDesc)->width) || vid->height != (int)((*vid->vdImageDesc)->height)) {
arMalloc(vid->scaleMatrixPtr, MatrixRecord, 1);
! SetIdentityMatrix(vid->scaleMatrixPtr);
! Fixed scaleX, scaleY;
! scaleX = FixRatio(vid->width, (*vid->vdImageDesc)->width);
! scaleY = FixRatio(vid->height, (*vid->vdImageDesc)->height);
! ScaleMatrix(vid->scaleMatrixPtr, scaleX, scaleY, 0, 0);
fprintf(stdout, "Video will be scaled to size %dx%d.\n", vid->width, vid->height);
+ doSourceScale = 1;
} else {
! doSourceScale = 0;
}
+ // If a flip was requested, add a scaling matrix for it.
+ if (flipH || flipV) {
+ Fixed scaleX, scaleY;
+ if (flipH) scaleX = -fixed1;
+ else scaleX = fixed1;
+ if (flipV) scaleY = -fixed1;
+ else scaleY = fixed1;
+ if (!doSourceScale) {
+ arMalloc(vid->scaleMatrixPtr, MatrixRecord, 1);
+ SetIdentityMatrix(vid->scaleMatrixPtr);
+ }
+ ScaleMatrix(vid->scaleMatrixPtr, scaleX, scaleY, FloatToFixed((float)(vid->width) * 0.5f), FloatToFixed((float)(vid->height) * 0.5f));
+ }
+
// Allocate buffer for the grabber to write pixel data into, and use
// QTNewGWorldFromPtr() to wrap an offscreen GWorld structure around
|