41 #include "compose.hpp"
45 #include "filesystem.h"
50 #include <asdcp/KM_fileio.h>
51 #include <asdcp/AS_DCP.h>
54 using std::make_shared;
56 using std::shared_ptr;
57 using boost::optional;
63 auto const size = filesystem::file_size(path);
64 _buffer.reset(
new ASDCP::JP2K::FrameBuffer(
size));
67 boost::throw_exception (
FileError(
"could not open JPEG2000 file", path, errno));
71 boost::throw_exception (
FileError(
"could not read from JPEG2000 file", path, errno));
87 _buffer = make_shared<ASDCP::JP2K::FrameBuffer>(4 * Kumu::Megabyte);
89 auto const r = reader->ReadFrame (n, *_buffer, c->context(), check_hmac ? c->hmac() :
nullptr);
91 if (ASDCP_FAILURE(r)) {
92 boost::throw_exception (
ReadError(String::compose (
"could not read video frame %1 (%2)", n,
static_cast<int>(r))));
99 _buffer = make_shared<ASDCP::JP2K::FrameBuffer>(
size);
100 _buffer->Size (
size);
101 memcpy (_buffer->Data(),
data,
size);
108 return _buffer->RoData ();
115 return _buffer->Data ();
122 return _buffer->Size ();
126 shared_ptr<OpenJPEGImage>
129 return decompress_j2k (
const_cast<uint8_t*
>(_buffer->RoData()), _buffer->Size(), reduce);
An exception related to a file.
size_t read(void *ptr, size_t size, size_t nmemb)
std::shared_ptr< OpenJPEGImage > xyz_image(int reduce=0) const
int size() const override
uint8_t const * data() const override
MonoJ2KPictureFrame(boost::filesystem::path path)
Any error that occurs when reading data from a DCP.
Exceptions thrown by libdcp.
Methods to encode and decode JPEG2000.
MonoJ2KPictureFrame class.
Namespace for everything in libdcp.
std::shared_ptr< OpenJPEGImage > decompress_j2k(uint8_t const *data, int64_t size, int reduce)
Conversion between RGB and XYZ.
Utility methods and classes.