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"
33 /** @file src/ab_transcoder.cc
34 * @brief A transcoder which uses one Film for the left half of the screen, and a different one
35 * for the right half (to facilitate A/B comparisons of settings)
39 using boost::shared_ptr;
40 using boost::dynamic_pointer_cast;
42 /** @param a Film to use for the left half of the screen.
43 * @param b Film to use for the right half of the screen.
44 * @param o Decoder options.
45 * @param j Job that we are associated with.
46 * @param e Encoder to use.
49 ABTranscoder::ABTranscoder (shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<Job> j)
52 , _player_a (_film_a->player ())
53 , _player_b (_film_b->player ())
55 , _encoder (new Encoder (_film_a))
56 , _combiner (new Combiner (a->log()))
58 if (_film_a->has_audio ()) {
59 _matcher.reset (new Matcher (_film_a->log(), _film_a->audio_frame_rate(), _film_a->video_frame_rate()));
60 _delay_line.reset (new DelayLine (_film_a->log(), _film_a->audio_channels(), _film_a->audio_delay() * _film_a->audio_frame_rate() / 1000));
61 _gain.reset (new Gain (_film_a->log(), _film_a->audio_gain()));
64 _player_a->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3));
65 _player_b->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3));
68 _combiner->connect_video (_matcher);
69 _matcher->connect_video (_encoder);
71 _combiner->connect_video (_encoder);
74 if (_matcher && _delay_line) {
75 _player_a->connect_audio (_delay_line);
76 _delay_line->connect_audio (_matcher);
77 _matcher->connect_audio (_gain);
78 _gain->connect_audio (_encoder);
85 _encoder->process_begin ();
87 bool done[2] = { false, false };
90 done[0] = _player_a->pass ();
91 done[1] = _player_b->pass ();
94 _player_a->set_progress (_job);
97 if (done[0] && done[1]) {
103 _delay_line->process_end ();
106 _matcher->process_end ();
109 _gain->process_end ();
111 _encoder->process_end ();