Make a parent for SMPTELoadFont and InteropLoadFont.
[libdcp.git] / src / stereo_picture_frame.cc
index 8f3183714055b902a0bdf87a536d90ccd5a5afad..3e872e2bf45812039027c209c3ce445554e80b68 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 */
 
-#include <openjpeg.h>
-#include "AS_DCP.h"
-#include "KM_fileio.h"
 #include "stereo_picture_frame.h"
 #include "exceptions.h"
 #include "argb_frame.h"
-#include "lut.h"
 #include "util.h"
-#include "gamma_lut.h"
 #include "rgb_xyz.h"
+#include "colour_conversion.h"
+#include "AS_DCP.h"
+#include "KM_fileio.h"
+#include <openjpeg.h>
 
 #define DCI_GAMMA 2.6
 
@@ -54,16 +53,22 @@ StereoPictureFrame::StereoPictureFrame (boost::filesystem::path mxf_path, int n)
        }
 }
 
+StereoPictureFrame::StereoPictureFrame ()
+{
+       _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte);
+}
+
 StereoPictureFrame::~StereoPictureFrame ()
 {
        delete _buffer;
 }
 
-/** @param reduce a factor by which to reduce the resolution
+/** @param eye Eye to return (EYE_LEFT or EYE_RIGHT).
+ *  @param reduce a factor by which to reduce the resolution
  *  of the image, expressed as a power of two (pass 0 for no
  *  reduction).
- *
- *  @param eye Eye to return (EYE_LEFT or EYE_RIGHT).
+ *  @param srgb_gamma Reciprocal of gamma to use when doing the
+ *  output gamma correction (after conversion from XYZ to RGB).
  *
  *  @return An ARGB representation of one of the eyes (left or right)
  *  of this frame.  This is ARGB in the Cairo sense, so that each
@@ -84,7 +89,23 @@ StereoPictureFrame::argb_frame (Eye eye, int reduce, float srgb_gamma) const
                break;
        }
        
-       return xyz_to_rgb (xyz_frame, GammaLUT::cache.get (12, DCI_GAMMA), GammaLUT::cache.get (12, 1 / srgb_gamma));
+       return xyz_to_rgba (xyz_frame, ColourConversion::xyz_to_srgb);
+}
+
+void
+StereoPictureFrame::rgb_frame (Eye eye, uint16_t* buffer) const
+{
+       shared_ptr<XYZFrame> xyz_frame;
+       switch (eye) {
+       case LEFT:
+               xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Left.RoData()), _buffer->Left.Size(), 0);
+               break;
+       case RIGHT:
+               xyz_frame = decompress_j2k (const_cast<uint8_t*> (_buffer->Right.RoData()), _buffer->Right.Size(), 0);
+               break;
+       }
+       
+       return xyz_to_rgb (xyz_frame, ColourConversion::xyz_to_srgb, buffer);
 }
 
 uint8_t const *
@@ -93,6 +114,12 @@ StereoPictureFrame::left_j2k_data () const
        return _buffer->Left.RoData ();
 }
 
+uint8_t*
+StereoPictureFrame::left_j2k_data ()
+{
+       return _buffer->Left.Data ();
+}
+
 int
 StereoPictureFrame::left_j2k_size () const
 {
@@ -105,6 +132,12 @@ StereoPictureFrame::right_j2k_data () const
        return _buffer->Right.RoData ();
 }
 
+uint8_t*
+StereoPictureFrame::right_j2k_data ()
+{
+       return _buffer->Right.Data ();
+}
+
 int
 StereoPictureFrame::right_j2k_size () const
 {