diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-21 01:15:32 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-21 01:15:32 +0100 |
| commit | e60bb3e51bd1508b149e6b8f6608f09b5196ae26 (patch) | |
| tree | a7a5b937c9ae138d4eebca8d5130d308bf9ae420 /src/lib | |
| parent | f07d5125a7b609320682689abe40781f096ca25e (diff) | |
No-op: remove all trailing whitespace.
Diffstat (limited to 'src/lib')
160 files changed, 712 insertions, 712 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 3dd15ac27..8f9b15010 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -63,7 +63,7 @@ AnalyseAudioJob::run () { shared_ptr<Player> player (new Player (_film)); player->set_ignore_video (); - + int64_t const len = _film->length().frames (_film->audio_frame_rate()); _samples_per_point = max (int64_t (1), len / _num_points); @@ -88,7 +88,7 @@ AnalyseAudioJob::run () _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ())); _analysis->write (_film->audio_analysis_path ()); - + set_progress (1); set_state (FINISHED_OK); } diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 73422a9be..7e1dc6e78 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -65,7 +65,7 @@ AudioPoint::operator= (AudioPoint const & other) if (this == &other) { return *this; } - + for (int i = 0; i < COUNT; ++i) { _data[i] = other._data[i]; } @@ -79,7 +79,7 @@ AudioPoint::as_xml (xmlpp::Element* parent) const parent->add_child ("Peak")->add_child_text (raw_convert<string> (_data[PEAK])); parent->add_child ("RMS")->add_child_text (raw_convert<string> (_data[RMS])); } - + AudioAnalysis::AudioAnalysis (int channels) { _data.resize (channels); diff --git a/src/lib/audio_analysis.h b/src/lib/audio_analysis.h index 9387ec896..2411b4316 100644 --- a/src/lib/audio_analysis.h +++ b/src/lib/audio_analysis.h @@ -42,7 +42,7 @@ public: AudioPoint& operator= (AudioPoint const &); void as_xml (xmlpp::Element *) const; - + float& operator[] (int t) { return _data[t]; } @@ -62,7 +62,7 @@ public: _peak = peak; _peak_time = time; } - + AudioPoint get_point (int c, int p) const; int points (int c) const; int channels () const; diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index 71422944d..0130f17b4 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -57,7 +57,7 @@ AudioBuffers::operator= (AudioBuffers const & other) if (this == &other) { return *this; } - + deallocate (); allocate (other._channels, other._frames); copy_from (&other, other._frames, 0, 0); @@ -80,12 +80,12 @@ AudioBuffers::allocate (int channels, int frames) _channels = channels; _frames = frames; _allocated_frames = frames; - + _data = static_cast<float**> (malloc (_channels * sizeof (float *))); if (!_data) { throw bad_alloc (); } - + for (int i = 0; i < _channels; ++i) { _data[i] = static_cast<float*> (malloc (frames * sizeof (float))); if (!_data[i]) { @@ -129,7 +129,7 @@ AudioBuffers::set_frames (int f) _data[c][i] = 0; } } - + _frames = f; } @@ -149,7 +149,7 @@ void AudioBuffers::make_silent (int c) { DCPOMATIC_ASSERT (c >= 0 && c < _channels); - + for (int i = 0; i < _frames; ++i) { _data[c][i] = 0; } @@ -180,7 +180,7 @@ AudioBuffers::copy_from (AudioBuffers const * from, int frames_to_copy, int read /* Prevent the asserts from firing if there is nothing to do */ return; } - + DCPOMATIC_ASSERT (from->channels() == channels()); DCPOMATIC_ASSERT (from); @@ -197,14 +197,14 @@ AudioBuffers::copy_from (AudioBuffers const * from, int frames_to_copy, int read * @param to Offset to move to. * @param frames Number of frames to move. */ - + void AudioBuffers::move (int from, int to, int frames) { if (frames == 0) { return; } - + DCPOMATIC_ASSERT (from >= 0); DCPOMATIC_ASSERT (from < _frames); DCPOMATIC_ASSERT (to >= 0); @@ -213,7 +213,7 @@ AudioBuffers::move (int from, int to, int frames) DCPOMATIC_ASSERT (frames <= _frames); DCPOMATIC_ASSERT ((from + frames) <= _frames); DCPOMATIC_ASSERT ((to + frames) <= _allocated_frames); - + for (int i = 0; i < _channels; ++i) { memmove (_data[i] + to, _data[i] + from, frames * sizeof(float)); } @@ -279,7 +279,7 @@ void AudioBuffers::apply_gain (float dB) { float const linear = pow (10, dB / 20); - + for (int i = 0; i < _channels; ++i) { for (int j = 0; j < _frames; ++j) { _data[i][j] *= linear; diff --git a/src/lib/audio_buffers.h b/src/lib/audio_buffers.h index 8cd67aaa7..bcf5d5928 100644 --- a/src/lib/audio_buffers.h +++ b/src/lib/audio_buffers.h @@ -47,7 +47,7 @@ public: float** data () const { return _data; } - + float* data (int) const; int channels () const { @@ -75,7 +75,7 @@ public: private: void allocate (int, int); void deallocate (); - + /** Number of channels */ int _channels; /** Number of frames (where a frame is one sample across all channels) */ diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index e1f435f49..d2d90a1f5 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -82,7 +82,7 @@ AudioContent::AudioContent (shared_ptr<const Film> film, vector<shared_ptr<Conte { shared_ptr<AudioContent> ref = dynamic_pointer_cast<AudioContent> (c[0]); DCPOMATIC_ASSERT (ref); - + for (size_t i = 0; i < c.size(); ++i) { shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c[i]); @@ -115,7 +115,7 @@ AudioContent::set_audio_gain (double g) boost::mutex::scoped_lock lm (_mutex); _audio_gain = g; } - + signal_changed (AudioContentProperty::AUDIO_GAIN); } @@ -126,7 +126,7 @@ AudioContent::set_audio_delay (int d) boost::mutex::scoped_lock lm (_mutex); _audio_delay = d; } - + signal_changed (AudioContentProperty::AUDIO_DELAY); } @@ -155,7 +155,7 @@ AudioContent::set_audio_mapping (AudioMapping mapping) } i->set_mapping (stream_mapping); } - + signal_changed (AudioContentProperty::AUDIO_STREAMS); } @@ -166,9 +166,9 @@ AudioContent::audio_mapping () const BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) { channels += i->channels (); } - + AudioMapping merged (channels, MAX_DCP_AUDIO_CHANNELS); - + int c = 0; int s = 0; BOOST_FOREACH (AudioStreamPtr i, audio_streams ()) { @@ -193,7 +193,7 @@ AudioContent::resampled_audio_frame_rate () const { shared_ptr<const Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - + /* Resample to a DCI-approved sample rate */ double t = has_rate_above_48k() ? 96000 : 48000; diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index df6527ed0..2ecb51205 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -68,7 +68,7 @@ public: void set_audio_gain (double); void set_audio_delay (int); - + double audio_gain () const { boost::mutex::scoped_lock lm (_mutex); return _audio_gain; @@ -80,7 +80,7 @@ public: } std::string processing_description () const; - + private: /** Gain to apply to audio in dB */ double _audio_gain; diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index 1b17029b7..387b1ad7f 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -40,7 +40,7 @@ class AudioDecoder : public virtual Decoder, public boost::enable_shared_from_th { public: AudioDecoder (boost::shared_ptr<const AudioContent>); - + boost::shared_ptr<const AudioContent> audio_content () const { return _audio_content; } @@ -57,8 +57,8 @@ protected: void audio (AudioStreamPtr stream, boost::shared_ptr<const AudioBuffers>, ContentTime); void flush (); void seek (ContentTime t, bool accurate); - -private: + +private: boost::shared_ptr<const AudioContent> _audio_content; /** An AudioDecoderStream object to manage each stream in _audio_content */ std::map<AudioStreamPtr, boost::shared_ptr<AudioDecoderStream> > _streams; diff --git a/src/lib/audio_decoder_stream.cc b/src/lib/audio_decoder_stream.cc index f1d9839f8..8c521f94d 100644 --- a/src/lib/audio_decoder_stream.cc +++ b/src/lib/audio_decoder_stream.cc @@ -59,7 +59,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) shared_ptr<ContentAudio> dec; Frame const end = frame + length - 1; - + if (frame < _decoded.frame || end > (_decoded.frame + length * 4)) { /* Either we have no decoded data, or what we do have is a long way from what we want: seek */ seek (ContentTime::from_frames (frame, _content->resampled_audio_frame_rate()), accurate); @@ -69,7 +69,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) (to be set up shortly) */ Frame decoded_offset = 0; - + /* Now enough pass() calls will either: * (a) give us what we want, or * (b) hit the end of the decoder. @@ -84,7 +84,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) !_decoder->pass () ) {} - + decoded_offset = frame - _decoded.frame; } else { while ( @@ -92,7 +92,7 @@ AudioDecoderStream::get (Frame frame, Frame length, bool accurate) !_decoder->pass () ) {} - + /* Use decoded_offset of 0, as we don't really care what frames we return */ } @@ -183,7 +183,7 @@ AudioDecoderStream::add (shared_ptr<const AudioBuffers> data) */ return; } - + /* Resize _decoded to fit the new data */ int new_size = 0; if (_decoded.audio->frames() == 0) { @@ -194,7 +194,7 @@ AudioDecoderStream::add (shared_ptr<const AudioBuffers> data) /* Otherwise we need to extend _decoded to include the new stuff */ new_size = _position.get() + data->frames() - _decoded.frame; } - + _decoded.audio->ensure_size (new_size); _decoded.audio->set_frames (new_size); diff --git a/src/lib/audio_decoder_stream.h b/src/lib/audio_decoder_stream.h index 24f86c2e3..5c772e4f7 100644 --- a/src/lib/audio_decoder_stream.h +++ b/src/lib/audio_decoder_stream.h @@ -32,12 +32,12 @@ class AudioDecoderStream { public: AudioDecoderStream (boost::shared_ptr<const AudioContent>, AudioStreamPtr, AudioDecoder* decoder); - + ContentAudio get (Frame time, Frame length, bool accurate); void audio (boost::shared_ptr<const AudioBuffers>, ContentTime); void flush (); void seek (ContentTime time, bool accurate); - + private: void reset_decoded (); diff --git a/src/lib/audio_filter.cc b/src/lib/audio_filter.cc index dbef25201..2cf1cf604 100644 --- a/src/lib/audio_filter.cc +++ b/src/lib/audio_filter.cc @@ -29,9 +29,9 @@ vector<float> AudioFilter::sinc_blackman (float cutoff, bool invert) const { vector<float> ir (_M + 1); - + /* Impulse response */ - + for (int i = 0; i <= _M; ++i) { if (i == (_M / 2)) { ir[i] = 2 * M_PI * cutoff; @@ -42,27 +42,27 @@ AudioFilter::sinc_blackman (float cutoff, bool invert) const ir[i] *= (0.42 - 0.5 * cos (2 * M_PI * i / _M) + 0.08 * cos (4 * M_PI * i / _M)); } } - + /* Normalise */ - + float sum = 0; for (int i = 0; i <= _M; ++i) { sum += ir[i]; } - + for (int i = 0; i <= _M; ++i) { ir[i] /= sum; } - + /* Frequency inversion (swapping low-pass for high-pass, or whatever) */ - + if (invert) { for (int i = 0; i <= _M; ++i) { ir[i] = -ir[i]; } ir[_M / 2] += 1; } - + return ir; } @@ -70,12 +70,12 @@ shared_ptr<AudioBuffers> AudioFilter::run (shared_ptr<AudioBuffers> in) { shared_ptr<AudioBuffers> out (new AudioBuffers (in->channels(), in->frames())); - + if (!_tail) { _tail.reset (new AudioBuffers (in->channels(), _M + 1)); _tail->make_silent (); } - + for (int i = 0; i < in->channels(); ++i) { for (int j = 0; j < in->frames(); ++j) { float s = 0; @@ -86,17 +86,17 @@ AudioFilter::run (shared_ptr<AudioBuffers> in) s += in->data(i)[j - k] * _ir[k]; } } - + out->data(i)[j] = s; } } - + int const amount = min (in->frames(), _tail->frames()); if (amount < _tail->frames ()) { _tail->move (amount, 0, _tail->frames() - amount); } _tail->copy_from (in.get(), amount, in->frames() - amount, _tail->frames () - amount); - + return out; } @@ -124,16 +124,16 @@ BandPassAudioFilter::BandPassAudioFilter (float transition_bandwidth, float lowe { vector<float> lpf = sinc_blackman (lower, false); vector<float> hpf = sinc_blackman (higher, true); - + _ir.resize (_M + 1); for (int i = 0; i <= _M; ++i) { _ir[i] = lpf[i] + hpf[i]; } - + /* We now have a band-stop, so invert for band-pass */ for (int i = 0; i <= _M; ++i) { _ir[i] = -_ir[i]; } - + _ir[_M / 2] += 1; } diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index ca175912b..725109ae6 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -56,7 +56,7 @@ AudioMapping::setup (int input_channels, int output_channels) { _input_channels = input_channels; _output_channels = output_channels; - + _gain.resize (_input_channels); for (int i = 0; i < _input_channels; ++i) { _gain[i].resize (_output_channels); @@ -161,7 +161,7 @@ AudioMapping::mapped_output_channels () const static float const minus_96_db = 0.000015849; list<int> mapped; - + for (vector<vector<float> >::const_iterator i = _gain.begin(); i != _gain.end(); ++i) { for (size_t j = 0; j < i->size(); ++j) { if (abs ((*i)[j]) > minus_96_db) { @@ -172,7 +172,7 @@ AudioMapping::mapped_output_channels () const mapped.sort (); mapped.unique (); - + return mapped; } diff --git a/src/lib/audio_mapping.h b/src/lib/audio_mapping.h index 57169cc1e..ca9b9847f 100644 --- a/src/lib/audio_mapping.h +++ b/src/lib/audio_mapping.h @@ -48,7 +48,7 @@ public: AudioMapping (cxml::ConstNodePtr, int); /* Default copy constructor is fine */ - + void as_xml (xmlpp::Node *) const; void make_zero (); @@ -63,12 +63,12 @@ public: int output_channels () const { return _output_channels; } - + std::string digest () const; std::list<int> mapped_output_channels () const; void unmap_all (); - + private: void setup (int input_channels, int output_channels); diff --git a/src/lib/audio_stream.h b/src/lib/audio_stream.h index 757d2ea29..80ccc4cdb 100644 --- a/src/lib/audio_stream.h +++ b/src/lib/audio_stream.h @@ -30,7 +30,7 @@ class AudioStream public: AudioStream (int frame_rate, int channels); AudioStream (int frame_rate, AudioMapping mapping); - + void set_mapping (AudioMapping mapping); void set_frame_rate (int frame_rate); @@ -51,7 +51,7 @@ protected: private: friend struct audio_sampling_rate_test; - + int _frame_rate; AudioMapping _mapping; }; diff --git a/src/lib/channel_count.h b/src/lib/channel_count.h index 4247fc063..bc840293e 100644 --- a/src/lib/channel_count.h +++ b/src/lib/channel_count.h @@ -32,7 +32,7 @@ public: : min (n) , max (n) {} - + ChannelCount (int min_, int max_) : min (min_) , max (max_) diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index ce3077b2a..f77439238 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -84,4 +84,4 @@ Screen::as_xml (xmlpp::Element* parent) const } } - + diff --git a/src/lib/cinema.h b/src/lib/cinema.h index 5c0386837..fea4f1c14 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -44,7 +44,7 @@ public: Screen (cxml::ConstNodePtr); void as_xml (xmlpp::Element *) const; - + boost::shared_ptr<Cinema> cinema; std::string name; boost::optional<dcp::Certificate> certificate; @@ -72,13 +72,13 @@ public: void add_screen (boost::shared_ptr<Screen>); void remove_screen (boost::shared_ptr<Screen>); - + std::string name; std::string email; std::list<boost::shared_ptr<Screen> > screens () const { return _screens; } -private: +private: std::list<boost::shared_ptr<Screen> > _screens; }; diff --git a/src/lib/cinema_sound_processor.h b/src/lib/cinema_sound_processor.h index 30ab7d5a5..1d4a389f3 100644 --- a/src/lib/cinema_sound_processor.h +++ b/src/lib/cinema_sound_processor.h @@ -50,7 +50,7 @@ public: std::string name () const { return _name; } - + static std::vector<CinemaSoundProcessor const *> all (); static void setup_cinema_sound_processors (); static CinemaSoundProcessor const * from_id (std::string id); diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index 0f05474d8..31d4cc41a 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -45,13 +45,13 @@ vector<PresetColourConversion> PresetColourConversion::_presets; ColourConversion::ColourConversion () : dcp::ColourConversion (dcp::ColourConversion::srgb_to_xyz ()) { - + } ColourConversion::ColourConversion (dcp::ColourConversion conversion_) : dcp::ColourConversion (conversion_) { - + } ColourConversion::ColourConversion (cxml::NodePtr node, int version) @@ -78,7 +78,7 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version) } else { /* Version 1.x */ - + if (node->bool_child ("InputGammaLinearised")) { _in.reset (new dcp::ModifiedGammaTransferFunction (node->number_child<float> ("InputGamma"), 0.04045, 0.055, 12.92)); } else { @@ -87,7 +87,7 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version) } _yuv_to_rgb = static_cast<dcp::YUVToRGB> (node->optional_number_child<int>("YUVToRGB").get_value_or (dcp::YUV_TO_RGB_REC601)); - + list<cxml::NodePtr> m = node->node_children ("Matrix"); if (!m.empty ()) { /* Read in old <Matrix> nodes and convert them to chromaticities */ @@ -117,8 +117,8 @@ ColourConversion::ColourConversion (cxml::NodePtr node, int version) node->number_child<double> ("AdjustedWhiteX"), node->number_child<double> ("AdjustedWhiteY") ); } - } - + } + _out.reset (new dcp::GammaTransferFunction (node->number_child<double> ("OutputGamma"))); } @@ -212,7 +212,7 @@ ColourConversion::identifier () const } digester.add (dynamic_pointer_cast<const dcp::GammaTransferFunction> (_out)->gamma ()); - + return digester.get (); } diff --git a/src/lib/colour_conversion.h b/src/lib/colour_conversion.h index 06a9cf6c3..eaf43f592 100644 --- a/src/lib/colour_conversion.h +++ b/src/lib/colour_conversion.h @@ -59,7 +59,7 @@ public: std::string name; /** an internal short (non-internationalised) name for this preset */ std::string id; - + static std::vector<PresetColourConversion> all () { return _presets; } @@ -67,7 +67,7 @@ public: static PresetColourConversion from_id (std::string id); static void setup_colour_conversion_presets (); - + private: static std::vector<PresetColourConversion> _presets; }; diff --git a/src/lib/config.cc b/src/lib/config.cc index e726acee1..e6f363729 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -79,9 +79,9 @@ Config::set_defaults () _check_for_test_updates = false; _maximum_j2k_bandwidth = 250000000; _log_types = Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR | Log::TYPE_DEBUG; -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS _win32_console = false; -#endif +#endif _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -138,7 +138,7 @@ Config::read () _servers.push_back ((*i)->content ()); } } - + _tms_ip = f.string_child ("TMSIP"); _tms_path = f.string_child ("TMSPath"); _tms_user = f.string_child ("TMSUser"); @@ -170,13 +170,13 @@ Config::read () } else if (f.optional_string_child ("DCPIssuer")) { _dcp_issuer = f.string_child ("DCPIssuer"); } - + if (version && version.get() >= 2) { _default_isdcf_metadata = ISDCFMetadata (f.node_child ("ISDCFMetadata")); } else { _default_isdcf_metadata = ISDCFMetadata (f.node_child ("DCIMetadata")); } - + _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10); _default_j2k_bandwidth = f.optional_number_child<int>("DefaultJ2KBandwidth").get_value_or (200000000); _default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0); @@ -207,9 +207,9 @@ Config::read () _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate"); _log_types = f.optional_number_child<int> ("LogTypes").get_value_or (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR); -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS _win32_console = f.optional_bool_child ("Win32Console").get_value_or (false); -#endif +#endif list<cxml::NodePtr> his = f.node_children ("History"); for (list<cxml::NodePtr>::const_iterator i = his.begin(); i != his.end(); ++i) { @@ -308,7 +308,7 @@ Config::write () const root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ()); root->add_child("ServerPortBase")->add_child_text (raw_convert<string> (_server_port_base)); root->add_child("UseAnyServers")->add_child_text (_use_any_servers ? "1" : "0"); - + for (vector<string>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) { root->add_child("Server")->add_child_text (*i); } @@ -356,9 +356,9 @@ Config::write () const root->add_child("MaximumJ2KBandwidth")->add_child_text (raw_convert<string> (_maximum_j2k_bandwidth)); root->add_child("AllowAnyDCPFrameRate")->add_child_text (_allow_any_dcp_frame_rate ? "1" : "0"); root->add_child("LogTypes")->add_child_text (raw_convert<string> (_log_types)); -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0"); -#endif +#endif xmlpp::Element* signer = root->add_child ("Signer"); dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf (); @@ -437,7 +437,7 @@ Config::add_to_history (boost::filesystem::path p) { /* Remove existing instances of this path in the history */ _history.erase (remove (_history.begin(), _history.end(), p), _history.end ()); - + _history.insert (_history.begin (), p); if (_history.size() > HISTORY_SIZE) { _history.pop_back (); diff --git a/src/lib/config.h b/src/lib/config.h index 20529911b..0040591f1 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -88,7 +88,7 @@ public: std::string tms_ip () const { return _tms_ip; } - + /** @return The path on a TMS that we should changed DCPs to */ std::string tms_path () const { return _tms_path; @@ -112,7 +112,7 @@ public: std::list<boost::shared_ptr<Cinema> > cinemas () const { return _cinemas; } - + std::list<int> allowed_dcp_frame_rates () const { return _allowed_dcp_frame_rates; } @@ -120,7 +120,7 @@ public: bool allow_any_dcp_frame_rate () const { return _allow_any_dcp_frame_rate; } - + ISDCFMetadata default_isdcf_metadata () const { return _default_isdcf_metadata; } @@ -180,7 +180,7 @@ public: std::string kdm_bcc () const { return _kdm_bcc; } - + std::string kdm_email () const { return _kdm_email; } @@ -213,11 +213,11 @@ public: return _log_types; } -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS bool win32_console () const { return _win32_console; } -#endif +#endif std::vector<boost::filesystem::path> history () const { return _history; @@ -291,7 +291,7 @@ public: if (!_language) { return; } - + _language = boost::none; changed (); } @@ -347,7 +347,7 @@ public: void set_kdm_bcc (std::string f) { maybe_set (_kdm_bcc, f); } - + void set_kdm_email (std::string e) { maybe_set (_kdm_email, e); } @@ -382,11 +382,11 @@ public: maybe_set (_log_types, t); } -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS void set_win32_console (bool c) { maybe_set (_win32_console, c); } -#endif +#endif void clear_history () { _history.clear (); @@ -394,12 +394,12 @@ public: } void add_to_history (boost::filesystem::path p); - + void changed (); boost::signals2::signal<void ()> Changed; void write () const; - + static Config* instance (); static void drop (); static void restore_defaults (); @@ -474,11 +474,11 @@ private: /** maximum allowed J2K bandwidth in bits per second */ int _maximum_j2k_bandwidth; int _log_types; -#ifdef DCPOMATIC_WINDOWS +#ifdef DCPOMATIC_WINDOWS bool _win32_console; -#endif +#endif std::vector<boost::filesystem::path> _history; - + /** Singleton instance, or 0 */ static Config* _instance; }; diff --git a/src/lib/content.cc b/src/lib/content.cc index 2ee660b7f..aa382d68b 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -134,7 +134,7 @@ Content::examine (shared_ptr<Job> job) if (job) { job->sub (_("Computing digest")); } - + boost::mutex::scoped_lock lm (_mutex); vector<boost::filesystem::path> p = _paths; lm.unlock (); @@ -163,7 +163,7 @@ Content::set_position (DCPTime p) if (p == _position) { return; } - + _position = p; } @@ -200,7 +200,7 @@ Content::clone () const if (!film) { return shared_ptr<Content> (); } - + /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */ xmlpp::Document doc; xmlpp::Node* node = doc.create_root_node ("Content"); @@ -230,7 +230,7 @@ string Content::identifier () const { SafeStringStream s; - + s << Content::digest() << "_" << position().get() << "_" << trim_start().get() diff --git a/src/lib/content.h b/src/lib/content.h index 4b6153a9d..6ee9e59dd 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -69,17 +69,17 @@ public: * @param job Job to use to report progress, or 0. */ virtual void examine (boost::shared_ptr<Job> job); - + /** @return Quick one-line summary of the content, as will be presented in the * film editor. */ virtual std::string summary () const = 0; - + /** @return Technical details of this content; these are written to logs to * help with debugging. */ virtual std::string technical_summary () const; - + virtual void as_xml (xmlpp::Node *) const; virtual DCPTime full_length () const = 0; virtual std::string identifier () const; @@ -104,7 +104,7 @@ public: boost::mutex::scoped_lock lm (_mutex); return _paths[i]; } - + bool paths_valid () const; /** @return Digest of the content's file(s). Note: this is @@ -134,7 +134,7 @@ public: } void set_trim_end (DCPTime); - + DCPTime trim_end () const { boost::mutex::scoped_lock lm (_mutex); return _trim_end; @@ -146,7 +146,7 @@ public: } DCPTime length_after_trim () const; - + void set_change_signals_frequent (bool f) { _change_signals_frequent = f; } @@ -169,7 +169,7 @@ protected: /** Paths of our data files */ std::vector<boost::filesystem::path> _paths; - + private: std::string _digest; DCPTime _position; diff --git a/src/lib/content_audio.h b/src/lib/content_audio.h index 194e90e3f..c343865e3 100644 --- a/src/lib/content_audio.h +++ b/src/lib/content_audio.h @@ -37,7 +37,7 @@ public: : audio (new AudioBuffers (0, 0)) , frame (0) {} - + ContentAudio (boost::shared_ptr<AudioBuffers> a, Frame f) : audio (a) , frame (f) diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index db3a30500..3c65b4312 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -48,7 +48,7 @@ content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, l string const type = node->string_child ("Type"); boost::shared_ptr<Content> content; - + if (type == "FFmpeg") { content.reset (new FFmpegContent (film, node, version, notes)); } else if (type == "Image") { diff --git a/src/lib/content_subtitle.h b/src/lib/content_subtitle.h index 36bc22b13..ef904a980 100644 --- a/src/lib/content_subtitle.h +++ b/src/lib/content_subtitle.h @@ -61,7 +61,7 @@ public: {} ContentTimePeriod period () const; - + std::list<dcp::SubtitleString> subs; }; diff --git a/src/lib/content_video.h b/src/lib/content_video.h index c8f5cca0b..2c996f816 100644 --- a/src/lib/content_video.h +++ b/src/lib/content_video.h @@ -40,7 +40,7 @@ public: , part (p) , frame (f) {} - + boost::shared_ptr<const ImageProxy> image; Eyes eyes; Part part; diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 0bcb31e3e..2689be2c2 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -75,7 +75,7 @@ string cpu_info () { string info; - + #ifdef DCPOMATIC_LINUX /* This use of ifstream is ok; the filename can never be non-Latin @@ -99,7 +99,7 @@ cpu_info () if (sysctlbyname ("machdep.cpu.brand_string", buffer, &N, 0, 0) == 0) { info = buffer; } -#endif +#endif #ifdef DCPOMATIC_WINDOWS HKEY key; @@ -124,11 +124,11 @@ cpu_info () } info = string (value.begin(), value.end()); - + RegCloseKey (key); -#endif - +#endif + return info; } @@ -142,7 +142,7 @@ app_contents () if (_NSGetExecutablePath (buffer, &size)) { throw StringError ("_NSGetExecutablePath failed"); } - + boost::filesystem::path path (buffer); path = boost::filesystem::canonical (path); path = path.parent_path (); @@ -170,7 +170,7 @@ shared_path () #endif #ifdef DCPOMATIC_OSX return app_contents() / "Resources"; -#endif +#endif } void @@ -241,7 +241,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share CloseHandle (child_stderr_read); #endif -#ifdef DCPOMATIC_LINUX +#ifdef DCPOMATIC_LINUX string ffprobe = "ffprobe \"" + content.string() + "\" 2> \"" + out.string() + "\""; LOG_GENERAL (N_("Probing with %1"), ffprobe); system (ffprobe.c_str ()); @@ -251,7 +251,7 @@ run_ffprobe (boost::filesystem::path content, boost::filesystem::path out, share boost::filesystem::path path = app_contents(); path /= "MacOS"; path /= "ffprobe"; - + string ffprobe = path.string() + " \"" + content.string() + "\" 2> \"" + out.string() + "\""; LOG_GENERAL (N_("Probing with %1"), ffprobe); system (ffprobe.c_str ()); @@ -262,13 +262,13 @@ list<pair<string, string> > mount_info () { list<pair<string, string> > m; - + #ifdef DCPOMATIC_LINUX FILE* f = setmntent ("/etc/mtab", "r"); if (!f) { return m; } - + while (true) { struct mntent* mnt = getmntent (f); if (!mnt) { @@ -291,11 +291,11 @@ openssl_path () wchar_t dir[512]; GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir)); PathRemoveFileSpec (dir); - + boost::filesystem::path path = dir; path /= "openssl.exe"; return path; -#else +#else /* We assume that it's on the path for Linux and OS X */ return "openssl"; #endif @@ -323,9 +323,9 @@ dcpomatic_fseek (FILE* stream, int64_t offset, int whence) { #ifdef DCPOMATIC_WINDOWS return _fseeki64 (stream, offset, whence); -#else +#else return fseek (stream, offset, whence); -#endif +#endif } void @@ -333,7 +333,7 @@ Waker::nudge () { #ifdef DCPOMATIC_WINDOWS SetThreadExecutionState (ES_SYSTEM_REQUIRED); -#endif +#endif } Waker::Waker () @@ -343,12 +343,12 @@ Waker::Waker () // IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); /* but it's not available on 10.5, so we use this */ IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_assertion_id); -#endif +#endif } Waker::~Waker () { -#ifdef DCPOMATIC_OSX +#ifdef DCPOMATIC_OSX IOPMAssertionRelease (_assertion_id); -#endif +#endif } diff --git a/src/lib/data.cc b/src/lib/data.cc index 92b0b19d5..5975ff6fc 100644 --- a/src/lib/data.cc +++ b/src/lib/data.cc @@ -54,13 +54,13 @@ Data::Data (boost::filesystem::path file) if (!f) { throw FileError (_("could not open file for reading"), file); } - + size_t const r = fread (_data.get(), 1, _size, f); if (r != size_t (_size)) { fclose (f); throw FileError (_("could not read from file"), file); } - + fclose (f); } diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index d51a560dd..880a543e7 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -82,10 +82,10 @@ void DCPContent::examine (shared_ptr<Job> job) { bool const could_be_played = can_be_played (); - + job->set_progress_unknown (); Content::examine (job); - + shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ())); take_from_video_examiner (examiner); take_from_audio_examiner (examiner); diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 74f06cdc6..54527422e 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -51,7 +51,7 @@ public: } DCPTime full_length () const; - + void examine (boost::shared_ptr<Job>); std::string summary () const; std::string technical_summary () const; @@ -63,7 +63,7 @@ public: boost::mutex::scoped_lock lm (_mutex); return _has_subtitles; } - + boost::filesystem::path directory () const; bool encrypted () const { @@ -78,10 +78,10 @@ public: } bool can_be_played () const; - + private: void read_directory (boost::filesystem::path); - + std::string _name; bool _has_subtitles; /** true if our DCP is encrypted */ diff --git a/src/lib/dcp_content_type.h b/src/lib/dcp_content_type.h index 34398009b..c370fef4d 100644 --- a/src/lib/dcp_content_type.h +++ b/src/lib/dcp_content_type.h @@ -64,5 +64,5 @@ private: /** All available DCP content types */ static std::vector<DCPContentType const *> _dcp_content_types; }; - + #endif diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index ab906b3d1..0ec50e0cd 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -63,7 +63,7 @@ DCPDecoder::pass () float const vfr = _dcp_content->video_frame_rate (); int64_t const frame = _next.frames (vfr); - + if ((*_reel)->main_picture ()) { shared_ptr<dcp::PictureAsset> asset = (*_reel)->main_picture()->asset (); shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset); @@ -76,7 +76,7 @@ DCPDecoder::pass () shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_LEFT)), frame ); - + video ( shared_ptr<ImageProxy> (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_RIGHT)), frame @@ -111,7 +111,7 @@ DCPDecoder::pass () ++_reel; } } - + return false; } diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h index 5d9b76497..7d26139ba 100644 --- a/src/lib/dcp_decoder.h +++ b/src/lib/dcp_decoder.h @@ -40,7 +40,7 @@ public: private: bool pass (); void seek (ContentTime t, bool accurate); - + std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const; std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const; diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 21ffeda29..1dd469206 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -83,7 +83,7 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content) _video_length += (*i)->main_picture()->duration(); } - + if ((*i)->main_sound ()) { shared_ptr<dcp::SoundAsset> asset = (*i)->main_sound()->asset (); @@ -109,20 +109,20 @@ DCPExaminer::DCPExaminer (shared_ptr<const DCPContent> content) _encrypted = dcp.encrypted (); _kdm_valid = true; - + /* Check that we can read the first picture frame */ try { if (!dcp.cpls().empty () && !dcp.cpls().front()->reels().empty ()) { shared_ptr<dcp::PictureAsset> asset = dcp.cpls().front()->reels().front()->main_picture()->asset (); shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset); shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset); - + if (mono) { mono->get_frame(0)->xyz_image (); } else { stereo->get_frame(0)->xyz_image (dcp::EYE_LEFT); } - + } } catch (dcp::DCPReadError& e) { _kdm_valid = false; diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index bf083e8ec..ed457b5c2 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -30,15 +30,15 @@ class DCPExaminer : public VideoExaminer, public AudioExaminer { public: DCPExaminer (boost::shared_ptr<const DCPContent>); - + boost::optional<float> video_frame_rate () const { return _video_frame_rate; } - + dcp::Size video_size () const { return _video_size.get_value_or (dcp::Size (1998, 1080)); } - + Frame video_length () const { return _video_length; } @@ -58,11 +58,11 @@ public: int audio_channels () const { return _audio_channels.get_value_or (0); } - + Frame audio_length () const { return _audio_length; } - + int audio_frame_rate () const { return _audio_frame_rate.get_value_or (48000); } diff --git a/src/lib/dcp_subtitle.cc b/src/lib/dcp_subtitle.cc index 9963d0a94..be6493780 100644 --- a/src/lib/dcp_subtitle.cc +++ b/src/lib/dcp_subtitle.cc @@ -30,11 +30,11 @@ shared_ptr<dcp::SubtitleAsset> DCPSubtitle::load (boost::filesystem::path file) const { shared_ptr<dcp::SubtitleAsset> sc; - + try { sc.reset (new dcp::InteropSubtitleAsset (file)); } catch (...) { - + } if (!sc) { diff --git a/src/lib/dcp_subtitle_content.cc b/src/lib/dcp_subtitle_content.cc index 3f13f34e2..8b09b6fee 100644 --- a/src/lib/dcp_subtitle_content.cc +++ b/src/lib/dcp_subtitle_content.cc @@ -36,7 +36,7 @@ DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, boost::file : Content (film, path) , SubtitleContent (film, path) { - + } DCPSubtitleContent::DCPSubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version) @@ -56,7 +56,7 @@ DCPSubtitleContent::examine (shared_ptr<Job> job) /* Default to turning these subtitles on */ set_use_subtitles (true); - + boost::mutex::scoped_lock lm (_mutex); shared_ptr<dcp::InteropSubtitleAsset> iop = dynamic_pointer_cast<dcp::InteropSubtitleAsset> (sc); @@ -95,7 +95,7 @@ DCPSubtitleContent::technical_summary () const { return Content::technical_summary() + " - " + _("DCP XML subtitles"); } - + void DCPSubtitleContent::as_xml (xmlpp::Node* node) const { diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 9687f646c..3c7bffdda 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -65,7 +65,7 @@ DCPSubtitleDecoder::image_subtitles_during (ContentTimePeriod, bool) const { return list<ContentTimePeriod> (); } - + list<ContentTimePeriod> DCPSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) const { @@ -78,7 +78,7 @@ DCPSubtitleDecoder::text_subtitles_during (ContentTimePeriod p, bool starting) c ContentTime::from_seconds (i->in().as_seconds ()), ContentTime::from_seconds (i->out().as_seconds ()) ); - + if ((starting && p.contains (period.from)) || (!starting && p.overlaps (period))) { d.push_back (period); } diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 806ec9464..b72353d9e 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -87,7 +87,7 @@ DCPVideo::DCPVideo ( , _burn_subtitles (b) , _log (l) { - + } DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::Node> node, shared_ptr<Log> log) @@ -144,11 +144,11 @@ DCPVideo::encode_locally (dcp::NoteHandler note) parameters.tile_size_on = false; parameters.cp_tdx = 1; parameters.cp_tdy = 1; - + /* Tile part */ parameters.tp_flag = 'C'; parameters.tp_on = 1; - + /* Tile and Image shall be at (0,0) */ parameters.cp_tx0 = 0; parameters.cp_ty0 = 0; @@ -159,19 +159,19 @@ DCPVideo::encode_locally (dcp::NoteHandler note) parameters.cblockw_init = 32; parameters.cblockh_init = 32; parameters.csty |= 0x01; - + /* The progression order shall be CPRL */ parameters.prog_order = CPRL; - + /* No ROI */ parameters.roi_compno = -1; - + parameters.subsampling_dx = 1; parameters.subsampling_dy = 1; - + /* 9-7 transform */ parameters.irreversible = 1; - + parameters.tcp_rates[0] = 0; parameters.tcp_numlayers++; parameters.cp_disto_alloc = 1; @@ -179,27 +179,27 @@ DCPVideo::encode_locally (dcp::NoteHandler note) if (_resolution == RESOLUTION_4K) { parameters.numpocs = 2; parameters.POC[0].tile = 1; - parameters.POC[0].resno0 = 0; + parameters.POC[0].resno0 = 0; parameters.POC[0].compno0 = 0; parameters.POC[0].layno1 = 1; parameters.POC[0].resno1 = parameters.numresolution - 1; parameters.POC[0].compno1 = 3; parameters.POC[0].prg1 = CPRL; parameters.POC[1].tile = 1; - parameters.POC[1].resno0 = parameters.numresolution - 1; + parameters.POC[1].resno0 = parameters.numresolution - 1; parameters.POC[1].compno0 = 0; parameters.POC[1].layno1 = 1; parameters.POC[1].resno1 = parameters.numresolution; parameters.POC[1].compno1 = 3; parameters.POC[1].prg1 = CPRL; } - + parameters.cp_comment = strdup (N_("DCP-o-matic")); parameters.cp_cinema = _resolution == RESOLUTION_2K ? CINEMA2K_24 : CINEMA4K_24; /* 3 components, so use MCT */ parameters.tcp_mct = 1; - + /* set max image */ parameters.max_comp_size = max_comp_size; parameters.tcp_rates[0] = ((float) (3 * xyz->size().width * xyz->size().height * 12)) / (max_cs_len * 8); @@ -269,7 +269,7 @@ DCPVideo::encode_remotely (ServerDescription serv) add_metadata (root); LOG_GENERAL (N_("Sending frame %1 to remote"), _index); - + /* Send XML metadata */ string xml = doc.write_to_string ("UTF-8"); socket->write (xml.length() + 1); @@ -285,7 +285,7 @@ DCPVideo::encode_remotely (ServerDescription serv) socket->read (e.data().get(), e.size()); LOG_GENERAL (N_("Finished remotely-encoded frame %1"), _index); - + return e; } diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index c1c48623d..97be07798 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -59,11 +59,11 @@ public: Eyes eyes () const; bool same (boost::shared_ptr<const DCPVideo> other) const; - + private: void add_metadata (xmlpp::Element *) const; - + boost::shared_ptr<const PlayerVideo> _frame; int _index; ///< frame index within the DCP's intrinsic duration int _frames_per_second; ///< Frames per second that we will use for the DCP diff --git a/src/lib/dcpomatic_socket.cc b/src/lib/dcpomatic_socket.cc index d575e3230..16f01f39c 100644 --- a/src/lib/dcpomatic_socket.cc +++ b/src/lib/dcpomatic_socket.cc @@ -78,7 +78,7 @@ Socket::write (uint8_t const * data, int size) boost::system::error_code ec = boost::asio::error::would_block; boost::asio::async_write (_socket, boost::asio::buffer (data, size), boost::lambda::var(ec) = boost::lambda::_1); - + do { _io_service.run_one (); } while (ec == boost::asio::error::would_block); @@ -110,7 +110,7 @@ Socket::read (uint8_t* data, int size) do { _io_service.run_one (); } while (ec == boost::asio::error::would_block); - + if (ec) { throw NetworkError (String::compose (_("error during async_read (%1)"), ec.value ())); } diff --git a/src/lib/dcpomatic_socket.h b/src/lib/dcpomatic_socket.h index 82ca5ff69..9e81faa0c 100644 --- a/src/lib/dcpomatic_socket.h +++ b/src/lib/dcpomatic_socket.h @@ -40,10 +40,10 @@ public: void write (uint32_t n); void write (uint8_t const * data, int size); - + void read (uint8_t* data, int size); uint32_t read_uint32 (); - + private: void check (); diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 0b78c5390..df9c46c71 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -62,7 +62,7 @@ public: /* Explicit conversion from type O */ Time (Time<O, S> d, FrameRateChange f); - + Type get () const { return _t; } @@ -144,7 +144,7 @@ public: to a frame boundary at the start rather than the end. */ int64_t ff = frames (r); - + h = ff / (3600 * r); ff -= h * 3600 * r; m = ff / (60 * r); @@ -173,7 +173,7 @@ public: return o.str (); } - + static Time<S, O> from_seconds (double s) { return Time<S, O> (s * HZ); } @@ -191,14 +191,14 @@ public: static Time<S, O> min () { return Time<S, O> (-INT64_MAX); } - + static Time<S, O> max () { return Time<S, O> (INT64_MAX); } - + private: friend struct dcptime_round_up_test; - + Type _t; static const int HZ = 96000; }; @@ -223,7 +223,7 @@ class ContentTimePeriod { public: ContentTimePeriod () {} - + ContentTimePeriod (ContentTime f, ContentTime t) : from (f) , to (t) diff --git a/src/lib/decoder.h b/src/lib/decoder.h index c5a359e1a..c93069882 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -40,9 +40,9 @@ class Decoder : public boost::noncopyable public: virtual ~Decoder () {} -protected: +protected: friend class AudioDecoderStream; - + /** Seek so that the next pass() will yield the next thing * (video/sound frame, subtitle etc.) at or after the requested * time. Pass accurate = true to try harder to ensure that, at worst, diff --git a/src/lib/dolby_cp750.cc b/src/lib/dolby_cp750.cc index 317d129d9..35f044630 100644 --- a/src/lib/dolby_cp750.cc +++ b/src/lib/dolby_cp750.cc @@ -39,7 +39,7 @@ DolbyCP750::db_for_fader_change (float from, float to) const float const t = min (to, 4.0f); db += (t - from) * 20; } - + if (to > 4) { float const t = max (from, 4.0f); db += (to - t) * 3.33333333333333333; diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index 776ccd118..93e15031d 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -117,7 +117,7 @@ Encoder::end () } lock.unlock (); - + terminate_threads (); LOG_GENERAL (N_("Mopping up %1"), _queue.size()); @@ -144,7 +144,7 @@ Encoder::end () LOG_ERROR (N_("Local encode failed (%1)"), e.what ()); } } -} +} /** @return an estimate of the current number of frames we are encoding per second, * or 0 if not known. @@ -178,7 +178,7 @@ void Encoder::frame_done () { boost::mutex::scoped_lock lock (_state_mutex); - + struct timeval tv; gettimeofday (&tv, 0); _time_history.push_front (tv); @@ -194,7 +194,7 @@ void Encoder::enqueue (shared_ptr<PlayerVideo> pv) { _waker.nudge (); - + boost::mutex::scoped_lock lock (_mutex); /* XXX: discard 3D here if required */ @@ -283,7 +283,7 @@ try encodings. */ int remote_backoff = 0; - + while (true) { LOG_TIMING ("[%1] encoder thread sleeps", boost::this_thread::get_id()); @@ -300,7 +300,7 @@ try shared_ptr<DCPVideo> vf = _queue.front (); LOG_TIMING ("[%1] encoder thread pops frame %2 (%3) from queue", boost::this_thread::get_id(), vf->index(), vf->eyes ()); _queue.pop_front (); - + lock.unlock (); optional<Data> encoded; @@ -309,14 +309,14 @@ try if (server) { try { encoded = vf->encode_remotely (server.get ()); - + if (remote_backoff > 0) { LOG_GENERAL ("%1 was lost, but now she is found; removing backoff", server->host_name ()); } - + /* This job succeeded, so remove any backoff */ remote_backoff = 0; - + } catch (std::exception& e) { if (remote_backoff < 60) { /* back off more */ @@ -327,7 +327,7 @@ try vf->index(), server->host_name(), e.what(), remote_backoff ); } - + } else { try { LOG_TIMING ("[%1] encoder thread begins local encode of %2", boost::this_thread::get_id(), vf->index()); diff --git a/src/lib/encoder.h b/src/lib/encoder.h index 0e2d30654..6bbdda4c5 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -77,9 +77,9 @@ public: int video_frames_out () const; private: - + void frame_done (); - + void encoder_thread (boost::optional<ServerDescription>); void terminate_threads (); void add_worker_threads (ServerDescription); diff --git a/src/lib/environment_info.cc b/src/lib/environment_info.cc index d10e23727..364973ff8 100644 --- a/src/lib/environment_info.cc +++ b/src/lib/environment_info.cc @@ -109,7 +109,7 @@ environment_info (shared_ptr<Log> log) info.dwOSVersionInfoSize = sizeof (info); GetVersionEx (&info); LOG_GENERAL ("Windows version %1.%2.%3 SP %4", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber, info.szCSDVersion); -#endif +#endif #if __GNUC__ #if __x86_64__ @@ -118,7 +118,7 @@ environment_info (shared_ptr<Log> log) LOG_GENERAL_NC ("Built for 32-bit"); #endif #endif - + LOG_GENERAL ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ()); list<pair<string, string> > const m = mount_info (); for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) { diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index c4c3d0815..399915253 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -47,7 +47,7 @@ ReadFileError::ReadFileError (boost::filesystem::path f, int e) WriteFileError::WriteFileError (boost::filesystem::path f, int e) : FileError (String::compose (_("could not write to file %1 (%2)"), f.string(), strerror (e)), f) { - + } MissingSettingError::MissingSettingError (string s) @@ -65,7 +65,7 @@ PixelFormatError::PixelFormatError (string o, AVPixelFormat f) SubRipError::SubRipError (string saw, string expecting, boost::filesystem::path f) : FileError (String::compose (_("Error in SubRip file: saw %1 while expecting %2"), saw.empty() ? "[nothing]" : saw, expecting), f) { - + } InvalidSignerError::InvalidSignerError () diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 96dc816ec..268e8c36d 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -296,8 +296,8 @@ public: } } -protected: - +protected: + void store_current () { boost::mutex::scoped_lock lm (_mutex); _exception = boost::current_exception (); diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 8764933e3..f5d114e8f 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -85,14 +85,14 @@ FFmpeg::setup_general () _avio_context = avio_alloc_context (_avio_buffer, _avio_buffer_size, 0, this, avio_read_wrapper, 0, avio_seek_wrapper); _format_context = avformat_alloc_context (); _format_context->pb = _avio_context; - + AVDictionary* options = 0; /* These durations are in microseconds, and represent how far into the content file we will look for streams. */ av_dict_set (&options, "analyzeduration", raw_convert<string> (5 * 60 * 1000000).c_str(), 0); av_dict_set (&options, "probesize", raw_convert<string> (5 * 60 * 1000000).c_str(), 0); - + if (avformat_open_input (&_format_context, 0, 0, &options) < 0) { throw OpenFileError (_ffmpeg_content->path(0).string ()); } @@ -126,8 +126,8 @@ FFmpeg::setup_general () */ if (_video_stream == -1 && video_stream_undefined_frame_rate != -1) { _video_stream = video_stream_undefined_frame_rate; - } - + } + if (_video_stream < 0) { throw DecodeError (N_("could not find video stream")); } @@ -146,7 +146,7 @@ FFmpeg::setup_general () } } } - + if (duplicates) { /* Put in our own IDs */ for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { @@ -167,7 +167,7 @@ FFmpeg::setup_decoders () for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { AVCodecContext* context = _format_context->streams[i]->codec; - + AVCodec* codec = avcodec_find_decoder (context->codec_id); if (codec) { @@ -177,7 +177,7 @@ FFmpeg::setup_decoders () */ AVDictionary* options = 0; av_dict_set (&options, "disable_footer", "1", 0); - + if (avcodec_open2 (context, codec, &options) < 0) { throw DecodeError (N_("could not open decoder")); } @@ -199,7 +199,7 @@ FFmpeg::subtitle_codec_context () const if (!_ffmpeg_content->subtitle_stream ()) { return 0; } - + return _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; } @@ -215,6 +215,6 @@ FFmpeg::avio_seek (int64_t const pos, int whence) if (whence == AVSEEK_SIZE) { return _file_group.length (); } - + return _file_group.seek (pos, whence); } diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 835136c75..4299edc28 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -56,14 +56,14 @@ public: protected: AVCodecContext* video_codec_context () const; AVCodecContext* subtitle_codec_context () const; - + boost::shared_ptr<const FFmpegContent> _ffmpeg_content; uint8_t* _avio_buffer; int _avio_buffer_size; AVIOContext* _avio_context; FileGroup _file_group; - + AVFormatContext* _format_context; AVPacket _packet; AVFrame* _frame; diff --git a/src/lib/ffmpeg_audio_stream.h b/src/lib/ffmpeg_audio_stream.h index 7fe3c4fda..84882e89c 100644 --- a/src/lib/ffmpeg_audio_stream.h +++ b/src/lib/ffmpeg_audio_stream.h @@ -37,7 +37,7 @@ public: void as_xml (xmlpp::Node *) const; /* XXX: should probably be locked */ - + boost::optional<ContentTime> first_audio; private: diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 1793b8998..c4fc36357 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -172,7 +172,7 @@ FFmpegContent::examine (shared_ptr<Job> job) if (!_subtitle_streams.empty ()) { _subtitle_stream = _subtitle_streams.front (); } - + _audio_streams = examiner->audio_streams (); if (!_audio_streams.empty ()) { @@ -214,7 +214,7 @@ FFmpegContent::technical_summary () const } string filt = Filter::ffmpeg_string (_filters); - + return Content::technical_summary() + " - " + VideoContent::technical_summary() + " - " + AudioContent::technical_summary() + " - " @@ -321,7 +321,7 @@ vector<AudioStreamPtr> FFmpegContent::audio_streams () const { boost::mutex::scoped_lock lm (_mutex); - + vector<AudioStreamPtr> s; copy (_audio_streams.begin(), _audio_streams.end(), back_inserter (s)); return s; diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 04523b117..5c2b5496d 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -54,7 +54,7 @@ public: boost::shared_ptr<FFmpegContent> shared_from_this () { return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ()); } - + void examine (boost::shared_ptr<Job>); std::string summary () const; std::string technical_summary () const; @@ -65,7 +65,7 @@ public: /* VideoContent */ void set_default_colour_conversion (); - + /* AudioContent */ std::vector<AudioStreamPtr> audio_streams () const; @@ -73,7 +73,7 @@ public: bool has_subtitles () const; void set_filters (std::vector<Filter const *> const &); - + std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const { boost::mutex::scoped_lock lm (_mutex); return _subtitle_streams; @@ -106,7 +106,7 @@ public: private: friend struct ffmpeg_pts_offset_test; friend struct audio_sampling_rate_test; - + std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams; boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream; std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 4ca06329b..0c9225a6a 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -124,14 +124,14 @@ void FFmpegDecoder::flush () { /* Get any remaining frames */ - + _packet.data = 0; _packet.size = 0; - + /* XXX: should we reset _packet.data and size after each *_decode_* call? */ - + while (decode_video_packet ()) {} - + decode_audio_packet (); AudioDecoder::flush (); } @@ -152,7 +152,7 @@ FFmpegDecoder::pass () av_strerror (r, buf, sizeof(buf)); LOG_ERROR (N_("error on av_read_frame (%1) (%2)"), buf, r); } - + flush (); return true; } @@ -206,7 +206,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream, uint8_t } } break; - + case AV_SAMPLE_FMT_S16: { int16_t* p = reinterpret_cast<int16_t *> (data[0]); @@ -234,7 +234,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream, uint8_t } } break; - + case AV_SAMPLE_FMT_S32: { int32_t* p = reinterpret_cast<int32_t *> (data[0]); @@ -268,7 +268,7 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> stream, uint8_t } } break; - + case AV_SAMPLE_FMT_FLTP: { float** p = reinterpret_cast<float**> (data); @@ -314,7 +314,7 @@ FFmpegDecoder::seek (ContentTime time, bool accurate) /* XXX: it seems debatable whether PTS should be used here... http://www.mjbshaw.com/2012/04/seeking-in-ffmpeg-know-your-timestamp.html */ - + ContentTime u = time - _pts_offset; if (u < ContentTime ()) { u = ContentTime (); @@ -324,7 +324,7 @@ FFmpegDecoder::seek (ContentTime time, bool accurate) avcodec_flush_buffers (video_codec_context()); /* XXX: should be flushing audio buffers? */ - + if (subtitle_codec_context ()) { avcodec_flush_buffers (subtitle_codec_context ()); } @@ -336,7 +336,7 @@ FFmpegDecoder::decode_audio_packet () /* Audio packets can contain multiple frames, so we may have to call avcodec_decode_audio4 several times. */ - + AVPacket copy_packet = _packet; /* XXX: inefficient */ @@ -350,7 +350,7 @@ FFmpegDecoder::decode_audio_packet () /* The packet's stream may not be an audio one; just ignore it in this method if so */ return; } - + while (copy_packet.size > 0) { int frame_finished; @@ -376,14 +376,14 @@ FFmpegDecoder::decode_audio_packet () av_frame_get_best_effort_timestamp (_frame) * av_q2d ((*stream)->stream (_format_context)->time_base)) + _pts_offset; - + int const data_size = av_samples_get_buffer_size ( 0, (*stream)->stream(_format_context)->codec->channels, _frame->nb_samples, audio_sample_format (*stream), 1 ); audio (*stream, deinterleave_audio (*stream, _frame->data, data_size), ct); } - + copy_packet.data += decode_result; copy_packet.size -= decode_result; } @@ -400,7 +400,7 @@ FFmpegDecoder::decode_video_packet () boost::mutex::scoped_lock lm (_filter_graphs_mutex); shared_ptr<FilterGraph> graph; - + list<shared_ptr<FilterGraph> >::iterator i = _filter_graphs.begin(); while (i != _filter_graphs.end() && !(*i)->can_process (dcp::Size (_frame->width, _frame->height), (AVPixelFormat) _frame->format)) { ++i; @@ -419,7 +419,7 @@ FFmpegDecoder::decode_video_packet () for (list<pair<shared_ptr<Image>, int64_t> >::iterator i = images.begin(); i != images.end(); ++i) { shared_ptr<Image> image = i->first; - + if (i->second != AV_NOPTS_VALUE) { double const pts = i->second * av_q2d (_format_context->streams[_video_stream]->time_base) + _pts_offset.seconds (); video ( @@ -433,7 +433,7 @@ FFmpegDecoder::decode_video_packet () return true; } - + void FFmpegDecoder::decode_subtitle_packet () { @@ -442,7 +442,7 @@ FFmpegDecoder::decode_subtitle_packet () if (avcodec_decode_subtitle2 (subtitle_codec_context(), &sub, &got_subtitle, &_packet) < 0 || !got_subtitle) { return; } - + if (sub.num_rects <= 0) { /* Sometimes we get an empty AVSubtitle, which is used by some codecs to indicate that the previous subtitle should stop. We can ignore it here. @@ -465,7 +465,7 @@ FFmpegDecoder::decode_subtitle_packet () /* We have to look up the `to' time in the stream's records */ period.to = ffmpeg_content()->subtitle_stream()->find_subtitle_to (sub_period.from); } - + AVSubtitleRect const * rect = sub.rects[0]; switch (rect->type) { @@ -481,7 +481,7 @@ FFmpegDecoder::decode_subtitle_packet () cout << "XXX: SUBTITLE_ASS " << rect->ass << "\n"; break; } - + avsubtitle_free (&sub); } @@ -504,7 +504,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP G, third B, fourth A. */ shared_ptr<Image> image (new Image (PIX_FMT_RGBA, dcp::Size (rect->w, rect->h), true)); - + /* Start of the first line in the subtitle */ uint8_t* sub_p = rect->pict.data[0]; /* sub_p looks up into a BGRA palette which is here @@ -513,7 +513,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP uint32_t const * palette = (uint32_t *) rect->pict.data[1]; /* Start of the output data */ uint32_t* out_p = (uint32_t *) image->data()[0]; - + for (int y = 0; y < rect->h; ++y) { uint8_t* sub_line_p = sub_p; uint32_t* out_line_p = out_p; @@ -524,7 +524,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP sub_p += rect->pict.linesize[0]; out_p += image->stride()[0] / sizeof (uint32_t); } - + dcp::Size const vs = _ffmpeg_content->video_size (); dcpomatic::Rect<double> const scaled_rect ( static_cast<double> (rect->x) / vs.width, @@ -532,7 +532,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP static_cast<double> (rect->w) / vs.width, static_cast<double> (rect->h) / vs.height ); - + image_subtitle (period, image, scaled_rect); } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 41af74447..60217b073 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -72,9 +72,9 @@ private: std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const; std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const; - + boost::shared_ptr<Log> _log; - + std::list<boost::shared_ptr<FilterGraph> > _filter_graphs; boost::mutex _filter_graphs_mutex; diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 6d5e33238..16a89faa7 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -56,7 +56,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo if (s->codec->channel_layout == 0) { s->codec->channel_layout = av_get_default_channel_layout (s->codec->channels); } - + _audio_streams.push_back ( shared_ptr<FFmpegAudioStream> ( new FFmpegAudioStream (audio_stream_name (s), s->id, s->codec->sample_rate, s->codec->channels) @@ -105,7 +105,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo if (_packet.stream_index == _video_stream) { video_packet (context); } - + for (size_t i = 0; i < _audio_streams.size(); ++i) { if (_audio_streams[i]->uses_index (_format_context, _packet.stream_index)) { audio_packet (context, _audio_streams[i]); @@ -180,7 +180,7 @@ optional<ContentTime> FFmpegExaminer::frame_time (AVStream* s) const { optional<ContentTime> t; - + int64_t const bet = av_frame_get_best_effort_timestamp (_frame); if (bet != AV_NOPTS_VALUE) { t = ContentTime::from_seconds (bet * av_q2d (s->time_base)); @@ -263,7 +263,7 @@ FFmpegExaminer::stream_name (AVStream* s) const if (lang) { n << lang->value; } - + AVDictionaryEntry const * title = av_dict_get (s->metadata, "title", 0, 0); if (title) { if (!n.str().empty()) { diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index d6149446a..7b64b508a 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -28,7 +28,7 @@ class FFmpegExaminer : public FFmpeg, public VideoExaminer { public: FFmpegExaminer (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Job> job = boost::shared_ptr<Job> ()); - + boost::optional<float> video_frame_rate () const; dcp::Size video_size () const; Frame video_length () const; @@ -37,7 +37,7 @@ public: std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const { return _subtitle_streams; } - + std::vector<boost::shared_ptr<FFmpegAudioStream> > audio_streams () const { return _audio_streams; } @@ -45,12 +45,12 @@ public: boost::optional<ContentTime> first_video () const { return _first_video; } - + private: void video_packet (AVCodecContext *); void audio_packet (AVCodecContext *, boost::shared_ptr<FFmpegAudioStream>); void subtitle_packet (AVCodecContext *, boost::shared_ptr<FFmpegSubtitleStream>); - + std::string stream_name (AVStream* s) const; std::string audio_stream_name (AVStream* s) const; std::string subtitle_stream_name (AVStream* s) const; diff --git a/src/lib/ffmpeg_stream.h b/src/lib/ffmpeg_stream.h index 6479bd70d..0930ea2b4 100644 --- a/src/lib/ffmpeg_stream.h +++ b/src/lib/ffmpeg_stream.h @@ -33,7 +33,7 @@ public: : name (n) , _id (i) {} - + FFmpegStream (cxml::ConstNodePtr); void as_xml (xmlpp::Node *) const; @@ -57,7 +57,7 @@ public: friend bool operator== (FFmpegStream const & a, FFmpegStream const & b); friend bool operator!= (FFmpegStream const & a, FFmpegStream const & b); - + private: int _id; }; diff --git a/src/lib/ffmpeg_subtitle_stream.cc b/src/lib/ffmpeg_subtitle_stream.cc index b322428b9..413477865 100644 --- a/src/lib/ffmpeg_subtitle_stream.cc +++ b/src/lib/ffmpeg_subtitle_stream.cc @@ -62,11 +62,11 @@ FFmpegSubtitleStream::add_subtitle (ContentTimePeriod period) _subtitles[period.from] = period.to; } -list<ContentTimePeriod> +list<ContentTimePeriod> FFmpegSubtitleStream::subtitles_during (ContentTimePeriod period, bool starting) const { list<ContentTimePeriod> d; - + /* XXX: inefficient */ for (map<ContentTime, ContentTime>::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { if ((starting && period.contains (i->first)) || (!starting && period.overlaps (ContentTimePeriod (i->first, i->second)))) { diff --git a/src/lib/ffmpeg_subtitle_stream.h b/src/lib/ffmpeg_subtitle_stream.h index 3ed931b8c..a39b10ffd 100644 --- a/src/lib/ffmpeg_subtitle_stream.h +++ b/src/lib/ffmpeg_subtitle_stream.h @@ -26,7 +26,7 @@ public: FFmpegSubtitleStream (std::string n, int i) : FFmpegStream (n, i) {} - + FFmpegSubtitleStream (cxml::ConstNodePtr); void as_xml (xmlpp::Node *) const; diff --git a/src/lib/file_group.cc b/src/lib/file_group.cc index 9c8d43204..6f6a5a916 100644 --- a/src/lib/file_group.cc +++ b/src/lib/file_group.cc @@ -82,7 +82,7 @@ FileGroup::ensure_open_path (size_t p) const /* Already open */ return; } - + if (_current_file) { fclose (_current_file); } @@ -111,9 +111,9 @@ FileGroup::seek (int64_t pos, int whence) const } #ifdef DCPOMATIC_WINDOWS full_pos += _ftelli64 (_current_file); -#else +#else full_pos += ftell (_current_file); -#endif +#endif full_pos += pos; break; case SEEK_END: diff --git a/src/lib/film.cc b/src/lib/film.cc index 5ec5fbc2f..66f1de868 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -137,11 +137,11 @@ Film::Film (boost::filesystem::path dir, bool log) _playlist_changed_connection = _playlist->Changed.connect (bind (&Film::playlist_changed, this)); _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2, _3)); - + /* Make state.directory a complete path without ..s (where possible) (Code swiped from Adam Bowen on stackoverflow) */ - + boost::filesystem::path p (boost::filesystem::system_complete (dir)); boost::filesystem::path result; for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) { @@ -171,7 +171,7 @@ Film::~Film () for (list<boost::signals2::connection>::const_iterator i = _job_connections.begin(); i != _job_connections.end(); ++i) { i->disconnect (); } -} +} string Film::video_identifier () const @@ -180,7 +180,7 @@ Film::video_identifier () const SafeStringStream s; s.imbue (std::locale::classic ()); - + s << container()->id() << "_" << resolution_to_string (_resolution) << "_" << _playlist->video_identifier() @@ -209,7 +209,7 @@ Film::video_identifier () const return s.str (); } - + /** @return The file to write video frame info to */ boost::filesystem::path Film::info_file () const @@ -259,7 +259,7 @@ Film::audio_analysis_path () const if (!ac) { continue; } - + digester.add (ac->digest ()); digester.add (ac->audio_mapping().digest ()); digester.add (ac->audio_gain ()); @@ -278,7 +278,7 @@ void Film::make_dcp () { set_isdcf_date_today (); - + if (dcp_name().find ("/") != string::npos) { throw BadSettingError (_("name"), _("cannot contain slashes")); } @@ -292,7 +292,7 @@ Film::make_dcp () LOG_GENERAL ("DCP video rate %1 fps", video_frame_rate()); LOG_GENERAL ("%1 threads", Config::instance()->num_local_encoding_threads()); LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth()); - + if (container() == 0) { throw MissingSettingError (_("container")); } @@ -386,7 +386,7 @@ Film::read_metadata () if (_state_version > current_state_version) { throw StringError (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!")); } - + _name = f.string_child ("Name"); if (_state_version >= 9) { _use_isdcf_name = f.bool_child ("UseISDCFName"); @@ -460,9 +460,9 @@ Film::dir (boost::filesystem::path d) const boost::filesystem::path p; p /= _directory; p /= d; - + boost::filesystem::create_directories (p); - + return p; } @@ -477,7 +477,7 @@ Film::file (boost::filesystem::path f) const p /= f; boost::filesystem::create_directories (p.parent_path ()); - + return p; } @@ -494,7 +494,7 @@ Film::isdcf_name (bool if_created_now) const split (words, raw_name, is_any_of (" ")); string fixed_name; - + /* Add each word to fixed_name */ for (vector<string>::const_iterator i = words.begin(); i != words.end(); ++i) { string w = *i; @@ -509,7 +509,7 @@ Film::isdcf_name (bool if_created_now) const ++caps; } } - + /* If w is all caps make the rest of it lower case, otherwise leave it alone. */ @@ -540,15 +540,15 @@ Film::isdcf_name (bool if_created_now) const if (dm.temp_version) { d << "-Temp"; } - + if (dm.pre_release) { d << "-Pre"; } - + if (dm.red_band) { d << "-RedBand"; } - + if (!dm.chain.empty ()) { d << "-" << dm.chain; } @@ -568,13 +568,13 @@ Film::isdcf_name (bool if_created_now) const if (video_frame_rate() != 24) { d << "-" << video_frame_rate(); } - + if (container()) { d << "_" << container()->isdcf_name(); } ContentList cl = content (); - + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ @@ -592,7 +592,7 @@ Film::isdcf_name (bool if_created_now) const break; } } - + if (content_ratio && content_ratio != container()) { d << "-" << content_ratio->isdcf_name(); } @@ -637,18 +637,18 @@ Film::isdcf_name (bool if_created_now) const copy (c.begin(), c.end(), back_inserter (mapped)); } } - + mapped.sort (); mapped.unique (); - + /* Count them */ - + for (list<int>::const_iterator i = mapped.begin(); i != mapped.end(); ++i) { if (*i >= audio_channels()) { /* This channel is mapped but is not included in the DCP */ continue; } - + if (static_cast<dcp::Channel> (*i) == dcp::LFE) { ++lfe; } else { @@ -656,7 +656,7 @@ Film::isdcf_name (bool if_created_now) const } } } - + if (non_lfe) { d << "_" << non_lfe << lfe; } @@ -664,7 +664,7 @@ Film::isdcf_name (bool if_created_now) const /* XXX: HI/VI */ d << "_" << resolution_to_string (_resolution); - + if (!dm.studio.empty ()) { d << "_" << dm.studio; } @@ -684,7 +684,7 @@ Film::isdcf_name (bool if_created_now) const } else { d << "_SMPTE"; } - + if (three_d ()) { d << "-3D"; } @@ -718,7 +718,7 @@ Film::dcp_name (bool if_created_now) const filtered += unfiltered[i]; } } - + return filtered; } @@ -863,7 +863,7 @@ Film::j2c_path (int f, Eyes e, bool t) const } else if (e == EYES_RIGHT) { s << ".R"; } - + s << ".j2c"; if (t) { @@ -879,7 +879,7 @@ vector<CPLSummary> Film::cpls () const { vector<CPLSummary> out; - + boost::filesystem::path const dir = directory (); for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator(dir); i != boost::filesystem::directory_iterator(); ++i) { if ( @@ -903,7 +903,7 @@ Film::cpls () const } } } - + return out; } @@ -947,13 +947,13 @@ Film::examine_and_add_content (shared_ptr<Content> c) if (dynamic_pointer_cast<FFmpegContent> (c)) { run_ffprobe (c->path(0), file ("ffprobe.log"), _log); } - + shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c)); _job_connections.push_back ( j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c))) ); - + JobManager::instance()->add (j); } @@ -964,7 +964,7 @@ Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c) if (!job || !job->finished_ok ()) { return; } - + shared_ptr<Content> content = c.lock (); if (content) { add_content (content); @@ -1035,7 +1035,7 @@ Film::playlist_changed () { signal_changed (CONTENT); signal_changed (NAME); -} +} int Film::audio_frame_rate () const @@ -1088,7 +1088,7 @@ Film::make_kdm ( if (!signer->valid ()) { throw InvalidSignerError (); } - + return dcp::DecryptedKDM ( cpl, key(), from, until, "DCP-o-matic", cpl->content_title_text(), dcp::LocalTime().as_string() ).encrypt (signer, target, formulation); @@ -1162,7 +1162,7 @@ string Film::subtitle_language () const { set<string> languages; - + ContentList cl = content (); BOOST_FOREACH (shared_ptr<Content>& c, cl) { shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c); @@ -1215,7 +1215,7 @@ Film::audio_output_names () const if (audio_processor ()) { return audio_processor()->input_names (); } - + vector<string> n; n.push_back (_("L")); n.push_back (_("R")); diff --git a/src/lib/film.h b/src/lib/film.h index f268bc5b7..5e4c01c86 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -105,7 +105,7 @@ public: uint64_t required_disk_space () const; bool should_be_enough_disk_space (double& required, double& available, bool& can_hard_link) const; - + /* Proxies for some Playlist methods */ ContentList content () const; @@ -121,7 +121,7 @@ public: dcp::LocalTime until, dcp::Formulation formulation ) const; - + std::list<dcp::EncryptedKDM> make_kdms ( std::list<boost::shared_ptr<Screen> >, boost::filesystem::path cpl_file, @@ -140,7 +140,7 @@ public: std::vector<std::string> audio_output_names () const; void repeat_content (ContentList, int); - + /** Identifiers for the parts of our state; used for signalling changes. */ @@ -200,7 +200,7 @@ public: bool is_signed () const { return _signed; } - + bool encrypted () const { return _encrypted; } @@ -245,7 +245,7 @@ public: AudioProcessor const * audio_processor () const { return _audio_processor; } - + /* SET */ @@ -304,7 +304,7 @@ private: * must not be relative. */ boost::filesystem::path _directory; - + /** Name for DCP-o-matic */ std::string _name; /** True if a auto-generated ISDCF-compliant name should be used for our DCP */ diff --git a/src/lib/filter.cc b/src/lib/filter.cc index a7dd9c5ce..c9876c05b 100644 --- a/src/lib/filter.cc +++ b/src/lib/filter.cc @@ -61,7 +61,7 @@ void Filter::setup_filters () { /* Note: "none" is a magic id name, so don't use it here */ - + maybe_add (N_("mcdeint"), _("Motion compensating deinterlacer"), _("De-interlacing"), N_("mcdeint")); maybe_add (N_("kerndeint"), _("Kernel deinterlacer"), _("De-interlacing"), N_("kerndeint")); maybe_add (N_("yadif"), _("Yet Another Deinterlacing Filter"), _("De-interlacing"), N_("yadif")); diff --git a/src/lib/filter.h b/src/lib/filter.h index 66ecc4308..39687fcd4 100644 --- a/src/lib/filter.h +++ b/src/lib/filter.h @@ -54,11 +54,11 @@ public: std::string vf () const { return _vf; } - + std::string category () const { return _category; } - + static std::vector<Filter const *> all (); static Filter const * from_id (std::string); static void setup_filters (); diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc index 9f80118bd..da7b04133 100644 --- a/src/lib/filter_graph.cc +++ b/src/lib/filter_graph.cc @@ -67,7 +67,7 @@ FilterGraph::FilterGraph (shared_ptr<const FFmpegContent> content, dcp::Size s, } _frame = av_frame_alloc (); - + AVFilterGraph* graph = avfilter_graph_alloc(); if (graph == 0) { throw DecodeError (N_("could not create filter graph.")); @@ -98,7 +98,7 @@ FilterGraph::FilterGraph (shared_ptr<const FFmpegContent> content, dcp::Size s, pixel_fmts[0] = _pixel_format; pixel_fmts[1] = PIX_FMT_NONE; sink_params->pixel_fmts = pixel_fmts; - + if (avfilter_graph_create_filter (&_buffer_sink_context, buffer_sink, N_("out"), 0, sink_params, graph) < 0) { throw DecodeError (N_("could not create buffer sink.")); } @@ -120,7 +120,7 @@ FilterGraph::FilterGraph (shared_ptr<const FFmpegContent> content, dcp::Size s, if (avfilter_graph_parse (graph, filters.c_str(), inputs, outputs, 0) < 0) { throw DecodeError (N_("could not set up filter graph.")); } - + if (avfilter_graph_config (graph, 0) < 0) { throw DecodeError (N_("could not configure filter graph.")); } @@ -148,17 +148,17 @@ FilterGraph::process (AVFrame* frame) if (r < 0) { throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)."), r)); } - + while (true) { if (av_buffersink_get_frame (_buffer_sink_context, _frame) < 0) { break; } - + images.push_back (make_pair (shared_ptr<Image> (new Image (_frame)), av_frame_get_best_effort_timestamp (_frame))); av_frame_unref (_frame); } } - + return images; } diff --git a/src/lib/font.cc b/src/lib/font.cc index 0e1ad85cd..d729c2696 100644 --- a/src/lib/font.cc +++ b/src/lib/font.cc @@ -24,7 +24,7 @@ Font::Font (cxml::NodePtr node) : _id (node->string_child ("Id")) , _file (node->optional_string_child ("File")) { - + } void diff --git a/src/lib/font.h b/src/lib/font.h index 0dd63448e..ca7650cc1 100644 --- a/src/lib/font.h +++ b/src/lib/font.h @@ -51,7 +51,7 @@ public: boost::signals2::signal<void()> Changed; -private: +private: /** Font ID, used to describe it in the subtitle content */ std::string _id; boost::optional<boost::filesystem::path> _file; diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc index 31fce6b6d..d327f8e31 100644 --- a/src/lib/frame_rate_change.cc +++ b/src/lib/frame_rate_change.cc @@ -37,14 +37,14 @@ about_equal (float a, float b) = Ff + Fd - Ff frames = Fd frames = Fd/f seconds - + So if we accept a difference of 1 frame, ie 1/f seconds, we can say that 1/f = Fd/f ie 1 = Fd ie d = 1/F - + So for a 3hr film, ie F = 3 * 60 * 60 = 10800, the acceptable FPS error is 1/F ~= 0.0001 ~= 10-e4 */ @@ -81,7 +81,7 @@ string FrameRateChange::description () const { string description; - + if (!skip && repeat == 1 && !change_speed) { description = _("Content and DCP have the same rate.\n"); } else { diff --git a/src/lib/image.cc b/src/lib/image.cc index d5d3167cd..c403b61ab 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -56,7 +56,7 @@ Image::line_factor (int n) const if (!d) { throw PixelFormatError ("lines()", _pixel_format); } - + return pow (2.0f, d->log2_chroma_h); } @@ -81,7 +81,7 @@ Image::components () const if ((d->flags & PIX_FMT_PLANAR) == 0) { return 1; } - + return d->nb_components; } @@ -129,7 +129,7 @@ Image::crop_scale_window ( sws_getCoefficients (lut[yuv_to_rgb]), 0, 0, 1 << 16, 1 << 16 ); - + /* Prepare input data pointers with crop */ uint8_t* scale_in_data[components()]; for (int c = 0; c < components(); ++c) { @@ -153,7 +153,7 @@ Image::crop_scale_window ( sws_freeContext (scale_context); - return out; + return out; } shared_ptr<Image> @@ -184,7 +184,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo sws_getCoefficients (lut[yuv_to_rgb]), 0, 0, 1 << 16, 1 << 16 ); - + sws_scale ( scale_context, data(), stride(), @@ -263,7 +263,7 @@ Image::make_black () static uint16_t const ten_bit_uv = (1 << 9) - 1; /* U/V black value for 16-bit colour */ static uint16_t const sixteen_bit_uv = (1 << 15) - 1; - + switch (_pixel_format) { case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: @@ -291,7 +291,7 @@ Image::make_black () case PIX_FMT_YUV444P9BE: yuv_16_black (swap_16 (nine_bit_uv), false); break; - + case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV444P10LE: yuv_16_black (ten_bit_uv, false); @@ -301,7 +301,7 @@ Image::make_black () case PIX_FMT_YUV444P16LE: yuv_16_black (sixteen_bit_uv, false); break; - + case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV422P10BE: yuv_16_black (swap_16 (ten_bit_uv), false); @@ -312,31 +312,31 @@ Image::make_black () case AV_PIX_FMT_YUVA444P9BE: yuv_16_black (swap_16 (nine_bit_uv), true); break; - + case AV_PIX_FMT_YUVA420P9LE: case AV_PIX_FMT_YUVA422P9LE: case AV_PIX_FMT_YUVA444P9LE: yuv_16_black (nine_bit_uv, true); break; - + case AV_PIX_FMT_YUVA420P10BE: case AV_PIX_FMT_YUVA422P10BE: case AV_PIX_FMT_YUVA444P10BE: yuv_16_black (swap_16 (ten_bit_uv), true); break; - + case AV_PIX_FMT_YUVA420P10LE: case AV_PIX_FMT_YUVA422P10LE: case AV_PIX_FMT_YUVA444P10LE: yuv_16_black (ten_bit_uv, true); break; - + case AV_PIX_FMT_YUVA420P16BE: case AV_PIX_FMT_YUVA422P16BE: case AV_PIX_FMT_YUVA444P16BE: yuv_16_black (swap_16 (sixteen_bit_uv), true); break; - + case AV_PIX_FMT_YUVA420P16LE: case AV_PIX_FMT_YUVA422P16LE: case AV_PIX_FMT_YUVA444P16LE: @@ -419,7 +419,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) tp[0] = op[0] * alpha + tp[0] * (1 - alpha); tp[1] = op[1] * alpha + tp[1] * (1 - alpha); tp[2] = op[2] * alpha + tp[2] * (1 - alpha); - + tp += this_bpp; op += other_bpp; } @@ -439,7 +439,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) tp[1] = op[1] * alpha + tp[1] * (1 - alpha); tp[2] = op[2] * alpha + tp[2] * (1 - alpha); tp[3] = op[3] * alpha + tp[3] * (1 - alpha); - + tp += this_bpp; op += other_bpp; } @@ -458,7 +458,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) tp[1] = op[0] * alpha + tp[1] * (1 - alpha); tp[3] = op[1] * alpha + tp[3] * (1 - alpha); tp[5] = op[2] * alpha + tp[5] * (1 - alpha); - + tp += this_bpp; op += other_bpp; } @@ -469,7 +469,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) DCPOMATIC_ASSERT (false); } } - + void Image::copy (shared_ptr<const Image> other, Position<int> position) { @@ -483,7 +483,7 @@ Image::copy (shared_ptr<const Image> other, Position<int> position) uint8_t * const op = other->data()[0] + oy * other->stride()[0]; memcpy (tp, op, N * 3); } -} +} void Image::read_from_socket (shared_ptr<Socket> socket) @@ -534,7 +534,7 @@ Image::bytes_per_pixel (int c) const if (d->nb_components > 3) { bpp[3] = floor ((d->comp[3].depth_minus1 + 1 + 7) / 8) / pow (2.0f, d->log2_chroma_w); } - + if ((d->flags & PIX_FMT_PLANAR) == 0) { /* Not planar; sum them up */ return bpp[0] + bpp[1] + bpp[2] + bpp[3]; @@ -562,10 +562,10 @@ Image::allocate () { _data = (uint8_t **) wrapped_av_malloc (4 * sizeof (uint8_t *)); _data[0] = _data[1] = _data[2] = _data[3] = 0; - + _line_size = (int *) wrapped_av_malloc (4 * sizeof (int)); _line_size[0] = _line_size[1] = _line_size[2] = _line_size[3] = 0; - + _stride = (int *) wrapped_av_malloc (4 * sizeof (int)); _stride[0] = _stride[1] = _stride[2] = _stride[3] = 0; diff --git a/src/lib/image.h b/src/lib/image.h index 8cf4a72f7..89cd98f7b 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -47,7 +47,7 @@ public: Image (boost::shared_ptr<const Image>, bool); Image& operator= (Image const &); ~Image (); - + uint8_t * const * data () const; int * line_size () const; int const * stride () const; @@ -61,7 +61,7 @@ public: boost::shared_ptr<Image> scale (dcp::Size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat, bool aligned) const; boost::shared_ptr<Image> crop (Crop c, bool aligned) const; boost::shared_ptr<Image> crop_scale_window (Crop c, dcp::Size, dcp::Size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat, bool aligned) const; - + void make_black (); void make_transparent (); void alpha_blend (boost::shared_ptr<const Image> image, Position<int> pos); @@ -70,14 +70,14 @@ public: void read_from_socket (boost::shared_ptr<Socket>); void write_to_socket (boost::shared_ptr<Socket>) const; - + AVPixelFormat pixel_format () const { return _pixel_format; } private: friend struct pixel_formats_test; - + void allocate (); void swap (Image &); float bytes_per_pixel (int) const; diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 3f62c3ebf..920d7ae54 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -58,7 +58,7 @@ ImageContent::ImageContent (shared_ptr<const Film> film, boost::filesystem::path if (_paths.empty()) { throw FileError (_("No valid image files were found in the folder."), p); } - + sort (_paths.begin(), _paths.end(), ImageFilenameSorter ()); } @@ -73,7 +73,7 @@ ImageContent::ImageContent (shared_ptr<const Film> film, cxml::ConstNodePtr node : Content (film, node) , VideoContent (film, node, version) { - + } string @@ -120,7 +120,7 @@ ImageContent::examine (shared_ptr<Job> job) shared_ptr<const Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - + shared_ptr<ImageExaminer> examiner (new ImageExaminer (film, shared_from_this(), job)); take_from_video_examiner (examiner); } @@ -168,10 +168,10 @@ ImageContent::set_video_frame_rate (float r) if (_video_frame_rate == r) { return; } - + _video_frame_rate = r; } - + signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); } diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 11c932153..4a8d91bdb 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -47,7 +47,7 @@ public: /* VideoContent */ void set_default_colour_conversion (); - + void set_video_length (Frame); bool still () const; void set_video_frame_rate (float); diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 3d3e1a55b..3d543eaf2 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -61,7 +61,7 @@ ImageDecoder::pass () _image.reset (new MagickImageProxy (path)); } } - + video (_image, _video_position); ++_video_position; return false; diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index 775496bfd..ed5ce65a7 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -37,7 +37,7 @@ public: private: bool pass (); void seek (ContentTime, bool); - + boost::shared_ptr<const ImageContent> _image_content; boost::shared_ptr<ImageProxy> _image; Frame _video_position; diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index cea5dfea7..79c9f727c 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -41,7 +41,7 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag : _film (film) , _image_content (content) { -#ifdef DCPOMATIC_IMAGE_MAGICK +#ifdef DCPOMATIC_IMAGE_MAGICK using namespace MagickCore; #endif boost::filesystem::path path = content->path(0).string (); diff --git a/src/lib/image_filename_sorter.cc b/src/lib/image_filename_sorter.cc index 0cb6adc6b..5a3e1dcec 100644 --- a/src/lib/image_filename_sorter.cc +++ b/src/lib/image_filename_sorter.cc @@ -40,7 +40,7 @@ private: boost::optional<int> extract_number (boost::filesystem::path p) { p = p.leaf (); - + std::string number; for (size_t i = 0; i < p.string().size(); ++i) { if (isdigit (p.string()[i])) { diff --git a/src/lib/image_subtitle.h b/src/lib/image_subtitle.h index b25943ae1..217f70fb2 100644 --- a/src/lib/image_subtitle.h +++ b/src/lib/image_subtitle.h @@ -31,7 +31,7 @@ public: : image (i) , rectangle (r) {} - + boost::shared_ptr<Image> image; /** Area that the subtitle covers on its corresponding video, expressed in * proportions of the image size; e.g. rectangle.x = 0.5 would mean that diff --git a/src/lib/internet.cc b/src/lib/internet.cc index b4395fd21..7bc818717 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -53,7 +53,7 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat /* Download the ZIP file to temp_zip */ CURL* curl = curl_easy_init (); curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); - + ScopedTemporary temp_zip; FILE* f = temp_zip.open ("wb"); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data); @@ -71,17 +71,17 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat } /* Open the ZIP file and read `file' out of it */ - + struct zip* zip = zip_open (temp_zip.c_str(), 0, 0); if (!zip) { return optional<string> (_("Could not open downloaded ZIP file")); } - + struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0); if (!zip_file) { return optional<string> (_("Unexpected ZIP file contents")); } - + ScopedTemporary temp_cert; f = temp_cert.open ("wb"); char buffer[4096]; @@ -93,7 +93,7 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat } } temp_cert.close (); - + load (temp_cert.file ()); return optional<string> (); } diff --git a/src/lib/isdcf_metadata.cc b/src/lib/isdcf_metadata.cc index a9d7d939e..4a0e57d27 100644 --- a/src/lib/isdcf_metadata.cc +++ b/src/lib/isdcf_metadata.cc @@ -44,7 +44,7 @@ ISDCFMetadata::ISDCFMetadata (cxml::ConstNodePtr node) , two_d_version_of_three_d (node->optional_bool_child ("TwoDVersionOfThreeD").get_value_or (false)) , mastered_luminance (node->optional_string_child ("MasteredLuminance").get_value_or ("")) { - + } void diff --git a/src/lib/isdcf_metadata.h b/src/lib/isdcf_metadata.h index 6b326ddc8..0e904238d 100644 --- a/src/lib/isdcf_metadata.h +++ b/src/lib/isdcf_metadata.h @@ -34,7 +34,7 @@ public: , red_band (false) , two_d_version_of_three_d (false) {} - + ISDCFMetadata (cxml::ConstNodePtr); void as_xml (xmlpp::Node *) const; diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index ce0b88265..991488773 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -112,7 +112,7 @@ J2KImageProxy::image (optional<dcp::NoteHandler> note) const } else { dcp::xyz_to_rgb (oj, dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note); } - + return image; } diff --git a/src/lib/j2k_image_proxy.h b/src/lib/j2k_image_proxy.h index fa2df8cd8..191d759db 100644 --- a/src/lib/j2k_image_proxy.h +++ b/src/lib/j2k_image_proxy.h @@ -40,11 +40,11 @@ public: Data j2k () const { return _data; } - + dcp::Size size () const { return _size; } - + private: Data _data; dcp::Size _size; diff --git a/src/lib/job.cc b/src/lib/job.cc index 25ff0aa4c..71e4c3446 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -86,7 +86,7 @@ Job::run_wrapper () set_error (e.what(), m); set_progress (1); set_state (FINISHED_ERROR); - + } catch (OpenFileError& e) { set_error ( @@ -106,7 +106,7 @@ Job::run_wrapper () set_error (_("Out of memory"), _("There was not enough memory to do this.")); set_progress (1); set_state (FINISHED_ERROR); - + } catch (std::exception& e) { set_error ( @@ -116,7 +116,7 @@ Job::run_wrapper () set_progress (1); set_state (FINISHED_ERROR); - + } catch (...) { set_error ( @@ -182,7 +182,7 @@ Job::paused () const boost::mutex::scoped_lock lm (_state_mutex); return _state == PAUSED; } - + /** Set the state of this job. * @param s New state. */ @@ -204,7 +204,7 @@ Job::set_state (State s) if (finished) { emit (boost::bind (boost::ref (Finished))); - } + } } /** @return DCPTime (in seconds) that this sub-job has been running */ @@ -214,7 +214,7 @@ Job::elapsed_time () const if (_start_time == 0) { return 0; } - + return time (0) - _start_time; } @@ -259,7 +259,7 @@ Job::sub (string n) boost::mutex::scoped_lock lm (_progress_mutex); _sub_name = n; } - + set_progress (0, true); } @@ -286,7 +286,7 @@ Job::set_error (string s, string d) { LOG_ERROR_NC (s); LOG_ERROR_NC (d); - + _film->log()->log (String::compose ("Error in job: %1 (%2)", s, d), Log::TYPE_ERROR); boost::mutex::scoped_lock lm (_state_mutex); _error_summary = s; @@ -319,9 +319,9 @@ Job::status () const /* 100% makes it sound like we've finished when we haven't */ pc = 99; } - + s << pc << N_("%"); - + if (t > 10 && r > 0) { /// TRANSLATORS: remaining here follows an amount of time that is remaining /// on an operation. @@ -368,7 +368,7 @@ Job::remaining_time () const if (progress().get_value_or(0) == 0) { return elapsed_time (); } - + return elapsed_time() / progress().get() - elapsed_time(); } diff --git a/src/lib/job.h b/src/lib/job.h index 8fe87747c..06a341f40 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -47,7 +47,7 @@ public: virtual std::string json_name () const = 0; /** Run this job in the current thread. */ virtual void run () = 0; - + void start (); void pause (); void resume (); @@ -97,7 +97,7 @@ protected: FINISHED_ERROR, ///< the job has finished in error FINISHED_CANCELLED ///< the job was cancelled }; - + void set_state (State); void set_error (std::string s, std::string d); diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index b5b64a77e..f31a00a18 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -40,7 +40,7 @@ JobManager::JobManager () , _last_active_jobs (false) , _scheduler (new boost::thread (boost::bind (&JobManager::scheduler, this))) { - + } JobManager::~JobManager () @@ -64,7 +64,7 @@ JobManager::add (shared_ptr<Job> j) } emit (boost::bind (boost::ref (JobAdded), weak_ptr<Job> (j))); - + return j; } @@ -98,7 +98,7 @@ JobManager::errors () const } return false; -} +} void JobManager::scheduler () @@ -112,21 +112,21 @@ JobManager::scheduler () if (_terminate) { return; } - + for (list<shared_ptr<Job> >::iterator i = _jobs.begin(); i != _jobs.end(); ++i) { if (!(*i)->finished ()) { active_jobs = true; } - + if ((*i)->running ()) { /* Something is already happening */ break; } - + if ((*i)->is_new()) { (*i)->start (); - + /* Only start one job at once */ break; } diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index b946c1a98..d0e83e26f 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -51,11 +51,11 @@ public: private: /* This function is part of the test suite */ friend void ::wait_for_jobs (); - + JobManager (); ~JobManager (); void scheduler (); - + mutable boost::mutex _mutex; std::list<boost::shared_ptr<Job> > _jobs; bool _terminate; diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index 1035c248f..e06ee22c3 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -139,22 +139,22 @@ void JSONServer::request (string url, shared_ptr<tcp::socket> socket) { cout << "request: " << url << "\n"; - + map<string, string> r = split_get_request (url); for (map<string, string>::iterator i = r.begin(); i != r.end(); ++i) { cout << i->first << " => " << i->second << "\n"; } - + string action; if (r.find ("action") != r.end ()) { action = r["action"]; } - + stringstream json; if (action == "status") { - + list<shared_ptr<Job> > jobs = JobManager::instance()->get (); - + json << "{ \"jobs\": ["; for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) { @@ -163,7 +163,7 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket) if ((*i)->film()) { json << "\"dcp\": \"" << (*i)->film()->dcp_name() << "\", "; } - + json << "\"name\": \"" << (*i)->json_name() << "\", "; if ((*i)->progress ()) { json << "\"progress\": " << (*i)->progress().get() << ", "; @@ -172,7 +172,7 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket) } json << "\"status\": \"" << (*i)->json_status() << "\""; json << " }"; - + list<shared_ptr<Job> >::iterator j = i; ++j; if (j != jobs.end ()) { @@ -180,12 +180,12 @@ JSONServer::request (string url, shared_ptr<tcp::socket> socket) } } json << "] }"; - + if (json.str().empty ()) { json << "{ }"; } } - + stringstream reply; reply << "HTTP/1.1 200 OK\r\n" << "Content-Length: " << json.str().length() << "\r\n" diff --git a/src/lib/json_server.h b/src/lib/json_server.h index 623067558..06c49d885 100644 --- a/src/lib/json_server.h +++ b/src/lib/json_server.h @@ -28,4 +28,4 @@ private: void request (std::string url, boost::shared_ptr<boost::asio::ip::tcp::socket> socket); }; - + diff --git a/src/lib/kdm.cc b/src/lib/kdm.cc index 8949736f8..8489eed33 100644 --- a/src/lib/kdm.cc +++ b/src/lib/kdm.cc @@ -42,7 +42,7 @@ struct ScreenKDM : screen (s) , kdm (k) {} - + shared_ptr<Screen> screen; dcp::EncryptedKDM kdm; }; @@ -68,23 +68,23 @@ struct CinemaKDMs } throw FileError ("could not create ZIP file", zip_file); } - + list<shared_ptr<string> > kdm_strings; - + for (list<ScreenKDM>::const_iterator i = screen_kdms.begin(); i != screen_kdms.end(); ++i) { shared_ptr<string> kdm (new string (i->kdm.as_xml ())); kdm_strings.push_back (kdm); - + struct zip_source* source = zip_source_buffer (zip, kdm->c_str(), kdm->length(), 0); if (!source) { throw StringError ("could not create ZIP source"); } - + if (zip_add (zip, kdm_filename (film, *i).c_str(), source) == -1) { throw StringError ("failed to add KDM to ZIP archive"); } } - + if (zip_close (zip) == -1) { throw StringError ("failed to close ZIP archive"); } @@ -111,9 +111,9 @@ make_screen_kdms ( ) { list<dcp::EncryptedKDM> kdms = film->make_kdms (screens, cpl, from, to, formulation); - + list<ScreenKDM> screen_kdms; - + list<shared_ptr<Screen> >::iterator i = screens.begin (); list<dcp::EncryptedKDM>::iterator j = kdms.begin (); while (i != screens.end() && j != kdms.end ()) { @@ -139,18 +139,18 @@ make_cinema_kdms ( list<CinemaKDMs> cinema_kdms; while (!screen_kdms.empty ()) { - + /* Get all the screens from a single cinema */ CinemaKDMs ck; - + list<ScreenKDM>::iterator i = screen_kdms.begin (); ck.cinema = i->screen->cinema; ck.screen_kdms.push_back (*i); list<ScreenKDM>::iterator j = i; ++i; screen_kdms.remove (*j); - + while (i != screen_kdms.end ()) { if (i->screen->cinema == ck.cinema) { ck.screen_kdms.push_back (*i); @@ -225,27 +225,27 @@ email_kdms ( list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation); for (list<CinemaKDMs>::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) { - + boost::filesystem::path zip_file = boost::filesystem::temp_directory_path (); zip_file /= boost::filesystem::unique_path().string() + ".zip"; i->make_zip_file (film, zip_file); - + /* Send email */ - + quickmail_initialize (); SafeStringStream start; start << from.date() << " " << from.time_of_day(); SafeStringStream end; end << to.date() << " " << to.time_of_day(); - + string subject = Config::instance()->kdm_subject(); boost::algorithm::replace_all (subject, "$CPL_NAME", film->dcp_name ()); boost::algorithm::replace_all (subject, "$START_TIME", start.str ()); boost::algorithm::replace_all (subject, "$END_TIME", end.str ()); boost::algorithm::replace_all (subject, "$CINEMA_NAME", i->cinema->name); quickmail mail = quickmail_create (Config::instance()->kdm_from().c_str(), subject.c_str ()); - + quickmail_add_to (mail, i->cinema->email.c_str ()); if (!Config::instance()->kdm_cc().empty ()) { quickmail_add_cc (mail, Config::instance()->kdm_cc().c_str ()); @@ -255,13 +255,13 @@ email_kdms ( } quickmail_add_header (mail, "Content-Type: text/plain; charset=UTF-8"); - + string body = Config::instance()->kdm_email().c_str(); boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ()); boost::algorithm::replace_all (body, "$START_TIME", start.str ()); boost::algorithm::replace_all (body, "$END_TIME", end.str ()); boost::algorithm::replace_all (body, "$CINEMA_NAME", i->cinema->name); - + SafeStringStream screens; for (list<ScreenKDM>::const_iterator j = i->screen_kdms.begin(); j != i->screen_kdms.end(); ++j) { screens << j->screen->name << ", "; @@ -280,7 +280,7 @@ email_kdms ( Config::instance()->mail_user().c_str(), Config::instance()->mail_password().c_str() ); - + if (error) { quickmail_destroy (mail); throw KDMError (String::compose ("Failed to send KDM email (%1)", error)); diff --git a/src/lib/log.cc b/src/lib/log.cc index efea9f6b5..42184ec45 100644 --- a/src/lib/log.cc +++ b/src/lib/log.cc @@ -75,7 +75,7 @@ Log::log (string message, int type) if (type & TYPE_WARNING) { s << "WARNING: "; } - + s << message; do_log (s.str ()); } @@ -153,7 +153,7 @@ FileLog::head_and_tail (int amount) const head_amount = size; tail_amount = 0; } - + FILE* f = fopen_boost (_file, "r"); if (!f) { return ""; @@ -162,7 +162,7 @@ FileLog::head_and_tail (int amount) const string out; char* buffer = new char[max(head_amount, tail_amount) + 1]; - + int N = fread (buffer, 1, head_amount, f); buffer[N] = '\0'; out += string (buffer); @@ -171,7 +171,7 @@ FileLog::head_and_tail (int amount) const out += "\n .\n .\n .\n"; fseek (f, - tail_amount - 1, SEEK_END); - + N = fread (buffer, 1, tail_amount, f); buffer[N] = '\0'; out += string (buffer) + "\n"; diff --git a/src/lib/log.h b/src/lib/log.h index f83c6a902..1b7cef038 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -54,14 +54,14 @@ public: virtual std::string head_and_tail (int amount = 1024) const = 0; protected: - + /** mutex to protect the log */ mutable boost::mutex _mutex; - + private: virtual void do_log (std::string m) = 0; void config_changed (); - + /** bit-field of log types which should be put into the log (others are ignored) */ int _types; boost::signals2::scoped_connection _config_connection; @@ -87,7 +87,7 @@ public: return ""; } -private: +private: void do_log (std::string) {} }; diff --git a/src/lib/magick_image_proxy.cc b/src/lib/magick_image_proxy.cc index d4d7e8aa6..41aede613 100644 --- a/src/lib/magick_image_proxy.cc +++ b/src/lib/magick_image_proxy.cc @@ -36,19 +36,19 @@ using boost::dynamic_pointer_cast; MagickImageProxy::MagickImageProxy (boost::filesystem::path path) { /* Read the file into a Blob */ - + boost::uintmax_t const size = boost::filesystem::file_size (path); FILE* f = fopen_boost (path, "rb"); if (!f) { throw OpenFileError (path); } - + uint8_t* data = new uint8_t[size]; if (fread (data, 1, size, f) != size) { delete[] data; throw ReadFileError (path); } - + fclose (f); _blob.update (data, size); delete[] data; @@ -67,7 +67,7 @@ shared_ptr<Image> MagickImageProxy::image (optional<dcp::NoteHandler>) const { boost::mutex::scoped_lock lm (_mutex); - + if (_image) { return _image; } @@ -110,7 +110,7 @@ MagickImageProxy::image (optional<dcp::NoteHandler>) const using namespace MagickCore; #else using namespace MagickLib; -#endif +#endif magick_image->write (0, i, size.width, 1, "RGB", CharPixel, p); p += _image->stride()[0]; } @@ -144,6 +144,6 @@ MagickImageProxy::same (shared_ptr<const ImageProxy> other) const if (_blob.length() != mp->_blob.length()) { return false; } - + return memcmp (_blob.data(), mp->_blob.data(), _blob.length()) == 0; } diff --git a/src/lib/magick_image_proxy.h b/src/lib/magick_image_proxy.h index f4ddb2c94..d22789eda 100644 --- a/src/lib/magick_image_proxy.h +++ b/src/lib/magick_image_proxy.h @@ -31,7 +31,7 @@ public: void send_binary (boost::shared_ptr<Socket>) const; bool same (boost::shared_ptr<const ImageProxy> other) const; -private: +private: Magick::Blob _blob; mutable boost::shared_ptr<Image> _image; mutable boost::mutex _mutex; diff --git a/src/lib/md5_digester.cc b/src/lib/md5_digester.cc index df73a6945..c1c8f6827 100644 --- a/src/lib/md5_digester.cc +++ b/src/lib/md5_digester.cc @@ -55,14 +55,14 @@ MD5Digester::get () const if (!_digest) { unsigned char digest[MD5_DIGEST_LENGTH]; MD5_Final (digest, &_context); - + SafeStringStream s; for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { s << hex << setfill('0') << setw(2) << ((int) digest[i]); } - + _digest = s.str (); } - + return _digest.get (); } diff --git a/src/lib/md5_digester.h b/src/lib/md5_digester.h index 8ae7e81cf..650714672 100644 --- a/src/lib/md5_digester.h +++ b/src/lib/md5_digester.h @@ -36,7 +36,7 @@ public: } void add (std::string const & s); - + std::string get () const; private: diff --git a/src/lib/piece.h b/src/lib/piece.h index 976409381..9aaeec301 100644 --- a/src/lib/piece.h +++ b/src/lib/piece.h @@ -34,7 +34,7 @@ public: , decoder (d) , frc (f) {} - + boost::shared_ptr<Content> content; boost::shared_ptr<Decoder> decoder; FrameRateChange frc; diff --git a/src/lib/player.cc b/src/lib/player.cc index 449a4384d..be1268f48 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -94,7 +94,7 @@ Player::setup_pieces () if (!(*i)->paths_valid ()) { continue; } - + shared_ptr<Decoder> decoder; optional<FrameRateChange> frc; @@ -106,7 +106,7 @@ Player::setup_pieces () if (!vc) { continue; } - + DCPTime const overlap = max (vc->position(), (*i)->position()) - min (vc->end(), (*i)->end()); if (overlap > best_overlap_t) { best_overlap = vc; @@ -202,7 +202,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent) property == VideoContentProperty::VIDEO_FRAME_TYPE || property == DCPContentProperty::CAN_BE_PLAYED ) { - + _have_valid_pieces = false; Changed (frequent); @@ -218,7 +218,7 @@ Player::content_changed (weak_ptr<Content> w, int property, bool frequent) property == VideoContentProperty::VIDEO_FADE_IN || property == VideoContentProperty::VIDEO_FADE_OUT ) { - + Changed (frequent); } } @@ -256,7 +256,7 @@ list<PositionImage> Player::transform_image_subtitles (list<ImageSubtitle> subs) const { list<PositionImage> all; - + for (list<ImageSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) { if (!i->image) { continue; @@ -264,7 +264,7 @@ Player::transform_image_subtitles (list<ImageSubtitle> subs) const /* We will scale the subtitle up to fit _video_container_size */ dcp::Size scaled_size (i->rectangle.width * _video_container_size.width, i->rectangle.height * _video_container_size.height); - + /* Then we need a corrective translation, consisting of two parts: * * 1. that which is the result of the scaling of the subtitle by _video_container_size; this will be @@ -346,7 +346,7 @@ Player::get_video (DCPTime time, bool accurate) pvf.push_back (black_player_video_frame (time)); return pvf; } - + dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ()); for (list<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) { @@ -388,8 +388,8 @@ Player::get_video (DCPTime time, bool accurate) for (list<shared_ptr<PlayerVideo> >::const_iterator i = pvf.begin(); i != pvf.end(); ++i) { (*i)->set_subtitle (merge (sub_images)); } - } - + } + return pvf; } @@ -404,7 +404,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) shared_ptr<AudioBuffers> audio (new AudioBuffers (_film->audio_channels(), length_frames)); audio->make_silent (); - + list<shared_ptr<Piece> > ov = overlaps<AudioContent> (time, time + length); if (ov.empty ()) { return audio; @@ -436,7 +436,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame const content_frame = dcp_to_content_audio (*i, request); BOOST_FOREACH (AudioStreamPtr j, content->audio_streams ()) { - + /* Audio from this piece's decoder stream (which might be more or less than what we asked for) */ ContentAudio all = decoder->get_audio (j, content_frame, request_frames, accurate); @@ -467,7 +467,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) if (_audio_processor) { dcp_mapped = _audio_processor->run (dcp_mapped); } - + all.audio = dcp_mapped; audio->accumulate_frames ( @@ -561,7 +561,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting) list<ContentImageSubtitle> image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting); for (list<ContentImageSubtitle>::iterator i = image.begin(); i != image.end(); ++i) { - + /* Apply content's subtitle offsets */ i->sub.rectangle.x += subtitle_content->subtitle_x_offset (); i->sub.rectangle.y += subtitle_content->subtitle_y_offset (); @@ -573,7 +573,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting) /* Apply a corrective translation to keep the subtitle centred after that scale */ i->sub.rectangle.x -= i->sub.rectangle.width * (subtitle_content->subtitle_x_scale() - 1); i->sub.rectangle.y -= i->sub.rectangle.height * (subtitle_content->subtitle_y_scale() - 1); - + ps.image.push_back (i->sub); } diff --git a/src/lib/player.h b/src/lib/player.h index e515fced3..f22faa7ac 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -44,7 +44,7 @@ class Resampler; class PlayerVideo; class ImageProxy; class Font; - + class PlayerStatistics { public: @@ -55,7 +55,7 @@ public: , good (0) , skip (0) {} - + int black; int repeat; int good; @@ -68,7 +68,7 @@ public: , good (0) , skip (0) {} - + DCPTime silence; int64_t good; int64_t skip; @@ -96,7 +96,7 @@ public: void set_burn_subtitles (bool burn); PlayerStatistics const & statistics () const; - + /** Emitted when something has changed such that if we went back and emitted * the last frame again it would look different. This is not emitted after * a seek. @@ -141,10 +141,10 @@ private: overlaps.push_back (*i); } } - + return overlaps; } - + boost::shared_ptr<const Film> _film; /** Our pieces are ready to go; if this is false the pieces must be (re-)created before they are used */ diff --git a/src/lib/player_subtitles.h b/src/lib/player_subtitles.h index 65de500f6..93a0d5378 100644 --- a/src/lib/player_subtitles.h +++ b/src/lib/player_subtitles.h @@ -30,7 +30,7 @@ public: : from (f) , to (t) {} - + DCPTime from; DCPTime to; diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index a84d3b45f..c2ba1362a 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -71,13 +71,13 @@ PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket _in = image_proxy_factory (node->node_child ("In"), socket); if (node->optional_number_child<int> ("SubtitleX")) { - + _subtitle.position = Position<int> (node->number_child<int> ("SubtitleX"), node->number_child<int> ("SubtitleY")); _subtitle.image.reset ( new Image (PIX_FMT_RGBA, dcp::Size (node->number_child<int> ("SubtitleWidth"), node->number_child<int> ("SubtitleHeight")), true) ); - + _subtitle.image->read_from_socket (socket); } } @@ -92,7 +92,7 @@ shared_ptr<Image> PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle, dcp::NoteHandler note) const { shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note)); - + Crop total_crop = _crop; switch (_part) { case PART_LEFT_HALF: @@ -115,7 +115,7 @@ PlayerVideo::image (AVPixelFormat pixel_format, bool burn_subtitle, dcp::NoteHan if (_colour_conversion) { yuv_to_rgb = _colour_conversion.get().yuv_to_rgb(); } - + shared_ptr<Image> out = im->crop_scale_window (total_crop, _inter_size, _out_size, yuv_to_rgb, pixel_format, true); if (burn_subtitle && _subtitle.image) { @@ -168,12 +168,12 @@ bool PlayerVideo::has_j2k () const { /* XXX: burnt-in subtitle; maybe other things */ - + shared_ptr<const J2KImageProxy> j2k = dynamic_pointer_cast<const J2KImageProxy> (_in); if (!j2k) { return false; } - + return _crop == Crop () && _inter_size == j2k->size(); } diff --git a/src/lib/player_video.h b/src/lib/player_video.h index e6aa4c7b2..276c97948 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -49,11 +49,11 @@ public: Part, boost::optional<ColourConversion> ); - + PlayerVideo (boost::shared_ptr<cxml::Node>, boost::shared_ptr<Socket>); void set_subtitle (PositionImage); - + boost::shared_ptr<Image> image (AVPixelFormat pix_fmt, bool burn_subtitle, dcp::NoteHandler note) const; void add_metadata (xmlpp::Node* node, bool send_subtitles) const; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 0bb339f50..c5e026699 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -67,11 +67,11 @@ Playlist::content_changed (weak_ptr<Content> content, int property, bool frequen - any other position changes will be timeline drags which should not result in content being sequenced. */ - + if (property == ContentProperty::LENGTH || property == VideoContentProperty::VIDEO_FRAME_TYPE) { maybe_sequence_video (); } - + ContentChanged (content, property, frequent); } @@ -81,9 +81,9 @@ Playlist::maybe_sequence_video () if (!_sequence_video || _sequencing_video) { return; } - + _sequencing_video = true; - + DCPTime next_left; DCPTime next_right; for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { @@ -91,7 +91,7 @@ Playlist::maybe_sequence_video () if (!vc) { continue; } - + if (vc->video_frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { vc->set_position (next_right); next_right = vc->end() + DCPTime::delta (); @@ -102,7 +102,7 @@ Playlist::maybe_sequence_video () } /* This won't change order, so it does not need a sort */ - + _sequencing_video = false; } @@ -110,7 +110,7 @@ string Playlist::video_identifier () const { string t; - + for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i); if (vc) { @@ -162,7 +162,7 @@ Playlist::remove (shared_ptr<Content> c) while (i != _content.end() && *i != c) { ++i; } - + if (i != _content.end ()) { _content.erase (i); Changed (); @@ -179,14 +179,14 @@ Playlist::remove (ContentList c) while (j != _content.end() && *j != *i) { ++j; } - + if (j != _content.end ()) { _content.erase (j); } } /* This won't change order, so it does not need a sort */ - + Changed (); } @@ -249,7 +249,7 @@ Playlist::best_dcp_frame_rate () const if (!best) { return 24; } - + return best->dcp; } @@ -272,7 +272,7 @@ Playlist::reconnect () } _content_connections.clear (); - + for (ContentList::iterator i = _content.begin(); i != _content.end(); ++i) { _content_connections.push_back ((*i)->Changed.connect (bind (&Playlist::content_changed, this, _1, _2, _3))); } @@ -349,7 +349,7 @@ Playlist::repeat (ContentList c, int n) } sort (_content.begin(), _content.end(), ContentSorter ()); - + reconnect (); Changed (); } @@ -358,7 +358,7 @@ void Playlist::move_earlier (shared_ptr<Content> c) { sort (_content.begin(), _content.end(), ContentSorter ()); - + ContentList::iterator previous = _content.end (); ContentList::iterator i = _content.begin(); while (i != _content.end() && *i != c) { @@ -371,7 +371,7 @@ Playlist::move_earlier (shared_ptr<Content> c) return; } - + DCPTime const p = (*previous)->position (); (*previous)->set_position (p + c->length_after_trim ()); c->set_position (p); @@ -382,7 +382,7 @@ void Playlist::move_later (shared_ptr<Content> c) { sort (_content.begin(), _content.end(), ContentSorter ()); - + ContentList::iterator i = _content.begin(); while (i != _content.end() && *i != c) { ++i; diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 91051e9c4..3829d6f31 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -68,7 +68,7 @@ public: std::string video_identifier () const; DCPTime length () const; - + int best_dcp_frame_rate () const; DCPTime video_end () const; FrameRateChange active_frame_rate_change (DCPTime, int dcp_frame_rate) const; @@ -85,7 +85,7 @@ public: * Third parameter is true if signals are currently being emitted frequently. */ mutable boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> ContentChanged; - + private: void content_changed (boost::weak_ptr<Content>, int, bool); void reconnect (); diff --git a/src/lib/position_image.h b/src/lib/position_image.h index c0c65d1da..e3a091b37 100644 --- a/src/lib/position_image.h +++ b/src/lib/position_image.h @@ -29,12 +29,12 @@ class PositionImage { public: PositionImage () {} - + PositionImage (boost::shared_ptr<Image> i, Position<int> p) : image (i) , position (p) {} - + boost::shared_ptr<Image> image; Position<int> position; diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index 6edd154e0..a6ebad141 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -49,7 +49,7 @@ Ratio::from_id (string i) if (i == "137") { i = "138"; } - + vector<Ratio const *>::iterator j = _ratios.begin (); while (j != _ratios.end() && (*j)->id() != i) { ++j; @@ -77,13 +77,13 @@ Ratio::from_ratio (float r) return *j; } - + Ratio const * Ratio::nearest_from_ratio (float r) { Ratio const * nearest = 0; float distance = FLT_MAX; - + for (vector<Ratio const *>::iterator i = _ratios.begin (); i != _ratios.end(); ++i) { float const d = fabs ((*i)->ratio() - r); if (d < distance) { diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 360fb2340..7b70bd7f7 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -66,7 +66,7 @@ private: std::string _nickname; std::string _isdcf_name; - static std::vector<Ratio const *> _ratios; + static std::vector<Ratio const *> _ratios; }; #endif diff --git a/src/lib/raw_image_proxy.h b/src/lib/raw_image_proxy.h index 33bf48273..71c8df30b 100644 --- a/src/lib/raw_image_proxy.h +++ b/src/lib/raw_image_proxy.h @@ -27,12 +27,12 @@ class RawImageProxy : public ImageProxy public: RawImageProxy (boost::shared_ptr<Image>); RawImageProxy (boost::shared_ptr<cxml::Node> xml, boost::shared_ptr<Socket> socket); - + boost::shared_ptr<Image> image (boost::optional<dcp::NoteHandler> note = boost::optional<dcp::NoteHandler> ()) const; void add_metadata (xmlpp::Node *) const; void send_binary (boost::shared_ptr<Socket>) const; bool same (boost::shared_ptr<const ImageProxy>) const; - + private: boost::shared_ptr<Image> _image; }; diff --git a/src/lib/rect.h b/src/lib/rect.h index 963119b50..97b90abc5 100644 --- a/src/lib/rect.h +++ b/src/lib/rect.h @@ -27,15 +27,15 @@ namespace dcpomatic { - + /** @struct Rect * @brief A rectangle. */ -template <class T> +template <class T> class Rect { public: - + Rect () : x (0) , y (0) @@ -71,7 +71,7 @@ public: { T const tx = max (x, other.x); T const ty = max (y, other.y); - + return Rect ( tx, ty, min (x + width, other.x + other.width) - tx, diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc index 0d059eb43..53f713283 100644 --- a/src/lib/render_subtitles.cc +++ b/src/lib/render_subtitles.cc @@ -72,7 +72,7 @@ render_subtitle (dcp::SubtitleString const & subtitle, dcp::Size target) image->size().height, Cairo::ImageSurface::format_stride_for_width (Cairo::FORMAT_ARGB32, image->size().width) ); - + Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (surface); Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context); @@ -89,13 +89,13 @@ render_subtitle (dcp::SubtitleString const & subtitle, dcp::Size target) } layout->set_font_description (font); layout->set_text (subtitle.text ()); - + /* Compute fade factor */ /* XXX */ float fade_factor = 1; layout->update_from_cairo_context (context); - + context->scale (xscale, yscale); if (subtitle.effect() == dcp::SHADOW) { @@ -123,7 +123,7 @@ render_subtitle (dcp::SubtitleString const & subtitle, dcp::Size target) layout->add_to_cairo_context (context); context->stroke (); } - + int layout_width; int layout_height; layout->get_size (layout_width, layout_height); diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index 8111dde5f..2538f7dca 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -20,7 +20,7 @@ extern "C" { #include "libavutil/channel_layout.h" #include "libavutil/opt.h" -} +} #include "resampler.h" #include "audio_buffers.h" #include "exceptions.h" @@ -51,7 +51,7 @@ Resampler::Resampler (int in, int out, int channels) /* Sample rates */ av_opt_set_int (_swr_context, "isr", _in_rate, 0); av_opt_set_int (_swr_context, "osr", _out_rate, 0); - + swr_init (_swr_context); } @@ -70,16 +70,16 @@ Resampler::run (shared_ptr<const AudioBuffers> in) int const resampled_frames = swr_convert ( _swr_context, (uint8_t **) resampled->data(), max_resampled_frames, (uint8_t const **) in->data(), in->frames() ); - + if (resampled_frames < 0) { char buf[256]; av_strerror (resampled_frames, buf, sizeof(buf)); throw EncodeError (String::compose (_("could not run sample-rate converter for %1 samples (%2) (%3)"), in->frames(), resampled_frames, buf)); } - + resampled->set_frames (resampled_frames); return resampled; -} +} shared_ptr<const AudioBuffers> Resampler::flush () @@ -91,11 +91,11 @@ Resampler::flush () while (true) { int const frames = swr_convert (_swr_context, (uint8_t **) pass->data(), pass_size, 0, 0); - + if (frames < 0) { throw EncodeError (_("could not run sample-rate converter")); } - + if (frames == 0) { break; } diff --git a/src/lib/resampler.h b/src/lib/resampler.h index 21ef412de..332b9b4b1 100644 --- a/src/lib/resampler.h +++ b/src/lib/resampler.h @@ -36,7 +36,7 @@ public: boost::shared_ptr<const AudioBuffers> run (boost::shared_ptr<const AudioBuffers>); boost::shared_ptr<const AudioBuffers> flush (); -private: +private: SwrContext* _swr_context; int _in_rate; int _out_rate; diff --git a/src/lib/safe_stringstream.h b/src/lib/safe_stringstream.h index 0ffcb6224..e6f6595ba 100644 --- a/src/lib/safe_stringstream.h +++ b/src/lib/safe_stringstream.h @@ -44,11 +44,11 @@ class SafeStringStream public: SafeStringStream () {} - + SafeStringStream (std::string s) : _stream (s) {} - + template <class T> std::ostream& operator<< (T val) { @@ -88,7 +88,7 @@ public: { _stream.fill (f); } - + void precision (int p) { _stream.precision (p); diff --git a/src/lib/scoped_temporary.cc b/src/lib/scoped_temporary.cc index c64f63243..b712fe494 100644 --- a/src/lib/scoped_temporary.cc +++ b/src/lib/scoped_temporary.cc @@ -31,7 +31,7 @@ ScopedTemporary::ScopedTemporary () /** Close and delete the temporary file */ ScopedTemporary::~ScopedTemporary () { - close (); + close (); boost::system::error_code ec; boost::filesystem::remove (_file, ec); } diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc index d71ec6fd2..86eec16b2 100644 --- a/src/lib/scp_dcp_job.cc +++ b/src/lib/scp_dcp_job.cc @@ -74,7 +74,7 @@ public: ssh_session session; -private: +private: bool _connected; }; @@ -121,60 +121,60 @@ void SCPDCPJob::run () { LOG_GENERAL_NC (N_("SCP DCP job starting")); - + SSHSession ss; - + set_status (_("connecting")); - + ssh_options_set (ss.session, SSH_OPTIONS_HOST, Config::instance()->tms_ip().c_str ()); ssh_options_set (ss.session, SSH_OPTIONS_USER, Config::instance()->tms_user().c_str ()); int const port = 22; ssh_options_set (ss.session, SSH_OPTIONS_PORT, &port); - + int r = ss.connect (); if (r != SSH_OK) { throw NetworkError (String::compose (_("Could not connect to server %1 (%2)"), Config::instance()->tms_ip(), ssh_get_error (ss.session))); } - + int const state = ssh_is_server_known (ss.session); if (state == SSH_SERVER_ERROR) { throw NetworkError (String::compose (_("SSH error (%1)"), ssh_get_error (ss.session))); } - + r = ssh_userauth_password (ss.session, 0, Config::instance()->tms_password().c_str ()); if (r != SSH_AUTH_SUCCESS) { throw NetworkError (String::compose (_("Failed to authenticate with server (%1)"), ssh_get_error (ss.session))); } - + SSHSCP sc (ss.session); - + r = ssh_scp_init (sc.scp); if (r != SSH_OK) { throw NetworkError (String::compose (_("Could not start SCP session (%1)"), ssh_get_error (ss.session))); } - + r = ssh_scp_push_directory (sc.scp, _film->dcp_name().c_str(), S_IRWXU); if (r != SSH_OK) { throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), _film->dcp_name(), ssh_get_error (ss.session))); } - + boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name()); - + boost::uintmax_t bytes_to_transfer = 0; for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) { bytes_to_transfer += boost::filesystem::file_size (*i); } - + boost::uintmax_t buffer_size = 64 * 1024; char buffer[buffer_size]; boost::uintmax_t bytes_transferred = 0; - + for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (dcp_dir); i != boost::filesystem::directory_iterator(); ++i) { - + string const leaf = boost::filesystem::path(*i).leaf().generic_string (); - + set_status (String::compose (_("copying %1"), leaf)); - + boost::uintmax_t to_do = boost::filesystem::file_size (*i); ssh_scp_push_file (sc.scp, leaf.c_str(), to_do, S_IRUSR | S_IWUSR); @@ -190,7 +190,7 @@ SCPDCPJob::run () fclose (f); throw ReadFileError (boost::filesystem::path (*i).string()); } - + r = ssh_scp_write (sc.scp, buffer, t); if (r != SSH_OK) { fclose (f); @@ -206,7 +206,7 @@ SCPDCPJob::run () fclose (f); } - + set_progress (1); set_status (N_("")); set_state (FINISHED_OK); diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 4be54c5cd..cddf424f4 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -62,12 +62,12 @@ void SendKDMEmailJob::run () { try { - + set_progress_unknown (); email_kdms (_film, _screens, _dcp, _from, _to, _formulation); set_progress (1); set_state (FINISHED_OK); - + } catch (std::exception& e) { set_progress (1); diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index 0fd14bc24..f08adea78 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -62,11 +62,11 @@ SendProblemReportJob::run () set_progress_unknown (); quickmail mail = quickmail_create (_from.c_str(), "DCP-o-matic problem report"); - + quickmail_add_to (mail, "carl@dcpomatic.com"); - + string body = _summary + "\n\n"; - + body += "log head and tail:\n"; body += "---<8----\n"; body += _film->log()->head_and_tail (); @@ -76,16 +76,16 @@ SendProblemReportJob::run () add_file (body, "metadata.xml"); quickmail_set_body (mail, body.c_str()); - + char const* error = quickmail_send (mail, "main.carlh.net", 2525, 0, 0); - + if (error) { set_state (FINISHED_ERROR); set_error (error, ""); } else { set_state (FINISHED_OK); } - + quickmail_destroy (mail); set_progress (1); @@ -98,7 +98,7 @@ SendProblemReportJob::add_file (string& body, boost::filesystem::path file) cons if (!f) { return; } - + body += file.string() + ":\n"; body += "---<8----\n"; uintmax_t const size = boost::filesystem::file_size (_film->file (file)); diff --git a/src/lib/server.cc b/src/lib/server.cc index 2a5ff5c9a..79840c25b 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -118,11 +118,11 @@ Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct t DCPVideo dcp_video_frame (pvf, xml, _log); gettimeofday (&after_read, 0); - + Data encoded = dcp_video_frame.encode_locally (boost::bind (&Log::dcp_log, _log.get(), _1, _2)); gettimeofday (&after_encode, 0); - + try { socket->write (encoded.size ()); socket->write (encoded.data ().get (), encoded.size ()); @@ -150,7 +150,7 @@ Server::worker_thread () shared_ptr<Socket> socket = _queue.front (); _queue.pop_front (); - + lock.unlock (); int frame = -1; @@ -160,9 +160,9 @@ Server::worker_thread () struct timeval after_read; struct timeval after_encode; struct timeval end; - + gettimeofday (&start, 0); - + try { frame = process (socket, after_read, after_encode); ip = socket->socket().remote_endpoint().address().to_string(); @@ -174,7 +174,7 @@ Server::worker_thread () gettimeofday (&end, 0); socket.reset (); - + lock.lock (); if (frame >= 0) { @@ -188,14 +188,14 @@ Server::worker_thread () << "receive " << (seconds(after_read) - seconds(start)) << "s " << "encode " << (seconds(after_encode) - seconds(after_read)) << "s " << "send " << (seconds(end) - seconds(after_encode)) << "s."; - + if (_verbose) { cout << message.str() << "\n"; } LOG_GENERAL_NC (message.str ()); } - + _full_condition.notify_all (); } } @@ -207,13 +207,13 @@ Server::run (int num_threads) if (_verbose) { cout << "DCP-o-matic server starting with " << num_threads << " threads.\n"; } - + for (int i = 0; i < num_threads; ++i) { _worker_threads.push_back (new thread (bind (&Server::worker_thread, this))); } _broadcast.thread = new thread (bind (&Server::broadcast_thread, this)); - + start_accept (); _io_service.run (); } @@ -267,7 +267,7 @@ Server::broadcast_received () } } - + _broadcast.socket->async_receive_from ( boost::asio::buffer (_broadcast.buffer, sizeof (_broadcast.buffer)), _broadcast.send_endpoint, boost::bind (&Server::broadcast_received, this) @@ -293,15 +293,15 @@ Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code cons } boost::mutex::scoped_lock lock (_worker_mutex); - + /* Wait until the queue has gone down a bit */ while (_queue.size() >= _worker_threads.size() * 2 && !_terminate) { _full_condition.wait (lock); } - + _queue.push_back (socket); _empty_condition.notify_all (); start_accept (); } - + diff --git a/src/lib/server.h b/src/lib/server.h index 1dc3b7b4e..51dc8774e 100644 --- a/src/lib/server.h +++ b/src/lib/server.h @@ -50,7 +50,7 @@ public: : _host_name ("") , _threads (1) {} - + /** @param h Server host name or IP address in string form. * @param t Number of threads to use on the server. */ @@ -60,7 +60,7 @@ public: {} /* Default copy constructor is fine */ - + /** @return server's host name or IP address in string form */ std::string host_name () const { return _host_name; @@ -121,13 +121,13 @@ private: : thread (0) , socket (0) {} - + boost::thread* thread; boost::asio::ip::udp::socket* socket; char buffer[64]; boost::asio::ip::udp::endpoint send_endpoint; boost::asio::io_service io_service; - + } _broadcast; }; diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index 726437ea5..ac4651657 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/server_finder.cc @@ -76,7 +76,7 @@ try socket.set_option (boost::asio::socket_base::broadcast (true)); string const data = DCPOMATIC_HELLO; - + while (!_stop) { if (Config::instance()->use_any_servers ()) { /* Broadcast to look for servers */ @@ -153,18 +153,18 @@ ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> so start_accept (); return; } - + uint32_t length; socket->read (reinterpret_cast<uint8_t*> (&length), sizeof (uint32_t)); length = ntohl (length); - + scoped_array<char> buffer (new char[length]); socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length); - + string s (buffer.get()); shared_ptr<cxml::Document> xml (new cxml::Document ("ServerAvailable")); xml->read_string (s); - + string const ip = socket->socket().remote_endpoint().address().to_string (); if (!server_found (ip) && xml->optional_number_child<int>("Version").get_value_or (0) == SERVER_LINK_VERSION) { ServerDescription sd (ip, xml->number_child<int> ("Threads")); diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h index dc62f998d..ec855938b 100644 --- a/src/lib/server_finder.h +++ b/src/lib/server_finder.h @@ -51,7 +51,7 @@ private: boost::signals2::signal<void (ServerDescription)> ServerFound; bool _disabled; - + /** Thread to periodically issue broadcasts to find encoding servers */ boost::thread* _broadcast_thread; /** Thread to listen to the responses from servers */ diff --git a/src/lib/signal_manager.h b/src/lib/signal_manager.h index ae4306e30..546d3d739 100644 --- a/src/lib/signal_manager.h +++ b/src/lib/signal_manager.h @@ -76,7 +76,7 @@ private: } friend class Signaller; - + /** A io_service which is used as the conduit for messages */ boost::asio::io_service _service; /** Object required to keep io_service from stopping when it has nothing to do */ diff --git a/src/lib/signaller.h b/src/lib/signaller.h index 661a171ec..fa249078c 100644 --- a/src/lib/signaller.h +++ b/src/lib/signaller.h @@ -103,7 +103,7 @@ public: if (signal_manager) { signal_manager->emit (boost::bind (&Wrapper<T>::signal, w)); } - + boost::mutex::scoped_lock lm (_signaller_mutex); /* Clean up finished Wrappers */ diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index 6a9a78bfa..cf2dcc1bd 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -62,7 +62,7 @@ SingleStreamAudioContent::take_from_audio_examiner (shared_ptr<AudioExaminer> ex { shared_ptr<const Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - + { boost::mutex::scoped_lock lm (_mutex); _audio_stream.reset (new AudioStream (examiner->audio_frame_rate(), examiner->audio_channels ())); diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h index abe68b444..7ae6dbaa4 100644 --- a/src/lib/single_stream_audio_content.h +++ b/src/lib/single_stream_audio_content.h @@ -45,7 +45,7 @@ public: AudioStreamPtr audio_stream () const { return _audio_stream; } - + void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>); protected: diff --git a/src/lib/sndfile_base.cc b/src/lib/sndfile_base.cc index 3f7ee0d75..712df7bda 100644 --- a/src/lib/sndfile_base.cc +++ b/src/lib/sndfile_base.cc @@ -39,10 +39,10 @@ Sndfile::Sndfile (shared_ptr<const SndfileContent> c) /* Here be monsters. See fopen_boost for similar shenanigans */ #ifdef DCPOMATIC_WINDOWS _sndfile = sf_wchar_open (_sndfile_content->path(0).c_str(), SFM_READ, &_info); -#else +#else _sndfile = sf_open (_sndfile_content->path(0).string().c_str(), SFM_READ, &_info); #endif - + if (!_sndfile) { throw DecodeError (_("could not open audio file for reading")); } diff --git a/src/lib/sndfile_base.h b/src/lib/sndfile_base.h index 6c4f02197..4b7a50fc7 100644 --- a/src/lib/sndfile_base.h +++ b/src/lib/sndfile_base.h @@ -31,7 +31,7 @@ public: Sndfile (boost::shared_ptr<const SndfileContent> content); virtual ~Sndfile (); -protected: +protected: boost::shared_ptr<const SndfileContent> _sndfile_content; SNDFILE* _sndfile; SF_INFO _info; diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h index f5a2e38b1..c07b823d4 100644 --- a/src/lib/sndfile_content.h +++ b/src/lib/sndfile_content.h @@ -38,9 +38,9 @@ public: boost::shared_ptr<SndfileContent> shared_from_this () { return boost::dynamic_pointer_cast<SndfileContent> (Content::shared_from_this ()); } - + DCPTime full_length () const; - + void examine (boost::shared_ptr<Job>); std::string summary () const; std::string technical_summary () const; @@ -48,7 +48,7 @@ public: void as_xml (xmlpp::Node *) const; void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>); - + static bool valid_file (boost::filesystem::path); private: @@ -56,7 +56,7 @@ private: boost::mutex::scoped_lock lm (_mutex); return _audio_length; } - + Frame _audio_length; }; diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index ff14543e1..2fa9ae2a3 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -39,7 +39,7 @@ SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c) , _remaining (_info.frames) , _deinterleave_buffer (0) { - + } SndfileDecoder::~SndfileDecoder () @@ -53,7 +53,7 @@ SndfileDecoder::pass () if (_remaining == 0) { return true; } - + /* Do things in half second blocks as I think there may be limits to what FFmpeg (and in particular the resampler) can cope with. */ @@ -61,7 +61,7 @@ SndfileDecoder::pass () sf_count_t const this_time = min (block, _remaining); int const channels = _sndfile_content->audio_stream()->channels (); - + shared_ptr<AudioBuffers> data (new AudioBuffers (channels, this_time)); if (_sndfile_content->audio_stream()->channels() == 1) { @@ -84,7 +84,7 @@ SndfileDecoder::pass () } } } - + data->set_frames (this_time); audio (_sndfile_content->audio_stream (), data, ContentTime::from_frames (_done, _info.samplerate)); _done += this_time; diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index 40e313165..7fcf5037c 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -33,7 +33,7 @@ public: private: bool pass (); void seek (ContentTime, bool); - + int64_t _done; int64_t _remaining; float* _deinterleave_buffer; diff --git a/src/lib/sndfile_examiner.h b/src/lib/sndfile_examiner.h index b3ab3c4e2..c64ceae6e 100644 --- a/src/lib/sndfile_examiner.h +++ b/src/lib/sndfile_examiner.h @@ -24,7 +24,7 @@ class SndfileExaminer : public Sndfile, public AudioExaminer { public: SndfileExaminer (boost::shared_ptr<const SndfileContent> content); - + int audio_channels () const; Frame audio_length () const; int audio_frame_rate () const; diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 9656ec184..7ab13c2c3 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -56,7 +56,7 @@ SubRipContent::examine (boost::shared_ptr<Job> job) shared_ptr<const Film> film = _film.lock (); DCPOMATIC_ASSERT (film); - + DCPTime len (s.length (), film->active_frame_rate_change (position ())); /* Default to turning these subtitles on */ diff --git a/src/lib/subrip_content.h b/src/lib/subrip_content.h index e63526179..09346a174 100644 --- a/src/lib/subrip_content.h +++ b/src/lib/subrip_content.h @@ -28,7 +28,7 @@ public: boost::shared_ptr<SubRipContent> shared_from_this () { return boost::dynamic_pointer_cast<SubRipContent> (Content::shared_from_this ()); } - + /* Content */ void examine (boost::shared_ptr<Job>); std::string summary () const; @@ -42,7 +42,7 @@ public: } static std::string const font_id; - + private: DCPTime _length; }; diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index fecbbc558..c2bd4f3e0 100644 --- a/src/lib/subrip_decoder.cc +++ b/src/lib/subrip_decoder.cc @@ -40,7 +40,7 @@ void SubRipDecoder::seek (ContentTime time, bool accurate) { SubtitleDecoder::seek (time, accurate); - + _next = 0; while (_next < _subtitles.size() && ContentTime::from_seconds (_subtitles[_next].from.all_as_seconds ()) < time) { ++_next; @@ -55,7 +55,7 @@ SubRipDecoder::pass () } /* XXX: we are ignoring positioning specified in the file */ - + list<dcp::SubtitleString> out; for (list<sub::Line>::const_iterator i = _subtitles[_next].lines.begin(); i != _subtitles[_next].lines.end(); ++i) { for (list<sub::Block>::const_iterator j = i->blocks.begin(); j != i->blocks.end(); ++j) { diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h index 876f763d3..38ccca0a3 100644 --- a/src/lib/subrip_decoder.h +++ b/src/lib/subrip_decoder.h @@ -37,7 +37,7 @@ protected: private: std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const; std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const; - + size_t _next; }; diff --git a/src/lib/subrip_subtitle.h b/src/lib/subrip_subtitle.h index d4d27e140..f39a317b7 100644 --- a/src/lib/subrip_subtitle.h +++ b/src/lib/subrip_subtitle.h @@ -32,7 +32,7 @@ struct SubRipSubtitlePiece , italic (false) , underline (false) {} - + std::string text; bool bold; bool italic; diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 514ee03cb..215829659 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -78,7 +78,7 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film, cxml::ConstNodePt } else { _use_subtitles = false; } - + if (version >= 7) { _subtitle_x_offset = node->number_child<float> ("SubtitleXOffset"); _subtitle_y_offset = node->number_child<float> ("SubtitleYOffset"); @@ -109,7 +109,7 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film, vector<shared_ptr shared_ptr<SubtitleContent> ref = dynamic_pointer_cast<SubtitleContent> (c[0]); DCPOMATIC_ASSERT (ref); list<shared_ptr<Font> > ref_fonts = ref->fonts (); - + for (size_t i = 0; i < c.size(); ++i) { shared_ptr<SubtitleContent> sc = dynamic_pointer_cast<SubtitleContent> (c[i]); @@ -120,7 +120,7 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> film, vector<shared_ptr if (sc->subtitle_x_offset() != ref->subtitle_x_offset()) { throw JoinError (_("Content to be joined must have the same subtitle X offset.")); } - + if (sc->subtitle_y_offset() != ref->subtitle_y_offset()) { throw JoinError (_("Content to be joined must have the same subtitle Y offset.")); } @@ -166,7 +166,7 @@ void SubtitleContent::as_xml (xmlpp::Node* root) const { boost::mutex::scoped_lock lm (_mutex); - + root->add_child("UseSubtitles")->add_child_text (raw_convert<string> (_use_subtitles)); root->add_child("SubtitleXOffset")->add_child_text (raw_convert<string> (_subtitle_x_offset)); root->add_child("SubtitleYOffset")->add_child_text (raw_convert<string> (_subtitle_y_offset)); @@ -188,7 +188,7 @@ SubtitleContent::set_use_subtitles (bool u) } signal_changed (SubtitleContentProperty::USE_SUBTITLES); } - + void SubtitleContent::set_subtitle_x_offset (double o) { diff --git a/src/lib/subtitle_content.h b/src/lib/subtitle_content.h index a159d7849..c00ec6f90 100644 --- a/src/lib/subtitle_content.h +++ b/src/lib/subtitle_content.h @@ -102,7 +102,7 @@ public: protected: /** subtitle language (e.g. "German") or empty if it is not known */ std::string _subtitle_language; - + private: friend struct ffmpeg_pts_offset_test; void font_changed (); diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index 93493aa70..dd2558505 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -74,7 +74,7 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, /* Now look for what we wanted in the data we have collected */ /* XXX: inefficient */ - + list<T> out; for (typename list<T>::const_iterator i = subs.begin(); i != subs.end(); ++i) { if ((starting && period.contains (i->period().from)) || (!starting && period.overlaps (i->period ()))) { @@ -83,7 +83,7 @@ SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, } /* Discard anything in _decoded_image_subtitles that is outside 5 seconds either side of period */ - + list<ContentImageSubtitle>::iterator i = _decoded_image_subtitles.begin(); while (i != _decoded_image_subtitles.end()) { list<ContentImageSubtitle>::iterator tmp = i; diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index 8ba74404f..c958419c7 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -40,7 +40,7 @@ public: protected: void seek (ContentTime, bool); - + void image_subtitle (ContentTimePeriod period, boost::shared_ptr<Image>, dcpomatic::Rect<double>); void text_subtitle (std::list<dcp::SubtitleString>); @@ -56,7 +56,7 @@ private: */ virtual std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod period, bool starting) const = 0; virtual std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod period, bool starting) const = 0; - + boost::shared_ptr<const SubtitleContent> _subtitle_content; }; diff --git a/src/lib/timer.cc b/src/lib/timer.cc index 69a7e3aa9..42f1cb350 100644 --- a/src/lib/timer.cc +++ b/src/lib/timer.cc @@ -81,7 +81,7 @@ StateTimer::~StateTimer () return; } - + set_state (N_("")); cout << _name << N_(":\n"); diff --git a/src/lib/timer.h b/src/lib/timer.h index 8c4b046bf..4293fee0d 100644 --- a/src/lib/timer.h +++ b/src/lib/timer.h @@ -39,7 +39,7 @@ class PeriodTimer public: PeriodTimer (std::string n); ~PeriodTimer (); - + private: /** name to use when giving output */ diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index d16287111..4a2d768f4 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -45,7 +45,7 @@ using boost::shared_ptr; TranscodeJob::TranscodeJob (shared_ptr<const Film> film) : Job (film) { - + } string @@ -101,7 +101,7 @@ TranscodeJob::status () const /// TRANSLATORS: fps here is an abbreviation for frames per second s << "; " << fixed << setprecision (1) << fps << " " << _("fps"); } - + return s.str (); } @@ -111,11 +111,11 @@ TranscodeJob::remaining_time () const { /* _transcoder might be destroyed by the job-runner thread */ shared_ptr<Transcoder> t = _transcoder; - + if (!t) { return 0; } - + float fps = t->current_encoding_rate (); if (fps == 0) { diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h index efe3f9719..23a856069 100644 --- a/src/lib/transcode_job.h +++ b/src/lib/transcode_job.h @@ -33,7 +33,7 @@ class TranscodeJob : public Job { public: TranscodeJob (boost::shared_ptr<const Film>); - + std::string name () const; std::string json_name () const; void run (); diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 4ff0c6dfe..3ecc3a064 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -67,7 +67,7 @@ Transcoder::go () if (!_film->burn_subtitles ()) { _writer->write (_player->get_subtitle_fonts ()); } - + for (DCPTime t; t < length; t += frame) { list<shared_ptr<PlayerVideo> > v = _player->get_video (t, true); for (list<shared_ptr<PlayerVideo> >::const_iterator i = v.begin(); i != v.end(); ++i) { diff --git a/src/lib/types.h b/src/lib/types.h index 655aeba09..b0e9e51ac 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -115,7 +115,7 @@ struct Crop if (s.height < minimum) { s.height = minimum; } - + return s; } @@ -130,7 +130,7 @@ struct CPLSummary , cpl_annotation_text (a) , cpl_file (f) {} - + std::string dcp_directory; std::string cpl_id; std::string cpl_annotation_text; diff --git a/src/lib/update.cc b/src/lib/update.cc index f433ff991..24cd28b16 100644 --- a/src/lib/update.cc +++ b/src/lib/update.cc @@ -64,7 +64,7 @@ UpdateChecker::UpdateChecker () curl_easy_setopt (_curl, CURLOPT_WRITEFUNCTION, write_callback_wrapper); curl_easy_setopt (_curl, CURLOPT_WRITEDATA, this); curl_easy_setopt (_curl, CURLOPT_TIMEOUT, 20); - + string const agent = "dcpomatic/" + string (dcpomatic_version); curl_easy_setopt (_curl, CURLOPT_USERAGENT, agent.c_str ()); @@ -74,7 +74,7 @@ UpdateChecker::UpdateChecker () UpdateChecker::~UpdateChecker () { /* We are not cleaning up our thread, but hey well */ - + curl_easy_cleanup (_curl); curl_global_cleanup (); delete[] _buffer; @@ -100,12 +100,12 @@ UpdateChecker::thread () } --_to_do; lock.unlock (); - + try { _offset = 0; /* Perform the request */ - + int r = curl_easy_perform (_curl); if (r != CURLE_OK) { set_state (FAILED); @@ -113,7 +113,7 @@ UpdateChecker::thread () } /* Parse the reply */ - + _buffer[_offset] = '\0'; string s (_buffer); cxml::Document doc ("Update"); @@ -133,7 +133,7 @@ UpdateChecker::thread () if (version_less_than (dcpomatic_version, stable)) { _stable = stable; } - + if (Config::instance()->check_for_test_updates() && version_less_than (dcpomatic_version, test)) { _test = test; } @@ -148,7 +148,7 @@ UpdateChecker::thread () } } } - + size_t UpdateChecker::write_callback (void* data, size_t size, size_t nmemb) { @@ -203,13 +203,13 @@ UpdateChecker::version_less_than (string const & a, string const & b) } else { am = raw_convert<int> (ap[2]); } - + float bm; if (ends_with (bp[2], "devel")) { bm = raw_convert<int> (bp[2].substr (0, bp[2].length() - 5)) + 0.5; } else { bm = raw_convert<int> (bp[2]); } - + return am < bm; } diff --git a/src/lib/update.h b/src/lib/update.h index 461217a37..b82be7808 100644 --- a/src/lib/update.h +++ b/src/lib/update.h @@ -51,7 +51,7 @@ public: boost::mutex::scoped_lock lm (_data_mutex); return _state; } - + /** @return new stable version, if there is one */ boost::optional<std::string> stable () { boost::mutex::scoped_lock lm (_data_mutex); @@ -63,7 +63,7 @@ public: boost::mutex::scoped_lock lm (_data_mutex); return _test; } - + /** @return true if the last signal emission was the first */ bool last_emit_was_first () const { boost::mutex::scoped_lock lm (_data_mutex); @@ -78,7 +78,7 @@ public: private: friend struct update_checker_test; - + static UpdateChecker* _instance; static bool version_less_than (std::string const & a, std::string const & b); diff --git a/src/lib/upmixer_a.h b/src/lib/upmixer_a.h index 111846fe0..389d52d25 100644 --- a/src/lib/upmixer_a.h +++ b/src/lib/upmixer_a.h @@ -31,7 +31,7 @@ class UpmixerA : public AudioProcessor { public: UpmixerA (int sampling_rate); - + std::string name () const; std::string id () const; ChannelCount in_channels () const; diff --git a/src/lib/util.cc b/src/lib/util.cc index ad4349da2..05eb3121e 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -184,7 +184,7 @@ int addr2line (void const * const addr) { char addr2line_cmd[512] = { 0 }; - sprintf (addr2line_cmd, "addr2line -f -p -e %.256s %p > %s", program_name.c_str(), addr, backtrace_file.string().c_str()); + sprintf (addr2line_cmd, "addr2line -f -p -e %.256s %p > %s", program_name.c_str(), addr, backtrace_file.string().c_str()); return system(addr2line_cmd); } @@ -198,19 +198,19 @@ exception_handler(struct _EXCEPTION_POINTERS * info) FILE* f = fopen_boost (backtrace_file, "w"); fprintf (f, "C-style exception %d\n", info->ExceptionRecord->ExceptionCode); fclose(f); - + if (info->ExceptionRecord->ExceptionCode != EXCEPTION_STACK_OVERFLOW) { CONTEXT* context = info->ContextRecord; SymInitialize (GetCurrentProcess (), 0, true); - + STACKFRAME frame = { 0 }; - + /* setup initial stack frame */ #if _WIN64 frame.AddrPC.Offset = context->Rip; frame.AddrStack.Offset = context->Rsp; frame.AddrFrame.Offset = context->Rbp; -#else +#else frame.AddrPC.Offset = context->Eip; frame.AddrStack.Offset = context->Esp; frame.AddrFrame.Offset = context->Ebp; @@ -218,7 +218,7 @@ exception_handler(struct _EXCEPTION_POINTERS * info) frame.AddrPC.Mode = AddrModeFlat; frame.AddrStack.Mode = AddrModeFlat; frame.AddrFrame.Mode = AddrModeFlat; - + while ( StackWalk ( IMAGE_FILE_MACHINE_I386, @@ -235,13 +235,13 @@ exception_handler(struct _EXCEPTION_POINTERS * info) addr2line((void *) frame.AddrPC.Offset); } } else { -#ifdef _WIN64 +#ifdef _WIN64 addr2line ((void *) info->ContextRecord->Rip); -#else +#else addr2line ((void *) info->ContextRecord->Eip); -#endif +#endif } - + return EXCEPTION_CONTINUE_SEARCH; } #endif @@ -273,7 +273,7 @@ terminate () << e.what() << std::endl; } catch (...) { - std::cerr << __FUNCTION__ << " caught unknown/unhandled exception." + std::cerr << __FUNCTION__ << " caught unknown/unhandled exception." << std::endl; } @@ -306,8 +306,8 @@ dcpomatic_setup () */ std::locale::global (boost::locale::generator().generate ("")); boost::filesystem::path::imbue (std::locale ()); -#endif - +#endif + avfilter_register_all (); #ifdef DCPOMATIC_OSX @@ -323,7 +323,7 @@ dcpomatic_setup () Pango::init (); dcp::init (); - + Ratio::setup_ratios (); PresetColourConversion::setup_colour_conversion_presets (); VideoContentScale::setup_scales (); @@ -382,7 +382,7 @@ dcpomatic_setup_gettext_i18n (string lang) #if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX) bindtextdomain ("libdcpomatic2", mo_path().string().c_str()); bind_textdomain_codeset ("libdcpomatic2", "UTF8"); -#endif +#endif #ifdef DCPOMATIC_LINUX bindtextdomain ("libdcpomatic2", LINUX_LOCALE_PREFIX); @@ -434,7 +434,7 @@ md5_digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t si fclose (f); --i; - } + } digester.add (buffer.get(), size - to_do); return digester.get (); @@ -516,7 +516,7 @@ valid_image_file (boost::filesystem::path f) if (boost::starts_with (f.leaf().string(), "._")) { return false; } - + string ext = f.extension().string(); transform (ext.begin(), ext.end(), ext.begin(), ::tolower); return ( @@ -555,7 +555,7 @@ fit_ratio_within (float ratio, dcp::Size full_frame) if (ratio < full_frame.ratio ()) { return dcp::Size (rint (full_frame.height * ratio), full_frame.height); } - + return dcp::Size (full_frame.width, rint (full_frame.width / ratio)); } @@ -578,7 +578,7 @@ subtitle_period (AVSubtitle const & sub) /* End time is not known */ return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3)); } - + return FFmpegSubtitlePeriod ( packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3), packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3) @@ -593,7 +593,7 @@ split_get_request (string url) KEY, VALUE } state = AWAITING_QUESTION_MARK; - + map<string, string> r; string k; string v; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index f97e46322..8c6f6c7eb 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -119,7 +119,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, cxml::ConstNodePtr node _scale = VideoContentScale (node->node_child ("Scale")); } - + if (node->optional_node_child ("ColourConversion")) { _colour_conversion = ColourConversion (node->node_child ("ColourConversion"), version); } @@ -168,7 +168,7 @@ VideoContent::VideoContent (shared_ptr<const Film> film, vector<shared_ptr<Conte if (vc->fade_in() != ref->fade_in() || vc->fade_out() != ref->fade_out()) { throw JoinError (_("Content to be joined must have the same fades.")); } - + _video_length += vc->video_length (); } @@ -239,7 +239,7 @@ VideoContent::take_from_video_examiner (shared_ptr<VideoExaminer> d) LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length); set_default_colour_conversion (); - + signal_changed (VideoContentProperty::VIDEO_SIZE); signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); signal_changed (VideoContentProperty::VIDEO_SCALE); @@ -251,14 +251,14 @@ VideoContent::set_left_crop (int c) { { boost::mutex::scoped_lock lm (_mutex); - + if (_crop.left == c) { return; } - + _crop.left = c; } - + signal_changed (VideoContentProperty::VIDEO_CROP); } @@ -270,10 +270,10 @@ VideoContent::set_right_crop (int c) if (_crop.right == c) { return; } - + _crop.right = c; } - + signal_changed (VideoContentProperty::VIDEO_CROP); } @@ -285,10 +285,10 @@ VideoContent::set_top_crop (int c) if (_crop.top == c) { return; } - + _crop.top = c; } - + signal_changed (VideoContentProperty::VIDEO_CROP); } @@ -300,7 +300,7 @@ VideoContent::set_bottom_crop (int c) if (_crop.bottom == c) { return; } - + _crop.bottom = c; } @@ -478,10 +478,10 @@ VideoContent::set_video_frame_rate (float r) if (_video_frame_rate == r) { return; } - + _video_frame_rate = r; } - + signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); } @@ -489,7 +489,7 @@ optional<float> VideoContent::fade (Frame f) const { DCPOMATIC_ASSERT (f >= 0); - + if (f < fade_in()) { return float (f) / fade_in(); } @@ -550,7 +550,7 @@ VideoContent::processing_description () const d << " (" << fixed << setprecision(2) << scaled.ratio() << ":1)\n"; } - + if (scaled != container_size) { d << String::compose ( _("Padded with black to fit container %1 (%2x%3)"), @@ -563,7 +563,7 @@ VideoContent::processing_description () const d << _("Content frame rate"); d << " " << fixed << setprecision(4) << video_frame_rate() << "\n"; - + FrameRateChange frc (video_frame_rate(), film->video_frame_rate ()); d << frc.description () << "\n"; diff --git a/src/lib/video_content.h b/src/lib/video_content.h index abc9c5fa3..01e3cb2aa 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -54,7 +54,7 @@ public: virtual std::string identifier () const; virtual void set_default_colour_conversion (); - + Frame video_length () const { boost::mutex::scoped_lock lm (_mutex); return _video_length; @@ -65,7 +65,7 @@ public: if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) { return _video_length / 2; } - + return _video_length; } @@ -73,7 +73,7 @@ public: boost::mutex::scoped_lock lm (_mutex); return _video_size; } - + float video_frame_rate () const { boost::mutex::scoped_lock lm (_mutex); return _video_frame_rate; @@ -93,7 +93,7 @@ public: void set_fade_in (Frame); void set_fade_out (Frame); - + VideoFrameType video_frame_type () const { boost::mutex::scoped_lock lm (_mutex); return _video_frame_type; @@ -149,7 +149,7 @@ public: boost::mutex::scoped_lock lm (_mutex); return _fade_out; } - + dcp::Size video_size_after_3d_split () const; dcp::Size video_size_after_crop () const; @@ -176,7 +176,7 @@ private: friend struct audio_sampling_rate_test; void setup_default_colour_conversion (); - + dcp::Size _video_size; VideoFrameType _video_frame_type; Crop _crop; diff --git a/src/lib/video_content_scale.cc b/src/lib/video_content_scale.cc index 59ff4bd9b..c8c295361 100644 --- a/src/lib/video_content_scale.cc +++ b/src/lib/video_content_scale.cc @@ -84,13 +84,13 @@ string VideoContentScale::id () const { SafeStringStream s; - + if (_ratio) { s << _ratio->id (); } else { s << (_scale ? "S1" : "S0"); } - + return s.str (); } @@ -122,7 +122,7 @@ VideoContentScale::from_id (string id) return VideoContentScale (true); } - + /** @param display_container Size of the container that we are displaying this content in. * @param film_container The size of the film's image. */ @@ -154,7 +154,7 @@ VideoContentScale::size (shared_ptr<const VideoContent> c, dcp::Size display_con float (display_container.width) / film_container.width, float (display_container.height) / film_container.height ); - + size.width = rint (size.width * scale); size.height = rint (size.height * scale); } diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 9d165ab02..fcc262163 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -52,7 +52,7 @@ list<ContentVideo> VideoDecoder::decoded_video (Frame frame) { list<ContentVideo> output; - + for (list<ContentVideo>::const_iterator i = _decoded_video.begin(); i != _decoded_video.end(); ++i) { if (i->frame == frame) { output.push_back (*i); @@ -224,7 +224,7 @@ VideoDecoder::fill_3d (Frame from, Frame to, Eyes eye) } } } - + /** Called by subclasses when they have a video frame ready */ void VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame) @@ -272,7 +272,7 @@ VideoDecoder::video (shared_ptr<const ImageProxy> image, Frame frame) boost::optional<Frame> from; boost::optional<Frame> to; - + if (_decoded_video.empty() && _last_seek_time && _last_seek_accurate) { from = _last_seek_time->frames (_video_content->video_frame_rate ()); to = to_push.front().frame; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 8643b0def..ae1fb3e87 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -118,7 +118,7 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j) job->sub (_("Checking existing image data")); check_existing_picture_asset (); - + _picture_asset_writer = _picture_asset->start_write ( _film->internal_video_asset_dir() / _film->internal_video_asset_filename(), _film->interop() ? dcp::INTEROP : dcp::SMPTE, @@ -133,7 +133,7 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j) if (_film->encrypted ()) { _sound_asset->set_key (_film->key ()); } - + /* Write the sound asset into the film directory so that we leave the creation of the DCP directory until the last minute. */ @@ -227,14 +227,14 @@ Writer::fake_write (int frame, Eyes eyes) /* The queue is too big; wait until that is sorted out */ _full_condition.wait (lock); } - + FILE* file = fopen_boost (_film->info_file (), "rb"); if (!file) { throw ReadFileError (_film->info_file ()); } dcp::FrameInfo info = read_frame_info (file, frame, eyes); fclose (file); - + QueueItem qi; qi.type = QueueItem::FAKE; qi.size = info.size; @@ -318,7 +318,7 @@ try bool done_something = false; while (true) { - + if (_finish || _queued_full_in_memory > _maximum_frames_in_memory || have_sequenced_image_at_queue_head ()) { /* We've got something to do: go and do it */ break; @@ -349,7 +349,7 @@ try LOG_WARNING (N_("- type FULL, frame %1, eyes %2"), i->frame, i->eyes); } else { LOG_WARNING (N_("- type FAKE, size %1, frame %2, eyes %3"), i->size, i->frame, i->eyes); - } + } } LOG_WARNING (N_("Last written frame %1, last written eyes %2"), _last_written_frame, _last_written_eyes); } @@ -399,7 +399,7 @@ try _last_written_frame = qi.frame; _last_written_eyes = qi.eyes; - + shared_ptr<Job> job = _job.lock (); DCPOMATIC_ASSERT (job); int64_t total = _film->length().frames (_film->video_frame_rate ()); @@ -443,7 +443,7 @@ try ); i->encoded->write_via_temp (_film->j2c_path (i->frame, i->eyes, true), _film->j2c_path (i->frame, i->eyes, false)); - + lock.lock (); i->encoded.reset (); --_queued_full_in_memory; @@ -473,7 +473,7 @@ Writer::terminate_thread (bool can_throw) if (_thread == 0) { return; } - + _finish = true; _empty_condition.notify_all (); _full_condition.notify_all (); @@ -483,10 +483,10 @@ Writer::terminate_thread (bool can_throw) if (can_throw) { rethrow (); } - + delete _thread; _thread = 0; -} +} void Writer::finish () @@ -494,17 +494,17 @@ Writer::finish () if (!_thread) { return; } - + terminate_thread (true); _picture_asset_writer->finalize (); if (_sound_asset_writer) { _sound_asset_writer->finalize (); } - + /* Hard-link the video asset into the DCP */ boost::filesystem::path video_from = _picture_asset->file (); - + boost::filesystem::path video_to; video_to /= _film->dir (_film->dcp_name()); video_to /= video_asset_filename (_picture_asset); @@ -528,7 +528,7 @@ Writer::finish () boost::filesystem::path audio_to; audio_to /= _film->dir (_film->dcp_name ()); audio_to /= audio_asset_filename (_sound_asset); - + boost::filesystem::rename (_film->file (audio_asset_filename (_sound_asset)), audio_to, ec); if (ec) { throw FileError ( @@ -547,7 +547,7 @@ Writer::finish () _film->dcp_content_type()->libdcp_kind () ) ); - + dcp.add (cpl); shared_ptr<dcp::Reel> reel (new dcp::Reel ()); @@ -583,7 +583,7 @@ Writer::finish () _film->dir (_film->dcp_name ()) / ("sub_" + _subtitle_asset->id() + ".mxf") ); } - + reel->add (shared_ptr<dcp::ReelSubtitleAsset> ( new dcp::ReelSubtitleAsset ( _subtitle_asset, @@ -593,7 +593,7 @@ Writer::finish () ) )); } - + cpl->add (reel); shared_ptr<Job> job = _job.lock (); @@ -637,14 +637,14 @@ Writer::check_existing_picture_asset_frame (FILE* asset, int f, Eyes eyes) LOG_GENERAL ("Existing frame %1 has no info file", f); return false; } - + dcp::FrameInfo info = read_frame_info (file, f, eyes); fclose (file); if (info.size == 0) { LOG_GENERAL ("Existing frame %1 has no info file", f); return false; } - + /* Read the data from the asset and hash it */ dcpomatic_fseek (asset, info.offset, SEEK_SET); Data data (info.size); @@ -738,9 +738,9 @@ Writer::write (PlayerSubtitles subs) s->set_edit_rate (dcp::Fraction (_film->video_frame_rate (), 1)); s->set_time_code_rate (_film->video_frame_rate ()); _subtitle_asset = s; - } + } } - + for (list<dcp::SubtitleString>::const_iterator i = subs.text.begin(); i != subs.text.end(); ++i) { _subtitle_asset->add (*i); } @@ -779,7 +779,7 @@ long Writer::frame_info_position (int frame, Eyes eyes) const { static int const info_size = 48; - + switch (eyes) { case EYES_BOTH: return frame * info_size; @@ -790,7 +790,7 @@ Writer::frame_info_position (int frame, Eyes eyes) const default: DCPOMATIC_ASSERT (false); } - + DCPOMATIC_ASSERT (false); } @@ -802,7 +802,7 @@ Writer::read_frame_info (FILE* file, int frame, Eyes eyes) const dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET); fread (&info.offset, sizeof (info.offset), 1, file); fread (&info.size, sizeof (info.size), 1, file); - + char hash_buffer[33]; fread (hash_buffer, 1, 32, file); hash_buffer[32] = '\0'; diff --git a/src/lib/writer.h b/src/lib/writer.h index 90b36962c..486d7d672 100644 --- a/src/lib/writer.h +++ b/src/lib/writer.h @@ -56,7 +56,7 @@ public: QueueItem () : size (0) {} - + enum Type { /** a normal frame with some JPEG200 data */ FULL, @@ -98,7 +98,7 @@ public: ~Writer (); bool can_fake_write (int) const; - + void write (Data, int, Eyes); void fake_write (int, Eyes); void repeat (int, Eyes); @@ -149,7 +149,7 @@ private: * ordering */ int _maximum_frames_in_memory; - + /** number of FULL written frames */ int _full_written; /** number of FAKE written frames */ @@ -159,7 +159,7 @@ private: due to the limit of frames to be held in memory. */ int _pushed_to_disk; - + boost::shared_ptr<dcp::PictureAsset> _picture_asset; boost::shared_ptr<dcp::PictureAssetWriter> _picture_asset_writer; boost::shared_ptr<dcp::SoundAsset> _sound_asset; |
