Remove more qt dependencies from PlaYUVerStream
Missing format name and file information
This commit is contained in:
@@ -470,7 +470,7 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
|
||||
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
|
||||
|
||||
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName, Width, Height, InputFormat, FrameRate, false ) )
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, FrameRate, false ) )
|
||||
{
|
||||
delete pcCurrModuleIf->m_pcModuleStream;
|
||||
pcCurrModuleIf->m_pcModuleStream = NULL;
|
||||
|
||||
+3
-1
@@ -235,7 +235,9 @@ Void VideoHandle::update()
|
||||
total_frame_num = getMaxFrameNumber();
|
||||
|
||||
resolution.append( QString( "@%1" ).arg( pcStream->getFrameRate() ) );
|
||||
m_pcFormatCodeLabel->setText( QString( "%1 | %2" ).arg( pcStream->getFormatName() ).arg( pcStream->getCodecName() ) );
|
||||
m_pcFormatCodeLabel->setText( QString( "%1 | %2" )
|
||||
.arg( QString::fromStdString( pcStream->getFormatName() ) )
|
||||
.arg( QString::fromStdString( pcStream->getCodecName() ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+113
-6
@@ -123,7 +123,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
if( m_pCurrStream )
|
||||
m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate );
|
||||
|
||||
if( m_pCurrStream->guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
|
||||
if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
|
||||
{
|
||||
ConfigureFormatDialog formatDialog( this );
|
||||
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, FrameRate ) == QDialog::Rejected )
|
||||
@@ -144,7 +144,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
m_pCurrStream = new PlaYUVerStream;
|
||||
}
|
||||
|
||||
m_pCurrStream->open( cFilename, Width, Height, InputFormat, FrameRate );
|
||||
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, FrameRate );
|
||||
|
||||
m_sStreamInfo.m_cFilename = cFilename;
|
||||
m_sStreamInfo.m_uiWidth = Width;
|
||||
@@ -160,7 +160,12 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
|
||||
|
||||
m_cFilename = cFilename;
|
||||
m_cWindowShortName = QFileInfo( cFilename ).fileName();
|
||||
//setWindowName( m_pCurrStream->getStreamInformationString() );
|
||||
QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() );
|
||||
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pCurrStream->getPelFmtName() );
|
||||
m_cStreamInformationString = "[" + m_cFormatName + " / " + m_cCodedName + " / " + m_cPelFmtName + "] ";
|
||||
m_cStreamInformationString += QFileInfo( m_cFilename ).fileName();
|
||||
|
||||
setWindowName( m_cWindowShortName );
|
||||
return true;
|
||||
}
|
||||
@@ -172,7 +177,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
|
||||
m_pCurrStream = new PlaYUVerStream;
|
||||
}
|
||||
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename, streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, streamInfo->m_uiFrameRate ) )
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, streamInfo->m_uiFrameRate ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -187,11 +192,113 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
|
||||
|
||||
m_cFilename = streamInfo->m_cFilename;
|
||||
m_cWindowShortName = QFileInfo( streamInfo->m_cFilename ).fileName();
|
||||
//setWindowName( m_pCurrStream->getStreamInformationString() );
|
||||
QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() );
|
||||
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pCurrStream->getPelFmtName() );
|
||||
m_cStreamInformationString = "[" + m_cFormatName + " / " + m_cCodedName + " / " + m_cPelFmtName + "] ";
|
||||
m_cStreamInformationString += QFileInfo( m_cFilename ).fileName();
|
||||
|
||||
setWindowName( m_cWindowShortName );
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
|
||||
{
|
||||
std::vector<PlaYUVerStdResolution> stdResList = PlaYUVerStream::stdResolutionSizes();
|
||||
Bool bGuessed = true;
|
||||
Bool bGuessedByFilesize = false;
|
||||
QString FilenameShort = QFileInfo( filename ).fileName();
|
||||
QString fileExtension = QFileInfo( filename ).suffix();
|
||||
if( !fileExtension.compare( "yuv" ) )
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
QVector<std::string> formats_list = QVector<std::string>::fromStdVector( PlaYUVerFrame::supportedPixelFormatListNames() );
|
||||
for( Int i = 0; i < formats_list.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list.at( i ).data(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( rWidth == 0 || rHeight == 0 )
|
||||
{
|
||||
// Guess resolution - match resolution name
|
||||
Int iMatch = -1;
|
||||
for( UInt i = 0; i < stdResList.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) )
|
||||
{
|
||||
iMatch = i;
|
||||
}
|
||||
}
|
||||
if( iMatch >= 0 )
|
||||
{
|
||||
rWidth = stdResList[iMatch].uiWidth;
|
||||
rHeight = stdResList[iMatch].uiHeight;
|
||||
}
|
||||
// Guess resolution - match %dx%d
|
||||
#if( QT_VERSION_PLAYUVER == 5 )
|
||||
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
if( resolutionMatch.hasMatch() )
|
||||
{
|
||||
QString resolutionString = resolutionMatch.captured( 0 );
|
||||
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
|
||||
{
|
||||
resolutionString.remove( "_" );
|
||||
QStringList resolutionArgs = resolutionString.split( "x" );
|
||||
if( resolutionArgs.size() == 2 )
|
||||
{
|
||||
rWidth = resolutionArgs.at( 0 ).toUInt();
|
||||
rHeight = resolutionArgs.at( 1 ).toUInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Guess resolution by file size
|
||||
if( rWidth == 0 && rHeight == 0 )
|
||||
{
|
||||
Char *filename_char = new char[filename.length() + 1];
|
||||
memcpy( filename_char, filename.toUtf8().constData(), filename.length() + 1 * sizeof(char) );
|
||||
FILE* pF = fopen( filename_char, "rb" );
|
||||
if( pF )
|
||||
{
|
||||
fseek( pF, 0, SEEK_END );
|
||||
UInt64 uiFileSize = ftell( pF );
|
||||
fclose( pF );
|
||||
delete[] filename_char;
|
||||
|
||||
Int count = 0, module, frame_bytes, match;
|
||||
for( UInt i = 0; i < stdResList.size(); i++ )
|
||||
{
|
||||
frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat );
|
||||
module = uiFileSize % frame_bytes;
|
||||
if( module == 0 )
|
||||
{
|
||||
match = i;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if( count == 1 )
|
||||
{
|
||||
rWidth = stdResList[match].uiWidth;
|
||||
rHeight = stdResList[match].uiHeight;
|
||||
bGuessedByFilesize = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 )
|
||||
bGuessed = true && !bGuessedByFilesize;
|
||||
}
|
||||
return !bGuessed;
|
||||
}
|
||||
|
||||
|
||||
Void VideoSubWindow::updateSelectedArea( QRect area )
|
||||
{
|
||||
m_cSelectedArea = area;
|
||||
@@ -273,7 +380,7 @@ Bool VideoSubWindow::save( QString filename )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
iRet = PlaYUVerStream::saveFrame( filename, saveFrame );
|
||||
iRet = PlaYUVerStream::saveFrame( filename.toStdString(), saveFrame );
|
||||
QApplication::restoreOverrideCursor();
|
||||
return iRet;
|
||||
}
|
||||
|
||||
@@ -64,13 +64,14 @@ private:
|
||||
|
||||
ViewArea* m_cViewArea;
|
||||
|
||||
QString m_cFilename;
|
||||
QString m_cStreamInformationString;
|
||||
PlaYUVerStreamInfo m_sStreamInfo;
|
||||
|
||||
PlaYUVerStream* m_pCurrStream;
|
||||
|
||||
PlaYUVerFrame* m_pcCurrFrame;
|
||||
QRect m_cSelectedArea;
|
||||
|
||||
QString m_cFilename;
|
||||
//PlaYUVerAppModuleIf* m_pcCurrentModule;
|
||||
QList<PlaYUVerAppModuleIf*> m_apcCurrentModule;
|
||||
|
||||
@@ -82,7 +83,7 @@ private:
|
||||
Bool m_bIsPlaying;
|
||||
Bool m_bIsModule;
|
||||
|
||||
|
||||
static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||
|
||||
/**
|
||||
* Private zoom function to handle
|
||||
|
||||
@@ -96,7 +96,6 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt&
|
||||
frame = NULL;
|
||||
m_bHasStream = false;
|
||||
|
||||
char *src_filename = filename;
|
||||
AVDictionary *format_opts = NULL;
|
||||
|
||||
/* register all formats and codecs */
|
||||
@@ -117,7 +116,7 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt&
|
||||
}
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if( avformat_open_input( &fmt_ctx, src_filename, NULL, &format_opts ) < 0 )
|
||||
if( avformat_open_input( &fmt_ctx, filename, NULL, &format_opts ) < 0 )
|
||||
{
|
||||
//qDebug( ) << " Could not open source file %s !!!" << filename << endl;
|
||||
return false;
|
||||
@@ -198,7 +197,7 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt&
|
||||
}
|
||||
|
||||
/* dump input information to stderr */
|
||||
av_dump_format( fmt_ctx, 0, src_filename, 0 );
|
||||
av_dump_format( fmt_ctx, 0, filename, 0 );
|
||||
if( !video_stream )
|
||||
{
|
||||
//qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl;
|
||||
|
||||
+11
-104
@@ -28,6 +28,8 @@
|
||||
#include "LibMemory.h"
|
||||
#include "PlaYUVerStream.h"
|
||||
#include <QImage>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#ifdef USE_FFMPEG
|
||||
#include "LibAvContextHandle.h"
|
||||
#endif
|
||||
@@ -181,7 +183,6 @@ PlaYUVerStream::PlaYUVerStream()
|
||||
m_iFileFormat = -1;
|
||||
m_pStreamBuffer = NULL;
|
||||
m_cFilename = "";
|
||||
m_cStreamInformationString = "";
|
||||
m_pcCurrFrame = NULL;
|
||||
m_pcNextFrame = NULL;
|
||||
m_ppcFrameBuffer = NULL;
|
||||
@@ -204,6 +205,8 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
|
||||
close();
|
||||
}
|
||||
|
||||
QString qtFilename = QString::fromStdString( filename );
|
||||
|
||||
m_bInit = false;
|
||||
m_bIsInput = bInput;
|
||||
m_cFilename = filename;
|
||||
@@ -217,7 +220,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
|
||||
m_iFileFormat = INVALID_HANDLER;
|
||||
|
||||
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
|
||||
QString currExt = QFileInfo( QString::fromStdString( m_cFilename ) ).suffix();
|
||||
QString currExt = QFileInfo( qtFilename ).suffix();
|
||||
if( formatsExt.contains( currExt ) )
|
||||
{
|
||||
m_iFileFormat = formatsExt.indexOf( currExt );
|
||||
@@ -339,8 +342,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
|
||||
}
|
||||
|
||||
m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].data();
|
||||
m_cStreamInformationString = "[" + m_cFormatName + " / " + m_cCodedName + " / " + m_cPelFmtName + "] ";
|
||||
m_cStreamInformationString += QFileInfo( QString::fromStdString( m_cFilename ) ).fileName().toStdString();
|
||||
|
||||
m_iCurrFrameNum = -1;
|
||||
|
||||
m_bInit = true;
|
||||
@@ -420,102 +422,6 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat,
|
||||
}
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate )
|
||||
{
|
||||
std::vector<PlaYUVerStdResolution> stdResList = stdResolutionSizes();
|
||||
Bool bGuessed = true;
|
||||
Bool bGuessedByFilesize = false;
|
||||
QString FilenameShort = QFileInfo( filename ).fileName();
|
||||
QString fileExtension = QFileInfo( filename ).suffix();
|
||||
if( !fileExtension.compare( "yuv" ) )
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
QVector<std::string> formats_list = QVector<std::string>::fromStdVector( PlaYUVerFrame::supportedPixelFormatListNames() );
|
||||
for( Int i = 0; i < formats_list.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list.at( i ).data(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( rWidth == 0 || rHeight == 0 )
|
||||
{
|
||||
// Guess resolution - match resolution name
|
||||
Int iMatch = -1;
|
||||
for( UInt i = 0; i < stdResList.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) )
|
||||
{
|
||||
iMatch = i;
|
||||
}
|
||||
}
|
||||
if( iMatch >= 0 )
|
||||
{
|
||||
rWidth = stdResList[iMatch].uiWidth;
|
||||
rHeight = stdResList[iMatch].uiHeight;
|
||||
}
|
||||
// Guess resolution - match %dx%d
|
||||
#if( QT_VERSION_PLAYUVER == 5 )
|
||||
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
|
||||
if( resolutionMatch.hasMatch() )
|
||||
{
|
||||
QString resolutionString = resolutionMatch.captured( 0 );
|
||||
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
|
||||
{
|
||||
resolutionString.remove( "_" );
|
||||
QStringList resolutionArgs = resolutionString.split( "x" );
|
||||
if( resolutionArgs.size() == 2 )
|
||||
{
|
||||
rWidth = resolutionArgs.at( 0 ).toUInt();
|
||||
rHeight = resolutionArgs.at( 1 ).toUInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Guess resolution by file size
|
||||
if( rWidth == 0 && rHeight == 0 )
|
||||
{
|
||||
Char *filename_char = new char[filename.length() + 1];
|
||||
memcpy( filename_char, filename.toUtf8().constData(), filename.length() + 1 * sizeof(char) );
|
||||
FILE* pF = fopen( filename_char, "rb" );
|
||||
if( pF )
|
||||
{
|
||||
fseek( pF, 0, SEEK_END );
|
||||
UInt64 uiFileSize = ftell( pF );
|
||||
fclose( pF );
|
||||
delete[] filename_char;
|
||||
|
||||
Int count = 0, module, frame_bytes, match;
|
||||
for( UInt i = 0; i < stdResList.size(); i++ )
|
||||
{
|
||||
frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat );
|
||||
module = uiFileSize % frame_bytes;
|
||||
if( module == 0 )
|
||||
{
|
||||
match = i;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if( count == 1 )
|
||||
{
|
||||
rWidth = stdResList[match].uiWidth;
|
||||
rHeight = stdResList[match].uiHeight;
|
||||
bGuessedByFilesize = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 )
|
||||
bGuessed = true && !bGuessedByFilesize;
|
||||
}
|
||||
return !bGuessed;
|
||||
}
|
||||
|
||||
Void PlaYUVerStream::loadAll()
|
||||
{
|
||||
if( m_bLoadAll || !m_bIsInput )
|
||||
@@ -652,17 +558,18 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame )
|
||||
return;
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::saveFrame( const QString& filename )
|
||||
Bool PlaYUVerStream::saveFrame( const std::string& filename )
|
||||
{
|
||||
return saveFrame( filename, m_pcCurrFrame );
|
||||
}
|
||||
|
||||
Bool PlaYUVerStream::saveFrame( const QString& filename, PlaYUVerFrame *saveFrame )
|
||||
Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame )
|
||||
{
|
||||
QString qtString = QString::fromStdString( filename );
|
||||
Int iFileFormat = INVALID_OUTPUT;
|
||||
|
||||
QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt();
|
||||
QString currExt = QFileInfo( filename ).suffix();
|
||||
QString currExt = QFileInfo( qtString ).suffix();
|
||||
if( formatsExt.contains( currExt ) )
|
||||
{
|
||||
iFileFormat = formatsExt.indexOf( currExt );
|
||||
@@ -683,7 +590,7 @@ Bool PlaYUVerStream::saveFrame( const QString& filename, PlaYUVerFrame *saveFram
|
||||
{
|
||||
saveFrame->fillRGBBuffer();
|
||||
QImage qimg = QImage( saveFrame->getRGBBuffer(), saveFrame->getWidth(), saveFrame->getHeight(), QImage::Format_RGB32 );
|
||||
return qimg.save( filename );
|
||||
return qimg.save( qtString );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "PlaYUVerDefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <QtCore>
|
||||
#include <QStringList>
|
||||
#include "PlaYUVerFrame.h"
|
||||
|
||||
namespace plaYUVer
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
std::string m_cFormatName;
|
||||
std::string m_cCodedName;
|
||||
std::string m_cPelFmtName;
|
||||
QString m_cStreamInformationString;
|
||||
|
||||
|
||||
FILE* m_pFile; /**< The input file pointer >*/
|
||||
Int m_iFileFormat;
|
||||
@@ -117,8 +117,6 @@ public:
|
||||
Bool openFile();
|
||||
Void closeFile();
|
||||
|
||||
static Bool guessFormat( std::string filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||
|
||||
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
|
||||
|
||||
Void loadAll();
|
||||
@@ -143,10 +141,6 @@ public:
|
||||
return m_bInit;
|
||||
}
|
||||
|
||||
QString getStreamInformationString()
|
||||
{
|
||||
return m_cStreamInformationString;
|
||||
}
|
||||
std::string getFileName()
|
||||
{
|
||||
return m_cFilename;
|
||||
|
||||
Reference in New Issue
Block a user