From 26cd949d9a2a34ff05ebbe8e7a7cc7cbc099bd8f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 15 Dec 2016 16:51:13 +0000 Subject: [PATCH] Add guessing for endianness --- app/VideoSubWindow.cpp | 44 ++++++++++++++++++++++++++++-------------- app/VideoSubWindow.h | 7 ++++++- lib/PlaYUVerDefs.h | 7 +++++++ 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index bdf6eee..718d43e 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -428,7 +428,7 @@ Void VideoSubWindow::updateVideoWindowInfo() } } -Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel ) +Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, Int& rEndianness ) { std::vector stdResList = PlaYUVerStream::stdResolutionSizes(); Bool bGuessed = true; @@ -488,19 +488,6 @@ 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 } @@ -534,6 +521,35 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, } } + // Guess bits per pixel - match %dbpp +#if( QT_VERSION_PLAYUVER == 5 ) + 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 + + // Guess Endianness + if( rEndianness == -1 ) + { + if( FilenameShort.contains( QStringLiteral( "be" ), Qt::CaseInsensitive ) ) + { + rEndianness = PLAYUVER_BIG_ENDIAN; + } + if( FilenameShort.contains( QStringLiteral( "le" ), Qt::CaseInsensitive ) ) + { + rEndianness = PLAYUVER_LITTLE_ENDIAN; + } + } + if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 ) bGuessed = true && !bGuessedByFilesize; } diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index b803912..badbb44 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& rBitsPerPixel ); + static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, Int& rEndianness ); /** * Private zoom function to handle @@ -164,6 +164,11 @@ public: return m_pCurrStream; } + PlaYUVerStream* getCurrStream() + { + return m_pCurrStream; + } + PlaYUVerFrame* getCurrFrame() { return m_pcCurrFrame; diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 647541d..7461c49 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -115,6 +115,13 @@ enum RGBcomponent COLOR_A, }; +enum Endianness +{ + PLAYUVER_BIG_ENDIAN = 0, + PLAYUVER_LITTLE_ENDIAN = 1, +}; + + inline String lowercase( const String& in ) { String out;