OpenVideo Documentation

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

ConverterYV12.h

Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (C) 2004-2006  Graz University of Technology
00003  *
00004  * This framework is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This framework is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this framework; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * For further information please contact Dieter Schmalstieg under
00019  * <schmalstieg@icg.tu-graz.ac.at> or write to Dieter Schmalstieg,
00020  * Graz University of Technology, Institut für Maschinelles Sehen und Darstellen,
00021  * Inffeldgasse 16a, 8010 Graz, Austria.
00022  * ========================================================================
00023  * PROJECT: OpenVideo
00024  * ======================================================================== */
00029 /* ======================================================================= */
00030 
00031 //
00032 // Optimized Converter from YV12 to RGB565 and Luminance
00033 // Written from scratch by Daniel Wagner
00034 // For questions send a mail to: daniel@icg.tu-graz.ac.at
00035 //
00036 // Modified by Bernhard Reitinger in order to convert YV12 to RGBA
00037 //
00038 // Highly optimized C++ version. Uses look-up
00039 // tables for almost everything; thereby requires
00040 // no multiplication or if operations for doing
00041 // format conversion including saturation checks.
00042 //
00043 // Memory usage: allocates 3249 bytes for lookup tables.
00044 //
00045 // Should run pretty fast on any device. Intel IPP
00046 // probably includes a much faster version using WirelessMXX
00047 // (would only work on Intel XScale processors).
00048 //
00049 //
00050 
00051 #ifndef _CONVERTERYV12_H_
00052 #define _CONVERTERYV12_H_
00053 
00054 namespace openvideo {
00055     
00056     class ConverterYV12
00057     {
00058     public:
00059 
00060     enum FORMAT {
00061         FORMAT_INVALID = 0,
00062         FORMAT_RGB565  = 1,
00063         FORMAT_RGB555  = 2,
00064         FORMAT_RGB24   = 3,
00065         FORMAT_RGB32   = 4,
00066         FORMAT_YV12    = 5
00067     };
00068     
00069     enum {
00070         LUTCAP_MIN = -153,
00071         LUTCAP_MAX = 535,
00072         CHANNEL_RANGE = 256
00073     };
00074 
00075     ConverterYV12()  {  init();  }
00076 
00077     ~ConverterYV12()  {  deinit();  }
00078 
00079     void convertToRGB32(const unsigned char* nSrcYUV, int nWidth, int nHeight, unsigned int* nDstRGB32, bool nSwizzle34, int nCropX=0, int nCropY=0);
00080 
00081     void convertToLum(const unsigned char* nSrcYUV, int nWidth, int nHeight, unsigned char* nDstLum, bool nSwizzle34, int nCropX=0, int nCropY=0);
00082 
00083     protected:
00084     void init();
00085     void deinit();
00086 
00087     int cap(int nV)                 {  /*assert(nV>=LUTCAP_MIN && nV<=LUTCAP_MAX);*/  return lutCap[nV];  }
00088 
00089     int getV_for_Red(int nV)        {  /*assert(nV>=0 && nV<CHANNEL_RANGE);*/  return lutV_for_Red[nV];  }
00090     int getU_for_Blue(int nU)       {  /*assert(nU>=0 && nU<CHANNEL_RANGE);*/  return lutU_for_Blue[nU];  }
00091     int getV_for_Green(int nV)      {  /*assert(nV>=0 && nV<CHANNEL_RANGE);*/  return lutV_for_Green[nV];  }
00092     int getU_for_Green(int nU)      {  /*assert(nU>=0 && nU<CHANNEL_RANGE);*/  return lutU_for_Green[nU];  }
00093     int getY(int nY)                {  /*assert(nY>=0 && nY<CHANNEL_RANGE);*/  return lutY[nY];  }
00094 
00095     unsigned char   *lutCap0,
00096         *lutCap;
00097 
00098     short           *lutV_for_Red,
00099         *lutU_for_Blue,
00100         *lutV_for_Green,
00101         *lutU_for_Green,
00102         *lutY;
00103     };
00104 
00105 
00106 }  // namespace openvideo
00107 
00108 #endif // _CONVERTERYV12_H_
00109 
00110 //========================================================================
00111 // End of $FILENAME$
00112 //========================================================================
00113 // Local Variables:
00114 // mode: c++
00115 // c-basic-offset: 4
00116 // eval: (c-set-offset 'substatement-open 0)
00117 // eval: (c-set-offset 'case-label '+)
00118 // eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00119 // eval: (setq indent-tabs-mode nil)
00120 // End:
00121 //========================================================================
 This page was generated at Wed May 31 13:04:16 2006 for OpenVideo by Doxygen.
 If you have any comments, please send a message to schmalstieg@icg.tu-graz.ac.at.
www.studierstube.org