yuv.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*- */
00002 /* $Id: yuv.h 35110 2011-01-05 00:31:58Z joq $ */
00003 /*
00004  * Copyright (C) 2000-2004 Damien Douxchamps  <ddouxchamps@users.sf.net>
00005  *                         Dan Dennedy  <dan@dennedy.org>
00006  *
00007  * NOTE: On 4 Jan. 2011, this file was re-licensed under the GNU LGPL
00008  * with permission of the original GPL authors: Damien Douxchamps and
00009  * Dan Dennedy.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public License
00013  * as published by the Free Software Foundation; either version 2 of
00014  * the License, or (at your option) any later version.
00015  * 
00016  * This program is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  * 
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00024  * 02111-1307, USA.
00025  */
00026 
00027 /* Copyright (C) 2010 Jack O'Quin
00028  *
00029  * Minor changes for use with the ROS camera1394 driver:
00030  *
00031  *  * generate RGB rather than BGR
00032  *  * repackage as a separate file
00033  *  * use yuv namespace
00034  */
00035 
00036 #ifndef _YUV_H_
00037 #define _YUV_H_
00038 
00039 #include <dc1394/dc1394.h>
00040 
00046 namespace yuv
00047 {
00048 
00050   void inline uyv2rgb(const unsigned char *src, unsigned char *dest,
00051                       unsigned long long int NumPixels)
00052   {
00053     register int i = NumPixels + (NumPixels << 1) - 1;
00054     register int j = NumPixels + (NumPixels << 1) - 1;
00055     register int y, u, v;
00056     register int r, g, b;
00057 
00058     while (i > 0) {
00059       v = src[i--] - 128;
00060       y = src[i--];
00061       u = src[i--] - 128;
00062       YUV2RGB(y, u, v, r, g, b);
00063       dest[j--] = b;
00064       dest[j--] = g;
00065       dest[j--] = r;
00066     }
00067   }
00068 
00070   void inline uyvy2rgb(unsigned char *src, unsigned char *dest,
00071                        unsigned long long int NumPixels)
00072   {
00073     register int i = (NumPixels << 1)-1;
00074     register int j = NumPixels + ( NumPixels << 1 ) -1;
00075     register int y0, y1, u, v;
00076     register int r, g, b;
00077 
00078     while (i > 0)
00079       {
00080         y1 = (unsigned char) src[i--];
00081         v  = (unsigned char) src[i--] - 128;
00082         y0 = (unsigned char) src[i--];
00083         u  = (unsigned char) src[i--] - 128;
00084         YUV2RGB (y1, u, v, r, g, b);
00085         dest[j--] = b;
00086         dest[j--] = g;
00087         dest[j--] = r;
00088         YUV2RGB (y0, u, v, r, g, b);
00089         dest[j--] = b;
00090         dest[j--] = g;
00091         dest[j--] = r;
00092       }
00093   }
00094 
00096   void inline uyyvyy2rgb(const unsigned char *src, unsigned char *dest,
00097                          unsigned long long int NumPixels)
00098   {
00099     register int i = NumPixels + (NumPixels >> 1) - 1;
00100     register int j = NumPixels + (NumPixels << 1) - 1;
00101     register int y0, y1, y2, y3, u, v;
00102     register int r, g, b;
00103 
00104     while (i > 0) {
00105       y3 = src[i--];
00106       y2 = src[i--];
00107       v = src[i--] - 128;
00108       y1 = src[i--];
00109       y0 = src[i--];
00110       u = src[i--] - 128;
00111       YUV2RGB(y3, u, v, r, g, b);
00112       dest[j--] = b;
00113       dest[j--] = g;
00114       dest[j--] = r;
00115       YUV2RGB(y2, u, v, r, g, b);
00116       dest[j--] = b;
00117       dest[j--] = g;
00118       dest[j--] = r;
00119       YUV2RGB(y1, u, v, r, g, b);
00120       dest[j--] = b;
00121       dest[j--] = g;
00122       dest[j--] = r;
00123       YUV2RGB(y0, u, v, r, g, b);
00124       dest[j--] = b;
00125       dest[j--] = g;
00126       dest[j--] = r;
00127     }
00128   }
00129 }
00130 
00131 #endif // _YUV_H_


camera1394stereo
Author(s): Joan Pau Beltran
autogenerated on Sun Oct 5 2014 22:44:07