Missing install file.
[libdcp.git] / src / util.cc
index 2fae85611d7204ee7c54290f3b7c8409b10004bd..6bee0dc76d34ff62ad460719bf4b81811ae20c35 100644 (file)
@@ -26,6 +26,7 @@
 #include <iostream>
 #include <iomanip>
 #include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
 #include <openssl/sha.h>
 #include "KM_util.h"
 #include "KM_fileio.h"
 #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<string> (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<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 +267,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;
                }