VideoTools
|
Provides rgb/yuv colourspace mapping functions. More...
Classes | |
class | triple |
A 3-tuple for holding rgb or yuv triples. More... | |
class | cache |
A cache for a complete set of rgb/yuv mappings, amounting to about 50MB of data. More... | |
class | matrix_256_inverse |
Rgb-to-yuv matrix using scaled integers where 256 is 1. More... | |
class | matrix_256 |
Yuv-to-rgb matrix using scaled integers where 256 is 1. More... | |
class | matrix_1000_inverse |
Rgb-to-yuv matrix using scaled integers where 1000 is 1. More... | |
class | matrix_1000 |
Yuv-to-rgb matrix using scaled integers where 1000 is 1. More... | |
class | range_y |
Defines the "digital" range for y component. More... | |
class | range_uv |
Defines the "digital" range for u/v components. More... | |
class | range_rgb |
Defines the "digital" range for r/g/b components. More... | |
class | fp_1000 |
A simple fixed-point number class with a scale factor of 1000. More... | |
class | fp_256 |
A simple fixed-point number class with a scale factor of 256. More... | |
class | converter_double |
An adaptor for double. More... | |
class | converter_fp |
An adaptor for fp_#. More... | |
Functions | |
template<typename Tmatrix , typename Tconverter , typename Ta , typename Ttriple > | |
g__constexpr Tconverter::fp_type | product (Ta a1, Ta a2, Ta a3, Ttriple tfp) g__noexcept |
Does a cross-product using fp types. | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | y_imp (Ttriple rgb) g__noexcept |
Calculates y from rgb using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | u_imp (Ttriple rgb) g__noexcept |
Calculates u (cb) from rgb using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | v_imp (Ttriple rgb) g__noexcept |
Calculates v (cr) from rgb using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | r_imp (Ttriple yuv) g__noexcept |
Calculates r from yuv using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | g_imp (Ttriple yuv) g__noexcept |
Calculates g from yuv using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Ttriple > | |
g__constexpr Tconverter::fp_type | b_imp (Ttriple yuv) g__noexcept |
Calculates b from yuv using fp types. More... | |
template<typename Tmatrix , typename Tconverter , typename Trange_rgb , typename Trange_y , typename Trange_uv , typename Ttriple > | |
Ttriple | yuv_imp (Ttriple rgb) g__noexcept |
A top-level function that calculates yuv from rgb with all the implementation options exposed as template parameters. | |
template<typename Tmatrix , typename Tconverter , typename Trange_rgb , typename Trange_y , typename Trange_uv , typename Ttriple > | |
Ttriple | rgb_imp (Ttriple yuv) g__noexcept |
A top-level function that calculates rgb from yuv with all the implementation options exposed as template parameters. | |
triple< unsigned char > | yuv (triple< unsigned char > rgb) g__noexcept |
A top-level function that calculates yuv from rgb with default implementation options. | |
triple< unsigned char > | rgb (triple< unsigned char > yuv) g__noexcept |
A top-level function that calculates rgb from yuv with default implementation options. | |
unsigned char | r_int (unsigned char y, unsigned char, unsigned char v) g__noexcept |
A fast conversion from yuv to r. | |
unsigned char | g_int (unsigned char y, unsigned char u, unsigned char v) g__noexcept |
A fast conversion from yuv to g. | |
unsigned char | b_int (unsigned char y, unsigned char u, unsigned char) g__noexcept |
A fast conversion from yuv to b. | |
triple< unsigned char > | rgb_int (triple< unsigned char > yuv) g__noexcept |
A fast conversion from yuv to rgb. | |
unsigned char | y_int (unsigned char r, unsigned char g, unsigned char b) |
A fast conversion from rgb to y. | |
unsigned char | u_int (unsigned char r, unsigned char g, unsigned char b) |
A fast conversion from rgb to u. | |
unsigned char | v_int (unsigned char r, unsigned char g, unsigned char b) |
A fast conversion from rgb to v. | |
triple< unsigned char > | yuv_int (triple< unsigned char > rgb) g__noexcept |
A fast conversion from rgb to yuv. | |
template<typename T > | |
g__constexpr T | clamp (T min, T value, T max) |
Does min/max clamping. | |
template<typename Trange , typename Tout , typename Tin > | |
g__constexpr Tout | clamp (Tin value) |
Does min/max clamping to a range. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_range_from_unsigned (typename Tconverter::fp_type fp) g__noexcept |
Scales an unsigned fp value to another fp value in the relevant range. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_range_from_signed (typename Tconverter::fp_type fp) g__noexcept |
Scales a signed fp value to another fp value in the relevant range. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_range_imp (typename Tconverter::fp_type fp) g__noexcept |
Scales an fp value to another fp value in the relevant range. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Trange::value_type | map_to_range (typename Tconverter::fp_type fp) g__noexcept |
Maps an "analogue" space value to a "digial" range value. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_space_signed (typename Trange::value_type n) g__noexcept |
Maps a "digital" range value to a signed "analogue" space value. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_space_unsigned (typename Trange::value_type n) g__noexcept |
Maps a "digital" range value to an unsigned "analogue" space value. | |
template<typename Trange , typename Tconverter > | |
g__constexpr Tconverter::fp_type | map_to_space_imp (typename Trange::value_type n) g__noexcept |
Maps a "digital" range value to an "analogue" space value. | |
template<typename Tconverter , typename Trange1 , typename Trange2 , typename Trange3 > | |
g__constexpr triple< typename Tconverter::fp_type > | map_to_space (triple< typename Trange1::value_type > t) g__noexcept |
Maps a "digital" range triple to an "analogue" space triple. | |
fp_1000 | operator* (const fp_1000 &a, const fp_1000 &b) g__noexcept |
fp_1000 | operator/ (const fp_1000 &a, const fp_1000 &b) g__noexcept |
fp_1000 | operator+ (const fp_1000 &a, const fp_1000 &b) g__noexcept |
fp_1000 | operator- (const fp_1000 &a, const fp_1000 &b) g__noexcept |
bool | operator< (const fp_1000 &a, const fp_1000 &b) g__noexcept |
bool | operator> (const fp_1000 &a, const fp_1000 &b) g__noexcept |
fp_256 | operator* (fp_256 a, fp_256 b) g__noexcept |
fp_256 | operator/ (fp_256 a, fp_256 b) g__noexcept |
fp_256 | operator+ (fp_256 a, fp_256 b) g__noexcept |
fp_256 | operator- (fp_256 a, fp_256 b) g__noexcept |
bool | operator< (fp_256 a, fp_256 b) g__noexcept |
bool | operator> (fp_256 a, fp_256 b) g__noexcept |
Provides rgb/yuv colourspace mapping functions.
Synopsis.
Most code will be content to use just the two lookup functions rgb_int() and yuv_int(), and in that case the bulk of the code here is only used at built-time to generate the lookup tables that underlie those functions.
Otherwise, there are two top-level functions rgb_imp() and yuv_imp() with lots of template parameters providing maximum flexibility, and two convenience functions rgb() and yuv() that use rgb_imp() and yuv_imp() with sensible template defaults.
The implementation recognises that the core matrix multiplication has to be performed with a higher-precision numeric datatype than is used at the interface, and that the values used at the interface are sometimes constrained to a range that is not a convenient power of two (ie. head-room and toe-room for YUV values). The internal datatype can be considered to be "analogue" and the external datatype "digital", alluding to their different levels of precision.
The internal datatype is most naturally "double", but for speed on some machines it can be better to used a fixed-point type. Two fixed-point classes are provided, "fp_256" and "fp_1000", together with adaptors that are used to convert between internal and external values. If any internal datatype other than "double", "fp_256" or "fp_1000" is used then it will need to have a corresponding adaptor class (as per "converter_double").
g__constexpr Tconverter::fp_type Gr::ColourSpace::b_imp | ( | Ttriple | yuv | ) |
Calculates b from yuv using fp types.
Uses the matrix given by the template parameter.
Definition at line 187 of file grcolourspace.h.
g__constexpr Tconverter::fp_type Gr::ColourSpace::g_imp | ( | Ttriple | yuv | ) |
Calculates g from yuv using fp types.
Uses the matrix given by the template parameter.
Definition at line 177 of file grcolourspace.h.
g__constexpr Tconverter::fp_type Gr::ColourSpace::r_imp | ( | Ttriple | yuv | ) |
Calculates r from yuv using fp types.
Uses the matrix given by the template parameter.
Definition at line 167 of file grcolourspace.h.
g__constexpr Tconverter::fp_type Gr::ColourSpace::u_imp | ( | Ttriple | rgb | ) |
Calculates u (cb) from rgb using fp types.
Uses the matrix given by the template parameter.
Definition at line 147 of file grcolourspace.h.
g__constexpr Tconverter::fp_type Gr::ColourSpace::v_imp | ( | Ttriple | rgb | ) |
Calculates v (cr) from rgb using fp types.
Uses the matrix given by the template parameter.
Definition at line 157 of file grcolourspace.h.
g__constexpr Tconverter::fp_type Gr::ColourSpace::y_imp | ( | Ttriple | rgb | ) |
Calculates y from rgb using fp types.
Uses the matrix given by the template parameter.
Definition at line 137 of file grcolourspace.h.