2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
25 #include "openjpeg_image.h"
32 using boost::shared_ptr;
45 gettimeofday (&_start, 0);
51 gettimeofday (&stop, 0);
52 _total += (stop.tv_sec + stop.tv_usec / 1e6) - (_start.tv_sec + _start.tv_usec / 1e6);
62 struct timeval _start;
65 /** Run some basic benchmarks of JPEG2000 encoding / decoding */
67 main (int argc, char* argv[])
70 cerr << "Syntax: " << argv[0] << " private-test-path\n";
74 int const count = 100;
75 int const j2k_bandwidth = 100000000;
77 dcp::Data j2k (boost::filesystem::path (argv[1]) / "thx.j2c");
83 for (int i = 0; i < count; ++i) {
85 shared_ptr<dcp::OpenJPEGImage> xyz = dcp::decompress_j2k (j2k, 0);
88 recomp = dcp::compress_j2k (xyz, j2k_bandwidth, 24, false, false);
90 cout << (i + 1) << " ";
95 cout << "Decompress: " << count / decompress.get() << " fps.\n";
96 cout << "Compress: " << count / compress.get() << " fps.\n";
98 FILE* f = fopen ("check.j2c", "wb");
99 fwrite (recomp.data().get(), 1, recomp.size(), f);