2 Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic 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 DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/compose.hpp"
23 #include "lib/image.h"
24 #include "lib/timer.h"
27 using boost::shared_ptr;
30 #define ITERATIONS 500
35 dummy_image(dcp::Size size, AVPixelFormat pixel)
37 shared_ptr<Image> image(new Image(pixel, size, true));
39 for (int y = 0; y < size.height; ++y) {
40 for (int c = 0; c < image->planes(); ++c) {
41 uint8_t* p = image->data()[c] + y * image->stride()[c];
42 int const line_size = image->line_size()[c];
43 for (int x = 0; x < line_size; ++x) {
55 test (dcp::Size from_size, AVPixelFormat from_pixel, dcp::Size to, bool fast)
57 shared_ptr<Image> image = dummy_image(from_size, from_pixel);
58 PeriodTimer pt (String::compose("%1:%2 -> %3:%4 %5 %6", from_size.width, from_size.height, to.width, to.height, static_cast<int>(from_pixel), fast ? "fast" : "slow"));
59 for (int i = 0; i < ITERATIONS; ++i) {
60 image->scale (to, dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB48, true, fast);
68 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), true);
69 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), false);
71 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(2006, 1088), true);
72 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(2006, 1088), false);
74 test (dcp::Size(996, 540), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), true);
75 test (dcp::Size(996, 540), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), false);
77 test (dcp::Size(498, 270), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), true);
78 test (dcp::Size(498, 270), AV_PIX_FMT_RGB24, dcp::Size(1998, 1080), false);
80 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(1720, 930), true);
81 test (dcp::Size(1998, 1080), AV_PIX_FMT_RGB24, dcp::Size(1720, 930), false);
83 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), true);
84 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), false);
86 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(2006, 1088), true);
87 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(2006, 1088), false);
89 test (dcp::Size(996, 540), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), true);
90 test (dcp::Size(996, 540), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), false);
92 test (dcp::Size(498, 270), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), true);
93 test (dcp::Size(498, 270), AV_PIX_FMT_XYZ12LE, dcp::Size(1998, 1080), false);
95 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(1720, 930), true);
96 test (dcp::Size(1998, 1080), AV_PIX_FMT_XYZ12LE, dcp::Size(1720, 930), false);