X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Futil.cc;h=6bee0dc76d34ff62ad460719bf4b81811ae20c35;hb=5fdaf6d2cf0377d7a326063065c6af5adbf68a92;hp=2fae85611d7204ee7c54290f3b7c8409b10004bd;hpb=4709841e68d860c4fbee2f2f824e57489c8ad97d;p=libdcp.git diff --git a/src/util.cc b/src/util.cc index 2fae8561..6bee0dc7 100644 --- a/src/util.cc +++ b/src/util.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "KM_util.h" #include "KM_fileio.h" @@ -35,13 +36,13 @@ #include "types.h" #include "argb_frame.h" #include "gamma_lut.h" -#include "xyz_srgb_lut.h" using std::string; using std::stringstream; using std::min; using std::max; using boost::shared_ptr; +using boost::lexical_cast; using namespace libdcp; /** Create a UUID. @@ -188,7 +189,7 @@ libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce) if (!image) { opj_destroy_decompress (decoder); opj_cio_close (cio); - boost::throw_exception (DCPReadError ("could not decode JPEG2000 codestream")); + boost::throw_exception (DCPReadError ("could not decode JPEG2000 codestream of " + lexical_cast (size) + " bytes.")); } opj_cio_close (cio); @@ -203,11 +204,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 +267,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; }