summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-11-24 09:37:22 +0000
committerCarl Hetherington <cth@carlh.net>2014-11-24 09:37:22 +0000
commit5aa66b7fd3e5256cd20eedde287a2124522610a0 (patch)
tree08059a8bf97110b2c995c1e9b6f130957098535e /src
parent3c5c59b5244d8948f05a3251ec14cb20fbcc0d7c (diff)
Add constructor of MonoPictureFrame from a JPEG2000 codestream file.
Diffstat (limited to 'src')
-rw-r--r--src/mono_picture_frame.cc18
-rw-r--r--src/mono_picture_frame.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc
index a06634a5..f3063c0c 100644
--- a/src/mono_picture_frame.cc
+++ b/src/mono_picture_frame.cc
@@ -37,6 +37,24 @@ using std::string;
using boost::shared_ptr;
using namespace dcp;
+/** Make a picture frame from a JPEG2000 file.
+ * @param path Path to JPEG2000 file.
+ */
+MonoPictureFrame::MonoPictureFrame (boost::filesystem::path path)
+{
+ boost::uintmax_t const size = boost::filesystem::file_size (path);
+ _buffer = new ASDCP::JP2K::FrameBuffer (size);
+ FILE* f = fopen_boost (path, "r");
+ if (!f) {
+ boost::throw_exception (FileError ("could not open JPEG2000 file", path, errno));
+ }
+
+ fread (j2k_data(), 1, size, f);
+ fclose (f);
+
+ _buffer->Size (size);
+}
+
/** Make a picture frame from a 2D (monoscopic) asset.
* @param mxf_path Path to the asset's MXF file.
* @param n Frame within the asset, not taking EntryPoint into account.
diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h
index 707c54cd..78728fbf 100644
--- a/src/mono_picture_frame.h
+++ b/src/mono_picture_frame.h
@@ -46,6 +46,7 @@ class MonoPictureFrame : public boost::noncopyable
{
public:
MonoPictureFrame (boost::filesystem::path mxf_path, int n, ASDCP::AESDecContext *);
+ MonoPictureFrame (boost::filesystem::path path);
MonoPictureFrame ();
~MonoPictureFrame ();