]> git.sesse.net Git - movit/blobdiff - colorspace_conversion_effect.h
Calculate the RGB-to-XYZ matrix ourselves instead of using a “magic” one from Wikipedia.
[movit] / colorspace_conversion_effect.h
index e3c60ea81730af2a2eaaffe0370e23b3a71cf35c..b21f72e1a8b6b8782e332aedfaca2455d3f9644b 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef _COLORSPACE_CONVERSION_EFFECT_H
-#define _COLORSPACE_CONVERSION_EFFECT_H 1
+#ifndef _MOVIT_COLORSPACE_CONVERSION_EFFECT_H
+#define _MOVIT_COLORSPACE_CONVERSION_EFFECT_H 1
 
 // An effect to convert between different color spaces.
 // Can convert freely between sRGB/Rec. 709 and the two different Rec. 601
@@ -8,18 +8,30 @@
 // We don't do any fancy gamut mapping or similar; colors that are out-of-gamut
 // will simply stay out-of-gamut, and probably clip in the output stage.
 
+#include <string>
+#include <Eigen/Core>
+
 #include "effect.h"
-#include "effect_chain.h"
+#include "image_format.h"
+
+class ColorspaceConversionEffect : public Effect {
+private:
+       // Should not be instantiated by end users.
+       ColorspaceConversionEffect();
+       friend class EffectChain;
 
-class ColorSpaceConversionEffect : public Effect {
 public:
-       ColorSpaceConversionEffect();
+       virtual std::string effect_type_id() const { return "ColorspaceConversionEffect"; }
        std::string output_fragment_shader();
 
        virtual bool needs_srgb_primaries() const { return false; }
+       virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
+
+       // Get a conversion matrix from the given color space to XYZ.
+       static Eigen::Matrix3d get_xyz_matrix(Colorspace space);
 
 private:
-       ColorSpace source_space, destination_space;
+       Colorspace source_space, destination_space;
 };
 
-#endif // !defined(_COLORSPACE_CONVERSION_EFFECT_H)
+#endif // !defined(_MOVIT_COLORSPACE_CONVERSION_EFFECT_H)