diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-04-29 15:22:55 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-04-29 15:22:55 +0100 |
| commit | 5b6d753439207fcb33b84690bcc22d142a7c3bfa (patch) | |
| tree | 092c65d1e8d83b816cfd37ead57699d729d9f3be /src | |
| parent | 085f9fa7a4e389a5579742f20e142513c21bbd82 (diff) | |
Change output gamma correction to be closer to EasyDCP behaviour.
Diffstat (limited to 'src')
| -rw-r--r-- | src/picture_frame.cc | 5 | ||||
| -rw-r--r-- | src/util.cc | 13 | ||||
| -rw-r--r-- | src/util.h | 2 | ||||
| -rw-r--r-- | src/wscript | 1 | ||||
| -rw-r--r-- | src/xyz_srgb_lut.cc | 24 | ||||
| -rw-r--r-- | src/xyz_srgb_lut.h | 13 |
6 files changed, 10 insertions, 48 deletions
diff --git a/src/picture_frame.cc b/src/picture_frame.cc index 98802101..7e6bc1f8 100644 --- a/src/picture_frame.cc +++ b/src/picture_frame.cc @@ -26,7 +26,6 @@ #include "lut.h" #include "util.h" #include "gamma_lut.h" -#include "xyz_srgb_lut.h" #define DCI_GAMMA 2.6 @@ -84,7 +83,7 @@ MonoPictureFrame::argb_frame (int reduce, float srgb_gamma) const { opj_image_t* xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->RoData()), _buffer->Size(), reduce); assert (xyz_frame->numcomps == 3); - shared_ptr<ARGBFrame> f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), XYZsRGBLUT::cache.get (12, srgb_gamma)); + shared_ptr<ARGBFrame> f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma)); opj_image_destroy (xyz_frame); return f; } @@ -139,7 +138,7 @@ StereoPictureFrame::argb_frame (Eye eye, int reduce, float srgb_gamma) const } assert (xyz_frame->numcomps == 3); - shared_ptr<ARGBFrame> f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), XYZsRGBLUT::cache.get (12, srgb_gamma)); + shared_ptr<ARGBFrame> f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma)); opj_image_destroy (xyz_frame); return f; } diff --git a/src/util.cc b/src/util.cc index 2fae8561..c66e63f5 100644 --- a/src/util.cc +++ b/src/util.cc @@ -35,7 +35,6 @@ #include "types.h" #include "argb_frame.h" #include "gamma_lut.h" -#include "xyz_srgb_lut.h" using std::string; using std::stringstream; @@ -203,11 +202,13 @@ libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce) * @return RGB image. */ shared_ptr<ARGBFrame> -libdcp::xyz_to_rgb (opj_image_t* xyz_frame, shared_ptr<const GammaLUT> lut_in, shared_ptr<const XYZsRGBLUT> lut_out) +libdcp::xyz_to_rgb (opj_image_t* xyz_frame, shared_ptr<const GammaLUT> lut_in, shared_ptr<const GammaLUT> lut_out) { float const dci_coefficient = 48.0 / 52.37; - /* sRGB color matrix for XYZ -> RGB */ + /* sRGB color matrix for XYZ -> RGB. This is the same as the one used by the Fraunhofer + EasyDCP player, I think. + */ float const colour_matrix[3][3] = { { 3.24096989631653, -1.5373831987381, -0.498610764741898 }, @@ -264,9 +265,9 @@ libdcp::xyz_to_rgb (opj_image_t* xyz_frame, shared_ptr<const GammaLUT> lut_in, s d.b = max (d.b, 0.0); /* Out gamma LUT */ - *argb_line++ = lut_out->lut()[(int) (d.b * max_colour)]; - *argb_line++ = lut_out->lut()[(int) (d.g * max_colour)]; - *argb_line++ = lut_out->lut()[(int) (d.r * max_colour)]; + *argb_line++ = lut_out->lut()[(int) (d.b * max_colour)] * 0xff; + *argb_line++ = lut_out->lut()[(int) (d.g * max_colour)] * 0xff; + *argb_line++ = lut_out->lut()[(int) (d.r * max_colour)] * 0xff; *argb_line++ = 0xff; } @@ -60,7 +60,7 @@ extern std::string content_kind_to_string (ContentKind kind); extern ContentKind content_kind_from_string (std::string kind); extern bool empty_or_white_space (std::string s); extern opj_image_t* decompress_j2k (uint8_t* data, int64_t size, int reduce); -extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (opj_image_t* xyz_frame, boost::shared_ptr<const GammaLUT>, boost::shared_ptr<const XYZsRGBLUT>); +extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (opj_image_t* xyz_frame, boost::shared_ptr<const GammaLUT>, boost::shared_ptr<const GammaLUT>); } diff --git a/src/wscript b/src/wscript index efba2502..3960f2b0 100644 --- a/src/wscript +++ b/src/wscript @@ -31,7 +31,6 @@ def build(bld): util.cc version.cc xml.cc - xyz_srgb_lut.cc """ headers = """ diff --git a/src/xyz_srgb_lut.cc b/src/xyz_srgb_lut.cc deleted file mode 100644 index 3d207195..00000000 --- a/src/xyz_srgb_lut.cc +++ /dev/null @@ -1,24 +0,0 @@ -#include <iostream> -#include <cmath> -#include "xyz_srgb_lut.h" - -using namespace libdcp; - -LUTCache<XYZsRGBLUT> XYZsRGBLUT::cache; - -XYZsRGBLUT::XYZsRGBLUT(int bits, float gamma) - : LUT<int> (bits, gamma) -{ - int const bit_length = pow(2, bits); - - for (int i = 0; i < bit_length; ++i) { - float v = float(i) / (bit_length - 1); - if (v < (0.04045 / 12.92)) { - v *= 12.92; - } else { - v = (1.055 * pow (v, (1 / gamma))) - 0.055; - } - - _lut[i] = int(v * 255); - } -} diff --git a/src/xyz_srgb_lut.h b/src/xyz_srgb_lut.h deleted file mode 100644 index 63f89178..00000000 --- a/src/xyz_srgb_lut.h +++ /dev/null @@ -1,13 +0,0 @@ -#include "lut.h" -#include "lut_cache.h" - -namespace libdcp { - -class XYZsRGBLUT : public LUT<int> -{ -public: - XYZsRGBLUT(int colour_depth, float gamma); - static LUTCache<XYZsRGBLUT> cache; -}; - -} |
