diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-09 16:29:21 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-09 16:29:21 +0100 |
| commit | 92b7d1cffbd0d457f8b4b23cc72937bcf8e5ed5e (patch) | |
| tree | b175db682422765468991702e8563bcd89713b70 /src | |
| parent | 7392cb8383c9b857edad5f99eaf917ed70da237d (diff) | |
Tidying.
Diffstat (limited to 'src')
67 files changed, 523 insertions, 301 deletions
diff --git a/src/lib/active_text.cc b/src/lib/active_text.cc index 1180ce7b0..1e0fd6adb 100644 --- a/src/lib/active_text.cc +++ b/src/lib/active_text.cc @@ -31,6 +31,7 @@ using std::shared_ptr; using boost::optional; using namespace dcpomatic; + /** Get the open captions that should be burnt into a given period. * @param period Period of interest. * @param always_burn_captions Always burn captions even if their content is not set to burn. @@ -42,9 +43,9 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const list<PlayerText> ps; - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + for (auto const& i: _data) { - shared_ptr<const TextContent> caption = i->first.lock (); + auto caption = i.first.lock (); if (!caption) { continue; } @@ -54,9 +55,9 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const continue; } - for (auto j: i->second) { + for (auto j: i.second) { DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); - optional<DCPTimePeriod> overlap = period.overlap (test); + auto overlap = period.overlap (test); if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { ps.push_back (j.subs); } @@ -66,6 +67,7 @@ ActiveText::get_burnt (DCPTimePeriod period, bool always_burn_captions) const return ps; } + /** Remove subtitles that finish before a given time from our list. * @param time Time to remove before. */ @@ -75,20 +77,21 @@ ActiveText::clear_before (DCPTime time) boost::mutex::scoped_lock lm (_mutex); Map updated; - for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + for (auto const& i: _data) { list<Period> as; - for (auto j: i->second) { + for (auto j: i.second) { if (!j.to || j.to.get() >= time) { as.push_back (j); } } if (!as.empty ()) { - updated[i->first] = as; + updated[i.first] = as; } } _data = updated; } + /** Add a new subtitle with a from time. * @param content Content that the subtitle is from. * @param ps Subtitles. @@ -105,6 +108,7 @@ ActiveText::add_from (weak_ptr<const TextContent> content, PlayerText ps, DCPTim _data[content].push_back (Period (ps, from)); } + /** Add the to time for the last subtitle added from a piece of content. * @param content Content that the subtitle is from. * @param to To time for the last subtitle submitted to add_from for this content. @@ -126,6 +130,7 @@ ActiveText::add_to (weak_ptr<const TextContent> content, DCPTime to) return make_pair (_data[content].back().subs, _data[content].back().from); } + /** @param content Some content. * @return true if we have any active subtitles from this content. */ @@ -134,7 +139,7 @@ ActiveText::have (weak_ptr<const TextContent> content) const { boost::mutex::scoped_lock lm (_mutex); - Map::const_iterator i = _data.find(content); + auto i = _data.find(content); if (i == _data.end()) { return false; } @@ -142,6 +147,7 @@ ActiveText::have (weak_ptr<const TextContent> content) const return !i->second.empty(); } + void ActiveText::clear () { diff --git a/src/lib/active_text.h b/src/lib/active_text.h index b54957b3f..d5ce4cb07 100644 --- a/src/lib/active_text.h +++ b/src/lib/active_text.h @@ -18,18 +18,22 @@ */ + /** @file src/lib/active_captions.h * @brief ActiveText class. */ + #include "dcpomatic_time.h" #include "player_text.h" #include <boost/thread/mutex.hpp> #include <list> #include <map> + class TextContent; + /** @class ActiveText * @brief A class to maintain information on active subtitles for Player. */ diff --git a/src/lib/content.h b/src/lib/content.h index d17b0d0e5..7fad2ff79 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -27,10 +27,11 @@ #ifndef DCPOMATIC_CONTENT_H #define DCPOMATIC_CONTENT_H -#include "types.h" -#include "signaller.h" -#include "dcpomatic_time.h" + #include "change_signaller.h" +#include "dcpomatic_time.h" +#include "signaller.h" +#include "types.h" #include "user_property.h" #include <libcxml/cxml.h> #include <boost/filesystem.hpp> diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index d72c0c43d..6df0588e9 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -176,10 +176,10 @@ DCPContent::read_directory (boost::filesystem::path p) bool have_assetmap = false; bool have_metadata = false; - for (directory_iterator i(p); i != directory_iterator(); ++i) { - if (i->path().filename() == "ASSETMAP" || i->path().filename() == "ASSETMAP.xml") { + for (auto i: directory_iterator(p)) { + if (i.path().filename() == "ASSETMAP" || i.path().filename() == "ASSETMAP.xml") { have_assetmap = true; - } else if (i->path().filename() == "metadata.xml") { + } else if (i.path().filename() == "metadata.xml") { have_metadata = true; } } diff --git a/src/lib/dkdm_recipient.cc b/src/lib/dkdm_recipient.cc index 30c307569..3e39611ca 100644 --- a/src/lib/dkdm_recipient.cc +++ b/src/lib/dkdm_recipient.cc @@ -20,8 +20,8 @@ #include "dkdm_recipient.h" -#include "kdm_with_metadata.h" #include "film.h" +#include "kdm_with_metadata.h" #include <dcp/raw_convert.h> @@ -68,7 +68,7 @@ kdm_for_dkdm_recipient ( ) { if (!recipient->recipient) { - return KDMWithMetadataPtr(); + return {}; } dcp::LocalTime const begin(valid_from, recipient->utc_offset_hour, recipient->utc_offset_minute); diff --git a/src/lib/emailer.h b/src/lib/emailer.h index fa278e535..63fd88f2d 100644 --- a/src/lib/emailer.h +++ b/src/lib/emailer.h @@ -19,6 +19,7 @@ */ +#include "types.h" #include <curl/curl.h> #include <boost/scoped_array.hpp> diff --git a/src/lib/ext.cc b/src/lib/ext.cc index 06add8d84..1af6c137b 100644 --- a/src/lib/ext.cc +++ b/src/lib/ext.cc @@ -242,8 +242,8 @@ copy (boost::filesystem::path from, boost::filesystem::path to, uint64_t& total_ } set_timestamps_to_now (cr); - for (directory_iterator i = directory_iterator(from); i != directory_iterator(); ++i) { - copy (i->path(), cr, total_remaining, total, copied_files, nanomsg); + for (auto i: directory_iterator(from)) { + copy (i.path(), cr, total_remaining, total, copied_files, nanomsg); } } else { string const write_digest = write (from, cr, total_remaining, total, nanomsg); diff --git a/src/lib/film.cc b/src/lib/film.cc index 5d1dc924b..a6f6c8a99 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -74,12 +74,12 @@ #include <boost/filesystem.hpp> #include <boost/regex.hpp> #include <unistd.h> -#include <stdexcept> -#include <iostream> #include <algorithm> #include <cstdlib> #include <iomanip> +#include <iostream> #include <set> +#include <stdexcept> #include "i18n.h" diff --git a/src/lib/film.h b/src/lib/film.h index dfa659cb5..9cd6d35a5 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -18,14 +18,17 @@ */ + /** @file src/film.h * @brief A representation of some audio and video content, and details of * how they should be presented in a DCP. */ + #ifndef DCPOMATIC_FILM_H #define DCPOMATIC_FILM_H + #include "change_signaller.h" #include "dcp_text_track.h" #include "frame_rate_change.h" @@ -44,6 +47,7 @@ #include <string> #include <vector> + namespace xmlpp { class Document; } @@ -65,6 +69,7 @@ struct isdcf_name_test; struct recover_test_2d_encrypted; struct atmos_encrypted_passthrough_test; + class InfoFileHandle { public: @@ -87,6 +92,7 @@ private: boost::filesystem::path _file; }; + /** @class Film * * @brief A representation of some audio, video, subtitle and closed-caption content, diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index a1ff2ae65..99424a9c1 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -19,18 +19,18 @@ */ -#include "frame_rate_change.h" -#include "types.h" +#include "compose.hpp" #include "content.h" #include "film.h" -#include "compose.hpp" +#include "frame_rate_change.h" +#include "types.h" #include <cmath> #include "i18n.h" -using std::string; using std::shared_ptr; +using std::string; FrameRateChange::FrameRateChange () diff --git a/src/lib/image.cc b/src/lib/image.cc index c6d2345a8..17bab64c7 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -106,6 +106,7 @@ Image::horizontal_factor (int n) const return lrintf(powf(2.0f, d->log2_chroma_w)); } + /** @param n Component index. * @return Number of samples (i.e. pixels, unless sub-sampled) in each direction for this component. */ @@ -118,6 +119,7 @@ Image::sample_size (int n) const ); } + /** @return Number of planes */ int Image::planes () const @@ -308,12 +310,14 @@ Image::crop_scale_window ( return out; } + shared_ptr<Image> Image::convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, Alignment out_alignment, bool fast) const { return scale(size(), yuv_to_rgb, out_format, out_alignment, fast); } + /** @param out_size Size to scale to. * @param yuv_to_rgb YUVToRGB transform transform to use, if required. * @param out_format Output pixel format. @@ -372,6 +376,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo return scaled; } + /** Blacken a YUV image whose bits per pixel is rounded up to 16 */ void Image::yuv_16_black (uint16_t v, bool alpha) @@ -394,12 +399,14 @@ Image::yuv_16_black (uint16_t v, bool alpha) } } + uint16_t Image::swap_16 (uint16_t v) { return ((v >> 8) & 0xff) | ((v & 0xff) << 8); } + void Image::make_part_black (int const start, int const width) { @@ -470,6 +477,7 @@ Image::make_part_black (int const start, int const width) } } + void Image::make_black () { @@ -585,6 +593,7 @@ Image::make_black () } } + void Image::make_transparent () { @@ -595,6 +604,7 @@ Image::make_transparent () memset (data()[0], 0, sample_size(0).height * stride()[0]); } + void Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) { @@ -841,6 +851,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) } } + void Image::copy (shared_ptr<const Image> other, Position<int> position) { @@ -856,6 +867,7 @@ Image::copy (shared_ptr<const Image> other, Position<int> position) } } + void Image::read_from_socket (shared_ptr<Socket> socket) { @@ -869,6 +881,7 @@ Image::read_from_socket (shared_ptr<Socket> socket) } } + void Image::write_to_socket (shared_ptr<Socket> socket) const { @@ -882,6 +895,7 @@ Image::write_to_socket (shared_ptr<Socket> socket) const } } + float Image::bytes_per_pixel (int c) const { @@ -928,6 +942,7 @@ Image::bytes_per_pixel (int c) const return bpp[c]; } + /** Construct a Image of a given size and format, allocating memory * as required. * @@ -1007,6 +1022,7 @@ Image::allocate () } } + Image::Image (Image const & other) : std::enable_shared_from_this<Image>(other) , _size (other._size) @@ -1027,6 +1043,7 @@ Image::Image (Image const & other) } } + Image::Image (AVFrame const * frame, Alignment alignment) : _size (frame->width, frame->height) , _pixel_format (static_cast<AVPixelFormat>(frame->format)) @@ -1049,6 +1066,7 @@ Image::Image (AVFrame const * frame, Alignment alignment) } } + Image::Image (shared_ptr<const Image> other, Alignment alignment) : _size (other->_size) , _pixel_format (other->_pixel_format) @@ -1069,6 +1087,7 @@ Image::Image (shared_ptr<const Image> other, Alignment alignment) } } + Image& Image::operator= (Image const & other) { @@ -1081,6 +1100,7 @@ Image::operator= (Image const & other) return *this; } + void Image::swap (Image & other) { @@ -1096,6 +1116,7 @@ Image::swap (Image & other) std::swap (_alignment, other._alignment); } + Image::~Image () { for (int i = 0; i < planes(); ++i) { @@ -1107,30 +1128,35 @@ Image::~Image () av_free (_stride); } + uint8_t * const * Image::data () const { return _data; } + int const * Image::line_size () const { return _line_size; } + int const * Image::stride () const { return _stride; } + dcp::Size Image::size () const { return _size; } + Image::Alignment Image::alignment () const { @@ -1193,6 +1219,7 @@ operator== (Image const & a, Image const & b) return true; } + /** Fade the image. * @param f Amount to fade by; 0 is black, 1 is no fade. */ diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 6a6be2716..2dbb45581 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -64,6 +64,7 @@ ImageContent::ImageContent (cxml::ConstNodePtr node, int version) video = VideoContent::from_xml (this, node, version); } + string ImageContent::summary () const { @@ -78,6 +79,7 @@ ImageContent::summary () const return s; } + string ImageContent::technical_summary () const { @@ -93,6 +95,7 @@ ImageContent::technical_summary () const return s; } + void ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const { @@ -104,6 +107,7 @@ ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const } } + void ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) { @@ -136,6 +140,7 @@ ImageContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) set_default_colour_conversion (); } + DCPTime ImageContent::full_length (shared_ptr<const Film> film) const { @@ -143,12 +148,14 @@ ImageContent::full_length (shared_ptr<const Film> film) const return DCPTime::from_frames (llrint(video->length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } + DCPTime ImageContent::approximate_length () const { return DCPTime::from_frames (video->length_after_3d_combine(), 24); } + string ImageContent::identifier () const { @@ -157,12 +164,14 @@ ImageContent::identifier () const return buffer; } + bool ImageContent::still () const { return number_of_paths() == 1; } + void ImageContent::set_default_colour_conversion () { @@ -185,6 +194,7 @@ ImageContent::set_default_colour_conversion () } } + void ImageContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p) const { diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index e1106f86d..59dc4e873 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -19,16 +19,16 @@ */ +#include "exceptions.h" +#include "ffmpeg_image_proxy.h" +#include "film.h" +#include "frame_interval_checker.h" +#include "image.h" #include "image_content.h" #include "image_decoder.h" -#include "video_decoder.h" -#include "image.h" -#include "ffmpeg_image_proxy.h" #include "j2k_image_proxy.h" -#include "film.h" -#include "exceptions.h" #include "video_content.h" -#include "frame_interval_checker.h" +#include "video_decoder.h" #include <boost/filesystem.hpp> #include <iostream> diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 562a7c557..5a1672204 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -19,16 +19,16 @@ */ -#include "image_content.h" -#include "image_examiner.h" -#include "film.h" -#include "job.h" -#include "exceptions.h" +#include "compose.hpp" #include "config.h" #include "cross.h" -#include "compose.hpp" +#include "exceptions.h" #include "ffmpeg_image_proxy.h" +#include "film.h" #include "image.h" +#include "image_content.h" +#include "image_examiner.h" +#include "job.h" #include <dcp/openjpeg_image.h> #include <dcp/exceptions.h> #include <dcp/j2k_transcode.h> @@ -39,8 +39,8 @@ using std::cout; using std::list; -using std::sort; using std::shared_ptr; +using std::sort; using boost::optional; diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc index ea5f46da6..f8bf3dc6b 100644 --- a/src/lib/image_filename_sorter.cc +++ b/src/lib/image_filename_sorter.cc @@ -18,22 +18,25 @@ */ + #include "image_filename_sorter.h" #include <dcp/locale_convert.h> #include <boost/filesystem.hpp> #include <boost/optional.hpp> #include <iostream> + using std::list; using std::string; using dcp::locale_convert; using boost::optional; + bool ImageFilenameSorter::operator() (boost::filesystem::path a, boost::filesystem::path b) { - string an = extract_numbers (a); - string bn = extract_numbers (b); + auto an = extract_numbers (a); + auto bn = extract_numbers (b); int const anl = an.length (); int const bnl = bn.length (); @@ -47,11 +50,12 @@ ImageFilenameSorter::operator() (boost::filesystem::path a, boost::filesystem::p return an < bn; } + string ImageFilenameSorter::extract_numbers (boost::filesystem::path p) { string numbers; - string const ps = p.leaf().string(); + auto const ps = p.leaf().string(); for (size_t i = 0; i < ps.size(); ++i) { if (isdigit (ps[i])) { numbers += ps[i]; diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc index 9e456c941..c426e796f 100644 --- a/src/lib/image_proxy.cc +++ b/src/lib/image_proxy.cc @@ -19,13 +19,13 @@ */ -#include "image_proxy.h" -#include "raw_image_proxy.h" +#include "cross.h" +#include "exceptions.h" #include "ffmpeg_image_proxy.h" -#include "j2k_image_proxy.h" #include "image.h" -#include "exceptions.h" -#include "cross.h" +#include "image_proxy.h" +#include "j2k_image_proxy.h" +#include "raw_image_proxy.h" #include <dcp/util.h> #include <libcxml/cxml.h> #include <iostream> diff --git a/src/lib/internet.cc b/src/lib/internet.cc index ca72399f3..34e106977 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -19,10 +19,10 @@ */ -#include "scoped_temporary.h" #include "compose.hpp" -#include "exceptions.h" #include "cross.h" +#include "exceptions.h" +#include "scoped_temporary.h" #include "util.h" #include <curl/curl.h> #include <zip.h> @@ -37,8 +37,8 @@ using std::function; using std::list; using std::string; -using boost::optional; using boost::algorithm::trim; +using boost::optional; static size_t @@ -66,7 +66,7 @@ ls_url (string url) auto const cr = curl_easy_perform (curl); if (cr != CURLE_OK) { - return list<string>(); + return {}; } list<string> result; diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 8e00f3556..985708f05 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -24,32 +24,32 @@ */ -#include "j2k_encoder.h" -#include "util.h" -#include "film.h" -#include "log.h" -#include "dcpomatic_log.h" +#include "compose.hpp" #include "config.h" -#include "dcp_video.h" #include "cross.h" -#include "writer.h" +#include "dcp_video.h" +#include "dcpomatic_log.h" +#include "encode_server_description.h" #include "encode_server_finder.h" +#include "film.h" +#include "j2k_encoder.h" +#include "log.h" #include "player.h" #include "player_video.h" -#include "encode_server_description.h" -#include "compose.hpp" +#include "util.h" +#include "writer.h" #include <libcxml/cxml.h> #include <iostream> #include "i18n.h" -using std::list; using std::cout; using std::exception; +using std::list; +using std::make_shared; using std::shared_ptr; using std::weak_ptr; -using std::make_shared; using boost::optional; using dcp::Data; using namespace dcpomatic; diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 00d3cf2ef..67083e655 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -19,18 +19,18 @@ */ -#include "j2k_image_proxy.h" +#include "dcpomatic_assert.h" #include "dcpomatic_socket.h" #include "image.h" -#include "dcpomatic_assert.h" +#include "j2k_image_proxy.h" #include "warnings.h" -#include <dcp/raw_convert.h> -#include <dcp/openjpeg_image.h> -#include <dcp/mono_picture_frame.h> -#include <dcp/stereo_picture_frame.h> #include <dcp/colour_conversion.h> -#include <dcp/rgb_xyz.h> #include <dcp/j2k_transcode.h> +#include <dcp/mono_picture_frame.h> +#include <dcp/openjpeg_image.h> +#include <dcp/raw_convert.h> +#include <dcp/rgb_xyz.h> +#include <dcp/stereo_picture_frame.h> #include <libcxml/cxml.h> DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> diff --git a/src/lib/job.cc b/src/lib/job.cc index 4c8199bdc..50dcc336e 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -18,35 +18,39 @@ */ + /** @file src/job.cc * @brief A parent class to represent long-running tasks which are run in their own thread. */ -#include "job.h" -#include "util.h" + +#include "compose.hpp" #include "cross.h" +#include "dcpomatic_log.h" #include "exceptions.h" #include "film.h" +#include "job.h" #include "log.h" -#include "dcpomatic_log.h" -#include "compose.hpp" +#include "util.h" #include <dcp/exceptions.h> #include <sub/exceptions.h> -#include <boost/thread.hpp> -#include <boost/filesystem.hpp> #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/filesystem.hpp> +#include <boost/thread.hpp> #include <iostream> #include "i18n.h" -using std::string; -using std::list; + using std::cout; +using std::function; +using std::list; using std::shared_ptr; +using std::string; using boost::optional; -using std::function; using namespace dcpomatic; + /** @param film Associated film, or 0 */ Job::Job (shared_ptr<const Film> film) : _film (film) @@ -59,6 +63,7 @@ Job::Job (shared_ptr<const Film> film) } + Job::~Job () { #ifdef DCPOMATIC_DEBUG @@ -67,6 +72,7 @@ Job::~Job () #endif } + void Job::stop_thread () { @@ -78,6 +84,7 @@ Job::stop_thread () } catch (...) {} } + /** Start the job in a separate thread, returning immediately */ void Job::start () @@ -91,6 +98,7 @@ Job::start () #endif } + /** A wrapper for the ::run() method to catch exceptions */ void Job::run_wrapper () @@ -251,6 +259,7 @@ Job::run_wrapper () } } + /** @return true if this job is new (ie has not started running) */ bool Job::is_new () const @@ -259,6 +268,7 @@ Job::is_new () const return _state == NEW; } + /** @return true if the job is running */ bool Job::running () const @@ -267,6 +277,7 @@ Job::running () const return _state == RUNNING; } + /** @return true if the job has finished (either successfully or unsuccessfully) */ bool Job::finished () const @@ -275,6 +286,7 @@ Job::finished () const return _state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED; } + /** @return true if the job has finished successfully */ bool Job::finished_ok () const @@ -283,6 +295,7 @@ Job::finished_ok () const return _state == FINISHED_OK; } + /** @return true if the job has finished unsuccessfully */ bool Job::finished_in_error () const @@ -291,6 +304,7 @@ Job::finished_in_error () const return _state == FINISHED_ERROR; } + bool Job::finished_cancelled () const { @@ -298,6 +312,7 @@ Job::finished_cancelled () const return _state == FINISHED_CANCELLED; } + bool Job::paused_by_user () const { @@ -305,6 +320,7 @@ Job::paused_by_user () const return _state == PAUSED_BY_USER; } + bool Job::paused_by_priority () const { @@ -312,6 +328,7 @@ Job::paused_by_priority () const return _state == PAUSED_BY_PRIORITY; } + /** Set the state of this job. * @param s New state. */ @@ -337,6 +354,7 @@ Job::set_state (State s) } } + /** @return DCPTime (in seconds) that this sub-job has been running */ int Job::elapsed_sub_time () const @@ -348,6 +366,7 @@ Job::elapsed_sub_time () const return time (0) - _sub_start_time; } + /** Check to see if this job has been interrupted or paused */ void Job::check_for_interruption_or_pause () @@ -403,6 +422,7 @@ Job::set_progress (float p, bool force) set_progress_common (p); } + void Job::set_progress_common (optional<float> p) { @@ -414,6 +434,7 @@ Job::set_progress_common (optional<float> p) emit (boost::bind (boost::ref (Progress))); } + /** @return fractional progress of the current sub-job, if known */ optional<float> Job::progress () const @@ -422,6 +443,7 @@ Job::progress () const return _progress; } + void Job::sub (string n) { @@ -435,6 +457,7 @@ Job::sub (string n) _sub_start_time = time (0); } + string Job::error_details () const { @@ -442,6 +465,7 @@ Job::error_details () const return _error_details; } + /** @return A summary of any error that the job has generated */ string Job::error_summary () const @@ -450,6 +474,7 @@ Job::error_summary () const return _error_summary; } + /** Set the current error string. * @param s New error string. * @param d New error detail string. @@ -466,6 +491,7 @@ Job::set_error (string s, string d) _error_details = d; } + /** Say that this job's progress will be unknown until further notice */ void Job::set_progress_unknown () @@ -474,6 +500,7 @@ Job::set_progress_unknown () set_progress_common (optional<float> ()); } + /** @return Human-readable status of this job */ string Job::status () const @@ -523,6 +550,7 @@ Job::status () const return s; } + string Job::json_status () const { @@ -547,6 +575,7 @@ Job::json_status () const return ""; } + /** @return An estimate of the remaining time for this sub-job, in seconds */ int Job::remaining_time () const @@ -558,6 +587,7 @@ Job::remaining_time () const return elapsed_sub_time() / progress().get() - elapsed_sub_time(); } + void Job::cancel () { @@ -573,6 +603,7 @@ Job::cancel () _thread.join (); } + /** @return true if the job was paused, false if it was not running */ bool Job::pause_by_user () @@ -596,6 +627,7 @@ Job::pause_by_user () return paused; } + void Job::pause_by_priority () { @@ -605,6 +637,7 @@ Job::pause_by_priority () } } + void Job::resume () { @@ -614,6 +647,7 @@ Job::resume () } } + void Job::when_finished (boost::signals2::connection& connection, function<void()> finished) { @@ -625,6 +659,7 @@ Job::when_finished (boost::signals2::connection& connection, function<void()> fi } } + optional<string> Job::message () const { @@ -632,6 +667,7 @@ Job::message () const return _message; } + void Job::set_message (string m) { diff --git a/src/lib/kdm_with_metadata.cc b/src/lib/kdm_with_metadata.cc index a486952f8..9292be224 100644 --- a/src/lib/kdm_with_metadata.cc +++ b/src/lib/kdm_with_metadata.cc @@ -19,24 +19,24 @@ */ -#include "kdm_with_metadata.h" #include "cinema.h" -#include "screen.h" -#include "util.h" -#include "zipper.h" #include "config.h" #include "dcpomatic_log.h" #include "emailer.h" +#include "kdm_with_metadata.h" +#include "screen.h" +#include "util.h" +#include "zipper.h" #include "i18n.h" -using std::string; using std::cout; +using std::function; using std::list; using std::shared_ptr; +using std::string; using boost::optional; -using std::function; int diff --git a/src/lib/log.cc b/src/lib/log.cc index 97b649893..aae492faf 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -24,9 +24,9 @@ */ -#include "log.h" -#include "cross.h" #include "config.h" +#include "cross.h" +#include "log.h" #include "string_log_entry.h" #include <time.h> #include <cstdio> @@ -34,10 +34,10 @@ #include "i18n.h" -using std::string; using std::cout; -using std::shared_ptr; using std::make_shared; +using std::shared_ptr; +using std::string; Log::Log () diff --git a/src/lib/mid_side_decoder.cc b/src/lib/mid_side_decoder.cc index 09b528c81..d3d85622c 100644 --- a/src/lib/mid_side_decoder.cc +++ b/src/lib/mid_side_decoder.cc @@ -19,9 +19,9 @@ */ -#include "mid_side_decoder.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include "mid_side_decoder.h" #include "i18n.h" diff --git a/src/lib/nanomsg.cc b/src/lib/nanomsg.cc index 61e6c08ce..8061e2f84 100644 --- a/src/lib/nanomsg.cc +++ b/src/lib/nanomsg.cc @@ -19,17 +19,17 @@ */ -#include "nanomsg.h" #include "dcpomatic_log.h" #include "exceptions.h" +#include "nanomsg.h" #include <nanomsg/nn.h> #include <nanomsg/pair.h> -#include <stdexcept> #include <cerrno> +#include <stdexcept> -using std::string; using std::runtime_error; +using std::string; using boost::optional; diff --git a/src/lib/overlaps.cc b/src/lib/overlaps.cc index 536629b33..7a541a7c2 100644 --- a/src/lib/overlaps.cc +++ b/src/lib/overlaps.cc @@ -19,9 +19,9 @@ */ +#include "content.h" #include "overlaps.h" #include "types.h" -#include "content.h" using std::function; diff --git a/src/lib/player.cc b/src/lib/player.cc index f7b75babc..c97f977b1 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -20,46 +20,47 @@ #include "atmos_decoder.h" -#include "player.h" -#include "film.h" #include "audio_buffers.h" +#include "audio_content.h" +#include "audio_decoder.h" +#include "audio_processor.h" +#include "compose.hpp" +#include "config.h" #include "content_audio.h" +#include "content_video.h" #include "dcp_content.h" +#include "dcp_decoder.h" #include "dcpomatic_log.h" -#include "job.h" +#include "decoder.h" +#include "decoder_factory.h" +#include "ffmpeg_content.h" +#include "film.h" +#include "frame_rate_change.h" #include "image.h" -#include "raw_image_proxy.h" -#include "ratio.h" +#include "image_decoder.h" +#include "job.h" #include "log.h" -#include "render_text.h" -#include "config.h" -#include "content_video.h" +#include "piece.h" +#include "player.h" #include "player_video.h" -#include "frame_rate_change.h" -#include "audio_processor.h" #include "playlist.h" +#include "ratio.h" +#include "raw_image_proxy.h" #include "referenced_reel_asset.h" -#include "decoder_factory.h" -#include "decoder.h" -#include "video_decoder.h" -#include "audio_decoder.h" +#include "render_text.h" +#include "shuffler.h" #include "text_content.h" #include "text_decoder.h" -#include "ffmpeg_content.h" -#include "audio_content.h" -#include "dcp_decoder.h" -#include "image_decoder.h" -#include "compose.hpp" -#include "shuffler.h" #include "timer.h" +#include "video_decoder.h" #include <dcp/reel.h> +#include <dcp/reel_closed_caption_asset.h> +#include <dcp/reel_picture_asset.h> #include <dcp/reel_sound_asset.h> #include <dcp/reel_subtitle_asset.h> -#include <dcp/reel_picture_asset.h> -#include <dcp/reel_closed_caption_asset.h> -#include <stdint.h> #include <algorithm> #include <iostream> +#include <stdint.h> #include "i18n.h" @@ -70,6 +71,7 @@ using std::dynamic_pointer_cast; using std::list; using std::make_pair; using std::make_shared; +using std::make_shared; using std::max; using std::min; using std::min; @@ -77,7 +79,6 @@ using std::pair; using std::shared_ptr; using std::vector; using std::weak_ptr; -using std::make_shared; using boost::optional; using boost::scoped_ptr; #if BOOST_VERSION >= 106100 diff --git a/src/lib/player.h b/src/lib/player.h index 14fb8d0ee..0d0116e92 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -27,7 +27,6 @@ #include "atmos_metadata.h" #include "audio_merger.h" #include "audio_stream.h" -#include "content.h" #include "content_atmos.h" #include "content_audio.h" #include "content_text.h" @@ -35,7 +34,6 @@ #include "empty.h" #include "film.h" #include "image.h" -#include "piece.h" #include "player_text.h" #include "position_image.h" #include "shuffler.h" @@ -52,11 +50,12 @@ namespace dcpomatic { } class AtmosContent; +class AudioBuffers; +class Content; +class Piece; class PlayerVideo; class Playlist; -class AudioBuffers; class ReferencedReelAsset; -class Shuffler; class PlayerProperty diff --git a/src/lib/player_text.cc b/src/lib/player_text.cc index a3b7ec89f..626f8fac3 100644 --- a/src/lib/player_text.cc +++ b/src/lib/player_text.cc @@ -19,8 +19,8 @@ */ -#include "player_text.h" #include "font.h" +#include "player_text.h" using std::list; diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 2f0616d48..7372dd2de 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -77,6 +77,7 @@ PlayerVideo::PlayerVideo ( } + PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket) { _crop = Crop (node); @@ -106,12 +107,14 @@ PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket } } + void PlayerVideo::set_text (PositionImage image) { _text = image; } + shared_ptr<Image> PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const { @@ -194,6 +197,7 @@ PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, V } } + void PlayerVideo::add_metadata (xmlpp::Node* node) const { @@ -221,6 +225,7 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const } } + void PlayerVideo::write_to_socket (shared_ptr<Socket> socket) const { @@ -230,6 +235,7 @@ PlayerVideo::write_to_socket (shared_ptr<Socket> socket) const } } + bool PlayerVideo::has_j2k () const { @@ -243,6 +249,7 @@ PlayerVideo::has_j2k () const return _crop == Crop() && _out_size == j2k->size() && _inter_size == j2k->size() && !_text && !_fade && !_colour_conversion; } + shared_ptr<const dcp::Data> PlayerVideo::j2k () const { @@ -251,12 +258,14 @@ PlayerVideo::j2k () const return j2k->j2k (); } + Position<int> PlayerVideo::inter_position () const { return Position<int> ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.height) / 2); } + /** @return true if this PlayerVideo is definitely the same as another, false if it is probably not */ bool PlayerVideo::same (shared_ptr<const PlayerVideo> other) const @@ -287,18 +296,21 @@ PlayerVideo::same (shared_ptr<const PlayerVideo> other) const return _in->same (other->_in); } + AVPixelFormat PlayerVideo::force (AVPixelFormat force_to) { return force_to; } + AVPixelFormat PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p) { return p == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE; } + void PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only) { @@ -309,12 +321,14 @@ PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, Vide } } + size_t PlayerVideo::memory_used () const { return _in->memory_used(); } + /** @return Shallow copy of this; _in and _text are shared between the original and the copy */ shared_ptr<PlayerVideo> PlayerVideo::shallow_copy () const @@ -335,6 +349,7 @@ PlayerVideo::shallow_copy () const ); } + /** Re-read crop, fade, inter/out size, colour conversion and video range from our content. * @return true if this was possible, false if not. */ diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index e8714e9d6..c18a43882 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -19,20 +19,20 @@ */ -#include "playlist.h" -#include "video_content.h" -#include "text_content.h" -#include "ffmpeg_decoder.h" -#include "ffmpeg_content.h" -#include "image_decoder.h" #include "audio_content.h" +#include "compose.hpp" +#include "config.h" #include "content_factory.h" #include "dcp_content.h" +#include "digester.h" +#include "ffmpeg_content.h" +#include "ffmpeg_decoder.h" +#include "image_decoder.h" #include "job.h" -#include "config.h" +#include "playlist.h" +#include "text_content.h" #include "util.h" -#include "digester.h" -#include "compose.hpp" +#include "video_content.h" #include <libcxml/cxml.h> #include <libxml++/libxml++.h> #include <boost/bind/placeholders.hpp> @@ -41,17 +41,17 @@ #include "i18n.h" -using std::list; using std::cout; -using std::vector; -using std::min; +using std::dynamic_pointer_cast; +using std::list; using std::max; -using std::string; +using std::min; using std::pair; -using boost::optional; using std::shared_ptr; +using std::string; +using std::vector; using std::weak_ptr; -using std::dynamic_pointer_cast; +using boost::optional; using namespace dcpomatic; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; diff --git a/src/lib/position_image.cc b/src/lib/position_image.cc index 9ba2e9c3f..392d96d7e 100644 --- a/src/lib/position_image.cc +++ b/src/lib/position_image.cc @@ -19,8 +19,8 @@ */ -#include "position_image.h" #include "image.h" +#include "position_image.h" bool diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 5f1a3aa63..2646d7225 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -19,9 +19,9 @@ */ +#include "config.h" #include "ratio.h" #include "util.h" -#include "config.h" #include <dcp/types.h> #include <cfloat> @@ -123,6 +123,7 @@ Ratio::nearest_from_ratio (float r) return &(*nearest); } + vector<Ratio const *> Ratio::containers () { @@ -130,10 +131,10 @@ Ratio::containers () return all(); } - vector<Ratio const *> r; - r.push_back (Ratio::from_id ("185")); - r.push_back (Ratio::from_id ("239")); - return r; + return { + Ratio::from_id ("185"), + Ratio::from_id ("239") + }; } diff --git a/src/lib/raw_image_proxy.cc b/src/lib/raw_image_proxy.cc index fb0d16df8..d6980dc93 100644 --- a/src/lib/raw_image_proxy.cc +++ b/src/lib/raw_image_proxy.cc @@ -19,8 +19,8 @@ */ -#include "raw_image_proxy.h" #include "image.h" +#include "raw_image_proxy.h" #include "warnings.h" #include <dcp/raw_convert.h> #include <dcp/util.h> diff --git a/src/lib/reel_writer.cc b/src/lib/reel_writer.cc index 2830ca3f0..3d60370ff 100644 --- a/src/lib/reel_writer.cc +++ b/src/lib/reel_writer.cc @@ -100,6 +100,7 @@ mxf_metadata () return meta; } + /** @param job Related job, or 0. * @param text_only true to enable a special mode where the writer will expect only subtitles and closed captions to be written * (no picture nor sound) and not give errors in that case. This is used by the hints system to check the potential sizes of @@ -202,6 +203,7 @@ ReelWriter::ReelWriter ( _default_font = dcp::ArrayData(default_font_file()); } + /** @param frame reel-relative frame */ void ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const @@ -213,6 +215,7 @@ ReelWriter::write_frame_info (Frame frame, Eyes eyes, dcp::FrameInfo info) const checked_fwrite (info.hash.c_str(), info.hash.size(), handle->get(), handle->file()); } + dcp::FrameInfo ReelWriter::read_frame_info (shared_ptr<InfoFileHandle> info, Frame frame, Eyes eyes) const { @@ -229,6 +232,7 @@ ReelWriter::read_frame_info (shared_ptr<InfoFileHandle> info, Frame frame, Eyes return frame_info; } + long ReelWriter::frame_info_position (Frame frame, Eyes eyes) const { @@ -246,6 +250,7 @@ ReelWriter::frame_info_position (Frame frame, Eyes eyes) const DCPOMATIC_ASSERT (false); } + Frame ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) { @@ -304,6 +309,7 @@ ReelWriter::check_existing_picture_asset (boost::filesystem::path asset) return first_nonexistant_frame; } + void ReelWriter::write (shared_ptr<const Data> encoded, Frame frame, Eyes eyes) { @@ -345,6 +351,7 @@ ReelWriter::fake_write (int size) _picture_asset_writer->fake_write (size); } + void ReelWriter::repeat_write (Frame frame, Eyes eyes) { @@ -360,6 +367,7 @@ ReelWriter::repeat_write (Frame frame, Eyes eyes) write_frame_info (frame, eyes, fin); } + void ReelWriter::finish (boost::filesystem::path output_dcp) { @@ -751,6 +759,7 @@ ReelWriter::create_reel ( return reel; } + void ReelWriter::calculate_digests (std::function<void (float)> set_progress) try @@ -772,6 +781,7 @@ try */ } + Frame ReelWriter::start () const { @@ -911,6 +921,7 @@ ReelWriter::write (PlayerText subs, TextType type, optional<DCPTextTrack> track, } } + bool ReelWriter::existing_picture_frame_ok (FILE* asset_file, shared_ptr<InfoFileHandle> info_file, Frame frame) const { diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index 056b2e1ee..1918b9a55 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -19,11 +19,11 @@ */ -#include "resampler.h" #include "audio_buffers.h" -#include "exceptions.h" #include "compose.hpp" #include "dcpomatic_assert.h" +#include "exceptions.h" +#include "resampler.h" #include <samplerate.h> #include <iostream> #include <cmath> diff --git a/src/lib/rng.cc b/src/lib/rng.cc index 4d82cf721..42af8a768 100644 --- a/src/lib/rng.cc +++ b/src/lib/rng.cc @@ -33,7 +33,8 @@ RNG::RNG (int32_t seed) } -int32_t RNG::get () +int32_t +RNG::get () { uint32_t const b = ((_state >> 0) ^ (_state >> 1) ^ (_state >> 2) ^ (_state >> 7)); _state = (_state >> 1) | (b << 23); diff --git a/src/lib/scoped_temporary.cc b/src/lib/scoped_temporary.cc index 223100ba5..4ba69f53b 100644 --- a/src/lib/scoped_temporary.cc +++ b/src/lib/scoped_temporary.cc @@ -19,9 +19,9 @@ */ -#include "scoped_temporary.h" -#include "exceptions.h" #include "cross.h" +#include "exceptions.h" +#include "scoped_temporary.h" /** Construct a ScopedTemporary. A temporary filename is decided but the file is not opened diff --git a/src/lib/scp_uploader.cc b/src/lib/scp_uploader.cc index 9c349f233..0223b29e0 100644 --- a/src/lib/scp_uploader.cc +++ b/src/lib/scp_uploader.cc @@ -19,12 +19,12 @@ */ -#include "scp_uploader.h" -#include "exceptions.h" -#include "job.h" +#include "compose.hpp" #include "config.h" #include "cross.h" -#include "compose.hpp" +#include "exceptions.h" +#include "job.h" +#include "scp_uploader.h" #include "warnings.h" #include <sys/stat.h> diff --git a/src/lib/screen.cc b/src/lib/screen.cc index 504504c8c..6f9e53b45 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -19,10 +19,10 @@ */ -#include "screen.h" -#include "kdm_with_metadata.h" -#include "film.h" #include "cinema.h" +#include "film.h" +#include "kdm_with_metadata.h" +#include "screen.h" #include <libxml++/libxml++.h> #include <boost/algorithm/string.hpp> #include <boost/date_time/posix_time/posix_time.hpp> diff --git a/src/lib/send_notification_email_job.cc b/src/lib/send_notification_email_job.cc index c4d5a6518..1c21aa9ef 100644 --- a/src/lib/send_notification_email_job.cc +++ b/src/lib/send_notification_email_job.cc @@ -19,11 +19,11 @@ */ -#include "send_notification_email_job.h" -#include "exceptions.h" +#include "compose.hpp" #include "config.h" #include "emailer.h" -#include "compose.hpp" +#include "exceptions.h" +#include "send_notification_email_job.h" #include <list> #include "i18n.h" diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index 6fbb73430..df51a3e69 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -19,15 +19,15 @@ */ -#include "send_problem_report_job.h" #include "compose.hpp" -#include "film.h" #include "cross.h" +#include "emailer.h" +#include "environment_info.h" +#include "film.h" #include "film.h" #include "log.h" +#include "send_problem_report_job.h" #include "version.h" -#include "emailer.h" -#include "environment_info.h" #include <libxml++/libxml++.h> #include "i18n.h" diff --git a/src/lib/server.cc b/src/lib/server.cc index c1be5735e..7529e3c16 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -19,8 +19,8 @@ */ -#include "server.h" #include "dcpomatic_socket.h" +#include "server.h" #include "i18n.h" diff --git a/src/lib/shuffler.cc b/src/lib/shuffler.cc index 5a4faf4d1..f6a3bdc7a 100644 --- a/src/lib/shuffler.cc +++ b/src/lib/shuffler.cc @@ -19,10 +19,10 @@ */ -#include "shuffler.h" #include "content_video.h" #include "dcpomatic_assert.h" #include "dcpomatic_log.h" +#include "shuffler.h" #include <string> #include <iostream> diff --git a/src/lib/spl.cc b/src/lib/spl.cc index 8d0dcc6fc..aec945c8b 100644 --- a/src/lib/spl.cc +++ b/src/lib/spl.cc @@ -30,10 +30,10 @@ DCPOMATIC_ENABLE_WARNINGS #include <iostream> +using dcp::raw_convert; using std::cout; -using std::string; using std::shared_ptr; -using dcp::raw_convert; +using std::string; void diff --git a/src/lib/spl_entry.cc b/src/lib/spl_entry.cc index 878bd610f..bbc36969f 100644 --- a/src/lib/spl_entry.cc +++ b/src/lib/spl_entry.cc @@ -28,8 +28,8 @@ DCPOMATIC_DISABLE_WARNINGS DCPOMATIC_ENABLE_WARNINGS -using std::shared_ptr; using std::dynamic_pointer_cast; +using std::shared_ptr; SPLEntry::SPLEntry (shared_ptr<Content> c) diff --git a/src/lib/state.cc b/src/lib/state.cc index e22f9e0b9..b4d457158 100644 --- a/src/lib/state.cc +++ b/src/lib/state.cc @@ -79,7 +79,7 @@ State::read_path (string file) boost::filesystem::path State::write_path (string file) { - boost::filesystem::path p = config_path_or_override(config_versions.front()); + auto p = config_path_or_override(config_versions.front()); boost::system::error_code ec; boost::filesystem::create_directories (p, ec); p /= file; diff --git a/src/lib/stdout_log.cc b/src/lib/stdout_log.cc index 50278906f..a09bd2e08 100644 --- a/src/lib/stdout_log.cc +++ b/src/lib/stdout_log.cc @@ -19,14 +19,14 @@ */ -#include "stdout_log.h" #include "config.h" +#include "stdout_log.h" #include <iostream> using std::cout; -using std::string; using std::shared_ptr; +using std::string; StdoutLog::StdoutLog () diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc index 8c2c56518..919693dd8 100644 --- a/src/lib/string_text_file.cc +++ b/src/lib/string_text_file.cc @@ -18,29 +18,32 @@ */ -#include "string_text_file.h" + #include "cross.h" #include "exceptions.h" +#include "string_text_file.h" #include "string_text_file_content.h" -#include <sub/subrip_reader.h> +#include <sub/collect.h> #include <sub/ssa_reader.h> #include <sub/stl_binary_reader.h> -#include <sub/collect.h> -#include <unicode/ucsdet.h> +#include <sub/subrip_reader.h> #include <unicode/ucnv.h> +#include <unicode/ucsdet.h> #include <iostream> #include "i18n.h" -using std::vector; + using std::cout; -using std::string; using std::shared_ptr; -using boost::scoped_array; +using std::string; +using std::vector; using boost::optional; +using boost::scoped_array; using dcp::ArrayData; using namespace dcpomatic; + StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content) { string ext = content->path(0).extension().string(); @@ -111,22 +114,24 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content) } } + /** @return time of first subtitle, if there is one */ optional<ContentTime> StringTextFile::first () const { if (_subtitles.empty()) { - return optional<ContentTime>(); + return {}; } return ContentTime::from_seconds(_subtitles[0].from.all_as_seconds()); } + ContentTime StringTextFile::length () const { if (_subtitles.empty ()) { - return ContentTime (); + return {}; } return ContentTime::from_seconds (_subtitles.back().to.all_as_seconds ()); diff --git a/src/lib/string_text_file_content.cc b/src/lib/string_text_file_content.cc index 2ce343f2e..da31dfc1c 100644 --- a/src/lib/string_text_file_content.cc +++ b/src/lib/string_text_file_content.cc @@ -19,12 +19,12 @@ */ -#include "string_text_file_content.h" -#include "util.h" -#include "string_text_file.h" #include "film.h" #include "font.h" +#include "string_text_file.h" +#include "string_text_file_content.h" #include "text_content.h" +#include "util.h" #include <dcp/raw_convert.h> #include <libxml++/libxml++.h> #include <iostream> diff --git a/src/lib/string_text_file_decoder.cc b/src/lib/string_text_file_decoder.cc index d366bedc0..68394b948 100644 --- a/src/lib/string_text_file_decoder.cc +++ b/src/lib/string_text_file_decoder.cc @@ -19,8 +19,8 @@ */ -#include "string_text_file_decoder.h" #include "string_text_file_content.h" +#include "string_text_file_decoder.h" #include "text_content.h" #include "text_decoder.h" #include <dcp/subtitle_string.h> diff --git a/src/lib/subtitle_analysis.cc b/src/lib/subtitle_analysis.cc index 0838816b0..632fa99af 100644 --- a/src/lib/subtitle_analysis.cc +++ b/src/lib/subtitle_analysis.cc @@ -19,8 +19,8 @@ */ -#include "subtitle_analysis.h" #include "exceptions.h" +#include "subtitle_analysis.h" #include "warnings.h" #include <libcxml/cxml.h> #include <dcp/raw_convert.h> @@ -49,7 +49,7 @@ SubtitleAnalysis::SubtitleAnalysis (boost::filesystem::path path) throw OldFormatError ("Subtitle analysis file is too old"); } - cxml::NodePtr bounding_box = f.optional_node_child("BoundingBox"); + auto bounding_box = f.optional_node_child("BoundingBox"); if (bounding_box) { _bounding_box = dcpomatic::Rect<double> (); _bounding_box->x = bounding_box->number_child<double>("X"); @@ -67,7 +67,7 @@ void SubtitleAnalysis::write (boost::filesystem::path path) const { auto doc = make_shared<xmlpp::Document>(); - xmlpp::Element* root = doc->create_root_node ("SubtitleAnalysis"); + auto root = doc->create_root_node ("SubtitleAnalysis"); root->add_child("Version")->add_child_text (raw_convert<string>(_current_state_version)); diff --git a/src/lib/text_content.cc b/src/lib/text_content.cc index 1e9c609c9..2584b5caa 100644 --- a/src/lib/text_content.cc +++ b/src/lib/text_content.cc @@ -32,13 +32,13 @@ #include "i18n.h" -using std::string; -using std::vector; using std::cout; +using std::dynamic_pointer_cast; using std::list; -using std::shared_ptr; using std::make_shared; -using std::dynamic_pointer_cast; +using std::shared_ptr; +using std::string; +using std::vector; using boost::optional; using dcp::raw_convert; using namespace dcpomatic; @@ -80,6 +80,7 @@ TextContent::TextContent (Content* parent, TextType type, TextType original_type } + /** @return TextContents from node or <Text> nodes under node (according to version). * The list could be empty if no TextContents are found. */ @@ -112,6 +113,7 @@ TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version, li return c; } + TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version, list<string>& notes) : ContentPart (parent) , _use (false) @@ -255,6 +257,7 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version, } } + TextContent::TextContent (Content* parent, vector<shared_ptr<Content>> c) : ContentPart (parent) { @@ -352,6 +355,7 @@ TextContent::TextContent (Content* parent, vector<shared_ptr<Content>> c) connect_to_fonts (); } + /** _mutex must not be held on entry */ void TextContent::as_xml (xmlpp::Node* root) const @@ -414,6 +418,7 @@ TextContent::as_xml (xmlpp::Node* root) const } } + string TextContent::identifier () const { @@ -442,6 +447,7 @@ TextContent::identifier () const return s; } + void TextContent::add_font (shared_ptr<Font> font) { @@ -449,6 +455,7 @@ TextContent::add_font (shared_ptr<Font> font) connect_to_fonts (); } + void TextContent::connect_to_fonts () { @@ -463,6 +470,7 @@ TextContent::connect_to_fonts () } } + void TextContent::font_changed () { @@ -470,144 +478,168 @@ TextContent::font_changed () ContentChangeSignaller cc (_parent, TextContentProperty::FONTS); } + void TextContent::set_colour (dcp::Colour colour) { maybe_set (_colour, colour, TextContentProperty::COLOUR); } + void TextContent::unset_colour () { maybe_set (_colour, optional<dcp::Colour>(), TextContentProperty::COLOUR); } + void TextContent::set_effect (dcp::Effect e) { maybe_set (_effect, e, TextContentProperty::EFFECT); } + void TextContent::unset_effect () { maybe_set (_effect, optional<dcp::Effect>(), TextContentProperty::EFFECT); } + void TextContent::set_effect_colour (dcp::Colour colour) { maybe_set (_effect_colour, colour, TextContentProperty::EFFECT_COLOUR); } + void TextContent::unset_effect_colour () { maybe_set (_effect_colour, optional<dcp::Colour>(), TextContentProperty::EFFECT_COLOUR); } + void TextContent::set_use (bool u) { maybe_set (_use, u, TextContentProperty::USE); } + void TextContent::set_burn (bool b) { maybe_set (_burn, b, TextContentProperty::BURN); } + void TextContent::set_x_offset (double o) { maybe_set (_x_offset, o, TextContentProperty::X_OFFSET); } + void TextContent::set_y_offset (double o) { maybe_set (_y_offset, o, TextContentProperty::Y_OFFSET); } + void TextContent::set_x_scale (double s) { maybe_set (_x_scale, s, TextContentProperty::X_SCALE); } + void TextContent::set_y_scale (double s) { maybe_set (_y_scale, s, TextContentProperty::Y_SCALE); } + void TextContent::set_line_spacing (double s) { maybe_set (_line_spacing, s, TextContentProperty::LINE_SPACING); } + void TextContent::set_fade_in (ContentTime t) { maybe_set (_fade_in, t, TextContentProperty::FADE_IN); } + void TextContent::unset_fade_in () { maybe_set (_fade_in, optional<ContentTime>(), TextContentProperty::FADE_IN); } + void TextContent::set_fade_out (ContentTime t) { maybe_set (_fade_out, t, TextContentProperty::FADE_OUT); } + void TextContent::unset_fade_out () { maybe_set (_fade_out, optional<ContentTime>(), TextContentProperty::FADE_OUT); } + void TextContent::set_type (TextType type) { maybe_set (_type, type, TextContentProperty::TYPE); } + void TextContent::set_outline_width (int w) { maybe_set (_outline_width, w, TextContentProperty::OUTLINE_WIDTH); } + void TextContent::set_dcp_track (DCPTextTrack t) { maybe_set (_dcp_track, t, TextContentProperty::DCP_TRACK); } + void TextContent::unset_dcp_track () { maybe_set (_dcp_track, optional<DCPTextTrack>(), TextContentProperty::DCP_TRACK); } + void TextContent::set_language (optional<dcp::LanguageTag> language) { maybe_set (_language, language, TextContentProperty::LANGUAGE); } + void TextContent::set_language_is_additional (bool additional) { maybe_set (_language_is_additional, additional, TextContentProperty::LANGUAGE_IS_ADDITIONAL); } + void TextContent::take_settings_from (shared_ptr<const TextContent> c) { diff --git a/src/lib/text_decoder.cc b/src/lib/text_decoder.cc index 99b68faba..512b6fc7b 100644 --- a/src/lib/text_decoder.cc +++ b/src/lib/text_decoder.cc @@ -19,22 +19,22 @@ */ -#include "text_decoder.h" +#include "compose.hpp" +#include "log.h" #include "text_content.h" +#include "text_decoder.h" #include "util.h" -#include "log.h" -#include "compose.hpp" #include <sub/subtitle.h> #include <boost/algorithm/string.hpp> #include <iostream> -using std::list; using std::cout; -using std::string; -using std::min; +using std::list; using std::max; +using std::min; using std::shared_ptr; +using std::string; using boost::optional; using namespace dcpomatic; diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index f5ddf1754..e16917224 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -26,8 +26,8 @@ #include "analytics.h" #include "compose.hpp" -#include "content.h" #include "config.h" +#include "content.h" #include "dcp_encoder.h" #include "dcpomatic_log.h" #include "encoder.h" @@ -44,13 +44,13 @@ using std::cout; +using std::dynamic_pointer_cast; using std::fixed; using std::make_shared; using std::setprecision; using std::shared_ptr; using std::string; using boost::optional; -using std::dynamic_pointer_cast; /** @param film Film to use */ diff --git a/src/lib/types.cc b/src/lib/types.cc index 228ebf28f..f08dd63b1 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -18,15 +18,16 @@ */ -#include "types.h" + #include "compose.hpp" #include "dcpomatic_assert.h" +#include "types.h" #include "warnings.h" -#include <dcp/raw_convert.h> #include <dcp/cpl.h> #include <dcp/dcp.h> -#include <dcp/reel_file_asset.h> +#include <dcp/raw_convert.h> #include <dcp/reel_asset.h> +#include <dcp/reel_file_asset.h> DCPOMATIC_DISABLE_WARNINGS #include <libxml++/libxml++.h> DCPOMATIC_ENABLE_WARNINGS @@ -34,6 +35,7 @@ DCPOMATIC_ENABLE_WARNINGS #include "i18n.h" + using std::max; using std::min; using std::string; @@ -42,16 +44,19 @@ using std::shared_ptr; using std::vector; using dcp::raw_convert; + bool operator== (Crop const & a, Crop const & b) { return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom); } + bool operator!= (Crop const & a, Crop const & b) { return !(a == b); } + /** @param r Resolution. * @return Untranslated string representation. */ @@ -85,6 +90,7 @@ string_to_resolution (string s) return Resolution::TWO_K; } + Crop::Crop (shared_ptr<cxml::Node> node) { left = node->number_child<int> ("LeftCrop"); @@ -93,6 +99,7 @@ Crop::Crop (shared_ptr<cxml::Node> node) bottom = node->number_child<int> ("BottomCrop"); } + void Crop::as_xml (xmlpp::Node* node) const { @@ -102,6 +109,7 @@ Crop::as_xml (xmlpp::Node* node) const node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom)); } + TextType string_to_text_type (string s) { @@ -116,6 +124,7 @@ string_to_text_type (string s) } } + string text_type_to_string (TextType t) { @@ -131,6 +140,7 @@ text_type_to_string (TextType t) } } + string text_type_to_name (TextType t) { @@ -146,6 +156,7 @@ text_type_to_name (TextType t) } } + string video_frame_type_to_string (VideoFrameType t) { @@ -171,6 +182,7 @@ video_frame_type_to_string (VideoFrameType t) DCPOMATIC_ASSERT (false); } + VideoFrameType string_to_video_frame_type (string s) { @@ -193,6 +205,7 @@ string_to_video_frame_type (string s) DCPOMATIC_ASSERT (false); } + CPLSummary::CPLSummary (boost::filesystem::path p) : dcp_directory (p.leaf().string()) { diff --git a/src/lib/update_checker.cc b/src/lib/update_checker.cc index 2c2e23be1..541ce4bfc 100644 --- a/src/lib/update_checker.cc +++ b/src/lib/update_checker.cc @@ -20,8 +20,8 @@ #include "update_checker.h" -#include "version.h" #include "util.h" +#include "version.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include <curl/curl.h> diff --git a/src/lib/uploader.cc b/src/lib/uploader.cc index c5448e469..ccf8b7feb 100644 --- a/src/lib/uploader.cc +++ b/src/lib/uploader.cc @@ -19,16 +19,16 @@ */ -#include "uploader.h" -#include "dcpomatic_assert.h" #include "compose.hpp" +#include "dcpomatic_assert.h" +#include "uploader.h" #include "i18n.h" -using std::string; -using std::shared_ptr; using std::function; +using std::shared_ptr; +using std::string; Uploader::Uploader (function<void (string)> set_status, function<void (float)> set_progress) diff --git a/src/lib/upmixer_a.cc b/src/lib/upmixer_a.cc index f402b6691..214933baa 100644 --- a/src/lib/upmixer_a.cc +++ b/src/lib/upmixer_a.cc @@ -19,9 +19,9 @@ */ -#include "upmixer_a.h" #include "audio_buffers.h" #include "audio_mapping.h" +#include "upmixer_a.h" #include "i18n.h" @@ -86,13 +86,14 @@ UpmixerA::run (shared_ptr<const AudioBuffers> in, int channels) in_LR->apply_gain (-6); /* Run filters */ - vector<shared_ptr<AudioBuffers>> all_out; - all_out.push_back (_left.run(in_L)); - all_out.push_back (_right.run(in_R)); - all_out.push_back (_centre.run(in_LR)); - all_out.push_back (_lfe.run(in_LR)); - all_out.push_back (_ls.run(in_L)); - all_out.push_back (_rs.run(in_R)); + vector<shared_ptr<AudioBuffers>> all_out = { + _left.run(in_L), + _right.run(in_R), + _centre.run(in_LR), + _lfe.run(in_LR), + _ls.run(in_L), + _rs.run(in_R) + }; auto out = make_shared<AudioBuffers>(channels, in->frames()); int const N = min (channels, 6); diff --git a/src/lib/util.cc b/src/lib/util.cc index 64fdd6a37..106a56541 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -112,14 +112,14 @@ using std::shared_ptr; using std::string; using std::vector; using std::wstring; -using boost::thread; -using boost::optional; -using boost::lexical_cast; 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; @@ -131,6 +131,7 @@ bool is_batch_converter = false; 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. * @@ -151,6 +152,7 @@ seconds_to_hms (int s) return buffer; } + string time_to_hmsf (DCPTime time, Frame rate) { @@ -167,6 +169,7 @@ 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") */ @@ -225,12 +228,14 @@ seconds_to_approximate_hms (int s) 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 */ @@ -242,6 +247,7 @@ addr2line (void const * const addr) 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. @@ -302,12 +308,14 @@ exception_handler(struct _EXCEPTION_POINTERS * info) 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 @@ -336,6 +344,7 @@ terminate () abort(); } + void dcpomatic_setup_path_encoding () { @@ -357,6 +366,7 @@ 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. */ @@ -424,6 +434,7 @@ DCPOMATIC_ENABLE_WARNINGS ui_thread = boost::this_thread::get_id (); } + #ifdef DCPOMATIC_WINDOWS boost::filesystem::path mo_path () @@ -438,6 +449,7 @@ mo_path () } #endif + #ifdef DCPOMATIC_OSX boost::filesystem::path mo_path () @@ -446,6 +458,7 @@ mo_path () } #endif + void dcpomatic_setup_gettext_i18n (string lang) { @@ -478,6 +491,7 @@ 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) @@ -550,6 +564,7 @@ stride_round_up (int c, int const * stride, int t) return a - (a % t); } + /** Trip an assert if the caller is not in the UI thread */ void ensure_ui_thread () @@ -557,6 +572,7 @@ ensure_ui_thread () DCPOMATIC_ASSERT (boost::this_thread::get_id() == ui_thread); } + string audio_channel_name (int c) { @@ -586,6 +602,7 @@ audio_channel_name (int c) return channels[c]; } + string short_audio_channel_name (int c) { @@ -635,6 +652,7 @@ valid_image_file (boost::filesystem::path f) ); } + bool valid_sound_file (boost::filesystem::path f) { @@ -647,6 +665,7 @@ valid_sound_file (boost::filesystem::path f) return (ext == ".wav" || ext == ".mp3" || ext == ".aif" || ext == ".aiff"); } + bool valid_j2k_file (boost::filesystem::path f) { @@ -655,6 +674,7 @@ valid_j2k_file (boost::filesystem::path f) return (ext == ".j2k" || ext == ".j2c" || ext == ".jp2"); } + string tidy_for_filename (string f) { @@ -662,6 +682,7 @@ tidy_for_filename (string f) return f; } + dcp::Size fit_ratio_within (float ratio, dcp::Size full_frame) { @@ -672,6 +693,7 @@ 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) { @@ -682,6 +704,7 @@ wrapped_av_malloc (size_t s) return p; } + map<string, string> split_get_request (string url) { @@ -728,6 +751,7 @@ 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) { @@ -741,6 +765,7 @@ video_asset_filename (shared_ptr<dcp::PictureAsset> asset, int reel_index, int r 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) { @@ -811,6 +836,7 @@ careful_string_filter (string s) 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. @@ -853,6 +879,7 @@ audio_channel_types (list<int> mapped, int channels) return make_pair (non_lfe, lfe); } + shared_ptr<AudioBuffers> remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping map) { @@ -877,6 +904,7 @@ remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping m return mapped; } + Eyes increment_eyes (Eyes e) { @@ -887,6 +915,7 @@ increment_eyes (Eyes e) return Eyes::LEFT; } + void checked_fwrite (void const * ptr, size_t size, FILE* stream, boost::filesystem::path path) { @@ -902,6 +931,7 @@ checked_fwrite (void const * ptr, size_t size, FILE* stream, boost::filesystem:: } } + void checked_fread (void* ptr, size_t size, FILE* stream, boost::filesystem::path path) { @@ -917,6 +947,7 @@ checked_fread (void* ptr, size_t size, FILE* stream, boost::filesystem::path pat } } + size_t utf8_strlen (string s) { @@ -936,6 +967,7 @@ utf8_strlen (string s) return N; } + string day_of_week_to_string (boost::gregorian::greg_weekday d) { @@ -959,6 +991,7 @@ 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) @@ -998,6 +1031,7 @@ emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size decoder->emit_bitmap (period, image, rect); } + bool show_jobs_on_console (bool progress) { @@ -1053,6 +1087,7 @@ show_jobs_on_console (bool progress) return error; } + /** XXX: could use mmap? */ void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::function<void (float)> progress) @@ -1105,12 +1140,14 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, std::fun free (buffer); } + double db_to_linear (double db) { return pow(10, db / 20); } + double linear_to_db (double linear) { diff --git a/src/lib/util.h b/src/lib/util.h index 1296dc789..0f3351dbf 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -34,13 +34,13 @@ #include "types.h" #include <dcp/atmos_asset.h> #include <dcp/decrypted_kdm.h> -#include <dcp/util.h> #include <dcp/subtitle_image.h> -#include <boost/optional.hpp> -#include <boost/filesystem.hpp> +#include <dcp/util.h> #include <boost/date_time/gregorian/gregorian.hpp> -#include <string> +#include <boost/filesystem.hpp> +#include <boost/optional.hpp> #include <map> +#include <string> #include <vector> #undef check @@ -130,29 +130,6 @@ extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); extern std::string to_upper (std::string s); extern void start_of_thread (std::string name); - -template <class T> -std::list<T> -vector_to_list (std::vector<T> v) -{ - std::list<T> l; - for (auto& i: v) { - l.push_back (i); - } - return l; -} - -template <class T> -std::vector<T> -list_to_vector (std::list<T> v) -{ - std::vector<T> l; - for (auto& i: v) { - l.push_back (i); - } - return l; -} - extern double db_to_linear (double db); extern double linear_to_db (double linear); diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index c6574fce3..27eb04fe0 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -18,19 +18,20 @@ */ -#include "video_content.h" -#include "content.h" -#include "video_examiner.h" + +#include "colour_conversion.h" #include "compose.hpp" -#include "ratio.h" #include "config.h" -#include "colour_conversion.h" -#include "util.h" -#include "film.h" +#include "content.h" +#include "dcpomatic_log.h" #include "exceptions.h" +#include "film.h" #include "frame_rate_change.h" #include "log.h" -#include "dcpomatic_log.h" +#include "ratio.h" +#include "util.h" +#include "video_content.h" +#include "video_examiner.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include <libxml++/libxml++.h> @@ -39,6 +40,7 @@ #include "i18n.h" + int const VideoContentProperty::USE = 0; int const VideoContentProperty::SIZE = 1; int const VideoContentProperty::FRAME_TYPE = 2; @@ -51,23 +53,25 @@ int const VideoContentProperty::CUSTOM_RATIO = 8; int const VideoContentProperty::CUSTOM_SIZE = 9; int const VideoContentProperty::BURNT_SUBTITLE_LANGUAGE = 10; -using std::string; -using std::setprecision; + using std::cout; -using std::vector; -using std::min; -using std::max; +using std::dynamic_pointer_cast; using std::fixed; -using std::setprecision; using std::list; +using std::make_shared; +using std::max; +using std::min; using std::pair; +using std::setprecision; +using std::setprecision; using std::shared_ptr; -using std::make_shared; +using std::string; +using std::vector; using boost::optional; -using std::dynamic_pointer_cast; using dcp::raw_convert; using namespace dcpomatic; + VideoContent::VideoContent (Content* parent) : ContentPart (parent) , _use (true) @@ -81,6 +85,7 @@ VideoContent::VideoContent (Content* parent) } + shared_ptr<VideoContent> VideoContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) { @@ -91,6 +96,7 @@ VideoContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version) return make_shared<VideoContent>(parent, node, version); } + VideoContent::VideoContent (Content* parent, cxml::ConstNodePtr node, int version) : ContentPart (parent) { @@ -297,6 +303,7 @@ VideoContent::as_xml (xmlpp::Node* node) const } } + void VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d) { @@ -329,6 +336,7 @@ VideoContent::take_from_examiner (shared_ptr<VideoExaminer> d) } } + /** @return string which includes everything about how this content looks */ string VideoContent::identifier () const @@ -359,6 +367,7 @@ VideoContent::identifier () const return s; } + string VideoContent::technical_summary () const { @@ -376,6 +385,7 @@ VideoContent::technical_summary () const return s; } + dcp::Size VideoContent::size_after_3d_split () const { @@ -396,6 +406,7 @@ VideoContent::size_after_3d_split () const DCPOMATIC_ASSERT (false); } + /** @return Video size after 3D split and crop */ dcp::Size VideoContent::size_after_crop () const @@ -427,6 +438,7 @@ VideoContent::fade (shared_ptr<const Film> film, Frame f) const return optional<double> (); } + string VideoContent::processing_description (shared_ptr<const Film> film) { @@ -503,6 +515,7 @@ VideoContent::processing_description (shared_ptr<const Film> film) return d; } + void VideoContent::add_properties (list<UserProperty>& p) const { @@ -510,30 +523,35 @@ VideoContent::add_properties (list<UserProperty>& p) const p.push_back (UserProperty (UserProperty::VIDEO, _("Size"), String::compose ("%1x%2", size().width, size().height))); } + void VideoContent::set_length (Frame len) { maybe_set (_length, len, ContentProperty::LENGTH); } + void VideoContent::set_left_crop (int c) { maybe_set (_crop.left, c, VideoContentProperty::CROP); } + void VideoContent::set_right_crop (int c) { maybe_set (_crop.right, c, VideoContentProperty::CROP); } + void VideoContent::set_top_crop (int c) { maybe_set (_crop.top, c, VideoContentProperty::CROP); } + void VideoContent::set_bottom_crop (int c) { @@ -547,36 +565,42 @@ VideoContent::set_frame_type (VideoFrameType t) maybe_set (_frame_type, t, VideoContentProperty::FRAME_TYPE); } + void VideoContent::unset_colour_conversion () { maybe_set (_colour_conversion, boost::optional<ColourConversion> (), VideoContentProperty::COLOUR_CONVERSION); } + void VideoContent::set_colour_conversion (ColourConversion c) { maybe_set (_colour_conversion, c, VideoContentProperty::COLOUR_CONVERSION); } + void VideoContent::set_fade_in (Frame t) { maybe_set (_fade_in, t, VideoContentProperty::FADE_IN); } + void VideoContent::set_fade_out (Frame t) { maybe_set (_fade_out, t, VideoContentProperty::FADE_OUT); } + void VideoContent::set_range (VideoRange r) { maybe_set (_range, r, VideoContentProperty::RANGE); } + void VideoContent::set_use (bool u) { @@ -619,6 +643,7 @@ VideoContent::modify_position (shared_ptr<const Film> film, DCPTime& pos) const pos = pos.round (film->video_frame_rate()); } + void VideoContent::modify_trim_start (ContentTime& trim) const { diff --git a/src/lib/video_mxf_content.cc b/src/lib/video_mxf_content.cc index c7ee69d89..21d4669df 100644 --- a/src/lib/video_mxf_content.cc +++ b/src/lib/video_mxf_content.cc @@ -19,25 +19,25 @@ */ -#include "video_mxf_examiner.h" -#include "video_mxf_content.h" -#include "video_content.h" -#include "job.h" -#include "film.h" #include "compose.hpp" +#include "film.h" +#include "job.h" +#include "video_content.h" +#include "video_mxf_content.h" +#include "video_mxf_examiner.h" #include <asdcp/KM_log.h> +#include <dcp/exceptions.h> #include <dcp/mono_picture_asset.h> #include <dcp/stereo_picture_asset.h> -#include <dcp/exceptions.h> #include <libxml++/libxml++.h> #include "i18n.h" using std::list; -using std::string; -using std::shared_ptr; using std::make_shared; +using std::shared_ptr; +using std::string; using namespace dcpomatic; diff --git a/src/lib/video_mxf_decoder.cc b/src/lib/video_mxf_decoder.cc index 92cab0259..25d84ce84 100644 --- a/src/lib/video_mxf_decoder.cc +++ b/src/lib/video_mxf_decoder.cc @@ -19,11 +19,11 @@ */ -#include "video_mxf_decoder.h" +#include "frame_interval_checker.h" +#include "j2k_image_proxy.h" #include "video_decoder.h" #include "video_mxf_content.h" -#include "j2k_image_proxy.h" -#include "frame_interval_checker.h" +#include "video_mxf_decoder.h" #include <dcp/mono_picture_asset.h> #include <dcp/mono_picture_asset_reader.h> #include <dcp/stereo_picture_asset.h> diff --git a/src/lib/video_mxf_examiner.cc b/src/lib/video_mxf_examiner.cc index 8c7029ea8..83b19905b 100644 --- a/src/lib/video_mxf_examiner.cc +++ b/src/lib/video_mxf_examiner.cc @@ -18,19 +18,23 @@ */ + #include "video_mxf_content.h" #include "video_mxf_examiner.h" #include <dcp/exceptions.h> #include <dcp/mono_picture_asset.h> #include <dcp/stereo_picture_asset.h> + using std::shared_ptr; +using std::make_shared; using boost::optional; + VideoMXFExaminer::VideoMXFExaminer (shared_ptr<const VideoMXFContent> content) { try { - _asset.reset (new dcp::MonoPictureAsset (content->path(0))); + _asset = make_shared<dcp::MonoPictureAsset>(content->path(0)); } catch (dcp::MXFFileError& e) { /* maybe it's stereo */ } catch (dcp::ReadError& e) { @@ -38,34 +42,39 @@ VideoMXFExaminer::VideoMXFExaminer (shared_ptr<const VideoMXFContent> content) } if (!_asset) { - _asset.reset (new dcp::StereoPictureAsset (content->path(0))); + _asset = make_shared<dcp::StereoPictureAsset>(content->path(0)); } } + optional<double> VideoMXFExaminer::video_frame_rate () const { return _asset->frame_rate().as_float (); } + dcp::Size VideoMXFExaminer::video_size () const { return _asset->size (); } + Frame VideoMXFExaminer::video_length () const { return _asset->intrinsic_duration (); } + optional<double> VideoMXFExaminer::sample_aspect_ratio () const { return 1.0; } + bool VideoMXFExaminer::yuv () const { diff --git a/src/lib/video_ring_buffers.cc b/src/lib/video_ring_buffers.cc index 63c52ee06..7e3c67187 100644 --- a/src/lib/video_ring_buffers.cc +++ b/src/lib/video_ring_buffers.cc @@ -19,19 +19,19 @@ */ -#include "video_ring_buffers.h" -#include "player_video.h" #include "compose.hpp" +#include "player_video.h" +#include "video_ring_buffers.h" #include <list> #include <iostream> +using std::cout; using std::list; using std::make_pair; -using std::cout; using std::pair; -using std::string; using std::shared_ptr; +using std::string; using boost::optional; using namespace dcpomatic; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 4596fde05..6ce0b1f3e 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -19,31 +19,31 @@ */ -#include "writer.h" -#include "compose.hpp" -#include "film.h" -#include "ratio.h" -#include "log.h" -#include "dcpomatic_log.h" -#include "dcp_video.h" -#include "dcp_content_type.h" +#include "audio_buffers.h" #include "audio_mapping.h" +#include "compose.hpp" #include "config.h" -#include "job.h" #include "cross.h" -#include "audio_buffers.h" -#include "version.h" +#include "dcp_content_type.h" +#include "dcp_video.h" +#include "dcpomatic_log.h" +#include "film.h" #include "font_data.h" -#include "util.h" +#include "job.h" +#include "log.h" +#include "ratio.h" #include "reel_writer.h" #include "text_content.h" +#include "util.h" +#include "version.h" +#include "writer.h" #include <dcp/cpl.h> #include <dcp/locale_convert.h> #include <dcp/reel_file_asset.h> -#include <fstream> #include <cerrno> -#include <iostream> #include <cfloat> +#include <fstream> +#include <iostream> #include "i18n.h" @@ -65,8 +65,8 @@ using boost::optional; #if BOOST_VERSION >= 106100 using namespace boost::placeholders; #endif -using dcp::Data; using dcp::ArrayData; +using dcp::Data; using namespace dcpomatic; diff --git a/src/wx/playlist_controls.cc b/src/wx/playlist_controls.cc index 6fd0bdc0b..fbf5cf7c8 100644 --- a/src/wx/playlist_controls.cc +++ b/src/wx/playlist_controls.cc @@ -74,7 +74,7 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie auto spl_header = new wxBoxSizer (wxHORIZONTAL); { - wxStaticText* m = new StaticText (this, "Playlists"); + auto m = new StaticText (this, "Playlists"); m->SetFont (subheading_font); spl_header->Add (m, 1, wxALIGN_CENTER_VERTICAL); } @@ -88,7 +88,7 @@ PlaylistControls::PlaylistControls (wxWindow* parent, shared_ptr<FilmViewer> vie auto content_header = new wxBoxSizer (wxHORIZONTAL); { - wxStaticText* m = new StaticText (this, "Content"); + auto m = new StaticText (this, "Content"); m->SetFont (subheading_font); content_header->Add (m, 1, wxALIGN_CENTER_VERTICAL); } @@ -273,11 +273,11 @@ PlaylistControls::update_playlist_directory () _playlists.clear (); - for (directory_iterator i = directory_iterator(*dir); i != directory_iterator(); ++i) { + for (auto i: directory_iterator(*dir)) { try { - if (is_regular_file(i->path()) && i->path().extension() == ".xml") { + if (is_regular_file(i.path()) && i.path().extension() == ".xml") { SPL spl; - spl.read (i->path(), _content_view); + spl.read (i.path(), _content_view); _playlists.push_back (spl); } } catch (exception& e) { @@ -301,10 +301,10 @@ PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp) if (!kdm_dir) { return {}; } - for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) { + for (auto i: directory_iterator(*kdm_dir)) { try { - if (file_size(i->path()) < MAX_KDM_SIZE) { - dcp::EncryptedKDM kdm (dcp::file_to_string(i->path())); + if (file_size(i.path()) < MAX_KDM_SIZE) { + dcp::EncryptedKDM kdm (dcp::file_to_string(i.path())); if (kdm.cpl_id() == dcp->cpl()) { return kdm; } @@ -313,7 +313,7 @@ PlaylistControls::get_kdm_from_directory (shared_ptr<DCPContent> dcp) /* Hey well */ } } - return optional<dcp::EncryptedKDM>(); + return {}; } void |
