diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-07-02 11:06:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-03-21 16:41:13 +0000 |
| commit | 92078affea8d93960709db3fee2c661105102418 (patch) | |
| tree | 726bf04ed686a847f1f02bce463e959520e11a67 | |
| parent | b0849ca5ee5b26e72f78c5b5601a9a9a40177e01 (diff) | |
Various hacks.
| -rwxr-xr-x | run/poznan | 2 | ||||
| -rw-r--r-- | src/lib/poznan_encoder.cc | 23 | ||||
| -rw-r--r-- | src/lib/poznan_encoder.h | 1 | ||||
| -rw-r--r-- | src/lib/wscript | 2 | ||||
| -rw-r--r-- | test/poznan.cc | 9 | ||||
| -rw-r--r-- | test/wscript | 4 | ||||
| -rw-r--r-- | wscript | 3 |
7 files changed, 23 insertions, 21 deletions
diff --git a/run/poznan b/run/poznan index 7c472711b..d4e798f70 100755 --- a/run/poznan +++ b/run/poznan @@ -12,3 +12,5 @@ else build/test/poznan $* fi +#j2k_dump -i poznan.j2k > poznan.dump +#diff -u good.dump poznan.dump diff --git a/src/lib/poznan_encoder.cc b/src/lib/poznan_encoder.cc index 937566e81..22da60abd 100644 --- a/src/lib/poznan_encoder.cc +++ b/src/lib/poznan_encoder.cc @@ -24,6 +24,7 @@ #include <poznan/tier2/markers.h> #include <dcp/openjpeg_image.h> #include <dlfcn.h> +#include <thrust/system/cuda/error.h> #include "i18n.h" @@ -143,31 +144,32 @@ PoznanEncoder::do_encode (shared_ptr<const dcp::OpenJPEGImage> input) img->use_part2_mct = _param.param_use_part2_mct; img->mct_compression_method = _param.param_mct_compression_method; - img->coding_style = CODING_STYLE; + img->coding_style = CODING_STYLE_PRECINCTS_DEFINED; img->prog_order = COMP_POS_RES_LY_PROG; img->num_layers = NUM_LAYERS; _set_coding_parameters (img, &_param); _init_tiles (&img, &_param); - _color_coder_lossy (img); - type_tile* tile = &(img->tile[0]); /* XXX: it's a shame about this int -> float conversion */ 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]) / 4095; + 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); } + _color_coder_lossy (img); + std::cout << "Tile " << tile->width << "x" << tile->height << "\n"; _fwt (tile); _quantize_tile (tile); @@ -176,21 +178,14 @@ PoznanEncoder::do_encode (shared_ptr<const dcp::OpenJPEGImage> input) type_buffer buffer; _init_buffer (&buffer); _encode_codestream (&buffer, img); + if (cudaGetLastError () != cudaSuccess) { + throw EncodeError ("CUDA error"); + } std::cout << img->num_tiles << " tiles.\n"; std::cout << "got " << buffer.bytes_count << " bytes.\n"; Data encoded (buffer.data, buffer.bytes_count); - /* XXX! */ - static int shit = 0; - { - string name = raw_convert<string> (shit); - FILE* f = fopen (name.c_str(), "wb"); - fwrite (buffer.data, 1, buffer.bytes_count, f); - fclose (f); - ++shit; - } - free (buffer.data); delete img; diff --git a/src/lib/poznan_encoder.h b/src/lib/poznan_encoder.h index 2184e49ff..91413493c 100644 --- a/src/lib/poznan_encoder.h +++ b/src/lib/poznan_encoder.h @@ -58,4 +58,5 @@ private: void (*_cuda_h_allocate_mem) (void **, uint64_t); void (*_cuda_memcpy_htd) (void *, void *, uint64_t); void (*_cuda_h_free) (void *); + void (*_check_cuda_error) (char const *); }; diff --git a/src/lib/wscript b/src/lib/wscript index 7f7d63e5a..46b6f2627 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -157,7 +157,7 @@ def build(bld): AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_REGEX SNDFILE SAMPLERATE POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++ - CURL ZIP FONTCONFIG PANGOMM CAIROMM XMLSEC SUB ICU PATCHED_FFMPEG + CURL ZIP FONTCONFIG PANGOMM CAIROMM XMLSEC SUB ICU PATCHED_FFMPEG CUDA """ if bld.env.TARGET_OSX: diff --git a/test/poznan.cc b/test/poznan.cc index d96dcae1b..fe18667d1 100644 --- a/test/poznan.cc +++ b/test/poznan.cc @@ -28,20 +28,21 @@ int main () 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] = 0; + rgb->data()[0][y * line_size + x * 3 + 1] = 255; 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] = 0; rgb->data()[0][y * line_size + x * 3 + 1] = 0; - rgb->data()[0][y * line_size + x * 3 + 2] = 0; + rgb->data()[0][y * line_size + x * 3 + 2] = 255; } } shared_ptr<const dcp::OpenJPEGImage> xyz = dcp::rgb_to_xyz (rgb->data()[0], rgb->size(), rgb->stride()[0], ColourConversion::rec709_to_xyz ()); Data j2k = encoder->encode (xyz, 100000000, 24, RESOLUTION_2K, false); + j2k.write ("poznan.j2k"); } diff --git a/test/wscript b/test/wscript index b424ed22c..fe4a7dfaf 100644 --- a/test/wscript +++ b/test/wscript @@ -31,7 +31,7 @@ def build(bld): obj = bld(features='cxx cxxprogram') obj.name = 'unit-tests' obj.uselib = 'BOOST_TEST BOOST_THREAD BOOST_FILESYSTEM BOOST_DATETIME SNDFILE SAMPLERATE DCP FONTCONFIG CAIROMM PANGOMM XMLPP ' - obj.uselib += 'AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML MAGICK SUB GLIB CURL SSH XMLSEC BOOST_REGEX ICU ' + obj.uselib += 'AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC CXML MAGICK SUB GLIB CURL SSH XMLSEC BOOST_REGEX ICU CUDA ' if bld.env.TARGET_WINDOWS: obj.uselib += 'WINSOCK2' obj.use = 'libdcpomatic2' @@ -102,7 +102,7 @@ def build(bld): obj = bld(features='cxx cxxprogram') obj.name = 'poznan' - obj.uselib = 'DCP' + obj.uselib = 'DCP CUDA' obj.use = 'libdcpomatic2' obj.source = "poznan.cc" obj.target = 'poznan' @@ -267,6 +267,9 @@ def configure(conf): else: conf.env.LIB_XMLSEC = ['xmlsec1-openssl', 'xmlsec1'] + # XXX + conf.env.LIB_CUDA = ['cudart'] + # FFmpeg if conf.options.static_ffmpeg: names = ['avformat', 'avfilter', 'avcodec', 'avutil', 'swscale', 'postproc'] |
