Improve PlaYUVerFrame fmt matching and change bit per pixel to UInt

This commit is contained in:
jfmcarreira committed 2015-11-18 15:04:37 +00:00
1 parent 07310ab0f1
commit 1eed4bc8f9
2 files changed
+20 -17

No files matched your search

+12 -10
View File
@@ -197,7 +197,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel
m_uiHeight = height;
m_iPixelFormat = pel_format;
m_iNumberChannels = 3;
m_iBitsPel = bitsPixel > 8 ? bitsPixel : 8;
m_uiBitsPel = bitsPixel > 8 ? bitsPixel : 8;
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
{
@@ -220,7 +220,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel
m_puiHistogram = NULL;
m_bHasHistogram = false;
m_uiHistoSegments = 1 << m_iBitsPel;
m_uiHistoSegments = 1 << m_uiBitsPel;
if( m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_RGB || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_ARGB )
m_uiHistoChannels = m_pcPelFormat->numberChannels + 1;
@@ -255,12 +255,14 @@ Bool PlaYUVerFrame::haveSameFmt( PlaYUVerFrame* other, UInt match ) const
Bool bRet = true;
if( other )
{
if( match & MATCH_COLOR_SPACE )
bRet &= ( getColorSpace() == other->getColorSpace() );
if( match & MATCH_RESOLUTION )
bRet &= ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() );
bRet &= ( getWidth() == other->getWidth() ) && ( getHeight() == other->getHeight() );
if( match & MATCH_PEL_FMT )
bRet &= ( m_iPixelFormat == other->getPelFormat() );
bRet &= ( getPelFormat() == other->getPelFormat() );
if( match & MATCH_BITS )
bRet &= ( m_iBitsPel == other->getBitsPel() );
bRet &= ( getBitsPel() == other->getBitsPel() );
}
else
{
@@ -286,10 +288,10 @@ UInt PlaYUVerFrame::getNumberChannels() const
UInt64 PlaYUVerFrame::getBytesPerFrame()
{
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_iBitsPel );
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPel );
}
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel )
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel )
{
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] );
UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
@@ -392,7 +394,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize )
Byte* ppBuff[MAX_NUMBER_PLANES];
Byte* pTmpBuff;
Pel* pTmpPel;
UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1;
UInt bytesPixel = ( m_uiBitsPel - 1 ) / 8 + 1;
Int ratioH, ratioW, step;
UInt i, ch, b;
@@ -431,7 +433,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize )
Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer )
{
UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1;
UInt bytesPixel = ( m_uiBitsPel - 1 ) / 8 + 1;
Byte* ppBuff[MAX_NUMBER_PLANES];
Byte* pTmpBuff;
Pel* pTmpPel;
@@ -474,7 +476,7 @@ Void PlaYUVerFrame::fillRGBBuffer()
if( m_bHasRGBPel )
return;
Int iR, iG, iB;
Int shiftBits = m_iBitsPel - 8;
Int shiftBits = m_uiBitsPel - 8;
UInt* pARGB = ( UInt* )m_pcARGB32;
if( m_pcPelFormat->colorSpace == COLOR_GRAY )
{
+8 -7
View File
@@ -148,9 +148,10 @@ public:
*/
enum FormatMatching
{
MATCH_RESOLUTION = 1,
MATCH_PEL_FMT = 2,
MATCH_BITS = 4,
MATCH_COLOR_SPACE = 1,
MATCH_RESOLUTION = 2,
MATCH_PEL_FMT = 4,
MATCH_BITS = 8,
MATCH_ALL = 0xFFFF,
};
@@ -174,7 +175,7 @@ public:
* pixel format
* @return number of bytes per frame
*/
static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel );
static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, UInt bitsPixel );
/**
* Convert a Pixel to a new color space
@@ -232,9 +233,9 @@ public:
{
return m_iPixelFormat;
}
Int getBitsPel() const
UInt getBitsPel() const
{
return m_iBitsPel;
return m_uiBitsPel;
}
Pel*** getPelBufferYUV() const
@@ -372,7 +373,7 @@ private:
UInt m_uiHeight; //!< Height of the frame
Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
Int m_iNumberChannels; //!< Number of channels
Int m_iBitsPel; //!< Bits per pixel/channel
UInt m_uiBitsPel; //!< Bits per pixel/channel
Pel*** m_pppcInputPel;