the suspected thread-unsafe crash bugs on OS X.
float s = data[i];
float as = fabsf (s);
if (as < 10e-7) {
- /* locked_stringstream can't serialise and recover inf or -inf, so prevent such
+ /* We may struggle to serialise and recover inf or -inf, so prevent such
values by replacing with this (140dB down) */
s = as = 10e-7;
}
#include "i18n.h"
using std::string;
-using std::cout;
using boost::shared_ptr;
AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels)
string
AudioFilterGraph::src_parameters () const
{
- locked_stringstream a;
+ char layout[64];
+ av_get_channel_layout_string (layout, sizeof(layout), 0, _channel_layout);
- char buffer[64];
- av_get_channel_layout_string (buffer, sizeof(buffer), 0, _channel_layout);
+ char buffer[256];
+ snprintf (
+ buffer, sizeof(buffer), "time_base=1/1:sample_rate=%d:sample_fmt=%s:channel_layout=%s",
+ _sample_rate, av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), layout
+ );
- a << "time_base=1/1:sample_rate=" << _sample_rate << ":"
- << "sample_fmt=" << av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP) << ":"
- << "channel_layout=" << buffer;
-
- return a.str ();
+ return buffer;
}
void *
if (r < 0) {
char buffer[256];
av_strerror (r, buffer, sizeof(buffer));
- throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)"), buffer));
+ throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)"), &buffer[0]));
}
while (true) {
boost::algorithm::replace_all (body, "$END_TIME", name_values['t']);
boost::algorithm::replace_all (body, "$CINEMA_NAME", i.cinema->name);
- locked_stringstream screens;
+ string screens;
BOOST_FOREACH (ScreenKDM const & j, i.screen_kdms) {
- screens << j.screen->name << ", ";
+ screens += j.screen->name + ", ";
}
- boost::algorithm::replace_all (body, "$SCREENS", screens.str().substr (0, screens.str().length() - 2));
+ boost::algorithm::replace_all (body, "$SCREENS", screens.substr (0, screens.length() - 2));
Emailer email (config->kdm_from(), i.cinema->emails, subject, body);
-/* Defines String::compose(fmt, arg...) for easy, i18n-friendly
+/* -*- c-basic-offset: 2 -*-
+ * Defines String::compose(fmt, arg...) for easy, i18n-friendly
* composition of strings.
*
* Version 1.0.
#ifndef STRING_COMPOSE_H
#define STRING_COMPOSE_H
-#include <locked_sstream.h>
+#include <boost/filesystem.hpp>
#include <string>
#include <list>
-#include <map> // for multimap
+#include <map>
+#include <inttypes.h>
namespace StringPrivate
{
std::string str() const;
private:
- locked_stringstream os;
+ std::string os;
int arg_no;
// we store the output as a list - when the output string is requested, the
}
}
+ template <typename T>
+ inline void write(std::string& s, const T& obj)
+ {
+ /* Assume anything not specialized has a to_string() method */
+ s += to_string (obj);
+ }
+
+ template <>
+ inline void write(std::string& s, const int64_t& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%" PRId64, obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, const int& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%d", obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, const unsigned int& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%ud", obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, const long unsigned int& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%lu", obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, const float& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%f", obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, const char& obj)
+ {
+ s += obj;
+ }
+
+ template <>
+ inline void write(std::string& s, const double& obj)
+ {
+ char buffer[64];
+ snprintf(buffer, 64, "%f", obj);
+ s += buffer;
+ }
+
+ template <>
+ inline void write(std::string& s, char const * const & obj)
+ {
+ s += obj;
+ }
+
+ template <>
+ inline void write(std::string& s, char* const & obj)
+ {
+ s += obj;
+ }
+
+ template <>
+ inline void write(std::string& s, const std::string& obj)
+ {
+ s += obj;
+ }
+
+ template <>
+ inline void write(std::string& s, const boost::filesystem::path & obj)
+ {
+ s += obj.string();
+ }
// implementation of class Composition
template <typename T>
inline Composition &Composition::arg(const T &obj)
{
- os << obj;
-
- std::string rep = os.str();
+ write(os, obj);
- if (!rep.empty()) { // manipulators don't produce output
- for (specification_map::const_iterator i = specs.lower_bound(arg_no),
- end = specs.upper_bound(arg_no); i != end; ++i) {
+ if (!os.empty()) { // manipulators don't produce output
+ for (specification_map::const_iterator i = specs.lower_bound(arg_no), end = specs.upper_bound(arg_no); i != end; ++i) {
output_list::iterator pos = i->second;
++pos;
- output.insert(pos, rep);
+ output.insert(pos, os);
}
- os.str(std::string());
- //os.clear();
+ os = "";
++arg_no;
}
#include "job.h"
#include "compose.hpp"
#include "raw_convert.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/thread/mutex.hpp>
string
Content::identifier () const
{
- locked_stringstream s;
-
- s << Content::digest()
- << "_" << position().get()
- << "_" << trim_start().get()
- << "_" << trim_end().get();
-
- return s.str ();
+ char buffer[256];
+ snprintf (
+ buffer, sizeof(buffer), "%s_%" PRId64 "_%" PRId64 "_%" PRId64,
+ Content::digest().c_str(), position().get(), trim_start().get(), trim_end().get()
+ );
+ return buffer;
}
bool
string
DCPContent::identifier () const
{
- locked_stringstream s;
- s << Content::identifier() << "_" << video->identifier() << "_";
+ string s = Content::identifier() + "_" + video->identifier() + "_";
if (subtitle) {
- s << subtitle->identifier () << " ";
+ s += subtitle->identifier () + " ";
}
- s << (_reference_video ? "1" : "0")
- << (_reference_subtitle ? "1" : "0");
- return s.str ();
+
+ s += string (_reference_video ? "1" : "0") + string (_reference_subtitle ? "1" : "0");
+ return s;
}
void
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
*/
#include "dcpomatic_time.h"
+#include <inttypes.h>
-using std::ostream;
+using std::string;
template <>
Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
return b;
}
-ostream &
-operator<< (ostream& s, ContentTime t)
+string
+to_string (ContentTime t)
{
- s << "[CONT " << t.get() << " " << t.seconds() << "s]";
- return s;
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds());
+ return buffer;
}
-ostream &
-operator<< (ostream& s, DCPTime t)
+string
+to_string (DCPTime t)
{
- s << "[DCP " << t.get() << " " << t.seconds() << "s]";
- return s;
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds());
+ return buffer;
}
-ostream &
-operator<< (ostream& s, DCPTimePeriod p)
+string
+to_string (DCPTimePeriod p)
{
- s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]";
- return s;
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds());
+ return buffer;
}
/*
- Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include "frame_rate_change.h"
#include "dcpomatic_assert.h"
-#include <locked_sstream.h>
#include <boost/optional.hpp>
#include <stdint.h>
#include <cmath>
int f;
split (r, h, m, s, f);
- locked_stringstream o;
- o.width (2);
- o.fill ('0');
- o << std::setw(2) << std::setfill('0') << h << ":"
- << std::setw(2) << std::setfill('0') << m << ":"
- << std::setw(2) << std::setfill('0') << s << ":"
- << std::setw(2) << std::setfill('0') << f;
- return o.str ();
+ char buffer[128];
+ snprintf (buffer, sizeof (buffer), "%02d:%02d:%02d:%02d", h, m, s, f);
+ return buffer;
}
DCPTime max (DCPTime a, DCPTime b);
ContentTime min (ContentTime a, ContentTime b);
ContentTime max (ContentTime a, ContentTime b);
-std::ostream& operator<< (std::ostream& s, ContentTime t);
-std::ostream& operator<< (std::ostream& s, DCPTime t);
-std::ostream& operator<< (std::ostream& s, DCPTimePeriod p);
+std::string to_string (ContentTime t);
+std::string to_string (DCPTime t);
+std::string to_string (DCPTimePeriod p);
#endif
*/
#include "digester.h"
-#include <locked_sstream.h>
#include <nettle/md5.h>
#include <iomanip>
unsigned char digest[MD5_DIGEST_SIZE];
md5_digest (&_context, MD5_DIGEST_SIZE, digest);
- locked_stringstream s;
+ char hex[MD5_DIGEST_SIZE * 2 + 1];
for (int i = 0; i < MD5_DIGEST_SIZE; ++i) {
- s << hex << setfill('0') << setw(2) << ((int) digest[i]);
+ sprintf(hex + i * 2, "%02x", digest[i]);
}
- _digest = s.str ();
+ _digest = hex;
}
return _digest.get ();
boost::posix_time::time_duration offset = local_now - utc_now;
sprintf (date_buffer + strlen(date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), abs (offset.hours()), offset.minutes());
- locked_stringstream email;
-
- email << "Date: " << date_buffer << "\r\n"
- << "To: " << address_list (_to) << "\r\n"
- << "From: " << _from << "\r\n";
+ _email = "Date: " + string(date_buffer) + "\r\n"
+ "To: " + address_list (_to) + "\r\n"
+ "From: " + _from + "\r\n";
if (!_cc.empty ()) {
- email << "Cc: " << address_list (_cc) << "\r\n";
+ _email += "Cc: " + address_list (_cc) + "\r\n";
}
if (!_bcc.empty ()) {
- email << "Bcc: " << address_list (_bcc) << "\r\n";
+ _email += "Bcc: " + address_list (_bcc) + "\r\n";
}
string const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
}
if (!_attachments.empty ()) {
- email << "MIME-Version: 1.0\r\n"
- << "Content-Type: multipart/mixed; boundary=" << boundary << "\r\n";
+ _email += "MIME-Version: 1.0\r\n"
+ "Content-Type: multipart/mixed; boundary=" + boundary + "\r\n";
}
- email << "Subject: " << _subject << "\r\n"
- << "User-Agent: DCP-o-matic\r\n"
- << "\r\n";
+ _email += "Subject: " + _subject + "\r\n"
+ "User-Agent: DCP-o-matic\r\n"
+ "\r\n";
if (!_attachments.empty ()) {
- email << "--" << boundary << "\r\n"
- << "Content-Type: text/plain; charset=utf-8\r\n\r\n";
+ _email += "--" + boundary + "\r\n"
+ + "Content-Type: text/plain; charset=utf-8\r\n\r\n";
}
- email << _body;
+ _email += _body;
BOOST_FOREACH (Attachment i, _attachments) {
- email << "\r\n\r\n--" << boundary << "\r\n"
- << "Content-Type: " << i.mime_type << "; name=" << i.name << "\r\n"
- << "Content-Transfer-Encoding: Base64\r\n"
- << "Content-Disposition: attachment; filename=" << i.name << "\r\n\r\n";
+ _email += "\r\n\r\n--" + boundary + "\r\n"
+ "Content-Type: " + i.mime_type + "; name=" + i.name + "\r\n"
+ "Content-Transfer-Encoding: Base64\r\n"
+ "Content-Disposition: attachment; filename=" + i.name + "\r\n\r\n";
BIO* b64 = BIO_new (BIO_f_base64());
char* out;
long int bytes = BIO_get_mem_data (bio, &out);
- email << string (out, bytes);
+ _email += string (out, bytes);
BIO_free_all (b64);
}
if (!_attachments.empty ()) {
- email << "\r\n--" << boundary << "--\r\n";
+ _email += "\r\n--" + boundary + "--\r\n";
}
- _email = email.str ();
-
curl_global_init (CURL_GLOBAL_DEFAULT);
CURL* curl = curl_easy_init ();
#include "compose.hpp"
#include "log.h"
#include "encoded_log_entry.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/algorithm/string.hpp>
*/
#include "encoded_log_entry.h"
-#include <locked_sstream.h>
using std::string;
-using std::fixed;
EncodedLogEntry::EncodedLogEntry (int frame, string ip, double receive, double encode, double send)
: LogEntry (LogEntry::TYPE_GENERAL)
string
EncodedLogEntry::message () const
{
- locked_stringstream m;
- m.precision (2);
- m << fixed
- << "Encoded frame " << _frame << " from " << _ip << ": "
- << "receive " << _receive << "s "
- << "encode " << _encode << "s "
- << "send " << _send << "s.";
-
- return m.str ();
+ char buffer[256];
+ snprintf (buffer, sizeof(buffer), "Encoded frame %d from %s: receive %.2fs encode %.2fs send %.2fs.", _frame, _ip.c_str(), _receive, _encode, _send);
+ return buffer;
}
LOG_TIMING ("encoder-wake thread=%1 queue=%2", boost::this_thread::get_id(), _queue.size());
shared_ptr<DCPVideo> vf = _queue.front ();
- LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", boost::this_thread::get_id(), vf->index(), vf->eyes ());
+ LOG_TIMING ("encoder-pop thread=%1 frame=%2 eyes=%3", boost::this_thread::get_id(), vf->index(), (int) vf->eyes ());
_queue.pop_front ();
lock.unlock ();
string
ffmpeg_version_to_string (int v)
{
- locked_stringstream s;
- s << ((v & 0xff0000) >> 16) << N_(".") << ((v & 0xff00) >> 8) << N_(".") << (v & 0xff);
- return s.str ();
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "%d.%d.%d", ((v & 0xff0000) >> 16), ((v & 0xff00) >> 8), (v & 0xff));
+ return buffer;
}
-
/** Return a user-readable string summarising the versions of our dependencies */
static
string
dependency_version_summary ()
{
- locked_stringstream s;
- s << N_("libavcodec ") << ffmpeg_version_to_string (avcodec_version()) << N_(", ")
- << N_("libavfilter ") << ffmpeg_version_to_string (avfilter_version()) << N_(", ")
- << N_("libavformat ") << ffmpeg_version_to_string (avformat_version()) << N_(", ")
- << N_("libavutil ") << ffmpeg_version_to_string (avutil_version()) << N_(", ")
- << N_("libswscale ") << ffmpeg_version_to_string (swscale_version()) << N_(", ")
- << MagickVersion << N_(", ")
- << N_("libssh ") << ssh_version (0) << N_(", ")
- << N_("libdcp ") << dcp::version << N_(" git ") << dcp::git_commit;
-
- return s.str ();
+ char buffer[512];
+ snprintf (
+ buffer, sizeof(buffer), "libavcodec %s, libavfilter %s, libavformat %s, libavutil %s, libswscale %s, %s, libssh %s, libdcp %s git %s",
+ ffmpeg_version_to_string(avcodec_version()).c_str(),
+ ffmpeg_version_to_string(avfilter_version()).c_str(),
+ ffmpeg_version_to_string(avformat_version()).c_str(),
+ ffmpeg_version_to_string(avutil_version()).c_str(),
+ ffmpeg_version_to_string(swscale_version()).c_str(),
+ MagickVersion,
+ ssh_version(0),
+ dcp::version, dcp::git_commit
+ );
+
+ return buffer;
}
list<string>
{
char buffer[128];
gethostname (buffer, sizeof (buffer));
- info.push_back (String::compose ("Host name %1", buffer));
+ info.push_back (String::compose ("Host name %1", &buffer[0]));
}
#ifdef DCPOMATIC_DEBUG
}
PixelFormatError::PixelFormatError (string o, AVPixelFormat f)
- : runtime_error (String::compose (_("Cannot handle pixel format %1 during %2"), f, o))
+ : runtime_error (String::compose (_("Cannot handle pixel format %1 during %2"), (int) f, o))
{
}
#include "frame_rate_change.h"
#include "raw_convert.h"
#include "subtitle_content.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
extern "C" {
#include <libavformat/avformat.h>
string
FFmpegContent::identifier () const
{
- locked_stringstream s;
-
- s << Content::identifier();
+ string s = Content::identifier();
if (video) {
- s << "_" << video->identifier();
+ s += "_" + video->identifier();
}
if (subtitle) {
- s << "_" << subtitle->identifier();
+ s += "_" + subtitle->identifier();
}
boost::mutex::scoped_lock lm (_mutex);
if (_subtitle_stream) {
- s << "_" << _subtitle_stream->identifier ();
+ s += "_" + _subtitle_stream->identifier ();
}
for (vector<Filter const *>::const_iterator i = _filters.begin(); i != _filters.end(); ++i) {
- s << "_" << (*i)->id ();
+ s += "_" + (*i)->id ();
}
- return s.str ();
+ return s;
}
list<ContentTimePeriod>
/* Maybe we should fail here, but for now we'll just finish off instead */
char buf[256];
av_strerror (r, buf, sizeof(buf));
- LOG_ERROR (N_("error on av_read_frame (%1) (%2)"), buf, r);
+ LOG_ERROR (N_("error on av_read_frame (%1) (%2)"), &buf[0], r);
}
flush ();
#include "ffmpeg_audio_stream.h"
#include "ffmpeg_subtitle_stream.h"
#include "util.h"
-#include <locked_sstream.h>
#include <boost/foreach.hpp>
#include <iostream>
string
FFmpegExaminer::subtitle_stream_name (AVStream* s) const
{
- locked_stringstream n;
+ string n = stream_name (s);
- n << stream_name (s);
-
- if (n.str().empty()) {
- n << _("unknown");
+ if (n.empty()) {
+ n = _("unknown");
}
- return n.str ();
+ return n;
}
string
FFmpegExaminer::stream_name (AVStream* s) const
{
- locked_stringstream n;
+ string n;
if (s->metadata) {
AVDictionaryEntry const * lang = av_dict_get (s->metadata, "language", 0, 0);
if (lang) {
- n << lang->value;
+ n = lang->value;
}
AVDictionaryEntry const * title = av_dict_get (s->metadata, "title", 0, 0);
if (title) {
- if (!n.str().empty()) {
- n << " ";
+ if (!n.empty()) {
+ n += " ";
}
- n << title->value;
+ n += title->value;
}
}
- return n.str ();
+ return n;
}
int
#include "dcpomatic_time.h"
#include "rgba.h"
#include "ffmpeg_stream.h"
+#include <map>
class FFmpegSubtitleStream : public FFmpegStream
{
#include "dcp_content.h"
#include "screen_kdm.h"
#include "cinema.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <dcp/cpl.h>
#include <dcp/certificate_chain.h>
{
DCPOMATIC_ASSERT (container ());
- locked_stringstream s;
- s.imbue (std::locale::classic ());
-
- s << container()->id()
- << "_" << resolution_to_string (_resolution)
- << "_" << _playlist->video_identifier()
- << "_" << _video_frame_rate
- << "_" << j2k_bandwidth();
+ string s = container()->id()
+ + "_" + resolution_to_string (_resolution)
+ + "_" + _playlist->video_identifier()
+ + "_" + raw_convert<string>(_video_frame_rate)
+ + "_" + raw_convert<string>(j2k_bandwidth());
if (encrypted ()) {
- s << "_E";
+ s += "_E";
} else {
- s << "_P";
+ s += "_P";
}
if (_interop) {
- s << "_I";
+ s += "_I";
} else {
- s << "_S";
+ s += "_S";
}
if (_three_d) {
- s << "_3D";
+ s += "_3D";
}
- return s.str ();
+ return s;
}
/** @return The file to write video frame info to */
string
Film::isdcf_name (bool if_created_now) const
{
- locked_stringstream d;
+ string d;
string raw_name = name ();
fixed_name = fixed_name.substr (0, 14);
}
- d << fixed_name;
+ d += fixed_name;
if (dcp_content_type()) {
- d << "_" << dcp_content_type()->isdcf_name();
- d << "-" << isdcf_metadata().content_version;
+ d += "_" + dcp_content_type()->isdcf_name();
+ d += "-" + raw_convert<string>(isdcf_metadata().content_version);
}
ISDCFMetadata const dm = isdcf_metadata ();
if (dm.temp_version) {
- d << "-Temp";
+ d += "-Temp";
}
if (dm.pre_release) {
- d << "-Pre";
+ d += "-Pre";
}
if (dm.red_band) {
- d << "-RedBand";
+ d += "-RedBand";
}
if (!dm.chain.empty ()) {
- d << "-" << dm.chain;
+ d += "-" + dm.chain;
}
if (three_d ()) {
- d << "-3D";
+ d += "-3D";
}
if (dm.two_d_version_of_three_d) {
- d << "-2D";
+ d += "-2D";
}
if (!dm.mastered_luminance.empty ()) {
- d << "-" << dm.mastered_luminance;
+ d += "-" + dm.mastered_luminance;
}
if (video_frame_rate() != 24) {
- d << "-" << video_frame_rate();
+ d += "-" + raw_convert<string>(video_frame_rate());
}
if (container()) {
- d << "_" << container()->isdcf_name();
+ d += "_" + container()->isdcf_name();
}
/* XXX: this uses the first bit of content only */
}
if (content_ratio && content_ratio != container()) {
- d << "-" << content_ratio->isdcf_name();
+ d += "-" + content_ratio->isdcf_name();
}
}
if (!dm.audio_language.empty ()) {
- d << "_" << dm.audio_language;
+ d += "_" + dm.audio_language;
if (!dm.subtitle_language.empty()) {
bool burnt_in = true;
transform (language.begin(), language.end(), language.begin(), ::toupper);
}
- d << "-" << language;
+ d += "-" + language;
} else {
- d << "-XX";
+ d += "-XX";
}
}
if (!dm.territory.empty ()) {
- d << "_" << dm.territory;
+ d += "_" + dm.territory;
if (dm.rating.empty ()) {
- d << "-NR";
+ d += "-NR";
} else {
- d << "-" << dm.rating;
+ d += "-" + dm.rating;
}
}
}
if (non_lfe) {
- d << "_" << non_lfe << lfe;
+ d += String::compose("_%1%2", non_lfe, lfe);
}
/* XXX: HI/VI */
- d << "_" << resolution_to_string (_resolution);
+ d += "_" + resolution_to_string (_resolution);
if (!dm.studio.empty ()) {
- d << "_" << dm.studio;
+ d += "_" + dm.studio;
}
if (if_created_now) {
- d << "_" << boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
+ d += "_" + boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
} else {
- d << "_" << boost::gregorian::to_iso_string (_isdcf_date);
+ d += "_" + boost::gregorian::to_iso_string (_isdcf_date);
}
if (!dm.facility.empty ()) {
- d << "_" << dm.facility;
+ d += "_" + dm.facility;
}
if (_interop) {
- d << "_IOP";
+ d += "_IOP";
} else {
- d << "_SMPTE";
+ d += "_SMPTE";
}
if (three_d ()) {
- d << "-3D";
+ d += "-3D";
}
bool vf = false;
}
if (vf) {
- d << "_VF";
+ d += "_VF";
} else {
- d << "_OV";
+ d += "_OV";
}
- return d.str ();
+ return d;
}
/** @return name to give the DCP */
p /= "j2c";
p /= video_identifier ();
- locked_stringstream s;
- s.width (8);
- s << setfill('0') << reel << "_" << frame;
+ char buffer[256];
+ snprintf(buffer, sizeof(buffer), "%08d_%08" PRId64, reel, frame);
+ string s (buffer);
if (eyes == EYES_LEFT) {
- s << ".L";
+ s += ".L";
} else if (eyes == EYES_RIGHT) {
- s << ".R";
+ s += ".R";
}
- s << ".j2c";
+ s += ".j2c";
if (tmp) {
- s << ".tmp";
+ s += ".tmp";
}
- p /= s.str();
+ p /= s;
return file (p);
}
#include "filter.h"
#include "exceptions.h"
#include "image.h"
-#include <locked_sstream.h>
#include "compose.hpp"
extern "C" {
#include <libavfilter/avfiltergraph.h>
#include "frame_rate_change.h"
#include "exceptions.h"
#include "image_filename_sorter.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
string
ImageContent::identifier () const
{
- locked_stringstream s;
- s << Content::identifier();
- s << "_" << video->identifier ();
- s << "_" << video->length();
- return s.str ();
+ char buffer[256];
+ snprintf (buffer, sizeof(buffer), "%s_%s_%" PRId64, Content::identifier().c_str(), video->identifier().c_str(), video->length());
+ return buffer;
}
bool
#include "scoped_temporary.h"
#include "compose.hpp"
#include "exceptions.h"
-#include <locked_sstream.h>
#include <curl/curl.h>
#include <zip.h>
#include <boost/function.hpp>
temp_zip.close ();
curl_easy_cleanup (curl);
if (cr != CURLE_OK) {
- return String::compose (_("Download failed (%1/%2 error %3)"), url, file, cr);
+ return String::compose (_("Download failed (%1/%2 error %3)"), url, file, (int) cr);
}
/* Open the ZIP file and read `file' out of it */
throw NetworkError (curl_easy_strerror (r));
}
- locked_stringstream s (ls_raw);
list<string> ls;
- while (s.good ()) {
- string line = s.getline ();
- trim (line);
- if (line.length() > 55) {
- string const file = line.substr (55);
- if (file != "." && file != "..") {
- ls.push_back (file);
+ string line;
+ for (size_t i = 0; i < ls_raw.length(); ++i) {
+ line += ls_raw[i];
+ if (ls_raw[i] == '\n') {
+ trim (line);
+ if (line.length() > 55) {
+ string const file = line.substr (55);
+ if (file != "." && file != "..") {
+ ls.push_back (file);
+ }
}
+ line = "";
}
}
int const t = elapsed_sub_time ();
int const r = remaining_time ();
- locked_stringstream s;
+ string s;
if (!finished () && p) {
int pc = lrintf (p.get() * 100);
if (pc == 100) {
pc = 99;
}
- s << pc << N_("%");
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "%d%%", pc);
+ s += buffer;
if (t > 10 && r > 0) {
/// TRANSLATORS: remaining here follows an amount of time that is remaining
/// on an operation.
- s << "; " << seconds_to_approximate_hms (r) << " " << _("remaining");
+ s += "; " + seconds_to_approximate_hms (r) + " " + _("remaining");
}
} else if (finished_ok ()) {
- s << String::compose (_("OK (ran for %1)"), seconds_to_hms (_ran_for));
+ s = String::compose (_("OK (ran for %1)"), seconds_to_hms (_ran_for));
} else if (finished_in_error ()) {
- s << String::compose (_("Error: %1"), error_summary ());
+ s = String::compose (_("Error: %1"), error_summary ());
} else if (finished_cancelled ()) {
- s << _("Cancelled");
+ s = _("Cancelled");
}
- return s.str ();
+ return s;
}
string
*/
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/thread.hpp>
#include "json_server.h"
#include "job_manager.h"
#include "job.h"
#include "util.h"
#include "film.h"
#include "transcode_job.h"
+#include "raw_convert.h"
+#include <boost/asio.hpp>
+#include <boost/bind.hpp>
+#include <boost/thread.hpp>
#include <iostream>
using std::string;
action = r["action"];
}
- locked_stringstream json;
+ string json;
if (action == "status") {
list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
- json << "{ \"jobs\": [";
+ json += "{ \"jobs\": [";
for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
- json << "{ ";
+ json += "{ ";
if ((*i)->film()) {
- json << "\"dcp\": \"" << (*i)->film()->dcp_name() << "\", ";
+ json += "\"dcp\": \"" + (*i)->film()->dcp_name() + "\", ";
}
- json << "\"name\": \"" << (*i)->json_name() << "\", ";
+ json += "\"name\": \"" + (*i)->json_name() + "\", ";
if ((*i)->progress ()) {
- json << "\"progress\": " << (*i)->progress().get() << ", ";
+ json += "\"progress\": " + raw_convert<string>((*i)->progress().get()) + ", ";
} else {
- json << "\"progress\": unknown, ";
+ json += "\"progress\": unknown, ";
}
- json << "\"status\": \"" << (*i)->json_status() << "\"";
- json << " }";
+ json += "\"status\": \"" + (*i)->json_status() + "\"";
+ json += " }";
list<shared_ptr<Job> >::iterator j = i;
++j;
if (j != jobs.end ()) {
- json << ", ";
+ json += ", ";
}
}
- json << "] }";
-
- if (json.str().empty ()) {
- json << "{ }";
- }
+ json += "] }";
}
- locked_stringstream reply;
- reply << "HTTP/1.1 200 OK\r\n"
- << "Content-Length: " << json.str().length() << "\r\n"
- << "Content-Type: application/json\r\n"
- << "\r\n"
- << json.str () << "\r\n";
- cout << "reply: " << json.str() << "\n";
- boost::asio::write (*socket, boost::asio::buffer (reply.str().c_str(), reply.str().length()));
+ string reply = "HTTP/1.1 200 OK\r\n"
+ "Content-Length: " + raw_convert<string>(json.length()) + "\r\n"
+ "Content-Type: application/json\r\n"
+ "\r\n"
+ + json + "\r\n";
+ cout << "reply: " << json << "\n";
+ boost::asio::write (*socket, boost::asio::buffer (reply.c_str(), reply.length()));
}
*/
+#include <boost/asio.hpp>
+
class JSONServer
{
public:
void handle (boost::shared_ptr<boost::asio::ip::tcp::socket> socket);
void request (std::string url, boost::shared_ptr<boost::asio::ip::tcp::socket> socket);
};
-
-
#include "cross.h"
#include "config.h"
#include "string_log_entry.h"
-#include <locked_sstream.h>
#include <time.h>
#include <cstdio>
*/
#include "log_entry.h"
-#include <locked_sstream.h>
+#include <inttypes.h>
#include "i18n.h"
string
LogEntry::get () const
{
- locked_stringstream s;
+ string s;
if (_type & TYPE_TIMING) {
- s << _time.tv_sec << ":" << _time.tv_usec << " ";
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "%" PRId64 ":%" PRId64 " ", static_cast<int64_t> (_time.tv_sec), static_cast<int64_t> (_time.tv_usec));
+ s += buffer;
} else {
char buffer[64];
time_t const sec = _time.tv_sec;
struct tm* t = localtime (&sec);
strftime (buffer, 64, "%c", t);
string a (buffer);
- s << a << N_(": ");
+ s += string(buffer) + N_(": ");
}
if (_type & TYPE_ERROR) {
- s << "ERROR: ";
+ s += "ERROR: ";
}
if (_type & TYPE_WARNING) {
- s << "WARNING: ";
+ s += "WARNING: ";
}
- s << message ();
- return s.str ();
+ s += message ();
+ return s;
}
double
*/
#include "string_log_entry.h"
-#include <locked_sstream.h>
#include "i18n.h"
#include "font.h"
#include "raw_convert.h"
#include "content.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
string
SubtitleContent::identifier () const
{
- locked_stringstream s;
- s << raw_convert<string> (x_scale())
- << "_" << raw_convert<string> (y_scale())
- << "_" << raw_convert<string> (x_offset())
- << "_" << raw_convert<string> (y_offset())
- << "_" << raw_convert<string> (line_spacing());
+ string s = raw_convert<string> (x_scale())
+ + "_" + raw_convert<string> (y_scale())
+ + "_" + raw_convert<string> (x_offset())
+ + "_" + raw_convert<string> (y_offset())
+ + "_" + raw_convert<string> (line_spacing());
/* XXX: I suppose really _fonts shouldn't be in here, since not all
types of subtitle content involve fonts.
*/
BOOST_FOREACH (shared_ptr<Font> f, _fonts) {
for (int i = 0; i < FontFiles::VARIANTS; ++i) {
- s << "_" << f->file(static_cast<FontFiles::Variant>(i)).get_value_or ("Default");
+ s += "_" + f->file(static_cast<FontFiles::Variant>(i)).get_value_or("Default").string();
}
}
how this content looks.
*/
- return s.str ();
+ return s;
}
void
#include "film.h"
#include "transcoder.h"
#include "log.h"
-#include <locked_sstream.h>
#include "compose.hpp"
#include <iostream>
#include <iomanip>
return Job::status ();
}
- locked_stringstream s;
-
- s << Job::status ();
-
- if (!finished () && !_transcoder->finishing ()) {
+ char buffer[256];
+ if (finished() || _transcoder->finishing()) {
+ strncpy (buffer, Job::status().c_str(), 256);
+ } else {
/// TRANSLATORS: fps here is an abbreviation for frames per second
- s << "; " << _transcoder->video_frames_enqueued() << "/"
- << _film->length().frames_round (_film->video_frame_rate ()) << " " << _("frames") << "; "
- << fixed << setprecision (1) << fps << " " << _("fps");
+ snprintf (
+ buffer, sizeof(buffer), "%s; %d/%" PRId64 " frames; %.1f fps",
+ Job::status().c_str(),
+ _transcoder->video_frames_enqueued(),
+ _film->length().frames_round (_film->video_frame_rate ()),
+ fps
+ );
}
- return s.str ();
+ return buffer;
}
/** @return Approximate remaining time in seconds */
#include "version.h"
#include "util.h"
#include "raw_convert.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <curl/curl.h>
#include <boost/algorithm/string.hpp>
#include "digester.h"
#include "audio_processor.h"
#include "compose.hpp"
-#include <locked_sstream.h>
#include <dcp/util.h>
#include <dcp/picture_asset.h>
#include <dcp/sound_asset.h>
int h = m / 60;
m -= (h * 60);
- locked_stringstream hms;
- hms << h << N_(":");
- hms.width (2);
- hms << setfill ('0') << m << N_(":");
- hms.width (2);
- hms << setfill ('0') << s;
-
- return hms.str ();
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "%d:%02d:%02d", h, m, s);
+ return buffer;
}
/** @param s Number of seconds.
int h = m / 60;
m -= (h * 60);
- locked_stringstream ap;
+ string ap;
bool const hours = h > 0;
bool const minutes = h < 6 && m > 0;
if (hours) {
if (m > 30 && !minutes) {
/// TRANSLATORS: h here is an abbreviation for hours
- ap << (h + 1) << _("h");
+ ap += raw_convert<string>(h + 1) + _("h");
} else {
/// TRANSLATORS: h here is an abbreviation for hours
- ap << h << _("h");
+ ap += raw_convert<string>(h) + _("h");
}
if (minutes || seconds) {
- ap << N_(" ");
+ ap += N_(" ");
}
}
/* Minutes */
if (s > 30 && !seconds) {
/// TRANSLATORS: m here is an abbreviation for minutes
- ap << (m + 1) << _("m");
+ ap += raw_convert<string>(m + 1) + _("m");
} else {
/// TRANSLATORS: m here is an abbreviation for minutes
- ap << m << _("m");
+ ap += raw_convert<string>(m) + _("m");
}
if (seconds) {
- ap << N_(" ");
+ ap += N_(" ");
}
}
if (seconds) {
/* Seconds */
/// TRANSLATORS: s here is an abbreviation for seconds
- ap << s << _("s");
+ ap += raw_convert<string>(s) + _("s");
}
- return ap.str ();
+ return ap;
}
double
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
#include <string>
+#include <map>
#include <vector>
#undef check
#include "frame_rate_change.h"
#include "log.h"
#include "raw_convert.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <dcp/colour_matrix.h>
#include <libxml++/libxml++.h>
string
VideoContent::identifier () const
{
- locked_stringstream s;
- s << crop().left
- << "_" << crop().right
- << "_" << crop().top
- << "_" << crop().bottom
- << "_" << scale().id()
- << "_" << _fade_in
- << "_" << _fade_out;
+ char buffer[256];
+ snprintf (
+ buffer, sizeof(buffer), "%d_%d_%d_%d_%s_%" PRId64 "_%" PRId64,
+ crop().left,
+ crop().right,
+ crop().top,
+ crop().bottom,
+ scale().id().c_str(),
+ _fade_in,
+ _fade_out
+ );
+
+ string s (buffer);
if (colour_conversion()) {
- s << "_" << colour_conversion().get().identifier ();
+ s += "_" + colour_conversion().get().identifier ();
}
- return s.str ();
+ return s;
}
string
string
VideoContent::processing_description () const
{
- /* stringstream is OK here as this string is just for presentation to the user */
- locked_stringstream d;
+ string d;
+ char buffer[256];
if (size().width && size().height) {
- d << String::compose (
+ d += String::compose (
_("Content video is %1x%2"),
size_after_3d_split().width,
size_after_3d_split().height
double ratio = size_after_3d_split().ratio ();
if (sample_aspect_ratio ()) {
- d << ", " << _("pixel aspect ratio") << " " << fixed << setprecision(2) << sample_aspect_ratio().get () << ":1";
+ snprintf (buffer, sizeof(buffer), _(", pixel aspect ratio %.2f:1"), sample_aspect_ratio().get());
+ d += buffer;
ratio *= sample_aspect_ratio().get ();
}
- d << "\n" << _("Display aspect ratio") << " " << fixed << setprecision(2) << ratio << ":1\n";
+ snprintf (buffer, sizeof(buffer), _("\nDisplay aspect ratio %.2f:1"), ratio);
+ d += buffer;
}
if ((crop().left || crop().right || crop().top || crop().bottom) && size() != dcp::Size (0, 0)) {
dcp::Size cropped = size_after_crop ();
- d << String::compose (
+ d += String::compose (
_("Cropped to %1x%2"),
cropped.width, cropped.height
);
- d << " (" << fixed << setprecision(2) << cropped.ratio () << ":1)\n";
+ snprintf (buffer, sizeof(buffer), " (%.2f:1)\n", cropped.ratio());
+ d += buffer;
}
shared_ptr<const Film> film = _parent->film ();
dcp::Size const scaled = scale().size (shared_from_this(), container_size, container_size);
if (scaled != size_after_crop ()) {
- d << String::compose (
+ d += String::compose (
_("Scaled to %1x%2"),
scaled.width, scaled.height
);
- d << " (" << fixed << setprecision(2) << scaled.ratio() << ":1)\n";
+ snprintf (buffer, sizeof(buffer), _(" (%.2f:1)\n"), scaled.ratio());
+ d += buffer;
}
if (scaled != container_size) {
- d << String::compose (
+ d += String::compose (
_("Padded with black to fit container %1 (%2x%3)"),
film->container()->nickname (),
container_size.width, container_size.height
);
- d << " (" << fixed << setprecision(2) << container_size.ratio () << ":1)\n";
+ snprintf (buffer, sizeof(buffer), _(" (%.2f:1)\n"), container_size.ratio());
+ d += buffer;
}
if (_parent->video_frame_rate()) {
double const vfr = _parent->video_frame_rate().get ();
- d << _("Content frame rate");
- d << " " << fixed << setprecision(4) << vfr << "\n";
+ snprintf (buffer, sizeof(buffer), _("Content frame rate %.4f\n"), vfr);
+ d += buffer;
FrameRateChange frc (vfr, film->video_frame_rate ());
- d << frc.description () << "\n";
+ d += frc.description () + "\n";
}
- return d.str ();
+ return d;
}
void
#include "video_content.h"
#include "ratio.h"
#include "util.h"
-#include <locked_sstream.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#include <boost/optional.hpp>
string
VideoContentScale::id () const
{
- locked_stringstream s;
-
if (_ratio) {
- s << _ratio->id ();
- } else {
- s << (_scale ? "S1" : "S0");
+ return _ratio->id ();
}
- return s.str ();
+ return (_scale ? "S1" : "S0");
}
string
string
VideoFilterGraph::src_parameters () const
{
- locked_stringstream a;
-
- a << "video_size=" << _size.width << "x" << _size.height << ":"
- << "pix_fmt=" << _pixel_format << ":"
- << "time_base=1/1:"
- << "pixel_aspect=1/1";
-
- return a.str ();
+ char buffer[256];
+ snprintf (buffer, sizeof(buffer), "video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=1/1", _size.width, _size.height, _pixel_format);
+ return buffer;
}
void *
LOG_WARNING (N_("Finishing writer with a left-over queue of %1:"), _queue.size());
for (list<QueueItem>::const_iterator i = _queue.begin(); i != _queue.end(); ++i) {
if (i->type == QueueItem::FULL) {
- LOG_WARNING (N_("- type FULL, frame %1, eyes %2"), i->frame, i->eyes);
+ LOG_WARNING (N_("- type FULL, frame %1, eyes %2"), i->frame, (int) i->eyes);
} else {
- LOG_WARNING (N_("- type FAKE, size %1, frame %2, eyes %3"), i->size, i->frame, i->eyes);
+ LOG_WARNING (N_("- type FAKE, size %1, frame %2, eyes %3"), i->size, i->frame, (int) i->eyes);
}
}
}
switch (qi.type) {
case QueueItem::FULL:
- LOG_DEBUG_ENCODE (N_("Writer FULL-writes %1 (%2)"), qi.frame, qi.eyes);
+ LOG_DEBUG_ENCODE (N_("Writer FULL-writes %1 (%2)"), qi.frame, (int) qi.eyes);
if (!qi.encoded) {
qi.encoded = Data (_film->j2c_path (qi.reel, qi.frame, qi.eyes, false));
}
#include <boost/noncopyable.hpp>
#include <iostream>
#include <fstream>
+/* This is OK as it's only used with DCPOMATIC_WINDOWS */
#include <sstream>
#ifdef check
}
for (size_t i = 0; i < history.size(); ++i) {
- locked_stringstream s;
+ string s;
if (i < 9) {
- s << "&" << (i + 1) << " ";
+ s = String::compose ("&%1 %2", i + 1, history[i].string());
+ } else {
+ s = history[i].string();
}
- s << history[i].string();
- _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
+ _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
}
_history_items = history.size ();
#include "lib/config.h"
#include "lib/exceptions.h"
#include "lib/emailer.h"
-#include <locked_sstream.h>
#include <dcp/certificate.h>
#include <getopt.h>
#include <iostream>
static boost::posix_time::time_duration
duration_from_string (string d)
{
- locked_stringstream s (d);
int N;
- string unit;
- s >> N >> unit;
+ char unit_buf[64] = "\0";
+ sscanf (d.c_str(), "%d %64s", &N, unit_buf);
+ string const unit (unit_buf);
if (N == 0) {
cerr << "Could not understand duration \"" << d << "\"\n";
void update_state ()
{
- locked_stringstream s;
- s << fixed << setprecision(1) << server_log->fps ();
- _fps->SetLabel (std_to_wx (s.str()));
+ _fps->SetLabel (wxString::Format ("%.1f", server_log->fps()));
}
wxTextCtrl* _text;
#include "lib/raw_convert.h"
#include "wx_util.h"
#include "colour_conversion_editor.h"
-#include <locked_sstream.h>
#include <dcp/gamma_transfer_function.h>
#include <dcp/modified_gamma_transfer_function.h>
#include <wx/spinctrl.h>
_ignore_chromaticity_changed = true;
- locked_stringstream s;
- s.setf (std::ios::fixed, std::ios::floatfield);
- s.precision (6);
-
- s << conversion.red().x;
- _red_x->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.red().y;
- _red_y->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.green().x;
- _green_x->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.green().y;
- _green_y->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.blue().x;
- _blue_x->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.blue().y;
- _blue_y->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.white().x;
- _white_x->SetValue (std_to_wx (s.str ()));
-
- s.str ("");
- s << conversion.white().y;
- _white_y->SetValue (std_to_wx (s.str ()));
+ char buffer[256];
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.red().x);
+ _red_x->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.red().y);
+ _red_y->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.green().x);
+ _green_x->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.green().y);
+ _green_y->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.blue().x);
+ _blue_x->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.blue().y);
+ _blue_y->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.white().x);
+ _white_x->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.white().y);
+ _white_y->SetValue (std_to_wx (buffer));
_ignore_chromaticity_changed = false;
if (conversion.adjusted_white ()) {
_adjust_white->SetValue (true);
- s.str ("");
- s << conversion.adjusted_white().get().x;
- _adjusted_white_x->SetValue (std_to_wx (s.str ()));
- s.str ("");
- s << conversion.adjusted_white().get().y;
- _adjusted_white_y->SetValue (std_to_wx (s.str ()));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.adjusted_white().get().x);
+ _adjusted_white_x->SetValue (std_to_wx (buffer));
+ snprintf (buffer, sizeof (buffer), "%.6f", conversion.adjusted_white().get().y);
+ _adjusted_white_y->SetValue (std_to_wx (buffer));
} else {
_adjust_white->SetValue (false);
}
boost::numeric::ublas::matrix<double> m = get().bradford ();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
- locked_stringstream s;
- s.setf (std::ios::fixed, std::ios::floatfield);
- s.precision (7);
- s << m (i, j);
- _bradford[i][j]->SetLabel (std_to_wx (s.str ()));
+ char buffer[256];
+ snprintf (buffer, sizeof (buffer), "%.7f", m (i, j));
+ _bradford[i][j]->SetLabel (std_to_wx (buffer));
}
}
}
boost::numeric::ublas::matrix<double> m = get().rgb_to_xyz ();
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
- locked_stringstream s;
- s.setf (std::ios::fixed, std::ios::floatfield);
- s.precision (7);
- s << m (i, j);
- _rgb_to_xyz[i][j]->SetLabel (std_to_wx (s.str ()));
+ char buffer[256];
+ snprintf (buffer, sizeof (buffer), "%.7f", m (i, j));
+ _rgb_to_xyz[i][j]->SetLabel (std_to_wx (buffer));
}
}
}
void
ColourConversionEditor::set_text_ctrl (wxTextCtrl* control, double value)
{
- locked_stringstream s;
- s.precision (7);
- s << value;
- control->SetValue (std_to_wx (s.str ()));
+ char buffer[256];
+ snprintf (buffer, sizeof (buffer), "%.7f", value);
+ control->SetValue (std_to_wx (buffer));
}
} else {
message->SetLabel (wxT (""));
- locked_stringstream s;
+ string s;
BOOST_FOREACH (string e, errors) {
- s << e << "\n";
+ s += e + "\n";
}
- error_dialog (this, std_to_wx (s.str ()));
+ error_dialog (this, std_to_wx (s));
}
}
_block_update = true;
- _hours->SetValue (std_to_wx (raw_convert<string> (_hours_spin->GetValue ())));
-
- locked_stringstream m;
- m << setfill('0') << setw(2) << _minutes_spin->GetValue();
- _minutes->SetValue (std_to_wx (m.str()));
+ _hours->SetValue (wxString::Format ("%d", _hours_spin->GetValue ()));
+ _minutes->SetValue (wxString::Format ("%02d", _minutes_spin->GetValue ()));
_block_update = false;
BOOST_CHECK (b.sample_peak ());
BOOST_CHECK_CLOSE (b.sample_peak().get(), peak, 1);
BOOST_CHECK (b.sample_peak_time ());
- BOOST_CHECK_EQUAL (b.sample_peak_time().get(), peak_time);
+ BOOST_CHECK_EQUAL (b.sample_peak_time().get().get(), peak_time.get());
}
static void
film->examine_and_add_content (content);
wait_for_jobs ();
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (2));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(2).get());
content->subtitle->set_use (true);
content->subtitle->set_burn (false);
);
BOOST_REQUIRE_EQUAL (ctp.size(), 2);
- BOOST_CHECK_EQUAL (ctp.front().from, ContentTime::from_seconds (25 + 12 * 0.04));
- BOOST_CHECK_EQUAL (ctp.front().to, ContentTime::from_seconds (26 + 4 * 0.04));
- BOOST_CHECK_EQUAL (ctp.back().from, ContentTime::from_seconds (25 + 12 * 0.04));
- BOOST_CHECK_EQUAL (ctp.back().to, ContentTime::from_seconds (26 + 4 * 0.04));
+ BOOST_CHECK_EQUAL (ctp.front().from.get(), ContentTime::from_seconds(25 + 12 * 0.04).get());
+ BOOST_CHECK_EQUAL (ctp.front().to.get(), ContentTime::from_seconds(26 + 4 * 0.04).get());
+ BOOST_CHECK_EQUAL (ctp.back().from.get(), ContentTime::from_seconds(25 + 12 * 0.04).get());
+ BOOST_CHECK_EQUAL (ctp.back().to.get(), ContentTime::from_seconds(26 + 4 * 0.04).get());
list<ContentTextSubtitle> subs = decoder->subtitle->get_text (
ContentTimePeriod (
/* Some overlaps */
a = TimePeriod<DCPTime> (DCPTime (0), DCPTime (4));
b = TimePeriod<DCPTime> (DCPTime (3), DCPTime (8));
- BOOST_CHECK (a.overlap (b));
- BOOST_CHECK_EQUAL (a.overlap(b).get(), DCPTimePeriod(DCPTime(3), DCPTime(4)));
+ BOOST_CHECK (a.overlap(b));
+ BOOST_CHECK (a.overlap(b).get() == DCPTimePeriod(DCPTime(3), DCPTime(4)));
a = TimePeriod<DCPTime> (DCPTime (1), DCPTime (9));
b = TimePeriod<DCPTime> (DCPTime (0), DCPTime (10));
- BOOST_CHECK (a.overlap (b));
- BOOST_CHECK_EQUAL (a.overlap(b).get(), DCPTimePeriod(DCPTime(1), DCPTime(9)));
+ BOOST_CHECK (a.overlap(b));
+ BOOST_CHECK (a.overlap(b).get() == DCPTimePeriod(DCPTime(1), DCPTime(9)));
}
shared_ptr<FFmpegContent> content (new FFmpegContent (film, "test/data/count300bd24.m2ts"));
shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (content));
- BOOST_CHECK_EQUAL (examiner->first_video().get(), ContentTime::from_seconds (600));
+ BOOST_CHECK_EQUAL (examiner->first_video().get().get(), ContentTime::from_seconds(600).get());
BOOST_CHECK_EQUAL (examiner->audio_streams().size(), 1U);
- BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->first_audio.get(), ContentTime::from_seconds (600));
+ BOOST_CHECK_EQUAL (examiner->audio_streams()[0]->first_audio.get().get(), ContentTime::from_seconds(600).get());
}
content->_first_video = ContentTime ();
content->ffmpeg_audio_streams().front()->first_audio = ContentTime ();
FFmpegDecoder decoder (content, film->log());
- BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ());
+ BOOST_CHECK_EQUAL (decoder._pts_offset.get(), 0);
}
{
content->_first_video = ContentTime::from_seconds (600);
content->ffmpeg_audio_streams().front()->first_audio = ContentTime::from_seconds (600);
FFmpegDecoder decoder (content, film->log());
- BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime::from_seconds (-600));
+ BOOST_CHECK_EQUAL (decoder._pts_offset.get(), ContentTime::from_seconds(-600).get());
}
{
content->_first_video = ContentTime::from_frames (1, 24);
content->ffmpeg_audio_streams().front()->first_audio = ContentTime ();
FFmpegDecoder decoder (content, film->log());
- BOOST_CHECK_EQUAL (decoder._pts_offset, ContentTime ());
+ BOOST_CHECK_EQUAL (decoder._pts_offset.get(), 0);
}
{
film->examine_and_add_content (C);
wait_for_jobs ();
- BOOST_CHECK_EQUAL (A->full_length(), DCPTime (288000));
+ BOOST_CHECK_EQUAL (A->full_length().get(), 288000);
A->set_position (DCPTime::from_seconds (0));
B->set_position (DCPTime::from_seconds (10));
shared_ptr<FFmpegContent> B (new FFmpegContent (film, "test/data/test.mp4"));
film->examine_and_add_content (B);
wait_for_jobs ();
- BOOST_CHECK_EQUAL (A->full_length(), DCPTime (288000));
+ BOOST_CHECK_EQUAL (A->full_length().get(), 288000);
film->set_reel_type (REELTYPE_SINGLE);
list<DCPTimePeriod> r = film->reels ();
BOOST_CHECK_EQUAL (r.size(), 1);
- BOOST_CHECK_EQUAL (r.front().from, DCPTime (0));
- BOOST_CHECK_EQUAL (r.front().to, DCPTime (288000 * 2));
+ BOOST_CHECK_EQUAL (r.front().from.get(), 0);
+ BOOST_CHECK_EQUAL (r.front().to.get(), 288000 * 2);
film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT);
r = film->reels ();
BOOST_CHECK_EQUAL (r.size(), 2);
- BOOST_CHECK_EQUAL (r.front().from, DCPTime (0));
- BOOST_CHECK_EQUAL (r.front().to, DCPTime (288000));
- BOOST_CHECK_EQUAL (r.back().from, DCPTime (288000));
- BOOST_CHECK_EQUAL (r.back().to, DCPTime (288000 * 2));
+ BOOST_CHECK_EQUAL (r.front().from.get(), 0);
+ BOOST_CHECK_EQUAL (r.front().to.get(), 288000);
+ BOOST_CHECK_EQUAL (r.back().from.get(), 288000);
+ BOOST_CHECK_EQUAL (r.back().to.get(), 288000 * 2);
film->set_j2k_bandwidth (100000000);
film->set_reel_type (REELTYPE_BY_LENGTH);
r = film->reels ();
BOOST_CHECK_EQUAL (r.size(), 3);
list<DCPTimePeriod>::const_iterator i = r.begin ();
- BOOST_CHECK_EQUAL (i->from, DCPTime (0));
- BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (60, 24));
+ BOOST_CHECK_EQUAL (i->from.get(), 0);
+ BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(60, 24).get());
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime::from_frames (60, 24));
- BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (120, 24));
+ BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_frames(60, 24).get());
+ BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(120, 24).get());
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime::from_frames (120, 24));
- BOOST_CHECK_EQUAL (i->to, DCPTime::from_frames (144, 24));
+ BOOST_CHECK_EQUAL (i->from.get(), DCPTime::from_frames(120, 24).get());
+ BOOST_CHECK_EQUAL (i->to.get(), DCPTime::from_frames(144, 24).get());
}
/** Make a short DCP with multi reels split by video content, then import
list<DCPTimePeriod> r = film2->reels ();
BOOST_CHECK_EQUAL (r.size(), 3);
list<DCPTimePeriod>::const_iterator i = r.begin ();
- BOOST_CHECK_EQUAL (i->from, DCPTime (0));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000));
+ BOOST_CHECK_EQUAL (i->from.get(), 0);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 2));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 2));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 3));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3);
c->set_reference_video (true);
c->set_reference_audio (true);
list<DCPTimePeriod> reels = film->reels();
BOOST_REQUIRE_EQUAL (reels.size(), 4);
list<DCPTimePeriod>::const_iterator i = reels.begin ();
- BOOST_CHECK_EQUAL (i->from, DCPTime (0));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000));
+ BOOST_CHECK_EQUAL (i->from.get(), 0);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 2));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 2));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 3));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 3));
- BOOST_CHECK_EQUAL (i->to, sub->full_length().round_up (film->video_frame_rate()));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000 * 3);
+ BOOST_CHECK_EQUAL (i->to.get(), sub->full_length().round_up(film->video_frame_rate()).get());
}
/** Check creation of a multi-reel DCP with a single .srt subtitle file;
list<DCPTimePeriod> reels = film->reels();
BOOST_REQUIRE_EQUAL (reels.size(), 4);
list<DCPTimePeriod>::const_iterator i = reels.begin ();
- BOOST_CHECK_EQUAL (i->from, DCPTime (0));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000));
+ BOOST_CHECK_EQUAL (i->from.get(), 0);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 2));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 2);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 2));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 3));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000 * 2);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 3);
++i;
- BOOST_CHECK_EQUAL (i->from, DCPTime (96000 * 3));
- BOOST_CHECK_EQUAL (i->to, DCPTime (96000 * 4));
+ BOOST_CHECK_EQUAL (i->from.get(), 96000 * 3);
+ BOOST_CHECK_EQUAL (i->to.get(), 96000 * 4);
film->make_dcp ();
wait_for_jobs ();
uint8_t* ref_buffer = new uint8_t[buffer_size];
uint8_t* check_buffer = new uint8_t[buffer_size];
- locked_stringstream error;
- error << "File " << check.string() << " differs from reference " << ref.string();
+ string error = "File " + check.string() + " differs from reference " + ref.string();
while (N) {
uintmax_t this_time = min (uintmax_t (buffer_size), N);
r = fread (check_buffer, 1, this_time, check_file);
BOOST_CHECK_EQUAL (r, this_time);
- BOOST_CHECK_MESSAGE (memcmp (ref_buffer, check_buffer, this_time) == 0, error.str ());
+ BOOST_CHECK_MESSAGE (memcmp (ref_buffer, check_buffer, this_time) == 0, error);
if (memcmp (ref_buffer, check_buffer, this_time)) {
break;
}
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(content->video->length() / 25.0).get());
/* 25fps content, 24fps DCP; length should be increased */
film->set_video_frame_rate (24);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 24.0));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(content->video->length() / 24.0).get());
/* 25fps content, 30fps DCP; length should be decreased */
film->set_video_frame_rate (30);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 30.0));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(content->video->length() / 30.0).get());
/* 25fps content, 50fps DCP; length should be the same */
film->set_video_frame_rate (50);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(content->video->length() / 25.0).get());
/* 25fps content, 60fps DCP; length should be decreased */
film->set_video_frame_rate (60);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() * (50.0 / 60) / 25.0));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(content->video->length() * (50.0 / 60) / 25.0).get());
/* Make the content audio-only */
content->video.reset ();
/* 24fps content, 24fps DCP */
film->set_video_frame_rate (24);
content->set_video_frame_rate (24);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(1).get());
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
content->set_video_frame_rate (25);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(1).get());
/* 25fps content, 24fps DCP; length should be increased */
film->set_video_frame_rate (24);
BOOST_CHECK_SMALL (labs (content->full_length().get() - DCPTime::from_seconds(25.0 / 24).get()), 2L);
/* 25fps content, 30fps DCP; length should be decreased */
film->set_video_frame_rate (30);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (25.0 / 30));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(25.0 / 30).get());
/* 25fps content, 50fps DCP; length should be the same */
film->set_video_frame_rate (50);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (1));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(1).get());
/* 25fps content, 60fps DCP; length should be decreased */
film->set_video_frame_rate (60);
- BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (50.0 / 60));
+ BOOST_CHECK_EQUAL (content->full_length().get(), DCPTime::from_seconds(50.0 / 60).get());
}
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
shared_ptr<Piece> piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime ());
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12), DCPTime::from_seconds (0.5));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (3.0));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0).get(), 0);
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12).get(), DCPTime::from_seconds(0.5).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72).get(), DCPTime::from_seconds(3.0).get());
/* Position 3s, no trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 36), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 162), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get());
/* Position 3s, 1.5s trim, content rate = DCP rate */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (1.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 36), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 198), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get());
/* Position 0, no trim, content rate 24, DCP rate 25.
Now, for example, a DCPTime position of 3s means 3s at 25fps. Since we run the video
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime ());
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 15), DCPTime::from_seconds (0.6));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 75), DCPTime::from_seconds (3.0));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0);
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 15).get(), DCPTime::from_seconds(0.6).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 75).get(), DCPTime::from_seconds(3.0).get());
/* Position 3s, no trim, content rate 24, DCP rate 25 */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 40), DCPTime::from_seconds (4.60));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 169), DCPTime::from_seconds (9.76));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 40).get(), DCPTime::from_seconds(4.60).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 169).get(), DCPTime::from_seconds(9.76).get());
/* Position 3s, 1.6s trim, content rate 24, DCP rate 25, so the 1.6s trim is at 24fps */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (1.464));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 40), DCPTime::from_seconds (3.064));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 80), DCPTime::from_seconds (4.664));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 209), DCPTime::from_seconds (9.824));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.464).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 40).get(), DCPTime::from_seconds(3.064).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 80).get(), DCPTime::from_seconds(4.664).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 209).get(), DCPTime::from_seconds(9.824).get());
/* Position 0, no trim, content rate 24, DCP rate 48
Now, for example, a DCPTime position of 3s means 3s at 48fps. Since we run the video
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime ());
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 12), DCPTime::from_seconds (0.5));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (3.0));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0);
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 12).get(), DCPTime::from_seconds(0.5).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.0).get());
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 36), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 162), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 162).get(), DCPTime::from_seconds(9.75).get());
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (1.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 36), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 198), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 36).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 198).get(), DCPTime::from_seconds(9.75).get());
/* Position 0, no trim, content rate 48, DCP rate 24
Now, for example, a DCPTime position of 3s means 3s at 24fps. Since we run the video
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime ());
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 24), DCPTime::from_seconds (0.5));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 144), DCPTime::from_seconds (3.0));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), 0);
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 24).get(), DCPTime::from_seconds(0.5).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(3.0).get());
/* Position 3s, no trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 324), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 324).get(), DCPTime::from_seconds(9.75).get());
/* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
content->set_position (DCPTime::from_seconds (3));
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
piece = player->_pieces.front ();
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 0), DCPTime::from_seconds (1.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 72), DCPTime::from_seconds (3.00));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 144), DCPTime::from_seconds (4.50));
- BOOST_CHECK_EQUAL (player->content_video_to_dcp (piece, 396), DCPTime::from_seconds (9.75));
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 0).get(), DCPTime::from_seconds(1.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 72).get(), DCPTime::from_seconds(3.00).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 144).get(), DCPTime::from_seconds(4.50).get());
+ BOOST_CHECK_EQUAL (player->content_video_to_dcp(piece, 396).get(), DCPTime::from_seconds(9.75).get());
}
/** Test Player::dcp_to_content_audio */
/* Straightforward test of DCPTime::round_up */
BOOST_AUTO_TEST_CASE (dcptime_round_up_test)
{
- BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 2), DCPTime (0));
- BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 2), DCPTime (2));
- BOOST_CHECK_EQUAL (DCPTime (2).round_up (DCPTime::HZ / 2), DCPTime (2));
- BOOST_CHECK_EQUAL (DCPTime (3).round_up (DCPTime::HZ / 2), DCPTime (4));
+ BOOST_CHECK_EQUAL (DCPTime(0).round_up(DCPTime::HZ / 2).get(), 0);
+ BOOST_CHECK_EQUAL (DCPTime(1).round_up(DCPTime::HZ / 2).get(), 2);
+ BOOST_CHECK_EQUAL (DCPTime(2).round_up(DCPTime::HZ / 2).get(), 2);
+ BOOST_CHECK_EQUAL (DCPTime(3).round_up(DCPTime::HZ / 2).get(), 4);
- BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 42), DCPTime (0));
- BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 42), DCPTime (42));
- BOOST_CHECK_EQUAL (DCPTime (42).round_up (DCPTime::HZ / 42), DCPTime (42));
- BOOST_CHECK_EQUAL (DCPTime (43).round_up (DCPTime::HZ / 42), DCPTime (84));
+ BOOST_CHECK_EQUAL (DCPTime(0).round_up(DCPTime::HZ / 42).get(), 0);
+ BOOST_CHECK_EQUAL (DCPTime(1).round_up(DCPTime::HZ / 42).get(), 42);
+ BOOST_CHECK_EQUAL (DCPTime(42).round_up(DCPTime::HZ / 42).get(), 42);
+ BOOST_CHECK_EQUAL (DCPTime(43).round_up(DCPTime::HZ / 42).get(), 84);
/* Check that rounding up to non-integer frame rates works */
- BOOST_CHECK_EQUAL (DCPTime (45312).round_up (29.976), DCPTime (48045));
+ BOOST_CHECK_EQUAL (DCPTime(45312).round_up(29.976).get(), 48045);
}
BOOST_AUTO_TEST_CASE (timecode_test)
test (dcp::Size content_size, dcp::Size display_size, dcp::Size film_size, Crop crop, Ratio const * ratio, bool scale, dcp::Size correct)
{
shared_ptr<Film> film;
- locked_stringstream s;
- s << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ string s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<Content>"
"<Type>FFmpeg</Type>"
"<Path>/home/c.hetherington/DCP/prophet_clip.mkv</Path>"
"<TrimStart>0</TrimStart>"
"<TrimEnd>0</TrimEnd>"
"<VideoLength>2879</VideoLength>"
- "<VideoWidth>" << content_size.width << "</VideoWidth>"
- "<VideoHeight>" << content_size.height << "</VideoHeight>"
+ "<VideoWidth>" + raw_convert<string>(content_size.width) + "</VideoWidth>"
+ "<VideoHeight>" + raw_convert<string>(content_size.height) + "</VideoHeight>"
"<VideoFrameRate>23.97602462768555</VideoFrameRate>"
"<OriginalVideoFrameRate>23.97602462768555</OriginalVideoFrameRate>"
"<VideoFrameType>0</VideoFrameType>"
"<SampleAspectRatio>1</SampleAspectRatio>"
"<BitsPerPixel>12</BitsPerPixel>"
- "<LeftCrop>" << crop.left << "</LeftCrop>"
- "<RightCrop>" << crop.right << "</RightCrop>"
- "<TopCrop>" << crop.top << "</TopCrop>"
- "<BottomCrop>" << crop.bottom << "</BottomCrop>"
+ "<LeftCrop>" + raw_convert<string>(crop.left) + "</LeftCrop>"
+ "<RightCrop>" + raw_convert<string>(crop.right) + "</RightCrop>"
+ "<TopCrop>" + raw_convert<string>(crop.top) + "</TopCrop>"
+ "<BottomCrop>" + raw_convert<string>(crop.bottom) + "</BottomCrop>"
"<Scale>";
if (ratio) {
- s << "<Ratio>" << ratio->id() << "</Ratio>";
+ s += "<Ratio>" + ratio->id() + "</Ratio>";
} else {
- s << "<Scale>" << scale << "</Scale>";
+ s += "<Scale>" + string(scale ? "1" : "0") + "</Scale>";
}
- s << "</Scale>"
+ s += "</Scale>"
"<ColourConversion>"
"<InputGamma>2.4</InputGamma>"
"<InputGammaLinearised>1</InputGammaLinearised>"
"</Content>";
shared_ptr<cxml::Document> doc (new cxml::Document ());
- doc->read_string(s.str ());
+ doc->read_string (s);
list<string> notes;
shared_ptr<FFmpegContent> vc (new FFmpegContent (film, doc, 10, notes));