summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-04-21 01:00:36 +0100
committerCarl Hetherington <cth@carlh.net>2015-04-21 01:00:36 +0100
commitff96cc9c9e33fbe9dea02ea2d397144f9c9ac8c9 (patch)
tree30182f6187bb2ac4df9499f9b64e42aa9ae862dc /src/lib/util.cc
parent1a9453df58177ff006da99e9ef1ed77624aa7d42 (diff)
Hand-apply bd7102b476c631b1fa9067f18ce938d86073f6c8; single-file hashes.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index ab991e76b..1c9968206 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -423,7 +423,7 @@ md5_digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t si
}
boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i]));
- fseek (f, -this_time, SEEK_END);
+ dcpomatic_fseek (f, -this_time, SEEK_END);
fread (p, 1, this_time, f);
p += this_time;
to_do -= this_time;
@@ -619,3 +619,47 @@ split_get_request (string url)
return r;
}
+
+long
+frame_info_position (int frame, Eyes eyes)
+{
+ static int const info_size = 48;
+
+ switch (eyes) {
+ case EYES_BOTH:
+ return frame * info_size;
+ case EYES_LEFT:
+ return frame * info_size * 2;
+ case EYES_RIGHT:
+ return frame * info_size * 2 + info_size;
+ default:
+ DCPOMATIC_ASSERT (false);
+ }
+
+ DCPOMATIC_ASSERT (false);
+}
+
+dcp::FrameInfo
+read_frame_info (FILE* file, int frame, Eyes eyes)
+{
+ dcp::FrameInfo info;
+ dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
+ fread (&info.offset, sizeof (info.offset), 1, file);
+ fread (&info.size, sizeof (info.size), 1, file);
+
+ char hash_buffer[33];
+ fread (hash_buffer, 1, 32, file);
+ hash_buffer[32] = '\0';
+ info.hash = hash_buffer;
+
+ return info;
+}
+
+void
+write_frame_info (FILE* file, int frame, Eyes eyes, dcp::FrameInfo info)
+{
+ dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
+ fwrite (&info.offset, sizeof (info.offset), 1, file);
+ fwrite (&info.size, sizeof (info.size), 1, file);
+ fwrite (info.hash.c_str(), 1, info.hash.size(), file);
+}