cgv
|
the packing_info class stores information about packed integers structures. More...
#include <packing_info.h>
Public Member Functions | |
packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0) | |
construct packing information from alignment and bit depths. | |
void | clear () |
clear packing info information | |
unsigned | get_bit_depth (unsigned ci) const |
return the bit depth of the ci-th component | |
void | set_bit_depth (unsigned ci, unsigned depth) |
set the bit depth of the ci-th component | |
bool | is_packing () const |
return whether packing is enabled | |
void | set_packing (bool enable=true) |
set the packing flag | |
unsigned int | get_component_alignment () const |
return the component alignment in bits in the packed case and in bytes in the unpacked case | |
void | set_component_alignment (unsigned a) |
set the component alignment in bits in the packed case and in bytes in the unpacked case | |
int | get_signed (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
unsigned int | get_unsigned (unsigned ci, const void *ptr) const |
return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | set_signed (unsigned ci, void *ptr, int v) const |
set the ci-th component of the data entry pointed to by the given pointer of a signed packed component | |
bool | set_unsigned (unsigned ci, void *ptr, unsigned v) const |
set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component | |
bool | operator== (const packing_info &pi) const |
equal comparison | |
bool | operator!= (const packing_info &pi) const |
unequal comparison | |
Static Public Member Functions | |
static size_t | align (size_t v, unsigned a) |
return the next integer larger or equal to v which is dividable by a | |
Protected Member Functions | |
bool | prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const |
bool | prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const |
unsigned int | get_bit_offset (unsigned ci) const |
Protected Attributes | |
bool | is_packed: 1 |
unsigned | bd0: 6 |
unsigned | bd1: 6 |
unsigned | bd2: 6 |
unsigned | bd3: 6 |
unsigned | ca: 6 |
the packing_info class stores information about packed integers structures.
It is typically used to define packed component formats. The stored information includes, whether packing is used, the alignment of the components and bit depths of up to 4 components. The aligment is an integer defining a multiple to which the components are aligned. If the alignment is 1, the components are packed densely. If it is for example 8, the components are stored at starting at locations that are multiples of 8. For example if the components have bit depth 6 and the alignment is 8, then the first component is stored starting with the first bit, the second component starting with the 8th bit and so on. In case no packing is used the alignment is measured in bytes. The bit depths and alignment are stored as unsigned integers with 6 bits, i.e. the maximum value is 63.
Definition at line 24 of file packing_info.h.
cgv::data::packing_info::packing_info | ( | unsigned | align = 1 , |
unsigned | d0 = 0 , |
||
unsigned | d1 = 0 , |
||
unsigned | d2 = 0 , |
||
unsigned | d3 = 0 |
||
) |
construct packing information from alignment and bit depths.
If no bit depths are given, the components are not packed and the alignment is in bytes. If one or more depths are specified, the alignment is in bits. If exactly one depth is given, all component bit depths are set to this bit depth
Definition at line 12 of file packing_info.cxx.
|
static |
return the next integer larger or equal to v which is dividable by a
Definition at line 8 of file packing_info.cxx.
Referenced by cgv::data::data_view_base::data_view_base(), cgv::data::component_format::get_entry_size(), cgv::data::component_format::set_component_format(), and cgv::media::image::bmp_writer::write_image().
void cgv::data::packing_info::clear | ( | ) |
clear packing info information
Definition at line 20 of file packing_info.cxx.
Referenced by cgv::data::component_format::clear().
unsigned cgv::data::packing_info::get_bit_depth | ( | unsigned | ci | ) | const |
return the bit depth of the ci-th component
Definition at line 26 of file packing_info.cxx.
Referenced by cgv::data::fmt1_compares_better(), cgv::data::component_format::get_entry_size(), and operator==().
|
protected |
Definition at line 69 of file packing_info.cxx.
unsigned int cgv::data::packing_info::get_component_alignment | ( | ) | const |
return the component alignment in bits in the packed case and in bytes in the unpacked case
Definition at line 43 of file packing_info.cxx.
Referenced by cgv::data::component_format::get_entry_size(), operator==(), and cgv::render::gl::gl_context::read_frame_buffer().
int cgv::data::packing_info::get_signed | ( | unsigned | ci, |
const void * | ptr | ||
) | const |
return the ci-th component of the data entry pointed to by the given pointer of a signed packed component
Definition at line 76 of file packing_info.cxx.
References cgv::utils::disable_upper_bits(), cgv::utils::enable_upper_bits(), and cgv::utils::is_bit_set().
unsigned cgv::data::packing_info::get_unsigned | ( | unsigned | ci, |
const void * | ptr | ||
) | const |
return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
Definition at line 88 of file packing_info.cxx.
References cgv::utils::disable_upper_bits().
bool cgv::data::packing_info::is_packing | ( | ) | const |
return whether packing is enabled
Definition at line 35 of file packing_info.cxx.
Referenced by cgv::data::fmt1_compares_better(), cgv::data::component_format::get_entry_size(), and operator==().
bool cgv::data::packing_info::operator!= | ( | const packing_info & | pi | ) | const |
unequal comparison
Definition at line 122 of file packing_info.cxx.
bool cgv::data::packing_info::operator== | ( | const packing_info & | pi | ) | const |
equal comparison
Definition at line 111 of file packing_info.cxx.
References get_bit_depth(), get_component_alignment(), and is_packing().
|
protected |
Definition at line 60 of file packing_info.cxx.
|
protected |
Definition at line 51 of file packing_info.cxx.
void cgv::data::packing_info::set_bit_depth | ( | unsigned | ci, |
unsigned | depth | ||
) |
set the bit depth of the ci-th component
Definition at line 30 of file packing_info.cxx.
Referenced by cgv::data::component_format::set_component_format().
void cgv::data::packing_info::set_component_alignment | ( | unsigned | a | ) |
set the component alignment in bits in the packed case and in bytes in the unpacked case
Definition at line 47 of file packing_info.cxx.
Referenced by cgv::data::component_format::set_component_format().
void cgv::data::packing_info::set_packing | ( | bool | enable = true | ) |
set the packing flag
Definition at line 39 of file packing_info.cxx.
Referenced by cgv::data::component_format::set_component_format().
bool cgv::data::packing_info::set_signed | ( | unsigned | ci, |
void * | ptr, | ||
int | v | ||
) | const |
set the ci-th component of the data entry pointed to by the given pointer of a signed packed component
Definition at line 97 of file packing_info.cxx.
References cgv::utils::set_bits().
bool cgv::data::packing_info::set_unsigned | ( | unsigned | ci, |
void * | ptr, | ||
unsigned | v | ||
) | const |
set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
Definition at line 104 of file packing_info.cxx.
References cgv::utils::set_bits().
|
protected |
Definition at line 28 of file packing_info.h.
|
protected |
Definition at line 29 of file packing_info.h.
|
protected |
Definition at line 30 of file packing_info.h.
|
protected |
Definition at line 31 of file packing_info.h.
|
protected |
Definition at line 32 of file packing_info.h.
|
protected |
Definition at line 27 of file packing_info.h.