home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / video / simpleVideo / examples / svtest8.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.4 KB  |  91 lines

  1. /*
  2.  * Copyright (c) 1994, Silicon Graphics, Inc.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that the name of Silicon Graphics may not be used in any advertising or
  7.  * publicity relating to the software without the specific, prior written
  8.  * permission of Silicon Graphics.
  9.  *
  10.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  11.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  12.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  13.  *
  14.  * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
  17.  * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  */
  20. /* $Id: svtest8.c,v 1.4 1994/04/29 23:15:20 dpb Exp $ */
  21.  
  22. /*** Continuous transfer of frames from vino to galileo;
  23.  *** Use continuous transfers, yuv images;
  24.  ***/
  25.  
  26. #include <stdio.h>
  27. #include <unistd.h>
  28. #include <signal.h>
  29. #include "sv.h"
  30.  
  31. int frameCount = 0;
  32. struct timeval startTime, now;
  33.  
  34. void
  35. intHandler(void)
  36. {
  37.     double delta_t, fps;
  38.  
  39.     gettimeofday(&now);
  40.     
  41.     now.tv_sec  -= startTime.tv_sec;
  42.     now.tv_usec -= startTime.tv_usec;
  43.     
  44.     delta_t = (double)now.tv_sec + (double)now.tv_usec/1000000.0;
  45.     fps = (double)frameCount/delta_t;
  46.  
  47.     printf("%5.2f frames/sec.\n", fps); 
  48.  
  49.     exit(0);
  50. }
  51.  
  52. int
  53. main(void)
  54. {
  55.     int ret;
  56.     svImage *imageInfo;
  57.     svContext context1, context2;
  58.  
  59.     context1 = svCurrentContext();
  60.     svSelectInput(vnINPUT_INDYCAM);
  61.     svSetFrameCount(2);
  62.     svSetTransferMode(svTRANSFER_CONTINUOUS);
  63.     svSetImagePacking(VL_PACKING_YVYU_422_8);
  64.  
  65.     context2 = svNewContext();
  66.     svSelectOutput(gvOUTPUT_ANALOG);
  67.     svSetFrameCount(2);
  68.     svSetTransferMode(svTRANSFER_CONTINUOUS);
  69.     svSetImagePacking(VL_PACKING_YVYU_422_8);
  70.  
  71.     imageInfo = svNewImage();
  72.  
  73.     signal(SIGINT, intHandler);
  74.     gettimeofday(&startTime);
  75.  
  76.     while (1) {
  77.     svSetContext(context1);
  78.     if (ret = svGetFrame(imageInfo))
  79.         printf("svGetFrame returns %d\n", ret);
  80.  
  81.     svSetContext(context2);
  82.     if (ret = svPutFrame(imageInfo))
  83.         printf("svPutFrame returns %d\n", ret);
  84.     
  85.     frameCount++;
  86.     }
  87.  
  88.     return 0;
  89. }
  90.  
  91.