Further development to support different formats. Currently only YUV420
is supported
This commit is contained in:
1 parent
f82a625790
commit
eff1e41cea
4 files changed
+85
-55
No files matched your search
@@ -58,6 +58,11 @@ public:
|
||||
return QSize( widthSpinBox->value(), heightSpinBox->value() );
|
||||
}
|
||||
|
||||
Int getPixelFormat()
|
||||
{
|
||||
pixelFormatBox->currentIndex();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void StandardResolutionSelection();
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ ImageInterface::ImageInterface( QWidget * parent ) :
|
||||
// Define the cViewArea as the widget inside the scroll area
|
||||
m_cScrollArea->setWidget( m_cViewArea );
|
||||
|
||||
|
||||
m_cCurrFileName = QString( "" );
|
||||
m_dScaleFactor = 1;
|
||||
|
||||
@@ -75,7 +74,7 @@ bool ImageInterface::loadFile( const QString &fileName )
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height() );
|
||||
m_currStream.init( fileName, formatDialog.getResolution().width(), formatDialog.getResolution().height(), formatDialog.getPixelFormat() );
|
||||
|
||||
if( m_currStream.getStatus() == 0 )
|
||||
{
|
||||
@@ -182,8 +181,8 @@ Void ImageInterface::adjustScrollBar( Double factor )
|
||||
|
||||
QSize ImageInterface::sizeHint() const
|
||||
{
|
||||
QSize maxSize; // The size of the parent (viewport widget
|
||||
// of the QMdiArea).
|
||||
QSize maxSize; // The size of the parent (viewport widget
|
||||
// of the QMdiArea).
|
||||
|
||||
QWidget *p = parentWidget();
|
||||
if( p )
|
||||
|
||||
+62
-43
@@ -42,7 +42,7 @@ InputStream::InputStream()
|
||||
m_pppcInputPel[2] = NULL;
|
||||
m_pppcRGBPel = NULL;
|
||||
|
||||
m_eFormat = INVALID;
|
||||
m_iFileFormat = INVALID;
|
||||
}
|
||||
|
||||
InputStream::~InputStream()
|
||||
@@ -82,11 +82,11 @@ QStringList InputStream::supportedReadFormatsList()
|
||||
QStringList InputStream::supportedPixelFormatList()
|
||||
{
|
||||
QStringList formats;
|
||||
formats << "YUV420" << "YUV444";
|
||||
formats << "YUV420" << "YUV400";
|
||||
return formats;
|
||||
}
|
||||
|
||||
Void InputStream::init( QString filename, UInt width, UInt height )
|
||||
Void InputStream::init( QString filename, UInt width, UInt height, Int input_format )
|
||||
{
|
||||
|
||||
if( width <= 0 || height <= 0 )
|
||||
@@ -106,7 +106,8 @@ Void InputStream::init( QString filename, UInt width, UInt height )
|
||||
m_uiWidth = width;
|
||||
m_uiHeight = height;
|
||||
|
||||
m_eFormat = YUV_420p;
|
||||
m_iFileFormat = YUVFormat;
|
||||
m_iPixelFormat = input_format;
|
||||
|
||||
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
|
||||
UInt64 alloc_memory;
|
||||
@@ -115,23 +116,39 @@ Void InputStream::init( QString filename, UInt width, UInt height )
|
||||
m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input );
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[0] ), m_uiHeight, m_uiWidth );
|
||||
if( !alloc_memory )
|
||||
if( m_iFileFormat == YUVFormat )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[1] ), m_uiHeight / 2, m_uiWidth / 2 );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[2] ), m_uiHeight / 2, m_uiWidth / 2 );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
switch( m_iPixelFormat )
|
||||
{
|
||||
case YUV420:
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[0] ), m_uiHeight, m_uiWidth );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[1] ), m_uiHeight / 2, m_uiWidth / 2 );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[2] ), m_uiHeight / 2, m_uiWidth / 2 );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case YUV400:
|
||||
alloc_memory = get_mem2Dpel( &( m_pppcInputPel[0] ), m_uiHeight, m_uiWidth );
|
||||
if( !alloc_memory )
|
||||
{
|
||||
//Error
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
get_mem3Dpel( &m_pppcRGBPel, 3, m_uiHeight, m_uiWidth );
|
||||
@@ -235,37 +252,39 @@ Void InputStream::readFrame()
|
||||
{
|
||||
UInt64 bytes_read = 0;
|
||||
|
||||
|
||||
if( m_iStatus == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UInt64 frame_bytes_input = m_uiWidth * m_uiHeight * 1.5;
|
||||
|
||||
bytes_read = fread( &( m_pppcInputPel[0][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight ) )
|
||||
switch( m_iPixelFormat )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
case YUV420:
|
||||
bytes_read = fread( &( m_pppcInputPel[0][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight ) )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
}
|
||||
bytes_read = fread( &( m_pppcInputPel[1][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
}
|
||||
bytes_read = fread( &( m_pppcInputPel[2][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
}
|
||||
YUV420toRGB();
|
||||
break;
|
||||
}
|
||||
bytes_read = fread( &( m_pppcInputPel[1][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
}
|
||||
bytes_read = fread( &( m_pppcInputPel[2][0][0] ), sizeof(Pel), m_uiWidth * m_uiHeight / 4, m_pFile );
|
||||
if( bytes_read != ( m_uiWidth * m_uiHeight / 4 ) )
|
||||
{
|
||||
m_iErrorStatus = READING;
|
||||
qDebug() << " Reading error !!!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
YUV420toRGB();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+15
-8
@@ -35,11 +35,6 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
typedef enum YUV_FILE_FORMATS
|
||||
{
|
||||
INVALID = 0, YUV_420p = 1,
|
||||
} YUVFileFormats;
|
||||
|
||||
enum InputStream_Errors
|
||||
{
|
||||
NO_ERROR = 0, READING = 1,
|
||||
@@ -54,8 +49,8 @@ private:
|
||||
|
||||
QString m_cFilename;
|
||||
FILE* m_pFile; /**< The input file pointer >*/
|
||||
|
||||
YUVFileFormats m_eFormat;
|
||||
Int m_iFileFormat;
|
||||
Int m_iPixelFormat;
|
||||
|
||||
UInt m_uiWidth;
|
||||
UInt m_uiHeight;
|
||||
@@ -73,7 +68,19 @@ public:
|
||||
static QStringList supportedReadFormatsList();
|
||||
static QStringList supportedPixelFormatList();
|
||||
|
||||
Void init( QString filename, UInt width, UInt height );
|
||||
enum InputStreamColorSpace
|
||||
{
|
||||
YUV420,
|
||||
YUV400,
|
||||
};
|
||||
|
||||
enum InputStreamFormats
|
||||
{
|
||||
INVALID = -1,
|
||||
YUVFormat = 0, // Use color space.
|
||||
};
|
||||
|
||||
Void init( QString filename, UInt width, UInt height, Int input_format );
|
||||
|
||||
Void YUV420toRGB();
|
||||
|
||||
|
||||
Reference in new issue
Block a user