X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=ycbcr_conversion_effect.frag;h=ef289df8fa34dc35ddf74858d8a351227b96de12;hp=4ef38016a7240e88023e32b7b5e0a8764b372526;hb=240454ecb79e895dfebfab146174bd7458af4e42;hpb=5b08f06cd4547102186932ce789788e07ea8fd8c diff --git a/ycbcr_conversion_effect.frag b/ycbcr_conversion_effect.frag index 4ef3801..ef289df 100644 --- a/ycbcr_conversion_effect.frag +++ b/ycbcr_conversion_effect.frag @@ -17,16 +17,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;