8 #include "ycbcr_conversion_effect.h"
9 #include "effect_util.h"
14 using namespace Eigen;
18 YCbCrConversionEffect::YCbCrConversionEffect(const YCbCrFormat &ycbcr_format)
19 : ycbcr_format(ycbcr_format)
23 string YCbCrConversionEffect::output_fragment_shader()
26 Matrix3d ycbcr_to_rgb;
27 compute_ycbcr_matrix(ycbcr_format, offset, &ycbcr_to_rgb);
29 string frag_shader = output_glsl_mat3("PREFIX(ycbcr_matrix)", ycbcr_to_rgb.inverse());
30 frag_shader += output_glsl_vec3("PREFIX(offset)", offset[0], offset[1], offset[2]);
32 if (ycbcr_format.full_range) {
33 // The card will clamp for us later.
34 frag_shader += "#define YCBCR_CLAMP_RANGE 0\n";
36 frag_shader += "#define YCBCR_CLAMP_RANGE 1\n";
38 // These limits come from BT.601 page 8, or BT.701, page 5.
39 // TODO: Use num_levels. Currently we support 8-bit levels only.
40 frag_shader += output_glsl_vec3("PREFIX(ycbcr_min)", 16.0 / 255.0, 16.0 / 255.0, 16.0 / 255.0);
41 frag_shader += output_glsl_vec3("PREFIX(ycbcr_max)", 235.0 / 255.0, 240.0 / 255.0, 240.0 / 255.0);
44 return frag_shader + read_file("ycbcr_conversion_effect.frag");