#endif
#ifdef DCPOMATIC_LINUX
- bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX);
+ bindtextdomain ("libdcpomatic", LINUX_LOCALE_PREFIX);
#endif
}
}
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;
bool
valid_image_file (boost::filesystem::path f)
{
+ if (boost::starts_with (f.leaf().string(), "._")) {
+ return false;
+ }
+
string ext = f.extension().string();
transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
return (
}
dcp::Size
-fit_ratio_within (float ratio, dcp::Size full_frame, int round)
+fit_ratio_within (float ratio, dcp::Size full_frame)
{
if (ratio < full_frame.ratio ()) {
- return dcp::Size (round_to (full_frame.height * ratio, round), full_frame.height);
+ return dcp::Size (rint (full_frame.height * ratio), full_frame.height);
}
- return dcp::Size (full_frame.width, round_to (full_frame.width / ratio, round));
+ return dcp::Size (full_frame.width, rint (full_frame.width / ratio));
}
void *
}
return p;
}
-
-ContentTimePeriod
+
+FFmpegSubtitlePeriod
subtitle_period (AVSubtitle const & sub)
{
ContentTime const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
- ContentTimePeriod period (
+ if (sub.end_display_time == static_cast<uint32_t> (-1)) {
+ /* End time is not known */
+ return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3));
+ }
+
+ return FFmpegSubtitlePeriod (
packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3),
packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3)
);
-
- return period;
}
map<string, string>
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);
+}