X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gamma_compression_effect.h;h=9094f1964acfd9e10e7fb9844b07965b5564c1be;hp=70163419388281da8b6cb54d3bd2c117dd250cd6;hb=9527105a4958fa20f8d87d719a26b00cb000c0e8;hpb=2ced784c6599cb0b21427481ee17f4c8f6afdada diff --git a/gamma_compression_effect.h b/gamma_compression_effect.h index 7016341..9094f19 100644 --- a/gamma_compression_effect.h +++ b/gamma_compression_effect.h @@ -1,21 +1,45 @@ -#ifndef _GAMMA_COMPRESSION_EFFECT_H -#define _GAMMA_COMPRESSION_EFFECT_H 1 +#ifndef _MOVIT_GAMMA_COMPRESSION_EFFECT_H +#define _MOVIT_GAMMA_COMPRESSION_EFFECT_H 1 + +// An effect to convert linear light to the given gamma curve, +// typically inserted by the framework automatically at the end +// of the processing chain. +// +// Currently supports sRGB, Rec. 601/709 and Rec. 2020 (10- and 12-bit). +// Note that Movit's internal formats generally do not have enough accuracy +// for 12-bit input or output. + +#include +#include #include "effect.h" -#include "effect_chain.h" +#include "image_format.h" -#define COMPRESSION_CURVE_SIZE 4096 +namespace movit { class GammaCompressionEffect : public Effect { -public: +private: + // Should not be instantiated by end users. GammaCompressionEffect(); - std::string output_fragment_shader(); + friend class EffectChain; - virtual bool needs_srgb_primaries() { return false; } +public: + std::string effect_type_id() const override { return "GammaCompressionEffect"; } + std::string output_fragment_shader() override; + void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override; + + bool needs_srgb_primaries() const override { return false; } + bool strong_one_to_one_sampling() const override { return true; } + + // Actually needs postmultiplied input as well as outputting it. + // EffectChain will take care of that. + AlphaHandling alpha_handling() const override { return OUTPUT_POSTMULTIPLIED_ALPHA; } private: GammaCurve destination_curve; - float compression_curve[COMPRESSION_CURVE_SIZE]; + float uniform_linear_scale, uniform_c[5], uniform_beta; }; -#endif // !defined(_GAMMA_COMPRESSION_EFFECT_H) +} // namespace movit + +#endif // !defined(_MOVIT_GAMMA_COMPRESSION_EFFECT_H)