diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-10 15:28:29 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-10 15:28:29 +0100 |
| commit | 6e10de6161f783de85bbaf59824a29026d524e55 (patch) | |
| tree | 2dc33ebea4800a32bb0f4e832e779f1ae888017c /src | |
| parent | a020b117c972db1d4e412c17465a5b7999eb3de9 (diff) | |
Take a JPEG2000 header marked as SRGB to mean that no XYZ -> RGB conversion should happen.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_video.cc | 4 | ||||
| -rw-r--r-- | src/lib/image_examiner.cc | 2 | ||||
| -rw-r--r-- | src/lib/j2k_image_proxy.cc | 30 |
3 files changed, 25 insertions, 11 deletions
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 78cbe65bd..69587a6ff 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -40,7 +40,7 @@ #include "raw_convert.h" #include "data.h" #include <libcxml/cxml.h> -#include <dcp/xyz_image.h> +#include <dcp/openjpeg_image.h> #include <dcp/rgb_xyz.h> #include <dcp/colour_matrix.h> #include <boost/array.hpp> @@ -107,7 +107,7 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml:: Data DCPVideo::encode_locally (dcp::NoteHandler note) { - shared_ptr<dcp::XYZImage> xyz; + shared_ptr<dcp::OpenJPEGImage> xyz; shared_ptr<Image> image = _frame->image (AV_PIX_FMT_RGB48LE, _burn_subtitles, note); if (_frame->colour_conversion()) { diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 502e8adbe..b2f962323 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -24,8 +24,8 @@ #include "exceptions.h" #include "config.h" #include "cross.h" +#include <dcp/openjpeg_image.h> #include <dcp/exceptions.h> -#include <dcp/xyz_image.h> #include <Magick++.h> #include <iostream> diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 28b7299c8..7dca3d8a9 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -22,7 +22,7 @@ #include "image.h" #include "data.h" #include "raw_convert.h" -#include <dcp/xyz_image.h> +#include <dcp/openjpeg_image.h> #include <dcp/mono_picture_frame.h> #include <dcp/stereo_picture_frame.h> #include <dcp/colour_conversion.h> @@ -82,21 +82,35 @@ J2KImageProxy::image (optional<dcp::NoteHandler> note) const { shared_ptr<Image> image (new Image (PIX_FMT_RGB48LE, _size, true)); - shared_ptr<dcp::XYZImage> xyz = dcp::decompress_j2k (const_cast<uint8_t*> (_data.data().get()), _data.size (), 0); + shared_ptr<dcp::OpenJPEGImage> oj = dcp::decompress_j2k (const_cast<uint8_t*> (_data.data().get()), _data.size (), 0); - if (xyz->opj_image()->comps[0].prec < 12) { - int const shift = 12 - xyz->opj_image()->comps[0].prec; + if (oj->opj_image()->comps[0].prec < 12) { + int const shift = 12 - oj->opj_image()->comps[0].prec; for (int c = 0; c < 3; ++c) { - int* p = xyz->data (c); - for (int y = 0; y < xyz->size().height; ++y) { - for (int x = 0; x < xyz->size().width; ++x) { + int* p = oj->data (c); + for (int y = 0; y < oj->size().height; ++y) { + for (int x = 0; x < oj->size().width; ++x) { *p++ <<= shift; } } } } - dcp::xyz_to_rgb (xyz, dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note); + if (oj->opj_image()->color_space == CLRSPC_SRGB) { + /* No XYZ -> RGB conversion necessary; just copy and interleave the values */ + int p = 0; + for (int y = 0; y < oj->size().height; ++y) { + uint16_t* q = (uint16_t *) (image->data()[0] + y * image->stride()[0]); + for (int x = 0; x < oj->size().width; ++x) { + for (int c = 0; c < 3; ++c) { + *q++ = oj->data(c)[p] << 4; + } + ++p; + } + } + } else { + dcp::xyz_to_rgb (oj, dcp::ColourConversion::srgb_to_xyz(), image->data()[0], image->stride()[0], note); + } return image; } |
