X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Futil.cc;h=6bcacf9f2bd3733dd09e1f2bafbdeeb100b8fb9e;hb=4b74bd9f359b9fe4f841cd9a361f3b2b24c2351e;hp=d3511e8c7e34e0b1c5f5744147b18d83fb944837;hpb=0aabb6497979e2df9731f8753645149d85c02bc8;p=dcpomatic.git diff --git a/src/lib/util.cc b/src/lib/util.cc index d3511e8c7..6bcacf9f2 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -22,29 +22,33 @@ * @brief Some utility functions and classes. */ -#include "util.h" -#include "exceptions.h" -#include "dcp_content_type.h" -#include "filter.h" + +#define UNICODE 1 + + +#include "audio_buffers.h" +#include "audio_processor.h" #include "cinema_sound_processor.h" +#include "compose.hpp" #include "config.h" -#include "ratio.h" -#include "job.h" #include "cross.h" -#include "video_content.h" -#include "rect.h" -#include "digester.h" -#include "audio_processor.h" #include "crypto.h" -#include "compose.hpp" -#include "audio_buffers.h" -#include "string_text.h" -#include "font.h" -#include "render_text.h" +#include "dcp_content_type.h" +#include "digester.h" +#include "exceptions.h" #include "ffmpeg_image_proxy.h" +#include "filter.h" +#include "font.h" #include "image.h" -#include "text_decoder.h" +#include "job.h" #include "job_manager.h" +#include "ratio.h" +#include "rect.h" +#include "render_text.h" +#include "string_text.h" +#include "text_decoder.h" +#include "util.h" +#include "video_content.h" #include "warnings.h" #include #include @@ -54,11 +58,13 @@ #include #include #include +DCPOMATIC_DISABLE_WARNINGS extern "C" { #include #include #include } +DCPOMATIC_ENABLE_WARNINGS #include #include #include @@ -89,25 +95,23 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" -using std::string; -using std::wstring; -using std::setfill; -using std::ostream; + +using std::bad_alloc; +using std::cout; using std::endl; -using std::vector; -using std::min; -using std::max; -using std::map; -using std::list; -using std::multimap; using std::istream; +using std::list; +using std::make_pair; +using std::make_shared; +using std::map; +using std::min; +using std::ostream; using std::pair; -using std::cout; -using std::bad_alloc; using std::set_terminate; -using std::make_pair; using std::shared_ptr; -using std::make_shared; +using std::string; +using std::vector; +using std::wstring; using boost::thread; using boost::optional; using boost::lexical_cast; @@ -118,6 +122,7 @@ using dcp::raw_convert; using dcp::locale_convert; using namespace dcpomatic; + /** Path to our executable, required by the stacktrace stuff and filled * in during App::onInit(). */ @@ -365,10 +370,12 @@ dcpomatic_setup () SetUnhandledExceptionFilter(exception_handler); #endif +#ifdef DCPOMATIC_HAVE_AVREGISTER DCPOMATIC_DISABLE_WARNINGS av_register_all (); avfilter_register_all (); DCPOMATIC_ENABLE_WARNINGS +#endif #ifdef DCPOMATIC_OSX /* Add our library directory to the libltdl search path so that @@ -392,14 +399,14 @@ DCPOMATIC_ENABLE_WARNINGS #endif Pango::init (); - dcp::init (tags_path()); + dcp::init (libdcp_resources_path()); #if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) /* Render something to fontconfig to create its cache */ list subs; dcp::SubtitleString ss( optional(), false, false, false, dcp::Colour(), 42, 1, dcp::Time(), dcp::Time(), 0, dcp::HAlign::CENTER, 0, dcp::VAlign::CENTER, dcp::Direction::LTR, - "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time() + "Hello dolly", dcp::Effect::NONE, dcp::Colour(), dcp::Time(), dcp::Time(), 0 ); subs.push_back (StringText(ss, 0)); render_text (subs, list>(), dcp::Size(640, 480), DCPTime(), 24); @@ -522,18 +529,6 @@ digest_head_tail (vector files, boost::uintmax_t size) return digester.get (); } -/** Round a number up to the nearest multiple of another number. - * @param c Index. - * @param stride Array of numbers to round, indexed by c. - * @param t Multiple to round to. - * @return Rounded number. - */ -int -stride_round_up (int c, int const * stride, int t) -{ - int const a = stride[c] + (t - 1); - return a - (a % t); -} /** Trip an assert if the caller is not in the UI thread */ void @@ -595,7 +590,7 @@ short_audio_channel_name (int c) _("BsR"), _("DBP"), _("DBS"), - "", + _("Sign"), "" }; @@ -949,8 +944,8 @@ void emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, shared_ptr decoder) { /* XXX: this is rather inefficient; decoding the image just to get its size */ - FFmpegImageProxy proxy (sub.png_image(), VideoRange::FULL); - auto image = proxy.image().image; + FFmpegImageProxy proxy (sub.png_image()); + auto image = proxy.image(Image::Alignment::PADDED).image; /* set up rect with height and width */ dcpomatic::Rect rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height)); @@ -1040,7 +1035,7 @@ show_jobs_on_console (bool progress) /** XXX: could use mmap? */ void -copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function progress) +copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function progress) { auto f = fopen_boost (from, "rb"); if (!f) { @@ -1104,7 +1099,7 @@ linear_to_db (double linear) dcp::Size -scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container) +scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container, PixelQuanta quanta) { /* Now scale it down if the display container is smaller than the film container */ if (display_container != film_container) { @@ -1115,6 +1110,7 @@ scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_cont s.width = lrintf (s.width * scale); s.height = lrintf (s.height * scale); + s = quanta.round (s); } return s; @@ -1176,3 +1172,21 @@ to_upper (string s) return s; } + +/* Set to 1 to print the IDs of some of our threads to stdout on creation */ +#define DCPOMATIC_DEBUG_THREADS 0 + +#if DCPOMATIC_DEBUG_THREADS +void +start_of_thread (string name) +{ + std::cout << "THREAD:" << name << ":" << std::hex << pthread_self() << "\n"; +} +#else +void +start_of_thread (string) +{ + +} +#endif +