Change function order and variables names
This commit is contained in:
1 parent
84729b9cd7
commit
84f2aa00be
5 files changed
+89
-96
No files matched your search
@@ -72,8 +72,8 @@ ViewArea::ViewArea( QWidget *parent ) :
|
||||
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_RGB32 );
|
||||
m_pcCurrFrame->fillRGBBuffer();
|
||||
QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB32 );
|
||||
setImage( QPixmap::fromImage( qimg ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -694,7 +694,7 @@ Void plaYUVerApp::seekEvent( Int direction )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) )
|
||||
{
|
||||
Int frame_num = m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum();
|
||||
UInt64 frame_num = m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum();
|
||||
if( !( (frame_num + 1) >= getMaxFrameNumber() && direction > 0 ) )
|
||||
{
|
||||
for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
|
||||
@@ -182,6 +182,11 @@ Int PlaYUVerFrame::getColorSpace() const
|
||||
return m_pcPelFormat->colorSpace;
|
||||
}
|
||||
|
||||
Int PlaYUVerFrame::getNumberChannels() const
|
||||
{
|
||||
return m_pcPelFormat->numberChannels;
|
||||
}
|
||||
|
||||
UInt64 PlaYUVerFrame::getBytesPerFrame()
|
||||
{
|
||||
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat );
|
||||
@@ -225,44 +230,7 @@ Void PlaYUVerFrame::FrameToBuffer( Pel *output_buffer )
|
||||
m_pcPelFormat->bufferFromFrame( m_pppcInputPel, output_buffer, m_uiWidth, m_uiHeight );
|
||||
}
|
||||
|
||||
Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, Int eColorSpace )
|
||||
{
|
||||
Pixel PelValue = m_pcPelFormat->getPixelValue( m_pppcInputPel, xPos, yPos );
|
||||
ConvertPixel( PelValue, eColorSpace );
|
||||
return PelValue;
|
||||
}
|
||||
|
||||
Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, Int eOutputSpace )
|
||||
{
|
||||
Int outA, outB, outC;
|
||||
Pixel sOutputPixel =
|
||||
{
|
||||
COLOR_INVALID,
|
||||
0,
|
||||
0,
|
||||
0 };
|
||||
|
||||
if( sInputPixel.color_space == eOutputSpace )
|
||||
return sInputPixel;
|
||||
|
||||
if( eOutputSpace == COLOR_RGB )
|
||||
{
|
||||
yuvToRgb<Int>( sInputPixel.Luma, sInputPixel.ChromaU, sInputPixel.ChromaV, outA, outB, outC );
|
||||
sOutputPixel.ColorR = outA;
|
||||
sOutputPixel.ColorG = outB;
|
||||
sOutputPixel.ColorB = outC;
|
||||
}
|
||||
if( eOutputSpace == COLOR_YUV )
|
||||
{
|
||||
rgbToYuv<Int>( sInputPixel.ColorR, sInputPixel.ColorG, sInputPixel.ColorB, outA, outB, outC );
|
||||
sOutputPixel.Luma = outA;
|
||||
sOutputPixel.ChromaU = outB;
|
||||
sOutputPixel.ChromaV = outC;
|
||||
}
|
||||
return sOutputPixel;
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::FrametoRGB8()
|
||||
Void PlaYUVerFrame::fillRGBBuffer()
|
||||
{
|
||||
if( m_bHasRGBPel )
|
||||
return;
|
||||
@@ -331,6 +299,43 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
|
||||
}
|
||||
}
|
||||
|
||||
Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, Int eColorSpace )
|
||||
{
|
||||
Pixel PelValue = m_pcPelFormat->getPixelValue( m_pppcInputPel, xPos, yPos );
|
||||
ConvertPixel( PelValue, eColorSpace );
|
||||
return PelValue;
|
||||
}
|
||||
|
||||
Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, Int eOutputSpace )
|
||||
{
|
||||
Int outA, outB, outC;
|
||||
Pixel sOutputPixel =
|
||||
{
|
||||
COLOR_INVALID,
|
||||
0,
|
||||
0,
|
||||
0 };
|
||||
|
||||
if( sInputPixel.color_space == eOutputSpace )
|
||||
return sInputPixel;
|
||||
|
||||
if( eOutputSpace == COLOR_RGB )
|
||||
{
|
||||
yuvToRgb<Int>( sInputPixel.Luma, sInputPixel.ChromaU, sInputPixel.ChromaV, outA, outB, outC );
|
||||
sOutputPixel.ColorR = outA;
|
||||
sOutputPixel.ColorG = outB;
|
||||
sOutputPixel.ColorB = outC;
|
||||
}
|
||||
if( eOutputSpace == COLOR_YUV )
|
||||
{
|
||||
rgbToYuv<Int>( sInputPixel.ColorR, sInputPixel.ColorG, sInputPixel.ColorB, outA, outB, outC );
|
||||
sOutputPixel.Luma = outA;
|
||||
sOutputPixel.ChromaU = outB;
|
||||
sOutputPixel.ChromaV = outC;
|
||||
}
|
||||
return sOutputPixel;
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::openPixfc()
|
||||
{
|
||||
#ifdef USE_PIXFC
|
||||
@@ -405,7 +410,7 @@ cv::Mat PlaYUVerFrame::getCvMat()
|
||||
cv::Mat opencvFrame( m_uiHeight, m_uiWidth, cvType );
|
||||
if( m_iPixelFormat != GRAY )
|
||||
{
|
||||
FrametoRGB8();
|
||||
fillRGBBuffer();
|
||||
memcpy( opencvFrame.data, m_pcRGB32, m_uiWidth * m_uiHeight * 3 * sizeof(Pel) );
|
||||
}
|
||||
else
|
||||
|
||||
+39
-51
@@ -91,7 +91,6 @@ Void rgbToYuv( T iR, T iG, T iB, T &iY, T &iU, T &iV )
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
|
||||
}
|
||||
|
||||
|
||||
class PlaYUVerFrame
|
||||
{
|
||||
public:
|
||||
@@ -124,46 +123,65 @@ public:
|
||||
PlaYUVerFrame( PlaYUVerFrame *other, QRect area );
|
||||
~PlaYUVerFrame();
|
||||
|
||||
Void FrametoRGB8();
|
||||
|
||||
Void FrameFromBuffer( Pel*, Int );
|
||||
Void FrameToBuffer( Pel* );
|
||||
|
||||
Void copyFrom( PlaYUVerFrame* );
|
||||
Void copyFrom( PlaYUVerFrame*, UInt, UInt );
|
||||
|
||||
UInt64 getBytesPerFrame();
|
||||
static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat );
|
||||
|
||||
Int getColorSpace() const;
|
||||
Int getNumberChannels() const;
|
||||
UInt getChromaWidth() const;
|
||||
UInt getChromaHeight() const;
|
||||
UInt getChromaLength() const;
|
||||
|
||||
Void FrameFromBuffer( Pel*, Int );
|
||||
Void FrameToBuffer( Pel* );
|
||||
|
||||
Void fillRGBBuffer();
|
||||
|
||||
Void copyFrom( PlaYUVerFrame* );
|
||||
Void copyFrom( PlaYUVerFrame*, UInt, UInt );
|
||||
|
||||
Pixel getPixelValue( Int xPos, Int yPos, Int eColorSpace );
|
||||
static Pixel ConvertPixel( Pixel, Int );
|
||||
|
||||
UInt getWidth() const
|
||||
{
|
||||
return m_uiWidth;
|
||||
}
|
||||
UInt getHeight() const
|
||||
{
|
||||
return m_uiHeight;
|
||||
}
|
||||
Int getPelFormat() const
|
||||
{
|
||||
return m_iPixelFormat;
|
||||
}
|
||||
|
||||
Int getBitsChannel() const
|
||||
{
|
||||
return m_iBitsChannels;
|
||||
}
|
||||
Bool isValid() const
|
||||
{
|
||||
return ( m_uiWidth > 0 ) && ( m_uiHeight > 0 ) && ( m_iPixelFormat >= 0 );
|
||||
}
|
||||
Bool haveSameFmt( PlaYUVerFrame* other ) const
|
||||
{
|
||||
return ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() ) && ( m_iPixelFormat == other->getPelFormat() );
|
||||
}
|
||||
Pel*** getPelBufferYUV() const
|
||||
{
|
||||
return m_pppcInputPel;
|
||||
}
|
||||
|
||||
Pel*** getPelBufferYUV()
|
||||
{
|
||||
m_bHasRGBPel = false;
|
||||
return m_pppcInputPel;
|
||||
}
|
||||
|
||||
Pixel getPixelValue( Int xPos, Int yPos, Int eColorSpace );
|
||||
|
||||
UChar* getQImageBuffer() const
|
||||
UChar* getRGBBuffer() const
|
||||
{
|
||||
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* );
|
||||
@@ -194,36 +212,6 @@ public:
|
||||
Double getPSNR( PlaYUVerFrame* Org, Int component );
|
||||
Double getSSIM( PlaYUVerFrame* Org, Int component );
|
||||
|
||||
UInt getWidth() const
|
||||
{
|
||||
return m_uiWidth;
|
||||
}
|
||||
UInt getHeight() const
|
||||
{
|
||||
return m_uiHeight;
|
||||
}
|
||||
Int getPelFormat() const
|
||||
{
|
||||
return m_iPixelFormat;
|
||||
}
|
||||
Int getColorSpace() const;
|
||||
Int getNumberChannels() const
|
||||
{
|
||||
return m_iNumberChannels;
|
||||
}
|
||||
Int getBitsChannel() const
|
||||
{
|
||||
return m_iBitsChannels;
|
||||
}
|
||||
Bool isValid() const
|
||||
{
|
||||
return ( m_uiWidth > 0 ) && ( m_uiHeight > 0 ) && ( m_iPixelFormat >= 0 );
|
||||
}
|
||||
Bool haveSameFmt( PlaYUVerFrame* other ) const
|
||||
{
|
||||
return ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() ) && ( m_iPixelFormat == other->getPelFormat() );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
PlaYUVerFramePelFormat* m_pcPelFormat;
|
||||
|
||||
@@ -551,7 +551,7 @@ Void PlaYUVerStream::readFrame()
|
||||
}
|
||||
//Int time = m_cTimer.elapsed();
|
||||
//m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time) / 2;
|
||||
m_pcNextFrame->FrametoRGB8();
|
||||
m_pcNextFrame->fillRGBBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -608,8 +608,8 @@ Bool PlaYUVerStream::saveFrame( const QString& filename, PlaYUVerFrame *saveFram
|
||||
}
|
||||
else
|
||||
{
|
||||
saveFrame->FrametoRGB8();
|
||||
QImage qimg = QImage( saveFrame->getQImageBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB888 );
|
||||
saveFrame->fillRGBBuffer();
|
||||
QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB888 );
|
||||
return qimg.save( filename );
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user