1 #ifndef _MOVIT_YCBCR_CONVERSION_EFFECT_H
2 #define _MOVIT_YCBCR_CONVERSION_EFFECT_H 1
3 
4 // Converts from R'G'B' to Y'CbCr; that is, more or less the opposite of YCbCrInput,
5 // except that it keeps the data as 4:4:4 chunked Y'CbCr; you'll need to subsample
6 // and/or convert to planar somehow else.
7 
8 #include <epoxy/gl.h>
9 #include <Eigen/Core>
10 #include <string>
11 
12 #include "effect.h"
13 #include "ycbcr.h"
14 
15 namespace movit {
16 
17 class YCbCrConversionEffect : public Effect {
18 private:
19 	// Should not be instantiated by end users;
20 	// call EffectChain::add_ycbcr_output() instead.
21 	YCbCrConversionEffect(const YCbCrFormat &ycbcr_format, GLenum type);
22 	friend class EffectChain;
23 
24 public:
effect_type_id()25 	std::string effect_type_id() const override { return "YCbCrConversionEffect"; }
26 	std::string output_fragment_shader() override;
27 	void set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) override;
alpha_handling()28 	AlphaHandling alpha_handling() const override { return DONT_CARE_ALPHA_TYPE; }
strong_one_to_one_sampling()29 	bool strong_one_to_one_sampling() const override { return true; }
30 
31 	// Should not be called by end users; call
32 	// EffectChain::change_ycbcr_output_format() instead.
change_output_format(const YCbCrFormat & ycbcr_format)33 	void change_output_format(const YCbCrFormat &ycbcr_format) {
34 		this->ycbcr_format = ycbcr_format;
35 	}
36 
37 private:
38 	YCbCrFormat ycbcr_format;
39 	GLenum type;
40 
41 	Eigen::Matrix3d uniform_ycbcr_matrix;
42 	float uniform_offset[3];
43 	bool uniform_clamp_range;
44 	float uniform_ycbcr_min[3], uniform_ycbcr_max[3];
45 };
46 
47 }  // namespace movit
48 
49 #endif // !defined(_MOVIT_YCBCR_CONVERSION_EFFECT_H)
50