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.
30 #include "dcp_video_frame.h"
32 #include "exceptions.h"
35 #include "video_decoder.h"
42 using boost::shared_ptr;
44 static ServerDescription* server;
45 static shared_ptr<FileLog> log_ (new FileLog ("servomatictest.log"));
49 process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub)
51 shared_ptr<DCPVideoFrame> local (
54 libdcp::Size (1024, 1024), 0, 0, 0,
55 Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_)
58 shared_ptr<DCPVideoFrame> remote (
61 libdcp::Size (1024, 1024), 0, 0, 0,
62 Scaler::from_id ("bicubic"), frame, 24, "", 0, 250000000, log_)
65 cout << "Frame " << frame << ": ";
70 shared_ptr<EncodedData> local_encoded = local->encode_locally ();
71 shared_ptr<EncodedData> remote_encoded;
75 remote_encoded = remote->encode_remotely (server);
76 } catch (NetworkError& e) {
77 remote_error = e.what ();
80 if (!remote_error.empty ()) {
81 cout << "\033[0;31mnetwork problem: " << remote_error << "\033[0m\n";
85 if (local_encoded->size() != remote_encoded->size()) {
86 cout << "\033[0;31msizes differ\033[0m\n";
90 uint8_t* p = local_encoded->data();
91 uint8_t* q = remote_encoded->data();
92 for (int i = 0; i < local_encoded->size(); ++i) {
94 cout << "\033[0;31mdata differ\033[0m at byte " << i << "\n";
99 cout << "\033[0;32mgood\033[0m\n";
105 cerr << "Syntax: " << n << " [--help] --film <film> --server <host>\n";
110 main (int argc, char* argv[])
116 static struct option long_options[] = {
117 { "help", no_argument, 0, 'h'},
118 { "server", required_argument, 0, 's'},
119 { "film", required_argument, 0, 'f'},
123 int option_index = 0;
124 int c = getopt_long (argc, argv, "hs:f:", long_options, &option_index);
135 server_host = optarg;
143 if (server_host.empty() || film_dir.empty()) {
150 server = new ServerDescription (server_host, 1);
151 shared_ptr<Film> film (new Film (film_dir, true));
153 shared_ptr<Playlist> playlist = film->playlist ();
154 playlist->disable_audio ();
157 playlist->Video.connect (boost::bind (process_video, _1, _2, _3));
160 done = playlist->pass ();
162 } catch (std::exception& e) {
163 cerr << "Error: " << e.what() << "\n";