From ed0b967234a97da402e4fa5370e49a5590329457 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 18 Nov 2016 17:41:09 +0000 Subject: [PATCH] Add RGB planar format and try to guess bpp --- app/VideoSubWindow.cpp | 20 +++++++++++++++++--- app/VideoSubWindow.h | 2 +- lib/PlaYUVerFrame.h | 1 + lib/PlaYUVerFramePixelFormats.cpp | 24 +++++++++++++++++++----- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 04a46a1..f3c6f65 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -317,7 +317,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) m_pCurrStream = new PlaYUVerStream; } - if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) + if( guessFormat( cFilename, Width, Height, InputFormat, BitsPel ) || bForceDialog ) { if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ) == QDialog::Rejected ) @@ -428,7 +428,7 @@ Void VideoSubWindow::updateVideoWindowInfo() } } -Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel ) { std::vector stdResList = PlaYUVerStream::stdResolutionSizes(); Bool bGuessed = true; @@ -470,8 +470,9 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, rWidth = stdResList[iMatch].uiWidth; rHeight = stdResList[iMatch].uiHeight; } - // Guess resolution - match %dx%d + #if( QT_VERSION_PLAYUVER == 5 ) + // Guess resolution - match %dx%d QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort ); if( resolutionMatch.hasMatch() ) { @@ -487,6 +488,19 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, } } } + // Guess bits per pixel - match %dbpp + QRegularExpressionMatch BppMatch = QRegularExpression( "_\\d*bpp" ).match( FilenameShort ); + if( BppMatch.hasMatch() ) + { + QString matchString = BppMatch.captured( 0 ); + matchString.remove( "_" ); + matchString.remove( "bpp" ); + rBitsPerPixel = matchString.toUInt(); + if( !( rBitsPerPixel > 0 && rBitsPerPixel < 16 ) ) + { + rBitsPerPixel = -1; + } + } #endif } diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index c448eca..b803912 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -103,7 +103,7 @@ private: Void refreshFrameOperation(); - static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel ); /** * Private zoom function to handle diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index dbe26bb..654d3ac 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -58,6 +58,7 @@ public: YUV422p, YUYV422, GRAY, + RGBp, RGB24, BGR24, NUMBER_PEL_FORMATS diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp index 2bd4374..07c3b9e 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PlaYUVerFramePixelFormats.cpp @@ -268,7 +268,21 @@ const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NU { { 0, 0, 1 } }, /* Y */ }, { - "RGB24", + "RGBp", + PlaYUVerPixel::COLOR_RGB, + 3, + 3, + 0, + 0, + ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), + { + { 0, 0, 1 }, /* R */ + { 1, 0, 1 }, /* G */ + { 2, 0, 1 }, /* B */ + }, + }, + { + "RGB", PlaYUVerPixel::COLOR_RGB, 3, 1, @@ -282,7 +296,7 @@ const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NU }, }, { - "BGR24", + "BGR", PlaYUVerPixel::COLOR_RGB, 3, 1, @@ -290,9 +304,9 @@ const PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PlaYUVerFrame::NU 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), { - { 0, 2, 3}, /* R */ - { 0, 2, 2}, /* G */ - { 0, 2, 1}, /* B */ + { 0, 2, 3}, /* B */ + { 0, 2, 2}, /* R */ + { 0, 2, 1}, /* G */ }, } };