24#include <core/exceptions/software.h>
25#include <fvutils/colormap/cmfile.h>
26#include <fvutils/colormap/cmfile_yuvblock.h>
27#include <fvutils/colormap/yuvcm.h>
28#include <fvutils/ipc/shm_lut.h>
106 constructor(cm->
depth(), cm->
width(), cm->
height(), shmem_lut_id, destroy_on_free);
107 memcpy(lut_, cm->lut_, lut_size_);
118 memcpy(lut_, cm.lut_, lut_size_);
129YuvColormap::constructor(
unsigned int depth,
132 const char * shmem_lut_id,
133 bool destroy_on_free)
162 depth_div_ = 256 / depth_;
163 width_div_ = 256 / width_;
164 height_div_ = 256 / height_;
165 plane_size_ = width_ * height_;
167 if (shmem_lut_id != NULL) {
169 new SharedMemoryLookupTable(shmem_lut_id, width_, height_, depth_, 1);
171 lut_ = shm_lut_->
buffer();
175 lut_size_ = (size_t)width_ * (
size_t)height_ * (size_t)depth_;
176 lut_ = (
unsigned char *)malloc(lut_size_);
178 memset(lut_, C_OTHER, lut_size_);
196 *(lut_ + (y / depth_div_) * plane_size_ + (v / height_div_) * width_ + (u / width_div_)) = c;
202 memset(lut_, C_OTHER, lut_size_);
208 memcpy(lut_, buffer, lut_size_);
217std::list<ColormapFileBlock *>
220 std::list<ColormapFileBlock *> rv;
222 for (
unsigned int i = 0; i < depth_; ++i) {
245 if (level > depth_) {
249 memcpy(lut_ + level * plane_size_, uvplane, plane_size_);
267 if ((width_ != tc->width_) || (height_ != tc->height_) || (depth_ != tc->depth_)) {
271 unsigned char *this_lut = lut_;
272 unsigned char *other_lut = tc->lut_;
274 for (
unsigned int i = 0; i < plane_size_ * depth_; ++i) {
275 if ((*this_lut == C_OTHER) || (*this_lut == C_BACKGROUND)) {
277 if ((*other_lut != C_OTHER) && (*other_lut != C_BACKGROUND)) {
279 *this_lut = *other_lut;
298 if (lut_size_ != yuvcm.lut_size_) {
302 memcpy(lut_, yuvcm.lut_, lut_size_);
363 unsigned char *this_lut = lut_;
365 for (
unsigned int i = 0; i < plane_size_ * depth_; ++i, ++this_lut) {
366 if (*this_lut == from)
Expected parameter is missing.
size_t data_size() const
Get the size of the data-segment.
void set_destroy_on_delete(bool destroy)
Set deletion behaviour.
YUV block for colormap file.
Colormap * get_colormap()
Get a freshly generated colormap based on current file content.
virtual void read(const char *file_name)
Read file.
unsigned char * buffer() const
Get LUT buffer.
virtual Colormap & operator=(const YuvColormap &yuvcm)
Assign operation.
void copy_uvplane(unsigned char *uvplane, unsigned int level)
Copy single U/V plane.
virtual Colormap & operator+=(const Colormap &cmlt)
Adds the given colormap to this colormap.
virtual unsigned char * get_buffer() const
Get the raw buffer of this colormap.
virtual size_t size()
Size in bytes of buffer returned by get_buffer().
void replace_color(color_t from, color_t to)
Replace a given color with another one.
YuvColormap(unsigned int depth=1, unsigned int width=256, unsigned int height=256)
Constructor.
virtual unsigned int height() const
Get height of colormap.
virtual void reset()
Reset colormap.
virtual std::list< ColormapFileBlock * > get_blocks()
Get file blocks for this colormap.
virtual unsigned int depth() const
Get depth of colormap.
virtual unsigned int width() const
Get width of colormap.
virtual ~YuvColormap()
Destructor.
virtual void set(unsigned int y, unsigned int u, unsigned int v, color_t c)
Set color class for given YUV value.
unsigned int plane_size() const
Get U/V plane size.
virtual unsigned int deepness() const
Get deepness of colormap.
Fawkes library namespace.