Add test program for Poznan encoder.
authorCarl Hetherington <cth@carlh.net>
Tue, 19 May 2015 14:39:28 +0000 (15:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 21 Mar 2016 16:41:10 +0000 (16:41 +0000)
run/poznan [new file with mode: 0755]
test/poznan.cc [new file with mode: 0644]
test/wscript

diff --git a/run/poznan b/run/poznan
new file mode 100755 (executable)
index 0000000..7c47271
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src/lib:poznan:$LD_LIBRARY_PATH
+export DCPOMATIC_LINUX_SHARE_PREFIX=`pwd`
+if [ "$1" == "--debug" ]; then
+    shift;
+    gdb --args build/test/poznan $*
+elif [ "$1" == "--valgrind" ]; then
+    shift;
+    valgrind --tool="memcheck" --leak-check=full build/test/poznan $*
+else
+    build/test/poznan $*
+fi
+
diff --git a/test/poznan.cc b/test/poznan.cc
new file mode 100644 (file)
index 0000000..67769dd
--- /dev/null
@@ -0,0 +1,49 @@
+#include "lib/poznan_encoder.h"
+#include "lib/jpeg2000_encoder.h"
+#include "lib/image.h"
+#include "lib/colour_conversion.h"
+#include "lib/config.h"
+#include <dcp/rgb_xyz.h>
+
+using std::vector;
+using boost::shared_ptr;
+
+int main ()
+{
+       JPEG2000Encoder::setup_encoders ();
+       
+       shared_ptr<JPEG2000Encoder> encoder = JPEG2000Encoder::from_id ("poznan");
+
+       shared_ptr<Image> rgb (new Image (PIX_FMT_RGB24, dcp::Size (1998, 1080), false));
+
+       int const line_size = 1998 * 3;
+
+       for (int x = 0; x < 666; ++x) {
+               for (int y = 0; y < 1080; ++y) {
+                       rgb->data()[0][y * line_size + x * 3] = 255;
+                       rgb->data()[0][y * line_size + x * 3 + 1] = 0;
+                       rgb->data()[0][y * line_size + x * 3 + 2] = 0;
+               }
+       }
+
+       for (int x = 666; x < 1332; ++x) {
+               for (int y = 0; y < 1080; ++y) {
+                       rgb->data()[0][y * line_size + x * 3] = 255;
+                       rgb->data()[0][y * line_size + x * 3 + 1] = 0;
+                       rgb->data()[0][y * line_size + x * 3 + 2] = 0;
+               }
+       }
+
+       for (int x = 1332; x < 1998; ++x) {
+               for (int y = 0; y < 1080; ++y) {
+                       rgb->data()[0][y * line_size + x * 3] = 255;
+                       rgb->data()[0][y * line_size + x * 3 + 1] = 0;
+                       rgb->data()[0][y * line_size + x * 3 + 2] = 0;
+               }
+       }
+
+       vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
+       shared_ptr<const dcp::XYZImage> xyz = dcp::rgb_to_xyz (rgb->data()[0], rgb->size(), rgb->stride()[0], presets.front().conversion);
+
+       shared_ptr<EncodedData> j2k = encoder->encode (xyz, 100000000, 24, RESOLUTION_2K, false);
+}
index 7efe6e61c9f692f594e631ab0ec97ca107ff6967..b424ed22cd73364b12110c3300da7bb87136f08b 100644 (file)
@@ -99,3 +99,11 @@ def build(bld):
 
     obj.target = 'unit-tests'
     obj.install_path = ''
+
+    obj = bld(features='cxx cxxprogram')
+    obj.name = 'poznan'
+    obj.uselib = 'DCP'
+    obj.use = 'libdcpomatic2'
+    obj.source = "poznan.cc"
+    obj.target = 'poznan'
+    obj.install_path = ''