* @param e Encoder to use.
*/
-ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<Job> j)
- : _film_a (a)
- , _film_b (b)
- , _player_a (_film_a->player ())
- , _player_b (_film_b->player ())
+ABTranscoder::ABTranscoder (shared_ptr<Film> film_a, shared_ptr<Film> film_b, shared_ptr<Job> j)
+ : _player_a (film_a->player ())
+ , _player_b (film_b->player ())
, _job (j)
- , _encoder (new Encoder (_film_a))
- , _combiner (new Combiner (a->log()))
+ , _encoder (new Encoder (film_a, j))
+ , _combiner (new Combiner (film_a->log()))
{
- _matcher.reset (new Matcher (_film_a->log(), _film_a->audio_frame_rate(), _film_a->video_frame_rate()));
- _delay_line.reset (new DelayLine (_film_a->log(), _film_a->audio_delay() * _film_a->audio_frame_rate() / 1000));
- _gain.reset (new Gain (_film_a->log(), _film_a->audio_gain()));
+ _matcher.reset (new Matcher (film_a->log(), film_a->audio_frame_rate(), film_a->video_frame_rate()));
+ _delay_line.reset (new DelayLine (film_a->log(), film_a->audio_delay() * film_a->audio_frame_rate() / 1000));
+ _gain.reset (new Gain (film_a->log(), film_a->audio_gain()));
_player_a->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3, _4));
_player_b->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3, _4));
- int const trim_start = _film_a->trim_type() == Film::ENCODE ? _film_a->trim_start() : 0;
- int const trim_end = _film_a->trim_type() == Film::ENCODE ? _film_a->trim_end() : 0;
+ int const trim_start = film_a->trim_type() == Film::ENCODE ? film_a->trim_start() : 0;
+ int const trim_end = film_a->trim_type() == Film::ENCODE ? film_a->trim_end() : 0;
_trimmer.reset (new Trimmer (
- _film_a->log(), trim_start, trim_end, _film_a->content_length(),
- _film_a->audio_frame_rate(), _film_a->video_frame_rate(), _film_a->dcp_frame_rate()
+ film_a->log(), trim_start, trim_end, film_a->content_length(),
+ film_a->audio_frame_rate(), film_a->video_frame_rate(), film_a->dcp_frame_rate()
));
{
_encoder->process_begin ();
- bool done[2] = { false, false };
-
- while (1) {
- done[0] = _player_a->pass ();
- done[1] = _player_b->pass ();
-
- if (_job) {
- _player_a->set_progress (_job);
- }
-
- if (done[0] && done[1]) {
- break;
- }
- }
+ while (!_player_a->pass () || !_player_b->pass ()) {}
_delay_line->process_end ();
_matcher->process_end ();
void go ();
private:
- boost::shared_ptr<Film> _film_a;
- boost::shared_ptr<Film> _film_b;
boost::shared_ptr<Player> _player_a;
boost::shared_ptr<Player> _player_b;
boost::shared_ptr<Job> _job;
int const Encoder::_history_size = 25;
/** @param f Film that we are encoding */
-Encoder::Encoder (shared_ptr<Film> f)
+Encoder::Encoder (shared_ptr<Film> f, shared_ptr<Job> j)
: _film (f)
+ , _job (j)
, _video_frames_in (0)
, _video_frames_out (0)
#ifdef HAVE_SWRESAMPLE
}
}
- _writer.reset (new Writer (_film));
+ _writer.reset (new Writer (_film, _job));
}
class DCPVideoFrame;
class EncodedData;
class Writer;
+class Job;
/** @class Encoder
* @brief Encoder to J2K and WAV for DCP.
class Encoder : public VideoSink, public AudioSink
{
public:
- Encoder (boost::shared_ptr<Film> f);
+ Encoder (boost::shared_ptr<Film> f, boost::shared_ptr<Job>);
virtual ~Encoder ();
/** Called to indicate that a processing run is about to begin */
- virtual void process_begin ();
+ void process_begin ();
/** Call with a frame of video.
* @param i Video frame image.
void process_audio (boost::shared_ptr<const AudioBuffers>);
/** Called when a processing run has finished */
- virtual void process_end ();
+ void process_end ();
float current_encoding_rate () const;
int video_frames_out () const;
/** Film that we are encoding */
boost::shared_ptr<Film> _film;
+ boost::shared_ptr<Job> _job;
/** Mutex for _time_history and _last_frame */
mutable boost::mutex _history_mutex;
return done;
}
-void
-Player::set_progress (shared_ptr<Job> job)
-{
- /* Assume progress can be divined from how far through the video we are */
-
- if (_video_decoder >= _video_decoders.size() || !_playlist->video_length()) {
- return;
- }
-
- job->set_progress ((_video_start[_video_decoder] + _video_decoders[_video_decoder]->video_frame()) / _playlist->video_length ());
-}
-
void
Player::process_video (shared_ptr<const Image> i, bool same, shared_ptr<Subtitle> s, double t)
{
void disable_subtitles ();
bool pass ();
- void set_progress (boost::shared_ptr<Job>);
bool seek (double);
void seek_back ();
void seek_forward ();
#include "audio_decoder.h"
#include "player.h"
#include "trimmer.h"
+#include "job.h"
using std::string;
using boost::shared_ptr;
Transcoder::Transcoder (shared_ptr<Film> f, shared_ptr<Job> j)
: _job (j)
, _player (f->player ())
- , _encoder (new Encoder (f))
+ , _encoder (new Encoder (f, j))
{
_matcher.reset (new Matcher (f->log(), f->audio_frame_rate(), f->video_frame_rate()));
_delay_line.reset (new DelayLine (f->log(), f->audio_delay() * f->audio_frame_rate() / 1000));
Transcoder::go ()
{
_encoder->process_begin ();
- while (1) {
- if (_player->pass ()) {
- break;
- }
- _player->set_progress (_job);
- }
+ while (!_player->pass ()) {}
+
_delay_line->process_end ();
if (_matcher) {
_matcher->process_end ();
*/
+#include "types.h"
+
/** @file src/transcoder.h
*
* A decoder is selected according to the content type, and the encoder can be specified
float current_encoding_rate () const;
int video_frames_out () const;
-protected:
+private:
/** A Job that is running this Transcoder, or 0 */
boost::shared_ptr<Job> _job;
boost::shared_ptr<Player> _player;
#include "player.h"
#include "audio_mapping.h"
#include "config.h"
+#include "job.h"
#include "i18n.h"
int const Writer::_maximum_frames_in_memory = 8;
-Writer::Writer (shared_ptr<Film> f)
+Writer::Writer (shared_ptr<Film> f, shared_ptr<Job> j)
: _film (f)
+ , _job (j)
, _first_nonexistant_frame (0)
, _thread (0)
, _finish (false)
}
}
lock.lock ();
+
+ if (_film->video_length ()) {
+ _job->set_progress (float(_full_written + _fake_written + _repeat_written) / _film->video_length());
+ }
++_last_written_frame;
}
class Film;
class EncodedData;
class AudioBuffers;
+class Job;
namespace libdcp {
class MonoPictureAsset;
class Writer : public ExceptionStore
{
public:
- Writer (boost::shared_ptr<Film>);
+ Writer (boost::shared_ptr<Film>, boost::shared_ptr<Job>);
bool can_fake_write (int) const;
/** our Film */
boost::shared_ptr<Film> _film;
+ boost::shared_ptr<Job> _job;
/** the first frame index that does not already exist in our MXF */
int _first_nonexistant_frame;