From c11e9b7fb7c03f3480e43faa9a906aba48fec466 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 28 Sep 2016 15:07:46 -0700 Subject: [PATCH] bt709 coefficients for video constrained space Original bt709 color space coefficients were full range yuv for higher quality. This change makes the coefficients use the video constrained color space the same as bt601 which is 16 to 240 for Y and 16 to 235 for chroma channels. BUG=libyuv:639 TEST=libyuv unittests run locally R=hubbe@chromium.org Review URL: https://codereview.chromium.org/2367253003 . --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/row_common.cc | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.chromium b/README.chromium index 3fdee104b..bc3b69b5c 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1620 +Version: 1621 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index bbc3e0dfb..1f50abf40 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1620 +#define LIBYUV_VERSION 1621 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/row_common.cc b/source/row_common.cc index aefa38c49..099ab600d 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -1143,20 +1143,21 @@ const struct YuvConstants SIMD_ALIGNED(kYvuJPEGConstants) = { #undef YG // BT.709 YUV to RGB reference -// * R = Y - V * -1.28033 -// * G = Y - U * 0.21482 - V * 0.38059 -// * B = Y - U * -2.12798 +// R = (Y - 16) * 1.164 - V * -1.793 +// G = (Y - 16) * 1.164 - U * 0.213 - V * 0.533 +// B = (Y - 16) * 1.164 - U * -2.112 +// See also http://www.equasys.de/colorconversion.html // Y contribution to R,G,B. Scale and bias. -#define YG 16320 /* round(1.000 * 64 * 256 * 256 / 257) */ -#define YGB 32 /* 64 / 2 */ +#define YG 18997 /* round(1.164 * 64 * 256 * 256 / 257) */ +#define YGB -1160 /* 1.164 * 64 * -16 + 64 / 2 */ -// TODO(fbarchard): Find way to express 2.12 instead of 2.0. +// TODO(fbarchard): Find way to express 2.112 instead of 2.0. // U and V contributions to R,G,B. -#define UB -128 /* max(-128, round(-2.12798 * 64)) */ -#define UG 14 /* round(0.21482 * 64) */ -#define VG 24 /* round(0.38059 * 64) */ -#define VR -82 /* round(-1.28033 * 64) */ +#define UB -128 /* max(-128, round(-2.112 * 64)) */ +#define UG 14 /* round(0.213 * 64) */ +#define VG 34 /* round(0.533 * 64) */ +#define VR -115 /* round(-1.793 * 64) */ // Bias values to round, and subtract 128 from U and V. #define BB (UB * 128 + YGB)