Fawkes API  Fawkes Development Version
cmfile_yuvblock.cpp
1 
2 /**************************************************************************
3  * cmfile_yuvblock.cpp - FVFF Colormap File YUV Block
4  *
5  * Created: Mon Mar 31 18:10:01 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 #include <fvutils/colormap/cmfile_yuvblock.h>
25 #include <fvutils/colormap/cmfile.h>
26 #include <fvutils/colormap/yuvcm.h>
27 
28 #include <core/exceptions/software.h>
29 #include <cstring>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 /** @class ColormapFileYuvBlock <fvutils/colormap/cmfile_yuvblock.h>
37  * YUV block for colormap file.
38  * @author Tim Niemueller
39  */
40 
41 /** Constructor.
42  * @param cm YUV colormap that this block shall represent.
43  * @param level Y level
44  */
46  : ColormapFileBlock(CMFILE_TYPE_YUV, cm->plane_size(), sizeof(cmfile_yuvblock_header_t))
47 {
48  if ( level > cm->depth() ) {
49  throw fawkes::OutOfBoundsException("YuvColormap level is out of bounds", level, 0, cm->depth());
50  }
51 
52  __cm = cm;
53  __level = level;
54 
56  __header->range_from = level * cm->deepness() / cm->depth();
57  __header->range_to = ((level + 1) * cm->deepness() / cm->depth()) - 1;
58 
59  memcpy(_data, __cm->get_buffer() + level * cm->plane_size(), _data_size);
60 }
61 
62 
63 /** Copy Constructor.
64  * It is assumed that the block actually is a rectification LUT info block. Check that
65  * before calling this method.
66  * @param block block to copy
67  */
69  : ColormapFileBlock(block)
70 {
72 }
73 
74 
75 /** Range from value.
76  * @return range from value
77  */
78 unsigned int
80 {
81  return __header->range_from;
82 }
83 
84 
85 /** Range to value.
86  * @return range to value
87  */
88 unsigned int
90 {
91  return __header->range_to;
92 }
93 
94 } // end namespace firevision
virtual unsigned int deepness() const
Get deepness of colormap.
Definition: yuvcm.cpp:343
void * _data
Pointer to the internal data segment.
Definition: fvfile_block.h:55
unsigned int range_from() const
Range from value.
FireVision File Format data block.
Definition: fvfile_block.h:35
ColormapFileYuvBlock(YuvColormap *cm, unsigned int level=0)
Constructor.
YUV Colormap.
Definition: yuvcm.h:39
unsigned int range_to() const
Range to value.
void * _spec_header
Pointer to the content specific block header.
Definition: fvfile_block.h:57
FireVision data file block for colormap files.
Definition: cmfile_block.h:36
Block header for a YUV block in a ColormapFile.
virtual unsigned int depth() const
Get depth of colormap.
Definition: yuvcm.cpp:336
Index out of bounds.
Definition: software.h:88
size_t _data_size
Size of _data in bytes.
Definition: fvfile_block.h:56
unsigned int plane_size() const
Get U/V plane size.
Definition: yuvcm.cpp:353