diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-07-21 01:50:51 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-07-21 18:58:43 +0200 |
| commit | 5c6575633a3e9208a4759ba318c759b08904e686 (patch) | |
| tree | 8632e604f255ea0abd558c247f2feba975616161 /src | |
| parent | bc34a710886beb753b449ac7da842aacfff3dd2d (diff) | |
Represent frame info hash using raw bytes rather than ASCII-encoding.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/film.cc | 7 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/lib/frame_info.cc | 14 | ||||
| -rw-r--r-- | src/lib/frame_info.h | 4 | ||||
| -rw-r--r-- | src/lib/reel_writer.cc | 3 |
5 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 577895161..c7892d555 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -146,6 +146,12 @@ static constexpr char assets_file[] = "assets.xml"; */ int const Film::current_state_version = 38; +/* 1 -> 2 + * Hash stored as raw bytes rather than with ASCII encoding + * (16 bytes instead of 32) + */ +int const Film::current_frame_info_version = 2; + /** Construct a Film object in a given directory. * @@ -289,6 +295,7 @@ Film::info_file (DCPTimePeriod period) const { boost::filesystem::path p; p /= "info"; + p /= raw_convert<string>(current_frame_info_version); p /= video_identifier () + "_" + raw_convert<string> (period.from.get()) + "_" + raw_convert<string> (period.to.get()); return file (p); } diff --git a/src/lib/film.h b/src/lib/film.h index 2e7a562e1..285f72152 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -456,6 +456,7 @@ public: /** Current version number of the state file */ static int const current_state_version; + static int const current_frame_info_version; private: diff --git a/src/lib/frame_info.cc b/src/lib/frame_info.cc index e9478b7b1..33b895eb7 100644 --- a/src/lib/frame_info.cc +++ b/src/lib/frame_info.cc @@ -25,11 +25,11 @@ using std::shared_ptr; -using std::string; +using std::vector; -J2KFrameInfo::J2KFrameInfo(uint64_t offset_, uint64_t size_, string hash_) - : dcp::J2KFrameInfo(offset_, size_, hash_) +J2KFrameInfo::J2KFrameInfo(uint64_t offset_, uint64_t size_, vector<unsigned char> hash_) + : dcp::J2KFrameInfo(offset_, size_, std::move(hash_)) { } @@ -61,10 +61,8 @@ J2KFrameInfo::read(dcp::File& file) file.checked_read(&offset, sizeof(offset)); file.checked_read(&size, sizeof(size)); - char hash_buffer[33]; - file.checked_read(hash_buffer, 32); - hash_buffer[32] = '\0'; - hash = hash_buffer; + hash.resize(16); + file.checked_read(hash.data(), 16); } @@ -93,6 +91,6 @@ J2KFrameInfo::write(shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes info_file->get().seek(position(frame, eyes), SEEK_SET); info_file->get().checked_write(&offset, sizeof(offset)); info_file->get().checked_write(&size, sizeof(size)); - info_file->get().checked_write(hash.c_str(), hash.size()); + info_file->get().checked_write(hash.data(), hash.size()); } diff --git a/src/lib/frame_info.h b/src/lib/frame_info.h index 9ec141588..064aec91d 100644 --- a/src/lib/frame_info.h +++ b/src/lib/frame_info.h @@ -32,7 +32,7 @@ class J2KFrameInfo : public dcp::J2KFrameInfo { public: J2KFrameInfo(dcp::J2KFrameInfo const& info); - J2KFrameInfo(uint64_t offset_, uint64_t size_, std::string hash_); + J2KFrameInfo(uint64_t offset_, uint64_t size_, std::vector<unsigned char> hash_); explicit J2KFrameInfo(std::shared_ptr<InfoFileHandle> info_file); J2KFrameInfo(std::shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes); @@ -46,7 +46,7 @@ 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); + static constexpr auto _size_on_disk = 16 + sizeof(dcp::J2KFrameInfo::offset) + sizeof(dcp::J2KFrameInfo::size); }; diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index d8aff1162..17ac02c0c 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -986,8 +986,7 @@ ReelWriter::existing_picture_frame_ok (dcp::File& asset_file, shared_ptr<InfoFil } else { Digester digester; digester.add (data.data(), data.size()); - LOG_GENERAL ("Hash %1 vs %2", digester.get(), info.hash); - if (digester.get() != info.hash) { + if (digester.get_vector() != info.hash) { LOG_GENERAL ("Existing frame %1 failed hash check", frame); ok = false; } |
