From 518d68483a22fa95d5fa671e87def7f39ec8ddde Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 06:24:54 +0100 Subject: [PATCH] Major changes in ColorSpace Definition Now color space is defined in PlaYUVerFrame New function to check if a pixel format is RGB or YUV or Gray or ARGB implemented --- source/app/TypeDef.h | 10 +--------- source/app/ViewArea.cpp | 2 +- source/app/plaYUVerApp.cpp | 2 +- source/lib/PlaYUVerFrame.cpp | 6 +++--- source/lib/PlaYUVerFrame.h | 33 +++++++++++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 16 deletions(-) diff --git a/source/app/TypeDef.h b/source/app/TypeDef.h index 8f34ee7..a121cef 100644 --- a/source/app/TypeDef.h +++ b/source/app/TypeDef.h @@ -112,14 +112,6 @@ typedef UChar Pel; ///< 8-bit pixel type // PlaYUVer definitions // ==================================================================================================================== -enum ColorSpace -{ - COLOR_INVALID = -1, - COLOR_YUV = 0, - COLOR_RGB, -}; - - enum YUVcomponent { LUMA = 0, @@ -136,7 +128,7 @@ enum RGBcomponent typedef struct __pixel_definition { - ColorSpace color_space; + Int color_space; union { Pel Luma; diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 2cea3ad..50df77d 100755 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -372,7 +372,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) for(Int j=vr.y() ; j<=vr.bottom() ; j++) { QPoint pixelTopLeft(i,j); - sPixelValue = curFrame->getPixelValue( pixelTopLeft, COLOR_YUV ); + sPixelValue = curFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); QRect pixelRect(viewToWindow(pixelTopLeft), QSize(m_zoomFactor,m_zoomFactor)); if( sPixelValue.Luma < 128 ) diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index e38cc28..27d9992 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -491,7 +491,7 @@ void plaYUVerApp::updatePixelValueStatusBar( const QPoint & pos, InputStream* st if( ( posX < iWidth ) && ( posX >= 0 ) && ( posY < iHeight ) && ( posY >= 0 ) ) { - sPixelValue = curFrame->getPixelValue( pos, COLOR_YUV ); + sPixelValue = curFrame->getPixelValue( pos, PlaYUVerFrame::COLOR_YUV ); strPixel = QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Luma ).arg( sPixelValue.ChromaU ).arg( sPixelValue.ChromaV ); strStatus.append( strPixel ); statusBar()->showMessage( strStatus, 0 ); diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 8b2b827..bb67c2f 100755 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -430,7 +430,7 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() return 0; } -Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, ColorSpace eOutputSpace ) +Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, Int eOutputSpace ) { Pixel sOutputPixel = { @@ -453,7 +453,7 @@ Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, ColorSpace eOutputSpace ) return sOutputPixel; } -Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, ColorSpace space ) +Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, Int color_space ) { Pixel pixel_value; switch( m_iPixelFormat ) @@ -491,7 +491,7 @@ Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, ColorSpace space ) default: break; } - ConvertPixel( pixel_value, space ); + ConvertPixel( pixel_value, color_space ); return pixel_value; } diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 743cb66..11379a2 100755 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -56,6 +56,15 @@ public: PlaYUVerFrame( UInt width = 0, UInt height = 0, Int pel_format = 0 ); ~PlaYUVerFrame(); + enum ColorSpace + { + COLOR_INVALID = -1, + COLOR_YUV = 0, + COLOR_RGB, + COLOR_ARGB, + COLOR_GRAY, + }; + enum PixelFormats { NO_FMT = -1, @@ -68,6 +77,26 @@ public: NUMBER_FORMATS }; + static Int isRGBorYUVorGray( Int pixel_format ) + { + switch( pixel_format ) + { + case GRAY: + return COLOR_GRAY; + break; + case YUV420p: + case YUV444p: + case YUV422p: + case YUYV422: + return COLOR_YUV; + break; + case RGB8: + return COLOR_RGB; + break; + } + return COLOR_INVALID; + } + static QStringList supportedPixelFormatList() { QStringList formats; @@ -94,8 +123,8 @@ public: return m_pppcInputPel; } - static Pixel ConvertPixel( Pixel sInputPixel, ColorSpace eOutputSpace ); - Pixel getPixelValue( const QPoint &pos, ColorSpace color ); + static Pixel ConvertPixel( Pixel sInputPixel, Int eOutputSpace ); + Pixel getPixelValue( const QPoint &pos, Int color ); UChar* getQImageBuffer() const {