summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-02-02 22:33:27 +0000
committerCarl Hetherington <cth@carlh.net>2015-02-02 22:33:27 +0000
commit989f182558193a51e0a26603fb2ca59f827216a0 (patch)
tree7d2b2511967e5417838a4343341e5aa9d26cf2b8 /test
parent0d7fe66361a40702cb97357955cf35256f1d2c26 (diff)
Remove Image and ARGBImage and just dump RGB data into
uint8_t* buffers. This is hopefully simpler than trying to come up with some Image hierarchy that suits everything.
Diffstat (limited to 'test')
-rw-r--r--test/argb_image_test.cc31
-rw-r--r--test/decryption_test.cc40
-rw-r--r--test/image_test.cc68
-rw-r--r--test/rgb_xyz_test.cc46
-rw-r--r--test/round_trip_test.cc23
-rw-r--r--test/wscript2
6 files changed, 56 insertions, 154 deletions
diff --git a/test/argb_image_test.cc b/test/argb_image_test.cc
deleted file mode 100644
index e88d208b..00000000
--- a/test/argb_image_test.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "argb_image.h"
-#include <boost/test/unit_test.hpp>
-
-/** Very simple tests of ARGBImage */
-BOOST_AUTO_TEST_CASE (argb_image_test)
-{
- dcp::ARGBImage f (dcp::Size (100, 200));
-
- BOOST_CHECK (f.data() != 0);
- BOOST_CHECK_EQUAL (f.stride(), 100 * 4);
- BOOST_CHECK_EQUAL (f.size(), dcp::Size (100, 200));
-}
diff --git a/test/decryption_test.cc b/test/decryption_test.cc
index a28f3c64..282e74f3 100644
--- a/test/decryption_test.cc
+++ b/test/decryption_test.cc
@@ -17,22 +17,28 @@
*/
-#include <boost/test/unit_test.hpp>
#include "dcp.h"
#include "mono_picture_frame.h"
#include "cpl.h"
#include "decrypted_kdm.h"
#include "encrypted_kdm.h"
-#include "argb_image.h"
#include "mono_picture_mxf.h"
#include "reel_picture_asset.h"
#include "reel.h"
#include "test.h"
+#include "xyz_image.h"
+#include "rgb_xyz.h"
+#include "colour_conversion.h"
+#include <boost/test/unit_test.hpp>
+#include <boost/scoped_array.hpp>
+using std::pair;
+using std::make_pair;
using boost::dynamic_pointer_cast;
using boost::shared_ptr;
+using boost::scoped_array;
-static shared_ptr<const dcp::ARGBImage>
+pair<uint8_t*, dcp::Size>
get_frame (dcp::DCP const & dcp)
{
shared_ptr<const dcp::Reel> reel = dcp.cpls().front()->reels().front ();
@@ -41,7 +47,11 @@ get_frame (dcp::DCP const & dcp)
shared_ptr<const dcp::MonoPictureMXF> mono_picture = dynamic_pointer_cast<const dcp::MonoPictureMXF> (picture);
shared_ptr<const dcp::MonoPictureFrame> j2k_frame = mono_picture->get_frame (0);
- return j2k_frame->argb_image ();
+ shared_ptr<dcp::XYZImage> xyz = j2k_frame->xyz_image();
+
+ uint8_t* argb = new uint8_t[xyz->size().width * xyz->size().height * 4];
+ dcp::xyz_to_rgba (j2k_frame->xyz_image(), dcp::ColourConversion::xyz_to_srgb(), argb);
+ return make_pair (argb, xyz->size ());
}
/** Decrypt an encrypted test DCP and check that its first frame is the same as the unencrypted version */
@@ -68,14 +78,24 @@ BOOST_AUTO_TEST_CASE (decryption_test)
encrypted.add (kdm);
- shared_ptr<const dcp::ARGBImage> plaintext_frame = get_frame (plaintext);
- shared_ptr<const dcp::ARGBImage> encrypted_frame = get_frame (encrypted);
+ pair<uint8_t *, dcp::Size> plaintext_frame = get_frame (plaintext);
+ pair<uint8_t *, dcp::Size> encrypted_frame = get_frame (encrypted);
/* Check that plaintext and encrypted are the same */
- BOOST_CHECK_EQUAL (plaintext_frame->stride(), encrypted_frame->stride());
- BOOST_CHECK_EQUAL (plaintext_frame->size().width, encrypted_frame->size().width);
- BOOST_CHECK_EQUAL (plaintext_frame->size().height, encrypted_frame->size().height);
- BOOST_CHECK_EQUAL (memcmp (plaintext_frame->data(), encrypted_frame->data(), plaintext_frame->stride() * plaintext_frame->size().height), 0);
+
+ BOOST_CHECK_EQUAL (plaintext_frame.second, encrypted_frame.second);
+
+ BOOST_CHECK_EQUAL (
+ memcmp (
+ plaintext_frame.first,
+ encrypted_frame.first,
+ plaintext_frame.second.width * plaintext_frame.second.height * 4
+ ),
+ 0
+ );
+
+ delete[] plaintext_frame.first;
+ delete[] encrypted_frame.first;
}
/** Load in a KDM that didn't work at first */
diff --git a/test/image_test.cc b/test/image_test.cc
deleted file mode 100644
index 216c3c5c..00000000
--- a/test/image_test.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "image.h"
-#include <boost/test/unit_test.hpp>
-
-using std::string;
-using boost::shared_ptr;
-
-class TestImage : public dcp::Image
-{
-public:
- TestImage (dcp::Size s)
- : Image (s)
- {
-
- }
-
- TestImage (TestImage const & other)
- : Image (other)
- {
-
- }
-
- TestImage (shared_ptr<const TestImage> other)
- : Image (other)
- {
-
- }
-
- uint8_t * const * data () const {
- return 0;
- }
-
- int const * stride () const {
- return 0;
- }
-};
-
-/** Token test for Image class to keep gcov happy */
-BOOST_AUTO_TEST_CASE (image_test)
-{
- TestImage im (dcp::Size (412, 930));
- BOOST_CHECK_EQUAL (im.size (), dcp::Size (412, 930));
-
- TestImage im2 (im);
- BOOST_CHECK_EQUAL (im2.size (), im.size ());
-
- shared_ptr<TestImage> im3 (new TestImage (dcp::Size (1203, 1294)));
- TestImage im4 (im3);
- BOOST_CHECK_EQUAL (im4.size (), im3->size ());
-}
diff --git a/test/rgb_xyz_test.cc b/test/rgb_xyz_test.cc
index 6ee62dbf..26411870 100644
--- a/test/rgb_xyz_test.cc
+++ b/test/rgb_xyz_test.cc
@@ -17,47 +17,19 @@
*/
-#include "image.h"
#include "rgb_xyz.h"
#include "xyz_image.h"
#include "colour_conversion.h"
#include <boost/test/unit_test.hpp>
#include <boost/bind.hpp>
+#include <boost/scoped_array.hpp>
using std::max;
using std::list;
using std::string;
using boost::shared_ptr;
using boost::optional;
-
-class SimpleImage : public dcp::Image
-{
-public:
- SimpleImage (dcp::Size size)
- : Image (size)
- {
- /* 48bpp */
- _stride[0] = _size.width * 6;
- _data[0] = new uint8_t[size.height * stride()[0]];
- }
-
- ~SimpleImage ()
- {
- delete[] _data[0];
- }
-
- uint8_t * const * data () const {
- return _data;
- }
-
- int const * stride () const {
- return _stride;
- }
-
-private:
- uint8_t* _data[1];
- int _stride[1];
-};
+using boost::scoped_array;
/** Convert a test image from sRGB to XYZ and check that the transforms are right */
BOOST_AUTO_TEST_CASE (rgb_xyz_test)
@@ -65,9 +37,9 @@ BOOST_AUTO_TEST_CASE (rgb_xyz_test)
unsigned int seed = 0;
dcp::Size const size (640, 480);
- shared_ptr<const dcp::Image> rgb (new SimpleImage (size));
+ scoped_array<uint8_t> rgb (new uint8_t[size.width * size.height * 6]);
for (int y = 0; y < size.height; ++y) {
- uint16_t* p = reinterpret_cast<uint16_t*> (rgb->data()[0] + y * rgb->stride()[0]);
+ uint16_t* p = reinterpret_cast<uint16_t*> (rgb.get() + y * size.width * 6);
for (int x = 0; x < size.width; ++x) {
/* Write a 12-bit random number for each component */
for (int c = 0; c < 3; ++c) {
@@ -77,10 +49,10 @@ BOOST_AUTO_TEST_CASE (rgb_xyz_test)
}
}
- shared_ptr<dcp::XYZImage> xyz = dcp::rgb_to_xyz (rgb, dcp::ColourConversion::srgb_to_xyz ());
+ shared_ptr<dcp::XYZImage> xyz = dcp::rgb_to_xyz (rgb.get(), size, size.width * 6, dcp::ColourConversion::srgb_to_xyz ());
for (int y = 0; y < size.height; ++y) {
- uint16_t* p = reinterpret_cast<uint16_t*> (rgb->data()[0] + y * rgb->stride()[0]);
+ uint16_t* p = reinterpret_cast<uint16_t*> (rgb.get() + y * size.width * 6);
for (int x = 0; x < size.width; ++x) {
double cr = *p++ / 65535.0;
@@ -159,10 +131,10 @@ BOOST_AUTO_TEST_CASE (xyz_rgb_range_test)
xyz->data(2)[2] = 0;
xyz->data(2)[3] = 4095;
- shared_ptr<SimpleImage> image (new SimpleImage (dcp::Size (2, 2)));
+ scoped_array<uint8_t> rgb (new uint8_t[2 * 2 * 6]);
notes.clear ();
- dcp::xyz_to_rgb (xyz, dcp::ColourConversion::xyz_to_srgb (), image, boost::optional<dcp::NoteHandler> (boost::bind (&note_handler, _1, _2)));
+ dcp::xyz_to_rgb (xyz, dcp::ColourConversion::xyz_to_srgb (), rgb.get(), 2 * 6, boost::optional<dcp::NoteHandler> (boost::bind (&note_handler, _1, _2)));
/* The 6 out-of-range samples should have been noted */
BOOST_REQUIRE_EQUAL (notes.size(), 6);
@@ -178,7 +150,7 @@ BOOST_AUTO_TEST_CASE (xyz_rgb_range_test)
as inputs at the extremes (0 and 4095).
*/
- uint16_t* buffer = reinterpret_cast<uint16_t*> (image->data()[0]);
+ uint16_t* buffer = reinterpret_cast<uint16_t*> (rgb.get ());
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 0], buffer[2 * 3 + 1]);
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 1], buffer[2 * 3 + 1]);
BOOST_REQUIRE_EQUAL (buffer[0 * 3 + 2], buffer[2 * 3 + 2]);
diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc
index 6f5372ec..dcaa6939 100644
--- a/test/round_trip_test.cc
+++ b/test/round_trip_test.cc
@@ -27,17 +27,21 @@
#include "test.h"
#include "cpl.h"
#include "mono_picture_frame.h"
-#include "argb_image.h"
#include "certificate_chain.h"
#include "mono_picture_mxf_writer.h"
#include "reel_picture_asset.h"
#include "reel_mono_picture_asset.h"
#include "file.h"
+#include "xyz_image.h"
+#include "rgb_xyz.h"
+#include "colour_conversion.h"
#include <boost/test/unit_test.hpp>
+#include <boost/scoped_array.hpp>
#include <iostream>
using std::list;
using boost::shared_ptr;
+using boost::scoped_array;
/* Build an encrypted picture MXF and a KDM for it and check that the KDM can be decrypted */
BOOST_AUTO_TEST_CASE (round_trip_test)
@@ -102,9 +106,16 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
BOOST_CHECK (!kdm_B.keys().empty ());
mxf_B->set_key (kdm_B.keys().front().key());
- shared_ptr<dcp::ARGBImage> frame_A = mxf_A->get_frame(0)->argb_image ();
- shared_ptr<dcp::ARGBImage> frame_B = mxf_B->get_frame(0)->argb_image ();
- BOOST_CHECK_EQUAL (frame_A->size().width, frame_B->size().width);
- BOOST_CHECK_EQUAL (frame_A->size().height, frame_B->size().height);
- BOOST_CHECK_EQUAL (memcmp (frame_A->data(), frame_B->data(), frame_A->size().width * frame_A->size().height), 0);
+ shared_ptr<dcp::XYZImage> xyz_A = mxf_A->get_frame(0)->xyz_image ();
+ shared_ptr<dcp::XYZImage> xyz_B = mxf_B->get_frame(0)->xyz_image ();
+
+ scoped_array<uint8_t> frame_A (new uint8_t[xyz_A->size().width * xyz_A->size().height * 4]);
+ dcp::xyz_to_rgba (xyz_A, dcp::ColourConversion::xyz_to_srgb(), frame_A.get());
+
+ scoped_array<uint8_t> frame_B (new uint8_t[xyz_B->size().width * xyz_B->size().height * 4]);
+ dcp::xyz_to_rgba (xyz_B, dcp::ColourConversion::xyz_to_srgb(), frame_B.get());
+
+ BOOST_CHECK_EQUAL (xyz_A->size().width, xyz_B->size().width);
+ BOOST_CHECK_EQUAL (xyz_A->size().height, xyz_B->size().height);
+ BOOST_CHECK_EQUAL (memcmp (frame_A.get(), frame_B.get(), xyz_A->size().width * xyz_A->size().height * 4), 0);
}
diff --git a/test/wscript b/test/wscript
index b723f54c..09bcb132 100644
--- a/test/wscript
+++ b/test/wscript
@@ -25,7 +25,6 @@ def build(bld):
else:
obj.use = 'libdcp%s' % bld.env.API_VERSION
obj.source = """
- argb_image_test.cc
certificates_test.cc
colour_test.cc
colour_conversion_test.cc
@@ -38,7 +37,6 @@ def build(bld):
exception_test.cc
fraction_test.cc
frame_info_test.cc
- image_test.cc
interop_load_font_test.cc
local_time_test.cc
kdm_test.cc