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"
24 #include "video_decoder.h"
25 #include "audio_decoder.h"
30 #include "decoder_factory.h"
32 /** @file src/ab_transcoder.cc
33 * @brief A transcoder which uses one Film for the left half of the screen, and a different one
34 * for the right half (to facilitate A/B comparisons of settings)
38 using boost::shared_ptr;
40 /** @param a Film to use for the left half of the screen.
41 * @param b Film to use for the right half of the screen.
43 * @param j Job that we are associated with.
44 * @param e Encoder to use.
47 ABTranscoder::ABTranscoder (
48 shared_ptr<Film> a, shared_ptr<Film> b, shared_ptr<const Options> o, Job* j, shared_ptr<Encoder> e)
55 _da = decoder_factory (_film_a, o, j);
56 _db = decoder_factory (_film_b, o, j);
60 // _da->Video.connect (bind (&ABTranscoder::process_video, this, _1, _2, 0));
61 // _db->Video.connect (bind (&ABTranscoder::process_video, this, _1, _2, 1));
62 // _da->Audio.connect (bind (&Encoder::process_audio, e, _1));
65 ABTranscoder::~ABTranscoder ()
71 ABTranscoder::process_video (shared_ptr<Image> yuv, shared_ptr<Subtitle> sub, int index)
74 /* Keep this image around until we get the other half */
77 /* Copy the right half of yuv into _image */
78 for (int i = 0; i < yuv->components(); ++i) {
79 int const line_size = yuv->line_size()[i];
80 int const half_line_size = line_size / 2;
81 int const stride = yuv->stride()[i];
83 uint8_t* p = _image->data()[i];
84 uint8_t* q = yuv->data()[i];
86 for (int j = 0; j < yuv->lines (i); ++j) {
87 memcpy (p + half_line_size, q + half_line_size, half_line_size);
93 /* And pass it to the encoder */
94 _encoder->process_video (_image, sub);
103 _encoder->process_begin ();
106 bool const va = _da.first->pass ();
107 bool const vb = _db.first->pass ();
108 bool const a = _da.first->pass ();
115 _encoder->process_end ();