]> git.sesse.net Git - movit/blob - gamma_compression_effect.h
Comment and README updates about Rec. 2020 in light of the accuracy test results.
[movit] / gamma_compression_effect.h
1 #ifndef _MOVIT_GAMMA_COMPRESSION_EFFECT_H 
2 #define _MOVIT_GAMMA_COMPRESSION_EFFECT_H 1
3
4 // An effect to convert linear light to the given gamma curve,
5 // typically inserted by the framework automatically at the end
6 // of the processing chain.
7 //
8 // Currently supports sRGB, Rec. 601/709 and Rec. 2020 (10- and 12-bit).
9 // Note that Movit's internal formats generally do not have enough accuracy
10 // for 12-bit input or output.
11
12 #include <string>
13
14 #include "effect.h"
15 #include "image_format.h"
16
17 #define COMPRESSION_CURVE_SIZE 4096
18
19 class GammaCompressionEffect : public Effect {
20 private:
21         // Should not be instantiated by end users.
22         GammaCompressionEffect();
23         friend class EffectChain;
24
25 public:
26         virtual std::string effect_type_id() const { return "GammaCompressionEffect"; }
27         std::string output_fragment_shader();
28
29         virtual bool needs_srgb_primaries() const { return false; }
30
31         // Actually needs postmultiplied input as well as outputting it.
32         // EffectChain will take care of that.
33         virtual AlphaHandling alpha_handling() const { return OUTPUT_POSTMULTIPLIED_ALPHA; }
34
35 private:
36         GammaCurve destination_curve;
37         float compression_curve[COMPRESSION_CURVE_SIZE];
38 };
39
40 #endif // !defined(_MOVIT_GAMMA_COMPRESSION_EFFECT_H)