yuvcm.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __FIREVISION_FVUTILS_COLORMAP_YUVCM_H_
00025 #define __FIREVISION_FVUTILS_COLORMAP_YUVCM_H_
00026
00027 #include <fvutils/colormap/colormap.h>
00028
00029 #include <sys/types.h>
00030 #include <fvutils/base/types.h>
00031
00032 namespace firevision {
00033 #if 0
00034 }
00035 #endif
00036
00037 class SharedMemoryLookupTable;
00038
00039 class YuvColormap : public Colormap
00040 {
00041 public:
00042 YuvColormap(unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256);
00043 YuvColormap(const char *shmem_lut_id, unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256);
00044 YuvColormap(const char *shmem_lut_id, bool destroy_on_free, unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256);
00045 YuvColormap(YuvColormap *cm, const char *shmem_lut_id, bool destroy_on_free = false);
00046 virtual ~YuvColormap();
00047
00048 virtual color_t determine(unsigned int y, unsigned int u, unsigned int v) const;
00049 virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c);
00050
00051 virtual void reset();
00052 virtual void set(unsigned char *buffer);
00053
00054 virtual size_t size();
00055
00056 virtual unsigned char * get_buffer() const;
00057
00058 virtual Colormap & operator+=(const Colormap & cmlt);
00059 virtual Colormap & operator+=(const char *filename);
00060 virtual Colormap & operator=(const YuvColormap &yuvcm);
00061
00062 virtual unsigned int width() const;
00063 virtual unsigned int height() const;
00064 virtual unsigned int depth() const;
00065 virtual unsigned int deepness() const;
00066 unsigned int plane_size() const;
00067
00068 virtual std::list<ColormapFileBlock *> get_blocks();
00069
00070 void copy_uvplane(unsigned char *uvplane, unsigned int level);
00071
00072 private:
00073 void constructor(unsigned int depth, unsigned int width, unsigned int height,
00074 const char *shmem_lut_id = 0, bool destroy_on_free = false);
00075
00076
00077 SharedMemoryLookupTable *__shm_lut;
00078 unsigned char *__lut;
00079 size_t __lut_size;
00080
00081 unsigned int __width;
00082 unsigned int __height;
00083 unsigned int __depth;
00084 unsigned int __depth_div;
00085 unsigned int __width_div;
00086 unsigned int __height_div;
00087 unsigned int __plane_size;
00088 };
00089
00090
00091 inline color_t
00092 YuvColormap::determine(unsigned int y, unsigned int u, unsigned int v) const
00093 {
00094 return (color_t) *(__lut + (y / __depth_div) * __plane_size + (v / __height_div) * __width + (u / __width_div));
00095 }
00096
00097 }
00098
00099 #endif