From a556cb1ab4d1fdc7a0439ed32a02099751038eff Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 18 Jan 2013 15:04:38 +0100 Subject: [PATCH] Add details and reference about the YUV->RGB conversion Originated from the discussion at http://code.google.com/p/webp/issues/detail?id=134 Change-Id: I24384e2d2f5cf262d8632fc98303cba5e2d27224 --- src/dsp/yuv.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/dsp/yuv.h b/src/dsp/yuv.h index ace4ce03..8dd269e2 100644 --- a/src/dsp/yuv.h +++ b/src/dsp/yuv.h @@ -14,6 +14,18 @@ // V = 0.4394 * R - 0.3679 * G - 0.0715 * B + 128 // We use 16bit fixed point operations for RGB->YUV conversion. // +// For the Y'CbCr to RGB conversion, the BT.601 specification reads: +// R = 1.164 * (Y-16) + 1.596 * (V-128) +// G = 1.164 * (Y-16) - 0.813 * (V-128) - 0.391 * (U-128) +// B = 1.164 * (Y-16) + 2.018 * (U-128) +// where Y is in the [16,235] range, and U/V in the [16,240] range. +// But the common term 1.164 * (Y-16) can be handled as an offset in the +// VP8kClip[] table. So the formulae should be read as: +// R = 1.164 * [Y + 1.371 * (V-128) ] - 18.624 +// G = 1.164 * [Y - 0.698 * (V-128) - 0.336 * (U-128)] - 18.624 +// B = 1.164 * [Y + 1.733 * (U-128)] - 18.624 +// once factorized. Here too, 16bit fixed precision is used. +// // Author: Skal (pascal.massimino@gmail.com) #ifndef WEBP_DSP_YUV_H_