2 Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "frame_info.h"
26 using std::shared_ptr;
30 J2KFrameInfo::J2KFrameInfo(uint64_t offset_, uint64_t size_, string hash_)
31 : dcp::J2KFrameInfo(offset_, size_, hash_)
37 J2KFrameInfo::J2KFrameInfo(dcp::J2KFrameInfo const& info)
38 : dcp::J2KFrameInfo(info)
44 J2KFrameInfo::J2KFrameInfo(shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes)
46 info_file->get().seek(position(frame, eyes), SEEK_SET);
47 info_file->get().checked_read(&offset, sizeof(offset));
48 info_file->get().checked_read(&size, sizeof(size));
51 info_file->get().checked_read(hash_buffer, 32);
52 hash_buffer[32] = '\0';
58 J2KFrameInfo::position(Frame frame, Eyes eyes) const
62 return frame * _size_on_disk;
64 return frame * _size_on_disk * 2;
66 return frame * _size_on_disk * 2 + _size_on_disk;
68 DCPOMATIC_ASSERT(false);
71 DCPOMATIC_ASSERT(false);
75 /** @param frame reel-relative frame */
77 J2KFrameInfo::write(shared_ptr<InfoFileHandle> info_file, Frame frame, Eyes eyes) const
79 info_file->get().seek(position(frame, eyes), SEEK_SET);
80 info_file->get().checked_write(&offset, sizeof(offset));
81 info_file->get().checked_write(&size, sizeof(size));
82 info_file->get().checked_write(hash.c_str(), hash.size());