X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ycbcr_conversion_effect.frag;h=a0b896fe0bcd665da469d837a486d40c6865c743;hb=HEAD;hp=ea5de45f14d99a984e22ec564c2f6a855cf86d1c;hpb=6bec5fc3abc5f57c6cddec2148626cca9a94bedf;p=movit diff --git a/ycbcr_conversion_effect.frag b/ycbcr_conversion_effect.frag index ea5de45..a0b896f 100644 --- a/ycbcr_conversion_effect.frag +++ b/ycbcr_conversion_effect.frag @@ -1,6 +1,7 @@ -uniform sampler2D PREFIX(tex_y); -uniform sampler2D PREFIX(tex_cb); -uniform sampler2D PREFIX(tex_cr); +// See footer.frag for details about this if statement. +#ifndef YCBCR_ALSO_OUTPUT_RGBA +#define YCBCR_ALSO_OUTPUT_RGBA 0 +#endif #if YCBCR_ALSO_OUTPUT_RGBA vec4[2] FUNCNAME(vec2 tc) { @@ -12,16 +13,16 @@ vec4 FUNCNAME(vec2 tc) { ycbcr_a.rgb = PREFIX(ycbcr_matrix) * rgba.rgb + PREFIX(offset); -#if YCBCR_CLAMP_RANGE - // If we use limited-range Y'CbCr, the card's usual 0–255 clamping - // won't be enough, so we need to clamp ourselves here. - // - // We clamp before dither, which is a bit unfortunate, since - // it means dither can take us out of the clamped range again. - // However, since DitherEffect never adds enough dither to change - // the quantized levels, we will be fine in practice. - ycbcr_a.rgb = clamp(ycbcr_a.rgb, PREFIX(ycbcr_min), PREFIX(ycbcr_max)); -#endif + if (PREFIX(clamp_range)) { + // If we use limited-range Y'CbCr, the card's usual 0–255 clamping + // won't be enough, so we need to clamp ourselves here. + // + // We clamp before dither, which is a bit unfortunate, since + // it means dither can take us out of the clamped range again. + // However, since DitherEffect never adds enough dither to change + // the quantized levels, we will be fine in practice. + ycbcr_a.rgb = clamp(ycbcr_a.rgb, PREFIX(ycbcr_min), PREFIX(ycbcr_max)); + } ycbcr_a.a = rgba.a;