* @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 <dcp/decrypted_kdm.h>
#include <dcp/locale_convert.h>
#include <dcp/sound_asset.h>
#include <dcp/subtitle_asset.h>
#include <dcp/atmos_asset.h>
+DCPOMATIC_DISABLE_WARNINGS
extern "C" {
#include <libavfilter/avfilter.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
+DCPOMATIC_ENABLE_WARNINGS
#include <curl/curl.h>
#include <glib.h>
#include <pangomm/init.h>
#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 boost::thread;
-using boost::optional;
-using boost::lexical_cast;
+using std::string;
+using std::vector;
+using std::wstring;
using boost::bad_lexical_cast;
+using boost::lexical_cast;
+using boost::optional;
using boost::scoped_array;
+using boost::thread;
using dcp::Size;
-using dcp::raw_convert;
using dcp::locale_convert;
+using dcp::raw_convert;
using namespace dcpomatic;
+
/** Path to our executable, required by the stacktrace stuff and filled
* in during App::onInit().
*/
static boost::thread::id ui_thread;
static boost::filesystem::path backtrace_file;
+
/** Convert some number of seconds to a string representation
* in hours, minutes and seconds.
*
return buffer;
}
+
string
time_to_hmsf (DCPTime time, Frame rate)
{
return buffer;
}
+
/** @param s Number of seconds.
* @return String containing an approximate description of s (e.g. "about 2 hours")
*/
return ap;
}
+
double
seconds (struct timeval t)
{
return t.tv_sec + (double (t.tv_usec) / 1e6);
}
+
#ifdef DCPOMATIC_WINDOWS
/** Resolve symbol name and source location given the path to the executable */
return system(addr2line_cmd);
}
+
DCPOMATIC_DISABLE_WARNINGS
/** This is called when C signals occur on Windows (e.g. SIGSEGV)
* (NOT C++ exceptions!). We write a backtrace to backtrace_file by dark means.
DCPOMATIC_ENABLE_WARNINGS
#endif
+
void
set_backtrace_file (boost::filesystem::path p)
{
backtrace_file = p;
}
+
/** This is called when there is an unhandled exception. Any
* backtrace in this function is useless on Windows as the stack has
* already been unwound from the throw; we have the gdb wrap hack to
abort();
}
+
void
dcpomatic_setup_path_encoding ()
{
#endif
}
+
/** Call the required functions to set up DCP-o-matic's static arrays, etc.
* Must be called from the UI thread, if there is one.
*/
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
list<StringText> subs;
dcp::SubtitleString ss(
optional<string>(), 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<shared_ptr<Font>>(), dcp::Size(640, 480), DCPTime(), 24);
ui_thread = boost::this_thread::get_id ();
}
+
#ifdef DCPOMATIC_WINDOWS
boost::filesystem::path
mo_path ()
}
#endif
+
#ifdef DCPOMATIC_OSX
boost::filesystem::path
mo_path ()
}
#endif
+
void
dcpomatic_setup_gettext_i18n (string lang)
{
#endif
}
+
/** Compute a digest of the first and last `size' bytes of a set of files. */
string
digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
return digester.get ();
}
+
+string
+simple_digest (vector<boost::filesystem::path> paths)
+{
+ return digest_head_tail(paths, 1000000) + raw_convert<string>(boost::filesystem::file_size(paths.front()));
+}
+
+
/** Round a number up to the nearest multiple of another number.
* @param c Index.
* @param stride Array of numbers to round, indexed by c.
return a - (a % t);
}
+
/** Trip an assert if the caller is not in the UI thread */
void
ensure_ui_thread ()
DCPOMATIC_ASSERT (boost::this_thread::get_id() == ui_thread);
}
+
string
audio_channel_name (int c)
{
return channels[c];
}
+
string
short_audio_channel_name (int c)
{
_("BsR"),
_("DBP"),
_("DBS"),
- "",
+ _("Sign"),
""
};
);
}
+
bool
valid_sound_file (boost::filesystem::path f)
{
return (ext == ".wav" || ext == ".mp3" || ext == ".aif" || ext == ".aiff");
}
+
bool
valid_j2k_file (boost::filesystem::path f)
{
return (ext == ".j2k" || ext == ".j2c" || ext == ".jp2");
}
+
string
tidy_for_filename (string f)
{
return f;
}
+
dcp::Size
fit_ratio_within (float ratio, dcp::Size full_frame)
{
return dcp::Size (full_frame.width, lrintf (full_frame.width / ratio));
}
+
void *
wrapped_av_malloc (size_t s)
{
return p;
}
+
map<string, string>
split_get_request (string url)
{
return r;
}
+
string
video_asset_filename (shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, optional<string> summary)
{
return Config::instance()->dcp_asset_filename_format().get(values, "_" + asset->id() + ".mxf");
}
+
string
audio_asset_filename (shared_ptr<dcp::SoundAsset> asset, int reel_index, int reel_count, optional<string> summary)
{
return boost::locale::conv::utf_to_utf<char>(out);
}
+
/** @param mapped List of mapped audio channels from a Film.
* @param channels Total number of channels in the Film.
* @return First: number of non-LFE soundtrack channels (L/R/C/Ls/Rs/Lc/Rc/Bsl/Bsr), second: number of LFE channels.
return make_pair (non_lfe, lfe);
}
+
shared_ptr<AudioBuffers>
remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map)
{
return mapped;
}
+
Eyes
increment_eyes (Eyes e)
{
return Eyes::LEFT;
}
+
void
checked_fwrite (void const * ptr, size_t size, FILE* stream, boost::filesystem::path path)
{
}
}
+
void
checked_fread (void* ptr, size_t size, FILE* stream, boost::filesystem::path path)
{
}
}
+
size_t
utf8_strlen (string s)
{
return N;
}
+
string
day_of_week_to_string (boost::gregorian::greg_weekday d)
{
return d.as_long_string ();
}
+
/** @param size Size of picture that the subtitle will be overlaid onto */
void
emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, shared_ptr<TextDecoder> 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<double> rect(0, 0, image->size().width / double(size.width), image->size().height / double(size.height));
decoder->emit_bitmap (period, image, rect);
}
+
bool
show_jobs_on_console (bool progress)
{
return error;
}
+
/** XXX: could use mmap? */
void
-copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)> progress)
+copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)> progress)
{
auto f = fopen_boost (from, "rb");
if (!f) {
free (buffer);
}
+
double
db_to_linear (double db)
{
return pow(10, db / 20);
}
+
double
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) {
s.width = lrintf (s.width * scale);
s.height = lrintf (s.height * scale);
+ s = quanta.round (s);
}
return s;
return liberation_normal;
}
+
+
+string
+to_upper (string s)
+{
+ transform (s.begin(), s.end(), s.begin(), ::toupper);
+ 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
+