X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=dccf32f4d6c5d1345d4c7202b0dbe5ae812eb85d;hb=5229b795b9d7cafe174496fbc6bca8d62f4a3ff0;hp=f98e5960bb20e807f8bf2c9df0c0594a38f54926;hpb=a5e87b6f0f496f4ed71d9129d40a5baebb68495f;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index f98e5960b..dccf32f4d 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -37,6 +37,9 @@ #include "safe_stringstream.h" #include #include +#include +#include +#include #include #include #include @@ -322,6 +325,7 @@ dcpomatic_setup () dcp::init (); Ratio::setup_ratios (); + PresetColourConversion::setup_colour_conversion_presets (); VideoContentScale::setup_scales (); DCPContentType::setup_dcp_content_types (); Filter::setup_filters (); @@ -509,6 +513,10 @@ audio_channel_name (int c) 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 ( @@ -542,13 +550,13 @@ tidy_for_filename (string f) } 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 * @@ -560,18 +568,21 @@ wrapped_av_malloc (size_t s) } return p; } - -ContentTimePeriod + +FFmpegSubtitlePeriod subtitle_period (AVSubtitle const & sub) { ContentTime const packet_time = ContentTime::from_seconds (static_cast (sub.pts) / AV_TIME_BASE); - ContentTimePeriod period ( + if (sub.end_display_time == static_cast (-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 @@ -663,3 +674,21 @@ write_frame_info (FILE* file, int frame, Eyes eyes, dcp::FrameInfo info) fwrite (&info.size, sizeof (info.size), 1, file); fwrite (info.hash.c_str(), 1, info.hash.size(), file); } + +string +video_mxf_filename (shared_ptr mxf) +{ + return "j2c_" + mxf->id() + ".mxf"; +} + +string +audio_mxf_filename (shared_ptr mxf) +{ + return "pcm_" + mxf->id() + ".mxf"; +} + +string +subtitle_content_filename (shared_ptr content) +{ + return "sub_" + content->id() + ".xml"; +}