minor API changes to achieve better documentation
This commit is contained in:
1 parent
099dcaa336
commit
13d4a4f060
4 files changed
+81
-67
No files matched your search
@@ -625,18 +625,18 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
||||
Int ColorSpace = m_pcCurrFrame->getColorSpace();
|
||||
if( ColorSpace == PlaYUVerFrame::COLOR_GRAY )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y(), PlaYUVerFrame::COLOR_GRAY );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
strStatus.append( QString( "Y: %1" ).arg( sPixelValue.Y() ) );
|
||||
}
|
||||
if( ColorSpace == PlaYUVerFrame::COLOR_YUV )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y(), PlaYUVerFrame::COLOR_YUV );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
strStatus.append( QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
|
||||
}
|
||||
|
||||
if( ( ColorSpace == PlaYUVerFrame::COLOR_RGB ) )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y(), PlaYUVerFrame::COLOR_YUV );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
|
||||
strStatus.append( QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
|
||||
}
|
||||
emit updateStatusBar( strStatus );
|
||||
|
||||
+3
-3
@@ -418,7 +418,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
|
||||
|
||||
if( frFormat == PlaYUVerFrame::COLOR_YUV )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y(), PlaYUVerFrame::COLOR_YUV );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( sPixelValue.Y() < 128 )
|
||||
painter.setPen( QColor( Qt::white ) );
|
||||
@@ -431,7 +431,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
|
||||
}
|
||||
if( frFormat == PlaYUVerFrame::COLOR_GRAY )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y(), PlaYUVerFrame::COLOR_GRAY );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( sPixelValue.Y() < 128 )
|
||||
painter.setPen( QColor( Qt::white ) );
|
||||
@@ -443,7 +443,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
|
||||
|
||||
if( ( frFormat == PlaYUVerFrame::COLOR_RGB ) )
|
||||
{
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y(), PlaYUVerFrame::COLOR_RGB );
|
||||
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < 128 * 3 )
|
||||
painter.setPen( QColor( Qt::white ) );
|
||||
|
||||
+48
-47
@@ -53,6 +53,31 @@ std::vector<std::string> PlaYUVerFrame::supportedPixelFormatListNames()
|
||||
return formatsList;
|
||||
}
|
||||
|
||||
PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace eOutputSpace )
|
||||
{
|
||||
Int outA, outB, outC;
|
||||
PlaYUVerFrame::Pixel outPixel( COLOR_INVALID, 0, 0, 0 );
|
||||
|
||||
if( inputPixel.ColorSpace() == eOutputSpace || eOutputSpace == COLOR_ARGB || eOutputSpace == COLOR_GRAY )
|
||||
return inputPixel;
|
||||
|
||||
if( eOutputSpace == COLOR_RGB )
|
||||
{
|
||||
YUV2RGB( inputPixel.Y(), inputPixel.Cb(), inputPixel.Cr(), outA, outB, outC );
|
||||
outPixel.R() = outA;
|
||||
outPixel.G() = outB;
|
||||
outPixel.B() = outC;
|
||||
}
|
||||
if( eOutputSpace == COLOR_YUV )
|
||||
{
|
||||
rgbToYuv( inputPixel.R(), inputPixel.G(), inputPixel.B(), outA, outB, outC );
|
||||
outPixel.Y() = outA;
|
||||
outPixel.Cb() = outB;
|
||||
outPixel.Cr() = outC;
|
||||
}
|
||||
return outPixel;
|
||||
}
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format )
|
||||
{
|
||||
init( width, height, pel_format );
|
||||
@@ -66,7 +91,25 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight )
|
||||
{
|
||||
adjustSelectedAreaDims( posX, posY, areaWidth, areaHeight, other->getPelFormat() );
|
||||
|
||||
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] );
|
||||
if( pcPelFormat->log2ChromaWidth )
|
||||
{
|
||||
if( posX % ( 1 << pcPelFormat->log2ChromaWidth ) )
|
||||
posX--;
|
||||
if( ( posX + areaWidth ) % ( 1 << pcPelFormat->log2ChromaWidth ) )
|
||||
areaWidth++;
|
||||
}
|
||||
|
||||
if( pcPelFormat->log2ChromaHeight )
|
||||
{
|
||||
if( posY % ( 1 << pcPelFormat->log2ChromaHeight ) )
|
||||
posY--;
|
||||
|
||||
if( ( posY + areaHeight ) % ( 1 << pcPelFormat->log2ChromaHeight ) )
|
||||
areaHeight++;
|
||||
}
|
||||
|
||||
init( areaWidth, areaHeight, other->getPelFormat() );
|
||||
copyFrom( other, posX, posY );
|
||||
}
|
||||
@@ -298,27 +341,6 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame )
|
||||
memcpy( *m_pppcInputPel[LUMA], input_frame->getPelBufferYUV()[LUMA][0], getBytesPerFrame() * sizeof(Pel) );
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::adjustSelectedAreaDims( UInt& posX, UInt& posY, UInt& areaWidth, UInt& areaHeight, Int pelFormat )
|
||||
{
|
||||
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pelFormat] );
|
||||
if( pcPelFormat->log2ChromaWidth )
|
||||
{
|
||||
if( posX % ( 1 << pcPelFormat->log2ChromaWidth ) )
|
||||
posX--;
|
||||
if( ( posX + areaWidth ) % ( 1 << pcPelFormat->log2ChromaWidth ) )
|
||||
areaWidth++;
|
||||
}
|
||||
|
||||
if( pcPelFormat->log2ChromaHeight )
|
||||
{
|
||||
if( posY % ( 1 << pcPelFormat->log2ChromaHeight ) )
|
||||
posY--;
|
||||
|
||||
if( ( posY + areaHeight ) % ( 1 << pcPelFormat->log2ChromaHeight ) )
|
||||
areaHeight++;
|
||||
}
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
|
||||
{
|
||||
if( m_iPixelFormat != input_frame->getPelFormat() )
|
||||
@@ -337,7 +359,7 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
|
||||
m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
PlaYUVerFrame::Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, Int eColorSpace )
|
||||
PlaYUVerFrame::Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, ColorSpace eColorSpace )
|
||||
{
|
||||
PlaYUVerFrame::Pixel PixelValue( m_pcPelFormat->colorSpace, 0, 0, 0 );
|
||||
for( UInt ch = 0; ch < m_pcPelFormat->numberChannels; ch++ )
|
||||
@@ -346,32 +368,11 @@ PlaYUVerFrame::Pixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, Int eColo
|
||||
Int ratioW = ch > 0 ? m_pcPelFormat->log2ChromaHeight : 0;
|
||||
PixelValue.Components()[ch] = m_pppcInputPel[ch][( yPos >> ratioH )][( xPos >> ratioW )];
|
||||
}
|
||||
return ConvertPixel( PixelValue, eColorSpace );
|
||||
}
|
||||
|
||||
PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( PlaYUVerFrame::Pixel inputPixel, Int eOutputSpace )
|
||||
{
|
||||
Int outA, outB, outC;
|
||||
PlaYUVerFrame::Pixel outPixel( COLOR_INVALID, 0, 0, 0 );
|
||||
|
||||
if( inputPixel.ColorSpace() == eOutputSpace || eOutputSpace == COLOR_ARGB || eOutputSpace == COLOR_GRAY )
|
||||
return inputPixel;
|
||||
|
||||
if( eOutputSpace == COLOR_RGB )
|
||||
if( eColorSpace != COLOR_INVALID )
|
||||
{
|
||||
YUV2RGB( inputPixel.Y(), inputPixel.Cb(), inputPixel.Cr(), outA, outB, outC );
|
||||
outPixel.R() = outA;
|
||||
outPixel.G() = outB;
|
||||
outPixel.B() = outC;
|
||||
PixelValue = ConvertPixel( PixelValue, eColorSpace );
|
||||
}
|
||||
if( eOutputSpace == COLOR_YUV )
|
||||
{
|
||||
rgbToYuv( inputPixel.R(), inputPixel.G(), inputPixel.B(), outA, outB, outC );
|
||||
outPixel.Y() = outA;
|
||||
outPixel.Cb() = outB;
|
||||
outPixel.Cr() = outC;
|
||||
}
|
||||
return outPixel;
|
||||
return PixelValue;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+27
-14
@@ -132,10 +132,25 @@ public:
|
||||
/**
|
||||
* Function that handles the supported pixel formats
|
||||
* of PlaYUVerFrame
|
||||
* @@return vector of strings with pixel formats names
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedPixelFormatListNames();
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific
|
||||
* pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static UInt64 getBytesPerFrame( UInt, UInt, Int );
|
||||
|
||||
/**
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (PlaYUVerFrame::Pixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
static PlaYUVerFrame::Pixel ConvertPixel( Pixel inputPixel, ColorSpace eOutputSpace );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
@@ -145,7 +160,7 @@ public:
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
PlaYUVerFrame( UInt width = 0, UInt height = 0, Int pel_format = 0 );
|
||||
PlaYUVerFrame( UInt width, UInt height, Int pel_format = 0 );
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an
|
||||
@@ -170,16 +185,9 @@ public:
|
||||
|
||||
~PlaYUVerFrame();
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific
|
||||
* pixel format
|
||||
* @@return number of bytes per frame
|
||||
*/
|
||||
static UInt64 getBytesPerFrame( UInt, UInt, Int );
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @@return number of bytes per frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
UInt64 getBytesPerFrame();
|
||||
|
||||
@@ -195,12 +203,9 @@ public:
|
||||
Void fillRGBBuffer();
|
||||
|
||||
Void copyFrom( PlaYUVerFrame* );
|
||||
|
||||
static Void adjustSelectedAreaDims( UInt& posX, UInt& posY, UInt& areaWidth, UInt& areaHeight, Int pelFormat );
|
||||
Void copyFrom( PlaYUVerFrame*, UInt, UInt );
|
||||
|
||||
PlaYUVerFrame::Pixel getPixelValue( Int, Int, Int );
|
||||
static PlaYUVerFrame::Pixel ConvertPixel( Pixel, Int );
|
||||
PlaYUVerFrame::Pixel getPixelValue( Int xPos, Int yPos, ColorSpace eColorSpace = COLOR_INVALID );
|
||||
|
||||
UInt getWidth() const
|
||||
{
|
||||
@@ -305,6 +310,14 @@ private:
|
||||
Bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
UChar* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
|
||||
/**
|
||||
* Common constructor function of a frame
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
*/
|
||||
Void init( UInt width, UInt height, Int pel_format );
|
||||
|
||||
Void openPixfc();
|
||||
|
||||
Reference in new issue
Block a user