#!/bin/bash
-export LD_LIBRARY_PATH=build/src/lib:poznan:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH=build/src/lib:$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 $*
+ valgrind --tool="memcheck" build/test/poznan $*
else
build/test/poznan $*
fi
-#j2k_dump -i poznan.j2k > poznan.dump
-#diff -u good.dump poznan.dump
+j2k_dump -i openjpeg.j2k > openjpeg.dump
+j2k_dump -i poznan.j2k > poznan.dump
+diff -u openjpeg.dump poznan.dump
#include <dcp/data.h>
#include <dlfcn.h>
#include <thrust/system/cuda/error.h>
+#include <cfloat>
#include "i18n.h"
using std::string;
using std::cout;
+using std::min;
+using std::max;
using boost::shared_ptr;
using dcp::Data;
_encode_codestream = (void (*)(type_buffer *, type_image *)) dlsym (tier2, "encode_codestream");
_cuda_h_allocate_mem = (void (*)(void **, uint64_t)) dlsym (misc, "cuda_h_allocate_mem");
_cuda_memcpy_htd = (void (*)(void *, void *, uint64_t)) dlsym (misc, "cuda_memcpy_htd");
+ _cuda_memcpy_dth = (void (*)(void *, void *, uint64_t)) dlsym (misc, "cuda_memcpy_dth");
_cuda_h_free = (void (*)(void *)) dlsym (misc, "cuda_h_free");
if (
for (int i = 0; i < 3; ++i) {
type_tile_comp* c = &tile->tile_comp[i];
c->tile_comp_no = i;
- std::cout << "Tile comp " << i << ": " << c->width << "x" << c->height << "\n";
int const pixels = c->width * c->height;
_cuda_h_allocate_mem ((void **) &c->img_data, pixels * sizeof (type_data));
for (int j = 0; j < pixels; ++j) {
c->img_data[j] = float (input->data(i)[j]);
- //c->img_data[j] = input->data(i)[j];
}
_cuda_memcpy_htd (c->img_data, c->img_data_d, pixels * sizeof (type_data));
_cuda_h_free (c->img_data);
}
+ for (int i = 0; i < 3; ++i) {
+ type_tile_comp* c = &tile->tile_comp[i];
+ int const pixels = c->width * c->height;
+ float* data = new float[pixels];
+ _cuda_memcpy_dth (c->img_data_d, data, pixels * sizeof (type_data));
+ float yuv_min = FLT_MAX;
+ float yuv_max = -FLT_MAX;
+ for (int j = 0; j < pixels; ++j) {
+ yuv_min = min (yuv_min, data[j]);
+ yuv_max = max (yuv_max, data[j]);
+ }
+ delete[] data;
+ printf("RGB component %d range %f to %f\n", i, yuv_min, yuv_max);
+ }
+
_color_coder_lossy (img);
- std::cout << "Tile " << tile->width << "x" << tile->height << "\n";
+ for (int i = 0; i < 3; ++i) {
+ type_tile_comp* c = &tile->tile_comp[i];
+ int const pixels = c->width * c->height;
+ float* data = new float[pixels];
+ _cuda_memcpy_dth (c->img_data_d, data, pixels * sizeof (type_data));
+ float yuv_min = FLT_MAX;
+ float yuv_max = -FLT_MAX;
+ for (int j = 0; j < pixels; ++j) {
+ yuv_min = min (yuv_min, data[j]);
+ yuv_max = max (yuv_max, data[j]);
+ }
+ delete[] data;
+ printf("YCbCr component %d range %f to %f\n", i, yuv_min, yuv_max);
+ }
+
_fwt (tile);
_quantize_tile (tile);
_encode_tile (tile);
throw EncodeError ("CUDA error");
}
- std::cout << img->num_tiles << " tiles.\n";
- std::cout << "got " << buffer.bytes_count << " bytes.\n";
+ cout << "Output " << buffer.bytes_count << " bytes.\n";
Data encoded (buffer.data, buffer.bytes_count);
free (buffer.data);
void (*_encode_codestream) (type_buffer *, type_image *);
void (*_cuda_h_allocate_mem) (void **, uint64_t);
void (*_cuda_memcpy_htd) (void *, void *, uint64_t);
+ void (*_cuda_memcpy_dth) (void *, void *, uint64_t);
void (*_cuda_h_free) (void *);
void (*_check_cuda_error) (char const *);
};
#include "lib/image.h"
#include "lib/colour_conversion.h"
#include "lib/config.h"
+#include "lib/magick_image_proxy.h"
#include <dcp/rgb_xyz.h>
using std::vector;
using boost::shared_ptr;
using dcp::Data;
-int main ()
+static
+void
+colour_bars (shared_ptr<Image> rgb)
{
- JPEG2000Encoder::setup_encoders ();
-
- shared_ptr<JPEG2000Encoder> openjpeg = JPEG2000Encoder::from_id ("openjpeg");
- shared_ptr<JPEG2000Encoder> poznan = JPEG2000Encoder::from_id ("poznan");
-
- shared_ptr<Image> rgb (new Image (AV_PIX_FMT_RGB48LE, dcp::Size (1998, 1080), false));
-
- cout << rgb->stride()[0] << "\n";
-
int const line_size = rgb->stride()[0] / 2;
int const width = rgb->size().width;
int const height = rgb->size().height;
p[y * line_size + x * 3 + 2] = 65535;
}
}
+}
+
+int main ()
+{
+ JPEG2000Encoder::setup_encoders ();
+
+ shared_ptr<JPEG2000Encoder> openjpeg = JPEG2000Encoder::from_id ("openjpeg");
+ shared_ptr<JPEG2000Encoder> poznan = JPEG2000Encoder::from_id ("poznan");
+
+ bool const testcard = false;
+
+ shared_ptr<Image> rgb;
+ if (testcard) {
+ rgb.reset (new Image (AV_PIX_FMT_RGB48LE, dcp::Size (1998, 1080), false));
+ colour_bars (rgb);
+ } else {
+ shared_ptr<MagickImageProxy> mip (new MagickImageProxy ("../dcpomatic-test-private/frame.tiff"));
+ shared_ptr<Image> raw = mip->image();
+ rgb.reset (new Image (AV_PIX_FMT_RGB48LE, raw->size(), false));
+ for (int y = 0; y < raw->size().height; ++y) {
+ uint8_t const * p = raw->data()[0] + y * raw->stride()[0];
+ uint8_t* q = rgb->data()[0] + y * rgb->stride()[0];
+ if (y == 0) {
+ for (int x = 0; x < 16; ++x) {
+ cout << ((int)p[x * 3]) << " " << ((int)p[x * 3 + 1]) << " " << ((int)p[x * 2]) << "\n";
+ }
+ }
+ for (int x = 0; x < raw->size().width; ++x) {
+ *q++ = 0;
+ *q++ = *p++;
+ *q++ = 0;
+ *q++ = *p++;
+ *q++ = 0;
+ *q++ = *p++;
+ }
+ }
+ }
shared_ptr<const dcp::OpenJPEGImage> xyz = dcp::rgb_to_xyz (rgb->data()[0], rgb->size(), rgb->stride()[0], ColourConversion::rec709_to_xyz ());
openjpeg->encode (xyz, 100000000, 24, RESOLUTION_2K, false).write ("openjpeg.j2k");
obj = bld(features='cxx cxxprogram')
obj.name = 'poznan'
- obj.uselib = 'DCP CUDA'
+ obj.uselib = 'DCP CUDA MAGICK BOOST_FILESYSTEM SNDFILE'
obj.use = 'libdcpomatic2'
obj.source = "poznan.cc"
obj.target = 'poznan'