Add operators to PlaYUVerPixel

This commit is contained in:
jfmcarreira committed 2016-03-10 00:41:23 +00:00
1 parent 201a2ebdd6
commit 9022612019
4 files changed
+68 -17

No files matched your search

+10
View File
@@ -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() )
+2
View File
@@ -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 );
+37 -1
View File
@@ -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
+19 -16
View File
@@ -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)