/*
- 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
#define LIBDCP_PICTURE_ASSET_H
/** @file src/picture_asset.h
- * @brief An asset made up of JPEG2000 data
+ * @brief PictureAsset class.
*/
-#include <openjpeg.h>
-#include "mxf_asset.h"
+#include "mxf.h"
#include "util.h"
#include "metadata.h"
-namespace libdcp
+namespace ASDCP {
+ namespace JP2K {
+ struct PictureDescriptor;
+ }
+}
+
+namespace dcp
{
-class MonoPictureFrame;
+class MonoPictureFrame;
class StereoPictureFrame;
class PictureAssetWriter;
-/** @brief An asset made up of JPEG2000 data */
-class PictureAsset : public MXFAsset
+/** @class PictureAsset
+ * @brief An asset made up of JPEG2000 data.
+ */
+class PictureAsset : public Asset, public MXF
{
public:
- /** Construct a PictureAsset.
- * This class will not write anything to disk in this constructor, but subclasses may.
- *
- * @param directory Directory where MXF file is.
- * @param mxf_name Name of MXF file.
- */
- PictureAsset (boost::filesystem::path directory, std::string mxf_name);
+ PictureAsset (boost::filesystem::path file);
+ PictureAsset (Fraction edit_rate);
- /** Start a progressive write to this asset.
- * @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
- * MXF file does not exist.
- */
- virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite) = 0;
-
- virtual void read () = 0;
- virtual void create (std::vector<boost::filesystem::path> const &) {}
- virtual void create (boost::function<boost::filesystem::path (int)>) {}
-
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ virtual boost::shared_ptr<PictureAssetWriter> start_write (
+ boost::filesystem::path file,
+ Standard standard,
+ bool overwrite
+ ) = 0;
Size size () const {
return _size;
_size = s;
}
- void write_to_cpl (xmlpp::Element *, bool) const;
-
-protected:
-
- bool frame_buffer_equals (
- int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
- uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
- ) const;
+ Fraction frame_rate () const {
+ return _frame_rate;
+ }
- /** picture size in pixels */
- Size _size;
+ void set_frame_rate (Fraction r) {
+ _frame_rate = r;
+ }
-private:
- std::string key_type () const;
- virtual int edit_rate_factor () const = 0;
-};
+ Fraction screen_aspect_ratio () const {
+ return _screen_aspect_ratio;
+ }
-/** A 2D (monoscopic) picture asset */
-class MonoPictureAsset : public PictureAsset
-{
-public:
- MonoPictureAsset (boost::filesystem::path directory, std::string mxf_name);
+ void set_screen_aspect_ratio (Fraction r) {
+ _screen_aspect_ratio = r;
+ }
- void read ();
- void create (std::vector<boost::filesystem::path> const & files);
- void create (boost::function<boost::filesystem::path (int)> get_path);
+ Fraction edit_rate () const {
+ return _edit_rate;
+ }
- /** Start a progressive write to a MonoPictureAsset */
- boost::shared_ptr<PictureAssetWriter> start_write (bool);
+ int64_t intrinsic_duration () const {
+ return _intrinsic_duration;
+ }
- boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+protected:
+ friend class MonoPictureAssetWriter;
+ friend class StereoPictureAssetWriter;
-private:
- boost::filesystem::path path_from_list (int f, std::vector<boost::filesystem::path> const & files) const;
- void construct (boost::function<boost::filesystem::path (int)>, bool, MXFMetadata const &);
- std::string cpl_node_name () const;
- int edit_rate_factor () const;
-};
+ bool frame_buffer_equals (
+ int frame, EqualityOptions opt, NoteHandler note,
+ uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
+ ) const;
-/** A 3D (stereoscopic) picture asset */
-class StereoPictureAsset : public PictureAsset
-{
-public:
- StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name);
+ bool descriptor_equals (
+ ASDCP::JP2K::PictureDescriptor const & a,
+ ASDCP::JP2K::PictureDescriptor const & b,
+ NoteHandler note
+ ) const;
- void read ();
-
- /** Start a progressive write to a StereoPictureAsset */
- boost::shared_ptr<PictureAssetWriter> start_write (bool);
+ void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &);
- boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ Fraction _edit_rate;
+ /** The total length of this content in video frames. The amount of
+ * content presented may be less than this.
+ */
+ int64_t _intrinsic_duration;
+ /** picture size in pixels */
+ Size _size;
+ Fraction _frame_rate;
+ Fraction _screen_aspect_ratio;
private:
- std::string cpl_node_name () const;
- std::pair<std::string, std::string> cpl_node_attribute (bool) const;
- int edit_rate_factor () const;
+ std::string pkl_type (Standard standard) const;
};
-
+
}