diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-01-05 01:24:19 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-01-05 01:24:19 +0000 |
| commit | 5ee3348142f4cfafdbcf2c9c833843d717affc11 (patch) | |
| tree | 1c97c80eeccc6b5f515a611e35dee35b21d3b09b /src/mono_picture_frame.cc | |
| parent | 740938890d95e853cf13d4780a5d674c3d6c7f6f (diff) | |
Various IMF hacks.imf
Diffstat (limited to 'src/mono_picture_frame.cc')
| -rw-r--r-- | src/mono_picture_frame.cc | 37 |
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; } } |
