diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index e3f67f8..720a83e 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -343,6 +343,16 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::C return PixelValue; } +Void PlaYUVerFrame::setPixelValue( Int xPos, Int yPos, PlaYUVerPixel pixel ) +{ + for( UInt ch = 0; ch < m_pcPelFormat->numberChannels; ch++ ) + { + Int ratioH = ch > 0 ? m_pcPelFormat->log2ChromaWidth : 0; + Int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0; + m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )] = pixel.Components()[ch]; + } +} + Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame ) { if( m_iPixelFormat != input_frame->getPelFormat() && m_uiWidth == input_frame->getWidth() && m_uiHeight == input_frame->getHeight() ) diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 83d6676..54fb28f 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -206,6 +206,8 @@ public: PlaYUVerPixel getPixelValue( Int xPos, Int yPos ); PlaYUVerPixel getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace ); + Void setPixelValue( Int xPos, Int yPos, PlaYUVerPixel pixel ); + Void copyFrom( PlaYUVerFrame* ); Void copyFrom( PlaYUVerFrame*, UInt, UInt ); diff --git a/lib/PlaYUVerPixel.cpp b/lib/PlaYUVerPixel.cpp index 3c32070..2dc3bee 100644 --- a/lib/PlaYUVerPixel.cpp +++ b/lib/PlaYUVerPixel.cpp @@ -31,6 +31,42 @@ namespace plaYUVer { +PlaYUVerPixel::PlaYUVerPixel() +{ + m_iColorSpace = COLOR_INVALID; + PixelComponents[0] = 0; + PixelComponents[1] = 0; + PixelComponents[2] = 0; + PixelComponents[3] = 0; +} + +PlaYUVerPixel::PlaYUVerPixel( Int ColorSpace, Pel c0, Pel c1, Pel c2 ) +{ + m_iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace; + PixelComponents[0] = c0; + PixelComponents[1] = c1; + PixelComponents[2] = c2; + PixelComponents[3] = 0; +} + +PlaYUVerPixel PlaYUVerPixel::operator+ ( const PlaYUVerPixel& in ) +{ + PlaYUVerPixel out( m_iColorSpace, Y() + in.Y(), Cb() + in.Cb(), Cr() + in.Cr() ); + return out; +} + +PlaYUVerPixel PlaYUVerPixel::operator- ( const PlaYUVerPixel& in ) +{ + PlaYUVerPixel out( m_iColorSpace, Y() - in.Y(), Cb() - in.Cb(), Cr() - in.Cr() ); + return out; +} + +PlaYUVerPixel PlaYUVerPixel::operator* ( const Double& d ) +{ + PlaYUVerPixel out( m_iColorSpace, Y() * d, Cb() * d, Cr() * d ); + return out; +} + PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace ) { Int outA, outB, outC; @@ -55,5 +91,5 @@ PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace ) } return outPixel; } - + } // NAMESPACE diff --git a/lib/PlaYUVerPixel.h b/lib/PlaYUVerPixel.h index db4222c..343add9 100644 --- a/lib/PlaYUVerPixel.h +++ b/lib/PlaYUVerPixel.h @@ -73,22 +73,9 @@ public: COLOR_ARGB = 3, //!< RGB + Alpha }; - PlaYUVerPixel() - { - m_iColorSpace = COLOR_INVALID; - PixelComponents[0] = 0; - PixelComponents[1] = 0; - PixelComponents[2] = 0; - PixelComponents[3] = 0; - } - PlaYUVerPixel( Int ColorSpace, Pel c0, Pel c1, Pel c2 ) - { - m_iColorSpace = ColorSpace == COLOR_GRAY ? COLOR_YUV : ColorSpace; - PixelComponents[0] = c0; - PixelComponents[1] = c1; - PixelComponents[2] = c2; - PixelComponents[3] = 0; - } + PlaYUVerPixel(); + PlaYUVerPixel( Int ColorSpace, Pel c0, Pel c1, Pel c2 ); + Int ColorSpaceType() { return m_iColorSpace; @@ -97,6 +84,18 @@ public: { return PixelComponents; } + Pel Y() const + { + return PixelComponents[0]; + } + Pel Cb() const + { + return PixelComponents[1]; + } + Pel Cr() const + { + return PixelComponents[2]; + } Pel& Y() { return PixelComponents[0]; @@ -126,6 +125,10 @@ public: return PixelComponents[3]; } + PlaYUVerPixel operator+ ( const PlaYUVerPixel& ); + PlaYUVerPixel operator- ( const PlaYUVerPixel& ); + PlaYUVerPixel operator* ( const Double& ); + /** * Convert a Pixel to a new color space * @param inputPixel input pixel (PlaYUVerPixel)