2 Copyright (C) 2012 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/>.
21 /** @file test/make_black_test.cc
22 * @brief Check that Image::make_black works and doesn't use values which crash
24 * @ingroup selfcontained
25 * @see test/image_test.cc
28 #include <boost/test/unit_test.hpp>
31 #include <libavutil/pixfmt.h>
33 #include "lib/image.h"
37 BOOST_AUTO_TEST_CASE (make_black_test)
39 dcp::Size in_size (512, 512);
40 dcp::Size out_size (1024, 1024);
42 list<AVPixelFormat> pix_fmts;
43 pix_fmts.push_back (AV_PIX_FMT_RGB24); // 2
44 pix_fmts.push_back (AV_PIX_FMT_ARGB);
45 pix_fmts.push_back (AV_PIX_FMT_RGBA);
46 pix_fmts.push_back (AV_PIX_FMT_ABGR);
47 pix_fmts.push_back (AV_PIX_FMT_BGRA);
48 pix_fmts.push_back (AV_PIX_FMT_YUV420P); // 0
49 pix_fmts.push_back (AV_PIX_FMT_YUV411P);
50 pix_fmts.push_back (AV_PIX_FMT_YUV422P10LE);
51 pix_fmts.push_back (AV_PIX_FMT_YUV422P16LE);
52 pix_fmts.push_back (AV_PIX_FMT_YUV444P9LE);
53 pix_fmts.push_back (AV_PIX_FMT_YUV444P9BE);
54 pix_fmts.push_back (AV_PIX_FMT_YUV444P10LE);
55 pix_fmts.push_back (AV_PIX_FMT_YUV444P10BE);
56 pix_fmts.push_back (AV_PIX_FMT_UYVY422);
57 pix_fmts.push_back (AV_PIX_FMT_YUVJ420P);
58 pix_fmts.push_back (AV_PIX_FMT_YUVJ422P);
59 pix_fmts.push_back (AV_PIX_FMT_YUVJ444P);
60 pix_fmts.push_back (AV_PIX_FMT_YUVA420P9BE);
61 pix_fmts.push_back (AV_PIX_FMT_YUVA422P9BE);
62 pix_fmts.push_back (AV_PIX_FMT_YUVA444P9BE);
63 pix_fmts.push_back (AV_PIX_FMT_YUVA420P9LE);
64 pix_fmts.push_back (AV_PIX_FMT_YUVA422P9LE);
65 pix_fmts.push_back (AV_PIX_FMT_YUVA444P9LE);
66 pix_fmts.push_back (AV_PIX_FMT_YUVA420P10BE);
67 pix_fmts.push_back (AV_PIX_FMT_YUVA422P10BE);
68 pix_fmts.push_back (AV_PIX_FMT_YUVA444P10BE);
69 pix_fmts.push_back (AV_PIX_FMT_YUVA420P10LE);
70 pix_fmts.push_back (AV_PIX_FMT_YUVA422P10LE);
71 pix_fmts.push_back (AV_PIX_FMT_YUVA444P10LE);
72 pix_fmts.push_back (AV_PIX_FMT_YUVA420P16BE);
73 pix_fmts.push_back (AV_PIX_FMT_YUVA422P16BE);
74 pix_fmts.push_back (AV_PIX_FMT_YUVA444P16BE);
75 pix_fmts.push_back (AV_PIX_FMT_YUVA420P16LE);
76 pix_fmts.push_back (AV_PIX_FMT_YUVA422P16LE);
77 pix_fmts.push_back (AV_PIX_FMT_YUVA444P16LE);
78 pix_fmts.push_back (AV_PIX_FMT_RGB555LE); // 46
81 for (list<AVPixelFormat>::const_iterator i = pix_fmts.begin(); i != pix_fmts.end(); ++i) {
82 boost::shared_ptr<Image> foo (new Image (*i, in_size, true));
84 boost::shared_ptr<Image> bar = foo->scale (out_size, dcp::YUV_TO_RGB_REC601, AV_PIX_FMT_RGB24, true, false);
86 uint8_t* p = bar->data()[0];
87 for (int y = 0; y < bar->size().height; ++y) {
89 for (int x = 0; x < bar->line_size()[0]; ++x) {
91 std::cerr << "x=" << x << ", (x%3)=" << (x%3) << "\n";
93 BOOST_CHECK_EQUAL (*q++, 0);
95 p += bar->stride()[0];