]> git.sesse.net Git - movit/blob - colorspace_conversion_effect.h
Add some earlier check_error() calls so that we do not get confusing behavior if...
[movit] / colorspace_conversion_effect.h
1 #ifndef _MOVIT_COLORSPACE_CONVERSION_EFFECT_H
2 #define _MOVIT_COLORSPACE_CONVERSION_EFFECT_H 1
3
4 // An effect to convert between different color spaces.
5 // Can convert freely between sRGB/Rec. 709 and the two different Rec. 601
6 // color spaces (which thankfully have the same white point).
7 //
8 // We don't do any fancy gamut mapping or similar; colors that are out-of-gamut
9 // will simply stay out-of-gamut, and probably clip in the output stage.
10
11 #include <Eigen/Core>
12 #include <string>
13
14 #include "effect.h"
15 #include "image_format.h"
16
17 namespace movit {
18
19 class ColorspaceConversionEffect : public Effect {
20 private:
21         // Should not be instantiated by end users.
22         ColorspaceConversionEffect();
23         friend class EffectChain;
24
25 public:
26         virtual std::string effect_type_id() const { return "ColorspaceConversionEffect"; }
27         std::string output_fragment_shader();
28
29         virtual bool needs_srgb_primaries() const { return false; }
30         virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
31         virtual bool one_to_one_sampling() const { return true; }
32
33         // Get a conversion matrix from the given color space to XYZ.
34         static Eigen::Matrix3d get_xyz_matrix(Colorspace space);
35
36 private:
37         Colorspace source_space, destination_space;
38 };
39
40 }  // namespace movit
41
42 #endif // !defined(_MOVIT_COLORSPACE_CONVERSION_EFFECT_H)