summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-05-31 02:23:32 +0200
committerCarl Hetherington <cth@carlh.net>2024-07-21 18:58:43 +0200
commitc30cdf76f1e5cc4e22d77bc0bf358c0853e047f7 (patch)
tree55d76fe15e795652f46d0acf3c55b669b93e27f7
parente0149411ce091a3f0c33d6bb81602e15c19a09d3 (diff)
Add a constructor that can read the next frame from a dcp::File.
-rw-r--r--src/lib/frame_info.cc20
-rw-r--r--src/lib/frame_info.h8
2 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/frame_info.cc b/src/lib/frame_info.cc
index f348bca6a..e9478b7b1 100644
--- a/src/lib/frame_info.cc
+++ b/src/lib/frame_info.cc
@@ -20,6 +20,7 @@
#include "frame_info.h"
+#include "info_file_handle.h"
#include <string>
@@ -41,14 +42,27 @@ J2KFrameInfo::J2KFrameInfo(dcp::J2KFrameInfo const& info)
}
+J2KFrameInfo::J2KFrameInfo(shared_ptr<InfoFileHandle> info_file)
+{
+ read(info_file->get());
+}
+
+
J2KFrameInfo::J2KFrameInfo(shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes)
{
info_file->get().seek(position(frame, eyes), SEEK_SET);
- info_file->get().checked_read(&offset, sizeof(offset));
- info_file->get().checked_read(&size, sizeof(size));
+ read(info_file->get());
+}
+
+
+void
+J2KFrameInfo::read(dcp::File& file)
+{
+ file.checked_read(&offset, sizeof(offset));
+ file.checked_read(&size, sizeof(size));
char hash_buffer[33];
- info_file->get().checked_read(hash_buffer, 32);
+ file.checked_read(hash_buffer, 32);
hash_buffer[32] = '\0';
hash = hash_buffer;
}
diff --git a/src/lib/frame_info.h b/src/lib/frame_info.h
index a5a22bd9e..9ec141588 100644
--- a/src/lib/frame_info.h
+++ b/src/lib/frame_info.h
@@ -19,6 +19,10 @@
*/
+#ifndef DCPOMATIC_FRAME_INFO_H
+#define DCPOMATIC_FRAME_INFO_H
+
+
#include "film.h"
#include <dcp/frame_info.h>
#include <memory>
@@ -29,6 +33,7 @@ class J2KFrameInfo : public dcp::J2KFrameInfo
public:
J2KFrameInfo(dcp::J2KFrameInfo const& info);
J2KFrameInfo(uint64_t offset_, uint64_t size_, std::string hash_);
+ explicit J2KFrameInfo(std::shared_ptr<InfoFileHandle> info_file);
J2KFrameInfo(std::shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes);
void write(std::shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes) const;
@@ -38,8 +43,11 @@ public:
}
private:
+ void read(dcp::File& file);
long position(Frame frame, Eyes eyes) const;
static constexpr auto _size_on_disk = 32 + sizeof(dcp::J2KFrameInfo::offset) + sizeof(dcp::J2KFrameInfo::size);
};
+
+#endif