core/vidl/vidl_iidc1394_params.cxx
Go to the documentation of this file.
00001 // This is core/vidl/vidl_iidc1394_params.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Matt Leotta
00008 // \date   10 Jan 2006
00009 //
00010 //-----------------------------------------------------------------------------
00011 
00012 #include "vidl_iidc1394_params.h"
00013 #include <vcl_cassert.h>
00014 
00015 //-----------------------------------------------------------------------------
00016 
00017 
00018 vidl_iidc1394_params::vidl_iidc1394_params()
00019   : guid_( 0 ),
00020     speed_( ISO_SPEED_400 ),
00021     b_mode_(false),
00022     frame_rate_( FRAMERATE_15 ),
00023     video_mode_( MODE_640x480_RGB8 )
00024 {
00025 }
00026 
00027 
00028 //: Return the speed value for a speed setting
00029 unsigned int
00030 vidl_iidc1394_params::
00031 speed_val(speed_t s)
00032 {
00033   switch (s)
00034   {
00035     case ISO_SPEED_100:  return 100;
00036     case ISO_SPEED_200:  return 200;
00037     case ISO_SPEED_400:  return 400;
00038     case ISO_SPEED_800:  return 800;
00039     case ISO_SPEED_1600: return 1600;
00040     case ISO_SPEED_3200: return 3200;
00041     default:             return 0;
00042   }
00043 }
00044 
00045 
00046 //: Return the frame rate as a floating point value
00047 float
00048 vidl_iidc1394_params::
00049 frame_rate_val(frame_rate_t r)
00050 {
00051   switch (r)
00052   {
00053     case FRAMERATE_1_875: return 1.875f;
00054     case FRAMERATE_3_75:  return 3.75f;
00055     case FRAMERATE_7_5:   return 7.5f;
00056     case FRAMERATE_15:    return 15.0f;
00057     case FRAMERATE_30:    return 30.0f;
00058     case FRAMERATE_60:    return 60.0f;
00059     case FRAMERATE_120:   return 120.0f;
00060     case FRAMERATE_240:   return 240.0f;
00061     default:              return 0.0f;
00062   }
00063 }
00064 
00065 
00066 //: Return string describing the mode
00067 vcl_string
00068 vidl_iidc1394_params::
00069 video_mode_string(video_mode_t m)
00070 {
00071   switch (m)
00072   {
00073     case MODE_160x120_YUV444:   return "160x120 YUV(4:4:4)";
00074     case MODE_320x240_YUV422:   return "320x240 YUV(4:2:2)";
00075     case MODE_640x480_YUV411:   return "640x480 YUV(4:1:1)";
00076     case MODE_640x480_YUV422:   return "640x480 YUV(4:2:2)";
00077     case MODE_640x480_RGB8:     return "640x480 RGB";
00078     case MODE_640x480_MONO8:    return "640x480 Mono(8 bit)";
00079     case MODE_640x480_MONO16:   return "640x480 Mono(16 bit)";
00080     case MODE_800x600_YUV422:   return "800x600 YUV(4:2:2)";
00081     case MODE_800x600_RGB8:     return "800x600 RGB";
00082     case MODE_800x600_MONO8:    return "800x600 Mono(8 bit)";
00083     case MODE_1024x768_YUV422:  return "1024x768 YUV(4:2:2)";
00084     case MODE_1024x768_RGB8:    return "1024x768 RGB";
00085     case MODE_1024x768_MONO8:   return "1024x768 Mono(8 bit)";
00086     case MODE_800x600_MONO16:   return "800x600 Mono(16 bit)";
00087     case MODE_1024x768_MONO16:  return "1024x768 Mono(16 bit)";
00088     case MODE_1280x960_YUV422:  return "1280x960 YUV(4:2:2)";
00089     case MODE_1280x960_RGB8:    return "1280x960 RGB";
00090     case MODE_1280x960_MONO8:   return "1280x960 Mono(8 bit)";
00091     case MODE_1600x1200_YUV422: return "1600x1200 YUV(4:2:2)";
00092     case MODE_1600x1200_RGB8:   return "1600x1200 RGB";
00093     case MODE_1600x1200_MONO8:  return "1600x1200 Mono(8 bit)";
00094     case MODE_1280x960_MONO16:  return "1280x960 Mono(16 bit)";
00095     case MODE_1600x1200_MONO16: return "1600x1200 Mono(16 bit)";
00096     case MODE_EXIF:      return "Exif";
00097     case MODE_FORMAT7_0: return "Format 7 : Mode 0";
00098     case MODE_FORMAT7_1: return "Format 7 : Mode 1";
00099     case MODE_FORMAT7_2: return "Format 7 : Mode 2";
00100     case MODE_FORMAT7_3: return "Format 7 : Mode 3";
00101     case MODE_FORMAT7_4: return "Format 7 : Mode 4";
00102     case MODE_FORMAT7_5: return "Format 7 : Mode 5";
00103     case MODE_FORMAT7_6: return "Format 7 : Mode 6";
00104     case MODE_FORMAT7_7: return "Format 7 : Mode 7";
00105     default:             return "invalid mode";
00106   }
00107 }
00108 
00109 
00110 //: Return string describing the feature
00111 vcl_string
00112 vidl_iidc1394_params::
00113 feature_string(feature_t f)
00114 {
00115   switch (f)
00116   {
00117     case FEATURE_BRIGHTNESS:      return "Brightness";
00118     case FEATURE_EXPOSURE:        return "Exposure";
00119     case FEATURE_SHARPNESS:       return "Sharpness";
00120     case FEATURE_WHITE_BALANCE:   return "White Balance";
00121     case FEATURE_HUE:             return "Hue";
00122     case FEATURE_SATURATION:      return "Saturation";
00123     case FEATURE_GAMMA:           return "Gamma";
00124     case FEATURE_SHUTTER:         return "Shutter";
00125     case FEATURE_GAIN:            return "Gain";
00126     case FEATURE_IRIS:            return "Iris";
00127     case FEATURE_FOCUS:           return "Focus";
00128     case FEATURE_TEMPERATURE:     return "Temperature";
00129     case FEATURE_TRIGGER:         return "Trigger";
00130     case FEATURE_TRIGGER_DELAY:   return "Trigger Delay";
00131     case FEATURE_WHITE_SHADING:   return "White Shading";
00132     case FEATURE_FRAME_RATE:      return "Frame Rate";
00133     case FEATURE_ZOOM:            return "Zoom";
00134     case FEATURE_PAN:             return "Pan";
00135     case FEATURE_TILT:            return "Tilt";
00136     case FEATURE_OPTICAL_FILTER:  return "Optical Filter";
00137     case FEATURE_CAPTURE_SIZE:    return "Capture Size";
00138     case FEATURE_CAPTURE_QUALITY: return "Capture Quality";
00139     default:                      return "invalid feature";
00140   }
00141 }
00142 
00143 
00144 //: Return string describing the feature mode
00145 vcl_string
00146 vidl_iidc1394_params::
00147 feature_mode_string(feature_mode_t fm)
00148 {
00149   switch (fm)
00150   {
00151     case FEATURE_MODE_MANUAL:         return "Manual";
00152     case FEATURE_MODE_AUTO:           return "Automatic";
00153     case FEATURE_MODE_ONE_PUSH_AUTO:  return "One Push";
00154     default:                          return "invalid feature mode";
00155   }
00156 }
00157 
00158 
00159 //: Return the format number from the video mode enumeration
00160 unsigned int
00161 vidl_iidc1394_params::
00162 video_format_val(video_mode_t m)
00163 {
00164   if ((m>=MODE_160x120_YUV444)&&(m<=MODE_640x480_MONO16)) {
00165     return 0;
00166   }
00167   else if ((m>=MODE_800x600_YUV422)&&(m<=MODE_1024x768_MONO16)) {
00168     return 1;
00169   }
00170   else if ((m>=MODE_1280x960_YUV422)&&(m<=MODE_1600x1200_MONO16)) {
00171     return 2;
00172   }
00173   else if (m==MODE_EXIF) {
00174     return 6;
00175   }
00176   else if ((m>=MODE_FORMAT7_0)&&(m<=MODE_FORMAT7_7)) {
00177     return 7;
00178   }
00179   // unknown format
00180   return unsigned(-1);
00181 }
00182 
00183 
00184 //: Return the mode number from the video mode enumeration
00185 unsigned int
00186 vidl_iidc1394_params::
00187 video_mode_val(video_mode_t m)
00188 {
00189   if ((m>=MODE_160x120_YUV444)&&(m<=MODE_640x480_MONO16)) {
00190     return m - MODE_160x120_YUV444;
00191   }
00192   else if ((m>=MODE_800x600_YUV422)&&(m<=MODE_1024x768_MONO16)) {
00193     return m - MODE_800x600_YUV422;
00194   }
00195   else if ((m>=MODE_1280x960_YUV422)&&(m<=MODE_1600x1200_MONO16)) {
00196     return m - MODE_1280x960_YUV422;
00197   }
00198   else if (m==MODE_EXIF) {
00199     return 0;
00200   }
00201   else if ((m>=MODE_FORMAT7_0)&&(m<=MODE_FORMAT7_7)) {
00202     return m - MODE_FORMAT7_0;
00203   }
00204   // unknown mode value
00205   return unsigned(-1);
00206 }
00207 
00208 
00209 //: Return the video mode enumeration for a format and mode
00210 vidl_iidc1394_params::video_mode_t
00211 vidl_iidc1394_params::
00212 video_mode(unsigned int format, unsigned int mode)
00213 {
00214   assert(mode < 8);
00215   switch (format) {
00216     case 0:
00217       return video_mode_t(MODE_160x120_YUV444 + mode);
00218     case 1:
00219       return video_mode_t(MODE_800x600_YUV422 + mode);
00220     case 2:
00221       return video_mode_t(MODE_1280x960_YUV422 + mode);
00222     case 6:
00223       return MODE_EXIF;
00224     case 7:
00225       return video_mode_t(MODE_FORMAT7_0 + mode);
00226     default:
00227       return MODE_FORMAT7_0;
00228   }
00229   assert(false); // never reached
00230 }
00231 
00232 
00233 //: Return the pixel format of the video mode
00234 vidl_pixel_format
00235 vidl_iidc1394_params::pixel_format(video_mode_t m)
00236 {
00237   switch (m)
00238   {
00239     case MODE_160x120_YUV444:
00240       return VIDL_PIXEL_FORMAT_UYV_444;
00241 
00242     case MODE_320x240_YUV422:
00243     case MODE_640x480_YUV422:
00244     case MODE_800x600_YUV422:
00245     case MODE_1024x768_YUV422:
00246     case MODE_1280x960_YUV422:
00247     case MODE_1600x1200_YUV422:
00248       return VIDL_PIXEL_FORMAT_UYVY_422;
00249 
00250     case MODE_640x480_YUV411:
00251       return VIDL_PIXEL_FORMAT_UYVY_411;
00252 
00253     case MODE_640x480_RGB8:
00254     case MODE_800x600_RGB8:
00255     case MODE_1024x768_RGB8:
00256     case MODE_1280x960_RGB8:
00257     case MODE_1600x1200_RGB8:
00258       return VIDL_PIXEL_FORMAT_RGB_24;
00259 
00260     case MODE_640x480_MONO8:
00261     case MODE_800x600_MONO8:
00262     case MODE_1024x768_MONO8:
00263     case MODE_1280x960_MONO8:
00264     case MODE_1600x1200_MONO8:
00265       return VIDL_PIXEL_FORMAT_MONO_8;
00266 
00267     case MODE_640x480_MONO16:
00268     case MODE_800x600_MONO16:
00269     case MODE_1024x768_MONO16:
00270     case MODE_1280x960_MONO16:
00271     case MODE_1600x1200_MONO16:
00272       return VIDL_PIXEL_FORMAT_MONO_16;
00273 
00274     default:
00275       return VIDL_PIXEL_FORMAT_UNKNOWN;
00276   }
00277   assert(false); // never reached
00278 }
00279 
00280 
00281 //: Return the image resolution of the video mode
00282 bool
00283 vidl_iidc1394_params::resolution(video_mode_t m, unsigned& ni, unsigned& nj)
00284 {
00285   switch (m)
00286   {
00287     case MODE_160x120_YUV444:
00288       ni = 160;  nj = 120;  break;
00289     case MODE_320x240_YUV422:
00290       ni = 320;  nj = 240;  break;
00291     case MODE_640x480_YUV411:
00292     case MODE_640x480_YUV422:
00293     case MODE_640x480_RGB8:
00294     case MODE_640x480_MONO8:
00295     case MODE_640x480_MONO16:
00296       ni = 640;  nj = 480;  break;
00297     case MODE_800x600_YUV422:
00298     case MODE_800x600_RGB8:
00299     case MODE_800x600_MONO8:
00300     case MODE_800x600_MONO16:
00301       ni = 800;  nj = 600;  break;
00302     case MODE_1024x768_YUV422:
00303     case MODE_1024x768_RGB8:
00304     case MODE_1024x768_MONO8:
00305     case MODE_1024x768_MONO16:
00306       ni = 1024;  nj = 768;  break;
00307     case MODE_1280x960_YUV422:
00308     case MODE_1280x960_RGB8:
00309     case MODE_1280x960_MONO8:
00310     case MODE_1280x960_MONO16:
00311       ni = 1280;  nj = 960;  break;
00312     case MODE_1600x1200_YUV422:
00313     case MODE_1600x1200_RGB8:
00314     case MODE_1600x1200_MONO8:
00315     case MODE_1600x1200_MONO16:
00316       ni = 1600;  nj = 1200;  break;
00317     default:
00318       return false;
00319   }
00320   return true;
00321 }