summaryrefslogtreecommitdiff
path: root/src/mono_picture_frame.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mono_picture_frame.cc')
-rw-r--r--src/mono_picture_frame.cc37
1 files changed, 26 insertions, 11 deletions
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;
}
}