Merge master.
[dcpomatic.git] / src / lib / dcp_video_frame.h
index 4e9a777bd78ec909c4c0bd303b289880c5c0cfe4..0a8b5f287f6860a7d172bbdb483430565895506f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
     Taken from code Copyright (C) 2010-2011 Terrence Meiczinger
 
     This program is free software; you can redistribute it and/or modify
 
 */
 
-#include <openjpeg.h>
+#include <dcp/picture_mxf_writer.h>
 #include "util.h"
 
 /** @file  src/dcp_video_frame.h
  *  @brief A single frame of video destined for a DCP.
  */
 
-class FilmState;
-class Options;
+class Film;
 class ServerDescription;
 class Scaler;
 class Image;
@@ -36,21 +35,19 @@ class Subtitle;
 /** @class EncodedData
  *  @brief Container for J2K-encoded data.
  */
-class EncodedData
+class EncodedData : public boost::noncopyable
 {
 public:
-       /** @param d Data (will not be freed by this class, but may be by subclasses)
-        *  @param s Size of data, in bytes.
-        */
-       EncodedData (uint8_t* d, int s)
-               : _data (d)
-               , _size (s)
-       {}
+       /** @param s Size of data, in bytes */
+       EncodedData (int s);
 
-       virtual ~EncodedData () {}
+       EncodedData (boost::filesystem::path);
+
+       virtual ~EncodedData ();
 
        void send (boost::shared_ptr<Socket> socket);
-       void write (boost::shared_ptr<const Options>, int);
+       void write (boost::shared_ptr<const Film>, int, Eyes) const;
+       void write_info (boost::shared_ptr<const Film>, int, Eyes, dcp::FrameInfo) const;
 
        /** @return data */
        uint8_t* data () const {
@@ -64,7 +61,7 @@ public:
 
 protected:
        uint8_t* _data; ///< data
-       int _size;      ///< data size in bytes
+       int _size;      ///< data size in bytes
 };
 
 /** @class LocallyEncodedData
@@ -75,12 +72,10 @@ protected:
 class LocallyEncodedData : public EncodedData
 {
 public:
-       /** @param d Data (which will not be freed by this class)
+       /** @param d Data (which will be copied by this class)
         *  @param s Size of data, in bytes.
         */
-       LocallyEncodedData (uint8_t* d, int s)
-               : EncodedData (d, s)
-       {}
+       LocallyEncodedData (uint8_t* d, int s);
 };
 
 /** @class RemotelyEncodedData
@@ -91,7 +86,6 @@ class RemotelyEncodedData : public EncodedData
 {
 public:
        RemotelyEncodedData (int s);
-       ~RemotelyEncodedData ();
 };
 
 /** @class DCPVideoFrame
@@ -103,41 +97,34 @@ public:
  *  Objects of this class are used for the queue that we keep
  *  of images that require encoding.
  */
-class DCPVideoFrame
+class DCPVideoFrame : public boost::noncopyable
 {
 public:
-       DCPVideoFrame (boost::shared_ptr<Image>, boost::shared_ptr<Subtitle>, Size, int, int, float, Scaler const *, int, float, std::string, int, int, Log *);
-       virtual ~DCPVideoFrame ();
+       DCPVideoFrame (boost::shared_ptr<const Image>, int, Eyes, ColourConversion, int, int, Resolution, boost::shared_ptr<Log>);
+       DCPVideoFrame (boost::shared_ptr<const Image>, boost::shared_ptr<const cxml::Node>, boost::shared_ptr<Log>);
 
        boost::shared_ptr<EncodedData> encode_locally ();
-       boost::shared_ptr<EncodedData> encode_remotely (ServerDescription const *);
+       boost::shared_ptr<EncodedData> encode_remotely (ServerDescription);
 
+       Eyes eyes () const {
+               return _eyes;
+       }
+       
        int frame () const {
                return _frame;
        }
        
 private:
-       void create_openjpeg_container ();
-       void write_encoded (boost::shared_ptr<const Options>, uint8_t *, int);
-
-       boost::shared_ptr<Image> _input; ///< the input image
-       boost::shared_ptr<Subtitle> _subtitle; ///< any subtitle that should be on the image
-       Size _out_size;                  ///< the required size of the output, in pixels
-       int _padding;
-       int _subtitle_offset;
-       float _subtitle_scale;
-       Scaler const * _scaler;          ///< scaler to use
-       int _frame;                      ///< frame index within the Film
-       int _frames_per_second;          ///< Frames per second that we will use for the DCP (rounded)
-       std::string _post_process;       ///< FFmpeg post-processing string to use
-       int _colour_lut_index;           ///< Colour look-up table to use (see Config::colour_lut_index ())
-       int _j2k_bandwidth;              ///< J2K bandwidth to use (see Config::j2k_bandwidth ())
-
-       Log* _log; ///< log
-
-       opj_image_cmptparm_t _cmptparm[3]; ///< libopenjpeg's opj_image_cmptparm_t
-       opj_image* _image;                 ///< libopenjpeg's image container 
-       opj_cparameters_t* _parameters;    ///< libopenjpeg's parameters
-       opj_cinfo_t* _cinfo;               ///< libopenjpeg's opj_cinfo_t
-       opj_cio_t* _cio;                   ///< libopenjpeg's opj_cio_t
+
+       void add_metadata (xmlpp::Element *) const;
+       
+       boost::shared_ptr<const Image> _image;
+       int _frame;                      ///< frame index within the DCP's intrinsic duration
+       Eyes _eyes;
+       ColourConversion _conversion;
+       int _frames_per_second;          ///< Frames per second that we will use for the DCP
+       int _j2k_bandwidth;              ///< J2K bandwidth to use
+       Resolution _resolution;          ///< Resolution (2K or 4K)
+
+       boost::shared_ptr<Log> _log; ///< log
 };