Add function to return current format and set initial parameters
This commit is contained in:
1 parent
a10963ce13
commit
cd5b92f41b
3 files changed
+64
-44
No files matched your search
+59
-41
@@ -111,47 +111,6 @@ QStringList InputStream::supportedWriteFormatsList()
|
|||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
|
|
||||||
{
|
|
||||||
Bool bRet = false;
|
|
||||||
QString fileExtension = QFileInfo( filename ).completeSuffix();
|
|
||||||
if( !fileExtension.compare( "yuv" ) )
|
|
||||||
{
|
|
||||||
bRet = true;
|
|
||||||
// Guess resolution - match %dx%d
|
|
||||||
#if( QT_VERSION_PLAYUVER == 5 )
|
|
||||||
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*_" ).match( filename );
|
|
||||||
if( resolutionMatch.hasMatch() )
|
|
||||||
{
|
|
||||||
QString resolutionString = resolutionMatch.captured( 0 );
|
|
||||||
if( resolutionString.startsWith( "_" ) && resolutionString.endsWith( "_" ) )
|
|
||||||
{
|
|
||||||
resolutionString.remove( "_" );
|
|
||||||
QStringList resolutionArgs = resolutionString.split( "x" );
|
|
||||||
qDebug( ) << "Found resolution = "
|
|
||||||
<< resolutionArgs;
|
|
||||||
if( resolutionArgs.size() == 2 )
|
|
||||||
{
|
|
||||||
rWidth = resolutionArgs.at( 0 ).toUInt();
|
|
||||||
rHeight = resolutionArgs.at( 1 ).toUInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Guess pixel format
|
|
||||||
QStringList formats_list = PlaYUVerFrame::supportedPixelFormatList();
|
|
||||||
for( Int i = 0; i < formats_list.size(); i++ )
|
|
||||||
{
|
|
||||||
if( filename.contains( formats_list.at( i ), Qt::CaseInsensitive ) )
|
|
||||||
{
|
|
||||||
rInputFormat = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bool InputStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate )
|
Bool InputStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate )
|
||||||
{
|
{
|
||||||
Bool avStatus = false;
|
Bool avStatus = false;
|
||||||
@@ -264,6 +223,65 @@ Void InputStream::close()
|
|||||||
m_bInit = false;
|
m_bInit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Void InputStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
|
||||||
|
{
|
||||||
|
if( m_bInit )
|
||||||
|
{
|
||||||
|
rWidth = m_uiWidth;
|
||||||
|
rHeight = m_uiHeight;
|
||||||
|
rInputFormat = m_iPixelFormat;
|
||||||
|
rFrameRate = m_uiFrameRate;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rWidth = 0;
|
||||||
|
rHeight = 0;
|
||||||
|
rInputFormat = -1;
|
||||||
|
rFrameRate = 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
|
||||||
|
{
|
||||||
|
Bool bRet = false;
|
||||||
|
QString fileExtension = QFileInfo( filename ).completeSuffix();
|
||||||
|
if( !fileExtension.compare( "yuv" ) )
|
||||||
|
{
|
||||||
|
bRet = true;
|
||||||
|
// Guess resolution - match %dx%d
|
||||||
|
#if( QT_VERSION_PLAYUVER == 5 )
|
||||||
|
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*_" ).match( filename );
|
||||||
|
if( resolutionMatch.hasMatch() )
|
||||||
|
{
|
||||||
|
QString resolutionString = resolutionMatch.captured( 0 );
|
||||||
|
if( resolutionString.startsWith( "_" ) && resolutionString.endsWith( "_" ) )
|
||||||
|
{
|
||||||
|
resolutionString.remove( "_" );
|
||||||
|
QStringList resolutionArgs = resolutionString.split( "x" );
|
||||||
|
qDebug( ) << "Found resolution = "
|
||||||
|
<< resolutionArgs;
|
||||||
|
if( resolutionArgs.size() == 2 )
|
||||||
|
{
|
||||||
|
rWidth = resolutionArgs.at( 0 ).toUInt();
|
||||||
|
rHeight = resolutionArgs.at( 1 ).toUInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// Guess pixel format
|
||||||
|
QStringList formats_list = PlaYUVerFrame::supportedPixelFormatList();
|
||||||
|
for( Int i = 0; i < formats_list.size(); i++ )
|
||||||
|
{
|
||||||
|
if( filename.contains( formats_list.at( i ), Qt::CaseInsensitive ) )
|
||||||
|
{
|
||||||
|
rInputFormat = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
Void InputStream::readNextFrame()
|
Void InputStream::readNextFrame()
|
||||||
{
|
{
|
||||||
UInt64 bytes_read = 0;
|
UInt64 bytes_read = 0;
|
||||||
|
|||||||
@@ -104,12 +104,12 @@ public:
|
|||||||
YUVFormat = 0, // Use color space.
|
YUVFormat = 0, // Use color space.
|
||||||
};
|
};
|
||||||
|
|
||||||
Bool needFormatDialog( QString filename );
|
|
||||||
Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
|
||||||
|
|
||||||
Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate );
|
Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate );
|
||||||
Void close();
|
Void close();
|
||||||
|
|
||||||
|
Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||||
|
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||||
|
|
||||||
Void readNextFrame();
|
Void readNextFrame();
|
||||||
|
|
||||||
Bool writeFrame( const QString& filename );
|
Bool writeFrame( const QString& filename );
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
|
|||||||
UInt Width = 0, Height = 0, FrameRate = 30;
|
UInt Width = 0, Height = 0, FrameRate = 30;
|
||||||
Int InputFormat = -1;
|
Int InputFormat = -1;
|
||||||
|
|
||||||
|
m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate );
|
||||||
|
|
||||||
if( m_pCurrStream->guessFormat( fileName, Width, Height, InputFormat, FrameRate ) )
|
if( m_pCurrStream->guessFormat( fileName, Width, Height, InputFormat, FrameRate ) )
|
||||||
{
|
{
|
||||||
ConfigureFormatDialog formatDialog( this );
|
ConfigureFormatDialog formatDialog( this );
|
||||||
|
|||||||
Reference in new issue
Block a user