Fawkes API Fawkes Development Version
yuvcm.h
1
2/**************************************************************************
3 * yuvcm.h - YUV colormap
4 *
5 * Created: Sat Mar 29 12:45:29 2008
6 * Copyright 2005-2008 Tim Niemueller [www.niemueller.de]
7 *
8 ***************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _FIREVISION_FVUTILS_COLORMAP_YUVCM_H_
25#define _FIREVISION_FVUTILS_COLORMAP_YUVCM_H_
26
27#include <fvutils/base/types.h>
28#include <fvutils/colormap/colormap.h>
29#include <sys/types.h>
30
31namespace firevision {
32
33class SharedMemoryLookupTable;
34
35class YuvColormap : public Colormap
36{
37public:
38 YuvColormap(unsigned int depth = 1, unsigned int width = 256, unsigned int height = 256);
39 YuvColormap(const char * shmem_lut_id,
40 unsigned int depth = 1,
41 unsigned int width = 256,
42 unsigned int height = 256);
43 YuvColormap(const char * shmem_lut_id,
44 bool destroy_on_free,
45 unsigned int depth = 1,
46 unsigned int width = 256,
47 unsigned int height = 256);
48 YuvColormap(YuvColormap *cm, const char *shmem_lut_id, bool destroy_on_free = false);
49 YuvColormap(const YuvColormap &cm);
50 virtual ~YuvColormap();
51
52 virtual color_t determine(unsigned int y, unsigned int u, unsigned int v) const;
53 virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c);
54
55 virtual void reset();
56 virtual void set(unsigned char *buffer);
57
58 virtual size_t size();
59
60 virtual unsigned char *get_buffer() const;
61
62 virtual Colormap &operator+=(const Colormap &cmlt);
63 virtual Colormap &operator+=(const char *filename);
64 virtual Colormap &operator=(const YuvColormap &yuvcm);
65
66 virtual unsigned int width() const;
67 virtual unsigned int height() const;
68 virtual unsigned int depth() const;
69 virtual unsigned int deepness() const;
70 unsigned int plane_size() const;
71
72 virtual std::list<ColormapFileBlock *> get_blocks();
73
74 void copy_uvplane(unsigned char *uvplane, unsigned int level);
75
76 void replace_color(color_t from, color_t to);
77
78private:
79 void constructor(unsigned int depth,
80 unsigned int width,
81 unsigned int height,
82 const char * shmem_lut_id = 0,
83 bool destroy_on_free = false);
84
86 unsigned char * lut_;
87 size_t lut_size_;
88
89 unsigned int width_;
90 unsigned int height_;
91 unsigned int depth_;
92 unsigned int depth_div_;
93 unsigned int width_div_;
94 unsigned int height_div_;
95 unsigned int plane_size_;
96};
97
98inline color_t
99YuvColormap::determine(unsigned int y, unsigned int u, unsigned int v) const
100{
101 return (color_t)
102 * (lut_ + (y / depth_div_) * plane_size_ + (v / height_div_) * width_ + (u / width_div_));
103}
104
105} // end namespace firevision
106
107#endif
Colormap interface.
Definition: colormap.h:37
Shared memory lookup table.
Definition: shm_lut.h:113
YUV Colormap.
Definition: yuvcm.h:36
virtual Colormap & operator=(const YuvColormap &yuvcm)
Assign operation.
Definition: yuvcm.cpp:296
void copy_uvplane(unsigned char *uvplane, unsigned int level)
Copy single U/V plane.
Definition: yuvcm.cpp:243
virtual Colormap & operator+=(const Colormap &cmlt)
Adds the given colormap to this colormap.
Definition: yuvcm.cpp:260
virtual unsigned char * get_buffer() const
Get the raw buffer of this colormap.
Definition: yuvcm.cpp:231
virtual size_t size()
Size in bytes of buffer returned by get_buffer().
Definition: yuvcm.cpp:212
void replace_color(color_t from, color_t to)
Replace a given color with another one.
Definition: yuvcm.cpp:361
YuvColormap(unsigned int depth=1, unsigned int width=256, unsigned int height=256)
Constructor.
Definition: yuvcm.cpp:60
virtual unsigned int height() const
Get height of colormap.
Definition: yuvcm.cpp:330
virtual void reset()
Reset colormap.
Definition: yuvcm.cpp:200
virtual std::list< ColormapFileBlock * > get_blocks()
Get file blocks for this colormap.
Definition: yuvcm.cpp:218
virtual unsigned int depth() const
Get depth of colormap.
Definition: yuvcm.cpp:336
virtual unsigned int width() const
Get width of colormap.
Definition: yuvcm.cpp:324
virtual ~YuvColormap()
Destructor.
Definition: yuvcm.cpp:182
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
Set color class for given YUV value.
Definition: yuvcm.cpp:194
virtual color_t determine(unsigned int y, unsigned int u, unsigned int v) const
Determine color class for given YUV value.
Definition: yuvcm.h:99
unsigned int plane_size() const
Get U/V plane size.
Definition: yuvcm.cpp:351
virtual unsigned int deepness() const
Get deepness of colormap.
Definition: yuvcm.cpp:342