Commit d12a0871 authored by fbarchard@google.com's avatar fbarchard@google.com

adjust ubias to minimize error histogram centering error.

BUG=324
TESTED=TestFullYUV
R=harryjin@google.com

Review URL: https://webrtc-codereview.appspot.com/37739004

git-svn-id: http://libyuv.googlecode.com/svn/trunk@1248 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent eb8dda3a
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1247 Version: 1248
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1247 #define LIBYUV_VERSION 1248
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
...@@ -960,40 +960,39 @@ void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) { ...@@ -960,40 +960,39 @@ void I400ToARGBRow_C(const uint8* src_y, uint8* dst_argb, int width) {
} }
} }
// C reference code that mimics the YUV assembly. // YUV to RGB conversion constants.
#define YG 19071 /* round(1.164 * 64 * 256) */ #define YG 19071 /* round(1.164 * 64 * 256) */
#define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */ #define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */
// TODO(fbarchard): Adjusted U and V bias for even error distribution.
#define UB -128 /* -min(128, round(2.018 * 64)) */ #define UB -128 /* -min(128, round(2.018 * 64)) */
#define UBB -16385 /* approx -round(2.018 * 64 * 128) */
#define UG 25 /* -round(-0.391 * 64) */ #define UG 25 /* -round(-0.391 * 64) */
#define UR 0 #define UGB 3200 /* -round(-0.391 * 64) * 128 */
#define VB 0
#define VG 52 /* -round(-0.813 * 64) */ #define VG 52 /* -round(-0.813 * 64) */
#define VGB 6656 /* -round(-0.813 * 64) * 128 */
#define VR -102 /* -round(1.596 * 64) */ #define VR -102 /* -round(1.596 * 64) */
#define VRB -13056 /* -round(1.596 * 64) * 128 */
#define BB (UBB - YGB)
#define BG (UGB + VGB - YGB)
#define BR ( VRB - YGB)
// Bias // C reference code that mimics the YUV assembly.
#define BB (UB * 128 + VB * 128 - YGB)
#define BG (UG * 128 + VG * 128 - YGB)
#define BR (UR * 128 + VR * 128 - YGB)
static __inline void YuvPixel(uint8 y, uint8 u, uint8 v, static __inline void YuvPixel(uint8 y, uint8 u, uint8 v,
uint8* b, uint8* g, uint8* r) { uint8* b, uint8* g, uint8* r) {
uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16; uint32 y1 = (uint32)(y * 0x0101 * YG) >> 16;
*b = Clamp((int32)(BB - (v * VB + u * UB) + y1) >> 6); *b = Clamp((int32)(BB - ( u * UB) + y1) >> 6);
*g = Clamp((int32)(BG - (v * VG + u * UG) + y1) >> 6); *g = Clamp((int32)(BG - (v * VG + u * UG) + y1) >> 6);
*r = Clamp((int32)(BR - (v * VR + u * UR) + y1) >> 6); *r = Clamp((int32)(BR - (v * VR ) + y1) >> 6);
} }
#undef YG #undef YG
#undef YGB #undef YGB
#undef UB #undef UB
#undef UBB
#undef UG #undef UG
#undef UR #undef UGB
#undef VB
#undef VG #undef VG
#undef VGB
#undef VR #undef VR
#undef VRB
#undef BB #undef BB
#undef BG #undef BG
#undef BR #undef BR
......
...@@ -24,30 +24,27 @@ extern "C" { ...@@ -24,30 +24,27 @@ extern "C" {
#if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && \ #if !defined(LIBYUV_DISABLE_X86) && defined(_MSC_VER) && \
(defined(_M_IX86) || defined(_M_X64)) (defined(_M_IX86) || defined(_M_X64))
// YUV conversion constants. // YUV to RGB conversion constants.
#define YG 19071 /* round(1.164 * 64 * 256) */ #define YG 19071 /* round(1.164 * 64 * 256) */
#define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */ #define YGB 1197 /* 1.164 * 64 * 16 - adjusted for even error distribution */
// TODO(fbarchard): Adjusted U and V bias for even error distribution.
#define UB -128 /* -min(128, round(2.018 * 64)) */ #define UB -128 /* -min(128, round(2.018 * 64)) */
#define UBB -16385 /* approx -round(2.018 * 64 * 128) */
#define UG 25 /* -round(-0.391 * 64) */ #define UG 25 /* -round(-0.391 * 64) */
#define UR 0 #define UGB 3200 /* -round(-0.391 * 64) * 128 */
#define VB 0
#define VG 52 /* -round(-0.813 * 64) */ #define VG 52 /* -round(-0.813 * 64) */
#define VGB 6656 /* -round(-0.813 * 64) * 128 */
#define VR -102 /* -round(1.596 * 64) */ #define VR -102 /* -round(1.596 * 64) */
#define VRB -13056 /* -round(1.596 * 64) * 128 */
// Bias #define BB (UBB - YGB)
#define BB (UB * 128 + VB * 128 - YGB) #define BG (UGB + VGB - YGB)
#define BG (UG * 128 + VG * 128 - YGB) #define BR ( VRB - YGB)
#define BR (UR * 128 + VR * 128 - YGB)
static const vec8 kUVToB = { static const vec8 kUVToB = {
UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0
}; };
static const vec8 kUVToR = { static const vec8 kUVToR = {
UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR
}; };
static const vec8 kUVToG = { static const vec8 kUVToG = {
...@@ -55,11 +52,11 @@ static const vec8 kUVToG = { ...@@ -55,11 +52,11 @@ static const vec8 kUVToG = {
}; };
static const vec8 kVUToB = { static const vec8 kVUToB = {
VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB,
}; };
static const vec8 kVUToR = { static const vec8 kVUToR = {
VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0,
}; };
static const vec8 kVUToG = { static const vec8 kVUToG = {
...@@ -1475,12 +1472,12 @@ void RGBAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb, ...@@ -1475,12 +1472,12 @@ void RGBAToUVRow_SSSE3(const uint8* src_argb0, int src_stride_argb,
#if defined(HAS_I422TOARGBROW_AVX2) || defined(HAS_I422TOBGRAROW_AVX2) #if defined(HAS_I422TOARGBROW_AVX2) || defined(HAS_I422TOBGRAROW_AVX2)
static const lvec8 kUVToB_AVX = { static const lvec8 kUVToB_AVX = {
UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0,
UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB, UB, VB UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0, UB, 0
}; };
static const lvec8 kUVToR_AVX = { static const lvec8 kUVToR_AVX = {
UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR,
UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR, UR, VR 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR, 0, VR
}; };
static const lvec8 kUVToG_AVX = { static const lvec8 kUVToG_AVX = {
UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG, UG, VG,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment