Fix audio analysis; make sure we don't decode video and let it pile up unwanted.
[dcpomatic.git] / src / lib / j2k_image_proxy.cc
index 6924fad795bd1ddbdcab067036a96917110560ed..175f4c796e6afc039cd6f216da68a608257463dd 100644 (file)
 
 using std::string;
 using boost::shared_ptr;
+using boost::optional;
 
-J2KImageProxy::J2KImageProxy (shared_ptr<const dcp::MonoPictureFrame> frame, dcp::Size size, shared_ptr<Log> log)
-       : ImageProxy (log)
-       , _mono (frame)
+/** Construct a J2KImageProxy from a JPEG2000 file */
+J2KImageProxy::J2KImageProxy (boost::filesystem::path path, dcp::Size size)
+       : _mono (new dcp::MonoPictureFrame (path))
+       , _size (size)
+{
+
+}
+
+J2KImageProxy::J2KImageProxy (shared_ptr<const dcp::MonoPictureFrame> frame, dcp::Size size)
+       : _mono (frame)
        , _size (size)
 {
        
 }
 
-J2KImageProxy::J2KImageProxy (shared_ptr<const dcp::StereoPictureFrame> frame, dcp::Size size, dcp::Eye eye, shared_ptr<Log> log)
-       : ImageProxy (log)
-       , _stereo (frame)
+J2KImageProxy::J2KImageProxy (shared_ptr<const dcp::StereoPictureFrame> frame, dcp::Size size, dcp::Eye eye)
+       : _stereo (frame)
        , _size (size)
        , _eye (eye)
 {
 
 }
 
-J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket, shared_ptr<Log> log)
-       : ImageProxy (log)
+J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> socket)
 {
        _size = dcp::Size (xml->number_child<int> ("Width"), xml->number_child<int> ("Height"));
        if (xml->optional_number_child<int> ("Eye")) {
@@ -69,14 +75,14 @@ J2KImageProxy::J2KImageProxy (shared_ptr<cxml::Node> xml, shared_ptr<Socket> soc
 }
 
 shared_ptr<Image>
-J2KImageProxy::image () const
+J2KImageProxy::image (optional<dcp::NoteHandler> note) const
 {
-       shared_ptr<Image> image (new Image (PIX_FMT_RGB24, _size, false));
+       shared_ptr<Image> image (new Image (PIX_FMT_RGB48LE, _size, false));
 
        if (_mono) {
-               _mono->rgb_frame (image->data()[0]);
+               _mono->rgb_frame (reinterpret_cast<uint16_t*> (image->data()[0]), note);
        } else {
-               _stereo->rgb_frame (_eye, image->data()[0]);
+               _stereo->rgb_frame (_eye, reinterpret_cast<uint16_t*> (image->data()[0]));
        }
 
        return shared_ptr<Image> (new Image (image, true));