2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <boost/shared_ptr.hpp>
22 #include "ab_transcoder.h"
29 #include "delay_line.h"
34 /** @file src/ab_transcoder.cc
35 * @brief A transcoder which uses one Film for the left half of the screen, and a different one
36 * for the right half (to facilitate A/B comparisons of settings)
40 using boost::shared_ptr;
41 using boost::dynamic_pointer_cast;
43 /** @param a Film to use for the left half of the screen.
44 * @param b Film to use for the right half of the screen.
45 * @param o Decoder options.
46 * @param j Job that we are associated with.
47 * @param e Encoder to use.
50 ABTranscoder::ABTranscoder (shared_ptr<Film> film_a, shared_ptr<Film> film_b, shared_ptr<Job> j)
51 : _player_a (film_a->player ())
52 , _player_b (film_b->player ())
54 , _encoder (new Encoder (film_a, j))
55 , _combiner (new Combiner (film_a->log()))
57 _matcher.reset (new Matcher (film_a->log(), film_a->audio_frame_rate(), film_a->video_frame_rate()));
58 _delay_line.reset (new DelayLine (film_a->log(), film_a->audio_delay() * film_a->audio_frame_rate() / 1000));
59 _gain.reset (new Gain (film_a->log(), film_a->audio_gain()));
61 _player_a->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3, _4));
62 _player_b->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3, _4));
64 int const trim_start = film_a->trim_type() == Film::ENCODE ? film_a->trim_start() : 0;
65 int const trim_end = film_a->trim_type() == Film::ENCODE ? film_a->trim_end() : 0;
66 _trimmer.reset (new Trimmer (
67 film_a->log(), trim_start, trim_end, film_a->content_length(),
68 film_a->audio_frame_rate(), film_a->video_frame_rate(), film_a->dcp_frame_rate()
72 _combiner->connect_video (_delay_line);
73 _delay_line->connect_video (_matcher);
74 _matcher->connect_video (_trimmer);
75 _trimmer->connect_video (_encoder);
77 _player_a->connect_audio (_delay_line);
78 _delay_line->connect_audio (_matcher);
79 _matcher->connect_audio (_gain);
80 _gain->connect_audio (_trimmer);
81 _trimmer->connect_audio (_encoder);
87 _encoder->process_begin ();
89 while (!_player_a->pass () || !_player_b->pass ()) {}
91 _delay_line->process_end ();
92 _matcher->process_end ();
93 _gain->process_end ();
94 _trimmer->process_end ();
95 _encoder->process_end ();