Change copyright and format the code using clang-format

This commit is contained in:
jfmcarreira committed 2017-01-28 19:43:48 +00:00
1 parent a69c32bfbf
commit 8a60bb2766
122 files changed
+12950 -12139

No files matched your search

+82 -79
View File
@@ -1,5 +1,5 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2016 by Luis Lucas (luisfrlucas@gmail.com)
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
@@ -43,14 +43,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
for( Int i = 0; i < array.size(); i++ )
{
d = array.at( i );
out << d.m_cFilename
<< d.m_uiWidth
<< d.m_uiHeight
<< d.m_iPelFormat
<< d.m_uiBitsPelPixel
<< d.m_iEndianness
<< d.m_uiFrameRate
<< d.m_uiFileSize;
out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness
<< d.m_uiFrameRate << d.m_uiFileSize;
}
return out;
}
@@ -88,17 +82,16 @@ Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename )
* \brief Shows information about video sub window
*/
class VideoInformation: public QWidget
class VideoInformation : public QWidget
{
private:
private:
QList<QStaticText> m_cTopLeftTextList;
QFont m_cTopLeftTextFont;
QFont m_cCenterTextFont;
Bool m_bBusyWindow;
public:
VideoInformation( QWidget *parent ) :
QWidget( parent ),
m_bBusyWindow( false )
public:
VideoInformation( QWidget* parent ) : QWidget( parent ), m_bBusyWindow( false )
{
setPalette( Qt::transparent );
setAttribute( Qt::WA_TransparentForMouseEvents );
@@ -113,12 +106,9 @@ private:
m_cTopLeftTextList.append( textLines.at( i ) );
}
}
Void setBusyWindow( Bool bFlag )
{
m_bBusyWindow = bFlag;
}
protected:
void paintEvent( QPaintEvent *event )
Void setBusyWindow( Bool bFlag ) { m_bBusyWindow = bFlag; }
protected:
void paintEvent( QPaintEvent* event )
{
QPainter painter( this );
painter.setFont( m_cTopLeftTextFont );
@@ -140,31 +130,35 @@ protected:
}
};
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget * parent ) :
SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
m_bWindowBusy( false ),
m_pCurrStream( NULL ),
m_pcCurrFrame( NULL ),
m_pcCurrentDisplayModule( NULL ),
m_pcReferenceSubWindow( NULL ),
m_bIsPlaying( false )
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent )
: SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ),
m_bWindowBusy( false ),
m_pCurrStream( NULL ),
m_pcCurrFrame( NULL ),
m_pcCurrentDisplayModule( NULL ),
m_pcReferenceSubWindow( NULL ),
m_bIsPlaying( false )
{
// Create a new scroll area inside the sub-window
m_pcScrollArea = new QScrollArea;
connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) );
connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
SLOT( updateCurScrollValues() ) );
connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this,
SLOT( updateCurScrollValues() ) );
// Create a new interface to show images
m_cViewArea = new ViewArea;
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
SLOT( adjustScrollBarByScale( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double, QPoint ) ), this,
SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved_SWindow( QPoint ) ) );
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint& ) ), this,
SLOT( updatePixelValueStatusBar( const QPoint& ) ) );
m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
@@ -209,18 +203,18 @@ Void VideoSubWindow::keyPressEvent( QKeyEvent* event )
Bool bRet = false;
switch( event->key() )
{
case Qt::Key_A:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_LEFT );
break;
case Qt::Key_D:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_RIGHT );
break;
case Qt::Key_W:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_UP );
break;
case Qt::Key_S:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_DOWN );
break;
case Qt::Key_A:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_LEFT );
break;
case Qt::Key_D:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_RIGHT );
break;
case Qt::Key_W:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_UP );
break;
case Qt::Key_S:
bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_DOWN );
break;
}
if( bRet )
{
@@ -245,7 +239,7 @@ QSize VideoSubWindow::sizeHint() const
{
QSize maxSize;
QWidget *p = parentWidget();
QWidget* p = parentWidget();
if( p )
{
maxSize = p->size();
@@ -257,16 +251,16 @@ QSize VideoSubWindow::sizeHint() const
return sizeHint( maxSize );
}
QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const
{
QSize VideoSubWindow::sizeHint( const QSize& maxSize ) const
{
QSize isize;
if( m_pcCurrFrame )
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
else if( m_pCurrStream )
isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
// If the VideoSubWindow needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
// If the VideoSubWindow needs more space that the avaiable, we'll give
// to the subwindow a reasonable size preserving the image aspect ratio.
if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) )
{
isize.scale( maxSize, Qt::KeepAspectRatio );
@@ -296,7 +290,7 @@ Void VideoSubWindow::refreshSubWindow()
close();
return;
}
//seekAbsoluteEvent( currFrameNum );
// seekAbsoluteEvent( currFrameNum );
}
updateVideoWindowInfo();
refreshFrame();
@@ -319,8 +313,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
if( guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness ) || bForceDialog )
{
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate )
== QDialog::Rejected )
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -332,8 +326,8 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
}
catch( ... )
{
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate )
== QDialog::Rejected )
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -367,8 +361,9 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
m_pCurrStream = new PlaYUVerStream;
}
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness, streamInfo->m_uiFrameRate, true ) )
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight,
streamInfo->m_iPelFormat, streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
streamInfo->m_uiFrameRate, true ) )
{
return false;
}
@@ -403,7 +398,7 @@ Void VideoSubWindow::updateVideoWindowInfo()
}
}
}
//qDebug( ) << sourceWindowList;
// qDebug( ) << sourceWindowList;
if( sourceWindowList.size() > 0 )
{
m_pcVideoInfo->setInformationTopLeft( sourceWindowList );
@@ -415,20 +410,25 @@ Void VideoSubWindow::updateVideoWindowInfo()
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
m_cStreamInformation = m_cFormatName + " | " + m_cCodedName;
}
//#if 0
//#if 0
if( m_pcCurrFrame )
{
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() );
m_cStreamInformation += " | " + m_cPelFmtName;
}
//#endif
//#endif
if( m_cStreamInformation.isEmpty() )
{
m_cStreamInformation = " ";
}
}
Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPixel, Int& rEndianness )
Bool VideoSubWindow::guessFormat( QString filename,
UInt& rWidth,
UInt& rHeight,
Int& rInputFormat,
UInt& rBitsPerPixel,
Int& rEndianness )
{
std::vector<PlaYUVerStdResolution> stdResList = PlaYUVerStream::stdResolutionSizes();
Bool bGuessed = true;
@@ -504,7 +504,8 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
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, 8 );
frame_bytes =
PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
@@ -521,7 +522,7 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
}
}
// Guess bits per pixel - match %dbpp
// Guess bits per pixel - match %dbpp
#if( QT_VERSION_PLAYUVER == 5 )
QRegularExpressionMatch BppMatch = QRegularExpression( "_\\d*bpp" ).match( FilenameShort );
if( BppMatch.hasMatch() )
@@ -668,7 +669,7 @@ Void VideoSubWindow::refreshFrame( Bool bThreaded )
m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation );
}
else
#endif
#endif
{
refreshFrameOperation();
}
@@ -682,7 +683,8 @@ Bool VideoSubWindow::save( QString filename )
PlaYUVerFrame* saveFrame = m_pcCurrFrame;
if( m_cSelectedArea.isValid() )
{
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(), m_cSelectedArea.height() );
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(),
m_cSelectedArea.height() );
}
if( !saveFrame )
{
@@ -792,7 +794,7 @@ Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset )
valueY = scrollBarV->minimum();
m_cCurrScroll.setY( valueY );
// Update window scroll
// Update window scroll
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
}
@@ -836,15 +838,14 @@ Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center )
m_cCurrScroll.setY( value );
}
// Update window scroll
// Update window scroll
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
}
Void VideoSubWindow::updateCurScrollValues()
{
QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
QScrollBar* scrollBar = m_pcScrollArea->horizontalScrollBar();
m_cCurrScroll.setX( scrollBar->value() );
scrollBar = m_pcScrollArea->verticalScrollBar();
m_cCurrScroll.setY( scrollBar->value() );
@@ -852,7 +853,7 @@ Void VideoSubWindow::updateCurScrollValues()
Void VideoSubWindow::setCurScrollValues()
{
QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar();
QScrollBar* scrollBar = m_pcScrollArea->horizontalScrollBar();
scrollBar->setValue( m_cCurrScroll.x() );
scrollBar = m_pcScrollArea->verticalScrollBar();
scrollBar->setValue( m_cCurrScroll.y() );
@@ -872,7 +873,7 @@ Void VideoSubWindow::normalSize()
Void VideoSubWindow::zoomToFit()
{
// Scale to a smaller size that the real to a nicer look
// Scale to a smaller size that the real to a nicer look
scaleView( getScrollSize() );
}
@@ -899,7 +900,7 @@ Void VideoSubWindow::scaleView( Double scale, QPoint center )
}
}
Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
Void VideoSubWindow::scaleView( const QSize& size, QPoint center )
{
QSize imgViewSize;
if( m_pcCurrFrame )
@@ -909,13 +910,13 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
QSize newSize = imgViewSize;
newSize.scale( size, Qt::KeepAspectRatio );
// Calc the zoom factor
// Calc the zoom factor
Double wfactor = 1;
Double hfactor = 1;
Double factor;
wfactor = ( Double )newSize.width() / imgViewSize.width();
hfactor = ( Double )newSize.height() / imgViewSize.height();
wfactor = (Double)newSize.width() / imgViewSize.width();
hfactor = (Double)newSize.height() / imgViewSize.height();
if( wfactor < hfactor )
factor = wfactor;
@@ -957,13 +958,15 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
if( ColorSpace == PlaYUVerPixel::COLOR_YUV )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
strStatus.append( QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
strStatus.append(
QString( "Y: %1 U: %2 V: %3" ).arg( sPixelValue.Y() ).arg( sPixelValue.Cb() ).arg( sPixelValue.Cr() ) );
}
if( ( ColorSpace == PlaYUVerPixel::COLOR_RGB ) )
{
sPixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() );
strStatus.append( QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
strStatus.append(
QString( "R: %1 G: %2 B: %3" ).arg( sPixelValue.R() ).arg( sPixelValue.G() ).arg( sPixelValue.B() ) );
}
emit updateStatusBar( strStatus );
}