core/vidl/vidl_v4l_params.cxx
Go to the documentation of this file.
00001 // This is core/vidl/vidl_v4l_params.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Brendan McCane
00008 // \date   16 Mar 2006
00009 //
00010 //-----------------------------------------------------------------------------
00011 
00012 #include "vidl_v4l_ulong_fix.h" // include first to fix linux/videodev.h ulong problem
00013 #include "vidl_v4l_params.h"
00014 #include "vidl_pixel_format.h"
00015 
00016 //: convert from vidl pixel format to v4l pixel format
00017 int vidl_v4l_params::vidlpf_to_v4lpf(vidl_pixel_format vid_pf)
00018 {
00019     switch (vid_pf)
00020     {
00021     case VIDL_PIXEL_FORMAT_UNKNOWN: return -1;
00022     case VIDL_PIXEL_FORMAT_RGB_24: return VIDEO_PALETTE_RGB24;
00023     case VIDL_PIXEL_FORMAT_RGB_24P: return -1;
00024     case VIDL_PIXEL_FORMAT_BGR_24: return -1;
00025     case VIDL_PIXEL_FORMAT_RGBA_32: return VIDEO_PALETTE_RGB32;
00026     case VIDL_PIXEL_FORMAT_RGBA_32P: return -1;
00027     case VIDL_PIXEL_FORMAT_RGB_565: return VIDEO_PALETTE_RGB565;
00028     case VIDL_PIXEL_FORMAT_RGB_555: return VIDEO_PALETTE_RGB555;
00029     case VIDL_PIXEL_FORMAT_YUV_444P: return -1;
00030     case VIDL_PIXEL_FORMAT_YUV_422P: return VIDEO_PALETTE_YUV422P;
00031     case VIDL_PIXEL_FORMAT_YUV_420P: return VIDEO_PALETTE_YUV420P;
00032     case VIDL_PIXEL_FORMAT_YVU_420P: return -1;
00033     case VIDL_PIXEL_FORMAT_YUV_411P: return VIDEO_PALETTE_YUV411P;
00034     case VIDL_PIXEL_FORMAT_YUV_410P: return VIDEO_PALETTE_YUV410P;
00035     case VIDL_PIXEL_FORMAT_UYV_444: return -1;
00036     case VIDL_PIXEL_FORMAT_YUYV_422: return VIDEO_PALETTE_YUYV;
00037     case VIDL_PIXEL_FORMAT_UYVY_422: return VIDEO_PALETTE_UYVY;
00038     case VIDL_PIXEL_FORMAT_UYVY_411: return -1;
00039     case VIDL_PIXEL_FORMAT_MONO_1: return -1;
00040     case VIDL_PIXEL_FORMAT_MONO_8: return VIDEO_PALETTE_GREY;
00041     case VIDL_PIXEL_FORMAT_MONO_16: return -1;
00042     default: return -1;
00043     }
00044 }
00045 
00046 //: convert from v4l pixel format to vidl pixel format
00047 vidl_pixel_format vidl_v4l_params::v4lpf_to_vidlpf(int v4l_pf)
00048 {
00049     switch (v4l_pf)
00050     {
00051     case VIDEO_PALETTE_RGB24: return VIDL_PIXEL_FORMAT_RGB_24;
00052     case VIDEO_PALETTE_RGB32: return VIDL_PIXEL_FORMAT_RGBA_32;
00053     case VIDEO_PALETTE_RGB565: return VIDL_PIXEL_FORMAT_RGB_565;
00054     case VIDEO_PALETTE_RGB555: return VIDL_PIXEL_FORMAT_RGB_555;
00055     case VIDEO_PALETTE_YUV422P: return VIDL_PIXEL_FORMAT_YUV_422P;
00056     case VIDEO_PALETTE_YUV420P: return VIDL_PIXEL_FORMAT_YUV_420P;
00057     case VIDEO_PALETTE_YUV411P: return VIDL_PIXEL_FORMAT_YUV_411P;
00058     case VIDEO_PALETTE_YUV410P: return VIDL_PIXEL_FORMAT_YUV_410P;
00059     case VIDEO_PALETTE_YUYV: return VIDL_PIXEL_FORMAT_YUYV_422;
00060     case VIDEO_PALETTE_UYVY: return VIDL_PIXEL_FORMAT_UYVY_422;
00061     case VIDEO_PALETTE_GREY: return VIDL_PIXEL_FORMAT_MONO_8;
00062     default: return VIDL_PIXEL_FORMAT_UNKNOWN;
00063     }
00064 }
00065