From 5b6d753439207fcb33b84690bcc22d142a7c3bfa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 29 Apr 2013 15:22:55 +0100 Subject: Change output gamma correction to be closer to EasyDCP behaviour. --- src/picture_frame.cc | 5 ++--- src/util.cc | 13 +++++++------ src/util.h | 2 +- src/wscript | 1 - src/xyz_srgb_lut.cc | 24 ------------------------ src/xyz_srgb_lut.h | 13 ------------- 6 files changed, 10 insertions(+), 48 deletions(-) delete mode 100644 src/xyz_srgb_lut.cc delete mode 100644 src/xyz_srgb_lut.h (limited to 'src') 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 (_buffer->RoData()), _buffer->Size(), reduce); assert (xyz_frame->numcomps == 3); - shared_ptr f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), XYZsRGBLUT::cache.get (12, srgb_gamma)); + shared_ptr 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 f = xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), XYZsRGBLUT::cache.get (12, srgb_gamma)); + shared_ptr 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 -libdcp::xyz_to_rgb (opj_image_t* xyz_frame, shared_ptr lut_in, shared_ptr lut_out) +libdcp::xyz_to_rgb (opj_image_t* xyz_frame, shared_ptr lut_in, shared_ptr 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 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; } diff --git a/src/util.h b/src/util.h index 2036a7ce..6332ddc0 100644 --- a/src/util.h +++ b/src/util.h @@ -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 xyz_to_rgb (opj_image_t* xyz_frame, boost::shared_ptr, boost::shared_ptr); +extern boost::shared_ptr xyz_to_rgb (opj_image_t* xyz_frame, boost::shared_ptr, boost::shared_ptr); } 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 -#include -#include "xyz_srgb_lut.h" - -using namespace libdcp; - -LUTCache XYZsRGBLUT::cache; - -XYZsRGBLUT::XYZsRGBLUT(int bits, float gamma) - : LUT (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 -{ -public: - XYZsRGBLUT(int colour_depth, float gamma); - static LUTCache cache; -}; - -} -- cgit v1.2.3