41 #include "compose.hpp"
48 #include <asdcp/KM_fileio.h>
49 #include <asdcp/AS_DCP.h>
52 using std::make_shared;
54 using std::shared_ptr;
55 using boost::optional;
61 auto const size = boost::filesystem::file_size (path);
62 _buffer.reset(
new ASDCP::JP2K::FrameBuffer(
size));
65 boost::throw_exception (
FileError(
"could not open JPEG2000 file", path, errno));
68 size_t n = fread (
data(), 1,
size, f);
72 boost::throw_exception (
FileError(
"could not read from JPEG2000 file", path, errno));
88 _buffer = make_shared<ASDCP::JP2K::FrameBuffer>(4 * Kumu::Megabyte);
90 auto const r = reader->ReadFrame (n, *_buffer, c->context(), check_hmac ? c->hmac() :
nullptr);
92 if (ASDCP_FAILURE(r)) {
93 boost::throw_exception (
ReadError(String::compose (
"could not read video frame %1 (%2)", n,
static_cast<int>(r))));
100 _buffer = make_shared<ASDCP::JP2K::FrameBuffer>(
size);
101 _buffer->Size (
size);
102 memcpy (_buffer->Data(),
data,
size);
109 return _buffer->RoData ();
116 return _buffer->Data ();
123 return _buffer->Size ();
127 shared_ptr<OpenJPEGImage>
130 return decompress_j2k (
const_cast<uint8_t*
>(_buffer->RoData()), _buffer->Size(), reduce);
An exception related to a file.
std::shared_ptr< OpenJPEGImage > xyz_image(int reduce=0) const
MonoPictureFrame(boost::filesystem::path path)
uint8_t const * data() const override
int size() const override
Any error that occurs when reading data from a DCP.
Exceptions thrown by libdcp.
Methods to encode and decode JPEG2000.
Namespace for everything in libdcp.
std::shared_ptr< OpenJPEGImage > decompress_j2k(uint8_t const *data, int64_t size, int reduce)
FILE * fopen_boost(boost::filesystem::path, std::string)
Conversion between RGB and XYZ.
Utility methods and classes.