Changes in the PlaYUVerFrame to CvMat conversion
This commit is contained in:
1 parent
aae1ef6ce7
commit
d6c17ecabb
3 files changed
+24
-13
No files matched your search
@@ -398,7 +398,7 @@ cv::Mat PlaYUVerFrame::getCvMat()
|
||||
case YUV444p:
|
||||
case YUV422p:
|
||||
case YUYV422:
|
||||
cvType = CV_8UC3;
|
||||
cvType = CV_8UC4;
|
||||
break;
|
||||
case GRAY:
|
||||
cvType = CV_8UC1;
|
||||
@@ -413,7 +413,7 @@ cv::Mat PlaYUVerFrame::getCvMat()
|
||||
if( m_iPixelFormat != GRAY )
|
||||
{
|
||||
fillRGBBuffer();
|
||||
memcpy( opencvFrame.data, m_pcRGB32, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
|
||||
memcpy( opencvFrame.data, m_pcRGB32, m_uiWidth * m_uiHeight * 4 * sizeof(UChar) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -431,7 +431,7 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
|
||||
case 1:
|
||||
m_iPixelFormat = GRAY;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
m_iPixelFormat = RGB8;
|
||||
break;
|
||||
default:
|
||||
@@ -452,12 +452,13 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
|
||||
Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0];
|
||||
Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0];
|
||||
Pel* pcRGBPelInterlaced = m_pcRGB32;
|
||||
memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
|
||||
memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 4 * sizeof(Pel) );
|
||||
UInt* buff = (UInt*)pcRGBPelInterlaced;
|
||||
for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
|
||||
{
|
||||
*pInputPelY++ = *pcRGBPelInterlaced++;
|
||||
*pInputPelU++ = *pcRGBPelInterlaced++;
|
||||
*pInputPelV++ = *pcRGBPelInterlaced++;
|
||||
*pInputPelY++ = qRed( *buff );
|
||||
*pInputPelU++ = qGreen( *buff );
|
||||
*pInputPelV++ = qBlue( *buff++ );
|
||||
}
|
||||
m_bHasRGBPel = true;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,22 @@ Void rgbToYuv( T iR, T iG, T iB, T &iY, T &iU, T &iV )
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
|
||||
}
|
||||
|
||||
inline Q_DECL_CONSTEXPR Int qRed(UInt rgb) // get red part of RGB
|
||||
{ return ((rgb >> 16) & 0xff); }
|
||||
|
||||
inline Q_DECL_CONSTEXPR Int qGreen(UInt rgb) // get green part of RGB
|
||||
{ return ((rgb >> 8) & 0xff); }
|
||||
|
||||
inline Q_DECL_CONSTEXPR Int qBlue(UInt rgb) // get blue part of RGB
|
||||
{ return (rgb & 0xff); }
|
||||
|
||||
inline Q_DECL_CONSTEXPR Int qAlpha(UInt rgb) // get alpha part of RGBA
|
||||
{ return rgb >> 24; }
|
||||
|
||||
inline Q_DECL_CONSTEXPR UInt qRgb(Int r, Int g, Int b) // set RGB value
|
||||
{ return (0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
|
||||
|
||||
|
||||
class PlaYUVerFrame
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -39,12 +39,6 @@ namespace plaYUVer
|
||||
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
|
||||
#endif
|
||||
|
||||
static inline UInt qRgb( Int r, Int g, Int b ) // set RGB value
|
||||
{
|
||||
return ( 0xffu << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YUV Formats
|
||||
* Progressive and interlaces
|
||||
|
||||
Reference in new issue
Block a user