LUTCache<GammaLUT> GammaLUT::cache;
-GammaLUT::GammaLUT (int bit_depth, float gamma)
+GammaLUT::GammaLUT (int bit_depth, float gamma, bool linearised)
: _bit_depth (bit_depth)
, _gamma (gamma)
+ , _linearised (linearised)
{
_lut = new float[int(std::pow(2.0f, _bit_depth))];
int const bit_length = pow (2, _bit_depth);
- for (int i = 0; i < bit_length; ++i) {
- _lut[i] = pow(float(i) / (bit_length - 1), gamma);
+
+ if (_linearised) {
+ for (int i = 0; i < bit_length; ++i) {
+ float const p = static_cast<float> (i) / (bit_length - 1);
+ if (p > 0.04045) {
+ _lut[i] = pow ((p + 0.055) / 1.055, gamma);
+ } else {
+ _lut[i] = p / 12.92;
+ }
+ }
+ } else {
+ for (int i = 0; i < bit_length; ++i) {
+ _lut[i] = pow(float(i) / (bit_length - 1), gamma);
+ }
}
}
class GammaLUT
{
public:
- GammaLUT (int bit_depth, float gamma);
+ GammaLUT (int bit_depth, float gamma, bool linearised);
~GammaLUT () {
delete[] _lut;
return _gamma;
}
+ bool linearised () const {
+ return _linearised;
+ }
+
static LUTCache<GammaLUT> cache;
private:
float* _lut;
int _bit_depth;
float _gamma;
+ bool _linearised;
};
}
class LUTCache : public boost::noncopyable
{
public:
- boost::shared_ptr<T> get (int bit_depth, float gamma)
+ boost::shared_ptr<T> get (int bit_depth, float gamma, bool linearised)
{
for (typename std::list<boost::shared_ptr<T> >::iterator i = _cache.begin(); i != _cache.end(); ++i) {
if ((*i)->bit_depth() == bit_depth && (*i)->gamma() == gamma) {
}
}
- boost::shared_ptr<T> lut (new T (bit_depth, gamma));
+ boost::shared_ptr<T> lut (new T (bit_depth, gamma, linearised));
_cache.push_back (lut);
return lut;
}
{
return xyz_to_rgb (
decompress_j2k (const_cast<uint8_t*> (_buffer->RoData()), _buffer->Size(), reduce),
- GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma)
+ GammaLUT::cache.get (12, DCI_GAMMA, false), GammaLUT::cache.get (12, 1 / srgb_gamma, false)
);
}
break;
}
- return xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma));
+ return xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA, false), GammaLUT::cache.get (12, 1 / srgb_gamma, false));
}
uint8_t const *
stereo_picture_mxf.h
stereo_picture_frame.h
subtitle.h
+ subtitle_string.h
types.h
util.h
version.h