- frag_shader = output_glsl_mat3("PREFIX(inv_ycbcr_matrix)", ycbcr_to_rgb);
- frag_shader += output_glsl_vec3("PREFIX(offset)", offset[0], offset[1], offset[2]);
-
- float cb_offset_x = compute_chroma_offset(
- ycbcr_format.cb_x_position, ycbcr_format.chroma_subsampling_x, widths[1]);
- float cb_offset_y = compute_chroma_offset(
- ycbcr_format.cb_y_position, ycbcr_format.chroma_subsampling_y, heights[1]);
- frag_shader += output_glsl_vec2("PREFIX(cb_offset)", cb_offset_x, cb_offset_y);
-
- float cr_offset_x = compute_chroma_offset(
- ycbcr_format.cr_x_position, ycbcr_format.chroma_subsampling_x, widths[2]);
- float cr_offset_y = compute_chroma_offset(
- ycbcr_format.cr_y_position, ycbcr_format.chroma_subsampling_y, heights[2]);
- frag_shader += output_glsl_vec2("PREFIX(cr_offset)", cr_offset_x, cr_offset_y);
+ if (ycbcr_input_splitting == YCBCR_INPUT_INTERLEAVED) {
+ frag_shader += "#define Y_CB_CR_SAME_TEXTURE 1\n";
+ } else if (ycbcr_input_splitting == YCBCR_INPUT_SPLIT_Y_AND_CBCR) {
+ cb_cr_offsets_equal =
+ (fabs(ycbcr_format.cb_x_position - ycbcr_format.cr_x_position) < 1e-6) &&
+ (fabs(ycbcr_format.cb_y_position - ycbcr_format.cr_y_position) < 1e-6);
+ char buf[256];
+ snprintf(buf, sizeof(buf), "#define Y_CB_CR_SAME_TEXTURE 0\n#define CB_CR_SAME_TEXTURE 1\n#define CB_CR_OFFSETS_EQUAL %d\n",
+ cb_cr_offsets_equal);
+ frag_shader += buf;
+ } else {
+ frag_shader += "#define Y_CB_CR_SAME_TEXTURE 0\n#define CB_CR_SAME_TEXTURE 0\n";
+ }