From 7bd8eecb8ba8535978d58408dc73ce7528034c7e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 4 Aug 2022 23:55:17 +0200 Subject: wip: got stuck... because PlayerVideo is related to the render size because its subtitles are prepared for the _video_container_size that the Player knows about. I think the only way around this would be to store the subs in PlayerVideo in some independent way and to scale/convert to bitmap later. --- test/player_video_test.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 test/player_video_test.cc (limited to 'test') diff --git a/test/player_video_test.cc b/test/player_video_test.cc new file mode 100644 index 000000000..c4241ed9b --- /dev/null +++ b/test/player_video_test.cc @@ -0,0 +1,73 @@ +/* + Copyright (C) 2022 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/colour_conversion.h" +#include "lib/j2k_image_proxy.h" +#include "lib/player_video.h" +#include +#include +#include +#include +#include + + +using std::make_shared; +using std::weak_ptr; +using boost::optional; + + +BOOST_AUTO_TEST_CASE(player_video_j2k_passthrough_test) +{ + auto size = dcp::Size(4096, 2048); + auto image = make_shared(size); + for (int x = 0; x < size.width; ++x) { + image->data(0)[x] = x; + image->data(1)[x] = x; + image->data(2)[x] = x; + } + for (int y = 1; y < size.height; ++y) { + memcpy(image->data(0) + y * size.width, image->data(0), size.width); + memcpy(image->data(1) + y * size.width, image->data(1), size.width); + memcpy(image->data(2) + y * size.width, image->data(2), size.width); + } + auto compressed = compress_j2k(image, 250000000LL, 24, false, true); + auto decompressed = decompress_j2k(compressed, 0); + auto frame = make_shared(compressed.data(), compressed.size()); + auto proxy = make_shared(frame, size, AV_PIX_FMT_XYZ12LE, optional()); + auto video = make_shared(proxy, Crop(), optional(), size, size, Eyes::BOTH, Part::WHOLE, optional(), VideoRange::FULL, weak_ptr(), optional(), false); + auto out_image = video->image([](AVPixelFormat) { return AV_PIX_FMT_XYZ12LE; }, VideoRange::FULL, false); + + BOOST_REQUIRE_EQUAL(out_image->size().width, size.width); + BOOST_REQUIRE_EQUAL(out_image->size().height, size.height); + + for (int c = 0; c < 3; ++c) { + for (auto y = 0; y < size.height; ++y) { + auto in = decompressed->data(c) + y * size.width; + auto out = reinterpret_cast(out_image->data()[0] + y * out_image->stride()[0]) + c; + for (int x = 0; x < size.width; ++x) { + BOOST_REQUIRE_MESSAGE(*in == (*out >> 4), *in << " != " << *out << " at x=" << x << ", y=" << y << ", c=" << c); + ++in; + out += 3; + } + } + } +} + -- cgit v1.2.3