Add fill buffer RGB and frame to buff functions. Also fixed problem with odd resolutions

This commit is contained in:
2014-11-07 02:02:17 +00:00
parent 1b2ed92f3c
commit 84729b9cd7
4 changed files with 170 additions and 271 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ void ViewArea::setImage( PlaYUVerFrame* pcFrame )
{
m_pcCurrFrame = pcFrame;
m_pcCurrFrame->FrametoRGB8();
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 );
QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB32 );
setImage( QPixmap::fromImage( qimg ) );
}
+31 -220
View File
@@ -80,7 +80,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, QRect area )
{
adjustSelectedAreaDims( area , other->getPelFormat() );
adjustSelectedAreaDims( area, other->getPelFormat() );
init( area.width(), area.height(), other->getPelFormat() );
copyFrom( other, area.x(), area.y() );
}
@@ -90,8 +90,8 @@ PlaYUVerFrame::~PlaYUVerFrame()
if( m_pppcInputPel )
freeMem3ImageComponents<Pel>( m_pppcInputPel );
if( m_pcRGBPelInterlaced )
freeMem1D<UChar>( m_pcRGBPelInterlaced );
if( m_pcRGB32 )
freeMem1D( m_pcRGB32 );
closePixfc();
}
@@ -106,33 +106,33 @@ Void PlaYUVerFrame::adjustSelectedAreaDims( QRect &area, Int pel_format )
switch( pel_format )
{
case YUV420p:
if( posX%2 )
area.setX(posX-1);
if( posY%2 )
area.setY(posY-1);
if( posX % 2 )
area.setX( posX - 1 );
if( posY % 2 )
area.setY( posY - 1 );
if( (posX+width)%2 )
area.setWidth((posX+width)-area.x()+1);
if( ( posX + width ) % 2 )
area.setWidth( ( posX + width ) - area.x() + 1 );
else
area.setWidth((posX+width)-area.x());
area.setWidth( ( posX + width ) - area.x() );
if( (posY+height)%2 )
area.setHeight((posY+height)-area.y()+1);
if( ( posY + height ) % 2 )
area.setHeight( ( posY + height ) - area.y() + 1 );
else
area.setHeight((posY+height)-area.y());
area.setHeight( ( posY + height ) - area.y() );
break;
case YUV444p:
break;
case YUV422p:
case YUYV422:
if( posX%2 )
area.setX(posX-1);
if( posX % 2 )
area.setX( posX - 1 );
if( (posX+width)%2 )
area.setWidth((posX+width)-area.x()+1);
if( ( posX + width ) % 2 )
area.setWidth( ( posX + width ) - area.x() + 1 );
else
area.setWidth((posX+width)-area.x());
area.setWidth( ( posX + width ) - area.x() );
break;
case GRAY:
@@ -147,7 +147,7 @@ Void PlaYUVerFrame::adjustSelectedAreaDims( QRect &area, Int pel_format )
Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
{
m_pppcInputPel = NULL;
m_pcRGBPelInterlaced = NULL;
m_pcRGB32 = NULL;
m_uiWidth = width;
m_uiHeight = height;
m_iPixelFormat = pel_format;
@@ -172,7 +172,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
{
getMem3ImageComponents<Pel>( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->ratioChromaHeight, m_pcPelFormat->ratioChromaWidth );
}
getMem1D<Pel>( &m_pcRGBPelInterlaced, m_uiHeight * m_uiWidth * 3 );
getMem1D( &m_pcRGB32, m_uiHeight * m_uiWidth * 4 );
openPixfc();
}
@@ -182,7 +182,6 @@ Int PlaYUVerFrame::getColorSpace() const
return m_pcPelFormat->colorSpace;
}
UInt64 PlaYUVerFrame::getBytesPerFrame()
{
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
@@ -221,40 +220,14 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format )
m_pcPelFormat->frameFromBuffer( input_buffer, m_pppcInputPel, m_uiWidth, m_uiHeight );
}
template<typename T>
Void yuvToRgb( T iY, T iU, T iV, T &iR, T &iG, T &iB )
Void PlaYUVerFrame::FrameToBuffer( Pel *output_buffer )
{
iR = iY + 1402 * iV / 1000;
iG = iY - ( 101004 * iU + 209599 * iV ) / 293500;
iB = iY + 1772 * iU / 1000;
if( iR < 0 )
iR = 0;
if( iG < 0 )
iG = 0;
if( iB < 0 )
iB = 0;
if( iR > 255 )
iR = 255;
if( iG > 255 )
iG = 255;
if( iB > 255 )
iB = 255;
m_pcPelFormat->bufferFromFrame( m_pppcInputPel, output_buffer, m_uiWidth, m_uiHeight );
}
template<typename T>
Void rgbToYuv( T iR, T iG, T iB, T &iY, T &iU, T &iV )
{
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000;
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772;
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
}
Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, Int eColorSpace )
{
Pixel PelValue = m_pcPelFormat->getPixelValue(m_pppcInputPel, xPos, yPos );
Pixel PelValue = m_pcPelFormat->getPixelValue( m_pppcInputPel, xPos, yPos );
ConvertPixel( PelValue, eColorSpace );
return PelValue;
}
@@ -293,170 +266,8 @@ Void PlaYUVerFrame::FrametoRGB8()
{
if( m_bHasRGBPel )
return;
#ifdef USE_PIXFC
if( m_pcPixfc )
{
FrametoRGB8Pixfc();
}
#endif
{
Int iY, iU, iV, iR, iG, iB;
Pel** ppInputPelY = m_pppcInputPel[LUMA];
Pel* pInputPelY = &( m_pppcInputPel[LUMA][0][0] );
Pel *pInputPelU = NULL, *pInputPelV = NULL;
if( m_pppcInputPel[CHROMA_U] )
{
pInputPelU = m_pppcInputPel[CHROMA_U][0];
pInputPelV = m_pppcInputPel[CHROMA_V][0];
}
Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced;
Pel* pcRGBPelInterlacedl1 = m_pcRGBPelInterlaced + m_uiWidth * 3;
switch( m_iPixelFormat )
{
case YUV420p:
for( UInt y = 0; y < m_uiHeight; y += 2 )
{
for( UInt x = 0; x < m_uiWidth; x += 2 )
{
// Pixel (x, y).
iY = ppInputPelY[y][x];
iU = *pInputPelU++ - 128;
iV = *pInputPelV++ - 128;
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
// Pixel (x+1, y)
iY = ppInputPelY[y][x + 1];
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
// Pixel (x, y+1)
iY = ppInputPelY[y + 1][x];
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlacedl1++ = iR;
*pcRGBPelInterlacedl1++ = iG;
*pcRGBPelInterlacedl1++ = iB;
// Pixel (x+1, y+1)
iY = ppInputPelY[y + 1][x + 1];
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlacedl1++ = iR;
*pcRGBPelInterlacedl1++ = iG;
*pcRGBPelInterlacedl1++ = iB;
}
pcRGBPelInterlaced += m_uiWidth * 3;
pcRGBPelInterlacedl1 += m_uiWidth * 3;
}
break;
case YUV422p:
case YUYV422:
for( UInt y = 0; y < m_uiHeight; y += 1 )
for( UInt x = 0; x < m_uiWidth; x += 2 )
{
// Pixel (x, y).
iY = ppInputPelY[y][x];
iU = *pInputPelU++ - 128;
iV = *pInputPelV++ - 128;
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
// Pixel (x+1, y)
iY = ppInputPelY[y][x + 1];
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
}
break;
case YUV444p:
for( UInt y = 0; y < m_uiHeight; y++ )
for( UInt x = 0; x < m_uiWidth; x++ )
{
iY = *pInputPelY++;
iU = *pInputPelU++ - 128;
iV = *pInputPelV++ - 128;
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
}
break;
case GRAY:
for( UInt y = 0; y < m_uiHeight; y++ )
for( UInt x = 0; x < m_uiWidth; x++ )
{
iY = *pInputPelY;
iR = iG = iB = iY;
*pcRGBPelInterlaced++ = iR;
*pcRGBPelInterlaced++ = iG;
*pcRGBPelInterlaced++ = iB;
pInputPelY++;
}
break;
case RGB8:
break;
default:
// No action.
break;
}
m_bHasRGBPel = true;
}
}
Void PlaYUVerFrame::FrameToBuffer( Pel *output_buffer )
{
Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced;
Pel* pInputPelY = m_pppcInputPel[LUMA][0];
Pel *pInputPelU = NULL, *pInputPelV = NULL;
if( m_pppcInputPel[CHROMA_U] )
{
pInputPelU = m_pppcInputPel[CHROMA_U][0];
pInputPelV = m_pppcInputPel[CHROMA_V][0];
}
m_bHasRGBPel = false;
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight;
switch( m_iPixelFormat )
{
case YUV420p:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 4 * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 5 / 4, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 4 * sizeof(Pel) );
break;
case YUV444p:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input * sizeof(Pel) );
break;
case YUV422p:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 2 * sizeof(Pel) );
memcpy( output_buffer + frame_bytes_input * 3 / 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 2 * sizeof(Pel) );
break;
case YUYV422:
for( UInt i = 0; i < m_uiHeight * m_uiWidth / 2; i++ )
{
*output_buffer++ = *pInputPelY++;
*output_buffer++ = *pInputPelU++;
*output_buffer++ = *pInputPelY++;
*output_buffer++ = *pInputPelV++;
}
break;
case GRAY:
memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) );
break;
case RGB8:
FrametoRGB8();
memcpy( output_buffer, pcRGBPelInterlaced, frame_bytes_input * sizeof(Pel) * 3 );
break;
}
m_pcPelFormat->fillRGBbuffer( m_pppcInputPel, m_pcRGB32, m_uiWidth, m_uiHeight );
m_bHasRGBPel = true;
}
Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame )
@@ -478,8 +289,8 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
case YUV420p:
for( UInt i = 0; i < m_uiHeight / 2; i++ )
{
memcpy( m_pppcInputPel[LUMA][(i<<1)], &( input_frame->getPelBufferYUV()[LUMA][yPos + ( i << 1 )][xPos] ), m_uiWidth * sizeof(Pel) );
memcpy( m_pppcInputPel[LUMA][(i<<1) + 1], &( input_frame->getPelBufferYUV()[LUMA][yPos + ( i << 1 ) + 1][xPos] ), m_uiWidth * sizeof(Pel) );
memcpy( m_pppcInputPel[LUMA][( i << 1 )], &( input_frame->getPelBufferYUV()[LUMA][yPos + ( i << 1 )][xPos] ), m_uiWidth * sizeof(Pel) );
memcpy( m_pppcInputPel[LUMA][( i << 1 ) + 1], &( input_frame->getPelBufferYUV()[LUMA][yPos + ( i << 1 ) + 1][xPos] ), m_uiWidth * sizeof(Pel) );
memcpy( m_pppcInputPel[CHROMA_U][i], &( input_frame->getPelBufferYUV()[CHROMA_U][yPos / 2 + i][xPos / 2] ), m_uiWidth / 2 * sizeof(Pel) );
memcpy( m_pppcInputPel[CHROMA_V][i], &( input_frame->getPelBufferYUV()[CHROMA_V][yPos / 2 + i][xPos / 2] ), m_uiWidth / 2 * sizeof(Pel) );
}
@@ -550,13 +361,13 @@ Void PlaYUVerFrame::FrametoRGB8Pixfc()
switch( m_iPixelFormat )
{
case YUV420p:
m_pcPixfc->convert(m_pcPixfc, m_pppcInputPel, m_pcRGBPelInterlaced);
m_pcPixfc->convert(m_pcPixfc, m_pppcInputPel, m_pcRGB32);
break;
case YUV422p:
break;
case YUV444p:
case YUYV422:
m_pcPixfc->convert(m_pcPixfc, m_pppcInputPel, m_pcRGBPelInterlaced);
m_pcPixfc->convert(m_pcPixfc, m_pppcInputPel, m_pcRGB32);
break;
case GRAY:
break;
@@ -595,7 +406,7 @@ cv::Mat PlaYUVerFrame::getCvMat()
if( m_iPixelFormat != GRAY )
{
FrametoRGB8();
memcpy( opencvFrame.data, m_pcRGBPelInterlaced, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
memcpy( opencvFrame.data, m_pcRGB32, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
}
else
{
@@ -633,7 +444,7 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame )
Pel* pInputPelY = m_pppcInputPel[LUMA][0];
Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0];
Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0];
Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced;
Pel* pcRGBPelInterlaced = m_pcRGB32;
memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ )
{
+39 -3
View File
@@ -52,7 +52,7 @@ typedef struct
Int ratioChromaHeight;
Pixel (*getPixelValue)( Pel ***Img, Int xPos, Int yPos );
Void (*frameFromBuffer)( Pel *in, Pel*** out, UInt width, UInt height );
Void (*bufferFromFrame)( Pel* out, Pel ***in, UInt width, UInt height );
Void (*bufferFromFrame)( Pel ***in, Pel* out, UInt width, UInt height );
Void (*fillRGBbuffer)( Pel*** in, UChar* out, UInt width, UInt height );
Int ffmpegPelFormat;
} PlaYUVerFramePelFormat;
@@ -61,6 +61,37 @@ typedef struct
extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS];
template<typename T>
Void yuvToRgb( T iY, T iU, T iV, T &iR, T &iG, T &iB )
{
iR = iY + 1402 * iV / 1000;
iG = iY - ( 101004 * iU + 209599 * iV ) / 293500;
iB = iY + 1772 * iU / 1000;
if( iR < 0 )
iR = 0;
if( iG < 0 )
iG = 0;
if( iB < 0 )
iB = 0;
if( iR > 255 )
iR = 255;
if( iG > 255 )
iG = 255;
if( iB > 255 )
iB = 255;
}
template<typename T>
Void rgbToYuv( T iR, T iG, T iB, T &iY, T &iU, T &iV )
{
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000;
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772;
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
}
class PlaYUVerFrame
{
public:
@@ -123,11 +154,16 @@ public:
UChar* getQImageBuffer() const
{
return m_pcRGBPelInterlaced;
return m_pcRGB32;
}
static Pixel ConvertPixel( Pixel, Int );
template<typename T>
static Void YUV2RGB( T iY, T iU, T iV, T &iR, T &iG, T &iB );
template<typename T>
static Void RGB2YUV( T iR, T iG, T iB, T &iY, T &iU, T &iV );
#ifdef USE_OPENCV
cv::Mat getCvMat();
Void copyFrom( cv::Mat* );
@@ -200,7 +236,7 @@ private:
Bool m_bHasRGBPel;
Pel*** m_pppcInputPel;
UChar* m_pcRGBPelInterlaced;
UChar* m_pcRGB32;
Void adjustSelectedAreaDims( QRect &area, Int pel_format );
Void init( UInt width, UInt height, Int pel_format );
+99 -47
View File
@@ -39,24 +39,54 @@ 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
*/
Void frameFromBufferYUVProgressive( Pel ***out, Pel* in, UInt width, UInt height, UInt ratioChroma )
Void frameFromBufferYUVProgressive( Pel* in, Pel ***out, UInt width, UInt height, UInt ratioChroma )
{
memcpy( &out[LUMA][0][0], in, width * height * sizeof(Pel) );
memcpy( &out[CHROMA_U][0][0], in + width * height, width * height / ratioChroma * sizeof(Pel) );
memcpy( &out[CHROMA_V][0][0], in + width * height + width * height / ratioChroma, width * height / ratioChroma * sizeof(Pel) );
}
Void bufferFromFrameYUVProgressive( Pel *out, Pel*** in, UInt width, UInt height, UInt ratioChroma )
Void bufferFromFrameYUVProgressive( Pel*** in, Pel *out, UInt width, UInt height, UInt ratioChroma )
{
memcpy( out, &in[LUMA][0][0], width * height * sizeof(Pel) );
memcpy( out + width * height, &in[CHROMA_U][0][0], width * height / ratioChroma * sizeof(Pel) );
memcpy( out + width * height + width * height / ratioChroma, &in[CHROMA_V][0][0], width * height / ratioChroma * sizeof(Pel) );
}
Void fillRGBbufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt ratioChromaHor, UInt ratioChromaVer )
{
Pel** pY = in[LUMA];
Pel** pU = in[CHROMA_U];
Pel** pV = in[CHROMA_V];
Int iY, iU, iV, iR, iG, iB;
UInt* buff = ( UInt* )out;
for( UInt y = 0; y < height; y++ )
{
for( UInt x = 0; x < width; x++ )
{
// Pixel (x, y).
iY = pY[y][x];
iU = pU[y >> ratioChromaVer][x >> ratioChromaHor] - 128;
iV = pV[y >> ratioChromaVer][x >> ratioChromaHor] - 128;
yuvToRgb<Int>( iY, iU, iV, iR, iG, iB );
*buff = qRgb( iR, iG, iB );
buff++;
}
}
}
/**
* YUV420p 12 bits per pixel
*/
@@ -71,15 +101,15 @@ Pixel getPixelValueYUV420p( Pel ***Img, Int xPos, Int yPos )
}
Void frameFromBufferYUV420p( Pel *in, Pel*** out, UInt width, UInt height )
{
frameFromBufferYUVProgressive( out, in, width, height, 4 );
frameFromBufferYUVProgressive( in, out, width, height, 4 );
}
Void bufferFromFrameYUV420p( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameYUV420p( Pel ***in, Pel* out, UInt width, UInt height )
{
bufferFromFrameYUVProgressive( out, in, width, height, 4 );
bufferFromFrameYUVProgressive( in, out, width, height, 4 );
}
Void fillRGBbufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height )
{
fillRGBbufferYUV( in, out, width, height, 1, 1 );
}
PlaYUVerFramePelFormat yuv420p =
{
@@ -108,15 +138,15 @@ Pixel getPixelValueYUV444p( Pel ***Img, Int xPos, Int yPos )
}
Void frameFromBufferYUV444p( Pel *in, Pel*** out, UInt width, UInt height )
{
frameFromBufferYUVProgressive( out, in, width, height, 1 );
frameFromBufferYUVProgressive( in, out, width, height, 1 );
}
Void bufferFromFrameYUV444p( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameYUV444p( Pel ***in, Pel* out, UInt width, UInt height )
{
bufferFromFrameYUVProgressive( out, in, width, height, 1 );
bufferFromFrameYUVProgressive( in, out, width, height, 1 );
}
Void fillRGBbufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height )
{
fillRGBbufferYUV( in, out, width, height, 0, 0 );
}
PlaYUVerFramePelFormat yuv444p =
{
@@ -145,15 +175,15 @@ Pixel getPixelValueYUV422( Pel ***Img, Int xPos, Int yPos )
}
Void frameFromBufferYUV422p( Pel *in, Pel*** out, UInt width, UInt height )
{
frameFromBufferYUVProgressive( out, in, width, height, 2 );
frameFromBufferYUVProgressive( in, out, width, height, 2 );
}
Void bufferFromFrameYUV422p( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameYUV422p( Pel ***in, Pel* out, UInt width, UInt height )
{
bufferFromFrameYUVProgressive( out, in, width, height, 2 );
bufferFromFrameYUVProgressive( in, out, width, height, 2 );
}
Void fillRGBbufferYUV422p( Pel*** in, UChar* out, UInt width, UInt height )
Void fillRGBbufferYUV422( Pel*** in, UChar* out, UInt width, UInt height )
{
fillRGBbufferYUV( in, out, width, height, 1, 0 );
}
PlaYUVerFramePelFormat yuv422p =
{
@@ -165,13 +195,13 @@ PlaYUVerFramePelFormat yuv422p =
getPixelValueYUV422,
frameFromBufferYUV422p,
bufferFromFrameYUV422p,
fillRGBbufferYUV422p,
fillRGBbufferYUV422,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), };
/**
* YUV422 16 bits per pixel
* YUYV422 16 bits per pixel
*/
Void frameFromBufferYUV422( Pel *in, Pel*** out, UInt width, UInt height )
Void frameFromBufferYUYV422( Pel *in, Pel*** out, UInt width, UInt height )
{
Pel* pY = out[LUMA][0];
Pel* pU = out[CHROMA_U][0];
@@ -184,24 +214,30 @@ Void frameFromBufferYUV422( Pel *in, Pel*** out, UInt width, UInt height )
*pV++ = *in++;
}
}
Void bufferFromFrameYUV422( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameYUYV422( Pel ***in, Pel* out, UInt width, UInt height )
{
Pel* pY = in[LUMA][0];
Pel* pU = in[CHROMA_U][0];
Pel* pV = in[CHROMA_V][0];
for( UInt i = 0; i < height * width / 2; i++ )
{
*out++ = *pY++;
*out++ = *pU++;
*out++ = *pY++;
*out++ = *pV++;
}
}
Void fillRGBbufferYUV422( Pel*** in, UChar* out, UInt width, UInt height )
{
}
PlaYUVerFramePelFormat yuv422 =
PlaYUVerFramePelFormat yuyv422 =
{
"YUV422",
"YUYV422",
PlaYUVerFrame::COLOR_YUV,
3,
2,
1,
getPixelValueYUV422,
frameFromBufferYUV422,
bufferFromFrameYUV422,
frameFromBufferYUYV422,
bufferFromFrameYUYV422,
fillRGBbufferYUV422,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), };
@@ -222,20 +258,17 @@ Void frameFromBufferGray( Pel *in, Pel*** out, UInt width, UInt height )
{
memcpy( &out[LUMA][0][0], in, width * height * sizeof(Pel) );
}
Void bufferFromFrameGray( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameGray( Pel ***in, Pel* out, UInt width, UInt height )
{
memcpy( out, &in[LUMA][0][0], width * height * sizeof(Pel) );
}
Void fillRGBbufferGray( Pel*** in, UChar* out, UInt width, UInt height )
{
Pel *inPel = in[0][0];
Pel iY;
for( UInt i = 0; i < width * height; i++ )
UInt* buff = ( UInt* )out;
for( UInt i = 0; i < height * width; i++ )
{
iY = *inPel++;
*out++ = iY;
*out++ = iY;
*out++ = iY;
*buff++ = qRgb( *inPel, *inPel, *inPel++ );
}
}
PlaYUVerFramePelFormat gray =
@@ -257,7 +290,7 @@ PlaYUVerFramePelFormat gray =
*/
/** RGB 8 bits per pixel / 3 channels */
Pixel getPixelValueRGB8( Pel ***Img, Int xPos, Int yPos )
Pixel getPixelValueRGB24( Pel ***Img, Int xPos, Int yPos )
{
Pixel pixel_value;
pixel_value.color_space = PlaYUVerFrame::COLOR_RGB;
@@ -266,7 +299,7 @@ Pixel getPixelValueRGB8( Pel ***Img, Int xPos, Int yPos )
pixel_value.ColorB = Img[COLOR_B][yPos][xPos];
return pixel_value;
}
Void frameFromBufferRGB8( Pel *in, Pel*** out, UInt width, UInt height )
Void frameFromBufferRGB24( Pel *in, Pel*** out, UInt width, UInt height )
{
Pel* pR = out[COLOR_R][0];
Pel* pG = out[COLOR_G][0];
@@ -278,25 +311,44 @@ Void frameFromBufferRGB8( Pel *in, Pel*** out, UInt width, UInt height )
*pB++ = *in++;
}
}
Void bufferFromFrameRGB8( Pel* out, Pel ***in, UInt width, UInt height )
Void bufferFromFrameRGB24( Pel ***in, Pel* out, UInt width, UInt height )
{
Pel* pR = in[COLOR_R][0];
Pel* pG = in[COLOR_G][0];
Pel* pB = in[COLOR_B][0];
for( UInt i = 0; i < width * height; i++ )
{
*out++ = *pR++;
*out++ = *pG++;
*out++ = *pB++;
}
}
Void fillRGBbufferRGB8( Pel*** in, UChar* out, UInt width, UInt height )
Void fillRGBbufferRGB24( Pel*** in, UChar* out, UInt width, UInt height )
{
Pel* pR = in[COLOR_R][0];
Pel* pG = in[COLOR_G][0];
Pel* pB = in[COLOR_B][0];
Int iR, iG, iB;
UInt* buff = ( UInt* )out;
for( UInt i = 0; i < height * width; i++ )
{
iR = *pR++;
iG = *pG++;
iB = *pB++;
*buff++ = qRgb( iR, iG, iB );
}
}
PlaYUVerFramePelFormat rgb8 =
PlaYUVerFramePelFormat rgb24 =
{
"RGB8",
PlaYUVerFrame::COLOR_RGB,
3,
1,
1,
getPixelValueRGB8,
frameFromBufferRGB8,
bufferFromFrameRGB8,
fillRGBbufferRGB8,
getPixelValueRGB24,
frameFromBufferRGB24,
bufferFromFrameRGB24,
fillRGBbufferRGB24,
ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), };
extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORMATS] =
@@ -304,8 +356,8 @@ extern PlaYUVerFramePelFormat g_PlaYUVerFramePelFormatsList[PLAYUVER_NUMBER_FORM
yuv420p,
yuv444p,
yuv422p,
yuv422,
yuyv422,
gray,
rgb8, };
rgb24, };
} // NAMESPACE