summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-06-23 11:57:50 +0100
committerCarl Hetherington <cth@carlh.net>2017-06-23 11:57:50 +0100
commit3a5b068428bcc2080908a01204411038225d3851 (patch)
tree5ed2f1f753d1ffdd48765842d7f31a669166b016 /src
parent863d9cc51b406500dba596b6f1de733ec3f410c5 (diff)
Make xyz_to_xyz into a constructor of OpenJPEGImage where it makes more sense.
Diffstat (limited to 'src')
-rw-r--r--src/openjpeg_image.cc26
-rw-r--r--src/openjpeg_image.h3
-rw-r--r--src/rgb_xyz.cc25
-rw-r--r--src/rgb_xyz.h2
4 files changed, 29 insertions, 27 deletions
diff --git a/src/openjpeg_image.cc b/src/openjpeg_image.cc
index cf9063a9..31889566 100644
--- a/src/openjpeg_image.cc
+++ b/src/openjpeg_image.cc
@@ -85,6 +85,32 @@ OpenJPEGImage::OpenJPEGImage (OpenJPEGImage const & other)
*/
OpenJPEGImage::OpenJPEGImage (Size size)
{
+ create (size);
+}
+
+/** @param data_16 XYZ/RGB image data in packed 16:16:16, 48bpp with
+ * the 2-byte value for each component stored as little-endian.
+ */
+OpenJPEGImage::OpenJPEGImage (uint8_t const * data_16, dcp::Size size, int stride)
+{
+ create (size);
+
+ int jn = 0;
+ for (int y = 0; y < size.height; ++y) {
+ uint16_t const * p = reinterpret_cast<uint16_t const *> (data_16 + y * stride);
+ for (int x = 0; x < size.width; ++x) {
+ /* Truncate 16-bit to 12-bit */
+ _opj_image->comps[0].data[jn] = *p++ >> 4;
+ _opj_image->comps[1].data[jn] = *p++ >> 4;
+ _opj_image->comps[2].data[jn] = *p++ >> 4;
+ ++jn;
+ }
+ }
+}
+
+void
+OpenJPEGImage::create (Size size)
+{
opj_image_cmptparm_t cmptparm[3];
for (int i = 0; i < 3; ++i) {
diff --git a/src/openjpeg_image.h b/src/openjpeg_image.h
index fa83a8de..002e2a83 100644
--- a/src/openjpeg_image.h
+++ b/src/openjpeg_image.h
@@ -51,6 +51,7 @@ public:
explicit OpenJPEGImage (opj_image_t *);
explicit OpenJPEGImage (OpenJPEGImage const & other);
explicit OpenJPEGImage (Size);
+ OpenJPEGImage (uint8_t const * in_16, dcp::Size size, int stride);
~OpenJPEGImage ();
int* data (int) const;
@@ -67,6 +68,8 @@ public:
}
private:
+ void create (Size size);
+
opj_image_t* _opj_image; ///< opj_image_t that we are managing
};
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index b4307756..d0774e7c 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -348,28 +348,3 @@ dcp::rgb_to_xyz (
return xyz;
}
-
-
-/** @param xyz_16 XYZ image data in packed 16:16:16, 48bpp, 16X, 16Y,
- * 16Z, with the 2-byte value for each X/Y/Z component stored as
- * little-endian.
- */
-shared_ptr<dcp::OpenJPEGImage>
-dcp::xyz_to_xyz (uint8_t const * xyz_16, dcp::Size size, int stride)
-{
- shared_ptr<OpenJPEGImage> xyz_12 (new OpenJPEGImage (size));
-
- int jn = 0;
- for (int y = 0; y < size.height; ++y) {
- uint16_t const * p = reinterpret_cast<uint16_t const *> (xyz_16 + y * stride);
- for (int x = 0; x < size.width; ++x) {
- /* Truncate 16-bit to 12-bit */
- xyz_12->data(0)[jn] = *p++ >> 4;
- xyz_12->data(1)[jn] = *p++ >> 4;
- xyz_12->data(2)[jn] = *p++ >> 4;
- ++jn;
- }
- }
-
- return xyz_12;
-}
diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h
index 907869af..fcd15cfd 100644
--- a/src/rgb_xyz.h
+++ b/src/rgb_xyz.h
@@ -66,8 +66,6 @@ extern boost::shared_ptr<OpenJPEGImage> rgb_to_xyz (
boost::optional<NoteHandler> note = boost::optional<NoteHandler> ()
);
-extern boost::shared_ptr<OpenJPEGImage> xyz_to_xyz (uint8_t const * xyz, dcp::Size size, int stride);
-
extern void combined_rgb_to_xyz (ColourConversion const & conversion, double* matrix);
}