[Opalvoip-svn] SF.net SVN: opalvoip:[34715] ptlib/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-03-22 13:47:59
|
Revision: 34715 http://sourceforge.net/p/opalvoip/code/34715 Author: rjongbloed Date: 2016-03-22 13:47:56 +0000 (Tue, 22 Mar 2016) Log Message: ----------- Added PColourConverter::YUVtoRGB() Modified Paths: -------------- ptlib/trunk/include/ptlib/vconvert.h ptlib/trunk/src/ptlib/common/vconvert.cxx Modified: ptlib/trunk/include/ptlib/vconvert.h =================================================================== --- ptlib/trunk/include/ptlib/vconvert.h 2016-03-21 19:18:02 UTC (rev 34714) +++ ptlib/trunk/include/ptlib/vconvert.h 2016-03-22 13:47:56 UTC (rev 34715) @@ -285,6 +285,13 @@ BYTE & y, BYTE & u, BYTE & v ); + /**Convert YUV to RGB. + */ + static void YUVtoRGB( + unsigned y, unsigned u, unsigned v, + BYTE & r, BYTE & g, BYTE & b + ); + /**Copy a section of the source frame to a section of the destination frame with scaling/cropping as required. */ Modified: ptlib/trunk/src/ptlib/common/vconvert.cxx =================================================================== --- ptlib/trunk/src/ptlib/common/vconvert.cxx 2016-03-21 19:18:02 UTC (rev 34714) +++ ptlib/trunk/src/ptlib/common/vconvert.cxx 2016-03-22 13:47:56 UTC (rev 34715) @@ -1868,6 +1868,25 @@ * B = Y + 1.772 (Cb-128) * */ + +void PColourConverter::YUVtoRGB(unsigned y, unsigned u, unsigned v, + BYTE & r, BYTE & g, BYTE & b) +{ + FixedPoint cb = u - 128; + FixedPoint cr = v - 128; + FixedPoint rd = ROUND(YUVtoR_Coeff * cr); + FixedPoint gd = ROUND(YUVtoG_Coeff1 * cb - YUVtoG_Coeff2 * cr); + FixedPoint bd = ROUND(YUVtoB_Coeff * cb); + FixedPoint yvalue = y << ScaleBitShift; + FixedPoint rvalue = yvalue + rd; + FixedPoint gvalue = yvalue + gd; + FixedPoint bvalue = yvalue + bd; + r = CLAMP(rvalue); + g = CLAMP(gvalue); + b = CLAMP(bvalue); +} + + bool PStandardColourConverter::YUV420PtoRGB(const BYTE * srcFrameBuffer, BYTE * dstFrameBuffer, PINDEX * bytesReturned, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |