diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-16 12:32:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-16 12:32:04 +0100 |
| commit | 308488324dbc4d8b709d3fb1dc9fee0479346c21 (patch) | |
| tree | 446989a0bea3db683e5200da89c955140b175682 /src/lib | |
| parent | cfdd68eb5fb0ef8423e860103ad4e5510994f1da (diff) | |
| parent | 362ed9ee4f73bee21b3ef8d3b449bb8e8877f501 (diff) | |
Merge master.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_content.cc | 11 | ||||
| -rw-r--r-- | src/lib/audio_mapping.cc | 14 | ||||
| -rw-r--r-- | src/lib/colour_conversion.cc | 20 | ||||
| -rw-r--r-- | src/lib/config.cc | 24 | ||||
| -rw-r--r-- | src/lib/config.h | 11 | ||||
| -rw-r--r-- | src/lib/content.cc | 9 | ||||
| -rw-r--r-- | src/lib/dci_metadata.cc | 7 | ||||
| -rw-r--r-- | src/lib/dcp_video_frame.cc | 18 | ||||
| -rw-r--r-- | src/lib/ffmpeg.cc | 7 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 13 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.h | 1 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 1 | ||||
| -rw-r--r-- | src/lib/film.cc | 18 | ||||
| -rw-r--r-- | src/lib/image_examiner.cc | 3 | ||||
| -rw-r--r-- | src/lib/kdm.cc | 3 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 2 | ||||
| -rw-r--r-- | src/lib/server.cc | 6 | ||||
| -rw-r--r-- | src/lib/server_finder.cc | 5 | ||||
| -rw-r--r-- | src/lib/sndfile_content.cc | 9 | ||||
| -rw-r--r-- | src/lib/subrip_content.cc | 14 | ||||
| -rw-r--r-- | src/lib/subtitle_content.cc | 15 | ||||
| -rw-r--r-- | src/lib/update.cc | 7 | ||||
| -rw-r--r-- | src/lib/util.cc | 29 | ||||
| -rw-r--r-- | src/lib/util.h | 10 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 21 |
25 files changed, 128 insertions, 150 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index d9e00ff14..e8fd4bbd3 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -18,6 +18,7 @@ */ #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "audio_content.h" #include "analyse_audio_job.h" #include "job_manager.h" @@ -30,8 +31,8 @@ using std::string; using std::vector; using boost::shared_ptr; -using boost::lexical_cast; using boost::dynamic_pointer_cast; +using dcp::raw_convert; int const AudioContentProperty::AUDIO_CHANNELS = 200; int const AudioContentProperty::AUDIO_LENGTH = 201; @@ -59,8 +60,6 @@ AudioContent::AudioContent (shared_ptr<const Film> f, boost::filesystem::path p) AudioContent::AudioContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node) : Content (f, node) { - LocaleGuard lg; - _audio_gain = node->number_child<float> ("AudioGain"); _audio_delay = node->number_child<int> ("AudioDelay"); } @@ -90,11 +89,9 @@ AudioContent::AudioContent (shared_ptr<const Film> f, vector<shared_ptr<Content> void AudioContent::as_xml (xmlpp::Node* node) const { - LocaleGuard lg; - boost::mutex::scoped_lock lm (_mutex); - node->add_child("AudioGain")->add_child_text (lexical_cast<string> (_audio_gain)); - node->add_child("AudioDelay")->add_child_text (lexical_cast<string> (_audio_delay)); + node->add_child("AudioGain")->add_child_text (raw_convert<string> (_audio_gain)); + node->add_child("AudioDelay")->add_child_text (raw_convert<string> (_audio_delay)); } diff --git a/src/lib/audio_mapping.cc b/src/lib/audio_mapping.cc index 969397b0b..496300b48 100644 --- a/src/lib/audio_mapping.cc +++ b/src/lib/audio_mapping.cc @@ -17,9 +17,9 @@ */ -#include <boost/lexical_cast.hpp> #include <libxml++/libxml++.h> #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "audio_mapping.h" #include "util.h" @@ -30,8 +30,8 @@ using std::pair; using std::string; using std::min; using boost::shared_ptr; -using boost::lexical_cast; using boost::dynamic_pointer_cast; +using dcp::raw_convert; AudioMapping::AudioMapping () : _content_channels (0) @@ -94,7 +94,7 @@ AudioMapping::AudioMapping (shared_ptr<const cxml::Node> node, int state_version set ( (*i)->number_attribute<int> ("Content"), static_cast<dcp::Channel> ((*i)->number_attribute<int> ("DCP")), - lexical_cast<float> ((*i)->content ()) + raw_convert<float> ((*i)->content ()) ); } } @@ -115,14 +115,14 @@ AudioMapping::get (int c, dcp::Channel d) const void AudioMapping::as_xml (xmlpp::Node* node) const { - node->add_child ("ContentChannels")->add_child_text (lexical_cast<string> (_content_channels)); + node->add_child ("ContentChannels")->add_child_text (raw_convert<string> (_content_channels)); for (int c = 0; c < _content_channels; ++c) { for (int d = 0; d < MAX_DCP_AUDIO_CHANNELS; ++d) { xmlpp::Element* t = node->add_child ("Gain"); - t->set_attribute ("Content", lexical_cast<string> (c)); - t->set_attribute ("DCP", lexical_cast<string> (d)); - t->add_child_text (lexical_cast<string> (get (c, static_cast<dcp::Channel> (d)))); + t->set_attribute ("Content", raw_convert<string> (c)); + t->set_attribute ("DCP", raw_convert<string> (d)); + t->add_child_text (raw_convert<string> (get (c, static_cast<dcp::Channel> (d)))); } } } diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc index e4a2a84bf..73ee72249 100644 --- a/src/lib/colour_conversion.cc +++ b/src/lib/colour_conversion.cc @@ -17,9 +17,9 @@ */ -#include <boost/lexical_cast.hpp> #include <libxml++/libxml++.h> #include <dcp/colour_matrix.h> +#include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include "config.h" #include "colour_conversion.h" @@ -32,8 +32,8 @@ using std::string; using std::cout; using std::vector; using boost::shared_ptr; -using boost::lexical_cast; using boost::optional; +using dcp::raw_convert; ColourConversion::ColourConversion () : input_gamma (2.4) @@ -64,8 +64,6 @@ ColourConversion::ColourConversion (double i, bool il, double const m[3][3], dou ColourConversion::ColourConversion (cxml::NodePtr node) : matrix (3, 3) { - LocaleGuard lg; - input_gamma = node->number_child<double> ("InputGamma"); input_gamma_linearised = node->bool_child ("InputGammaLinearised"); @@ -79,7 +77,7 @@ ColourConversion::ColourConversion (cxml::NodePtr node) for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) { int const ti = (*i)->number_attribute<int> ("i"); int const tj = (*i)->number_attribute<int> ("j"); - matrix(ti, tj) = lexical_cast<double> ((*i)->content ()); + matrix(ti, tj) = raw_convert<double> ((*i)->content ()); } output_gamma = node->number_child<double> ("OutputGamma"); @@ -88,21 +86,19 @@ ColourConversion::ColourConversion (cxml::NodePtr node) void ColourConversion::as_xml (xmlpp::Node* node) const { - LocaleGuard lg; - - node->add_child("InputGamma")->add_child_text (lexical_cast<string> (input_gamma)); + node->add_child("InputGamma")->add_child_text (raw_convert<string> (input_gamma)); node->add_child("InputGammaLinearised")->add_child_text (input_gamma_linearised ? "1" : "0"); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { xmlpp::Element* m = node->add_child("Matrix"); - m->set_attribute ("i", lexical_cast<string> (i)); - m->set_attribute ("j", lexical_cast<string> (j)); - m->add_child_text (lexical_cast<string> (matrix (i, j))); + m->set_attribute ("i", raw_convert<string> (i)); + m->set_attribute ("j", raw_convert<string> (j)); + m->add_child_text (raw_convert<string> (matrix (i, j))); } } - node->add_child("OutputGamma")->add_child_text (lexical_cast<string> (output_gamma)); + node->add_child("OutputGamma")->add_child_text (raw_convert<string> (output_gamma)); } optional<size_t> diff --git a/src/lib/config.cc b/src/lib/config.cc index ca8d0bc53..754346418 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -24,6 +24,7 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <dcp/colour_matrix.h> +#include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include "config.h" #include "server.h" @@ -46,10 +47,10 @@ using std::max; using std::exception; using std::cerr; using boost::shared_ptr; -using boost::lexical_cast; using boost::optional; using boost::algorithm::is_any_of; using boost::algorithm::split; +using dcp::raw_convert; Config* Config::_instance = 0; @@ -60,6 +61,7 @@ Config::Config () , _use_any_servers (true) , _tms_path (".") , _sound_processor (SoundProcessor::from_id (N_("dolby_cp750"))) + , _allow_any_dcp_frame_rate (false) , _default_still_length (10) , _default_container (Ratio::from_id ("185")) , _default_dcp_content_type (DCPContentType::from_dci_name ("TST")) @@ -87,8 +89,6 @@ Config::Config () void Config::read () { - LocaleGuard lg; - if (!boost::filesystem::exists (file (false))) { read_old_metadata (); return; @@ -188,6 +188,7 @@ Config::read () _check_for_test_updates = f.optional_bool_child("CheckForTestUpdates").get_value_or (false); _maximum_j2k_bandwidth = f.optional_number_child<int> ("MaximumJ2KBandwidth").get_value_or (250000000); + _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate"); } void @@ -308,15 +309,13 @@ Config::instance () void Config::write () const { - LocaleGuard lg; - xmlpp::Document doc; xmlpp::Element* root = doc.create_root_node ("Config"); root->add_child("Version")->add_child_text ("1"); - root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads)); + root->add_child("NumLocalEncodingThreads")->add_child_text (raw_convert<string> (_num_local_encoding_threads)); root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ()); - root->add_child("ServerPortBase")->add_child_text (lexical_cast<string> (_server_port_base)); + 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) { @@ -344,9 +343,9 @@ Config::write () const _default_dci_metadata.as_xml (root->add_child ("DCIMetadata")); - root->add_child("DefaultStillLength")->add_child_text (lexical_cast<string> (_default_still_length)); - root->add_child("DefaultJ2KBandwidth")->add_child_text (lexical_cast<string> (_default_j2k_bandwidth)); - root->add_child("DefaultAudioDelay")->add_child_text (lexical_cast<string> (_default_audio_delay)); + root->add_child("DefaultStillLength")->add_child_text (raw_convert<string> (_default_still_length)); + root->add_child("DefaultJ2KBandwidth")->add_child_text (raw_convert<string> (_default_j2k_bandwidth)); + root->add_child("DefaultAudioDelay")->add_child_text (raw_convert<string> (_default_audio_delay)); for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) { i->as_xml (root->add_child ("ColourConversion")); @@ -365,8 +364,9 @@ Config::write () const root->add_child("CheckForUpdates")->add_child_text (_check_for_updates ? "1" : "0"); root->add_child("CheckForTestUpdates")->add_child_text (_check_for_test_updates ? "1" : "0"); - root->add_child("MaximumJ2KBandwidth")->add_child_text (lexical_cast<string> (_maximum_j2k_bandwidth)); - + 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"); + doc.write_to_file_formatted (file(false).string ()); } diff --git a/src/lib/config.h b/src/lib/config.h index ee11dcadb..ffaacf8f1 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -116,6 +116,10 @@ public: std::list<int> allowed_dcp_frame_rates () const { return _allowed_dcp_frame_rates; } + + bool allow_any_dcp_frame_rate () const { + return _allow_any_dcp_frame_rate; + } DCIMetadata default_dci_metadata () const { return _default_dci_metadata; @@ -241,6 +245,11 @@ public: changed (); } + void set_allow_any_dcp_frame_rate (bool a) { + _allow_any_dcp_frame_rate = a; + changed (); + } + void set_default_dci_metadata (DCIMetadata d) { _default_dci_metadata = d; changed (); @@ -369,6 +378,8 @@ private: /** Our sound processor */ SoundProcessor const * _sound_processor; std::list<int> _allowed_dcp_frame_rates; + /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */ + bool _allow_any_dcp_frame_rate; /** Default DCI metadata for newly-created Films */ DCIMetadata _default_dci_metadata; boost::optional<std::string> _language; diff --git a/src/lib/content.cc b/src/lib/content.cc index 0c37d9386..c4836cfa8 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -24,6 +24,7 @@ #include <boost/thread/mutex.hpp> #include <libxml++/libxml++.h> #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "content.h" #include "util.h" #include "content_factory.h" @@ -40,7 +41,7 @@ using std::list; using std::cout; using std::vector; using boost::shared_ptr; -using boost::lexical_cast; +using dcp::raw_convert; int const ContentProperty::PATH = 400; int const ContentProperty::POSITION = 401; @@ -123,9 +124,9 @@ Content::as_xml (xmlpp::Node* node) const node->add_child("Path")->add_child_text (i->string ()); } node->add_child("Digest")->add_child_text (_digest); - node->add_child("Position")->add_child_text (lexical_cast<string> (_position.get ())); - node->add_child("TrimStart")->add_child_text (lexical_cast<string> (_trim_start.get ())); - node->add_child("TrimEnd")->add_child_text (lexical_cast<string> (_trim_end.get ())); + node->add_child("Position")->add_child_text (raw_convert<string> (_position.get ())); + node->add_child("TrimStart")->add_child_text (raw_convert<string> (_trim_start.get ())); + node->add_child("TrimEnd")->add_child_text (raw_convert<string> (_trim_end.get ())); } void diff --git a/src/lib/dci_metadata.cc b/src/lib/dci_metadata.cc index 27306a15e..2c6e43654 100644 --- a/src/lib/dci_metadata.cc +++ b/src/lib/dci_metadata.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,13 +19,14 @@ #include <iostream> #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "dci_metadata.h" #include "i18n.h" using std::string; -using boost::lexical_cast; using boost::shared_ptr; +using dcp::raw_convert; DCIMetadata::DCIMetadata (shared_ptr<const cxml::Node> node) { @@ -42,7 +43,7 @@ DCIMetadata::DCIMetadata (shared_ptr<const cxml::Node> node) void DCIMetadata::as_xml (xmlpp::Node* root) const { - root->add_child("ContentVersion")->add_child_text (lexical_cast<string> (content_version)); + root->add_child("ContentVersion")->add_child_text (raw_convert<string> (content_version)); root->add_child("AudioLanguage")->add_child_text (audio_language); root->add_child("SubtitleLanguage")->add_child_text (subtitle_language); root->add_child("Territory")->add_child_text (territory); diff --git a/src/lib/dcp_video_frame.cc b/src/lib/dcp_video_frame.cc index 2b7a2e18f..59f356a5a 100644 --- a/src/lib/dcp_video_frame.cc +++ b/src/lib/dcp_video_frame.cc @@ -47,6 +47,7 @@ #include <dcp/xyz_frame.h> #include <dcp/rgb_xyz.h> #include <dcp/colour_matrix.h> +#include <dcp/raw_convert.h> #include <libcxml/cxml.h> #include "film.h" #include "dcp_video_frame.h" @@ -67,6 +68,7 @@ using std::cout; using boost::shared_ptr; using boost::lexical_cast; using dcp::Size; +using dcp::raw_convert; #define DCI_COEFFICENT (48.0 / 52.37) @@ -270,7 +272,7 @@ DCPVideoFrame::encode_remotely (ServerDescription serv) { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver (io_service); - boost::asio::ip::tcp::resolver::query query (serv.host_name(), boost::lexical_cast<string> (Config::instance()->server_port_base ())); + boost::asio::ip::tcp::resolver::query query (serv.host_name(), raw_convert<string> (Config::instance()->server_port_base ())); boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query); shared_ptr<Socket> socket (new Socket); @@ -280,9 +282,9 @@ DCPVideoFrame::encode_remotely (ServerDescription serv) xmlpp::Document doc; xmlpp::Element* root = doc.create_root_node ("EncodingRequest"); - root->add_child("Version")->add_child_text (lexical_cast<string> (SERVER_LINK_VERSION)); - root->add_child("Width")->add_child_text (lexical_cast<string> (_image->size().width)); - root->add_child("Height")->add_child_text (lexical_cast<string> (_image->size().height)); + root->add_child("Version")->add_child_text (raw_convert<string> (SERVER_LINK_VERSION)); + root->add_child("Width")->add_child_text (raw_convert<string> (_image->size().width)); + root->add_child("Height")->add_child_text (raw_convert<string> (_image->size().height)); add_metadata (root); stringstream xml; @@ -306,7 +308,7 @@ DCPVideoFrame::encode_remotely (ServerDescription serv) void DCPVideoFrame::add_metadata (xmlpp::Element* el) const { - el->add_child("Frame")->add_child_text (lexical_cast<string> (_frame)); + el->add_child("Frame")->add_child_text (raw_convert<string> (_frame)); switch (_eyes) { case EYES_BOTH: @@ -324,9 +326,9 @@ DCPVideoFrame::add_metadata (xmlpp::Element* el) const _conversion.as_xml (el->add_child("ColourConversion")); - el->add_child("FramesPerSecond")->add_child_text (lexical_cast<string> (_frames_per_second)); - el->add_child("J2KBandwidth")->add_child_text (lexical_cast<string> (_j2k_bandwidth)); - el->add_child("Resolution")->add_child_text (lexical_cast<string> (int (_resolution))); + el->add_child("FramesPerSecond")->add_child_text (raw_convert<string> (_frames_per_second)); + el->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth)); + el->add_child("Resolution")->add_child_text (raw_convert<string> (int (_resolution))); } EncodedData::EncodedData (int s) diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index a98aa9828..316b9614d 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -22,6 +22,7 @@ extern "C" { #include <libavformat/avformat.h> #include <libswscale/swscale.h> } +#include <dcp/raw_convert.h> #include "ffmpeg.h" #include "ffmpeg_content.h" #include "exceptions.h" @@ -33,7 +34,7 @@ using std::string; using std::cout; using std::stringstream; using boost::shared_ptr; -using boost::lexical_cast; +using dcp::raw_convert; boost::mutex FFmpeg::_mutex; @@ -94,8 +95,8 @@ FFmpeg::setup_general () /* These durations are in microseconds, and represent how far into the content file we will look for streams. */ - av_dict_set (&options, "analyzeduration", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0); - av_dict_set (&options, "probesize", lexical_cast<string> (5 * 60 * 1e6).c_str(), 0); + 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 ()); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index a51cb3de8..a374bcf3e 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -21,6 +21,7 @@ extern "C" { #include <libavformat/avformat.h> } #include <libcxml/cxml.h> +#include <libdcp/raw_convert.h> #include "ffmpeg_content.h" #include "ffmpeg_examiner.h" #include "compose.hpp" @@ -40,8 +41,8 @@ using std::list; using std::cout; using std::pair; using boost::shared_ptr; -using boost::lexical_cast; using boost::dynamic_pointer_cast; +using libdcp::raw_convert; int const FFmpegContentProperty::SUBTITLE_STREAMS = 100; int const FFmpegContentProperty::SUBTITLE_STREAM = 101; @@ -152,7 +153,7 @@ FFmpegContent::as_xml (xmlpp::Node* node) const } if (_first_video) { - node->add_child("FirstVideo")->add_child_text (lexical_cast<string> (_first_video.get().get())); + node->add_child("FirstVideo")->add_child_text (raw_convert<string> (_first_video.get().get())); } } @@ -322,7 +323,7 @@ void FFmpegStream::as_xml (xmlpp::Node* root) const { root->add_child("Name")->add_child_text (name); - root->add_child("Id")->add_child_text (lexical_cast<string> (_id)); + root->add_child("Id")->add_child_text (raw_convert<string> (_id)); } FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node, int version) @@ -338,10 +339,10 @@ void FFmpegAudioStream::as_xml (xmlpp::Node* root) const { FFmpegStream::as_xml (root); - root->add_child("FrameRate")->add_child_text (lexical_cast<string> (frame_rate)); - root->add_child("Channels")->add_child_text (lexical_cast<string> (channels)); + root->add_child("FrameRate")->add_child_text (raw_convert<string> (frame_rate)); + root->add_child("Channels")->add_child_text (raw_convert<string> (channels)); if (first_audio) { - root->add_child("FirstAudio")->add_child_text (lexical_cast<string> (first_audio.get().get())); + root->add_child("FirstAudio")->add_child_text (raw_convert<string> (first_audio.get().get())); } mapping.as_xml (root->add_child("Mapping")); } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 1ab0a92d0..37746ac9d 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -21,6 +21,7 @@ #define DCPOMATIC_FFMPEG_CONTENT_H #include <boost/enable_shared_from_this.hpp> +#include <boost/lexical_cast.hpp> #include "video_content.h" #include "audio_content.h" #include "subtitle_content.h" diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 0a4624569..9ae5f0485 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -27,7 +27,6 @@ #include <iomanip> #include <iostream> #include <stdint.h> -#include <boost/lexical_cast.hpp> #include <sndfile.h> extern "C" { #include <libavcodec/avcodec.h> diff --git a/src/lib/film.cc b/src/lib/film.cc index 33cb30460..bdd650437 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -35,6 +35,7 @@ #include <dcp/signer.h> #include <dcp/util.h> #include <dcp/local_time.h> +#include <dcp/raw_convert.h> #include "film.h" #include "job.h" #include "util.h" @@ -71,7 +72,6 @@ using std::cout; using std::list; using boost::shared_ptr; using boost::weak_ptr; -using boost::lexical_cast; using boost::dynamic_pointer_cast; using boost::to_upper_copy; using boost::ends_with; @@ -79,6 +79,7 @@ using boost::starts_with; using boost::optional; using dcp::Size; using dcp::Signer; +using dcp::raw_convert; /* 5 -> 6 * AudioMapping XML changed. @@ -151,9 +152,10 @@ string Film::video_identifier () const { assert (container ()); - LocaleGuard lg; stringstream s; + s.imbue (std::locale::classic ()); + s << container()->id() << "_" << resolution_to_string (_resolution) << "_" << _playlist->video_identifier() @@ -339,12 +341,10 @@ Film::encoded_frames () const shared_ptr<xmlpp::Document> Film::metadata () const { - LocaleGuard lg; - shared_ptr<xmlpp::Document> doc (new xmlpp::Document); xmlpp::Element* root = doc->create_root_node ("Metadata"); - root->add_child("Version")->add_child_text (lexical_cast<string> (current_state_version)); + root->add_child("Version")->add_child_text (raw_convert<string> (current_state_version)); root->add_child("Name")->add_child_text (_name); root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0"); @@ -359,11 +359,11 @@ Film::metadata () const root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution)); root->add_child("Scaler")->add_child_text (_scaler->id ()); root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0"); - root->add_child("J2KBandwidth")->add_child_text (lexical_cast<string> (_j2k_bandwidth)); + root->add_child("J2KBandwidth")->add_child_text (raw_convert<string> (_j2k_bandwidth)); _dci_metadata.as_xml (root->add_child ("DCIMetadata")); - root->add_child("VideoFrameRate")->add_child_text (lexical_cast<string> (_video_frame_rate)); + root->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate)); root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date)); - root->add_child("AudioChannels")->add_child_text (lexical_cast<string> (_audio_channels)); + root->add_child("AudioChannels")->add_child_text (raw_convert<string> (_audio_channels)); root->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0"); root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0"); root->add_child("Interop")->add_child_text (_interop ? "1" : "0"); @@ -391,8 +391,6 @@ Film::write_metadata () const list<string> Film::read_metadata () { - LocaleGuard lg; - if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) { throw StringError (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version. You will need to create a new Film, re-add your content and set it up again. Sorry!")); } diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 3897bbf37..004b89e65 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -18,7 +18,6 @@ */ #include <iostream> -#include <boost/lexical_cast.hpp> #include <Magick++.h> #include "image_content.h" #include "image_examiner.h" @@ -33,8 +32,6 @@ using std::cout; using std::list; using std::sort; using boost::shared_ptr; -using boost::lexical_cast; -using boost::bad_lexical_cast; ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const ImageContent> content, shared_ptr<Job>) : _film (film) diff --git a/src/lib/kdm.cc b/src/lib/kdm.cc index 793a3fa0e..902f0d333 100644 --- a/src/lib/kdm.cc +++ b/src/lib/kdm.cc @@ -164,6 +164,9 @@ make_cinema_kdms ( return cinema_kdms; } +/** @param from KDM from time in local time. + * @param to KDM to time in local time. + */ void write_kdm_files ( shared_ptr<const Film> film, diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 1e8a3319c..9a048980c 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -19,7 +19,6 @@ #include <libcxml/cxml.h> #include <boost/shared_ptr.hpp> -#include <boost/lexical_cast.hpp> #include "playlist.h" #include "sndfile_content.h" #include "sndfile_decoder.h" @@ -46,7 +45,6 @@ using boost::optional; using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; -using boost::lexical_cast; Playlist::Playlist () : _sequence_video (true) diff --git a/src/lib/server.cc b/src/lib/server.cc index bf7541c33..6bcff7e6e 100644 --- a/src/lib/server.cc +++ b/src/lib/server.cc @@ -27,9 +27,9 @@ #include <sstream> #include <iostream> #include <boost/algorithm/string.hpp> -#include <boost/lexical_cast.hpp> #include <boost/scoped_array.hpp> #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "server.h" #include "util.h" #include "scaler.h" @@ -56,8 +56,8 @@ using boost::thread; using boost::bind; using boost::scoped_array; using boost::optional; -using boost::lexical_cast; using dcp::Size; +using dcp::raw_convert; Server::Server (shared_ptr<Log> log, bool verbose) : _log (log) @@ -246,7 +246,7 @@ Server::broadcast_received () /* Reply to the client saying what we can do */ xmlpp::Document doc; xmlpp::Element* root = doc.create_root_node ("ServerAvailable"); - root->add_child("Threads")->add_child_text (lexical_cast<string> (_worker_threads.size ())); + root->add_child("Threads")->add_child_text (raw_convert<string> (_worker_threads.size ())); stringstream xml; doc.write_to_stream (xml, "UTF-8"); diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc index 1080d24c4..de8a3852c 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/server_finder.cc @@ -18,6 +18,7 @@ */ #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "server_finder.h" #include "exceptions.h" #include "util.h" @@ -32,7 +33,7 @@ using std::vector; using std::cout; using boost::shared_ptr; using boost::scoped_array; -using boost::lexical_cast; +using dcp::raw_convert; ServerFinder* ServerFinder::_instance = 0; @@ -82,7 +83,7 @@ try } try { boost::asio::ip::udp::resolver resolver (io_service); - boost::asio::ip::udp::resolver::query query (*i, lexical_cast<string> (Config::instance()->server_port_base() + 1)); + boost::asio::ip::udp::resolver::query query (*i, raw_convert<string> (Config::instance()->server_port_base() + 1)); boost::asio::ip::udp::endpoint end_point (*resolver.resolve (query)); socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point); } catch (...) { diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 0cf65967f..cad5eb8e7 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -18,6 +18,7 @@ */ #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "sndfile_content.h" #include "sndfile_decoder.h" #include "film.h" @@ -31,7 +32,7 @@ using std::string; using std::stringstream; using std::cout; using boost::shared_ptr; -using boost::lexical_cast; +using dcp::raw_convert; SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p) : Content (f, p) @@ -132,9 +133,9 @@ SndfileContent::as_xml (xmlpp::Node* node) const Content::as_xml (node); AudioContent::as_xml (node); - node->add_child("AudioChannels")->add_child_text (lexical_cast<string> (audio_channels ())); - node->add_child("AudioLength")->add_child_text (lexical_cast<string> (audio_length().get ())); - node->add_child("AudioFrameRate")->add_child_text (lexical_cast<string> (audio_frame_rate ())); + node->add_child("AudioChannels")->add_child_text (raw_convert<string> (audio_channels ())); + node->add_child("AudioLength")->add_child_text (raw_convert<string> (audio_length().get ())); + node->add_child("AudioFrameRate")->add_child_text (raw_convert<string> (audio_frame_rate ())); _audio_mapping.as_xml (node->add_child("AudioMapping")); } diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index eb9c67d9a..8f9c28e29 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -21,12 +21,14 @@ #include "util.h" #include "subrip.h" #include "film.h" +#include <dcp/raw_convert.h> #include "i18n.h" using std::stringstream; using std::string; using std::cout; +using dcp::raw_convert; using boost::shared_ptr; using boost::lexical_cast; @@ -81,12 +83,10 @@ SubRipContent::information () const void SubRipContent::as_xml (xmlpp::Node* node) const { - LocaleGuard lg; - node->add_child("Type")->add_child_text ("SubRip"); Content::as_xml (node); SubtitleContent::as_xml (node); - node->add_child("Length")->add_child_text (lexical_cast<string> (_length.get ())); + node->add_child("Length")->add_child_text (raw_convert<string> (_length.get ())); } DCPTime @@ -101,13 +101,11 @@ SubRipContent::full_length () const string SubRipContent::identifier () const { - LocaleGuard lg; - stringstream s; s << Content::identifier() - << "_" << subtitle_scale() - << "_" << subtitle_x_offset() - << "_" << subtitle_y_offset(); + << "_" << raw_convert<string> (subtitle_scale()) + << "_" << raw_convert<string> (subtitle_x_offset()) + << "_" << raw_convert<string> (subtitle_y_offset()); return s.str (); } diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 4c6e60192..783c73e25 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ */ #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "subtitle_content.h" #include "util.h" #include "exceptions.h" @@ -28,8 +29,8 @@ using std::string; using std::vector; using std::cout; using boost::shared_ptr; -using boost::lexical_cast; using boost::dynamic_pointer_cast; +using dcp::raw_convert; int const SubtitleContentProperty::SUBTITLE_X_OFFSET = 500; int const SubtitleContentProperty::SUBTITLE_Y_OFFSET = 501; @@ -50,8 +51,6 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, shared_ptr<const cxm , _subtitle_y_offset (0) , _subtitle_scale (1) { - LocaleGuard lg; - if (version >= 7) { _subtitle_x_offset = node->number_child<float> ("SubtitleXOffset"); _subtitle_y_offset = node->number_child<float> ("SubtitleYOffset"); @@ -92,11 +91,9 @@ SubtitleContent::SubtitleContent (shared_ptr<const Film> f, vector<shared_ptr<Co void SubtitleContent::as_xml (xmlpp::Node* root) const { - LocaleGuard lg; - - root->add_child("SubtitleXOffset")->add_child_text (lexical_cast<string> (_subtitle_x_offset)); - root->add_child("SubtitleYOffset")->add_child_text (lexical_cast<string> (_subtitle_y_offset)); - root->add_child("SubtitleScale")->add_child_text (lexical_cast<string> (_subtitle_scale)); + 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)); + root->add_child("SubtitleScale")->add_child_text (raw_convert<string> (_subtitle_scale)); } void diff --git a/src/lib/update.cc b/src/lib/update.cc index 019db8e76..c7527ee49 100644 --- a/src/lib/update.cc +++ b/src/lib/update.cc @@ -22,6 +22,7 @@ #include <boost/algorithm/string.hpp> #include <curl/curl.h> #include <libcxml/cxml.h> +#include <dcp/raw_convert.h> #include "update.h" #include "version.h" #include "ui_signaller.h" @@ -32,7 +33,7 @@ using std::cout; using std::min; using std::string; using std::stringstream; -using boost::lexical_cast; +using dcp::raw_convert; /** Singleton instance */ UpdateChecker* UpdateChecker::_instance = 0; @@ -130,12 +131,12 @@ UpdateChecker::thread () current_pre = true; } - float current_float = lexical_cast<float> (current); + float current_float = raw_convert<float> (current); if (current_pre) { current_float -= 0.005; } - if (current_float < lexical_cast<float> (_stable)) { + if (current_float < raw_convert<float> (_stable)) { set_state (YES); } else { set_state (NO); diff --git a/src/lib/util.cc b/src/lib/util.cc index 0eb14845d..14dfd1fa5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -37,7 +37,6 @@ #include <boost/algorithm/string.hpp> #include <boost/bind.hpp> #include <boost/lambda/lambda.hpp> -#include <boost/lexical_cast.hpp> #include <boost/thread.hpp> #include <boost/filesystem.hpp> #ifdef DCPOMATIC_WINDOWS @@ -53,6 +52,7 @@ #include <dcp/util.h> #include <dcp/signer_chain.h> #include <dcp/signer.h> +#include <dcp/raw_convert.h> extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> @@ -101,9 +101,9 @@ using std::streampos; using std::set_terminate; using boost::shared_ptr; using boost::thread; -using boost::lexical_cast; using boost::optional; using dcp::Size; +using dcp::raw_convert; static boost::thread::id ui_thread; static boost::filesystem::path backtrace_file; @@ -687,14 +687,14 @@ int get_required_int (multimap<string, string> const & kv, string k) { string const v = get_required_string (kv, k); - return lexical_cast<int> (v); + return raw_convert<int> (v); } float get_required_float (multimap<string, string> const & kv, string k) { string const v = get_required_string (kv, k); - return lexical_cast<float> (v); + return raw_convert<float> (v); } string @@ -724,7 +724,7 @@ get_optional_int (multimap<string, string> const & kv, string k) return 0; } - return lexical_cast<int> (i->second); + return raw_convert<int> (i->second); } /** Trip an assert if the caller is not in the UI thread */ @@ -761,25 +761,6 @@ audio_channel_name (int c) return channels[c]; } -LocaleGuard::LocaleGuard () - : _old (0) -{ - char const * old = setlocale (LC_NUMERIC, 0); - - if (old) { - _old = strdup (old); - if (strcmp (_old, "C")) { - setlocale (LC_NUMERIC, "C"); - } - } -} - -LocaleGuard::~LocaleGuard () -{ - setlocale (LC_NUMERIC, _old); - free (_old); -} - bool valid_image_file (boost::filesystem::path f) { diff --git a/src/lib/util.h b/src/lib/util.h index 8e65bbb54..58c2771b7 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -131,15 +131,7 @@ private: int _timeout; }; -class LocaleGuard -{ -public: - LocaleGuard (); - ~LocaleGuard (); - -private: - char* _old; -}; +extern int64_t video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second); /** @class ScopedTemporary * @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope. diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 9edbc104a..bd24621f7 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -20,6 +20,7 @@ #include <iomanip> #include <libcxml/cxml.h> #include <dcp/colour_matrix.h> +#include <dcp/raw_convert.h> #include "video_content.h" #include "video_examiner.h" #include "compose.hpp" @@ -45,9 +46,9 @@ using std::setprecision; using std::cout; using std::vector; using boost::shared_ptr; -using boost::lexical_cast; using boost::optional; using boost::dynamic_pointer_cast; +using dcp::raw_convert; vector<VideoContentScale> VideoContentScale::_scales; @@ -155,15 +156,15 @@ void VideoContent::as_xml (xmlpp::Node* node) const { boost::mutex::scoped_lock lm (_mutex); - node->add_child("VideoLength")->add_child_text (lexical_cast<string> (_video_length.get ())); - node->add_child("VideoWidth")->add_child_text (lexical_cast<string> (_video_size.width)); - node->add_child("VideoHeight")->add_child_text (lexical_cast<string> (_video_size.height)); - node->add_child("VideoFrameRate")->add_child_text (lexical_cast<string> (_video_frame_rate)); - node->add_child("VideoFrameType")->add_child_text (lexical_cast<string> (static_cast<int> (_video_frame_type))); - node->add_child("LeftCrop")->add_child_text (boost::lexical_cast<string> (_crop.left)); - node->add_child("RightCrop")->add_child_text (boost::lexical_cast<string> (_crop.right)); - node->add_child("TopCrop")->add_child_text (boost::lexical_cast<string> (_crop.top)); - node->add_child("BottomCrop")->add_child_text (boost::lexical_cast<string> (_crop.bottom)); + node->add_child("VideoLength")->add_child_text (raw_convert<string> (_video_length.get ())); + node->add_child("VideoWidth")->add_child_text (raw_convert<string> (_video_size.width)); + node->add_child("VideoHeight")->add_child_text (raw_convert<string> (_video_size.height)); + node->add_child("VideoFrameRate")->add_child_text (raw_convert<string> (_video_frame_rate)); + node->add_child("VideoFrameType")->add_child_text (raw_convert<string> (static_cast<int> (_video_frame_type))); + node->add_child("LeftCrop")->add_child_text (raw_convert<string> (_crop.left)); + node->add_child("RightCrop")->add_child_text (raw_convert<string> (_crop.right)); + node->add_child("TopCrop")->add_child_text (raw_convert<string> (_crop.top)); + node->add_child("BottomCrop")->add_child_text (raw_convert<string> (_crop.bottom)); _scale.as_xml (node->add_child("Scale")); _colour_conversion.as_xml (node->add_child("ColourConversion")); } |
