Add stream information into application title

This commit is contained in:
2014-02-04 23:57:43 +00:00
parent 57f5231e7b
commit ebecb1e3f5
9 changed files with 86 additions and 32 deletions
+2 -1
View File
@@ -22,6 +22,7 @@
*/
#include "ConfigureFormatDialog.h"
#include "PlaYUVerFrame.h"
#include "InputStream.h"
namespace plaYUVer
@@ -168,7 +169,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
pixelFormatBox->setSizePolicy( sizePolicyPixelFormat );
pixelFormatBox->setAcceptDrops( true );
pixelFormatBox->clear();
pixelFormatBox->insertItems( 0, InputStream::supportedPixelFormatList() );
pixelFormatBox->insertItems( 0, PlaYUVerFrame::supportedPixelFormatList() );
pixelFormatBox->setCurrentIndex( 0 );
pixelFormatLayout->addWidget( pixelFormatLabel );
+42 -20
View File
@@ -46,27 +46,25 @@ InputStream::InputStream()
m_uiFrameRate = 25;
m_iFileFormat = INVALID;
m_cFilename = QString( "" );
m_cStreamInformationString = QString( "" );
}
InputStream::~InputStream()
{
if( m_pFile )
fclose( m_pFile );
#ifdef USE_FFMPEG
m_cLibAvContext.closeAvFormat();
#endif
m_iStatus = 0;
close();
}
QString InputStream::supportedReadFormats()
{
QString formats;
formats = "*.yuv " // Raw video
"*.avi "// Audio video interleaved
#ifdef USE_FFMPEG
"*.avi " // Audio video interleaved
"*.wmv "// Windows media video
;
#endif
;
return formats;
}
@@ -86,8 +84,10 @@ QStringList InputStream::supportedReadFormatsList()
{
QStringList formats;
formats << "Raw video (*.yuv)" // Raw video
#ifdef USE_FFMPEG
<< "Audio video interleaved (*.avi)" // Audio video interleaved
<< "Windows media video (*.wmv)" // Windows media video
#endif
;
return formats;
@@ -104,13 +104,6 @@ QStringList InputStream::supportedWriteFormatsList()
return formats;
}
QStringList InputStream::supportedPixelFormatList()
{
QStringList formats;
formats << "YUV420" << "YUV400";
return formats;
}
Bool InputStream::needFormatDialog( QString filename )
{
QString fileExtension = QFileInfo( filename ).completeSuffix();
@@ -128,6 +121,12 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
{
Bool avStatus = false;
if( m_iStatus == 1 )
{
close();
}
m_cFilename = filename;
m_uiWidth = width;
m_uiHeight = height;
m_uiFrameRate = frame_rate;
@@ -135,8 +134,11 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
m_iFileFormat = YUVFormat;
m_iPixelFormat = input_format;
m_cStreamInformationString = QString( "[" );
#ifdef USE_FFMPEG
avStatus = m_cLibAvContext.initAvFormat( filename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
m_cStreamInformationString.append( QString::fromUtf8( m_cLibAvContext.getStreamInformation() ) );
m_uiTotalFrameNum = 100;
#endif
@@ -152,7 +154,6 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
if( !avStatus )
{
m_cFilename = filename;
m_pFile = fopen( m_cFilename.toLocal8Bit().data(), "rb" );
if( m_pFile == NULL )
{
@@ -162,6 +163,8 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
fseek( m_pFile, 0, SEEK_END );
m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input );
fseek( m_pFile, 0, SEEK_SET );
m_cStreamInformationString.append( QString::fromUtf8("rawvideo ") );
}
if( !get_mem1Dpel( &m_pInputBuffer, m_cCurrFrame->getBytesPerFrame() ) )
@@ -170,13 +173,32 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for
return;
}
m_uiCurrFrameNum = 0;
m_cStreamInformationString.append( QString("/ "));
m_cStreamInformationString.append( PlaYUVerFrame::supportedPixelFormatList().at( m_iPixelFormat ) );
m_cStreamInformationString.append( "] " );
m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() );
m_uiCurrFrameNum = 0;
m_iStatus = 1;
return;
}
Void InputStream::close()
{
if( m_pFile )
fclose( m_pFile );
#ifdef USE_FFMPEG
m_cLibAvContext.closeAvFormat();
#endif
m_iStatus = 0;
}
Void InputStream::readFrame()
{
UInt64 bytes_read = 0;
+11 -2
View File
@@ -64,6 +64,8 @@ private:
#endif
QString m_cFilename;
QString m_cStreamInformationString;
FILE* m_pFile; /**< The input file pointer >*/
Int m_iFileFormat;
Int m_iPixelFormat;
@@ -87,8 +89,6 @@ public:
static QStringList supportedReadFormatsList();
static QStringList supportedWriteFormatsList();
static QStringList supportedPixelFormatList();
enum InputStreamFormats
{
INVALID = -1, YUVFormat = 0, // Use color space.
@@ -97,6 +97,7 @@ public:
Bool needFormatDialog( QString filename );
Void init( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate );
Void close();
Void readFrame();
@@ -115,6 +116,14 @@ public:
{
return m_iStatus;
}
QString getFileName()
{
return m_cFilename;
}
QString getStreamInformationString()
{
return m_cStreamInformationString;
}
UInt getFrameNum()
{
return m_uiTotalFrameNum;
+7
View File
@@ -28,6 +28,13 @@
namespace plaYUVer
{
QStringList PlaYUVerFrame::supportedPixelFormatList()
{
QStringList formats;
formats << "yuv420" << "yuv400";
return formats;
}
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format )
{
m_pppcInputPel[0] = NULL;
+4
View File
@@ -29,6 +29,8 @@
#include <iostream>
#include <cstdio>
#include <QtCore>
#include "TypeDef.h"
namespace plaYUVer
@@ -40,6 +42,8 @@ public:
PlaYUVerFrame( UInt width, UInt height, Int pel_format );
~PlaYUVerFrame();
static QStringList supportedPixelFormatList();
Void FrameFromBuffer( Pel *input_buffer, Int pel_format );
UInt64 getBytesPerFrame();
+7 -8
View File
@@ -46,7 +46,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
// Define the cViewArea as the widget inside the scroll area
m_cScrollArea->setWidget( m_cViewArea );
m_cCurrFileName = QString( "" );
m_cWindowName = QString( " " );
m_dScaleFactor = 1;
}
@@ -93,8 +93,12 @@ bool SubWindowHandle::loadFile( const QString &fileName )
normalSize();
m_cWindowName = QString("ola");
m_cWindowName = m_currStream.getStreamInformationString();
m_cCurrFileName = fileName;
setWindowTitle( userFriendlyCurrentFile() + "[*]" );
setWindowTitle( m_cWindowName );
return true;
}
@@ -240,12 +244,7 @@ Void SubWindowHandle::closeEvent( QCloseEvent *event )
QString SubWindowHandle::userFriendlyCurrentFile()
{
return strippedName( m_cCurrFileName );
}
QString SubWindowHandle::strippedName( const QString &fullFileName )
{
return QFileInfo( fullFileName ).fileName();
return m_cWindowName;
}
} // NAMESPACE
+2 -1
View File
@@ -52,7 +52,9 @@ private:
InputStream m_currStream;
QString m_cWindowName;
QString m_cCurrFileName;
Double m_dScaleFactor;
public:
@@ -114,7 +116,6 @@ public:
*/
//static void cascader( QList<QWidget *> &widgets, const QRect &domain );
QString userFriendlyCurrentFile();
QString strippedName( const QString &fullFileName );
QString currentFile()
{
return m_cCurrFileName;
+5
View File
@@ -150,6 +150,11 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
video_dst_bufsize = ret;
}
const char *codec_name = avcodec_get_name(video_dec_ctx->codec_id);
sprintf(m_acStreamInformationString, "%s ", codec_name);
Double fr = 30;
if( video_stream->avg_frame_rate.den && video_stream->avg_frame_rate.num )
fr = av_q2d( video_stream->avg_frame_rate );
+6
View File
@@ -63,6 +63,10 @@ public:
{
return m_bHasStream;
}
Char* getStreamInformation()
{
return m_acStreamInformationString;
}
uint8_t *video_dst_data[4];
int video_dst_linesize[4];
@@ -77,6 +81,8 @@ private:
AVPacket pkt;
Bool m_bHasStream;
Char m_acStreamInformationString[20];
};
} // NAMESPACE