diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-09-15 21:25:17 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-09-15 21:25:17 +0200 |
| commit | 631ddd5d70e17f728af54edd6b2cbef61a08a253 (patch) | |
| tree | 772ba0adf994b84e3740c4c8d784b611704ffaa6 | |
| parent | 6735d3e88062d44433a1432bcc2f07ba1a610be4 (diff) | |
Add a constructor that can read the next frame from a dcp::File.
| -rw-r--r-- | src/lib/j2k_frame_info.cc | 13 | ||||
| -rw-r--r-- | src/lib/j2k_frame_info.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/j2k_frame_info.cc b/src/lib/j2k_frame_info.cc index 0e83c61f0..b260166ea 100644 --- a/src/lib/j2k_frame_info.cc +++ b/src/lib/j2k_frame_info.cc @@ -41,9 +41,22 @@ J2KFrameInfo::J2KFrameInfo(dcp::J2KFrameInfo const& info) } +J2KFrameInfo::J2KFrameInfo(dcp::File& info_file) +{ + read(info_file); +} + + J2KFrameInfo::J2KFrameInfo(dcp::File& info_file, Frame frame, Eyes eyes) { info_file.seek(position(frame, eyes), SEEK_SET); + read(info_file); +} + + +void +J2KFrameInfo::read(dcp::File& info_file) +{ info_file.checked_read(&offset, sizeof(offset)); info_file.checked_read(&size, sizeof(size)); diff --git a/src/lib/j2k_frame_info.h b/src/lib/j2k_frame_info.h index da9503248..d1ffd4d7c 100644 --- a/src/lib/j2k_frame_info.h +++ b/src/lib/j2k_frame_info.h @@ -29,6 +29,7 @@ class J2KFrameInfo : public dcp::J2KFrameInfo public: J2KFrameInfo(dcp::J2KFrameInfo const& info); J2KFrameInfo(uint64_t offset_, uint64_t size_, std::string hash_); + J2KFrameInfo(dcp::File& info_file); /** Seek to the required position in info_file and read the info for * the given frame and eyes. */ @@ -45,6 +46,7 @@ public: private: long position(Frame frame, Eyes eyes) const; + void read(dcp::File& info_file); static constexpr auto _size_on_disk = 32 + sizeof(dcp::J2KFrameInfo::offset) + sizeof(dcp::J2KFrameInfo::size); }; |
