using std::string;
using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
/** @param a Film to use for the left half of the screen.
* @param b Film to use for the right half of the screen.
, _film_b (b)
, _job (j)
, _encoder (e)
+ , _combiner (new Combiner (a->log()))
{
_da = decoder_factory (_film_a, o);
_db = decoder_factory (_film_b, o);
ABTranscoder::go ()
{
_encoder->process_begin ();
+
+ bool done[3] = { false, false, false };
while (1) {
- bool const va = _da.video->pass ();
- bool const vb = _db.video->pass ();
- bool const a = _da.audio->pass ();
+ done[0] = _da.video->pass ();
+ done[1] = _db.video->pass ();
+
+ if (!done[2] && _da.audio && dynamic_pointer_cast<Decoder> (_da.audio) != dynamic_pointer_cast<Decoder> (_da.video)) {
+ done[2] = _da.audio->pass ();
+ } else {
+ done[2] = true;
+ }
if (_job) {
_da.video->set_progress (_job);
}
- if (va && vb && a) {
+ if (done[0] && done[1] && done[2]) {
break;
}
}
using boost::shared_ptr;
-Combiner::Combiner (Log* log)
+Combiner::Combiner (shared_ptr<Log> log)
: VideoProcessor (log)
{
class Combiner : public VideoProcessor
{
public:
- Combiner (Log* log);
+ Combiner (boost::shared_ptr<Log> log);
void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
DCPVideoFrame::DCPVideoFrame (
shared_ptr<const Image> yuv, shared_ptr<Subtitle> sub,
Size out, int p, int subtitle_offset, float subtitle_scale,
- Scaler const * s, int f, int dcp_fps, string pp, int clut, int bw, Log* l
+ Scaler const * s, int f, int dcp_fps, string pp, int clut, int bw, shared_ptr<Log> l
)
: _input (yuv)
, _subtitle (sub)
public:
DCPVideoFrame (
boost::shared_ptr<const Image>, boost::shared_ptr<Subtitle>, libdcp::Size,
- int, int, float, Scaler const *, int, int, std::string, int, int, Log *
+ int, int, float, Scaler const *, int, int, std::string, int, int, boost::shared_ptr<Log>
);
virtual ~DCPVideoFrame ();
int _colour_lut; ///< Colour look-up table to use
int _j2k_bandwidth; ///< J2K bandwidth to use
- Log* _log; ///< log
+ boost::shared_ptr<Log> _log; ///< log
opj_image_cmptparm_t _cmptparm[3]; ///< libopenjpeg's opj_image_cmptparm_t
opj_image* _image; ///< libopenjpeg's image container
/** @param channels Number of channels of audio.
* @param frames Delay in frames, +ve to move audio later.
*/
-DelayLine::DelayLine (Log* log, int channels, int frames)
+DelayLine::DelayLine (shared_ptr<Log> log, int channels, int frames)
: AudioProcessor (log)
, _negative_delay_remaining (0)
, _frames (frames)
class DelayLine : public AudioProcessor
{
public:
- DelayLine (Log* log, int channels, int frames);
+ DelayLine (boost::shared_ptr<Log> log, int channels, int frames);
void process_audio (boost::shared_ptr<AudioBuffers>);
read_metadata ();
}
- _log = new FileLog (file ("log"));
+ _log.reset (new FileLog (file ("log")));
}
Film::Film (Film const & o)
: boost::enable_shared_from_this<Film> (o)
- , _log (0)
+ /* note: the copied film shares the original's log */
+ , _log (o._log)
, _directory (o._directory)
, _name (o._name)
, _use_dci_name (o._use_dci_name)
, _source_frame_rate (o._source_frame_rate)
, _dirty (o._dirty)
{
-
+
}
Film::~Film ()
{
- delete _log;
+
}
string
/** @return Logger.
* It is safe to call this from any thread.
*/
- Log* log () const {
+ boost::shared_ptr<Log> log () const {
return _log;
}
private:
/** Log to write to */
- Log* _log;
+ boost::shared_ptr<Log> _log;
/** Any running ExamineContentJob, or 0 */
boost::shared_ptr<ExamineContentJob> _examine_content_job;
using boost::shared_ptr;
/** @param gain gain in dB */
-Gain::Gain (Log* log, float gain)
+Gain::Gain (shared_ptr<Log> log, float gain)
: AudioProcessor (log)
, _gain (gain)
{
class Gain : public AudioProcessor
{
public:
- Gain (Log* log, float gain);
+ Gain (boost::shared_ptr<Log> log, float gain);
void process_audio (boost::shared_ptr<AudioBuffers>);
using std::min;
using boost::shared_ptr;
-Matcher::Matcher (Log* log, int sample_rate, float frames_per_second)
+Matcher::Matcher (shared_ptr<Log> log, int sample_rate, float frames_per_second)
: AudioVideoProcessor (log)
, _sample_rate (sample_rate)
, _frames_per_second (frames_per_second)
class Matcher : public AudioVideoProcessor
{
public:
- Matcher (Log* log, int sample_rate, float frames_per_second);
+ Matcher (boost::shared_ptr<Log> log, int sample_rate, float frames_per_second);
void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
void process_audio (boost::shared_ptr<AudioBuffers>);
void process_end ();
/** Construct a Processor.
* @param log Log to use.
*/
- Processor (Log* log)
+ Processor (boost::shared_ptr<Log> log)
: _log (log)
{}
virtual void process_end () {}
protected:
- Log* _log; ///< log to write to
+ boost::shared_ptr<Log> _log; ///< log to write to
};
/** @class AudioVideoProcessor
/** Construct an AudioVideoProcessor.
* @param log Log to write to.
*/
- AudioVideoProcessor (Log* log)
+ AudioVideoProcessor (boost::shared_ptr<Log> log)
: Processor (log)
{}
};
/** Construct an AudioProcessor.
* @param log Log to write to.
*/
- AudioProcessor (Log* log)
+ AudioProcessor (boost::shared_ptr<Log> log)
: Processor (log)
{}
};
/** Construct an VideoProcessor.
* @param log Log to write to.
*/
- VideoProcessor (Log* log)
+ VideoProcessor (boost::shared_ptr<Log> log)
: Processor (log)
{}
};
return s.str ();
}
-Server::Server (Log* log)
+Server::Server (shared_ptr<Log> log)
: _log (log)
{
class Server
{
public:
- Server (Log* log);
+ Server (boost::shared_ptr<Log> log);
void run (int num_threads);
std::list<boost::shared_ptr<Socket> > _queue;
boost::mutex _worker_mutex;
boost::condition _worker_condition;
- Log* _log;
+ boost::shared_ptr<Log> _log;
};
#include "audio_decoder.h"
using std::string;
-using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
#ifdef DVDOMATIC_POSIX
unsetenv ("UBUNTU_MENUPROXY");
#endif
-
+
+ /* This needs to be before setup_i18n, as setup_i18n() will
+ create a Config object, which needs Scalers to have
+ been created.
+ */
+ dvdomatic_setup ();
+
wxInitAllImageHandlers ();
setup_i18n ();
- dvdomatic_setup ();
-
if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) {
try {
film.reset (new Film (film_to_load));
#include "log.h"
#include "version.h"
-using namespace std;
+using std::cerr;
+using std::string;
+using std::cout;
+using boost::shared_ptr;
static void
help (string n)
}
Scaler::setup_scalers ();
- FileLog log ("servomatic.log");
- Server server (&log);
+ shared_ptr<FileLog> log (new FileLog ("servomatic.log"));
+ Server server (log);
server.run (num_threads);
return 0;
}
#include "lib/server.h"
#include "lib/config.h"
-using namespace std;
-using namespace boost;
+using std::cout;
+using std::string;
+using boost::shared_ptr;
+using boost::thread;
+using boost::bind;
enum {
ID_status = 1,
string _log;
};
-static MemoryLog memory_log;
+static shared_ptr<MemoryLog> memory_log (new MemoryLog);
class StatusDialog : public wxDialog
{
private:
void update (wxTimerEvent &)
{
- _text->ChangeValue (std_to_wx (memory_log.get ()));
+ _text->ChangeValue (std_to_wx (memory_log->get ()));
_sizer->Layout ();
}
void main_thread ()
{
- Server server (&memory_log);
+ Server server (memory_log);
server.run (Config::instance()->num_local_encoding_threads ());
}
using boost::shared_ptr;
static ServerDescription* server;
-static FileLog log_ ("servomatictest.log");
+static shared_ptr<FileLog> log_ (new FileLog ("servomatictest.log"));
static int frame = 0;
void
new DCPVideoFrame (
image, sub,
libdcp::Size (1024, 1024), 0, 0, 0,
- Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_)
+ Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_)
);
shared_ptr<DCPVideoFrame> remote (
new DCPVideoFrame (
image, sub,
libdcp::Size (1024, 1024), 0, 0, 0,
- Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, &log_)
+ Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_)
);
cout << "Frame " << frame << ": ";
void
do_positive_delay_line_test (int delay_length, int data_length)
{
- NullLog log;
+ shared_ptr<NullLog> log (new NullLog);
- DelayLine d (&log, 6, delay_length);
+ DelayLine d (log, 6, delay_length);
shared_ptr<AudioBuffers> data (new AudioBuffers (6, data_length));
int in = 0;
void
do_negative_delay_line_test (int delay_length, int data_length)
{
- NullLog log;
+ shared_ptr<NullLog> log (new NullLog);
- DelayLine d (&log, 6, delay_length);
+ DelayLine d (log, 6, delay_length);
shared_ptr<AudioBuffers> data (new AudioBuffers (6, data_length));
int in = 0;
shared_ptr<Subtitle> subtitle (new Subtitle (Position (50, 60), sub_image));
- FileLog log ("build/test/client_server_test.log");
+ shared_ptr<FileLog> log (new FileLog ("build/test/client_server_test.log"));
shared_ptr<DCPVideoFrame> frame (
new DCPVideoFrame (
"",
0,
200000000,
- &log
+ log
)
);
shared_ptr<EncodedData> locally_encoded = frame->encode_locally ();
BOOST_ASSERT (locally_encoded);
- Server* server = new Server (&log);
+ Server* server = new Server (log);
new thread (boost::bind (&Server::run, server, 2));