]> git.sesse.net Git - nageru/commitdiff
Stop crushing blacks for full-range sources.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 30 Oct 2018 08:01:41 +0000 (09:01 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 30 Oct 2018 08:01:41 +0000 (09:01 +0100)
ycbcr_converter.cpp

index 143c4716f5076e0ccfabe5728e464e6a864a1c80..694ba97eb06531fc4b6d882df93f9aa06d4b4c0f 100644 (file)
@@ -39,7 +39,6 @@ YCbCrConverter::YCbCrConverter(YCbCrConverter::OutputMode output_mode, ResourceP
        inout_format.gamma_curve = GAMMA_sRGB;
 
        ycbcr_format.luma_coefficients = YCBCR_REC_709;
-       ycbcr_format.full_range = false;
        ycbcr_format.num_levels = 256;
        ycbcr_format.chroma_subsampling_x = 2;
        ycbcr_format.chroma_subsampling_y = 1;
@@ -48,6 +47,18 @@ YCbCrConverter::YCbCrConverter(YCbCrConverter::OutputMode output_mode, ResourceP
        ycbcr_format.cr_x_position = 0.0f;
        ycbcr_format.cr_y_position = 0.5f;
 
+       // This is a hack. Even though we're sending MJPEG around, which is
+       // full-range, it's mostly transporting signals from limited-range
+       // sources with no conversion, so we ought to have had false here.
+       // However, in the off chance that we're actually getting real MJPEG,
+       // we don't want to crush its blacks (or whites) by clamping. All of
+       // our processing is fades, so if we're in limited-range input, we'll
+       // stay in limited-range output. (Fading between limited-range and
+       // full-range sources will be broken, of course.) There will be some
+       // slight confusion in the parts of the algorithms dealing with RGB,
+       // but they're small and we'll manage.
+       ycbcr_format.full_range = true;
+
        YCbCrFormat ycbcr_output_format = ycbcr_format;
        ycbcr_output_format.chroma_subsampling_x = 1;