Start removing Qt from PlaYUVStream. Too much incomplete

This commit is contained in:
jfmcarreira committed 2015-01-28 19:42:10 +00:00
1 parent 0164d2a5c0
commit c34007f9b3
6 files changed
+207 -201

No files matched your search

+12 -5
View File
@@ -41,11 +41,18 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
menusFont.setBold( true );
menusFont.setWeight( 75 );
// Config dialog
struct PlaYUVerStream::StandardResolution stdRes = PlaYUVerStream::standardResolutionSizes();
standardResolutionNames = stdRes.stringListFullName;
standardResolutionSizes = stdRes.sizeResolution;
QString Name;
UInt uiWidth, uiHeight;
std::vector<PlaYUVerStdResolution> listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes();
for( UInt i = 0; i < listPlaYUVerStdResolution.size(); i++ )
{
Name = QString::fromStdString( listPlaYUVerStdResolution[i].shortName );
uiWidth = listPlaYUVerStdResolution[i].uiWidth;
uiHeight = listPlaYUVerStdResolution[i].uiHeight;
standardResolutionNames.append( QString( "%1 (%2x%3)" ).arg( Name ).arg( uiWidth ).arg( uiHeight ) );
standardResolutionSizes.append( QSize( uiWidth, uiHeight) );
}
setObjectName( QStringLiteral( "ConfigureFormat" ) );
resize( 400, 370 );
@@ -150,7 +157,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
m_comboBoxPixelFormat->setSizePolicy( sizePolicyPixelFormat );
m_comboBoxPixelFormat->setAcceptDrops( true );
m_comboBoxPixelFormat->clear();
for( UInt i=0; i<PlaYUVerFrame::supportedPixelFormatListNames().size();i++ )
for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ )
{
m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].data() );
}
+1 -1
View File
@@ -83,7 +83,7 @@ Void LibAvContextHandle::closeAvFormat()
m_bHasStream = false;
}
Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames )
Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames )
{
fmt_ctx = NULL;
video_dec_ctx = NULL;
+1 -1
View File
@@ -56,7 +56,7 @@ public:
m_bHasStream( false )
{
}
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames );
Bool initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames );
Void closeAvFormat();
Bool decodeAvFormat();
-11
View File
@@ -25,9 +25,6 @@
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__
#ifdef PLAYUVER
#include "config.h"
#endif
#include <string>
namespace plaYUVer
@@ -100,14 +97,6 @@ typedef UChar Pel; ///< 8-bit pixel type
#define xFree( ptr ) free ( ptr )
#endif
// ====================================================================================================================
// Qt functions
// ====================================================================================================================
#if( QT_VERSION_PLAYUVER == 4 )
#define QStringLiteral QString::fromUtf8
#endif
// ====================================================================================================================
// PlaYUVer definitions
// ====================================================================================================================
+156 -41
View File
@@ -24,6 +24,7 @@
#include "config.h"
#include <cstdio>
#include <vector>
#include "LibMemory.h"
#include "PlaYUVerStream.h"
#include <QImage>
@@ -34,6 +35,134 @@
namespace plaYUVer
{
enum PlaYUVerStreamInputFormats
{
INVALID_INPUT = -1,
YUVINPUT = 0,
#ifdef USE_FFMPEG
AVIINPUT,
MP4INPUT,
WMVINPUT,
PGMINPUT,
PNGINPUT,
BMPINPUT,
JPEGINPUT,
#endif
TOTAL_INPUT_FORMATS
};
QStringList PlaYUVerStream::supportedReadFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv"
// Raw video
#ifdef USE_FFMPEG
<< "avi"
// Audio video interleaved
<< "mp4"
// MP4
<< "wmv"
// Windows media video
<< "pgm"
<< "png"
<< "bmp"
<< "jpg"
#endif
;
//assert( formatsExt.size() == TOTAL_INPUT_FORMATS );
return formatsExt;
}
QStringList PlaYUVerStream::supportedReadFormatsName()
{
QStringList formatsName;
formatsName << "Raw video"
#ifdef USE_FFMPEG
<< "Audio video interleaved"
<< "MPEG4"
<< "Windows media video"
<< "Portable Grayscale Map"
<< "Portable Network Graphics"
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
#endif
;
//assert( formatsName.size() == TOTAL_INPUT_FORMATS );
return formatsName;
}
enum PlaYUVerStreamOutputFormats
{
INVALID_OUTPUT = -1,
YUVOUTPUT = 0,
TOTAL_OUTPUT_FORMATS
};
QStringList PlaYUVerStream::supportedWriteFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv" // raw video
;
assert( formatsExt.size() == TOTAL_OUTPUT_FORMATS );
return formatsExt;
}
QStringList PlaYUVerStream::supportedWriteFormatsName()
{
QStringList formatsName;
formatsName << "Raw video";
assert( formatsName.size() == TOTAL_OUTPUT_FORMATS );
return formatsName;
}
QStringList PlaYUVerStream::supportedSaveFormatsExt()
{
QStringList formatsExt;
formatsExt << supportedWriteFormatsExt()
<< "bmp"
<< "jpeg"
<< "png" // portable network graphics
;
formatsExt.removeDuplicates();
return formatsExt;
}
QStringList PlaYUVerStream::supportedSaveFormatsName()
{
QStringList formatsName;
formatsName << supportedWriteFormatsName()
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
<< "Portable Network Graphics";
formatsName.removeDuplicates();
return formatsName;
}
#define REGIST_PLAYUVER_STANDARD_RESOLUTION( name, width, height) \
stdResElement.shortName = name; \
stdResElement.uiWidth = width; \
stdResElement.uiHeight = height; \
stdResList.push_back( stdResElement );
std::vector<PlaYUVerStdResolution> PlaYUVerStream::stdResolutionSizes()
{
std::vector<PlaYUVerStdResolution> stdResList;
PlaYUVerStdResolution stdResElement;
REGIST_PLAYUVER_STANDARD_RESOLUTION( "CIF", 352, 288 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "VGA", 640, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WVGA", 832, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "XVGA", 1024, 768 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "HD", 1280, 720 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA-", 1280, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA", 1280, 1024 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WSXGA", 1440, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "FullHD", 1920, 1080 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "8K", 8192, 4608 );
return stdResList;
}
PlaYUVerStream::PlaYUVerStream()
{
m_bInit = false;
@@ -49,10 +178,10 @@ PlaYUVerStream::PlaYUVerStream()
m_iCurrFrameNum = -1;
m_iPixelFormat = -1;
m_uiFrameRate = 30;
m_iFileFormat = INVALID_INPUT;
m_iFileFormat = -1;
m_pStreamBuffer = NULL;
m_cFilename = QString( "" );
m_cStreamInformationString = QString( "" );
m_cFilename = "";
m_cStreamInformationString = "";
m_pcCurrFrame = NULL;
m_pcNextFrame = NULL;
m_ppcFrameBuffer = NULL;
@@ -68,7 +197,7 @@ PlaYUVerStream::~PlaYUVerStream()
close();
}
Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput )
Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput )
{
if( m_bInit )
{
@@ -85,21 +214,21 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
if( m_bIsInput )
{
m_iFileFormat = INVALID_INPUT;
m_iFileFormat = INVALID_HANDLER;
QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt();
QString currExt = QFileInfo( filename ).suffix();
QString currExt = QFileInfo( QString::fromStdString( m_cFilename ) ).suffix();
if( formatsExt.contains( currExt ) )
{
m_iFileFormat = formatsExt.indexOf( currExt );
}
if( m_iFileFormat == INVALID_INPUT )
if( m_iFileFormat == INVALID_HANDLER )
{
close();
throw "Invalid file format";
return m_bInit;
}
m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper();
m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper().toStdString();
if( m_iFileFormat == YUVINPUT )
{
@@ -135,11 +264,11 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
#ifdef USE_FFMPEG
if( m_uiStreamHandler == FFMPEG )
{
if( !m_cLibAvContext->initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum ) )
if( !m_cLibAvContext->initAvFormat( m_cFilename.data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum ) )
{
throw "Cannot open file using FFmpeg libs";
}
m_cCodedName = QString::fromUtf8( m_cLibAvContext->getCodecName() ).toUpper();
m_cCodedName = m_cLibAvContext->getCodecName();
}
#endif
@@ -158,8 +287,8 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
throw "[PlaYUVerStream] Cannot open file";
return m_bInit;
}
m_cFormatName = QString::fromUtf8( "YUV" );
m_cCodedName = QString::fromUtf8( "Raw Video" );
m_cFormatName = "YUV";
m_cCodedName = "Raw Video";
}
getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize );
@@ -209,9 +338,9 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
return m_bInit;
}
QString pelFmtName( PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].data() );
m_cStreamInformationString = "[" + m_cFormatName + " / " + m_cCodedName + " / " + pelFmtName + "] " + QFileInfo( m_cFilename ).fileName();
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;
@@ -225,10 +354,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_
Bool PlaYUVerStream::openFile()
{
m_pFile = NULL;
Char *filename = new char[m_cFilename.length() + 1];
memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) );
m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" );
delete[] filename;
m_pFile = fopen( m_cFilename.data(), m_bIsInput ? "rb" : "wb" );
if( m_pFile == NULL )
{
return false;
@@ -254,7 +380,7 @@ Void PlaYUVerStream::close()
#ifdef USE_FFMPEG
if( m_uiStreamHandler == FFMPEG )
m_cLibAvContext->closeAvFormat();
delete m_cLibAvContext;
delete m_cLibAvContext;
#endif
if( m_ppcFrameBuffer )
@@ -296,6 +422,7 @@ 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();
@@ -318,28 +445,17 @@ Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
{
// Guess resolution - match resolution name
Int iMatch = -1;
QStringList stdResName = standardResolutionSizes().stringListName;
for( Int i = 0; i < stdResName.size(); i++ )
for( UInt i = 0; i < stdResList.size(); i++ )
{
if( FilenameShort.contains( stdResName.at( i ) ) )
if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) )
{
if( iMatch >= 0 )
{
if( stdResName.at( i ).size() > stdResName.at( iMatch ).size() )
{
iMatch = i;
}
}
else
{
iMatch = i;
}
iMatch = i;
}
}
if( iMatch >= 0 )
{
rWidth = standardResolutionSizes().sizeResolution.at( iMatch ).width();
rHeight = standardResolutionSizes().sizeResolution.at( iMatch ).height();
rWidth = stdResList[iMatch].uiWidth;
rHeight = stdResList[iMatch].uiHeight;
}
// Guess resolution - match %dx%d
#if( QT_VERSION_PLAYUVER == 5 )
@@ -375,10 +491,9 @@ Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
delete[] filename_char;
Int count = 0, module, frame_bytes, match;
QVector<QSize> sizeResolution = standardResolutionSizes().sizeResolution;
for( Int i = 0; i < sizeResolution.size(); i++ )
for( UInt i = 0; i < stdResList.size(); i++ )
{
frame_bytes = PlaYUVerFrame::getBytesPerFrame( sizeResolution.at( i ).width(), sizeResolution.at( i ).height(), rInputFormat );
frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
@@ -388,8 +503,8 @@ Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
}
if( count == 1 )
{
rWidth = sizeResolution.at( match ).width();
rHeight = sizeResolution.at( match ).height();
rWidth = stdResList[match].uiWidth;
rHeight = stdResList[match].uiHeight;
bGuessedByFilesize = true;
}
}
+37 -142
View File
@@ -36,6 +36,13 @@ namespace plaYUVer
class LibAvContextHandle;
typedef struct
{
std::string shortName;
UInt uiWidth;
UInt uiHeight;
} PlaYUVerStdResolution;
class PlaYUVerStream
{
private:
@@ -57,9 +64,10 @@ private:
UInt m_uiStreamHandler;
LibAvContextHandle* m_cLibAvContext;
QString m_cFilename;
QString m_cFormatName;
QString m_cCodedName;
std::string m_cFilename;
std::string m_cFormatName;
std::string m_cCodedName;
std::string m_cPelFmtName;
QString m_cStreamInformationString;
FILE* m_pFile; /**< The input file pointer >*/
@@ -81,138 +89,19 @@ private:
Int64 m_iCurrFrameNum;
public:
static QStringList supportedReadFormatsExt();
static QStringList supportedReadFormatsName();
static QStringList supportedWriteFormatsExt();
static QStringList supportedWriteFormatsName();
static QStringList supportedSaveFormatsExt();
static QStringList supportedSaveFormatsName();
static std::vector<PlaYUVerStdResolution> stdResolutionSizes();
PlaYUVerStream();
~PlaYUVerStream();
enum PlaYUVerStreamInputFormats
{
INVALID_INPUT = -1,
YUVINPUT = 0,
#ifdef USE_FFMPEG
AVIINPUT,
MP4INPUT,
WMVINPUT,
PGMINPUT,
PNGINPUT,
BMPINPUT,
JPEGINPUT,
#endif
TOTAL_INPUT_FORMATS
};
static QStringList supportedReadFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv" // Raw video
#ifdef USE_FFMPEG
<< "avi" // Audio video interleaved
<< "mp4"// MP4
<< "wmv"// Windows media video
<< "pgm"
<< "png"
<< "bmp"
<< "jpg"
#endif
;
assert( formatsExt.size() == TOTAL_INPUT_FORMATS );
return formatsExt;
}
static QStringList supportedReadFormatsName()
{
QStringList formatsName;
formatsName << "Raw video"
#ifdef USE_FFMPEG
<< "Audio video interleaved"
<< "MPEG4"
<< "Windows media video"
<< "Portable Grayscale Map"
<< "Portable Network Graphics"
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
#endif
;
assert( formatsName.size() == TOTAL_INPUT_FORMATS );
return formatsName;
}
enum PlaYUVerStreamOutputFormats
{
INVALID_OUTPUT = -1,
YUVOUTPUT = 0,
TOTAL_OUTPUT_FORMATS
};
static QStringList supportedWriteFormatsExt()
{
QStringList formatsExt;
formatsExt << "yuv" // raw video
;
assert( formatsExt.size() == TOTAL_OUTPUT_FORMATS );
return formatsExt;
}
static QStringList supportedWriteFormatsName()
{
QStringList formatsName;
formatsName << "Raw video";
assert( formatsName.size() == TOTAL_OUTPUT_FORMATS );
return formatsName;
}
static QStringList supportedSaveFormatsExt()
{
QStringList formatsExt;
formatsExt << supportedWriteFormatsExt()
<< "bmp"
<< "jpeg"
<< "png" // portable network graphics
;
formatsExt.removeDuplicates();
return formatsExt;
}
static QStringList supportedSaveFormatsName()
{
QStringList formatsName;
formatsName << supportedWriteFormatsName()
<< "Windows Bitmap"
<< "Joint Photographic Experts Group"
<< "Portable Network Graphics";
formatsName.removeDuplicates();
return formatsName;
}
#define REGIST_STANDARD_RESOLUTION( name, width, height) \
stdRes.stringListName.append( QString( name ) ); \
stdRes.stringListFullName.append( QString( "%1 (%2x%3)" ).arg( name ).arg( width ).arg( height ) ); \
stdRes.sizeResolution.append( QSize( width, height ) )
struct StandardResolution
{
QStringList stringListName;
QStringList stringListFullName;
QVector<QSize> sizeResolution;
};
static struct StandardResolution standardResolutionSizes()
{
struct StandardResolution stdRes;
REGIST_STANDARD_RESOLUTION( "CIF", 352, 288 );
REGIST_STANDARD_RESOLUTION( "VGA", 640, 480 );
REGIST_STANDARD_RESOLUTION( "WVGA", 832, 480 );
REGIST_STANDARD_RESOLUTION( "XVGA", 1024, 768 );
REGIST_STANDARD_RESOLUTION( "HD", 1280, 720 );
REGIST_STANDARD_RESOLUTION( "SXGA-", 1280, 900 );
REGIST_STANDARD_RESOLUTION( "SXGA", 1280, 1024 );
REGIST_STANDARD_RESOLUTION( "WSXGA", 1440, 900 );
REGIST_STANDARD_RESOLUTION( "FullHD", 1920, 1080 );
REGIST_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 );
REGIST_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 );
REGIST_STANDARD_RESOLUTION( "8K", 8192, 4608 );
return stdRes;
}
enum PlaYUVerStreamErrors
{
NO_STREAM_ERROR = 0,
@@ -222,13 +111,13 @@ public:
END_OF_SEQ,
};
Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true );
Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true );
Void close();
Bool openFile();
Void closeFile();
static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
static Bool guessFormat( std::string filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate );
@@ -238,8 +127,8 @@ public:
Void writeFrame();
Void writeFrame( PlaYUVerFrame *pcFrame );
Bool saveFrame( const QString& filename );
static Bool saveFrame( const QString& filename, PlaYUVerFrame *saveFrame );
Bool saveFrame( const std::string& filename );
static Bool saveFrame( const std::string& filename, PlaYUVerFrame *saveFrame );
Void setNextFrame();
PlaYUVerFrame* getCurrFrame();
@@ -253,22 +142,28 @@ public:
{
return m_bInit;
}
QString getFileName()
{
return m_cFilename;
}
QString getStreamInformationString()
{
return m_cStreamInformationString;
}
QString getFormatName()
std::string getFileName()
{
return m_cFilename;
}
std::string getFormatName()
{
return m_cFormatName;
}
QString getCodecName()
std::string getCodecName()
{
return m_cCodedName;
}
std::string getPelFmtName()
{
return m_cPelFmtName;
}
UInt getFrameNum()
{
return m_uiTotalFrameNum;