]> git.sesse.net Git - movit/blob - gamma_expansion_effect.h
Clip below-zero (out-of-gamut) colors in LiftGammaGainEffect.
[movit] / gamma_expansion_effect.h
1 #ifndef _MOVIT_GAMMA_EXPANSION_EFFECT_H 
2 #define _MOVIT_GAMMA_EXPANSION_EFFECT_H 1
3
4 // An effect to convert the given gamma curve into linear light,
5 // typically inserted by the framework automatically at the beginning
6 // of the processing chain.
7 //
8 // Currently supports sRGB and Rec. 601/709.
9
10 #include <string>
11
12 #include "effect.h"
13 #include "image_format.h"
14
15 #define EXPANSION_CURVE_SIZE 256
16
17 class GammaExpansionEffect : public Effect {
18 private:
19         // Should not be instantiated by end users.
20         GammaExpansionEffect();
21         friend class EffectChain;
22
23 public:
24         virtual std::string effect_type_id() const { return "GammaExpansionEffect"; }
25         std::string output_fragment_shader();
26
27         virtual bool needs_linear_light() const { return false; }
28         virtual bool needs_srgb_primaries() const { return false; }
29
30         // Actually processes its input in a nonlinear fashion,
31         // but does not touch alpha, and we are a special case anyway.
32         virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
33
34 private:
35         GammaCurve source_curve;
36         float expansion_curve[EXPANSION_CURVE_SIZE];
37 };
38
39 #endif // !defined(_MOVIT_GAMMA_EXPANSION_EFFECT_H)