Move convert_to_xyz out of DCPVideo.
authorCarl Hetherington <cth@carlh.net>
Fri, 20 May 2022 07:36:02 +0000 (09:36 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 23 May 2022 14:55:28 +0000 (16:55 +0200)
src/lib/colour_conversion.cc
src/lib/colour_conversion.h
src/lib/dcp_video.cc
src/lib/dcp_video.h
src/wx/video_waveform_plot.cc

index b0c81e91cc832d297b310098985eb0ea47bd6106..da6dca61db8d677b4bb83a93d08a8f311bbd5e76 100644 (file)
 #include "colour_conversion.h"
 #include "config.h"
 #include "digester.h"
+#include "player_video.h"
 #include "util.h"
 #include <dcp/chromaticity.h>
 #include <dcp/gamma_transfer_function.h>
 #include <dcp/identity_transfer_function.h>
 #include <dcp/modified_gamma_transfer_function.h>
+#include <dcp/openjpeg_image.h>
 #include <dcp/raw_convert.h>
+#include <dcp/rgb_xyz.h>
 #include <dcp/s_gamut3_transfer_function.h>
 #include <dcp/warnings.h>
 #include <libcxml/cxml.h>
@@ -47,6 +50,9 @@ using std::shared_ptr;
 using std::string;
 using std::vector;
 using boost::optional;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 using dcp::raw_convert;
 
 
@@ -305,3 +311,26 @@ PresetColourConversion::from_id (string s)
 
        DCPOMATIC_ASSERT (false);
 }
+
+
+shared_ptr<dcp::OpenJPEGImage>
+convert_to_xyz (shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note)
+{
+       shared_ptr<dcp::OpenJPEGImage> xyz;
+
+       auto image = frame->image (bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
+       if (frame->colour_conversion()) {
+               xyz = dcp::rgb_to_xyz (
+                       image->data()[0],
+                       image->size(),
+                       image->stride()[0],
+                       frame->colour_conversion().get(),
+                       note
+                       );
+       } else {
+               xyz = make_shared<dcp::OpenJPEGImage>(image->data()[0], image->size(), image->stride()[0]);
+       }
+
+       return xyz;
+}
+
index 73b6ad23ccf558f469b2e29a5369d562301ba505..66726f492dcd4f93c737d592a5581b239b611848 100644 (file)
 
 */
 
+
 #ifndef DCPOMATIC_COLOUR_CONVERSION_H
 #define DCPOMATIC_COLOUR_CONVERSION_H
 
+
 /* Hack for OS X compile failure; see https://bugs.launchpad.net/hugin/+bug/910160 */
 #ifdef check
 #undef check
 #endif
 
+
 #include <dcp/colour_conversion.h>
+#include <dcp/types.h>
 #include <libcxml/cxml.h>
 
+
 namespace xmlpp {
        class Node;
 }
 
+namespace dcp {
+       class OpenJPEGImage;
+}
+
+
+class PlayerVideo;
+
+
 class ColourConversion : public dcp::ColourConversion
 {
 public:
@@ -77,4 +90,8 @@ bool operator== (ColourConversion const &, ColourConversion const &);
 bool operator!= (ColourConversion const &, ColourConversion const &);
 bool operator== (PresetColourConversion const &, PresetColourConversion const &);
 
+
+extern std::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz (std::shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note);
+
+
 #endif
index 50d33e9d5e1cff769336d1ba7332e0f7363095fc..2cecee95b18d0479d8ddf4eedc0822f0c788bd98 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 
+#include "colour_conversion.h"
 #include "compose.hpp"
 #include "config.h"
 #include "cross.h"
@@ -100,26 +101,6 @@ DCPVideo::DCPVideo (shared_ptr<const PlayerVideo> frame, shared_ptr<const cxml::
        _resolution = Resolution (node->optional_number_child<int>("Resolution").get_value_or(static_cast<int>(Resolution::TWO_K)));
 }
 
-shared_ptr<dcp::OpenJPEGImage>
-DCPVideo::convert_to_xyz (shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note)
-{
-       shared_ptr<dcp::OpenJPEGImage> xyz;
-
-       auto image = frame->image (bind(&PlayerVideo::keep_xyz_or_rgb, _1), VideoRange::FULL, false);
-       if (frame->colour_conversion()) {
-               xyz = dcp::rgb_to_xyz (
-                       image->data()[0],
-                       image->size(),
-                       image->stride()[0],
-                       frame->colour_conversion().get(),
-                       note
-                       );
-       } else {
-               xyz = make_shared<dcp::OpenJPEGImage>(image->data()[0], image->size(), image->stride()[0]);
-       }
-
-       return xyz;
-}
 
 /** J2K-encode this frame on the local host.
  *  @return Encoded data.
index 3bd516ccd4ea676567e80ac70880d39b382568c6..14440deb928e7bf57f1d56b516a0a571e45d754a 100644 (file)
@@ -59,8 +59,6 @@ public:
 
        bool same (std::shared_ptr<const DCPVideo> other) const;
 
-       static std::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz (std::shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note);
-
 private:
 
        void add_metadata (xmlpp::Element *) const;
index 8e3284682485833dc7395c65b75e1c1edeb3be14..7c3e9528ff6a685f0b232bf77ff71956d9d535c2 100644 (file)
@@ -198,7 +198,7 @@ VideoWaveformPlot::set_image (shared_ptr<PlayerVideo> image)
        /* We must copy the PlayerVideo here as we will call ::image() on it, potentially
           with a different pixel_format than was used when ::prepare() was called.
        */
-       _image = DCPVideo::convert_to_xyz (image->shallow_copy(), [](dcp::NoteType, string) {});
+       _image = convert_to_xyz (image->shallow_copy(), [](dcp::NoteType, string) {});
        _dirty = true;
        Refresh ();
 }