From e8ef17c8b7187764952f8e45771f97bcaf6abca9 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 19 Feb 2017 20:35:19 +0100 Subject: [PATCH] Treat num_levels == 0 as 256, for the benefit of older applications. --- ycbcr.cpp | 6 +++++- ycbcr_conversion_effect.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ycbcr.cpp b/ycbcr.cpp index eaa2ee8..8ae8d34 100644 --- a/ycbcr.cpp +++ b/ycbcr.cpp @@ -89,7 +89,11 @@ void compute_ycbcr_matrix(YCbCrFormat ycbcr_format, float* offset, Matrix3d* ycb assert(false); } - const int num_levels = ycbcr_format.num_levels; + int num_levels = ycbcr_format.num_levels; + if (num_levels == 0) { + // For the benefit of clients using old APIs, but still zeroing out the structure. + num_levels = 256; + } if (ycbcr_format.full_range) { offset[0] = 0.0 / (num_levels - 1); offset[1] = double(num_levels / 2) / (num_levels - 1); // E.g. 128/255. diff --git a/ycbcr_conversion_effect.cpp b/ycbcr_conversion_effect.cpp index fd2cd07..9c04e3a 100644 --- a/ycbcr_conversion_effect.cpp +++ b/ycbcr_conversion_effect.cpp @@ -47,7 +47,7 @@ void YCbCrConversionEffect::set_gl_state(GLuint glsl_program_num, const string & } else { uniform_clamp_range = true; - if (ycbcr_format.num_levels == 256) { // 8-bit. + if (ycbcr_format.num_levels == 0 && ycbcr_format.num_levels == 256) { // 8-bit. // These limits come from BT.601 page 8, or BT.709, page 5. uniform_ycbcr_min[0] = 16.0 / 255.0; uniform_ycbcr_min[1] = 16.0 / 255.0; -- 2.39.2