summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-01-05 01:24:19 +0000
committerCarl Hetherington <cth@carlh.net>2016-01-05 01:24:19 +0000
commit5ee3348142f4cfafdbcf2c9c833843d717affc11 (patch)
tree1c97c80eeccc6b5f515a611e35dee35b21d3b09b
parent740938890d95e853cf13d4780a5d674c3d6c7f6f (diff)
Various IMF hacks.imf
-rw-r--r--src/dcp.cc6
-rw-r--r--src/imp.cc6
-rw-r--r--src/imp.h6
-rw-r--r--src/imp_cpl.cc8
-rw-r--r--src/imp_cpl.h4
-rw-r--r--src/mono_picture_asset.cc7
-rw-r--r--src/mono_picture_asset.h7
-rw-r--r--src/mono_picture_frame.cc37
-rw-r--r--src/mono_picture_frame.h2
-rw-r--r--src/package.cc12
-rw-r--r--src/package.h15
-rw-r--r--src/resource.cc6
-rw-r--r--src/resource.h17
-rw-r--r--src/segment.cc14
-rw-r--r--src/segment.h11
-rw-r--r--src/sequence.cc12
-rw-r--r--src/sequence.h7
-rw-r--r--src/smpte_subtitle_asset.cc4
-rw-r--r--src/smpte_subtitle_asset.h3
-rw-r--r--src/sound_asset.cc6
-rw-r--r--src/sound_asset.h3
-rw-r--r--src/sound_frame.cc38
-rw-r--r--src/sound_frame.h3
-rw-r--r--src/stereo_picture_frame.cc5
-rw-r--r--src/stereo_picture_frame.h2
-rw-r--r--src/types.h6
-rw-r--r--test/cpl_sar_test.cc2
-rw-r--r--test/imf_test.cc28
-rw-r--r--test/read_smpte_subtitle_test.cc3
-rw-r--r--test/round_trip_test.cc2
-rw-r--r--test/sound_frame_test.cc8
-rw-r--r--test/subs_in_out.cc2
-rw-r--r--tools/dcpdumpsub.cc2
33 files changed, 238 insertions, 56 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index 7393b18f..cc93fa8e 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -63,11 +63,7 @@ DCP::write_xml (
list<shared_ptr<DCPCPL> >
DCP::cpls () const
{
- list<shared_ptr<DCPCPL> > d;
- BOOST_FOREACH (shared_ptr<CPL> i, _cpls) {
- d.push_back (dynamic_pointer_cast<DCPCPL> (i));
- }
- return d;
+ return cpls_of_type<DCPCPL> ();
}
shared_ptr<CPL>
diff --git a/src/imp.cc b/src/imp.cc
index 61af1c96..d27b4726 100644
--- a/src/imp.cc
+++ b/src/imp.cc
@@ -69,3 +69,9 @@ IMP::assets () const
/* XXX */
return list<shared_ptr<Asset> > ();
}
+
+list<shared_ptr<IMPCPL> >
+IMP::cpls () const
+{
+ return cpls_of_type<IMPCPL> ();
+}
diff --git a/src/imp.h b/src/imp.h
index 03a00b76..81869740 100644
--- a/src/imp.h
+++ b/src/imp.h
@@ -21,6 +21,8 @@
namespace dcp {
+class IMPCPL;
+
class IMP : public Package
{
public:
@@ -32,10 +34,10 @@ public:
void add (DecryptedKDM const & kdm);
std::list<boost::shared_ptr<Asset> > assets () const;
+ std::list<boost::shared_ptr<IMPCPL> > cpls () const;
+
private:
boost::shared_ptr<CPL> read_cpl (boost::filesystem::path) const;
};
}
-
-
diff --git a/src/imp_cpl.cc b/src/imp_cpl.cc
index 2b36f02b..f4f27dfa 100644
--- a/src/imp_cpl.cc
+++ b/src/imp_cpl.cc
@@ -23,8 +23,10 @@
#include "segment.h"
#include <libcxml/cxml.h>
#include <boost/foreach.hpp>
+#include <iostream>
using std::string;
+using std::list;
using boost::shared_ptr;
using namespace dcp;
@@ -55,9 +57,11 @@ IMPCPL::IMPCPL (boost::filesystem::path file)
}
void
-IMPCPL::resolve_refs (std::list<boost::shared_ptr<Asset> >)
+IMPCPL::resolve_refs (list<shared_ptr<Asset> > assets)
{
- /* XXX */
+ BOOST_FOREACH (shared_ptr<Segment> i, _segments) {
+ i->resolve_refs (assets);
+ }
}
int64_t
diff --git a/src/imp_cpl.h b/src/imp_cpl.h
index 7a1337db..d0eeec16 100644
--- a/src/imp_cpl.h
+++ b/src/imp_cpl.h
@@ -36,6 +36,10 @@ public:
/** @return string to use for AnnotationText in a PKL */
std::string pkl_annotation () const;
+ std::list<boost::shared_ptr<Segment> > segments () {
+ return _segments;
+ }
+
private:
std::string pkl_type (Standard standard) const;
diff --git a/src/mono_picture_asset.cc b/src/mono_picture_asset.cc
index f1b5f9d5..9b83bae5 100644
--- a/src/mono_picture_asset.cc
+++ b/src/mono_picture_asset.cc
@@ -20,6 +20,7 @@
#include "mono_picture_asset.h"
#include "mono_picture_asset_writer.h"
#include "AS_DCP.h"
+#include "AS_02.h"
#include "KM_fileio.h"
#include "exceptions.h"
#include "dcp_assert.h"
@@ -34,8 +35,9 @@ using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using namespace dcp;
-MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file)
+MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file, AssetType type)
: PictureAsset (file)
+ , _type (type)
{
ASDCP::JP2K::MXFReader reader;
Kumu::Result_t r = reader.OpenRead (file.string().c_str());
@@ -60,6 +62,7 @@ MonoPictureAsset::MonoPictureAsset (boost::filesystem::path file)
MonoPictureAsset::MonoPictureAsset (Fraction edit_rate)
: PictureAsset (edit_rate)
+ , _type (ASSET_DCP)
{
}
@@ -67,7 +70,7 @@ MonoPictureAsset::MonoPictureAsset (Fraction edit_rate)
shared_ptr<const MonoPictureFrame>
MonoPictureAsset::get_frame (int n) const
{
- return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (_file, n, _decryption_context));
+ return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (_file, n, _decryption_context, _type));
}
static void
diff --git a/src/mono_picture_asset.h b/src/mono_picture_asset.h
index a10eada0..1febf4ed 100644
--- a/src/mono_picture_asset.h
+++ b/src/mono_picture_asset.h
@@ -21,6 +21,9 @@
#define LIBDCP_MONO_PICTURE_ASSET_H
#include "picture_asset.h"
+#include "exceptions.h"
+#include <KM_error.h>
+#include <AS_DCP.h>
namespace dcp {
@@ -35,7 +38,7 @@ public:
/** Create a MonoPictureAsset by reading a file.
* @param file Asset file to read.
*/
- MonoPictureAsset (boost::filesystem::path file);
+ MonoPictureAsset (boost::filesystem::path file, AssetType type);
/** Create a MonoPictureAsset with a given edit rate.
* @param edit_rate Edit rate (i.e. frame rate) in frames per second.
@@ -55,6 +58,8 @@ public:
private:
std::string cpl_node_name () const;
+
+ AssetType _type;
};
}
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc
index 089ac651..7ed2ce56 100644
--- a/src/mono_picture_frame.cc
+++ b/src/mono_picture_frame.cc
@@ -28,6 +28,7 @@
#include "colour_conversion.h"
#include "KM_fileio.h"
#include "AS_DCP.h"
+#include "AS_02.h"
#include "compose.hpp"
#include "j2k.h"
#include <openjpeg.h>
@@ -57,24 +58,38 @@ MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path)
_buffer->Size (size);
}
-/** Make a picture frame from a 2D (monoscopic) asset.
- * @param path Path to the asset's MXF file.
- * @param n Frame within the asset, not taking EntryPoint into account.
- * @param c Context for decryption, or 0.
- */
-MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c)
+template <class T>
+void
+read_frame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c, ASDCP::JP2K::FrameBuffer* buffer)
{
- ASDCP::JP2K::MXFReader reader;
+ T reader;
Kumu::Result_t r = reader.OpenRead (path.string().c_str());
if (ASDCP_FAILURE (r)) {
boost::throw_exception (FileError ("could not open MXF file for reading", path, r));
}
- /* XXX: unfortunate guesswork on this buffer size */
- _buffer = new ASDCP::JP2K::FrameBuffer (4 * Kumu::Megabyte);
+ r = reader.ReadFrame (n, *buffer, c);
+ if (r.Failure ()) {
+ boost::throw_exception (PackageReadError (String::compose ("could not read video frame %1 of %2 (%3)", n, path.string(), r.Value())));
+ }
+}
- if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) {
- boost::throw_exception (PackageReadError (String::compose ("could not read video frame %1 of %2", n, path.string())));
+/** Make a picture frame from a 2D (monoscopic) asset.
+ * @param path Path to the asset's MXF file.
+ * @param n Frame within the asset, not taking EntryPoint into account.
+ * @param c Context for decryption, or 0.
+ */
+MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c, AssetType type)
+ /* XXX: unfortunate guesswork on this buffer size */
+ : _buffer (new ASDCP::JP2K::FrameBuffer (4 * Kumu::Megabyte))
+{
+ switch (type) {
+ case ASSET_DCP:
+ read_frame<ASDCP::JP2K::MXFReader> (path, n, c, _buffer);
+ break;
+ case ASSET_IMP:
+ read_frame<AS_02::JP2K::MXFReader> (path, n, c, _buffer);
+ break;
}
}
diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h
index 68e4edf8..2faf2e08 100644
--- a/src/mono_picture_frame.h
+++ b/src/mono_picture_frame.h
@@ -46,7 +46,7 @@ class OpenJPEGImage;
class MonoPictureFrame : public boost::noncopyable
{
public:
- MonoPictureFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext *);
+ MonoPictureFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext *, AssetType type);
MonoPictureFrame (boost::filesystem::path path);
MonoPictureFrame ();
~MonoPictureFrame ();
diff --git a/src/package.cc b/src/package.cc
index abaac733..f3444b08 100644
--- a/src/package.cc
+++ b/src/package.cc
@@ -159,21 +159,27 @@ Package::read (bool keep_going, ReadErrors* errors)
case ASDCP::ESS_MPEG2_VES:
throw PackageReadError ("MPEG2 video essences are not supported");
case ASDCP::ESS_JPEG_2000:
+ other_assets.push_back (shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path, ASSET_DCP)));
+ break;
case ASDCP::ESS_AS02_JPEG_2000:
- other_assets.push_back (shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path)));
+ other_assets.push_back (shared_ptr<MonoPictureAsset> (new MonoPictureAsset (path, ASSET_IMP)));
break;
case ASDCP::ESS_PCM_24b_48k:
case ASDCP::ESS_PCM_24b_96k:
+ other_assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (path, ASSET_DCP)));
+ break;
case ASDCP::ESS_AS02_PCM_24b_48k:
case ASDCP::ESS_AS02_PCM_24b_96k:
- other_assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (path)));
+ other_assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (path, ASSET_IMP)));
break;
case ASDCP::ESS_JPEG_2000_S:
other_assets.push_back (shared_ptr<StereoPictureAsset> (new StereoPictureAsset (path)));
break;
case ASDCP::ESS_TIMED_TEXT:
+ other_assets.push_back (shared_ptr<SMPTESubtitleAsset> (new SMPTESubtitleAsset (path, ASSET_DCP)));
+ break;
case ASDCP::ESS_AS02_TIMED_TEXT:
- other_assets.push_back (shared_ptr<SMPTESubtitleAsset> (new SMPTESubtitleAsset (path)));
+ other_assets.push_back (shared_ptr<SMPTESubtitleAsset> (new SMPTESubtitleAsset (path, ASSET_IMP)));
break;
default:
throw PackageReadError ("Unknown MXF essence type");
diff --git a/src/package.h b/src/package.h
index 324998e5..610b7637 100644
--- a/src/package.h
+++ b/src/package.h
@@ -27,8 +27,10 @@
#include "types.h"
#include "certificate.h"
#include "metadata.h"
+#include "dcp_assert.h"
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
+#include <boost/foreach.hpp>
#include <string>
#include <vector>
@@ -111,6 +113,19 @@ protected:
*/
void write_assetmap (Standard standard, std::string pkl_uuid, int pkl_length, XMLMetadata metadata) const;
+ template <class T>
+ std::list<boost::shared_ptr<T> >
+ cpls_of_type () const
+ {
+ std::list<boost::shared_ptr<T> > cpls;
+ BOOST_FOREACH (boost::shared_ptr<CPL> i, _cpls) {
+ boost::shared_ptr<T> t = boost::dynamic_pointer_cast<T> (i);
+ DCP_ASSERT (t);
+ cpls.push_back (t);
+ }
+ return cpls;
+ }
+
/** the directory that we are writing to */
boost::filesystem::path _directory;
/** the CPLs that make up this package */
diff --git a/src/resource.cc b/src/resource.cc
index 50ab57b4..b6622435 100644
--- a/src/resource.cc
+++ b/src/resource.cc
@@ -23,7 +23,9 @@ using namespace dcp;
Resource::Resource (cxml::ConstNodePtr node)
: Object (node->string_child ("Id"))
+ , _asset_ref (node->string_child ("TrackFileId").substr (9))
+ , _intrinsic_duration (node->number_child<int64_t> ("IntrinsicDuration"))
+ , _entry_point (node->number_child<int64_t> ("EntryPoint"))
{
- _intrinsic_duration = node->number_child<int64_t> ("IntrinsicDuration");
- _entry_point = node->number_child<int64_t> ("EntryPoint");
+
}
diff --git a/src/resource.h b/src/resource.h
index f75d03fc..d762fac3 100644
--- a/src/resource.h
+++ b/src/resource.h
@@ -18,6 +18,7 @@
*/
#include "object.h"
+#include "ref.h"
#include <libcxml/cxml.h>
namespace dcp {
@@ -27,7 +28,23 @@ class Resource : public Object
public:
Resource (cxml::ConstNodePtr node);
+ /** @return a Ref to our actual asset */
+ Ref const & asset_ref () const {
+ return _asset_ref;
+ }
+
+ /** @return a Ref to our actual asset */
+ Ref & asset_ref () {
+ return _asset_ref;
+ }
+
+ template <class T>
+ boost::shared_ptr<T> asset () {
+ return boost::dynamic_pointer_cast<T> (_asset_ref.asset ());
+ }
+
private:
+ Ref _asset_ref;
int64_t _intrinsic_duration;
int64_t _entry_point;
};
diff --git a/src/segment.cc b/src/segment.cc
index 20f2bf1e..707aa1cd 100644
--- a/src/segment.cc
+++ b/src/segment.cc
@@ -19,7 +19,9 @@
#include "segment.h"
#include "sequence.h"
+#include <iostream>
+using std::list;
using boost::shared_ptr;
using namespace dcp;
@@ -40,3 +42,15 @@ Segment::Segment (cxml::ConstNodePtr node)
node->done ();
}
+
+void
+Segment::resolve_refs (list<shared_ptr<Asset> > assets)
+{
+ if (_main_image) {
+ _main_image->resolve (assets);
+ }
+
+ if (_main_audio) {
+ _main_audio->resolve (assets);
+ }
+}
diff --git a/src/segment.h b/src/segment.h
index 1b6e470d..5194d684 100644
--- a/src/segment.h
+++ b/src/segment.h
@@ -23,12 +23,23 @@
namespace dcp {
class Sequence;
+class Asset;
class Segment : public Object
{
public:
Segment (cxml::ConstNodePtr node);
+ boost::shared_ptr<Sequence> main_image () const {
+ return _main_image;
+ }
+
+ boost::shared_ptr<Sequence> main_audio () const {
+ return _main_audio;
+ }
+
+ void resolve_refs (std::list<boost::shared_ptr<Asset> >);
+
private:
boost::shared_ptr<Sequence> _main_image;
boost::shared_ptr<Sequence> _main_audio;
diff --git a/src/sequence.cc b/src/sequence.cc
index 3584a5b2..ae5cdc16 100644
--- a/src/sequence.cc
+++ b/src/sequence.cc
@@ -20,7 +20,11 @@
#include "sequence.h"
#include "xml.h"
#include "resource.h"
+#include <boost/foreach.hpp>
+#include <iostream>
+using std::list;
+using boost::shared_ptr;
using namespace dcp;
Sequence::Sequence (cxml::ConstNodePtr node)
@@ -28,3 +32,11 @@ Sequence::Sequence (cxml::ConstNodePtr node)
{
_resources = type_grand_children<Resource> (node, "ResourceList", "Resource");
}
+
+void
+Sequence::resolve (list<shared_ptr<Asset> > assets)
+{
+ BOOST_FOREACH (shared_ptr<Resource> i, _resources) {
+ i->asset_ref().resolve (assets);
+ }
+}
diff --git a/src/sequence.h b/src/sequence.h
index 74216ea5..1b491cd2 100644
--- a/src/sequence.h
+++ b/src/sequence.h
@@ -23,12 +23,19 @@
namespace dcp {
class Resource;
+class Asset;
class Sequence : public Object
{
public:
Sequence (cxml::ConstNodePtr node);
+ std::list<boost::shared_ptr<Resource> > resources () const {
+ return _resources;
+ }
+
+ void resolve (std::list<boost::shared_ptr<Asset> > assets);
+
private:
std::list<boost::shared_ptr<Resource> > _resources;
};
diff --git a/src/smpte_subtitle_asset.cc b/src/smpte_subtitle_asset.cc
index 8f40af5f..b1e96d77 100644
--- a/src/smpte_subtitle_asset.cc
+++ b/src/smpte_subtitle_asset.cc
@@ -51,6 +51,7 @@ using namespace dcp;
SMPTESubtitleAsset::SMPTESubtitleAsset ()
: _intrinsic_duration (0)
+ , _type (ASSET_DCP)
, _edit_rate (24, 1)
, _time_code_rate (24)
{
@@ -60,8 +61,9 @@ SMPTESubtitleAsset::SMPTESubtitleAsset ()
/** Construct a SMPTESubtitleAsset by reading an MXF or XML file.
* @param file Filename.
*/
-SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file)
+SMPTESubtitleAsset::SMPTESubtitleAsset (boost::filesystem::path file, AssetType type)
: SubtitleAsset (file)
+ , _type (type)
{
shared_ptr<cxml::Document> xml (new cxml::Document ("SubtitleReel"));
diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h
index a7adee6f..c23cd710 100644
--- a/src/smpte_subtitle_asset.h
+++ b/src/smpte_subtitle_asset.h
@@ -46,7 +46,7 @@ public:
/** @param file File name
*/
- SMPTESubtitleAsset (boost::filesystem::path file);
+ SMPTESubtitleAsset (boost::filesystem::path file, AssetType type);
bool equals (
boost::shared_ptr<const Asset>,
@@ -146,6 +146,7 @@ private:
* content presented may be less than this.
*/
int64_t _intrinsic_duration;
+ AssetType _type;
std::string _content_title_text;
boost::optional<std::string> _language;
boost::optional<std::string> _annotation_text;
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 3b988c6c..b9d0b4ba 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -43,8 +43,9 @@ using std::list;
using boost::shared_ptr;
using namespace dcp;
-SoundAsset::SoundAsset (boost::filesystem::path file)
+SoundAsset::SoundAsset (boost::filesystem::path file, AssetType type)
: Asset (file)
+ , _type (type)
{
ASDCP::PCM::MXFReader reader;
Kumu::Result_t r = reader.OpenRead (file.string().c_str());
@@ -74,6 +75,7 @@ SoundAsset::SoundAsset (boost::filesystem::path file)
SoundAsset::SoundAsset (Fraction edit_rate, int sampling_rate, int channels)
: _edit_rate (edit_rate)
, _intrinsic_duration (0)
+ , _type (ASSET_DCP)
, _channels (channels)
, _sampling_rate (sampling_rate)
{
@@ -156,7 +158,7 @@ shared_ptr<const SoundFrame>
SoundAsset::get_frame (int n) const
{
/* XXX: should add on entry point here? */
- return shared_ptr<const SoundFrame> (new SoundFrame (file(), n, _decryption_context));
+ return shared_ptr<const SoundFrame> (new SoundFrame (file(), n, _decryption_context, _type, _edit_rate));
}
shared_ptr<SoundAssetWriter>
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 968f7dde..cf5a3cd2 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -40,7 +40,7 @@ class SoundAssetWriter;
class SoundAsset : public Asset, public MXF
{
public:
- SoundAsset (boost::filesystem::path file);
+ SoundAsset (boost::filesystem::path file, AssetType type);
SoundAsset (Fraction edit_rate, int sampling_rate, int channels);
boost::shared_ptr<SoundAssetWriter> start_write (boost::filesystem::path file, Standard standard);
@@ -81,6 +81,7 @@ private:
* content presented may be less than this.
*/
int64_t _intrinsic_duration;
+ AssetType _type;
int _channels; ///< number of channels
int _sampling_rate; ///< sampling rate in Hz
};
diff --git a/src/sound_frame.cc b/src/sound_frame.cc
index 42c5ee17..c51491a7 100644
--- a/src/sound_frame.cc
+++ b/src/sound_frame.cc
@@ -24,24 +24,44 @@
#include "sound_frame.h"
#include "exceptions.h"
#include "AS_DCP.h"
+#include "AS_02.h"
#include "KM_fileio.h"
using namespace std;
using namespace dcp;
-SoundFrame::SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c)
+SoundFrame::SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext* c, AssetType type, Fraction edit_rate)
+ /* XXX: unfortunate guesswork on this buffer size */
+ : _buffer (new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte))
{
- ASDCP::PCM::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (path.string().c_str());
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open MXF file for reading", path, r));
+ switch (type) {
+ case ASSET_DCP:
+ {
+ ASDCP::PCM::MXFReader reader;
+ Kumu::Result_t r = reader.OpenRead (path.string().c_str());
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (FileError ("could not open MXF file for reading", path, r));
+ }
+
+ if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) {
+ boost::throw_exception (PackageReadError ("could not read audio frame"));
+ }
+ break;
}
- /* XXX: unfortunate guesswork on this buffer size */
- _buffer = new ASDCP::PCM::FrameBuffer (1 * Kumu::Megabyte);
+ case ASSET_IMP:
+ {
+ AS_02::PCM::MXFReader reader;
+ Kumu::Result_t r = reader.OpenRead (path.string().c_str(), ASDCP::Rational (edit_rate.numerator, edit_rate.denominator));
+ if (ASDCP_FAILURE (r)) {
+ boost::throw_exception (FileError ("could not open MXF file for reading", path, r));
+ }
- if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) {
- boost::throw_exception (PackageReadError ("could not read audio frame"));
+ if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer, c))) {
+ boost::throw_exception (PackageReadError ("could not read audio frame"));
+ }
+ break;
+ }
}
}
diff --git a/src/sound_frame.h b/src/sound_frame.h
index 4fdc39e5..b91b4d9f 100644
--- a/src/sound_frame.h
+++ b/src/sound_frame.h
@@ -24,6 +24,7 @@
#ifndef LIBDCP_SOUND_FRAME_H
#define LIBDCP_SOUND_FRAME_H
+#include "types.h"
#include <boost/noncopyable.hpp>
#include <boost/filesystem.hpp>
#include <stdint.h>
@@ -44,7 +45,7 @@ namespace dcp {
class SoundFrame : public boost::noncopyable
{
public:
- SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext *);
+ SoundFrame (boost::filesystem::path path, int n, ASDCP::AESDecContext *, AssetType type, Fraction edit_rate);
~SoundFrame ();
uint8_t const * data () const;
diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc
index 1bb210d6..caa89882 100644
--- a/src/stereo_picture_frame.cc
+++ b/src/stereo_picture_frame.cc
@@ -39,6 +39,8 @@ using namespace dcp;
* @param n Frame within the asset, not taking EntryPoint into account.
*/
StereoPictureFrame::StereoPictureFrame (boost::filesystem::path path, int n)
+ /* XXX: unfortunate guesswork on this buffer size */
+ : _buffer (new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte))
{
ASDCP::JP2K::MXFSReader reader;
Kumu::Result_t r = reader.OpenRead (path.string().c_str());
@@ -46,9 +48,6 @@ StereoPictureFrame::StereoPictureFrame (boost::filesystem::path path, int n)
boost::throw_exception (FileError ("could not open MXF file for reading", path, r));
}
- /* XXX: unfortunate guesswork on this buffer size */
- _buffer = new ASDCP::JP2K::SFrameBuffer (4 * Kumu::Megabyte);
-
if (ASDCP_FAILURE (reader.ReadFrame (n, *_buffer))) {
boost::throw_exception (PackageReadError (String::compose ("could not read video frame %1 of %2", n, path.string())));
}
diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h
index 5be764fe..dc649c2e 100644
--- a/src/stereo_picture_frame.h
+++ b/src/stereo_picture_frame.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2016 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
diff --git a/src/types.h b/src/types.h
index 481c1a46..1141e3da 100644
--- a/src/types.h
+++ b/src/types.h
@@ -120,6 +120,12 @@ enum Eye
EYE_RIGHT
};
+enum AssetType
+{
+ ASSET_DCP,
+ ASSET_IMP
+};
+
/** @class Fraction
* @brief A fraction (i.e. a thing with an integer numerator and an integer denominator).
*/
diff --git a/test/cpl_sar_test.cc b/test/cpl_sar_test.cc
index 3f5b07d1..3c5c9a6d 100644
--- a/test/cpl_sar_test.cc
+++ b/test/cpl_sar_test.cc
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE (cpl_sar)
{
shared_ptr<dcp::ReelMonoPictureAsset> pa (
new dcp::ReelMonoPictureAsset (
- shared_ptr<dcp::MonoPictureAsset> (new dcp::MonoPictureAsset ("test/ref/DCP/dcp_test1/video.mxf")),
+ shared_ptr<dcp::MonoPictureAsset> (new dcp::MonoPictureAsset ("test/ref/DCP/dcp_test1/video.mxf", dcp::ASSET_DCP)),
0
)
);
diff --git a/test/imf_test.cc b/test/imf_test.cc
index 3b95416b..0a3c8914 100644
--- a/test/imf_test.cc
+++ b/test/imf_test.cc
@@ -18,12 +18,40 @@
*/
#include "imp.h"
+#include "imp_cpl.h"
+#include "sequence.h"
+#include "segment.h"
#include "test.h"
+#include "resource.h"
+#include "mono_picture_asset.h"
+#include "mono_picture_frame.h"
#include <boost/test/unit_test.hpp>
+using boost::shared_ptr;
+
/** Simple test of reading an IMF package */
BOOST_AUTO_TEST_CASE (imf_test1)
{
dcp::IMP imp (private_test / "data" / "BelleSebastian2_TLR-2-2398_HD-239_DE-XX_CH_51_HD_PATH_20151229_DGL_SMPTE_IMPAPP2_OV");
imp.read ();
+
+ BOOST_REQUIRE_EQUAL (imp.cpls().size(), 1);
+ shared_ptr<dcp::IMPCPL> cpl = imp.cpls().front ();
+
+ BOOST_REQUIRE_EQUAL (cpl->segments().size(), 1);
+ shared_ptr<dcp::Segment> segment = cpl->segments().front ();
+
+ BOOST_REQUIRE (segment->main_image ());
+ shared_ptr<dcp::Sequence> main_image = segment->main_image ();
+
+ BOOST_REQUIRE_EQUAL (main_image->resources().size(), 1);
+ shared_ptr<dcp::Resource> resource = main_image->resources().front ();
+
+ BOOST_REQUIRE (resource->asset<dcp::MonoPictureAsset>());
+ shared_ptr<dcp::MonoPictureAsset> picture = resource->asset<dcp::MonoPictureAsset> ();
+
+ shared_ptr<const dcp::MonoPictureFrame> frame = picture->get_frame (100);
+ FILE* out = fopen ("/home/carl/piss.j2c", "wb");
+ fwrite (frame->j2k_data(), 1, frame->j2k_size(), out);
+ fclose (out);
}
diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc
index f4d28106..e90b849c 100644
--- a/test/read_smpte_subtitle_test.cc
+++ b/test/read_smpte_subtitle_test.cc
@@ -36,7 +36,8 @@ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test)
private_test /
"data" /
"JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV" /
- "8b48f6ae-c74b-4b80-b994-a8236bbbad74_sub.mxf"
+ "8b48f6ae-c74b-4b80-b994-a8236bbbad74_sub.mxf",
+ dcp::ASSET_DCP
);
BOOST_CHECK_EQUAL (sc.id(), "8b48f6ae-c74b-4b80-b994-a8236bbbad74");
diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc
index 8eff55a3..796b0c95 100644
--- a/test/round_trip_test.cc
+++ b/test/round_trip_test.cc
@@ -101,7 +101,7 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
/* Reload the picture asset */
shared_ptr<dcp::MonoPictureAsset> asset_B (
- new dcp::MonoPictureAsset (work_dir / "video.mxf")
+ new dcp::MonoPictureAsset (work_dir / "video.mxf", dcp::ASSET_DCP)
);
BOOST_CHECK (!kdm_B.keys().empty ());
diff --git a/test/sound_frame_test.cc b/test/sound_frame_test.cc
index 31e8b265..cf6695a6 100644
--- a/test/sound_frame_test.cc
+++ b/test/sound_frame_test.cc
@@ -31,7 +31,9 @@ BOOST_AUTO_TEST_CASE (sound_frame_test)
dcp::SoundFrame frame (
private_test / "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf",
42,
- 0
+ 0,
+ dcp::ASSET_DCP,
+ dcp::Fraction (48000, 1)
);
BOOST_REQUIRE_EQUAL (frame.size(), channels * frame_length * 3);
@@ -60,11 +62,11 @@ BOOST_AUTO_TEST_CASE (sound_frame_test)
BOOST_AUTO_TEST_CASE (sound_frame_test2)
{
- BOOST_CHECK_THROW (dcp::SoundFrame ("frobozz", 42, 0), dcp::FileError);
+ BOOST_CHECK_THROW (dcp::SoundFrame ("frobozz", 42, 0, dcp::ASSET_DCP, dcp::Fraction (48000, 1)), dcp::FileError);
BOOST_CHECK_THROW (dcp::SoundFrame (
private_test /
"TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV/pcm_95734608-5d47-4d3f-bf5f-9e9186b66afa_.mxf",
- 999999999, 0
+ 999999999, 0, dcp::ASSET_DCP, dcp::Fraction (48000, 1)
), dcp::PackageReadError
);
}
diff --git a/test/subs_in_out.cc b/test/subs_in_out.cc
index 154eb9e8..31b623b4 100644
--- a/test/subs_in_out.cc
+++ b/test/subs_in_out.cc
@@ -37,7 +37,7 @@ main (int argc, char* argv[])
} catch (exception& e) {
cerr << "Could not load as interop: " << e.what() << "\n";
try {
- dcp::SMPTESubtitleAsset sc (argv[1]);
+ dcp::SMPTESubtitleAsset sc (argv[1], dcp::ASSET_DCP);
cout << sc.xml_as_string();
} catch (exception& e) {
cerr << "Could not load as SMPTE (" << e.what() << ")\n";
diff --git a/tools/dcpdumpsub.cc b/tools/dcpdumpsub.cc
index ca98551b..2a045625 100644
--- a/tools/dcpdumpsub.cc
+++ b/tools/dcpdumpsub.cc
@@ -71,7 +71,7 @@ main (int argc, char* argv[])
exit (EXIT_FAILURE);
}
- dcp::SMPTESubtitleAsset sub (argv[optind]);
+ dcp::SMPTESubtitleAsset sub (argv[optind], dcp::ASSET_DCP);
cout << sub.xml_as_string() << "\n";