From 738582392d8c14242d023c339a00c6d61b26736b Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 12 Mar 2015 21:48:32 +0000 Subject: [PATCH 01/94] First approach to plot quality --- app/PlotSubWindow.cpp | 100 ++++++++++++++++++++++++++---------------- app/PlotSubWindow.h | 10 ++++- app/QualityHandle.cpp | 80 +++++++++++++++++++++++++++++++-- app/QualityHandle.h | 2 + 4 files changed, 147 insertions(+), 45 deletions(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 35b019b..9605711 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -27,6 +27,15 @@ namespace plaYUVer { +Void PlotSubWindow::definePlotColors() +{ + m_arrayColorList.append( Qt::blue ); + m_arrayColorList.append( Qt::red ); + m_arrayColorList.append( Qt::green ); + m_arrayColorList.append( Qt::black ); + m_arrayColorList.append( Qt::cyan ); +} + PlotSubWindow::PlotSubWindow( QWidget * parent ) : SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW ) { @@ -39,26 +48,6 @@ PlotSubWindow::PlotSubWindow( QWidget * parent ) : m_cPlotArea = new QCustomPlot( this ); setWidget( m_cPlotArea ); - Example(); - -} - -Void PlotSubWindow::Example() -{ - // add two new graphs and set their look: - m_cPlotArea->addGraph(); - m_cPlotArea->graph( 0 )->setPen( QPen( Qt::blue ) ); // line color blue for first graph - m_cPlotArea->graph( 0 )->setBrush( QBrush( QColor( 0, 0, 255, 20 ) ) ); // first graph will be filled with translucent blue - m_cPlotArea->addGraph(); - m_cPlotArea->graph( 1 )->setPen( QPen( Qt::red ) ); // line color red for second graph - // generate some points of data (y0 for first, y1 for second graph): - QVector x( 250 ), y0( 250 ), y1( 250 ); - for( int i = 0; i < 250; ++i ) - { - x[i] = i; - y0[i] = exp( -i / 150.0 ) * cos( i / 10.0 ); // exponentially decaying cosine - y1[i] = exp( -i / 150.0 ); // exponential envelope - } // configure right and top axis to show ticks but no labels: // (see QCPAxisRect::setupFullAxesBox for a quicker method to do this) m_cPlotArea->xAxis2->setVisible( true ); @@ -68,19 +57,30 @@ Void PlotSubWindow::Example() // make left and bottom axes always transfer their ranges to right and top axes: connect( m_cPlotArea->xAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->xAxis2, SLOT( setRange(QCPRange) ) ); connect( m_cPlotArea->yAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->yAxis2, SLOT( setRange(QCPRange) ) ); - // pass data points to graphs: - m_cPlotArea->graph( 0 )->setData( x, y0 ); - m_cPlotArea->graph( 1 )->setData( x, y1 ); - // let the ranges scale themselves so graph 0 fits perfectly in the visible area: - m_cPlotArea->graph( 0 )->rescaleAxes(); - // same thing for graph 1, but only enlarge ranges (in case graph 1 is smaller than graph 0): - m_cPlotArea->graph( 1 )->rescaleAxes( true ); - // Note: we could have also just called m_cPlotArea->rescaleAxes(); instead - // Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking: + + definePlotColors(); + m_uiNumberPlots = 0; + m_cPlotArea->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables ); } +Void PlotSubWindow::Example() +{ + // generate some points of data (y0 for first, y1 for second graph): + QVector x( 250 ), y0( 250 ), y1( 250 ); + for( int i = 0; i < 250; ++i ) + { + x[i] = i; + y0[i] = exp( -i / 150.0 ) * cos( i / 10.0 ); // exponentially decaying cosine + y1[i] = exp( -i / 150.0 ); // exponential envelope + } + + addPlot( x, y0 ); + addPlot( x, y1 ); + +} + PlotSubWindow::~PlotSubWindow() { delete m_cPlotArea; @@ -106,15 +106,37 @@ Void PlotSubWindow::scaleView( Double scale, QPoint center ) } -//QSize PlotSubWindow::sizeHint() const -//{ -// -//} -// -// -//QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const -//{ -// -//} +QSize PlotSubWindow::sizeHint() const +{ + QSize maxSize; + QWidget *p = parentWidget(); + if( p ) + { + maxSize = p->size(); + } + else + { + maxSize = QApplication::desktop()->availableGeometry().size(); + } + return sizeHint( maxSize ); +} + +QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const +{ + return maxSize; +} + +Void PlotSubWindow::addPlot( const QVector &key, const QVector &value ) +{ + QCPGraph *newPlot = m_cPlotArea->addGraph(); + newPlot->setPen( QPen( m_arrayColorList.at( m_uiNumberPlots ) ) ); // line color blue for first graph + newPlot->setBrush( QBrush( QColor( 0, 0, 255, 20 ) ) ); // first graph will be filled with translucent blue + // pass data points to graphs: + newPlot->setData( key, value ); + // let the ranges scale themselves so graph 0 fits perfectly in the visible area: + newPlot->rescaleAxes( m_uiNumberPlots > 1 ? true : false ); + + m_uiNumberPlots++; +} } // NAMESPACE diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index 9dfb063..c8da96c 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -44,6 +44,8 @@ Q_OBJECT private: QCustomPlot* m_cPlotArea; + QVector m_arrayColorList; + UInt m_uiNumberPlots; Void Example(); @@ -51,6 +53,8 @@ public: PlotSubWindow( QWidget * parent = 0 ); ~PlotSubWindow(); + Void definePlotColors(); + Void setTool( UInt uiTool ) { } @@ -71,8 +75,10 @@ public: /** * Size related functions */ -// QSize sizeHint() const; -// QSize sizeHint( const QSize & ) const; + QSize sizeHint() const; + QSize sizeHint( const QSize & ) const; + + Void addPlot(const QVector &key, const QVector &value); }; } // NAMESPACE diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 0230970..646c80d 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -28,6 +28,7 @@ #include "VideoSubWindow.h" #include "PlotSubWindow.h" #include "DialogSubWindowSelector.h" +#include "lib/LibMemory.h" namespace plaYUVer { @@ -75,7 +76,7 @@ QMenu* QualityHandle::createMenu() m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() ); m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); m_pcMenuQuality->addSeparator(); - //m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); + m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); return m_pcMenuQuality; } @@ -127,6 +128,62 @@ Void QualityHandle::update( VideoSubWindow* currSubWindow ) m_pcQualityHandleSideBar->updateCurrentWindow( currSubWindow ); } +QVector* QualityHandle::measureQuality( QVector apcWindowList ) +{ + QVector* padQualityValues; + UInt numberOfWindows = apcWindowList.size(); + UInt64 currFrames = 0; + UInt64 numberOfFrames = INT_MAX; + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + //! Check reference window + for( UInt i = 0; i < numberOfWindows; i++ ) + { + if( !apcWindowList.at( i )->getRefSubWindow() ) + { + return NULL; + } + } + VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow(); + + for( UInt i = 0; i < numberOfWindows; i++ ) + { + currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum(); + if( currFrames < numberOfFrames ) + numberOfFrames = currFrames; + apcWindowList.at( i )->stop(); + } + pcReferenceWindow->stop(); + + padQualityValues = new QVector [numberOfWindows + 1]; + + PlaYUVerFrame* pcReferenceFrame; + PlaYUVerFrame* pcCurrFrame; + for( UInt f = 1; f < numberOfFrames; f++ ) + { + padQualityValues[0].append( f ); + pcReferenceFrame = pcReferenceWindow->getCurrFrame(); + for( UInt i = 0; i < numberOfWindows; i++ ) + { + pcCurrFrame = apcWindowList.at( 0 )->getCurrFrame(); + padQualityValues[i + 1].append( pcCurrFrame->getQuality( 0, pcReferenceFrame, LUMA ) ); + apcWindowList.at( 0 )->play(); + apcWindowList.at( 0 )->playEvent(); + } + pcReferenceWindow->play(); + pcReferenceWindow->playEvent(); + } + for( UInt i = 0; i < numberOfWindows; i++ ) + { + apcWindowList.at( 0 )->stop(); + } + pcReferenceWindow->stop(); + QApplication::restoreOverrideCursor(); + + return padQualityValues; +} + Void QualityHandle::slotQualityMetricChanged( Int idx ) { m_actionGroupQualityMetric->actions().at( idx )->setChecked( true ); @@ -165,9 +222,24 @@ Void QualityHandle::slotSelectReference() Void QualityHandle::slotCreatePlot() { - PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet ); - m_pcMainWindowManager->addSubWindow( pcPlotWindow ); - pcPlotWindow->show(); + VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); + if( pcSubWindow ) + { + if( pcSubWindow->getRefSubWindow() ) + { + QVector apcWindowList; + apcWindowList.append( pcSubWindow ); + QVector* qualityVector = measureQuality( apcWindowList ); + + PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet ); + + pcPlotWindow->addPlot( qualityVector[0], qualityVector[1] ); + + m_pcMainWindowManager->addSubWindow( pcPlotWindow ); + pcPlotWindow->show(); + + } + } } diff --git a/app/QualityHandle.h b/app/QualityHandle.h index faa42d5..29d683f 100644 --- a/app/QualityHandle.h +++ b/app/QualityHandle.h @@ -78,6 +78,8 @@ private: QDockWidget* m_pcQualityHandleDock; QualityMeasurementSidebar* m_pcQualityHandleSideBar; + QVector* measureQuality( QVector apcWindowList ); + Q_SIGNALS: void changed(); From bf8ac0e8c7b1535f5c65751e92ebba3b66af7625 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 01:46:57 +0000 Subject: [PATCH 02/94] Add seekRelative function into PlaYUVerStream and minor fix in ModulesHandle --- app/ModulesHandle.cpp | 2 +- app/VideoSubWindow.cpp | 2 +- lib/PlaYUVerStream.cpp | 19 +++++++++++++++++++ lib/PlaYUVerStream.h | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 86dbf2b..4e19ce7 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -282,7 +282,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) } else { - windowName.append( pcVideoSubWindow->windowTitle() ); + windowName.append( pcVideoSubWindow->getWindowName() ); videoSubWindowList.append( pcVideoSubWindow ); } diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 5c0f72d..3e27fa2 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -518,7 +518,7 @@ Void VideoSubWindow::seekRelativeEvent( Bool bIsFoward ) { if( m_pCurrStream ) { - if( m_pCurrStream->seekInput( m_pCurrStream->getCurrFrameNum() + ( bIsFoward ? 1 : -1 ) ) ) + if( m_pCurrStream->seekInputRelative( bIsFoward ) ) { refreshFrame(); } diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index b30012b..eb212e6 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -692,6 +692,25 @@ PlaYUVerFrame* PlaYUVerStream::getNextFrame() return m_pcNextFrame; } +Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward ) +{ + if( !m_bInit || !m_bIsInput ) + return false; + + Bool bRet = false; + if( bIsFoward ) + { + readFrame(); + bRet = !setNextFrame(); + } + else + { + UInt64 newFrameNum = m_iCurrFrameNum - 1; + bRet = seekInput( newFrameNum ); + } + return bRet; +} + Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) { if( !m_bInit || new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum || ( Int64 )new_frame_num == m_iCurrFrameNum ) diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 57906fc..a9429ab 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -77,7 +77,6 @@ private: std::string m_cCodedName; std::string m_cPelFmtName; - FILE* m_pFile; /**< The input file pointer >*/ std::fstream m_fsIOStream; /**< The input file pointer >*/ @@ -146,6 +145,7 @@ public: PlaYUVerFrame* getCurrFrame( PlaYUVerFrame * ); PlaYUVerFrame* getNextFrame(); + Bool seekInputRelative( Bool bIsFoward ); Bool seekInput( UInt64 new_frame_num ); Bool isInit() From 7f6e4dc14f3f26cdf74558c439baa9550df7570d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 03:44:51 +0000 Subject: [PATCH 03/94] Improvements in PlaYUVerStream and QualityMeasurements --- app/QualityMeasurementSidebar.cpp | 4 ++++ app/SubWindowHandle.cpp | 3 --- app/VideoSubWindow.cpp | 3 +++ lib/PlaYUVerStream.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp index 3b2cf01..e140dd4 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/QualityMeasurementSidebar.cpp @@ -138,6 +138,10 @@ Void QualityMeasurementSidebar::updateSubWindowList() for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); + if( m_pcCurrentVideoSubWindow == pcVideoSubWindow ) + { + continue; + } if( m_pcCurrentVideoSubWindow ) { if( !m_pcCurrentVideoSubWindow->getCurrFrame()->haveSameFmt( pcVideoSubWindow->getCurrFrame() ) ) diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 0a304fb..7830ba9 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -42,9 +42,6 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setWidgetResizable( true ); m_uiCategory = category; diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 3e27fa2..f3c049b 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -97,6 +97,9 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); + setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + // Define the cViewArea as the widget inside the scroll area m_cViewArea->setMinimumSize( size() ); setWidget( m_cViewArea ); diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index eb212e6..48fafec 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -700,8 +700,8 @@ Bool PlaYUVerStream::seekInputRelative( Bool bIsFoward ) Bool bRet = false; if( bIsFoward ) { - readFrame(); bRet = !setNextFrame(); + readFrame(); } else { From f8061bd4d18239ca8c02cfb4324989d1b6c3f074 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 03:45:13 +0000 Subject: [PATCH 04/94] Support for ploting single and multiple plots --- app/PlotSubWindow.cpp | 116 ++++++++++++++++++++++++++++++++---------- app/PlotSubWindow.h | 30 ++++++++--- app/QualityHandle.cpp | 116 +++++++++++++++++++++++++++++++++--------- app/QualityHandle.h | 9 +++- 4 files changed, 213 insertions(+), 58 deletions(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 9605711..1a5d7dd 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -23,6 +23,7 @@ */ #include "PlotSubWindow.h" +#include "qcustomplot.h" namespace plaYUVer { @@ -36,7 +37,7 @@ Void PlotSubWindow::definePlotColors() m_arrayColorList.append( Qt::cyan ); } -PlotSubWindow::PlotSubWindow( QWidget * parent ) : +PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW ) { setParent( parent ); @@ -45,7 +46,19 @@ PlotSubWindow::PlotSubWindow( QWidget * parent ) : setBackgroundRole( QPalette::Light ); setVisible( false ); + definePlotColors(); + m_uiNumberPlots = 0; + m_dScaleFactor = 1; + + setWindowName( windowTitle ); + m_cPlotArea = new QCustomPlot( this ); + + QSizePolicy sizePolicy( QSizePolicy::Preferred, QSizePolicy::MinimumExpanding ); + sizePolicy.setHorizontalStretch( 0 ); + sizePolicy.setVerticalStretch( 0 ); + sizePolicy.setHeightForWidth( m_cPlotArea->sizePolicy().hasHeightForWidth() ); + m_cPlotArea->setSizePolicy( sizePolicy ); setWidget( m_cPlotArea ); // configure right and top axis to show ticks but no labels: @@ -58,26 +71,16 @@ PlotSubWindow::PlotSubWindow( QWidget * parent ) : connect( m_cPlotArea->xAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->xAxis2, SLOT( setRange(QCPRange) ) ); connect( m_cPlotArea->yAxis, SIGNAL( rangeChanged(QCPRange) ), m_cPlotArea->yAxis2, SLOT( setRange(QCPRange) ) ); - definePlotColors(); - m_uiNumberPlots = 0; + QFont legendFont = font(); // start out with MainWindow's font.. + legendFont.setPointSize( 9 ); // and make a bit smaller for legend + m_cPlotArea->legend->setFont( legendFont ); + m_cPlotArea->legend->setVisible( false ); - m_cPlotArea->setInteractions( QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables ); + m_cPlotArea->setInteractions( QCP::iRangeZoom | QCP::iRangeDrag ); //QCP::iSelectPlottables -} - -Void PlotSubWindow::Example() -{ - // generate some points of data (y0 for first, y1 for second graph): - QVector x( 250 ), y0( 250 ), y1( 250 ); - for( int i = 0; i < 250; ++i ) - { - x[i] = i; - y0[i] = exp( -i / 150.0 ) * cos( i / 10.0 ); // exponentially decaying cosine - y1[i] = exp( -i / 150.0 ); // exponential envelope - } - - addPlot( x, y0 ); - addPlot( x, y1 ); + m_cPlotPen.setStyle( Qt::SolidLine ); + m_cPlotPen.setColor( Qt::black ); + m_cPlotPen.setWidthF( 2 ); } @@ -88,12 +91,15 @@ PlotSubWindow::~PlotSubWindow() Void PlotSubWindow::normalSize() { - + m_cPlotArea->xAxis->setRange( m_aAxisRange[HORIZONTAL][0], m_aAxisRange[HORIZONTAL][1] ); + m_cPlotArea->yAxis->setRange( m_aAxisRange[VERTICAL][0], m_aAxisRange[VERTICAL][1] ); + m_cPlotArea->replot(); + m_dScaleFactor = 1; } Void PlotSubWindow::zoomToFit() { - + normalSize(); } Void PlotSubWindow::zoomToFactor( Double factor, QPoint center ) @@ -103,7 +109,23 @@ Void PlotSubWindow::zoomToFactor( Double factor, QPoint center ) Void PlotSubWindow::scaleView( Double scale, QPoint center ) { + scale -= 1; + scale /= 10; + scale += 1; + m_dScaleFactor *= scale; +// +// UInt aNewAxisRange[2][2]; +// for( UInt axis = 0; axis < 2; axis++ ) +// for( UInt dim = 0; dim < 2; dim++ ) +// aNewAxisRange[axis][dim] = m_aAxisRange[axis][dim] / m_dScaleFactor; +// +// m_cPlotArea->xAxis->setRange( aNewAxisRange[HORIZONTAL][0], aNewAxisRange[HORIZONTAL][1] ); +// m_cPlotArea->yAxis->setRange( aNewAxisRange[VERTICAL][0], aNewAxisRange[VERTICAL][1] ); + + m_cPlotArea->xAxis->scaleRange( scale, 0 ); + m_cPlotArea->yAxis->scaleRange( scale, 0 ); + m_cPlotArea->replot(); } QSize PlotSubWindow::sizeHint() const @@ -123,19 +145,61 @@ QSize PlotSubWindow::sizeHint() const QSize PlotSubWindow::sizeHint( const QSize & maxSize ) const { - return maxSize; + return maxSize * 2 / 3; } -Void PlotSubWindow::addPlot( const QVector &key, const QVector &value ) +Void PlotSubWindow::setAxisName( const QString& nameAxisX, const QString& nameAxisY ) +{ + m_cPlotArea->xAxis->setLabel( nameAxisX ); + m_cPlotArea->yAxis->setLabel( nameAxisY ); +} + +Void PlotSubWindow::setAxisRange( const QLine& axisLimits ) +{ + setAxisRange( HORIZONTAL, axisLimits.x1(), axisLimits.x2() ); + setAxisRange( VERTICAL, axisLimits.y1(), axisLimits.y2() ); +} + +Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd ) +{ + if( eAxis == HORIZONTAL ) + { + m_cPlotArea->xAxis->setRange( axisStart, axisEnd ); + horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); + m_aAxisRange[HORIZONTAL][0] = axisStart; + m_aAxisRange[HORIZONTAL][1] = axisEnd; + } + if( eAxis == VERTICAL ) + { + m_cPlotArea->yAxis->setRange( axisStart, axisEnd ); + verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); + m_aAxisRange[VERTICAL][0] = axisStart; + m_aAxisRange[VERTICAL][1] = axisEnd; + } + m_cPlotArea->replot(); +} + +Void PlotSubWindow::addPlot( const QVector &arrayX, const QVector &arrayY, const QString& key ) { QCPGraph *newPlot = m_cPlotArea->addGraph(); - newPlot->setPen( QPen( m_arrayColorList.at( m_uiNumberPlots ) ) ); // line color blue for first graph - newPlot->setBrush( QBrush( QColor( 0, 0, 255, 20 ) ) ); // first graph will be filled with translucent blue + m_cPlotPen.setColor( m_arrayColorList.at( m_uiNumberPlots ) ); + newPlot->setPen( m_cPlotPen ); // line style // pass data points to graphs: - newPlot->setData( key, value ); + newPlot->setData( arrayX, arrayY ); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: newPlot->rescaleAxes( m_uiNumberPlots > 1 ? true : false ); + if( !key.isEmpty() ) + { + m_cPlotArea->legend->setVisible( true ); + newPlot->setName( key ); + } + + m_aAxisRange[HORIZONTAL][0] = m_cPlotArea->xAxis->range().lower; + m_aAxisRange[HORIZONTAL][1] = m_cPlotArea->xAxis->range().upper; + m_aAxisRange[VERTICAL][0] = m_cPlotArea->yAxis->range().lower; + m_aAxisRange[VERTICAL][1] = m_cPlotArea->yAxis->range().upper; + m_uiNumberPlots++; } diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index c8da96c..090b50b 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -33,7 +33,8 @@ #include #endif #include "SubWindowHandle.h" -#include "qcustomplot.h" + +class QCustomPlot; namespace plaYUVer { @@ -44,13 +45,22 @@ Q_OBJECT private: QCustomPlot* m_cPlotArea; + QVector m_arrayColorList; + QPen m_cPlotPen; + + enum Axis + { + HORIZONTAL, + VERTICAL, + }; + Double m_aAxisRange[2][2]; + Double m_dScaleFactor; UInt m_uiNumberPlots; - Void Example(); - public: - PlotSubWindow( QWidget * parent = 0 ); + + PlotSubWindow( QWidget * parent, const QString& windowTitle ); ~PlotSubWindow(); Void definePlotColors(); @@ -69,7 +79,7 @@ public: Double getScaleFactor() { - return 0; + return m_dScaleFactor; } /** @@ -78,7 +88,15 @@ public: QSize sizeHint() const; QSize sizeHint( const QSize & ) const; - Void addPlot(const QVector &key, const QVector &value); + Void setAxisName( const QString& nameAxisX, const QString& nameAxisY ); + + Void setAxisRange( const QLine& axisLimits ); + Void setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStart, const Int& axisEnd ); + + Void setKey( const QString& key ); + + Void addPlot( const QVector &arrayX, const QVector &arrayY, const QString& key = QString() ); + }; } // NAMESPACE diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 646c80d..6ce37e9 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -29,6 +29,9 @@ #include "PlotSubWindow.h" #include "DialogSubWindowSelector.h" #include "lib/LibMemory.h" +#if( QT_VERSION_PLAYUVER == 5 ) +#include "QtConcurrent/qtconcurrentrun.h" +#endif namespace plaYUVer { @@ -65,8 +68,11 @@ Void QualityHandle::createActions() m_arrayActions.resize( TOTAL_ACT ); m_arrayActions[SELECT_REF_ACT] = new QAction( "Select Reference", this ); connect( m_arrayActions[SELECT_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectReference() ) ); - m_arrayActions[PLOT_QUALITY] = new QAction( "CREATE_PLOT", this ); - connect( m_arrayActions[PLOT_QUALITY], SIGNAL( triggered() ), this, SLOT( slotCreatePlot() ) ); + + m_arrayActions[PLOT_QUALITY] = new QAction( "Plot Window's Quality", this ); + connect( m_arrayActions[PLOT_QUALITY], SIGNAL( triggered() ), this, SLOT( slotPlotQualitySingle() ) ); + m_arrayActions[PLOT_SEVERAL_QUALITY] = new QAction( "Plot Several Quality", this ); + connect( m_arrayActions[PLOT_SEVERAL_QUALITY], SIGNAL( triggered() ), this, SLOT( slotPlotQualitySeveral() ) ); } QMenu* QualityHandle::createMenu() @@ -77,6 +83,7 @@ QMenu* QualityHandle::createMenu() m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); m_pcMenuQuality->addSeparator(); m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); + m_pcMenuQuality->addAction( m_arrayActions[PLOT_SEVERAL_QUALITY] ); return m_pcMenuQuality; } @@ -102,7 +109,9 @@ Void QualityHandle::updateMenus() m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow ); m_arrayActions[SELECT_REF_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow ); + m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasSubWindow ); m_pcQualityHandleSideBar->updateSideBar( hasSubWindow ); } @@ -128,25 +137,24 @@ Void QualityHandle::update( VideoSubWindow* currSubWindow ) m_pcQualityHandleSideBar->updateCurrentWindow( currSubWindow ); } -QVector* QualityHandle::measureQuality( QVector apcWindowList ) +Void QualityHandle::measureQuality( QVector apcWindowList ) { QVector* padQualityValues; UInt numberOfWindows = apcWindowList.size(); UInt64 currFrames = 0; UInt64 numberOfFrames = INT_MAX; - QApplication::setOverrideCursor( Qt::WaitCursor ); - //! Check reference window for( UInt i = 0; i < numberOfWindows; i++ ) { if( !apcWindowList.at( i )->getRefSubWindow() ) { - return NULL; + return; } } VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow(); + numberOfFrames = pcReferenceWindow->getInputStream()->getFrameNum(); for( UInt i = 0; i < numberOfWindows; i++ ) { currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum(); @@ -160,28 +168,49 @@ QVector* QualityHandle::measureQuality( QVector apcWind PlaYUVerFrame* pcReferenceFrame; PlaYUVerFrame* pcCurrFrame; - for( UInt f = 1; f < numberOfFrames; f++ ) + for( UInt f = 0; f < numberOfFrames; f++ ) { padQualityValues[0].append( f ); pcReferenceFrame = pcReferenceWindow->getCurrFrame(); for( UInt i = 0; i < numberOfWindows; i++ ) { - pcCurrFrame = apcWindowList.at( 0 )->getCurrFrame(); - padQualityValues[i + 1].append( pcCurrFrame->getQuality( 0, pcReferenceFrame, LUMA ) ); - apcWindowList.at( 0 )->play(); - apcWindowList.at( 0 )->playEvent(); + pcCurrFrame = apcWindowList.at( i )->getCurrFrame(); + padQualityValues[i + 1].append( pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, LUMA ) ); + apcWindowList.at( i )->seekRelativeEvent( true ); } - pcReferenceWindow->play(); - pcReferenceWindow->playEvent(); + pcReferenceWindow->seekRelativeEvent( true ); } for( UInt i = 0; i < numberOfWindows; i++ ) { - apcWindowList.at( 0 )->stop(); + apcWindowList.at( i )->stop(); } pcReferenceWindow->stop(); - QApplication::restoreOverrideCursor(); - return padQualityValues; + QString plotWindowTitle( QStringLiteral( "Quality - " ) ); + if( apcWindowList.size() == 1 ) + { + plotWindowTitle += apcWindowList.at( 0 )->getWindowName(); + } + PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet, plotWindowTitle ); + pcPlotWindow->setAxisName( "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) ); + + if( apcWindowList.size() > 1 ) + { + QString key; + for( UInt i = 0; i < numberOfWindows; i++ ) + { + key = apcWindowList.at( i )->getWindowName(); + pcPlotWindow->addPlot( padQualityValues[0], padQualityValues[i + 1], key ); + } + } + else + { + pcPlotWindow->addPlot( padQualityValues[0], padQualityValues[1] ); + } + + m_pcMainWindowManager->addSubWindow( pcPlotWindow ); + pcPlotWindow->show(); + } Void QualityHandle::slotQualityMetricChanged( Int idx ) @@ -220,7 +249,7 @@ Void QualityHandle::slotSelectReference() } } -Void QualityHandle::slotCreatePlot() +Void QualityHandle::slotPlotQualitySingle() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); if( pcSubWindow ) @@ -229,18 +258,57 @@ Void QualityHandle::slotCreatePlot() { QVector apcWindowList; apcWindowList.append( pcSubWindow ); - QVector* qualityVector = measureQuality( apcWindowList ); - PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet ); - - pcPlotWindow->addPlot( qualityVector[0], qualityVector[1] ); - - m_pcMainWindowManager->addSubWindow( pcPlotWindow ); - pcPlotWindow->show(); +//#ifndef QT_NO_CONCURRENT +// m_cMeasurementResult.waitForFinished(); +// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList ); +//#else + QApplication::setOverrideCursor( Qt::WaitCursor ); + measureQuality( apcWindowList ); + QApplication::restoreOverrideCursor(); +//#endif } } +} +Void QualityHandle::slotPlotQualitySeveral() +{ + VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); + if( pcSubWindow ) + { + QVector apcWindowList; + + VideoSubWindow* pcRefSubWindow = pcSubWindow->getRefSubWindow(); + if( !pcRefSubWindow ) + { + pcRefSubWindow = pcSubWindow; + } + + VideoSubWindow* pcVideoSubWindow; + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); + if( pcVideoSubWindow->getRefSubWindow() == pcRefSubWindow ) + { + apcWindowList.append( pcVideoSubWindow ); + } + } + + if( apcWindowList.size() > 0 ) + { +//#ifndef QT_NO_CONCURRENT +// m_cMeasurementResult.waitForFinished(); +// m_cMeasurementResult = QtConcurrent::run( this, &QualityHandle::measureQuality, apcWindowList ); +//#else + QApplication::setOverrideCursor( Qt::WaitCursor ); + measureQuality( apcWindowList ); + QApplication::restoreOverrideCursor(); +//#endif + + } + } } } // NAMESPACE diff --git a/app/QualityHandle.h b/app/QualityHandle.h index 29d683f..df01a2e 100644 --- a/app/QualityHandle.h +++ b/app/QualityHandle.h @@ -33,6 +33,7 @@ #elif( QT_VERSION_PLAYUVER == 4 ) #include #endif +#include "QFuture" #include "QualityMeasurementSidebar.h" namespace plaYUVer @@ -61,10 +62,12 @@ public: private: QWidget* m_pcParet; PlaYUVerSubWindowHandle* m_pcMainWindowManager; + enum { SELECT_REF_ACT, PLOT_QUALITY, + PLOT_SEVERAL_QUALITY, TOTAL_ACT, }; QVector m_arrayActions; @@ -78,7 +81,8 @@ private: QDockWidget* m_pcQualityHandleDock; QualityMeasurementSidebar* m_pcQualityHandleSideBar; - QVector* measureQuality( QVector apcWindowList ); + QFuture m_cMeasurementResult; + Void measureQuality( QVector apcWindowList ); Q_SIGNALS: void changed(); @@ -86,7 +90,8 @@ Q_SIGNALS: private Q_SLOTS: void slotQualityMetricChanged( int ); void slotSelectReference(); - void slotCreatePlot(); + void slotPlotQualitySingle(); + void slotPlotQualitySeveral(); }; } // NAMESPACE From d3a83bde04fd4799105f93c756382be7a4b20bc3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 15:01:30 +0000 Subject: [PATCH 05/94] Fix quality plot window when using multiple plots --- app/QualityHandle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 6ce37e9..bce8b29 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -186,10 +186,10 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) } pcReferenceWindow->stop(); - QString plotWindowTitle( QStringLiteral( "Quality - " ) ); + QString plotWindowTitle( QStringLiteral( "Quality" ) ); if( apcWindowList.size() == 1 ) { - plotWindowTitle += apcWindowList.at( 0 )->getWindowName(); + plotWindowTitle += " - " + apcWindowList.at( 0 )->getWindowName(); } PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet, plotWindowTitle ); pcPlotWindow->setAxisName( "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) ); From 59f744c7255ed51f6c97065b539f42357ac63b6d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 15:40:29 +0000 Subject: [PATCH 06/94] Two improvements related with PlotSubWindow Fix ModulesHandle to filter PlotSubWinodws Generalize reload to be applied to all kinds of subwindows --- app/ModulesHandle.cpp | 2 +- app/PlotSubWindow.h | 5 +++++ app/SubWindowHandle.h | 5 +++++ app/VideoSubWindow.cpp | 19 +++++++++++++++---- app/VideoSubWindow.h | 3 ++- app/plaYUVerApp.cpp | 24 ++++++++++++++---------- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 4e19ce7..7a5be64 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -256,7 +256,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows(); VideoSubWindow *videoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow(); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); for( Int j = 0; j < selectedWindows.size(); j++ ) { for( Int i = 0; i < subWindowList.size(); i++ ) diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index 090b50b..5be3302 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -65,6 +65,11 @@ public: Void definePlotColors(); + Void refreshSubWindow() + { + + } + Void setTool( UInt uiTool ) { } diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 8b77dc1..f7e01f3 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -76,6 +76,11 @@ public: SubWindowHandle( QWidget *, UInt ); ~SubWindowHandle(); + /** + * Show the image at its original size + */ + virtual Void refreshSubWindow() = 0; + /** * Show the image at its original size */ diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index f3c049b..8f27eec 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -122,11 +122,22 @@ Void VideoSubWindow::loadAll() refreshFrame(); } -Void VideoSubWindow::reloadFile() +Void VideoSubWindow::refreshSubWindow() { - Int currFrameNum = m_pCurrStream->getCurrFrameNum(); - loadFile( m_cFilename, false ); - seekAbsoluteEvent( currFrameNum ); + if( getCategory() == SubWindowHandle::VIDEO_STREAM_SUBWINDOW ) + { + Int currFrameNum = m_pCurrStream->getCurrFrameNum(); + if( !loadFile( m_cFilename, false ) ) + { + close(); + return; + } + seekAbsoluteEvent( currFrameNum ); + } + else + { + refreshFrame(); + } } Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 2208f15..c5ac156 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -117,9 +117,10 @@ public: Bool loadFile( QString cFilename, Bool bForceDialog = false ); Bool loadFile( PlaYUVerStreamInfo* streamInfo ); Void loadAll(); - Void reloadFile(); Bool save( QString filename ); + Void refreshSubWindow(); + Bool play(); Void pause(); Bool playEvent(); diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 4119ced..b58189c 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -328,9 +328,9 @@ Void plaYUVerApp::format() Void plaYUVerApp::reload() { - if( m_pcCurrentVideoSubWindow ) + if( m_pcCurrentSubWindow ) { - m_pcCurrentVideoSubWindow->reloadFile(); + m_pcCurrentSubWindow->refreshSubWindow(); m_pcCurrentSubWindow = NULL; update(); } @@ -338,14 +338,18 @@ Void plaYUVerApp::reload() Void plaYUVerApp::reloadAll() { - VideoSubWindow *videoSubWindow; - QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) + UInt windowCategoryOrder[] = { - videoSubWindow = qobject_cast( subWindowList.at( i ) ); - if( !videoSubWindow->getIsModule() ) + SubWindowHandle::VIDEO_STREAM_SUBWINDOW, + SubWindowHandle::MODULE_SUBWINDOW, + SubWindowHandle::MODULE_SUBWINDOW }; + + for( UInt c = 0; c < 3; c++ ) + { + QList subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] ); + for( Int i = 0; i < subWindowList.size(); i++ ) { - videoSubWindow->reloadFile(); + subWindowList.at( i )->refreshSubWindow(); } } m_pcCurrentSubWindow = NULL; @@ -533,10 +537,10 @@ Void plaYUVerApp::updateMenus() m_arrayActions[SAVE_ACT]->setEnabled( hasSubWindow ); m_arrayActions[CLOSE_ACT]->setEnabled( hasSubWindow ); m_arrayActions[CLOSEALL_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[RELOAD_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[FORMAT_ACT]->setEnabled( hasVideoStreamSubWindow ); - m_arrayActions[RELOAD_ACT]->setEnabled( hasVideoStreamSubWindow ); - m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow ); m_arrayActions[LOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow ); m_arrayActions[ZOOM_IN_ACT]->setEnabled( hasSubWindow ); From ce114a80c0f23eb68678ae635731b419610f3790 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 15:54:04 +0000 Subject: [PATCH 07/94] Fix quality measurement for several plots and add new opt to quality menu --- app/QualityHandle.cpp | 26 +++++++++++++++++++++++++- app/QualityHandle.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index bce8b29..61b071b 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -66,6 +66,9 @@ Void QualityHandle::createActions() } m_arrayActions.resize( TOTAL_ACT ); + + m_arrayActions[SELECT_CURR_REF_ACT] = new QAction( "Select Current as Reference", this ); + connect( m_arrayActions[SELECT_CURR_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectCurrentAsReference() ) ); m_arrayActions[SELECT_REF_ACT] = new QAction( "Select Reference", this ); connect( m_arrayActions[SELECT_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectReference() ) ); @@ -80,6 +83,7 @@ QMenu* QualityHandle::createMenu() m_pcMenuQuality = new QMenu( "Quality", this ); m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" ); m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() ); + m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] ); m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); m_pcMenuQuality->addSeparator(); m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); @@ -108,6 +112,7 @@ Void QualityHandle::updateMenus() Bool hasSubWindow = pcSubWindow ? true : false; m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow ); + m_arrayActions[SELECT_CURR_REF_ACT]->setEnabled( hasSubWindow ); m_arrayActions[SELECT_REF_ACT]->setEnabled( hasSubWindow ); m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow ); @@ -221,6 +226,24 @@ Void QualityHandle::slotQualityMetricChanged( Int idx ) m_iQualityMetricIdx = idx; } +Void QualityHandle::slotSelectCurrentAsReference() +{ + VideoSubWindow* pcRefSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); + if( pcRefSubWindow ) + { + VideoSubWindow* pcVideoSubWindow; + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); + if( pcVideoSubWindow != pcRefSubWindow ) + pcVideoSubWindow->setRefSubWindow( pcRefSubWindow ); + } + m_pcQualityHandleSideBar->updateSidebarData(); + m_pcQualityHandleDock->show(); + } +} + Void QualityHandle::slotSelectReference() { DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 ); @@ -242,7 +265,8 @@ Void QualityHandle::slotSelectReference() for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); - pcVideoSubWindow->setRefSubWindow( pcRefSubWindow ); + if( pcVideoSubWindow != pcRefSubWindow ) + pcVideoSubWindow->setRefSubWindow( pcRefSubWindow ); } m_pcQualityHandleSideBar->updateSidebarData(); m_pcQualityHandleDock->show(); diff --git a/app/QualityHandle.h b/app/QualityHandle.h index df01a2e..663c59e 100644 --- a/app/QualityHandle.h +++ b/app/QualityHandle.h @@ -65,6 +65,7 @@ private: enum { + SELECT_CURR_REF_ACT, SELECT_REF_ACT, PLOT_QUALITY, PLOT_SEVERAL_QUALITY, @@ -89,6 +90,7 @@ Q_SIGNALS: private Q_SLOTS: void slotQualityMetricChanged( int ); + void slotSelectCurrentAsReference(); void slotSelectReference(); void slotPlotQualitySingle(); void slotPlotQualitySeveral(); From df84dfcc706d695797faf13f20c450bd33c683c1 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 18:37:20 +0000 Subject: [PATCH 08/94] change plot color to follow system theme --- app/PlotSubWindow.cpp | 28 ++++++++++++++++++++++------ app/SubWindowHandle.cpp | 1 + app/VideoSubWindow.cpp | 1 - 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 1a5d7dd..cb49969 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -40,11 +40,6 @@ Void PlotSubWindow::definePlotColors() PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW ) { - setParent( parent ); - - setAttribute( Qt::WA_DeleteOnClose ); - setBackgroundRole( QPalette::Light ); - setVisible( false ); definePlotColors(); m_uiNumberPlots = 0; @@ -59,10 +54,27 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : sizePolicy.setVerticalStretch( 0 ); sizePolicy.setHeightForWidth( m_cPlotArea->sizePolicy().hasHeightForWidth() ); m_cPlotArea->setSizePolicy( sizePolicy ); - setWidget( m_cPlotArea ); + + m_cPlotArea->setBackgroundRole( backgroundRole() ); + + m_cPlotArea->setBackground( palette().brush( backgroundRole() ) ); + + m_cPlotArea->xAxis->setLabelColor( palette().text().color() ); + m_cPlotArea->yAxis->setLabelColor( palette().text().color() ); + m_cPlotArea->xAxis->setTickLabelColor( palette().text().color() ); + m_cPlotArea->yAxis->setTickLabelColor( palette().text().color() ); + m_cPlotArea->xAxis->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->yAxis->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->xAxis->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->yAxis->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->xAxis2->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->yAxis2->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->xAxis2->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->yAxis2->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); // configure right and top axis to show ticks but no labels: // (see QCPAxisRect::setupFullAxesBox for a quicker method to do this) + m_cPlotArea->axisRect( 0 )->setupFullAxesBox( true ); m_cPlotArea->xAxis2->setVisible( true ); m_cPlotArea->xAxis2->setTickLabels( false ); m_cPlotArea->yAxis2->setVisible( true ); @@ -74,6 +86,9 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : QFont legendFont = font(); // start out with MainWindow's font.. legendFont.setPointSize( 9 ); // and make a bit smaller for legend m_cPlotArea->legend->setFont( legendFont ); + m_cPlotArea->legend->setBrush( palette().brush( backgroundRole() ) ); + m_cPlotArea->legend->setTextColor( palette().text().color() ); + m_cPlotArea->legend->setBorderPen( QPen( palette().brush( QPalette::Active, QPalette::Shadow ), 1 ) ); m_cPlotArea->legend->setVisible( false ); m_cPlotArea->setInteractions( QCP::iRangeZoom | QCP::iRangeDrag ); //QCP::iSelectPlottables @@ -82,6 +97,7 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : m_cPlotPen.setColor( Qt::black ); m_cPlotPen.setWidthF( 2 ); + setWidget( m_cPlotArea ); } PlotSubWindow::~PlotSubWindow() diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 7830ba9..2ad5f1f 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -32,6 +32,7 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : m_cSubWindow( NULL ) { setParent( parent ); + setVisible( false ); setFocusPolicy( Qt::WheelFocus ); setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Background ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 8f27eec..dbc08ae 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -84,7 +84,6 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget m_bIsPlaying( false ), m_bIsModule( category == MODULE_SUBWINDOW ) { - setVisible( false ); // Create a new interface to show images m_cViewArea = new ViewArea( this ); From c22a33b16257191906dab67616f09be2d88008ef Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 19:05:17 +0000 Subject: [PATCH 09/94] finish color definition of qcustomplot --- app/PlotSubWindow.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index cb49969..de4f604 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -57,20 +57,27 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : m_cPlotArea->setBackgroundRole( backgroundRole() ); - m_cPlotArea->setBackground( palette().brush( backgroundRole() ) ); + QBrush backgroundBrush = palette().brush( backgroundRole() ); + QBrush foregroundBrush = palette().brush( foregroundRole() ); + + m_cPlotArea->setBackground( backgroundBrush ); m_cPlotArea->xAxis->setLabelColor( palette().text().color() ); m_cPlotArea->yAxis->setLabelColor( palette().text().color() ); m_cPlotArea->xAxis->setTickLabelColor( palette().text().color() ); m_cPlotArea->yAxis->setTickLabelColor( palette().text().color() ); - m_cPlotArea->xAxis->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->yAxis->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->xAxis->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->yAxis->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->xAxis2->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->yAxis2->setBasePen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->xAxis2->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); - m_cPlotArea->yAxis2->setTickPen( QPen( palette().brush( foregroundRole() ), 1 ) ); + m_cPlotArea->xAxis->setBasePen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis->setBasePen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->xAxis->setTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis->setTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->xAxis->setSubTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis->setSubTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->xAxis2->setSubTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis2->setSubTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->xAxis2->setBasePen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis2->setBasePen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->xAxis2->setTickPen( QPen( foregroundBrush, 1 ) ); + m_cPlotArea->yAxis2->setTickPen( QPen( foregroundBrush, 1 ) ); // configure right and top axis to show ticks but no labels: // (see QCPAxisRect::setupFullAxesBox for a quicker method to do this) @@ -86,7 +93,7 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : QFont legendFont = font(); // start out with MainWindow's font.. legendFont.setPointSize( 9 ); // and make a bit smaller for legend m_cPlotArea->legend->setFont( legendFont ); - m_cPlotArea->legend->setBrush( palette().brush( backgroundRole() ) ); + m_cPlotArea->legend->setBrush( backgroundBrush ); m_cPlotArea->legend->setTextColor( palette().text().color() ); m_cPlotArea->legend->setBorderPen( QPen( palette().brush( QPalette::Active, QPalette::Shadow ), 1 ) ); m_cPlotArea->legend->setVisible( false ); From 78279015d46d3acedd9a9d22e5175b65109f86d8 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 13 Mar 2015 19:48:17 +0000 Subject: [PATCH 10/94] Add progress bar to quality plots --- app/CMakeLists.txt | 1 + app/ConfigureFormatDialog.h | 4 --- app/ProgressBar.cpp | 60 +++++++++++++++++++++++++++++++++++++ app/ProgressBar.h | 53 ++++++++++++++++++++++++++++++++ app/QualityHandle.cpp | 8 ++++- 5 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 app/ProgressBar.cpp create mode 100644 app/ProgressBar.h diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 53c9f25..7494733 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -69,6 +69,7 @@ set(plaYUVer_App_SRCS AboutDialog.cpp ConfigureFormatDialog.cpp DialogSubWindowSelector.cpp + ProgressBar.cpp # Widgets HistogramWidget.cpp WidgetFrameNumber.cpp diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h index cb10ab4..7a745fd 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/ConfigureFormatDialog.h @@ -42,10 +42,6 @@ class QColor; namespace plaYUVer { -#define ADD_STANDARD_RESOLUTION( name, width, height) \ - standardResolutionNames.push_back( QString( name ) ); \ - standardResolutionSizesList.push_back( QSize( width, height ) ) - /** * */ diff --git a/app/ProgressBar.cpp b/app/ProgressBar.cpp new file mode 100644 index 0000000..c264599 --- /dev/null +++ b/app/ProgressBar.cpp @@ -0,0 +1,60 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ProgressBar.cpp + * \brief Progress bar code + */ + +#include "ProgressBar.h" +#include +#include +#include +#include +#include + +namespace plaYUVer +{ + +ProgressBar::ProgressBar( QWidget *parent, UInt maxValue ) : + QWidget( parent ), + m_uiTotalProgress( maxValue ), + m_uiProgress( 0 ) +{ + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + m_pcProgressBar = new QProgressBar; + m_pcProgressBar->setMaximum( m_uiTotalProgress ); + m_pcProgressBar->setAlignment( Qt::AlignCenter ); + mainLayout->addWidget( m_pcProgressBar ); + setLayout( mainLayout ); + setWindowTitle( QStringLiteral( "Progress" ) ); + + QSize screenSize = QApplication::desktop()->availableGeometry().size(); + QPoint screenCenter = QApplication::desktop()->availableGeometry().center(); + resize( screenSize.width() / 4, screenSize.height() / 10 ); + move( screenCenter.x() - screenSize.width() / 8, screenCenter.y() - screenSize.height() / 10 ); + show(); +} + +Void ProgressBar::incrementProgress( UInt increment ) +{ + m_uiProgress += increment; + m_pcProgressBar->setValue( m_uiProgress ); +} +} // NAMESPACE diff --git a/app/ProgressBar.h b/app/ProgressBar.h new file mode 100644 index 0000000..fffa430 --- /dev/null +++ b/app/ProgressBar.h @@ -0,0 +1,53 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ProgressBar.h + * \brief Progress bar code + */ + +#ifndef __PROGRESSBAR_H__ +#define __PROGRESSBAR_H__ + +#include "PlaYUVerAppDefs.h" +#include + +class QProgressBar; + +namespace plaYUVer +{ + +class ProgressBar: public QWidget +{ +Q_OBJECT + +public: + ProgressBar( QWidget *parent, UInt maxValue ); + + Void incrementProgress( UInt ); + +private: + UInt m_uiTotalProgress; + UInt m_uiProgress; + QProgressBar* m_pcProgressBar; +}; + +} // NAMESPACE + +#endif // __PROGRESSBAR_H__ diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 61b071b..a83d7bc 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -23,12 +23,13 @@ */ #include +#include "lib/LibMemory.h" #include "PlaYUVerSubWindowHandle.h" #include "QualityHandle.h" #include "VideoSubWindow.h" #include "PlotSubWindow.h" #include "DialogSubWindowSelector.h" -#include "lib/LibMemory.h" +#include "ProgressBar.h" #if( QT_VERSION_PLAYUVER == 5 ) #include "QtConcurrent/qtconcurrentrun.h" #endif @@ -169,6 +170,8 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) } pcReferenceWindow->stop(); + ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames ); + padQualityValues = new QVector [numberOfWindows + 1]; PlaYUVerFrame* pcReferenceFrame; @@ -184,6 +187,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) apcWindowList.at( i )->seekRelativeEvent( true ); } pcReferenceWindow->seekRelativeEvent( true ); + pcProgressBar->incrementProgress( 1 ); } for( UInt i = 0; i < numberOfWindows; i++ ) { @@ -216,6 +220,8 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) m_pcMainWindowManager->addSubWindow( pcPlotWindow ); pcPlotWindow->show(); + pcProgressBar->close(); + } Void QualityHandle::slotQualityMetricChanged( Int idx ) From 1481582314071e5cfedd2685428aca4fda467846 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Mar 2015 16:27:40 +0000 Subject: [PATCH 11/94] Fix PlaYUVerFrame conversion to cv::mat --- lib/PlaYUVerFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index bacb270..386875e 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -438,7 +438,7 @@ Void PlaYUVerFrame::getCvMat( Void** ppCvFrame ) switch( m_pcPelFormat->numberChannels ) { case 3: - cvType = CV_8UC3; + cvType = CV_8UC4; break; case 1: cvType = CV_8UC1; From 4aeedb0c15502649c7b1d06dd7ec1e722c075ec7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 17 Mar 2015 16:27:55 +0000 Subject: [PATCH 12/94] Fix gui configurations in quality menu --- app/ModulesHandle.cpp | 2 ++ app/QualityHandle.cpp | 4 ++-- app/VideoSubWindow.cpp | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 7a5be64..6eee962 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -426,6 +426,7 @@ Void ModulesHandle::destroyAllModulesIf() Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isPlaying, Bool disableThreads ) { Bool bRet = false; + QApplication::setOverrideCursor( Qt::WaitCursor ); if( !isPlaying || ( isPlaying && pcCurrModuleIf->m_pcModule->m_bApplyWhilePlaying ) ) { #ifdef PLAYUVER_THREADED_MODULES @@ -444,6 +445,7 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isP { bRet = true; } + QApplication::restoreOverrideCursor(); return bRet; } diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index a83d7bc..550f622 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -68,7 +68,7 @@ Void QualityHandle::createActions() m_arrayActions.resize( TOTAL_ACT ); - m_arrayActions[SELECT_CURR_REF_ACT] = new QAction( "Select Current as Reference", this ); + m_arrayActions[SELECT_CURR_REF_ACT] = new QAction( "Mark as Reference", this ); connect( m_arrayActions[SELECT_CURR_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectCurrentAsReference() ) ); m_arrayActions[SELECT_REF_ACT] = new QAction( "Select Reference", this ); connect( m_arrayActions[SELECT_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectReference() ) ); @@ -85,7 +85,7 @@ QMenu* QualityHandle::createMenu() m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" ); m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() ); m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] ); - m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); + //m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); m_pcMenuQuality->addSeparator(); m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); m_pcMenuQuality->addAction( m_arrayActions[PLOT_SEVERAL_QUALITY] ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index dbc08ae..8f960c3 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -155,8 +155,6 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) return false; } } - QApplication::setOverrideCursor( Qt::WaitCursor ); - QApplication::restoreOverrideCursor(); if( !m_pCurrStream ) { From ff6b3e7213f7b1832afe92ee87fbdf82173ff7b3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 19 Mar 2015 15:22:37 +0000 Subject: [PATCH 13/94] Fix refresh subiwndow --- app/SubWindowHandle.h | 17 +++++++++++++++++ app/VideoSubWindow.cpp | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index f7e01f3..62fb936 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -122,11 +122,28 @@ public: virtual Bool mayClose(); + /** + * Get category of the SubWindow + * @return category value based on enum SubWindowCategories + * @note This function should be used with enum SubWindowCategories + * with an & operation and it may belong to several categories + */ UInt getCategory() { return m_uiCategory; } + /** + * Check category of the SubWindow + * @param checkCateory SubWindow category to check against; + * it should be enum SubWindowCategories type + * @return true when SubWindow belong to checkCateory + */ + Bool checkCategory( UInt checkCateory ) + { + return m_uiCategory & checkCateory; + } + Void setSubWindow( PlaYUVerMdiSubWindow* subWindow ) { m_cSubWindow = subWindow; diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 8f960c3..4247a98 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -123,7 +123,7 @@ Void VideoSubWindow::loadAll() Void VideoSubWindow::refreshSubWindow() { - if( getCategory() == SubWindowHandle::VIDEO_STREAM_SUBWINDOW ) + if( getCategory() & SubWindowHandle::VIDEO_STREAM_SUBWINDOW ) { Int currFrameNum = m_pCurrStream->getCurrFrameNum(); if( !loadFile( m_cFilename, false ) ) From f1ea625b9b796064ac6423ac7214b79c14014e97 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 02:52:23 +0000 Subject: [PATCH 14/94] Minor fixes in argument parser and help of playuverTools --- lib/PlaYUVerCmdParser.cpp | 25 +++++++++++++++---------- lib/PlaYUVerCmdParser.h | 1 + lib/ProgramOptions.cpp | 5 +++++ lib/ProgramOptions.h | 2 ++ tools/CommandLineHandle.cpp | 15 +++------------ 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index 65bda94..6dbd779 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -62,10 +62,10 @@ Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] ) // m_cParserOptions.setDefaults(); const std::list& argv_unhandled = scanArgv( m_cParserOptions, argc, ( const Char** )argv ); - for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) - { - fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); - } +// for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) +// { +// fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); +// } if( checkListingOpts() ) { @@ -90,12 +90,6 @@ Bool PlaYUVerCmdParser::checkListingOpts() { Bool bRet = false; - if( m_cParserOptions["help"]->count() ) - { - doHelp( std::cout, m_cParserOptions ); - bRet |= true; - } - if( m_cParserOptions["version"]->count() ) { std::cout << "PlaYUVer version " @@ -112,6 +106,17 @@ Bool PlaYUVerCmdParser::checkListingOpts() } bRet |= true; } + + if( Opts()["quality_metrics"]->count() ) + { + printf( "PlaYUVer supported quality metrics: \n" ); + for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) + { + printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); + } + bRet |= true; + } + return bRet; } diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h index e602b6e..22a08f4 100644 --- a/lib/PlaYUVerCmdParser.h +++ b/lib/PlaYUVerCmdParser.h @@ -41,6 +41,7 @@ private: Options m_cParserOptions; Bool checkListingOpts(); + Void listModules(); }; } // NAMESPACE diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 5421e9a..3aaf893 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -51,6 +51,11 @@ using namespace std; namespace plaYUVer { +Options::Options( const std::string& name ) +{ + opt_name = name; +} + Options::~Options() { for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) diff --git a/lib/ProgramOptions.h b/lib/ProgramOptions.h index 0007cc1..af69593 100644 --- a/lib/ProgramOptions.h +++ b/lib/ProgramOptions.h @@ -227,6 +227,7 @@ private: class OptionSpecific; struct Options { + Options( const std::string& name = "" ); ~Options(); OptionSpecific addOptions(); @@ -261,6 +262,7 @@ struct Options NamesMap opt_long_map; NamesMap opt_short_map; + std::string opt_name; }; /* Class with templated overloaded operator(), for use by Options::addOptions() */ diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index f6b2b70..abcfbcc 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -86,19 +86,10 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) m_uiLogLevel = RESULT; } - if( Opts()["quality_metrics"]->count() ) + if( Opts()["help"]->count() ) { - printf( "PlaYUVer supported quality metrics: \n" ); - for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) - { - printf( " %s\n", PlaYUVerFrame::supportedQualityMetricsList()[i].c_str() ); - } - iRet = 1; - } - - if( Opts()["module_list"]->count() || Opts()["module_list_full"]->count() ) - { - listModules(); + printf( "Usage: %s modules/quality [options] -input=input_file [--output=output_file]\n", argv[0] ); + doHelp( std::cout, Opts() ); iRet = 1; } From e9fcf28365b715872c1a164797712d79736966a8 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 02:56:38 +0000 Subject: [PATCH 15/94] Rename file --- app/CMakeLists.txt | 2 +- app/{plaYUVerApp.cpp => PlaYUVerApp.cpp} | 4 ++-- app/{plaYUVerApp.h => PlaYUVerApp.h} | 2 +- app/PlaYUVerAppAdaptor.cpp | 2 +- app/PlaYUVerSubWindowHandle.cpp | 2 +- app/main.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename app/{plaYUVerApp.cpp => PlaYUVerApp.cpp} (99%) rename app/{plaYUVerApp.h => PlaYUVerApp.h} (99%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 53c9f25..0c5c485 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -45,7 +45,7 @@ ENDIF() set(plaYUVer_App_SRCS # Main main.cpp - plaYUVerApp.cpp + PlaYUVerApp.cpp PlaYUVerSubWindowHandle.cpp PlaYUVerMdiSubWindow.cpp SubWindowHandle.cpp diff --git a/app/plaYUVerApp.cpp b/app/PlaYUVerApp.cpp similarity index 99% rename from app/plaYUVerApp.cpp rename to app/PlaYUVerApp.cpp index 4119ced..7b8147d 100644 --- a/app/plaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -18,12 +18,12 @@ */ /** - * \file plaYUVerApp.cpp + * \file PlaYUVerApp.cpp * \brief Main definition of the plaYUVerApp app */ #include -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif diff --git a/app/plaYUVerApp.h b/app/PlaYUVerApp.h similarity index 99% rename from app/plaYUVerApp.h rename to app/PlaYUVerApp.h index 13fb5e2..995f904 100644 --- a/app/plaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -18,7 +18,7 @@ */ /** - * \file plaYUVerApp.h + * \file PlaYUVerApp.h * \ingroup PlaYUVerApp * \brief Main definition of the plaYUVerApp app * diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/PlaYUVerAppAdaptor.cpp index 9314035..fb40288 100644 --- a/app/PlaYUVerAppAdaptor.cpp +++ b/app/PlaYUVerAppAdaptor.cpp @@ -24,7 +24,7 @@ #include #include "PlaYUVerAppAdaptor.h" -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" namespace plaYUVer { diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 1958d3d..172e8af 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -22,7 +22,7 @@ * \brief Handle multiple sub-windows */ -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #include "PlaYUVerSubWindowHandle.h" #include "PlaYUVerMdiSubWindow.h" #include "SubWindowHandle.h" diff --git a/app/main.cpp b/app/main.cpp index 3e04ea1..f3d35e2 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -25,7 +25,7 @@ #include "config.h" #include "PlaYUVerAppDefs.h" #include -#include "plaYUVerApp.h" +#include "PlaYUVerApp.h" #include "SubWindowHandle.h" #ifdef USE_QTDBUS #include "PlaYUVerAppAdaptor.h" From 57e69e63075944a8df4b5595168abb31ea6abbca Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 03:28:30 +0000 Subject: [PATCH 16/94] Add command line args to playuver --- app/PlaYUVerApp.cpp | 48 ++++++++++++++++++++++++++++++------- app/PlaYUVerApp.h | 5 ++-- app/main.cpp | 44 ++++++++++++++++++---------------- lib/PlaYUVerCmdParser.cpp | 9 +++++-- lib/PlaYUVerCmdParser.h | 12 ++++++++-- tools/CommandLineHandle.cpp | 3 ++- 6 files changed, 84 insertions(+), 37 deletions(-) diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 7b8147d..40276f4 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -27,11 +27,11 @@ #ifdef USE_FERVOR #include "fvupdater.h" #endif +#include "lib/PlaYUVerCmdParser.h" #include "PlaYUVerSubWindowHandle.h" #include "VideoHandle.h" #include "QualityHandle.h" #include "ModulesHandle.h" - #include "DialogSubWindowSelector.h" #define SYNCHRONISED_ZOON 1 @@ -83,17 +83,47 @@ plaYUVerApp::plaYUVerApp() m_pcCurrentVideoSubWindow = NULL; } -Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) +Bool plaYUVerApp::parseArgs( Int argc, Char *argv[] ) { - if( argc >= 2 ) + Bool bRet = false; + m_pcCmdParser = new PlaYUVerCmdParser(); + m_pcCmdParser->config( argc, argv ); + + std::vector m_apcInputs; + std::string strResolution( "" ); + std::string strPelFmt( "" ); + + m_pcCmdParser->Opts().addOptions()/**/ + ( "input,i", m_apcInputs, "input file" ) /**/ + ( "size,s", strResolution, "size (WxH)" ) /**/ + ( "pel_fmt", strPelFmt, "pixel format" ); + + if( !m_pcCmdParser->parse() ) { - for( Int i = 1; i < argc; i++ ) - { - loadFile( argv[i] ); - } - m_pcWindowHandle->tileSubWindows(); - zoomToFitAll(); + bRet |= true; } + + if( m_pcCmdParser->Opts()["help"]->count() ) + { + printf( "Usage: %s [options] input_file[s]\n", argv[0] ); + doHelp( std::cout, m_pcCmdParser->Opts() ); + bRet |= true; + } + if( m_pcCmdParser->Opts()["input"]->count() ) + { + for( UInt i = 1; i < m_apcInputs.size(); i++ ) + { + loadFile( QString::fromStdString( m_apcInputs[i] ) ); + } + } + std::list& argv_unhandled = m_pcCmdParser->getNoArgs(); + for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) + { + loadFile( QString::fromStdString( *it ) ); + } + m_pcWindowHandle->tileSubWindows(); + zoomToFitAll(); + return bRet; } Void plaYUVerApp::about() diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index 995f904..c980297 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -55,6 +55,7 @@ namespace plaYUVer { +class PlaYUVerCmdParser; class PlaYUVerStream; class PlaYUVerSubWindowHandle; class VideoHandle; @@ -68,7 +69,7 @@ Q_OBJECT public: plaYUVerApp(); - Void parseArgs( Int argc, Char *argv[] ); + Bool parseArgs( Int argc, Char *argv[] ); Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); protected: @@ -113,7 +114,7 @@ private Q_SLOTS: private: PlaYUVerAppAdaptor* m_pDBusAdaptor; - + PlaYUVerCmdParser* m_pcCmdParser; /** * Save the current subwindow for every category */ diff --git a/app/main.cpp b/app/main.cpp index f3d35e2..abc4855 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -93,33 +93,32 @@ int main( int argc, char *argv[] ) QStringList tokens; // open given files... - foreach(const QString & file, filenameList) + foreach(const QString & file, filenameList){ + QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME, + QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile")); + + QList dbusargs; + dbusargs.append( file ); + m.setArguments(dbusargs); + + QDBusMessage res = QDBusConnection::sessionBus().call(m); + if (res.type() == QDBusMessage::ReplyMessage) { - QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME, - QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile")); - - QList dbusargs; - dbusargs.append( file ); - m.setArguments(dbusargs); - - QDBusMessage res = QDBusConnection::sessionBus().call(m); - if (res.type() == QDBusMessage::ReplyMessage) + if (res.arguments().count() == 1) { - if (res.arguments().count() == 1) + QVariant v = res.arguments()[0]; + if (v.isValid()) { - QVariant v = res.arguments()[0]; - if (v.isValid()) + QString s = v.toString(); + if ((!s.isEmpty()) && (s != QStringLiteral("ERROR"))) { - QString s = v.toString(); - if ((!s.isEmpty()) && (s != QStringLiteral("ERROR"))) - { - tokens << s; - } + tokens << s; } } } } - // this will wait until exiting is emitted by the used instance, if wanted... + } + // this will wait until exiting is emitted by the used instance, if wanted... return needToBlock ? application.exec() : 0; } } @@ -131,10 +130,13 @@ int main( int argc, char *argv[] ) #endif plaYUVerApp mainwindow; mainwindow.show(); - mainwindow.parseArgs( argc, argv ); + if( mainwindow.parseArgs( argc, argv ) ) + { + return 0; + } #ifdef USE_FERVOR - FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml"); + FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml"); FvUpdater::sharedUpdater()->SetDependencies("ALL"); #endif diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index 6dbd779..f8ec2cc 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -55,12 +55,17 @@ Options& PlaYUVerCmdParser::Opts() return m_cParserOptions; } -Bool PlaYUVerCmdParser::parse( Int argc, Char *argv[] ) +std::list& PlaYUVerCmdParser::getNoArgs() +{ + return m_aUnhandledArgs; +} + +Bool PlaYUVerCmdParser::parse() { try { // m_cParserOptions.setDefaults(); - const std::list& argv_unhandled = scanArgv( m_cParserOptions, argc, ( const Char** )argv ); + m_aUnhandledArgs = scanArgv( m_cParserOptions, m_iArgc, ( const Char** )m_ppArgv ); // for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) // { diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h index 22a08f4..8468c0c 100644 --- a/lib/PlaYUVerCmdParser.h +++ b/lib/PlaYUVerCmdParser.h @@ -25,7 +25,6 @@ #include "PlaYUVerDefs.h" #include "ProgramOptions.h" - namespace plaYUVer { @@ -35,10 +34,19 @@ public: PlaYUVerCmdParser(); ~PlaYUVerCmdParser(); - Bool parse( Int argc, Char *argv[] ); + Void config( Int argc, Char *argv[] ) + { + m_iArgc = argc; + m_ppArgv = argv; + } + Bool parse(); + std::list& getNoArgs(); Options& Opts(); private: + Int m_iArgc; + Char** m_ppArgv; Options m_cParserOptions; + std::list m_aUnhandledArgs; Bool checkListingOpts(); Void listModules(); diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index abcfbcc..ba07d58 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -76,7 +76,8 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) ( "quality", m_strQualityMetric, "select a quality metric" ) /**/ ( "module", m_strModule, "select a module (use internal name)" ); - if( !parse( argc, argv ) ) + config( argc, argv ); + if( !parse() ) { iRet = 1; } From 86c4fdc0c7e7a801ffe494f77e1dc84475d51282 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Mar 2015 03:37:56 +0000 Subject: [PATCH 17/94] Set version 0.6.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 535f465..a04c1d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET( PROJECT_NAME "playuver" ) PROJECT( ${PROJECT_NAME} ) SET( PLAYUVER_VERSION_MAJOR "0" ) SET( PLAYUVER_VERSION_MINOR "6" ) -SET( PLAYUVER_VERSION_PATCH "0" ) +SET( PLAYUVER_VERSION_PATCH "1" ) SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}") From 2072efd2d78010376e8133eda9159f0c5df86290 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 22 Mar 2015 04:27:57 +0000 Subject: [PATCH 18/94] Add modules arguments - test with binarization --- lib/CMakeLists.txt | 2 +- lib/PlaYUVerCmdParser.cpp | 32 ++++++++++++++++++++++++------ lib/PlaYUVerCmdParser.h | 1 + lib/ProgramOptions.cpp | 4 ++++ lib/ProgramOptions.h | 2 ++ modules/CMakeLists.txt | 4 ++++ modules/PlaYUVerModuleFactory.cpp | 3 ++- modules/PlaYUVerModuleIf.h | 3 +++ tools/CommandLineHandle.cpp | 33 ++++++++++++++++++++++++++++++- tools/CommandLineHandle.h | 1 + tools/PlaYUVerTools.cpp | 4 +++- 11 files changed, 79 insertions(+), 10 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 758c9ae..89182f9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -46,7 +46,7 @@ CONFIGURE_FILE( PlaYUVerConfig.cmake.in ${CMAKE_BINARY_DIR}/PlaYUVerConfig.cmake ADD_LIBRARY( PlaYUVerLib STATIC ${plaYUver_Lib_SRCS} ) INCLUDE_DIRECTORIES( ${FFMPEG_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ) -TARGET_LINK_LIBRARIES( PlaYUVerLib ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} ) +TARGET_LINK_LIBRARIES( PlaYUVerLib ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES} ) INSTALL(FILES ${plaYUver_Lib_HEADERS} DESTINATION include ) # INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libPlaYUVerLib${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION lib ) diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index f8ec2cc..3030734 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -67,10 +67,10 @@ Bool PlaYUVerCmdParser::parse() // m_cParserOptions.setDefaults(); m_aUnhandledArgs = scanArgv( m_cParserOptions, m_iArgc, ( const Char** )m_ppArgv ); -// for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) -// { -// fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); -// } + // for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) + // { + // fprintf( stderr, "Unhandled argument ignored: `%s'\n", *it ); + // } if( checkListingOpts() ) { @@ -91,6 +91,28 @@ Bool PlaYUVerCmdParser::parse() return true; } +Bool PlaYUVerCmdParser::parse( Options& opts, Int argc, Char *argv[] ) +{ + try + { + // m_cParserOptions.setDefaults(); + m_aUnhandledArgs = scanArgv( opts, argc, ( const Char** )argv ); + + } + catch( std::exception& e ) + { + std::cerr << "error: " + << e.what() + << "\n"; + return false; + } + catch( ... ) + { + std::cerr << "Exception of unknown type!\n"; + } + return true; +} + Bool PlaYUVerCmdParser::checkListingOpts() { Bool bRet = false; @@ -111,7 +133,6 @@ Bool PlaYUVerCmdParser::checkListingOpts() } bRet |= true; } - if( Opts()["quality_metrics"]->count() ) { printf( "PlaYUVer supported quality metrics: \n" ); @@ -121,7 +142,6 @@ Bool PlaYUVerCmdParser::checkListingOpts() } bRet |= true; } - return bRet; } diff --git a/lib/PlaYUVerCmdParser.h b/lib/PlaYUVerCmdParser.h index 8468c0c..75ea8c7 100644 --- a/lib/PlaYUVerCmdParser.h +++ b/lib/PlaYUVerCmdParser.h @@ -40,6 +40,7 @@ public: m_ppArgv = argv; } Bool parse(); + Bool parse( Options& opts, Int argc, Char *argv[] ); std::list& getNoArgs(); Options& Opts(); private: diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 3aaf893..985859c 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -54,6 +54,7 @@ namespace plaYUVer Options::Options( const std::string& name ) { opt_name = name; + allow_unknow = false; } Options::~Options() @@ -309,6 +310,8 @@ bool storePair( Options& opts, bool allow_long, bool allow_short, const string& if( !found ) { + if( !opts.allow_unknow ) + { /* not found */ cerr << "Unknown option: `" << name @@ -316,6 +319,7 @@ bool storePair( Options& opts, bool allow_long, bool allow_short, const string& << value << "')" << endl; + } return false; } diff --git a/lib/ProgramOptions.h b/lib/ProgramOptions.h index af69593..f96d588 100644 --- a/lib/ProgramOptions.h +++ b/lib/ProgramOptions.h @@ -263,6 +263,8 @@ struct Options NamesMap opt_short_map; std::string opt_name; + + Bool allow_unknow; }; /* Class with templated overloaded operator(), for use by Options::addOptions() */ diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 1dce7dd..e7d54f7 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -37,6 +37,7 @@ ADD_MODULE( FilterComponentChromaU "FilterComponent" ) ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) +ADD_MODULE( FrameBinarization "FrameBinarization" ) ADD_MODULE( LumaAverage "LumaAverage" ) IF( USE_OPENCV ) ADD_MODULE( DisparityStereoVar "DisparityStereoVar" ) @@ -48,4 +49,7 @@ ENDIF() # file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#endif // __MODULESLISTHEADER_H__\n" ) +INCLUDE_DIRECTORIES( ${OpenCV_INCLUDE_DIRS} ) ADD_LIBRARY( PlaYUVerModules ${plaYUver_Mod_SRCS} ) +TARGET_LINK_LIBRARIES( PlaYUVerModules PlaYUVerLib ${OpenCV_LIBRARIES} ) + diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 3007499..a1fb91a 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -37,6 +37,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "FilterComponentChromaU", &FilterComponentChromaU::Create ); Register( "FilterComponentChromaV", &FilterComponentChromaV::Create ); Register( "FrameDifference", &FrameDifference::Create ); + Register( "FrameBinarization", &FrameBinarization::Create ); Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create ); Register( "LumaAverage", &LumaAverage::Create ); #ifdef USE_OPENCV @@ -59,7 +60,7 @@ PlaYUVerModuleIf *PlaYUVerModuleFactory::CreateModule( const char* moduleName ) { PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); - for( ; it != PlaYUVerModuleFactoryMap.end(); ++it) + for( ; it != PlaYUVerModuleFactoryMap.end(); ++it ) { if( !strcmp( it->first, moduleName ) ) { diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index 54d886f..4388a0c 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -28,6 +28,7 @@ #include "lib/PlaYUVerDefs.h" #include "lib/PlaYUVerFrame.h" #include "lib/PlaYUVerStream.h" +#include "lib/ProgramOptions.h" namespace plaYUVer { @@ -84,6 +85,8 @@ public: UInt m_uiModuleRequirements; Bool m_bApplyWhilePlaying; + Options m_cModuleOptions; + PlaYUVerModuleIf() {} virtual ~PlaYUVerModuleIf() {} diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index ba07d58..74b569e 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -87,13 +87,23 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) m_uiLogLevel = RESULT; } - if( Opts()["help"]->count() ) + if( Opts()["module"]->count() && Opts()["help"]->count() ) + { + listModuleHelp(); + iRet = 1; + } + else if( Opts()["help"]->count() ) { printf( "Usage: %s modules/quality [options] -input=input_file [--output=output_file]\n", argv[0] ); doHelp( std::cout, Opts() ); iRet = 1; } + if( Opts()["module_list"]->count() || Opts()["module_list_full"]->count() ) + { + listModules(); + iRet = 1; + } return iRet; } @@ -151,7 +161,28 @@ Void CommandLineHandle::listModules() } printf( "\n" ); } +} +Void CommandLineHandle::listModuleHelp() +{ + std::string moduleName = m_strModule; + PlaYUVerModuleIf* pcCurrModuleIf = NULL; + + PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap(); + PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin(); + for( UInt i = 0; it != PlaYUVerModuleFactoryMap.end(); ++it, i++ ) + { + if( strcmp( it->first, moduleName.c_str() ) == 0 ) + { + pcCurrModuleIf = it->second(); + break; + } + } + if( pcCurrModuleIf ) + { + printf( "Usage: playuverTools --module=%s options:\n", it->first ); + doHelp( std::cout, pcCurrModuleIf->m_cModuleOptions ); + } } } // NAMESPACE diff --git a/tools/CommandLineHandle.h b/tools/CommandLineHandle.h index e1a0942..e778d1e 100644 --- a/tools/CommandLineHandle.h +++ b/tools/CommandLineHandle.h @@ -94,6 +94,7 @@ private: std::string m_strModule; Void listModules(); + Void listModuleHelp(); }; diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 6562ab4..e1b52e6 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -180,13 +180,15 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); + m_pcCurrModuleIf->m_cModuleOptions.allow_unknow = true; + scanArgv( m_pcCurrModuleIf->m_cModuleOptions, argc, ( const Char** )argv ); + if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { // Check outputs std::vector outputFileNames; if( m_cCmdLineHandler.Opts()["output"]->count() ) outputFileNames.push_back( m_cCmdLineHandler.m_strOutput ); - ; if( outputFileNames.size() == 1 ) { From dbd101e8de67332563153e63898dcdfd287b40b7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 22 Mar 2015 04:29:36 +0000 Subject: [PATCH 19/94] Add FrameBinarization module --- modules/FrameBinarization.cpp | 74 +++++++++++++++++++++++++++++++++++ modules/FrameBinarization.h | 54 +++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 modules/FrameBinarization.cpp create mode 100644 modules/FrameBinarization.h diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp new file mode 100644 index 0000000..27bcb33 --- /dev/null +++ b/modules/FrameBinarization.cpp @@ -0,0 +1,74 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file FrameBinarization.cpp + * \brief Binarize frame module + */ + +#include "FrameBinarization.h" + +namespace plaYUVer +{ + +FrameBinarization::FrameBinarization() +{ + /* Module Definition */ + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Measurements"; + m_pchModuleName = "FrameBinarization"; + m_pchModuleTooltip = "Binarize frame"; + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; + + m_cModuleOptions.addOptions()/**/ + ( "threshold", m_uiThreshold, "threshold value" ); + + m_pcBinFrame = NULL; + m_uiThreshold = 128; +} + +Void FrameBinarization::create( PlaYUVerFrame* frame ) +{ + m_pcBinFrame = NULL; + m_pcBinFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), PlaYUVerFrame::GRAY ); +} + +PlaYUVerFrame* FrameBinarization::process( PlaYUVerFrame* frame ) +{ + Pel* pPelInput = frame->getPelBufferYUV()[0][0]; + Pel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0]; + for( UInt y = 0; y < frame->getHeight(); y++ ) + for( UInt x = 0; x < frame->getWidth(); x++ ) + { + *pPelBin++ = *pPelInput++ >= m_uiThreshold ? 255 : 0; + } + return m_pcBinFrame; +} + +Void FrameBinarization::destroy() +{ + if( m_pcBinFrame ) + delete m_pcBinFrame; + m_pcBinFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/FrameBinarization.h b/modules/FrameBinarization.h new file mode 100644 index 0000000..5efca95 --- /dev/null +++ b/modules/FrameBinarization.h @@ -0,0 +1,54 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file FrameBinarization.h + * \brief Binarize frame module + */ + +#ifndef __FRAMEBINARIZATION_H__ +#define __FRAMEBINARIZATION_H__ + +#include "PlaYUVerModuleIf.h" + +namespace plaYUVer +{ + +class FrameBinarization: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( FrameBinarization ) + +private: + PlaYUVerFrame* m_pcBinFrame; + UInt m_uiThreshold; +public: + FrameBinarization(); + virtual ~FrameBinarization() + { + } + Void create( PlaYUVerFrame* ); + PlaYUVerFrame* process( PlaYUVerFrame* ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __LUMAAVERAGE_H__ + From c920ebe540ea3415bec6776991bc0d77bb7f2b3e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 23 Mar 2015 00:30:15 +0000 Subject: [PATCH 20/94] Create a dialog to configure module options --- app/CMakeLists.txt | 1 + app/ConfigureFormatDialog.cpp | 2 +- app/ModulesHandle.cpp | 4 +++ app/PlaYUVerAppModuleIf.h | 12 ++++--- lib/ProgramOptions.cpp | 50 +++++++++++++-------------- lib/ProgramOptions.h | 63 +++++++++++++++-------------------- 6 files changed, 65 insertions(+), 67 deletions(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0c5c485..153d69f 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -62,6 +62,7 @@ set(plaYUVer_App_SRCS external/qcustomplot.cpp # Module Plugins ModulesHandle.cpp + ModulesHandleOptDialog.cpp ModuleHandleDock.cpp PlaYUVerAppModuleIf.cpp GridManager.cpp diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index e5dc4fa..25b415f 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -243,4 +243,4 @@ void ConfigureFormatDialog::StandardResolutionSelection() m_spinBoxheight->setValue( currSize.height() ); } -} // Namespace SCode +} // NAMESPACE diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 4e19ce7..629e23a 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -28,6 +28,7 @@ #include "VideoHandle.h" #include "PlaYUVerModuleFactory.h" #include "DialogSubWindowSelector.h" +#include "ModulesHandleOptDialog.h" namespace plaYUVer { @@ -302,6 +303,9 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) pcCurrModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i ); } + ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf ); + moduleOptDialog.runConfiguration(); + if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) { if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h index 5dda03d..69524b3 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/PlaYUVerAppModuleIf.h @@ -43,20 +43,20 @@ class VideoSubWindow; class PlaYUVerAppModuleIf #ifdef PLAYUVER_THREADED_MODULES - : public QThread + : public QThread #else - : public QObject + : public QObject #endif { friend class ModulesHandle; friend class ModuleHandleDock; + friend class ModulesHandleOptDialog; private: QAction* m_pcModuleAction; PlaYUVerModuleIf* m_pcModule; - VideoSubWindow* m_pcSubWindow[MAX_NUMBER_FRAMES]; VideoSubWindow* m_pcDisplaySubWindow; @@ -83,8 +83,10 @@ public: PlaYUVerAppModuleIf* m_pcModule; }; - PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ); - virtual ~PlaYUVerAppModuleIf() {} + PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module ); + virtual ~PlaYUVerAppModuleIf() + { + } protected: virtual void run(); diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 985859c..233ae41 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -59,7 +59,7 @@ Options::Options( const std::string& name ) Options::~Options() { - for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { delete *it; } @@ -72,12 +72,12 @@ OptionBase* Options::operator[]( const std::string& optName ) OptionBase* Options::getOption( const std::string& optName ) { - Options::NamesMap::iterator opt_it; + Options::OptionMap::iterator opt_it; opt_it = opt_short_map.find( optName ); if( opt_it != opt_short_map.end() ) { - NamesPtrList opt_list = ( *opt_it ).second; - for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + OptionsList opt_list = ( *opt_it ).second; + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { return ( *it )->opt; } @@ -85,8 +85,8 @@ OptionBase* Options::getOption( const std::string& optName ) opt_it = opt_long_map.find( optName ); if( opt_it != opt_long_map.end() ) { - NamesPtrList opt_list = ( *opt_it ).second; - for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + OptionsList opt_list = ( *opt_it ).second; + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { return ( *it )->opt; } @@ -96,7 +96,7 @@ OptionBase* Options::getOption( const std::string& optName ) void Options::addOption( OptionBase *opt ) { - Names* names = new Names(); + Option* names = new Option(); names->opt = opt; string& opt_string = opt->opt_string; @@ -136,17 +136,17 @@ OptionSpecific Options::addOptions() * default value */ Void Options::setDefaults() { -// for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) +// for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) // { // ( *it )->opt->setDefault(); // } } -static void setOptions( Options::NamesPtrList& opt_list, const string& value ) +static void setOptions( Options::OptionsList& opt_list, const string& value ) { /* multiple options may be registered for the same name: * allow each to parse value */ - for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it ) { ( *it )->opt->parse( value ); } @@ -158,7 +158,7 @@ static const char spaces[41] = " "; * using the formatting: "-x, --long", * if a short/long option isn't specified, it is not printed */ -static void doHelpOpt( ostream& out, const Options::Names& entry, unsigned pad_short = 0 ) +static void doHelpOpt( ostream& out, const Options::Option& entry, unsigned pad_short = 0 ) { pad_short = min( pad_short, 8u ); @@ -192,7 +192,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns ) const unsigned pad_short = 3; /* first pass: work out the longest option name */ unsigned max_width = 0; - for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) + for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) { ostringstream line( ios_base::out ); doHelpOpt( line, **it, pad_short ); @@ -207,7 +207,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns ) * - if the option text is longer than opt_width, place the help * text at opt_width on the next line. */ - for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) + for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) { ostringstream line( ios_base::out ); line << " "; @@ -288,7 +288,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns ) bool storePair( Options& opts, bool allow_long, bool allow_short, const string& name, const string& value ) { bool found = false; - Options::NamesMap::iterator opt_it; + Options::OptionMap::iterator opt_it; if( allow_long ) { opt_it = opts.opt_long_map.find( name ); @@ -310,16 +310,16 @@ bool storePair( Options& opts, bool allow_long, bool allow_short, const string& if( !found ) { - if( !opts.allow_unknow ) - { - /* not found */ - cerr << "Unknown option: `" - << name - << "' (value:`" - << value - << "')" - << endl; - } +// if( !opts.allow_unknow ) +// { +// /* not found */ +// cerr << "Unknown option: `" +// << name +// << "' (value:`" +// << value +// << "')" +// << endl; +// } return false; } @@ -535,7 +535,7 @@ void scanFile( Options& opts, istream& in ) * default value */ void setDefaults( Options& opts ) { -// for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) +// for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) // { // ( *it )->opt->setDefault(); // } diff --git a/lib/ProgramOptions.h b/lib/ProgramOptions.h index f96d588..dc6fd20 100644 --- a/lib/ProgramOptions.h +++ b/lib/ProgramOptions.h @@ -106,7 +106,6 @@ struct OptionBase virtual void parse( const std::string& arg ) = 0; /* set the argument to the default value */ //virtual void setDefault() = 0; - int count() { return arg_count; @@ -143,9 +142,9 @@ struct FlagOpt: public OptionBase /** Type specific option storage */ template -struct Option: public OptionBase +struct StandardOpt: public OptionBase { - Option( const std::string& name, T& storage, const std::string& desc ) : + StandardOpt( const std::string& name, T& storage, const std::string& desc ) : OptionBase( name, desc ), opt_storage( storage ) { @@ -163,7 +162,7 @@ struct Option: public OptionBase /* Generic parsing */ template -inline void Option::parse( const std::string& arg ) +inline void StandardOpt::parse( const std::string& arg ) { std::istringstream arg_ss( arg, std::istringstream::in ); arg_ss.exceptions( std::ios::failbit ); @@ -181,7 +180,7 @@ inline void Option::parse( const std::string& arg ) /* string parsing is specialized -- copy the whole string, not just the * first word */ template<> -inline void Option::parse( const std::string& arg ) +inline void StandardOpt::parse( const std::string& arg ) { opt_storage = arg; arg_count++; @@ -190,7 +189,7 @@ inline void Option::parse( const std::string& arg ) /* string parsing is specialized -- copy the whole string, not just the * first word */ template<> -inline void Option >::parse( const std::string& arg ) +inline void StandardOpt >::parse( const std::string& arg ) { opt_storage.push_back( arg ); arg_count++; @@ -225,22 +224,18 @@ private: }; class OptionSpecific; -struct Options +class Options { - Options( const std::string& name = "" ); - ~Options(); +public: - OptionSpecific addOptions(); - Void setDefaults(); - - struct Names + struct Option { - Names() : + Option() : opt( 0 ) { } ; - ~Names() + ~Option() { if( opt ) delete opt; @@ -249,18 +244,28 @@ struct Options std::list opt_short; OptionBase* opt; }; + typedef std::list OptionsList; + OptionsList opt_list; + + Options( const std::string& name = "" ); + ~Options(); + + OptionSpecific addOptions(); + Void setDefaults(); OptionBase* operator[]( const std::string& optName ); OptionBase* getOption( const std::string& optName ); + OptionsList& getOptionList() + { + return opt_list; + } + void addOption( OptionBase *opt ); - typedef std::list NamesPtrList; - NamesPtrList opt_list; - - typedef std::map NamesMap; - NamesMap opt_long_map; - NamesMap opt_short_map; + typedef std::map OptionMap; + OptionMap opt_long_map; + OptionMap opt_short_map; std::string opt_name; @@ -286,24 +291,10 @@ public: OptionSpecific& operator()( const std::string& name, T& storage, const std::string& desc ) { - parent.addOption( new Option( name, storage, desc ) ); + parent.addOption( new StandardOpt( name, storage, desc ) ); return *this; } -// /** -// * Add option described by name to the parent Options list, -// * with storage for the option's value -// * with default_val as the default value -// * with desc as an optional help description -// */ -// template -// OptionSpecific& -// operator()( const std::string& name, T& storage, const std::string& desc ) -// { -// parent.addOption( new Option( name, storage, desc ) ); -// return *this; -// } - /** * Add option described by name to the parent Options list, * with storage for the option's value From 2a2a8a1bddc78712951f8c9c534656e90dfef573 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 23 Mar 2015 00:30:53 +0000 Subject: [PATCH 21/94] Add missing files --- app/ModulesHandleOptDialog.cpp | 126 +++++++++++++++++++++++++++++++++ app/ModulesHandleOptDialog.h | 56 +++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 app/ModulesHandleOptDialog.cpp create mode 100644 app/ModulesHandleOptDialog.h diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp new file mode 100644 index 0000000..18bc71f --- /dev/null +++ b/app/ModulesHandleOptDialog.cpp @@ -0,0 +1,126 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ModulesHandleOptDialog.cpp + * \brief Dialog box to config modules opts + */ + +#include "ModulesHandleOptDialog.h" +#include "lib/ProgramOptions.h" +#include +#include +#include +#include +#include + +namespace plaYUVer +{ + +class OpionConfiguration: public QWidget +{ +public: + OpionConfiguration( QWidget *parent, const QString& optName ) : + QWidget( parent ), + m_cName( optName ) + { + m_pcCheckBox = new QCheckBox( this ); + m_pcCheckBox->setText( optName ); + m_pcSpinBox = new QSpinBox( this ); + QHBoxLayout* layout = new QHBoxLayout( this ); + layout->addWidget( m_pcCheckBox ); + layout->addWidget( m_pcSpinBox ); + m_pcSpinBox->setMaximum( 999 ); + } + + Bool getChecked() + { + return m_pcCheckBox->checkState() == Qt::Checked; + } + Int getValue() + { + return m_pcSpinBox->value(); + } + QString& getName() + { + return m_cName; + } +private: + QCheckBox* m_pcCheckBox; + QSpinBox* m_pcSpinBox; + QString m_cName; +}; + +ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf ) : + QDialog( parent ), + m_pcCurrModuleIf( pcCurrModuleIf ) +{ + resize( 300, 10 ); + setWindowTitle( "Configure Resolution" ); + setWindowIcon( QIcon( ":/images/configureformat.png" ) ); + + const Options::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); + + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + + OpionConfiguration* pcOption; + for( Options::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) + { + pcOption = new OpionConfiguration( this, QString::fromStdString( ( *it )->opt->opt_string ) ); + m_apcOptionList.append( pcOption ); + mainLayout->addWidget( pcOption ); + } + + QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox(); + dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) ); + dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); + dialogButtonOkCancel->setCenterButtons( false ); + + mainLayout->addWidget( dialogButtonOkCancel ); + + connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); + connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); +} + +Int ModulesHandleOptDialog::runConfiguration() +{ + if( exec() == QDialog::Rejected ) + { + return QDialog::Rejected; + } + QString optionString( "" ); + Int argsCount = 0; + for( Int i = 0; i < m_apcOptionList.size(); i++ ) + { + if( m_apcOptionList.at( i )->getChecked() ) + { + optionString.append( QString( "--%1=%2" ).arg( m_apcOptionList.at( i )->getName() ).arg( m_apcOptionList.at( i )->getValue() ) ); + argsCount++; + } + } + if( argsCount > 0 ) + { + std::string optionStdString = optionString.toStdString(); + scanLine( m_pcCurrModuleIf->m_pcModule->m_cModuleOptions, optionStdString ); + qDebug( ) << optionString; + } + return QDialog::Accepted; +} + +} // NAMESPACE diff --git a/app/ModulesHandleOptDialog.h b/app/ModulesHandleOptDialog.h new file mode 100644 index 0000000..bb7eac2 --- /dev/null +++ b/app/ModulesHandleOptDialog.h @@ -0,0 +1,56 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file ModulesHandleOptDialog.h + * \brief Dialog box to config modules opts + */ + +#ifndef __MODULEHANDLEOPTDIALOG_H__ +#define __MODULEHANDLEOPTDIALOG_H__ + +#include "config.h" +#include "PlaYUVerAppDefs.h" +#include "PlaYUVerAppModuleIf.h" +#include +#include + +namespace plaYUVer +{ + +class OpionConfiguration; + +/** + * + */ +class ModulesHandleOptDialog: public QDialog +{ +Q_OBJECT + +public: + ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf ); + Int runConfiguration(); +private: + PlaYUVerAppModuleIf *m_pcCurrModuleIf; + QVector m_apcOptionList; +}; + +} // NAMESPACE + +#endif // __MODULEHANDLEOPTDIALOG_H__ From 53d5ae4139954ef9654a252a502fff39965578fe Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 16:14:54 +0000 Subject: [PATCH 22/94] Clean ModulesHandleOptDialog code --- app/ModulesHandleOptDialog.cpp | 40 +++++++++++++++------------------- modules/FrameBinarization.cpp | 2 +- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp index 18bc71f..2cac1b6 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/ModulesHandleOptDialog.cpp @@ -36,34 +36,28 @@ namespace plaYUVer class OpionConfiguration: public QWidget { public: - OpionConfiguration( QWidget *parent, const QString& optName ) : - QWidget( parent ), - m_cName( optName ) + OpionConfiguration( QWidget *parent, OptionBase* option ) : + QWidget( parent ) { - m_pcCheckBox = new QCheckBox( this ); - m_pcCheckBox->setText( optName ); - m_pcSpinBox = new QSpinBox( this ); + m_cName = QString::fromStdString( option->opt_string ); + m_pcDescription = new QLabel( this ); + m_pcDescription->setText( QString::fromStdString( option->opt_desc ) ); + m_pcValue = new QLineEdit( this ); QHBoxLayout* layout = new QHBoxLayout( this ); - layout->addWidget( m_pcCheckBox ); - layout->addWidget( m_pcSpinBox ); - m_pcSpinBox->setMaximum( 999 ); + layout->addWidget( m_pcDescription ); + layout->addWidget( m_pcValue ); } - - Bool getChecked() + QString getValue() { - return m_pcCheckBox->checkState() == Qt::Checked; - } - Int getValue() - { - return m_pcSpinBox->value(); + return m_pcValue->text(); } QString& getName() { return m_cName; } private: - QCheckBox* m_pcCheckBox; - QSpinBox* m_pcSpinBox; + QLineEdit* m_pcValue; + QLabel* m_pcDescription; QString m_cName; }; @@ -72,7 +66,7 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu m_pcCurrModuleIf( pcCurrModuleIf ) { resize( 300, 10 ); - setWindowTitle( "Configure Resolution" ); + setWindowTitle( "Select module parameters" ); setWindowIcon( QIcon( ":/images/configureformat.png" ) ); const Options::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); @@ -82,7 +76,7 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu OpionConfiguration* pcOption; for( Options::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) { - pcOption = new OpionConfiguration( this, QString::fromStdString( ( *it )->opt->opt_string ) ); + pcOption = new OpionConfiguration( this, ( *it )->opt ); m_apcOptionList.append( pcOption ); mainLayout->addWidget( pcOption ); } @@ -105,12 +99,14 @@ Int ModulesHandleOptDialog::runConfiguration() return QDialog::Rejected; } QString optionString( "" ); + QString valueString( "" ); Int argsCount = 0; for( Int i = 0; i < m_apcOptionList.size(); i++ ) { - if( m_apcOptionList.at( i )->getChecked() ) + valueString = m_apcOptionList.at( i )->getValue(); + if( !valueString.isEmpty() ) { - optionString.append( QString( "--%1=%2" ).arg( m_apcOptionList.at( i )->getName() ).arg( m_apcOptionList.at( i )->getValue() ) ); + optionString.append( QString( "--%1=%2" ).arg( m_apcOptionList.at( i )->getName() ).arg( valueString ) ); argsCount++; } } diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp index 27bcb33..5f4dfe1 100644 --- a/modules/FrameBinarization.cpp +++ b/modules/FrameBinarization.cpp @@ -39,7 +39,7 @@ FrameBinarization::FrameBinarization() m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; m_cModuleOptions.addOptions()/**/ - ( "threshold", m_uiThreshold, "threshold value" ); + ( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" ); m_pcBinFrame = NULL; m_uiThreshold = 128; From fb36f82bc127cfe014cb1d117a5b080b43a192fd Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 17:50:23 +0000 Subject: [PATCH 23/94] Change ProgramOptions functions to classes and create a new parser from string arrays --- app/ModulesHandleOptDialog.cpp | 35 ++- app/PlaYUVerApp.cpp | 2 +- lib/PlaYUVerCmdParser.cpp | 4 +- lib/ProgramOptions.cpp | 481 ++++++++++++++------------------- lib/ProgramOptions.h | 29 +- tools/CommandLineHandle.cpp | 4 +- tools/PlaYUVerTools.cpp | 3 +- 7 files changed, 247 insertions(+), 311 deletions(-) diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp index 2cac1b6..c6f992a 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/ModulesHandleOptDialog.cpp @@ -39,33 +39,35 @@ public: OpionConfiguration( QWidget *parent, OptionBase* option ) : QWidget( parent ) { - m_cName = QString::fromStdString( option->opt_string ); + m_cName = option->opt_string; m_pcDescription = new QLabel( this ); m_pcDescription->setText( QString::fromStdString( option->opt_desc ) ); m_pcValue = new QLineEdit( this ); + m_pcValue->setMinimumWidth( 40 ); + m_pcValue->setMaximumWidth( 65 ); QHBoxLayout* layout = new QHBoxLayout( this ); - layout->addWidget( m_pcDescription ); - layout->addWidget( m_pcValue ); + layout->addWidget( m_pcDescription, Qt::AlignLeft ); + layout->addWidget( m_pcValue, Qt::AlignRight ); } - QString getValue() + const QString getValue() const { return m_pcValue->text(); } - QString& getName() + const std::string& getName() { return m_cName; } private: QLineEdit* m_pcValue; QLabel* m_pcDescription; - QString m_cName; + std::string m_cName; }; ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModuleIf *pcCurrModuleIf ) : QDialog( parent ), m_pcCurrModuleIf( pcCurrModuleIf ) { - resize( 300, 10 ); + resize( 400, 10 ); setWindowTitle( "Select module parameters" ); setWindowIcon( QIcon( ":/images/configureformat.png" ) ); @@ -98,23 +100,26 @@ Int ModulesHandleOptDialog::runConfiguration() { return QDialog::Rejected; } - QString optionString( "" ); + + std::vector argsArray; + std::string optionString; QString valueString( "" ); - Int argsCount = 0; + for( Int i = 0; i < m_apcOptionList.size(); i++ ) { valueString = m_apcOptionList.at( i )->getValue(); if( !valueString.isEmpty() ) { - optionString.append( QString( "--%1=%2" ).arg( m_apcOptionList.at( i )->getName() ).arg( valueString ) ); - argsCount++; + optionString.append( "--" ); + optionString.append( m_apcOptionList.at( i )->getName() ); + optionString.append( "=" ); + optionString.append( valueString.toStdString() ); + argsArray.push_back( optionString ); } } - if( argsCount > 0 ) + if( argsArray.size() > 0 ) { - std::string optionStdString = optionString.toStdString(); - scanLine( m_pcCurrModuleIf->m_pcModule->m_cModuleOptions, optionStdString ); - qDebug( ) << optionString; + m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.scanArgs( argsArray ); } return QDialog::Accepted; } diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 40276f4..c2ce416 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -106,7 +106,7 @@ Bool plaYUVerApp::parseArgs( Int argc, Char *argv[] ) if( m_pcCmdParser->Opts()["help"]->count() ) { printf( "Usage: %s [options] input_file[s]\n", argv[0] ); - doHelp( std::cout, m_pcCmdParser->Opts() ); + m_pcCmdParser->Opts().doHelp( std::cout ); bRet |= true; } if( m_pcCmdParser->Opts()["input"]->count() ) diff --git a/lib/PlaYUVerCmdParser.cpp b/lib/PlaYUVerCmdParser.cpp index 3030734..bee40bc 100644 --- a/lib/PlaYUVerCmdParser.cpp +++ b/lib/PlaYUVerCmdParser.cpp @@ -65,7 +65,7 @@ Bool PlaYUVerCmdParser::parse() try { // m_cParserOptions.setDefaults(); - m_aUnhandledArgs = scanArgv( m_cParserOptions, m_iArgc, ( const Char** )m_ppArgv ); + m_aUnhandledArgs = m_cParserOptions.scanArgv( m_iArgc, ( const Char** )m_ppArgv ); // for( std::list::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++ ) // { @@ -96,7 +96,7 @@ Bool PlaYUVerCmdParser::parse( Options& opts, Int argc, Char *argv[] ) try { // m_cParserOptions.setDefaults(); - m_aUnhandledArgs = scanArgv( opts, argc, ( const Char** )argv ); + m_aUnhandledArgs = opts.scanArgv( argc, ( const Char** )argv ); } catch( std::exception& e ) diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 233ae41..4288944 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -53,8 +53,8 @@ namespace plaYUVer Options::Options( const std::string& name ) { - opt_name = name; - allow_unknow = false; + m_cOptionGroupName = name; + m_bAllowUnkonw = true; } Options::~Options() @@ -152,6 +152,207 @@ static void setOptions( Options::OptionsList& opt_list, const string& value ) } } +Bool Options::storePair( Bool allow_long, Bool allow_short, const string& name, const string& value ) +{ + bool found = false; + Options::OptionMap::iterator opt_it; + if( allow_long ) + { + opt_it = opt_long_map.find( name ); + if( opt_it != opt_long_map.end() ) + { + found = true; + } + } + + /* check for the short list */ + if( allow_short && !( found && allow_long ) ) + { + opt_it = opt_short_map.find( name ); + if( opt_it != opt_short_map.end() ) + { + found = true; + } + } + + if( !found ) + { + if( !m_bAllowUnkonw ) + { + /* not found */ + cerr << "Unknown option: `" + << name + << "' (value:`" + << value + << "')" + << endl; + } + return false; + } + + setOptions( ( *opt_it ).second, value ); + return true; +} + +Bool Options::storePair( const string& name, const string& value ) +{ + return storePair( true, true, name, value ); +} + +/** + * returns number of extra arguments consumed + */ +UInt Options::parseLONG( unsigned argc, const char* argv[] ) +{ + /* gnu style long options can take the forms: + * --option=arg + * --option arg + */ + string arg( argv[0] ); + size_t arg_opt_start = arg.find_first_not_of( '-' ); + size_t arg_opt_sep = arg.find_first_of( '=' ); + string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); + + unsigned extra_argc_consumed = 0; + if( arg_opt_sep == string::npos ) + { + /* no argument found => argument in argv[1] (maybe) */ + /* xxx, need to handle case where option isn't required */ +#if 0 + /* commented out, to return to true GNU style processing + * where longopts have to include an =, otherwise they are + * booleans */ + if (argc == 1) + return 0; /* run out of argv for argument */ + extra_argc_consumed = 1; +#endif + if( !storePair( true, false, option, "1" ) ) + { + return 0; + } + } + else + { + /* argument occurs after option_sep */ + string val = arg.substr( arg_opt_sep + 1 ); + storePair( true, false, option, val ); + } + return extra_argc_consumed; +} + +/** + * returns number of extra arguments consumed + */ +UInt Options::parseLONG( string arg ) +{ + /* gnu style long options can take the forms: + * --option=arg + * --option arg + */ + size_t arg_opt_start = arg.find_first_not_of( '-' ); + size_t arg_opt_sep = arg.find_first_of( '=' ); + string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); + + unsigned extra_argc_consumed = 0; + if( arg_opt_sep == string::npos ) + { + /* no argument found => argument in argv[1] (maybe) */ + /* xxx, need to handle case where option isn't required */ + if( !storePair( true, false, option, "1" ) ) + { + return 0; + } + } + else + { + /* argument occurs after option_sep */ + string val = arg.substr( arg_opt_sep + 1 ); + storePair( true, false, option, val ); + } + return extra_argc_consumed; +} + +unsigned Options::parseSHORT( unsigned argc, const char* argv[] ) +{ + /* short options can take the forms: + * --option arg + * -option arg + */ + string arg( argv[0] ); + size_t arg_opt_start = arg.find_first_not_of( '-' ); + string option = arg.substr( arg_opt_start ); + /* lookup option */ + + /* argument in argv[1] */ + /* xxx, need to handle case where option isn't required */ + if( argc == 1 ) + { + cerr << "Not processing option without argument `" + << option + << "'" + << endl; + return 0; /* run out of argv for argument */ + } + storePair( false, true, option, string( argv[1] ) ); + + return 1; +} + +list Options::scanArgv( unsigned argc, const char* argv[] ) +{ + /* a list for anything that didn't get handled as an option */ + list non_option_arguments; + + for( unsigned i = 1; i < argc; i++ ) + { + if( argv[i][0] != '-' ) + { + non_option_arguments.push_back( argv[i] ); + continue; + } + + if( argv[i][1] == 0 ) + { + /* a lone single dash is an argument (usually signifying stdin) */ + non_option_arguments.push_back( argv[i] ); + continue; + } + + if( argv[i][1] != '-' ) + { + /* handle short (single dash) options */ +#if 0 + i += parsePOSIX(opts, argc - i, &argv[i]); +#else + i += parseSHORT( argc - i, &argv[i] ); +#endif + continue; + } + + if( argv[i][2] == 0 ) + { + /* a lone double dash ends option processing */ + while( ++i < argc ) + non_option_arguments.push_back( argv[i] ); + break; + } + + /* handle long (double dash) options */ + i += parseLONG( argc - i, &argv[i] ); + } + + return non_option_arguments; +} + +Void Options::scanArgs( std::vector args_array) +{ + for( unsigned i = 0; i < args_array.size(); i++ ) + { + i += parseLONG( args_array[0] ); + } + return; +} + static const char spaces[41] = " "; /* format help text for a single option: @@ -187,12 +388,12 @@ static void doHelpOpt( ostream& out, const Options::Option& entry, unsigned pad_ } /* format the help text */ -void doHelp( ostream& out, Options& opts, unsigned columns ) +Void Options::doHelp( ostream& out, unsigned columns ) { const unsigned pad_short = 3; /* first pass: work out the longest option name */ unsigned max_width = 0; - for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { ostringstream line( ios_base::out ); doHelpOpt( line, **it, pad_short ); @@ -207,7 +408,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns ) * - if the option text is longer than opt_width, place the help * text at opt_width on the next line. */ - for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) + for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ ) { ostringstream line( ios_base::out ); line << " "; @@ -285,275 +486,5 @@ void doHelp( ostream& out, Options& opts, unsigned columns ) } } -bool storePair( Options& opts, bool allow_long, bool allow_short, const string& name, const string& value ) -{ - bool found = false; - Options::OptionMap::iterator opt_it; - if( allow_long ) - { - opt_it = opts.opt_long_map.find( name ); - if( opt_it != opts.opt_long_map.end() ) - { - found = true; - } - } - - /* check for the short list */ - if( allow_short && !( found && allow_long ) ) - { - opt_it = opts.opt_short_map.find( name ); - if( opt_it != opts.opt_short_map.end() ) - { - found = true; - } - } - - if( !found ) - { -// if( !opts.allow_unknow ) -// { -// /* not found */ -// cerr << "Unknown option: `" -// << name -// << "' (value:`" -// << value -// << "')" -// << endl; -// } - return false; - } - - setOptions( ( *opt_it ).second, value ); - return true; -} - -bool storePair( Options& opts, const string& name, const string& value ) -{ - return storePair( opts, true, true, name, value ); -} - -/** - * returns number of extra arguments consumed - */ -unsigned parseGNU( Options& opts, unsigned argc, const char* argv[] ) -{ - /* gnu style long options can take the forms: - * --option=arg - * --option arg - */ - string arg( argv[0] ); - size_t arg_opt_start = arg.find_first_not_of( '-' ); - size_t arg_opt_sep = arg.find_first_of( '=' ); - string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start ); - - unsigned extra_argc_consumed = 0; - if( arg_opt_sep == string::npos ) - { - /* no argument found => argument in argv[1] (maybe) */ - /* xxx, need to handle case where option isn't required */ -#if 0 - /* commented out, to return to true GNU style processing - * where longopts have to include an =, otherwise they are - * booleans */ - if (argc == 1) - return 0; /* run out of argv for argument */ - extra_argc_consumed = 1; -#endif - if( !storePair( opts, true, false, option, "1" ) ) - { - return 0; - } - } - else - { - /* argument occurs after option_sep */ - string val = arg.substr( arg_opt_sep + 1 ); - storePair( opts, true, false, option, val ); - } - - return extra_argc_consumed; -} - -unsigned parseSHORT( Options& opts, unsigned argc, const char* argv[] ) -{ - /* short options can take the forms: - * --option arg - * -option arg - */ - string arg( argv[0] ); - size_t arg_opt_start = arg.find_first_not_of( '-' ); - string option = arg.substr( arg_opt_start ); - /* lookup option */ - - /* argument in argv[1] */ - /* xxx, need to handle case where option isn't required */ - if( argc == 1 ) - { - cerr << "Not processing option without argument `" - << option - << "'" - << endl; - return 0; /* run out of argv for argument */ - } - storePair( opts, false, true, option, string( argv[1] ) ); - - return 1; -} - -list scanArgv( Options& opts, unsigned argc, const char* argv[] ) -{ - /* a list for anything that didn't get handled as an option */ - list non_option_arguments; - - for( unsigned i = 1; i < argc; i++ ) - { - if( argv[i][0] != '-' ) - { - non_option_arguments.push_back( argv[i] ); - continue; - } - - if( argv[i][1] == 0 ) - { - /* a lone single dash is an argument (usually signifying stdin) */ - non_option_arguments.push_back( argv[i] ); - continue; - } - - if( argv[i][1] != '-' ) - { - /* handle short (single dash) options */ -#if 0 - i += parsePOSIX(opts, argc - i, &argv[i]); -#else - i += parseSHORT( opts, argc - i, &argv[i] ); -#endif - continue; - } - - if( argv[i][2] == 0 ) - { - /* a lone double dash ends option processing */ - while( ++i < argc ) - non_option_arguments.push_back( argv[i] ); - break; - } - - /* handle long (double dash) options */ - i += parseGNU( opts, argc - i, &argv[i] ); - } - - return non_option_arguments; -} - -void scanLine( Options& opts, string& line ) -{ - /* strip any leading whitespace */ - size_t start = line.find_first_not_of( " \t\n\r" ); - if( start == string::npos ) - { - /* blank line */ - return; - } - if( line[start] == '#' ) - { - /* comment line */ - return; - } - /* look for first whitespace or ':' after the option end */ - size_t option_end = line.find_first_of( ": \t\n\r", start ); - string option = line.substr( start, option_end - start ); - - /* look for ':', eat up any whitespace first */ - start = line.find_first_not_of( " \t\n\r", option_end ); - if( start == string::npos ) - { - /* error: badly formatted line */ - return; - } - if( line[start] != ':' ) - { - /* error: badly formatted line */ - return; - } - - /* look for start of value string -- eat up any leading whitespace */ - start = line.find_first_not_of( " \t\n\r", ++start ); - if( start == string::npos ) - { - /* error: badly formatted line */ - return; - } - - /* extract the value part, which may contain embedded spaces - * by searching for a word at a time, until we hit a comment or end of line */ - size_t value_end = start; - do - { - if( line[value_end] == '#' ) - { - /* rest of line is a comment */ - value_end--; - break; - } - value_end = line.find_first_of( " \t\n\r", value_end ); - /* consume any white space, incase there is another word. - * any trailing whitespace will be removed shortly */ - value_end = line.find_first_not_of( " \t\n\r", value_end ); - } - while( value_end != string::npos ); - /* strip any trailing space from value*/ - value_end = line.find_last_not_of( " \t\n\r", value_end ); - - string value; - if( value_end >= start ) - { - value = line.substr( start, value_end + 1 - start ); - } - else - { - /* error: no value */ - return; - } - - /* store the value in option */ - storePair( opts, true, false, option, value ); -} - -void scanFile( Options& opts, istream& in ) -{ - do - { - string line; - getline( in, line ); - scanLine( opts, line ); - } - while( !!in ); -} - -/* for all options in opts, set their storage to their specified - * default value */ -void setDefaults( Options& opts ) -{ -// for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ ) -// { -// ( *it )->opt->setDefault(); -// } -} - -void parseConfigFile( Options& opts, const string& filename ) -{ - ifstream cfgstream( filename.c_str(), ifstream::in ); - if( !cfgstream ) - { - cerr << "Failed to open config file: `" - << filename - << "'" - << endl; - exit( EXIT_FAILURE ); - } - scanFile( opts, cfgstream ); -} - } // NAMESPACE diff --git a/lib/ProgramOptions.h b/lib/ProgramOptions.h index dc6fd20..b27ae47 100644 --- a/lib/ProgramOptions.h +++ b/lib/ProgramOptions.h @@ -74,17 +74,6 @@ struct ParseFailure: public std::exception } }; -void doHelp( std::ostream& out, Options& opts, unsigned columns = 80 ); -unsigned parseGNU( Options& opts, unsigned argc, const char* argv[] ); -unsigned parseSHORT( Options& opts, unsigned argc, const char* argv[] ); -std::list scanArgv( Options& opts, unsigned argc, const char* argv[] ); -void scanLine( Options& opts, std::string& line ); -void scanFile( Options& opts, std::istream& in ); -void setDefaults( Options& opts ); -void setDefaults( Options* opts ); -void parseConfigFile( Options& opts, const std::string& filename ); -bool storePair( Options& opts, const std::string& name, const std::string& value ); - /** OptionBase: Virtual base class for storing information relating to a * specific option This base class describes common elements. Type specific * information should be stored in a derived class. */ @@ -245,11 +234,14 @@ public: OptionBase* opt; }; typedef std::list OptionsList; - OptionsList opt_list; Options( const std::string& name = "" ); ~Options(); + std::list scanArgv( unsigned argc, const char* argv[] ); + Void scanArgs( std::vector args_array); + Void doHelp( std::ostream& out, unsigned columns = 80 ); + OptionSpecific addOptions(); Void setDefaults(); @@ -263,13 +255,22 @@ public: void addOption( OptionBase *opt ); +private: + typedef std::map OptionMap; OptionMap opt_long_map; OptionMap opt_short_map; - std::string opt_name; + OptionsList opt_list; - Bool allow_unknow; + std::string m_cOptionGroupName; + Bool m_bAllowUnkonw; + + Bool storePair( Bool allow_long, Bool allow_short, const std::string& name, const std::string& value ); + Bool storePair( const std::string& name, const std::string& value ); + UInt parseLONG( unsigned argc, const char* argv[] ); + UInt parseLONG( std::string arg ); + unsigned parseSHORT( unsigned argc, const char* argv[] ); }; /* Class with templated overloaded operator(), for use by Options::addOptions() */ diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index 74b569e..75fb37c 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -95,7 +95,7 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) else if( Opts()["help"]->count() ) { printf( "Usage: %s modules/quality [options] -input=input_file [--output=output_file]\n", argv[0] ); - doHelp( std::cout, Opts() ); + Opts().doHelp( std::cout ); iRet = 1; } @@ -181,7 +181,7 @@ Void CommandLineHandle::listModuleHelp() if( pcCurrModuleIf ) { printf( "Usage: playuverTools --module=%s options:\n", it->first ); - doHelp( std::cout, pcCurrModuleIf->m_cModuleOptions ); + pcCurrModuleIf->m_cModuleOptions.doHelp( std::cout ); } } diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index e1b52e6..d9a9c3b 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -180,8 +180,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); - m_pcCurrModuleIf->m_cModuleOptions.allow_unknow = true; - scanArgv( m_pcCurrModuleIf->m_cModuleOptions, argc, ( const Char** )argv ); + m_pcCurrModuleIf->m_cModuleOptions.scanArgv( argc, ( const Char** )argv ); if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { From 4a4e0c1890b26ac4b989f888dd6dbf681b1da92f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 18:27:05 +0000 Subject: [PATCH 24/94] Change apply when playing and add OPTIONS requirement --- app/ModulesHandle.cpp | 31 ++++++------- modules/AbsoluteFrameDifference.cpp | 2 - modules/DisparityStereoVar.cpp | 3 +- modules/FilterComponent.cpp | 3 -- modules/FrameBinarization.cpp | 3 +- modules/FrameDifference.cpp | 1 - modules/LumaAverage.cpp | 18 ++++---- modules/PlaYUVerModuleIf.h | 72 +++++++++++++++++------------ 8 files changed, 70 insertions(+), 63 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 8bcd29d..35c4791 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -303,9 +303,11 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) pcCurrModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i ); } - ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf ); - moduleOptDialog.runConfiguration(); - + if( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_OPTIONS ) + { + ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf ); + moduleOptDialog.runConfiguration(); + } if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) { if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) @@ -326,18 +328,15 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) else if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { pcCurrModuleIf->m_pcDisplaySubWindow = NULL; - if( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SIDEBAR ) - { - pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrModuleIf ); - QString titleDockWidget; - titleDockWidget.append( pcCurrModuleIf->m_pcModule->m_pchModuleName ); - titleDockWidget.append( " Information" ); - pcCurrModuleIf->m_pcDockWidget = new QDockWidget( titleDockWidget, m_pcParent ); - pcCurrModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable ); - pcCurrModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); - pcCurrModuleIf->m_pcDockWidget->setWidget( pcCurrModuleIf->m_pcModuleDock ); - qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget ); - } + pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrModuleIf ); + QString titleDockWidget; + titleDockWidget.append( pcCurrModuleIf->m_pcModule->m_pchModuleName ); + titleDockWidget.append( " Information" ); + pcCurrModuleIf->m_pcDockWidget = new QDockWidget( titleDockWidget, m_pcParent ); + pcCurrModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable ); + pcCurrModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); + pcCurrModuleIf->m_pcDockWidget->setWidget( pcCurrModuleIf->m_pcModuleDock ); + qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget ); } // Create Module @@ -431,7 +430,7 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf, Bool isP { Bool bRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); - if( !isPlaying || ( isPlaying && pcCurrModuleIf->m_pcModule->m_bApplyWhilePlaying ) ) + if( !( isPlaying && ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) ) { #ifdef PLAYUVER_THREADED_MODULES if( !disableThreads ) diff --git a/modules/AbsoluteFrameDifference.cpp b/modules/AbsoluteFrameDifference.cpp index 8af3b45..d0c1405 100644 --- a/modules/AbsoluteFrameDifference.cpp +++ b/modules/AbsoluteFrameDifference.cpp @@ -37,8 +37,6 @@ AbsoluteFrameDifference::AbsoluteFrameDifference() m_pchModuleTooltip = "Measure the absolute difference between two images (Y plane), e. g., abs( Y1 - Y2 )"; m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; - m_pcFrameDifference = NULL; } diff --git a/modules/DisparityStereoVar.cpp b/modules/DisparityStereoVar.cpp index 1dee936..210bc17 100644 --- a/modules/DisparityStereoVar.cpp +++ b/modules/DisparityStereoVar.cpp @@ -37,8 +37,7 @@ DisparityStereoVar::DisparityStereoVar() m_pchModuleName = "StereoVar"; m_pchModuleTooltip = "Measure the disparity between two images using the Stereo Var method (OpenCV)"; m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; - m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING; + m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW; m_pcDisparityFrame = NULL; m_cStereoVar.levels = 3; // ignored with USE_AUTO_PARAMS diff --git a/modules/FilterComponent.cpp b/modules/FilterComponent.cpp index 6102704..17258fb 100644 --- a/modules/FilterComponent.cpp +++ b/modules/FilterComponent.cpp @@ -66,7 +66,6 @@ FilterComponentLuma::FilterComponentLuma() m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; // Module requirements (check PlaYUVerModulesIf.h). // Several requirements should be "or" between each others. - m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; // Apply module while playing } Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame ) @@ -88,7 +87,6 @@ FilterComponentChromaU::FilterComponentChromaU() m_pchModuleTooltip = "Filter U matrix of YUV frame"; m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; - m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING; } Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame ) @@ -110,7 +108,6 @@ FilterComponentChromaV::FilterComponentChromaV() m_pchModuleTooltip = "Filter V matrix of YUV frame"; m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; - m_bApplyWhilePlaying = !APPLY_WHILE_PLAYING; } Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame ) diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp index 5f4dfe1..ce46630 100644 --- a/modules/FrameBinarization.cpp +++ b/modules/FrameBinarization.cpp @@ -35,8 +35,7 @@ FrameBinarization::FrameBinarization() m_pchModuleName = "FrameBinarization"; m_pchModuleTooltip = "Binarize frame"; m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; - m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; + m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; m_cModuleOptions.addOptions()/**/ ( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" ); diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index f3b8dd1..983f1e7 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -37,7 +37,6 @@ FrameDifference::FrameDifference() m_pchModuleTooltip = "Measure the difference between two images (Y plane), Y1 - Y2, with max absolute diff of 128"; m_uiModuleRequirements = MODULE_REQUIRES_NEW_WINDOW; m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; - m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; m_pcFrameDifference = NULL; } diff --git a/modules/LumaAverage.cpp b/modules/LumaAverage.cpp index c32a79d..3636a72 100644 --- a/modules/LumaAverage.cpp +++ b/modules/LumaAverage.cpp @@ -30,13 +30,14 @@ namespace plaYUVer LumaAverage::LumaAverage() { /* Module Definition */ - m_iModuleType = FRAME_MEASUREMENT_MODULE; - m_pchModuleCategory = "Measurements"; - m_pchModuleName = "LumaAverage"; - m_pchModuleTooltip = "Measure the average of luma component"; - m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; - m_uiModuleRequirements = MODULE_REQUIRES_SIDEBAR; - m_bApplyWhilePlaying = APPLY_WHILE_PLAYING; + m_iModuleType = FRAME_MEASUREMENT_MODULE; // Apply module to the frames or to the whole sequence. + // Currently only support for frame + m_pchModuleCategory = "Measurements"; // Category (sub-menu) + m_pchModuleName = "LumaAverage"; // Name + m_pchModuleTooltip = "Measure the average of luma component"; // Description + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; // Module requirements (check PlaYUVerModulesIf.h). + // Several requirements should be "or" between each others. } Void LumaAverage::create( PlaYUVerFrame* frame ) @@ -61,5 +62,6 @@ Void LumaAverage::destroy() } -} // NAMESPACE +} +// NAMESPACE diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index 4388a0c..227374e 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -38,7 +38,7 @@ public: \ static PlaYUVerModuleIf* Create() { return new X(); } \ void Delete() { delete this; } -enum // Module type +enum // Module type { FRAME_PROCESSING_MODULE, FRAME_MEASUREMENT_MODULE, @@ -47,32 +47,21 @@ enum // Module type #define APPLY_WHILE_PLAYING true #define MAX_NUMBER_FRAMES 3 -enum // Number of frames +enum Module_NumberOfFrames { MODULE_REQUIRES_ONE_FRAME = 1, MODULE_REQUIRES_TWO_FRAMES = 2, MODULE_REQUIRES_THREE_FRAMES = 3, }; -enum // Requirements +enum Module_Requirements { MODULE_REQUIRES_NOTHING = 0, - MODULE_REQUIRES_NEW_WINDOW = 2, - MODULE_REQUIRES_SIDEBAR = 4, - MODULES_REQUIREMENTS_TOTAL, + MODULE_REQUIRES_SKIP_WHILE_PLAY = 2, + MODULE_REQUIRES_OPTIONS = 4, + MODULE_REQUIRES_NEW_WINDOW = 6, }; -typedef struct -{ - Int m_iModuleType; - const Char* m_pchModuleCategory; - const Char* m_pchModuleName; - const Char* m_pchModuleTooltip; - UInt m_uiNumberOfFrames; - UInt m_uiModuleRequirements; - Bool m_bApplyWhilePlaying; -} PlaYUVerModuleDefinition; - class PlaYUVerModuleIf { public: @@ -81,27 +70,52 @@ public: const Char* m_pchModuleCategory; const Char* m_pchModuleName; const Char* m_pchModuleTooltip; - UInt m_uiNumberOfFrames; + enum Module_NumberOfFrames m_uiNumberOfFrames; UInt m_uiModuleRequirements; - Bool m_bApplyWhilePlaying; Options m_cModuleOptions; - PlaYUVerModuleIf() {} - virtual ~PlaYUVerModuleIf() {} + PlaYUVerModuleIf() + { + } + virtual ~PlaYUVerModuleIf() + { + } virtual void Delete() = 0; - virtual Void create() {} - virtual Void create( PlaYUVerFrame* ) {} + virtual Void create() + { + } + virtual Void create( PlaYUVerFrame* ) + { + } - virtual PlaYUVerFrame* process( PlaYUVerFrame* ) { return NULL; } - virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame* ) { return NULL; } - virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) { return NULL; } + virtual PlaYUVerFrame* process( PlaYUVerFrame* ) + { + return NULL; + } + virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame* ) + { + return NULL; + } + virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) + { + return NULL; + } - virtual Double measure( PlaYUVerFrame* ) { return 0; } - virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame* ) { return 0; } - virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) { return 0; } + virtual Double measure( PlaYUVerFrame* ) + { + return 0; + } + virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame* ) + { + return 0; + } + virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) + { + return 0; + } virtual Void destroy() = 0; From bf7099a2b35d95ad18bc0f6fec44a5acbc5bd742 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 19:03:09 +0000 Subject: [PATCH 25/94] Fix frame slider - max value must be set first --- app/VideoHandle.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 759dafb..0ae2ea5 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -232,19 +232,19 @@ Void VideoHandle::update() total_frame_num = getMaxFrameNumber(); resolution.append( QString( "@%1" ).arg( pcStream->getFrameRate() ) ); } - else - { - m_pcFrameNumInfo->setCurrFrameNum( 0 ); - } if( pcFrame ) + { m_pcResolutionLabel->setText( resolution ); + } m_pcFramePropertiesSideBar->setData( pcFrame, m_pcCurrentVideoSubWindow->isPlaying() ); - m_pcFrameSlider->setValue( frame_num ); - m_pcFrameSlider->setMaximum( total_frame_num - 1 ); m_pcFrameNumInfo->setTotalFrameNum( total_frame_num ); + m_pcFrameSlider->setMaximum( total_frame_num - 1 ); + + m_pcFrameNumInfo->setCurrFrameNum( frame_num ); + m_pcFrameSlider->setValue( frame_num ); if( m_pcCurrentVideoSubWindow->isPlaying() ) m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); From 7d48785670b12a3dbc5241bd3e34324e13a45459 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 20:57:34 +0000 Subject: [PATCH 26/94] Fix window handle window menu --- app/PlaYUVerSubWindowHandle.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 1958d3d..aad2176 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -61,6 +61,7 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : { m_uiWindowMode = 0; + //setWindowMode( NormalSubWindows ); setWindowMode( MdiWSubWindows ); m_pcActiveWindow = NULL; @@ -111,7 +112,10 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) if( m_uiWindowMode == NormalSubWindows ) { if( window ) + { m_pcActiveWindow = window; + emit changed(); + } } if( m_uiWindowMode == MdiWSubWindows ) @@ -268,7 +272,15 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) return; m_pcActiveWindow = qobject_cast( window ); - m_pcActiveWindow->window()->activateWindow(); + + if( m_uiWindowMode == NormalSubWindows ) + { + m_pcActiveWindow->window()->activateWindow(); + } + if( m_uiWindowMode == MdiWSubWindows ) + { + m_pcActiveWindow->setFocus(); + } } Void PlaYUVerSubWindowHandle::tileSubWindows() @@ -306,7 +318,7 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions[TILE_WINDOWS_ACT] = new QAction( tr( "Tile" ), this ); m_arrayActions[TILE_WINDOWS_ACT]->setIcon( QIcon( ":images/windowstile.png" ) ); m_arrayActions[TILE_WINDOWS_ACT]->setStatusTip( tr( "Tile the windows" ) ); - //connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) ); +//connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), mdiArea, SLOT( tileSubWindows() ) ); connect( m_arrayActions[TILE_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( tileSubWindows() ) ); m_arrayActions[CASCADE_WINDOWS_ACT] = new QAction( tr( "Cascade" ), this ); @@ -318,13 +330,13 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild ); m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) ); m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) ); - // connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) ); +// connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activateNextSubWindow() ) ); m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this ); m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild ); m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) ); m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) ); - // connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) ); +// connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ), this, SLOT( activatePreviousSubWindow() ) ); m_arrayActions[SEPARATOR_ACT] = new QAction( this ); m_arrayActions[SEPARATOR_ACT]->setSeparator( true ); From 81d260a8eb33277635e5b6f80b7ff7e03cc9c119 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 20:58:11 +0000 Subject: [PATCH 27/94] Deploy bugfix version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a04c1d5..c8f107c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET( PROJECT_NAME "playuver" ) PROJECT( ${PROJECT_NAME} ) SET( PLAYUVER_VERSION_MAJOR "0" ) SET( PLAYUVER_VERSION_MINOR "6" ) -SET( PLAYUVER_VERSION_PATCH "1" ) +SET( PLAYUVER_VERSION_PATCH "2" ) SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}") From 1eb2c9093a192c66ec5c35ce0abe14685d7df4a7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 24 Mar 2015 23:05:08 +0000 Subject: [PATCH 28/94] Fix unitialized variables --- app/plaYUVerApp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/plaYUVerApp.cpp b/app/plaYUVerApp.cpp index 4119ced..fffe06d 100644 --- a/app/plaYUVerApp.cpp +++ b/app/plaYUVerApp.cpp @@ -39,7 +39,10 @@ namespace plaYUVer { -plaYUVerApp::plaYUVerApp() +plaYUVerApp::plaYUVerApp() : + m_pcCurrentSubWindow( NULL ), + m_pcCurrentVideoSubWindow( NULL ), + m_pcAboutDialog( NULL ) { setWindowModality( Qt::ApplicationModal ); @@ -78,9 +81,6 @@ plaYUVerApp::plaYUVerApp() connect( m_appModuleQuality, SIGNAL( changed() ), this, SLOT( update() ) ); connect( m_appModuleExtensions, SIGNAL( changed() ), this, SLOT( update() ) ); - m_pcAboutDialog = NULL; - m_pcCurrentSubWindow = NULL; - m_pcCurrentVideoSubWindow = NULL; } Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) From c0e1dcd4601233d4cf4dd2882f813942927ca972 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 01:19:05 +0000 Subject: [PATCH 29/94] Change DialogSubWindowSelector in order to use check boxes --- app/DialogSubWindowSelector.cpp | 199 ++++++++++++-------------------- app/DialogSubWindowSelector.h | 25 +++- app/ModulesHandle.cpp | 17 +-- app/QualityHandle.cpp | 33 ------ app/QualityHandle.h | 2 - app/VideoHandle.cpp | 14 +-- modules/PlaYUVerModuleIf.h | 6 +- tools/PlaYUVerTools.cpp | 8 ++ 8 files changed, 114 insertions(+), 190 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index 0b7d191..d36876a 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -22,6 +22,8 @@ * \brief Dialog box to select sub windows */ +#include +#include #include "PlaYUVerSubWindowHandle.h" #include "DialogSubWindowSelector.h" #include "VideoSubWindow.h" @@ -29,83 +31,58 @@ namespace plaYUVer { -DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected, Int maxWindowsSelected ) : +DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected, + Int maxWindowsSelected ) : QDialog( parent ), m_uiCategory( uiCategory ), m_iMinSelectedWindows( minWindowsSelected ), m_iMaxSlectedWindows( maxWindowsSelected ), m_pcMainWindowManager( windowManager ) { - QFont titleFont, menusFont; - - titleFont.setPointSize( 14 ); - titleFont.setBold( true ); - titleFont.setWeight( 75 ); - - menusFont.setBold( true ); - menusFont.setWeight( 75 ); QSize windowSize( 350, 80 ); resize( windowSize ); - setWindowTitle( "Sub Windows Selection" ); + setWindowTitle( "Select desired Sub-Windows" ); - QHBoxLayout* MainLayout = new QHBoxLayout( this ); + QVBoxLayout* mainLayout = new QVBoxLayout( this ); - // Window list and add button - m_comboBoxWindowList = new QComboBox(); - QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - sizePolicy.setHorizontalStretch( 0 ); - sizePolicy.setVerticalStretch( 0 ); - sizePolicy.setHeightForWidth( m_comboBoxWindowList->sizePolicy().hasHeightForWidth() ); - m_comboBoxWindowList->setSizePolicy( sizePolicy ); - m_comboBoxWindowList->setAcceptDrops( true ); + minWindowsSelected = minWindowsSelected == 0 ? 1 : minWindowsSelected; + + m_pcGroupCheckBox = new QGroupBox( tr( "Exclusive Radio Buttons" ) ); + m_pcGroupCheckBox->setLayout( new QVBoxLayout() ); + + mainLayout->addWidget( m_pcGroupCheckBox ); - m_pushButtonAdd = new QPushButton( "Add", this ); m_pushButtonAddAll = new QPushButton( "Add all", this ); - m_pushButtonRemove = new QPushButton( "Remove", this ); m_pushButtonRemoveAll = new QPushButton( "Remove All", this ); - m_pushButtonRemove->setEnabled( false ); m_pushButtonRemoveAll->setEnabled( false ); - // Selected Sub Window List - m_listSelectedWindows = new QListWidget( this ); - // Confirmation buttons m_pushButtonOkCancel = new QDialogButtonBox(); m_pushButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); - m_pushButtonOkCancel->setOrientation( Qt::Vertical ); + m_pushButtonOkCancel->setOrientation( Qt::Horizontal ); m_pushButtonOkCancel->setCenterButtons( false ); m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false ); - // Create Layouts - QVBoxLayout* LeftVLayout = new QVBoxLayout(); - LeftVLayout->addWidget( m_comboBoxWindowList ); - //LeftVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - LeftVLayout->addWidget( m_listSelectedWindows ); - - QVBoxLayout* RightVLayout = new QVBoxLayout(); - RightVLayout->addWidget( m_pushButtonAdd ); - RightVLayout->addWidget( m_pushButtonAddAll ); - RightVLayout->addWidget( m_pushButtonRemove ); - RightVLayout->addWidget( m_pushButtonRemoveAll ); - RightVLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); - RightVLayout->addWidget( m_pushButtonOkCancel ); + QHBoxLayout* BottomHLayout = new QHBoxLayout(); + BottomHLayout->addWidget( m_pushButtonAddAll ); + BottomHLayout->addWidget( m_pushButtonRemoveAll ); + BottomHLayout->addWidget( m_pushButtonOkCancel ); // Add components - //MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MainLayout->addLayout( LeftVLayout ); - MainLayout->addLayout( RightVLayout ); + mainLayout->addLayout( BottomHLayout ); - setLayout( MainLayout ); + setLayout( mainLayout ); // Create actions connect( m_pushButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( m_pushButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); - connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( addSubWindow() ) ); + connect( m_pushButtonAddAll, SIGNAL( clicked() ), this, SLOT( addAllSubWindow() ) ); - connect( m_pushButtonRemove, SIGNAL( clicked() ), this, SLOT( removeSubWindow() ) ); connect( m_pushButtonRemoveAll, SIGNAL( clicked() ), this, SLOT( removeAllSubWindow() ) ); - QMetaObject::connectSlotsByName( this ); + + m_mapperWindowsList = new QSignalMapper( this ); + connect( m_mapperWindowsList, SIGNAL( mapped(int) ), this, SLOT( toggleSubWindow(int) ) ); updateSubWindowList(); } @@ -115,49 +92,58 @@ Void DialogSubWindowSelector::updateSubWindowList() SubWindowHandle *subWindow; QString currSubWindowName; m_pcWindowListNames.clear(); - QList subWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); - for( Int i = 0; i < subWindowList.size(); i++ ) + m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); + + QCheckBox* windowCheckBox; + + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { - subWindow = subWindowList.at( i ); + subWindow = m_apcSubWindowList.at( i ); currSubWindowName = subWindow->getWindowName(); - if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) ) - m_pcWindowListNames.append( currSubWindowName ); + windowCheckBox = new QCheckBox( currSubWindowName, this ); + connect( windowCheckBox, SIGNAL( stateChanged(int) ), m_mapperWindowsList, SLOT( map() ) ); + m_mapperWindowsList->setMapping( windowCheckBox, i ); + m_pcGroupCheckBox->layout()->addWidget( windowCheckBox ); + m_apcWindowsListCheckBox.append( windowCheckBox ); } - m_comboBoxWindowList->clear(); - m_comboBoxWindowList->insertItems( 0, m_pcWindowListNames ); - m_comboBoxWindowList->setCurrentIndex( -1 ); - Bool enableAddAll = true; +} - if( m_iMaxSlectedWindows >= 0 ) +Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle* subWindow ) +{ + Int iIdx = m_apcSubWindowList.indexOf( subWindow ); + if( iIdx >= 0 ) { - if( m_pcSelectedWindowListNames.size() >= m_iMaxSlectedWindows ) - { - m_pushButtonAdd->setEnabled( false ); - } - else - { - m_pushButtonAdd->setEnabled( true ); - } - if( m_pcWindowListNames.size() > m_iMaxSlectedWindows ) - { - enableAddAll = false; - } + m_apcWindowsListCheckBox.at( iIdx )->setChecked( true ); + m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( iIdx ) ); } - m_pushButtonAddAll->setEnabled( enableAddAll ); +} - if( m_pcSelectedWindowListNames.size() > 0 ) +// ----------------------- Slot Functions ----------------------- + +Void DialogSubWindowSelector::toggleSubWindow( Int idx ) +{ + Bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked(); + + if( isChecked ) + { + m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) ); + } + else + { + m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); + } + + if( m_apcSelectedSubWindowList.size() > 0 ) { - m_pushButtonRemove->setEnabled( true ); m_pushButtonRemoveAll->setEnabled( true ); } else { - m_pushButtonRemove->setEnabled( false ); m_pushButtonRemoveAll->setEnabled( false ); } - if( m_pcSelectedWindowListNames.size() >= m_iMinSelectedWindows ) + if( m_apcSelectedSubWindowList.size() >= m_iMinSelectedWindows ) { m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( true ); } @@ -166,68 +152,35 @@ Void DialogSubWindowSelector::updateSubWindowList() m_pushButtonOkCancel->buttons().at( 0 )->setEnabled( false ); } -} - -Void DialogSubWindowSelector::setSubWindowList( QStringList cWindowListNames ) -{ - m_pcSelectedWindowListNames = cWindowListNames; - m_listSelectedWindows->clear(); - m_listSelectedWindows->insertItems( 0, cWindowListNames ); - updateSubWindowList(); -} - -// ----------------------- Slot Functions ----------------------- - -Void DialogSubWindowSelector::addSubWindow() -{ - Int iSelectedIdx = m_comboBoxWindowList->currentIndex(); - if( iSelectedIdx >= 0 ) + if( m_iMaxSlectedWindows > 0 ) { - m_pcSelectedWindowListNames.append( m_pcWindowListNames.at( iSelectedIdx ) ); - m_listSelectedWindows->clear(); - m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames ); - updateSubWindowList(); + if( m_apcSelectedSubWindowList.size() >= m_iMaxSlectedWindows ) + { + m_pcGroupCheckBox->setEnabled( false ); + } + else + { + m_pcGroupCheckBox->setEnabled( true ); + } } } Void DialogSubWindowSelector::addAllSubWindow() { - if( m_iMaxSlectedWindows <= 0 || m_pcWindowListNames.size() <= m_iMaxSlectedWindows ) + for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { - for( Int i = 0; i < m_pcWindowListNames.size(); i++ ) - { - m_pcSelectedWindowListNames.append( m_pcWindowListNames.at( i ) ); - } - m_listSelectedWindows->clear(); - m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames ); - updateSubWindowList(); - } -} - -Void DialogSubWindowSelector::removeSubWindow() -{ - QList selectedWindows = m_listSelectedWindows->selectedItems(); - if( selectedWindows.size() ) - { - for( Int i = 0; i < selectedWindows.size(); i++ ) - { - QString currName = selectedWindows.at( i )->text(); - Int indexCurrName = m_pcSelectedWindowListNames.indexOf( currName ); - m_pcSelectedWindowListNames.removeAt( indexCurrName ); - m_listSelectedWindows->removeItemWidget( selectedWindows[i] ); - } - m_listSelectedWindows->clear(); - m_listSelectedWindows->insertItems( 0, m_pcSelectedWindowListNames ); - updateSubWindowList(); + m_apcWindowsListCheckBox.at( i )->setChecked( true ); + m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( i ) ); } } Void DialogSubWindowSelector::removeAllSubWindow() { - QList selectedWindows = m_listSelectedWindows->selectedItems(); - m_listSelectedWindows->clear(); - m_pcSelectedWindowListNames.clear(); - updateSubWindowList(); + for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + { + m_apcWindowsListCheckBox.at( i )->setChecked( false ); + } + m_apcSelectedSubWindowList.clear(); } } // Namespace SCode diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h index 3779826..704ddef 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/DialogSubWindowSelector.h @@ -34,13 +34,19 @@ #endif #include +#include + class QPixmap; class QColor; +class QCheckBox; +class QGroupBox; namespace plaYUVer { class PlaYUVerSubWindowHandle; +class SubWindowHandle; + /** * Class to define the dialog box to select sub windows * This class enable the selection of several group of windows @@ -50,18 +56,26 @@ class DialogSubWindowSelector: public QDialog Q_OBJECT public: - DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected = 0, Int maxWindowsSelected = -1 ); + DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected = 1, Int maxWindowsSelected = -1 ); - Void setSubWindowList( QStringList cWindowListNames ); - QStringList getSelectedWindows() + Void selectSubWindow( SubWindowHandle* subWindow ); + QList getSelectedWindows() { - return m_pcSelectedWindowListNames; + return m_apcSelectedSubWindowList; } private: UInt m_uiCategory; Int m_iMinSelectedWindows; Int m_iMaxSlectedWindows; PlaYUVerSubWindowHandle* m_pcMainWindowManager; + + QList m_apcSubWindowList; + QList m_apcSelectedSubWindowList; + + QSignalMapper* m_mapperWindowsList; + QGroupBox* m_pcGroupCheckBox; + QVector m_apcWindowsListCheckBox; + QStringList m_pcWindowListNames; QStringList m_pcSelectedWindowListNames; @@ -76,9 +90,8 @@ private: Void updateSubWindowList(); private Q_SLOTS: - void addSubWindow(); + void toggleSubWindow( int ); void addAllSubWindow(); - void removeSubWindow(); void removeAllSubWindow(); }; diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 35c4791..aeb7503 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -255,21 +255,14 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); if( dialogWindowsSelection.exec() == QDialog::Accepted ) { - QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows(); VideoSubWindow *videoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); - for( Int j = 0; j < selectedWindows.size(); j++ ) + QList subWindowList = dialogWindowsSelection.getSelectedWindows(); + for( Int i = 0; i < subWindowList.size(); i++ ) { - for( Int i = 0; i < subWindowList.size(); i++ ) - { - videoSubWindow = qobject_cast( subWindowList.at( i ) ); - if( videoSubWindow->getWindowName() == selectedWindows.at( j ) ) - { - videoSubWindowList.append( videoSubWindow ); - pcCurrModuleIf->m_pcSubWindow[j] = videoSubWindow; - } - } + videoSubWindow = qobject_cast( subWindowList.at( i ) ); + videoSubWindowList.append( videoSubWindow ); } + } // Check for same fmt in more than one frame modules for( Int i = 1; i < videoSubWindowList.size(); i++ ) diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 550f622..ba4f630 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -70,8 +70,6 @@ Void QualityHandle::createActions() m_arrayActions[SELECT_CURR_REF_ACT] = new QAction( "Mark as Reference", this ); connect( m_arrayActions[SELECT_CURR_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectCurrentAsReference() ) ); - m_arrayActions[SELECT_REF_ACT] = new QAction( "Select Reference", this ); - connect( m_arrayActions[SELECT_REF_ACT], SIGNAL( triggered() ), this, SLOT( slotSelectReference() ) ); m_arrayActions[PLOT_QUALITY] = new QAction( "Plot Window's Quality", this ); connect( m_arrayActions[PLOT_QUALITY], SIGNAL( triggered() ), this, SLOT( slotPlotQualitySingle() ) ); @@ -85,7 +83,6 @@ QMenu* QualityHandle::createMenu() m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" ); m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() ); m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] ); - //m_pcMenuQuality->addAction( m_arrayActions[SELECT_REF_ACT] ); m_pcMenuQuality->addSeparator(); m_pcMenuQuality->addAction( m_arrayActions[PLOT_QUALITY] ); m_pcMenuQuality->addAction( m_arrayActions[PLOT_SEVERAL_QUALITY] ); @@ -114,7 +111,6 @@ Void QualityHandle::updateMenus() m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow ); m_arrayActions[SELECT_CURR_REF_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[SELECT_REF_ACT]->setEnabled( hasSubWindow ); m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow ); m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasSubWindow ); @@ -250,35 +246,6 @@ Void QualityHandle::slotSelectCurrentAsReference() } } -Void QualityHandle::slotSelectReference() -{ - DialogSubWindowSelector dialogWindowSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, 1, 1 ); - if( dialogWindowSelection.exec() == QDialog::Accepted ) - { - VideoSubWindow* pcVideoSubWindow; - VideoSubWindow* pcRefSubWindow = NULL; - QStringList selectedWindows = dialogWindowSelection.getSelectedWindows(); - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); - for( Int i = 0; i < subWindowList.size(); i++ ) - { - pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); - if( pcVideoSubWindow->getWindowName() == selectedWindows.at( 0 ) ) - { - pcRefSubWindow = pcVideoSubWindow; - break; - } - } - for( Int i = 0; i < subWindowList.size(); i++ ) - { - pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); - if( pcVideoSubWindow != pcRefSubWindow ) - pcVideoSubWindow->setRefSubWindow( pcRefSubWindow ); - } - m_pcQualityHandleSideBar->updateSidebarData(); - m_pcQualityHandleDock->show(); - } -} - Void QualityHandle::slotPlotQualitySingle() { VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); diff --git a/app/QualityHandle.h b/app/QualityHandle.h index 663c59e..e1bc0b4 100644 --- a/app/QualityHandle.h +++ b/app/QualityHandle.h @@ -66,7 +66,6 @@ private: enum { SELECT_CURR_REF_ACT, - SELECT_REF_ACT, PLOT_QUALITY, PLOT_SEVERAL_QUALITY, TOTAL_ACT, @@ -91,7 +90,6 @@ Q_SIGNALS: private Q_SLOTS: void slotQualityMetricChanged( int ); void slotSelectCurrentAsReference(); - void slotSelectReference(); void slotPlotQualitySingle(); void slotPlotQualitySeveral(); }; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 0ae2ea5..e06a4ac 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -574,25 +574,17 @@ Void VideoHandle::videoSelectionButtonEvent() QStringList cWindowListNames; for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { - cWindowListNames.append( m_acPlayingSubWindows.at( i )->getWindowName() ); - dialogWindowsSelection.setSubWindowList( cWindowListNames ); + dialogWindowsSelection.selectSubWindow( m_acPlayingSubWindows.at( i ) ); } if( dialogWindowsSelection.exec() == QDialog::Accepted ) { - QStringList selectedWindows = dialogWindowsSelection.getSelectedWindows(); m_acPlayingSubWindows.clear(); VideoSubWindow *videoSubWindow; - QString windowName; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + QList subWindowList = dialogWindowsSelection.getSelectedWindows(); for( Int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); - windowName = videoSubWindow->getWindowName(); - if( selectedWindows.contains( windowName ) ) - { - m_acPlayingSubWindows.append( videoSubWindow ); - videoSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); - } + m_acPlayingSubWindows.append( videoSubWindow ); } if( m_acPlayingSubWindows.size() > 0 ) { diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index 227374e..527bbda 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -57,9 +57,9 @@ enum Module_NumberOfFrames enum Module_Requirements { MODULE_REQUIRES_NOTHING = 0, - MODULE_REQUIRES_SKIP_WHILE_PLAY = 2, - MODULE_REQUIRES_OPTIONS = 4, - MODULE_REQUIRES_NEW_WINDOW = 6, + MODULE_REQUIRES_SKIP_WHILE_PLAY = 1, + MODULE_REQUIRES_OPTIONS = 2, + MODULE_REQUIRES_NEW_WINDOW = 4, }; class PlaYUVerModuleIf diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index d9a9c3b..2da3fbf 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -301,6 +301,10 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() case MODULE_REQUIRES_TWO_FRAMES: pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); break; + case MODULE_REQUIRES_THREE_FRAMES: + pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame(), + m_apcInputStreams[2]->getCurrFrame() ); + break; } } return pcProcessedFrame; @@ -338,6 +342,10 @@ Int PlaYUVerTools::ModuleOperation() case MODULE_REQUIRES_TWO_FRAMES: dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); break; + case MODULE_REQUIRES_THREE_FRAMES: + dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame(), + m_apcInputStreams[2]->getCurrFrame() ); + break; } m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %8.3f \n", dMeasurementResult ); From ec03540d7663b790ad8f06287acc7b717e012324 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 01:46:12 +0000 Subject: [PATCH 30/94] Change behaviour of the sub window selection dialog when the max number of selections is reached --- app/DialogSubWindowSelector.cpp | 54 +++++++++++++++++++++++++-------- app/DialogSubWindowSelector.h | 1 + app/ModulesHandle.cpp | 1 + app/VideoHandle.cpp | 6 ++-- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index d36876a..5ff083c 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -48,7 +48,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWi minWindowsSelected = minWindowsSelected == 0 ? 1 : minWindowsSelected; - m_pcGroupCheckBox = new QGroupBox( tr( "Exclusive Radio Buttons" ) ); + m_pcGroupCheckBox = new QGroupBox(); m_pcGroupCheckBox->setLayout( new QVBoxLayout() ); mainLayout->addWidget( m_pcGroupCheckBox ); @@ -85,6 +85,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWi connect( m_mapperWindowsList, SIGNAL( mapped(int) ), this, SLOT( toggleSubWindow(int) ) ); updateSubWindowList(); + update(); } Void DialogSubWindowSelector::updateSubWindowList() @@ -106,7 +107,6 @@ Void DialogSubWindowSelector::updateSubWindowList() m_pcGroupCheckBox->layout()->addWidget( windowCheckBox ); m_apcWindowsListCheckBox.append( windowCheckBox ); } - } Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle* subWindow ) @@ -119,19 +119,15 @@ Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle* subWindow ) } } -// ----------------------- Slot Functions ----------------------- - -Void DialogSubWindowSelector::toggleSubWindow( Int idx ) +Void DialogSubWindowSelector::update() { - Bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked(); - - if( isChecked ) + if( m_apcWindowsListCheckBox.size() > m_iMaxSlectedWindows ) { - m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) ); + m_pushButtonAddAll->setEnabled( false ); } else { - m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); + m_pushButtonAddAll->setEnabled( true ); } if( m_apcSelectedSubWindowList.size() > 0 ) @@ -156,22 +152,55 @@ Void DialogSubWindowSelector::toggleSubWindow( Int idx ) { if( m_apcSelectedSubWindowList.size() >= m_iMaxSlectedWindows ) { - m_pcGroupCheckBox->setEnabled( false ); + for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + { + if( m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) ) + { + m_apcWindowsListCheckBox.at( i )->setEnabled( true ); + } + else + { + m_apcWindowsListCheckBox.at( i )->setEnabled( false ); + } + } } else { - m_pcGroupCheckBox->setEnabled( true ); + for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + { + m_apcWindowsListCheckBox.at( i )->setEnabled( true ); + } } } } +// ----------------------- Slot Functions ----------------------- + +Void DialogSubWindowSelector::toggleSubWindow( Int idx ) +{ + Bool isChecked = m_apcWindowsListCheckBox.at( idx )->isChecked(); + + if( isChecked ) + { + m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) ); + } + else + { + Bool bRemoved = m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); + assert( bRemoved ); + } + update(); +} + Void DialogSubWindowSelector::addAllSubWindow() { + m_apcSelectedSubWindowList.clear(); for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { m_apcWindowsListCheckBox.at( i )->setChecked( true ); m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( i ) ); } + update(); } Void DialogSubWindowSelector::removeAllSubWindow() @@ -181,6 +210,7 @@ Void DialogSubWindowSelector::removeAllSubWindow() m_apcWindowsListCheckBox.at( i )->setChecked( false ); } m_apcSelectedSubWindowList.clear(); + update(); } } // Namespace SCode diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h index 704ddef..99a4806 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/DialogSubWindowSelector.h @@ -88,6 +88,7 @@ private: QListWidget* m_listSelectedWindows; Void updateSubWindowList(); + Void update(); private Q_SLOTS: void toggleSubWindow( int ); diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index aeb7503..4781f0f 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -253,6 +253,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); + dialogWindowsSelection.selectSubWindow( pcVideoSubWindow ); if( dialogWindowsSelection.exec() == QDialog::Accepted ) { VideoSubWindow *videoSubWindow; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index e06a4ac..91d0a4b 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -580,10 +580,10 @@ Void VideoHandle::videoSelectionButtonEvent() { m_acPlayingSubWindows.clear(); VideoSubWindow *videoSubWindow; - QList subWindowList = dialogWindowsSelection.getSelectedWindows(); - for( Int i = 0; i < subWindowList.size(); i++ ) + QList selectedSubWindowList = dialogWindowsSelection.getSelectedWindows(); + for( Int i = 0; i < selectedSubWindowList.size(); i++ ) { - videoSubWindow = qobject_cast( subWindowList.at( i ) ); + videoSubWindow = qobject_cast( selectedSubWindowList.at( i ) ); m_acPlayingSubWindows.append( videoSubWindow ); } if( m_acPlayingSubWindows.size() > 0 ) From 951553926cc79f724d516bba1cf2eb5ba443cbd7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 17:57:10 +0000 Subject: [PATCH 31/94] change order when selecting sub windows and fix problem with add all --- app/DialogSubWindowSelector.cpp | 76 +++++++++++++++++++++++---------- app/DialogSubWindowSelector.h | 6 --- 2 files changed, 54 insertions(+), 28 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index 5ff083c..a4418d7 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -84,19 +84,10 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWi m_mapperWindowsList = new QSignalMapper( this ); connect( m_mapperWindowsList, SIGNAL( mapped(int) ), this, SLOT( toggleSubWindow(int) ) ); - updateSubWindowList(); - update(); -} - -Void DialogSubWindowSelector::updateSubWindowList() -{ SubWindowHandle *subWindow; QString currSubWindowName; - m_pcWindowListNames.clear(); - m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); - QCheckBox* windowCheckBox; - + m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { subWindow = m_apcSubWindowList.at( i ); @@ -104,12 +95,52 @@ Void DialogSubWindowSelector::updateSubWindowList() windowCheckBox = new QCheckBox( currSubWindowName, this ); connect( windowCheckBox, SIGNAL( stateChanged(int) ), m_mapperWindowsList, SLOT( map() ) ); m_mapperWindowsList->setMapping( windowCheckBox, i ); - m_pcGroupCheckBox->layout()->addWidget( windowCheckBox ); m_apcWindowsListCheckBox.append( windowCheckBox ); } + + update(); } -Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle* subWindow ) +Void DialogSubWindowSelector::updateSubWindowList() +{ + QLayout* pcLayout = m_pcGroupCheckBox->layout(); + QLayoutItem* pcLayoutItem; + QCheckBox* windowCheckBox; + Int iIdx; + + /** + * Remove all check boxes + */ + for( Int i = 0; i < pcLayout->count(); i++ ) + { + pcLayoutItem = pcLayout->itemAt( i ); + if( pcLayoutItem ) + { + pcLayout->removeWidget( pcLayoutItem->widget() ); + pcLayout->removeItem( pcLayoutItem ); + } + } + + for( Int i = 0; i < m_apcSelectedSubWindowList.size(); i++ ) + { + iIdx = m_apcSubWindowList.indexOf( m_apcSelectedSubWindowList.at( i ) ); + if( iIdx >= 0 ) + { + windowCheckBox = m_apcWindowsListCheckBox.at( iIdx ); + m_pcGroupCheckBox->layout()->addWidget( windowCheckBox ); + } + } + for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) + { + if( !m_apcSelectedSubWindowList.contains( m_apcSubWindowList.at( i ) ) ) + m_pcGroupCheckBox->layout()->addWidget( m_apcWindowsListCheckBox.at( i ) ); + } + + qDebug( ) << "Selected windows: " + << m_apcSelectedSubWindowList.size(); +} + +Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle * subWindow ) { Int iIdx = m_apcSubWindowList.indexOf( subWindow ); if( iIdx >= 0 ) @@ -121,15 +152,6 @@ Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle* subWindow ) Void DialogSubWindowSelector::update() { - if( m_apcWindowsListCheckBox.size() > m_iMaxSlectedWindows ) - { - m_pushButtonAddAll->setEnabled( false ); - } - else - { - m_pushButtonAddAll->setEnabled( true ); - } - if( m_apcSelectedSubWindowList.size() > 0 ) { m_pushButtonRemoveAll->setEnabled( true ); @@ -150,6 +172,14 @@ Void DialogSubWindowSelector::update() if( m_iMaxSlectedWindows > 0 ) { + if( m_apcWindowsListCheckBox.size() > m_iMaxSlectedWindows ) + { + m_pushButtonAddAll->setEnabled( false ); + } + else + { + m_pushButtonAddAll->setEnabled( true ); + } if( m_apcSelectedSubWindowList.size() >= m_iMaxSlectedWindows ) { for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) @@ -172,6 +202,7 @@ Void DialogSubWindowSelector::update() } } } + updateSubWindowList(); } // ----------------------- Slot Functions ----------------------- @@ -183,9 +214,11 @@ Void DialogSubWindowSelector::toggleSubWindow( Int idx ) if( isChecked ) { m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) ); + //m_apcWindowsListCheckBox.at( idx )->setChecked( true ); } else { + //m_apcWindowsListCheckBox.at( idx )->setChecked( false ); Bool bRemoved = m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); assert( bRemoved ); } @@ -198,7 +231,6 @@ Void DialogSubWindowSelector::addAllSubWindow() for( Int i = 0; i < m_apcWindowsListCheckBox.size(); i++ ) { m_apcWindowsListCheckBox.at( i )->setChecked( true ); - m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( i ) ); } update(); } diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h index 99a4806..eb1fa7c 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/DialogSubWindowSelector.h @@ -76,16 +76,10 @@ private: QGroupBox* m_pcGroupCheckBox; QVector m_apcWindowsListCheckBox; - QStringList m_pcWindowListNames; - QStringList m_pcSelectedWindowListNames; - QComboBox* m_comboBoxWindowList; QDialogButtonBox* m_pushButtonOkCancel; - QPushButton* m_pushButtonAdd; QPushButton* m_pushButtonAddAll; - QPushButton* m_pushButtonRemove; QPushButton* m_pushButtonRemoveAll; - QListWidget* m_listSelectedWindows; Void updateSubWindowList(); Void update(); From 3ac9f9b1523286579c9fb3a2f0d6c99cd09efcfc Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 18:00:26 +0000 Subject: [PATCH 32/94] Add relevant subwindows when selecting a module --- app/DialogSubWindowSelector.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index a4418d7..87b885f 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -214,11 +214,9 @@ Void DialogSubWindowSelector::toggleSubWindow( Int idx ) if( isChecked ) { m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( idx ) ); - //m_apcWindowsListCheckBox.at( idx )->setChecked( true ); } else { - //m_apcWindowsListCheckBox.at( idx )->setChecked( false ); Bool bRemoved = m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); assert( bRemoved ); } From 318bf2a54f2483711e5aaa3fd87ee0219622b3e7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 18:32:33 +0000 Subject: [PATCH 33/94] Add relevant subwindows when selecting a module --- app/ModulesHandle.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 4781f0f..ebcddcb 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -253,7 +253,20 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); - dialogWindowsSelection.selectSubWindow( pcVideoSubWindow ); + QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + + if( windowsList.size() <= numberOfFrames ) + { + for( Int i = 0; i < windowsList.size(); i++ ) + { + dialogWindowsSelection.selectSubWindow( windowsList.at( i ) ); + } + } + else + { + dialogWindowsSelection.selectSubWindow( pcVideoSubWindow ); + } + if( dialogWindowsSelection.exec() == QDialog::Accepted ) { VideoSubWindow *videoSubWindow; From a125fc5eacc4171285beddcd6b73b023edddcf05 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 25 Mar 2015 18:34:32 +0000 Subject: [PATCH 34/94] Bugfix in FrameDifference Module --- modules/FrameDifference.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index f3b8dd1..07cde10 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -63,6 +63,7 @@ PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* I diff = aux_pel_1 - aux_pel_2; diff = std::min( diff, 127 ); diff = std::max( diff, -128 ); + diff += 128; *pOutputPelYUV++ = diff; } return m_pcFrameDifference; From 76b9dcf449105a1ac308c1c2f78bb4ddfbd81967 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 01:05:47 +0000 Subject: [PATCH 35/94] Bug fix in ProgramOptions parse and graphical changes in options dialog in GUI app --- app/ModulesHandleOptDialog.cpp | 4 ++++ lib/PlaYUVerFrame.cpp | 1 - lib/ProgramOptions.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp index c6f992a..868cb3f 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/ModulesHandleOptDialog.cpp @@ -48,6 +48,7 @@ public: QHBoxLayout* layout = new QHBoxLayout( this ); layout->addWidget( m_pcDescription, Qt::AlignLeft ); layout->addWidget( m_pcValue, Qt::AlignRight ); + layout->setContentsMargins( 1, 1, 1, 1 ); } const QString getValue() const { @@ -90,6 +91,8 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu mainLayout->addWidget( dialogButtonOkCancel ); + setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); } @@ -116,6 +119,7 @@ Int ModulesHandleOptDialog::runConfiguration() optionString.append( valueString.toStdString() ); argsArray.push_back( optionString ); } + optionString.clear(); } if( argsArray.size() > 0 ) { diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 386875e..30c870c 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -91,7 +91,6 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other ) PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight ) { - PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[other->getPelFormat()] ); if( pcPelFormat->log2ChromaWidth ) { diff --git a/lib/ProgramOptions.cpp b/lib/ProgramOptions.cpp index 4288944..a0432cb 100644 --- a/lib/ProgramOptions.cpp +++ b/lib/ProgramOptions.cpp @@ -348,7 +348,7 @@ Void Options::scanArgs( std::vector args_array) { for( unsigned i = 0; i < args_array.size(); i++ ) { - i += parseLONG( args_array[0] ); + i += parseLONG( args_array[i] ); } return; } From cddf54d3e8e5180c16d94ac9f4df277c8ca1ac3a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 01:06:00 +0000 Subject: [PATCH 36/94] Add FrameCrop module --- modules/CMakeLists.txt | 1 + modules/FrameBinarization.cpp | 2 +- modules/PlaYUVerModuleFactory.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index e7d54f7..b297cdd 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -38,6 +38,7 @@ ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) ADD_MODULE( FrameBinarization "FrameBinarization" ) +ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) IF( USE_OPENCV ) ADD_MODULE( DisparityStereoVar "DisparityStereoVar" ) diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp index ce46630..fc0a366 100644 --- a/modules/FrameBinarization.cpp +++ b/modules/FrameBinarization.cpp @@ -31,7 +31,7 @@ FrameBinarization::FrameBinarization() { /* Module Definition */ m_iModuleType = FRAME_PROCESSING_MODULE; - m_pchModuleCategory = "Measurements"; + m_pchModuleCategory = "Utilities"; m_pchModuleName = "FrameBinarization"; m_pchModuleTooltip = "Binarize frame"; m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index a1fb91a..3716716 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -37,8 +37,9 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "FilterComponentChromaU", &FilterComponentChromaU::Create ); Register( "FilterComponentChromaV", &FilterComponentChromaV::Create ); Register( "FrameDifference", &FrameDifference::Create ); - Register( "FrameBinarization", &FrameBinarization::Create ); Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create ); + Register( "FrameCrop", &FrameCrop::Create ); + Register( "FrameBinarization", &FrameBinarization::Create ); Register( "LumaAverage", &LumaAverage::Create ); #ifdef USE_OPENCV Register( "DisparityStereoVar", &DisparityStereoVar::Create ); From 8353c7bddd0e302335cf80ccf23835c18614077e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 01:13:27 +0000 Subject: [PATCH 37/94] Add FrameCrop code --- modules/FrameCrop.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++ modules/FrameCrop.h | 57 ++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+) create mode 100644 modules/FrameCrop.cpp create mode 100644 modules/FrameCrop.h diff --git a/modules/FrameCrop.cpp b/modules/FrameCrop.cpp new file mode 100644 index 0000000..d4718cd --- /dev/null +++ b/modules/FrameCrop.cpp @@ -0,0 +1,81 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file FrameCrop.cpp + * \brief Crop a region of an image + */ + +#include "FrameCrop.h" + +namespace plaYUVer +{ + +FrameCrop::FrameCrop() +{ + /* Module Definition */ + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Utilities"; + m_pchModuleName = "FrameCrop"; + m_pchModuleTooltip = "Crop a region of a frame"; + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; + m_uiModuleRequirements = MODULE_REQUIRES_OPTIONS; + + m_cModuleOptions.addOptions()/**/ + ( "xPosition", m_uiXPosition, "X cordinate of the left-top corner of the crop region [0]" )/**/ + ( "yPosition", m_uiYPosition, "Y cordinate of the left-top corner of the crop region [0]" )/**/ + ( "width", m_iXSize, "Width of the crop region [-1]" )/**/ + ( "height", m_iYSize, "Height of the crop region [-1]" ); + + m_pcCropedFrame = NULL; + m_uiXPosition = 0; + m_uiYPosition = 0; + m_iXSize = -1; + m_iYSize = -1; +} + +Void FrameCrop::create( PlaYUVerFrame* frame ) +{ + m_pcCropedFrame = NULL; + if( m_iXSize == -1 ) + { + m_iXSize = frame->getWidth() - m_uiXPosition; + } + if( m_iYSize == -1 ) + { + m_iYSize = frame->getHeight() - m_uiYPosition; + } + m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat() ); +} + +PlaYUVerFrame* FrameCrop::process( PlaYUVerFrame* frame ) +{ + m_pcCropedFrame->copyFrom( frame, m_uiXPosition, m_uiYPosition ); + return m_pcCropedFrame; +} + +Void FrameCrop::destroy() +{ + if( m_pcCropedFrame ) + delete m_pcCropedFrame; + m_pcCropedFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/FrameCrop.h b/modules/FrameCrop.h new file mode 100644 index 0000000..eee1f60 --- /dev/null +++ b/modules/FrameCrop.h @@ -0,0 +1,57 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file FrameCrop.h + * \brief Crop a region of an image + */ + +#ifndef __FRAMECROP_H__ +#define __FRAMECROP_H__ + +#include "PlaYUVerModuleIf.h" + +namespace plaYUVer +{ + +class FrameCrop: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( FrameCrop ) + +private: + PlaYUVerFrame* m_pcCropedFrame; + UInt m_uiXPosition; + UInt m_uiYPosition; + Int m_iXSize; + Int m_iYSize; +public: + FrameCrop(); + virtual ~FrameCrop() + { + } + Void create( PlaYUVerFrame* ); + PlaYUVerFrame* process( PlaYUVerFrame* ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __FRAMECROP_H__ + From c46ab5a0ace48e1176049f77c7a076c680387eab Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 02:09:59 +0000 Subject: [PATCH 38/94] list color spaces supported --- lib/PlaYUVerFrame.cpp | 9 +++++++++ lib/PlaYUVerFrame.h | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 30c870c..602d6ef 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -42,6 +42,15 @@ namespace plaYUVer { +std::vector PlaYUVerFrame::supportedColorSpacesListNames() +{ + std::vector colorSpaceList; + colorSpaceList.push_back( "YUV" ); + colorSpaceList.push_back( "RGB" ); + colorSpaceList.push_back( "GRAY" ); + return colorSpaceList; +} + std::vector PlaYUVerFrame::supportedPixelFormatListNames() { std::vector formatsList; diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 0625cd1..dd5be01 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -117,9 +117,9 @@ public: { COLOR_INVALID = -1, //!< Invalid COLOR_YUV = 0, //!< YUV - COLOR_RGB, //!< RGB - COLOR_ARGB, //!< RGB + Alpha - COLOR_GRAY, //!< Grayscale + COLOR_RGB = 1, //!< RGB + COLOR_ARGB = 3, //!< RGB + Alpha + COLOR_GRAY = 2, //!< Grayscale }; /** ColorSpace Enum @@ -138,6 +138,13 @@ public: NUMBER_FORMATS }; + /** + * Function that handles the supported color space + * of PlaYUVerFrame + * @return vector of strings with pixel formats names + */ + static std::vector supportedColorSpacesListNames(); + /** * Function that handles the supported pixel formats * of PlaYUVerFrame From 94a5b4d27574f46c5e0aa398ae8a2ab6b60fac0a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 02:13:56 +0000 Subject: [PATCH 39/94] list color spaces supported --- lib/PlaYUVerFrame.cpp | 12 ++++++++++++ lib/PlaYUVerFrame.h | 1 + 2 files changed, 13 insertions(+) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 602d6ef..513fe45 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -62,6 +62,18 @@ std::vector PlaYUVerFrame::supportedPixelFormatListNames() return formatsList; } +std::vector PlaYUVerFrame::supportedPixelFormatListNames( Int colorSpace ) +{ + std::vector formatsList; + Int numberFormats = PLAYUVER_NUMBER_FORMATS; + for( Int i = 0; i < numberFormats; i++ ) + { + if( g_PlaYUVerPixFmtDescriptorsList[i].colorSpace == colorSpace ) + formatsList.push_back( g_PlaYUVerPixFmtDescriptorsList[i].name ); + } + return formatsList; +} + PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace eOutputSpace ) { Int outA, outB, outC; diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index dd5be01..271da41 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -151,6 +151,7 @@ public: * @return vector of strings with pixel formats names */ static std::vector supportedPixelFormatListNames(); + static std::vector supportedPixelFormatListNames( Int colorSpace ); /** * Get number of bytes per frame of a specific From 2e6da66ea832587f25d06f6993636a062ede31b7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 02:27:33 +0000 Subject: [PATCH 40/94] Upgrade ConfigureFormatDialog and add filter for color space --- app/ConfigureFormatDialog.cpp | 257 +++++++++++++++++++++------------- app/ConfigureFormatDialog.h | 2 + 2 files changed, 158 insertions(+), 101 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index 25b415f..c83d412 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -32,16 +32,6 @@ namespace plaYUVer ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : QDialog( parent ) { - QFont titleFont, menusFont; - - titleFont.setPointSize( 14 ); - titleFont.setBold( true ); - titleFont.setWeight( 75 ); - - menusFont.setBold( true ); - menusFont.setWeight( 75 ); - - QString Name; UInt uiWidth, uiHeight; std::vector listPlaYUVerStdResolution = PlaYUVerStream::stdResolutionSizes(); @@ -51,168 +41,211 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : 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) ); + standardResolutionSizes.append( QSize( uiWidth, uiHeight ) ); } setObjectName( "ConfigureFormat" ); - resize( 400, 370 ); setWindowTitle( "Configure Resolution" ); setWindowIcon( QIcon( ":/images/configureformat.png" ) ); QVBoxLayout* MainLayout = new QVBoxLayout( this ); - MainLayout->setObjectName( QStringLiteral( "MainLayout" ) ); - // headLayout - QHBoxLayout* headLayout = new QHBoxLayout(); - QLabel* dialogTitleLabel = new QLabel(); - dialogTitleLabel->setFont( titleFont ); - dialogTitleLabel->setText( "Configure Resolution" ); - QLabel* dialogIconLabel = new QLabel(); - dialogIconLabel->setObjectName( QStringLiteral( "dialogIconLabel" ) ); - dialogIconLabel->setPixmap( QPixmap( ":/images/dialogheader-grid.png" ) ); - headLayout->addWidget( dialogTitleLabel ); - headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - headLayout->addWidget( dialogIconLabel ); + QFont titleFont, menusFont, normalFont; - MainLayout->addLayout( headLayout ); + titleFont.setPointSize( 14 ); + titleFont.setBold( true ); + titleFont.setWeight( 75 ); - MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); + menusFont.setBold( true ); + titleFont.setWeight( 75 ); - // Filename layout -// QHBoxLayout* filenameLayout = new QHBoxLayout(); -// QLabel* filenameLabel = new QLabel(); -// filenameLabel->setText( "Name" ); -// filenameLabel->setFont( menusFont ); -// m_labelFilename = new QLabel(); -// m_labelFilename->setText( "Test" ); -// filenameLayout->addWidget( filenameLabel ); -// filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); -// filenameLayout->addWidget( m_labelFilename ); - //MainLayout->addLayout( filenameLayout ); + normalFont.setBold( false ); + // menusFont.setPointSize( 12 ); + +// // headLayout +// QHBoxLayout* headLayout = new QHBoxLayout(); +// QLabel* dialogTitleLabel = new QLabel(); +// dialogTitleLabel->setFont( titleFont ); +// dialogTitleLabel->setText( "Configure Resolution" ); +// headLayout->addWidget( dialogTitleLabel ); +// headLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); +// +// MainLayout->addLayout( headLayout ); +// MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); + + /* + * Filename layout + */ + QHBoxLayout* filenameLayout = new QHBoxLayout(); + QLabel* filenameLabel = new QLabel(); + filenameLabel->setText( "Name" ); + filenameLabel->setFont( menusFont ); + m_labelFilename = new QLabel(); + m_labelFilename->setFont( menusFont ); + filenameLayout->addWidget( filenameLabel ); + filenameLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + filenameLayout->addWidget( m_labelFilename ); + MainLayout->addLayout( filenameLayout ); - // standardResolutionLayout - MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); - QHBoxLayout* standardResolutionLayout = new QHBoxLayout(); - QLabel* standardResolutionLabel = new QLabel(); - standardResolutionLabel->setText( "Standard Resolution" ); - standardResolutionLabel->setFont( menusFont ); - m_comboBoxStandardResolution = new QComboBox(); QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); sizePolicy.setHorizontalStretch( 0 ); sizePolicy.setVerticalStretch( 0 ); - sizePolicy.setHeightForWidth( m_comboBoxStandardResolution->sizePolicy().hasHeightForWidth() ); + + /* + * Resolution + */ + QGroupBox* resolutionGroup = new QGroupBox(); + resolutionGroup->setTitle( QStringLiteral( "Resolution" ) ); + resolutionGroup->setFont( menusFont ); + + QGridLayout* resolutionGrid = new QGridLayout(); + resolutionGroup->setLayout( resolutionGrid ); + + m_comboBoxStandardResolution = new QComboBox(); + + m_comboBoxStandardResolution->setFont( normalFont ); m_comboBoxStandardResolution->setSizePolicy( sizePolicy ); m_comboBoxStandardResolution->setAcceptDrops( true ); m_comboBoxStandardResolution->clear(); m_comboBoxStandardResolution->insertItems( 0, standardResolutionNames ); m_comboBoxStandardResolution->setCurrentIndex( -1 ); - standardResolutionLayout->addWidget( standardResolutionLabel ); - standardResolutionLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - standardResolutionLayout->addWidget( m_comboBoxStandardResolution ); - MainLayout->addLayout( standardResolutionLayout ); - - // Resolution Grid - //resolutionGridVerticalSpacer = new QSpacerItem( 10, 20, QSizePolicy::Minimum ); - MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); - - QGridLayout* resolutionGrid = new QGridLayout(); - - QLabel* resolutionLabel = new QLabel(); - resolutionLabel->setFont( menusFont ); - resolutionLabel->setText( "Resolution chosen" ); - resolutionLabel->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); QLabel* widthLabel = new QLabel( "Width" ); + widthLabel->setFont( normalFont ); m_spinBoxWidth = new QSpinBox(); m_spinBoxWidth->setRange( 0, 9999 ); m_spinBoxWidth->setValue( 0 ); + m_spinBoxWidth->setFont( normalFont ); QLabel* heightLabel = new QLabel( "Height" ); + heightLabel->setFont( normalFont ); m_spinBoxheight = new QSpinBox(); m_spinBoxheight->setRange( 0, 9999 ); m_spinBoxheight->setValue( 0 ); + m_spinBoxheight->setFont( normalFont ); QLabel* pixelsLabel = new QLabel(); pixelsLabel->setText( "Pixels" ); + pixelsLabel->setFont( normalFont ); + resolutionGrid->addWidget( m_comboBoxStandardResolution, 1, 0, Qt::AlignCenter ); + resolutionGrid->addWidget( widthLabel, 0, 1, Qt::AlignCenter ); + resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, Qt::AlignCenter ); + resolutionGrid->addWidget( heightLabel, 0, 2, Qt::AlignCenter ); + resolutionGrid->addWidget( m_spinBoxheight, 1, 2, Qt::AlignCenter ); + resolutionGrid->addWidget( pixelsLabel, 1, 3, Qt::AlignCenter ); - resolutionGrid->addWidget( resolutionLabel, 1, 0, 1, 1 ); - resolutionGrid->addWidget( widthLabel, 0, 1, 1, 1 ); - resolutionGrid->addWidget( m_spinBoxWidth, 1, 1, 1, 1 ); - resolutionGrid->addWidget( heightLabel, 0, 2, 1, 1 ); - resolutionGrid->addWidget( m_spinBoxheight, 1, 2, 1, 1 ); - resolutionGrid->addWidget( pixelsLabel, 1, 3, 1, 1 ); - MainLayout->addLayout( resolutionGrid ); + /* + * Pixel format + */ + QGroupBox* pixelGroup = new QGroupBox(); + pixelGroup->setTitle( QStringLiteral( "Pixel Format" ) ); + pixelGroup->setFont( menusFont ); + QGridLayout* pixelGridLayout = new QGridLayout(); + pixelGroup->setLayout( pixelGridLayout ); + + QLabel* colorSpaceLabel = new QLabel(); + colorSpaceLabel->setText( "Color Space" ); + colorSpaceLabel->setFont( normalFont ); + m_comboBoxColorSpace = new QComboBox(); + m_comboBoxColorSpace->setSizePolicy( sizePolicy ); + m_comboBoxColorSpace->setFont( normalFont ); + m_comboBoxColorSpace->clear(); - // Pixel format - QHBoxLayout* pixelFormatLayout = new QHBoxLayout(); QLabel* pixelFormatLabel = new QLabel(); - pixelFormatLabel->setText( "Pixel Format" ); - pixelFormatLabel->setFont( menusFont ); + pixelFormatLabel->setText( "Sampling" ); + pixelFormatLabel->setFont( normalFont ); m_comboBoxPixelFormat = new QComboBox(); - QSizePolicy sizePolicyPixelFormat( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); - sizePolicyPixelFormat.setHorizontalStretch( 0 ); - sizePolicyPixelFormat.setVerticalStretch( 0 ); - sizePolicyPixelFormat.setHeightForWidth( m_comboBoxPixelFormat->sizePolicy().hasHeightForWidth() ); - m_comboBoxPixelFormat->setSizePolicy( sizePolicyPixelFormat ); - m_comboBoxPixelFormat->setAcceptDrops( true ); + m_comboBoxPixelFormat->setSizePolicy( sizePolicy ); + m_comboBoxPixelFormat->setFont( normalFont ); m_comboBoxPixelFormat->clear(); - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + + for( UInt i = 0; i < PlaYUVerFrame::supportedColorSpacesListNames().size(); i++ ) { - m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames()[i].c_str() ); + m_comboBoxColorSpace->insertItem( i, PlaYUVerFrame::supportedColorSpacesListNames()[i].c_str() ); } - m_comboBoxPixelFormat->setCurrentIndex( 1 ); + m_comboBoxColorSpace->setCurrentIndex( 1 ); - MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); - pixelFormatLayout->addWidget( pixelFormatLabel ); - pixelFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - pixelFormatLayout->addWidget( m_comboBoxPixelFormat ); - MainLayout->addLayout( pixelFormatLayout ); + pixelGridLayout->addWidget( colorSpaceLabel, 0, 0 ); + pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + pixelGridLayout->addWidget( m_comboBoxColorSpace, 0, 2 ); - // Frame rate format + pixelGridLayout->addWidget( pixelFormatLabel, 1, 0 ); + pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 ); + pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 ); + + /* + * Frame rate format + */ QHBoxLayout* framerateFormatLayout = new QHBoxLayout(); QLabel* framerateFormatLabel = new QLabel(); framerateFormatLabel->setFont( menusFont ); framerateFormatLabel->setText( "Frame Rate" ); m_spinBoxFrameRate = new QSpinBox(); + m_spinBoxFrameRate->setSuffix( QStringLiteral( " Hz" ) ); + m_spinBoxFrameRate->setMinimumWidth( 30 ); m_spinBoxFrameRate->setRange( 0, 200 ); m_spinBoxFrameRate->setValue( 30 ); - - MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); framerateFormatLayout->addWidget( framerateFormatLabel ); - framerateFormatLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + framerateFormatLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); framerateFormatLayout->addWidget( m_spinBoxFrameRate ); - MainLayout->addLayout( framerateFormatLayout ); - - // Confirmation buttons - - MainLayout->addItem( new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); - + /* + * Confirmation buttons + */ QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox(); dialogButtonOkCancel->setObjectName( QString::fromUtf8( "dialogButtonBox" ) ); dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); dialogButtonOkCancel->setCenterButtons( false ); + MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); + // MainLayout->addLayout( standardResolutionLayout ); + // MainLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum ) ); + MainLayout->addWidget( resolutionGroup ); + MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); + MainLayout->addWidget( pixelGroup ); + MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); + MainLayout->addLayout( framerateFormatLayout ); + MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); MainLayout->addWidget( dialogButtonOkCancel ); connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( StandardResolutionSelection() ) ); + connect( m_comboBoxColorSpace, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotColorSpaceChange(int) ) ); connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); - QMetaObject::connectSlotsByName( this ); + m_comboBoxColorSpace->setCurrentIndex( 0 ); } Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { // Set default values - //m_labelFilename->setText( Filename ); - setWindowTitle( "Configure resolution for " + Filename ); - //m_labelFilename->setText( QFileInfo( Filename ).fileName() ); + //setWindowTitle( "Configure resolution for " + Filename ); + m_labelFilename->setText( QFileInfo( Filename ).fileName() ); m_spinBoxWidth->setValue( rWidth ); m_spinBoxheight->setValue( rHeight ); - m_comboBoxPixelFormat->setCurrentIndex( rInputFormat >= 0 ? rInputFormat : 0 ); + + Int colorSpace = 0; + Int sampling = 0; + if( rInputFormat >= 0 ) + { + std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[rInputFormat]; + for( UInt j = 0; j < PlaYUVerFrame::supportedColorSpacesListNames().size(); j++ ) + { + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( j ).size(); i++ ) + { + if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames( j )[i] ) + { + colorSpace = j; + sampling = i; + break; + } + } + } + } + m_comboBoxColorSpace->setCurrentIndex( colorSpace ); + m_comboBoxPixelFormat->setCurrentIndex( sampling ); m_spinBoxFrameRate->setValue( rFrameRate ); for( Int i = 0; i < standardResolutionSizes.size(); i++ ) { @@ -227,7 +260,16 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi } rWidth = m_spinBoxWidth->value(); rHeight = m_spinBoxheight->value(); - rInputFormat = m_comboBoxPixelFormat->currentIndex(); + colorSpace = m_comboBoxColorSpace->currentIndex(); + sampling = m_comboBoxPixelFormat->currentIndex(); + std::string pelFmtName = PlaYUVerFrame::supportedPixelFormatListNames( colorSpace )[sampling]; + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + { + if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames()[i] ) + { + rInputFormat = i; + } + } rFrameRate = m_spinBoxFrameRate->value(); return QDialog::Accepted; } @@ -243,4 +285,17 @@ void ConfigureFormatDialog::StandardResolutionSelection() m_spinBoxheight->setValue( currSize.height() ); } +Void ConfigureFormatDialog::slotColorSpaceChange( Int idx ) +{ + if( idx == -1 ) + return; + + m_comboBoxPixelFormat->clear(); + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames( idx ).size(); i++ ) + { + m_comboBoxPixelFormat->insertItem( i, PlaYUVerFrame::supportedPixelFormatListNames( idx )[i].c_str() ); + } + m_comboBoxPixelFormat->setCurrentIndex( 0 ); +} + } // NAMESPACE diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h index 7a745fd..b1e4a98 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/ConfigureFormatDialog.h @@ -56,6 +56,7 @@ public: private Q_SLOTS: void StandardResolutionSelection(); + void slotColorSpaceChange( int ); private: QStringList standardResolutionNames; @@ -65,6 +66,7 @@ private: QComboBox *m_comboBoxStandardResolution; QSpinBox *m_spinBoxWidth; QSpinBox *m_spinBoxheight; + QComboBox *m_comboBoxColorSpace; QComboBox *m_comboBoxPixelFormat; QSpinBox *m_spinBoxFrameRate; From 556e6e3f3ce10c4746112953a8baa7789bccea5f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 18:17:44 +0000 Subject: [PATCH 41/94] Fix some warnings --- app/DialogSubWindowSelector.cpp | 3 +-- app/ModulesHandle.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index 87b885f..81fe4ec 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -217,8 +217,7 @@ Void DialogSubWindowSelector::toggleSubWindow( Int idx ) } else { - Bool bRemoved = m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); - assert( bRemoved ); + m_apcSelectedSubWindowList.removeOne( m_apcSubWindowList.at( idx ) ); } update(); } diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index ebcddcb..ef4d3a0 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -249,7 +249,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) QString windowName; QList videoSubWindowList; - UInt numberOfFrames = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; + Int numberOfFrames = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); @@ -358,7 +358,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { if( pcCurrModuleIf->m_pcDisplaySubWindow ) pcCurrModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrModuleIf ); - for( UInt i = 0; i < numberOfFrames; i++ ) + for( Int i = 0; i < numberOfFrames; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->associateModule( pcCurrModuleIf ); } From 527dd0dc72c1da271f5720b60231e7c36964149c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 18:28:46 +0000 Subject: [PATCH 42/94] Make read/write formats with opencv handler the same --- lib/LibOpenCVHandler.cpp | 14 ++------------ lib/PlaYUVerStream.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/LibOpenCVHandler.cpp b/lib/LibOpenCVHandler.cpp index ea191b8..a4ca1d8 100644 --- a/lib/LibOpenCVHandler.cpp +++ b/lib/LibOpenCVHandler.cpp @@ -66,22 +66,12 @@ std::vector LibOpenCVHandler::supportedWriteFormatsName() std::vector LibOpenCVHandler::supportedSaveFormatsExt() { - std::vector formatsExt; - formatsExt.push_back( "bmp" ); - formatsExt.push_back( "bmp" ); - formatsExt.push_back( "jpg" ); - formatsExt.push_back( "png" ); - return formatsExt; + return supportedReadFormatsExt(); } std::vector LibOpenCVHandler::supportedSaveFormatsName() { - std::vector formatsName; - formatsName.push_back( "Windows Bitmap" ); - formatsName.push_back( "Windows Bitmap" ); - formatsName.push_back( "Joint Photographic Experts Group" ); - formatsName.push_back( "Portable Network Graphics" ); - return formatsName; + return supportedReadFormatsName(); } PlaYUVerFrame* LibOpenCVHandler::loadFrame( std::string filename ) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 901e598..4b5b85f 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -84,28 +84,22 @@ std::vector PlaYUVerStream::supportedWriteFormatsName() std::vector PlaYUVerStream::supportedSaveFormatsExt() { - std::vector formatsExt; - std::vector writeExt = supportedWriteFormatsExt(); - formatsExt.insert( formatsExt.begin(), writeExt.begin(), writeExt.end() ); + std::vector formatsExt = supportedWriteFormatsExt(); #ifdef USE_OPENCV std::vector opencvFmt = LibOpenCVHandler::supportedSaveFormatsExt(); formatsExt.insert( formatsExt.end(), opencvFmt.begin(), opencvFmt.end() ); #endif - sort( formatsExt.begin(), formatsExt.end() ); formatsExt.erase( unique( formatsExt.begin(), formatsExt.end() ), formatsExt.end() ); return formatsExt; } std::vector PlaYUVerStream::supportedSaveFormatsName() { - std::vector formatsName; - std::vector writeName = supportedWriteFormatsName(); - formatsName.insert( formatsName.begin(), writeName.begin(), writeName.end() ); + std::vector formatsName = supportedWriteFormatsName(); #ifdef USE_OPENCV std::vector opencvFmt = LibOpenCVHandler::supportedSaveFormatsName(); formatsName.insert( formatsName.end(), opencvFmt.begin(), opencvFmt.end() ); #endif - sort( formatsName.begin(), formatsName.end() ); formatsName.erase( unique( formatsName.begin(), formatsName.end() ), formatsName.end() ); return formatsName; } From 2cdda80e4999b4f1ff8eec54d4065afcadfd5c76 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 26 Mar 2015 18:29:21 +0000 Subject: [PATCH 43/94] Deploy version 0.6.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8f107c..d82dffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ SET( PROJECT_NAME "playuver" ) PROJECT( ${PROJECT_NAME} ) SET( PLAYUVER_VERSION_MAJOR "0" ) SET( PLAYUVER_VERSION_MINOR "6" ) -SET( PLAYUVER_VERSION_PATCH "2" ) +SET( PLAYUVER_VERSION_PATCH "3" ) SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}") From 5138908da7a811571ee584bc73ee006b0d8d96b3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 27 Mar 2015 15:16:12 +0000 Subject: [PATCH 44/94] Minor change in Configure Dialog --- app/ConfigureFormatDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index c83d412..e4f5437 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -53,7 +53,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : QFont titleFont, menusFont, normalFont; - titleFont.setPointSize( 14 ); + titleFont.setPointSize( 12 ); titleFont.setBold( true ); titleFont.setWeight( 75 ); @@ -82,7 +82,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : filenameLabel->setText( "Name" ); filenameLabel->setFont( menusFont ); m_labelFilename = new QLabel(); - m_labelFilename->setFont( menusFont ); + m_labelFilename->setFont( titleFont ); filenameLayout->addWidget( filenameLabel ); filenameLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); filenameLayout->addWidget( m_labelFilename ); From de9458664b57f50065eeed160597809543afbb07 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 27 Mar 2015 15:17:49 +0000 Subject: [PATCH 45/94] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0de8b61..0635d47 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,13 @@ plaYUVer is an open-source video player with the following features: - Support for wide range of raw video formats; - Support for OpenCV imag/video processing library - Advanced frame zoom with easy to use pan function +- Synchronized zoom across several videos (perfect for comparison operations) - Usefull information in status bar, *e.g.*, pixel information -- Usefull sidebars with stream and frame information, *e.g.*, frame histogram + Usefull sidebars with frame information, *e.g.*, frame histogram - Constant growing libs for stream and frame processing (PlaYUVerStream PlaYUVerFrame) - Advanced API for frame/video processing algorithms - Frame level quality measurement API based on the PlaYUVerFrame class +- Command-line tool for quality and frame processing algorithms (uses the referred APIs) Developers From ae0d2f2e9f68e22fdc3bc7bb9c830ebfa89305e4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 27 Mar 2015 19:26:47 +0000 Subject: [PATCH 46/94] Increase color support in Plots --- app/PlotSubWindow.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index de4f604..37bcdb3 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -35,6 +35,10 @@ Void PlotSubWindow::definePlotColors() m_arrayColorList.append( Qt::green ); m_arrayColorList.append( Qt::black ); m_arrayColorList.append( Qt::cyan ); + m_arrayColorList.append( Qt::magenta ); + m_arrayColorList.append( Qt::yellow ); + m_arrayColorList.append( Qt::gray ); + m_arrayColorList.append( Qt::darkRed ); } PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : @@ -205,7 +209,12 @@ Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStar Void PlotSubWindow::addPlot( const QVector &arrayX, const QVector &arrayY, const QString& key ) { QCPGraph *newPlot = m_cPlotArea->addGraph(); - m_cPlotPen.setColor( m_arrayColorList.at( m_uiNumberPlots ) ); + QColor plotColor = m_arrayColorList.at( 0 ); + if( m_uiNumberPlots < m_arrayColorList.size() ) + { + plotColor = m_arrayColorList.at( m_uiNumberPlots ); + } + m_cPlotPen.setColor( plotColor ); newPlot->setPen( m_cPlotPen ); // line style // pass data points to graphs: newPlot->setData( arrayX, arrayY ); From 303775e880db6ceda1034ef572366a72dd0b5d7d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 27 Mar 2015 19:28:45 +0000 Subject: [PATCH 47/94] Fix signed/unsigned comparison --- app/PlotSubWindow.cpp | 10 +++++----- app/PlotSubWindow.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 37bcdb3..ebaa8d5 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -46,7 +46,7 @@ PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : { definePlotColors(); - m_uiNumberPlots = 0; + m_iNumberPlots = 0; m_dScaleFactor = 1; setWindowName( windowTitle ); @@ -210,16 +210,16 @@ Void PlotSubWindow::addPlot( const QVector &arrayX, const QVectoraddGraph(); QColor plotColor = m_arrayColorList.at( 0 ); - if( m_uiNumberPlots < m_arrayColorList.size() ) + if( m_iNumberPlots < m_arrayColorList.size() ) { - plotColor = m_arrayColorList.at( m_uiNumberPlots ); + plotColor = m_arrayColorList.at( m_iNumberPlots ); } m_cPlotPen.setColor( plotColor ); newPlot->setPen( m_cPlotPen ); // line style // pass data points to graphs: newPlot->setData( arrayX, arrayY ); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: - newPlot->rescaleAxes( m_uiNumberPlots > 1 ? true : false ); + newPlot->rescaleAxes( m_iNumberPlots > 1 ? true : false ); if( !key.isEmpty() ) { @@ -232,7 +232,7 @@ Void PlotSubWindow::addPlot( const QVector &arrayX, const QVectoryAxis->range().lower; m_aAxisRange[VERTICAL][1] = m_cPlotArea->yAxis->range().upper; - m_uiNumberPlots++; + m_iNumberPlots++; } } // NAMESPACE diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index 5be3302..5eb93a2 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -56,7 +56,7 @@ private: }; Double m_aAxisRange[2][2]; Double m_dScaleFactor; - UInt m_uiNumberPlots; + Int m_iNumberPlots; public: From 4c2abb4ca1f70f521ee07ec514a7dc727d957e2f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 31 Mar 2015 11:45:30 +0100 Subject: [PATCH 48/94] Do minor corrections to the GUI --- app/DialogSubWindowSelector.cpp | 4 ++-- app/QualityMeasurementSidebar.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index 81fe4ec..b2a13df 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -136,8 +136,8 @@ Void DialogSubWindowSelector::updateSubWindowList() m_pcGroupCheckBox->layout()->addWidget( m_apcWindowsListCheckBox.at( i ) ); } - qDebug( ) << "Selected windows: " - << m_apcSelectedSubWindowList.size(); +// qDebug( ) << "Selected windows: " +// << m_apcSelectedSubWindowList.size(); } Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle * subWindow ) diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp index e140dd4..0d86888 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/QualityMeasurementSidebar.cpp @@ -56,15 +56,17 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, PlaYUVerS m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); m_comboBoxRef = new QComboBox; - m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength ); + QSpacerItem* spaceQuality = new QSpacerItem( 1, 1, QSizePolicy::Expanding, QSizePolicy::Fixed ); + //m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength ); m_comboBoxRef->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); updateSubWindowList(); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget( MetricLabel, 0, 0, Qt::AlignLeft ); mainLayout->addWidget( m_comboBoxMetric, 0, 1, Qt::AlignLeft ); + mainLayout->addItem( spaceQuality, 0, 2, Qt::AlignRight ); mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft ); - mainLayout->addWidget( m_comboBoxRef, 1, 1, Qt::AlignLeft ); + mainLayout->addWidget( m_comboBoxRef, 1, 1, 1, 2, Qt::AlignLeft ); m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" ); m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); From 32c224a49d4e07008f8aece99dc7b4d96cf92069 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 31 Mar 2015 17:23:06 +0100 Subject: [PATCH 49/94] ../app/DialogSubWindowSelector.cpp Fix duplicate call of select sub window function --- app/DialogSubWindowSelector.cpp | 2 +- app/PlaYUVerApp.cpp | 4 +++- app/VideoHandle.cpp | 10 ++++++---- app/VideoHandle.h | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index b2a13df..3d6fe20 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -146,7 +146,7 @@ Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle * subWindow ) if( iIdx >= 0 ) { m_apcWindowsListCheckBox.at( iIdx )->setChecked( true ); - m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( iIdx ) ); + //m_apcSelectedSubWindowList.append( m_apcSubWindowList.at( iIdx ) ); } } diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 8fb0e3a..e618a47 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -215,6 +215,8 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) videoSubWindow->show(); connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); + + connect( subWindow, SIGNAL( aboutToClose( SubWindowHandle* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowHandle* ) ) ); connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) ); connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) ); @@ -643,7 +645,7 @@ Void plaYUVerApp::createActions() m_arrayActions[CLOSEALL_ACT] = new QAction( tr( "Close &All" ), this ); m_arrayActions[CLOSEALL_ACT]->setStatusTip( tr( "Close all the windows" ) ); - connect( m_arrayActions[CLOSEALL_ACT], SIGNAL( triggered() ), this, SLOT( closeAll() ) ); + connect( m_arrayActions[CLOSEALL_ACT], SIGNAL( triggered() ), m_pcWindowHandle, SLOT( removeAllSubWindow() ) ); m_arrayActions[EXIT_ACT] = new QAction( tr( "E&xit" ), this ); m_arrayActions[EXIT_ACT]->setShortcuts( QKeySequence::Quit ); diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 91d0a4b..6ba3c33 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -276,11 +276,13 @@ Void VideoHandle::updateSelectionArea( QRect area ) } } -Void VideoHandle::closeSubWindow( VideoSubWindow* currSubWindow ) +Void VideoHandle::closeSubWindow( SubWindowHandle* subWindow ) { - if( m_acPlayingSubWindows.contains( currSubWindow ) ) + VideoSubWindow* videoSubWindow = qobject_cast( subWindow ); + + if( m_acPlayingSubWindows.contains( videoSubWindow ) ) { - Int pos = m_acPlayingSubWindows.indexOf( currSubWindow ); + Int pos = m_acPlayingSubWindows.indexOf( videoSubWindow ); m_acPlayingSubWindows.at( pos )->stop(); m_acPlayingSubWindows.remove( pos ); if( m_acPlayingSubWindows.size() < 2 ) @@ -401,7 +403,7 @@ Void VideoHandle::setTimerStatus() else { #if( _CONTROL_PLAYING_TIME_ == 1 ) - if( m_pcPlayControlTimer ) + if( m_pcPlayControlTimer && m_pcPlayingTimer->interval() > 0 ) { qDebug( ) << "Desired Fps: " << 1000 / m_pcPlayingTimer->interval() diff --git a/app/VideoHandle.h b/app/VideoHandle.h index 1dc13e0..7a92a75 100644 --- a/app/VideoHandle.h +++ b/app/VideoHandle.h @@ -66,8 +66,6 @@ public: Void update( VideoSubWindow* currSubWindow ); - Void closeSubWindow( VideoSubWindow* currSubWindow ); - private: QWidget* m_pcParet; PlaYUVerSubWindowHandle* m_pcMainWindowManager; @@ -119,6 +117,7 @@ Q_SIGNALS: private Q_SLOTS: void update(); void updateSelectionArea( QRect area ); + void closeSubWindow( SubWindowHandle* subWindow ); void zoomToFactorAll( const double factor, const QPoint center = QPoint() ); void moveAllScrollBars( const QPoint offset ); void play(); From d8952ce953027a71eb5918a4e69f23d0bd2acc40 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 2 Apr 2015 17:34:43 +0100 Subject: [PATCH 50/94] Add a variable to control the number of bits per pixel --- app/ConfigureFormatDialog.cpp | 20 +++++++++++++++++++- app/ConfigureFormatDialog.h | 5 ++--- app/VideoSubWindow.cpp | 15 +++++++++------ app/VideoSubWindow.h | 1 + lib/PlaYUVerDefs.h | 1 + lib/PlaYUVerFrame.cpp | 33 ++++++++++++++++----------------- lib/PlaYUVerFrame.h | 12 ++++++------ lib/PlaYUVerFrameStats.cpp | 2 +- lib/PlaYUVerStream.cpp | 26 ++++++++++++++++++-------- lib/PlaYUVerStream.h | 7 ++++--- tools/PlaYUVerTools.cpp | 14 +++++++------- 11 files changed, 84 insertions(+), 52 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index e4f5437..d16d6c0 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -174,6 +174,21 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 ); pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 ); + /* + * Frame rate format + */ + QHBoxLayout* bitsPerPelLayout = new QHBoxLayout(); + QLabel* bitsPerPelLabel = new QLabel(); + bitsPerPelLabel->setFont( menusFont ); + bitsPerPelLabel->setText( "Frame Rate" ); + m_spinBoxBits = new QSpinBox(); + m_spinBoxBits->setMinimumWidth( 30 ); + m_spinBoxBits->setRange( 0, 16 ); + m_spinBoxBits->setValue( 8 ); + bitsPerPelLayout->addWidget( bitsPerPelLabel ); + bitsPerPelLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + bitsPerPelLayout->addWidget( m_spinBoxBits ); + /* * Frame rate format */ @@ -204,6 +219,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : MainLayout->addWidget( resolutionGroup ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); MainLayout->addWidget( pixelGroup ); + MainLayout->addLayout( bitsPerPelLayout ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); MainLayout->addLayout( framerateFormatLayout ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); @@ -218,7 +234,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : } -Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate ) { // Set default values //setWindowTitle( "Configure resolution for " + Filename ); @@ -246,6 +262,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi } m_comboBoxColorSpace->setCurrentIndex( colorSpace ); m_comboBoxPixelFormat->setCurrentIndex( sampling ); + m_spinBoxBits->setValue( rBits ); m_spinBoxFrameRate->setValue( rFrameRate ); for( Int i = 0; i < standardResolutionSizes.size(); i++ ) { @@ -270,6 +287,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi rInputFormat = i; } } + rBits = m_spinBoxBits->value(); rFrameRate = m_spinBoxFrameRate->value(); return QDialog::Accepted; } diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h index b1e4a98..b4c3e5d 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/ConfigureFormatDialog.h @@ -34,8 +34,6 @@ #endif #include - - class QPixmap; class QColor; @@ -52,7 +50,7 @@ Q_OBJECT public: ConfigureFormatDialog( QWidget *parent = 0 ); - Int runConfigureFormatDialog ( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate ); private Q_SLOTS: void StandardResolutionSelection(); @@ -68,6 +66,7 @@ private: QSpinBox *m_spinBoxheight; QComboBox *m_comboBoxColorSpace; QComboBox *m_comboBoxPixelFormat; + QSpinBox *m_spinBoxBits; QSpinBox *m_spinBoxFrameRate; }; diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 4247a98..839a58e 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -44,6 +44,7 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array << d.m_uiHeight << d.m_iPelFormat << d.m_uiFrameRate + << d.m_uiBitsPelPixel << d.m_uiFileSize; } return out; @@ -60,6 +61,7 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array ) in >> d.m_uiWidth; in >> d.m_uiHeight; in >> d.m_iPelFormat; + in >> d.m_uiBitsPelPixel; in >> d.m_uiFrameRate; in >> d.m_uiFileSize; array.append( d ); @@ -141,16 +143,16 @@ Void VideoSubWindow::refreshSubWindow() Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) { - UInt Width = 0, Height = 0, FrameRate = 30; + UInt Width = 0, Height = 0, BitsPel = 8, FrameRate = 30; Int InputFormat = PlaYUVerFrame::YUV420p; if( m_pCurrStream ) - m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate ); + m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, FrameRate ); if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) { ConfigureFormatDialog formatDialog( this ); - if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, FrameRate ) == QDialog::Rejected ) + if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, FrameRate ) == QDialog::Rejected ) { return false; } @@ -166,12 +168,13 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) m_pCurrStream = new PlaYUVerStream; } - m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, FrameRate ); + m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, FrameRate ); m_sStreamInfo.m_cFilename = cFilename; m_sStreamInfo.m_uiWidth = Width; m_sStreamInfo.m_uiHeight = Height; m_sStreamInfo.m_iPelFormat = InputFormat; + m_sStreamInfo.m_uiBitsPelPixel = BitsPel; m_sStreamInfo.m_uiFrameRate = FrameRate; m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size(); @@ -198,7 +201,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) } if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, - streamInfo->m_uiFrameRate ) ) + streamInfo->m_uiBitsPelPixel, streamInfo->m_uiFrameRate ) ) { return false; } @@ -317,7 +320,7 @@ 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 ); + frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 ); module = uiFileSize % frame_bytes; if( module == 0 ) { diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index c5ac156..d714614 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -49,6 +49,7 @@ typedef struct UInt m_uiWidth; UInt m_uiHeight; Int m_iPelFormat; + UInt m_uiBitsPelPixel; UInt m_uiFrameRate; UInt64 m_uiFileSize; } PlaYUVerStreamInfo; diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index fa07c3e..e60b894 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -76,6 +76,7 @@ typedef unsigned long long UInt64; // ==================================================================================================================== typedef UChar Pel; ///< 8-bit pixel type +typedef UChar SBytePel; ///< 8-bit pixel type //typedef Short Pel; ///< 16-bit pixel type // ==================================================================================================================== diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 513fe45..82bb1bf 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -99,14 +99,14 @@ PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace e return outPixel; } -PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format ) +PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel ) { - init( width, height, pel_format ); + init( width, height, pelFormat, bitsPixel ); } PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other ) { - init( other->getWidth(), other->getHeight(), other->getPelFormat() ); + init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel() ); copyFrom( other ); } @@ -130,7 +130,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt a areaHeight++; } - init( areaWidth, areaHeight, other->getPelFormat() ); + init( areaWidth, areaHeight, other->getPelFormat(), other->getBitsPel() ); copyFrom( other, posX, posY ); } @@ -145,16 +145,16 @@ PlaYUVerFrame::~PlaYUVerFrame() closePixfc(); } -static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth ) +static Int getMem3ImageComponents( SBytePel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth ) { Int dim0 = 3; Int i; UInt64 total_mem_size = 0; UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) * CHROMASHIFT( dim2, log2ChromaWidth ) * 2 ); - total_mem_size += getMem2D( array3D, dim0, dim1 ); + total_mem_size += getMem2D( array3D, dim0, dim1 ); - if( ( ( *array3D )[0][0] = ( Pel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL ) + if( ( ( *array3D )[0][0] = ( SBytePel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL ) printf( "getMem3DImageComponents: array1D" ); total_mem_size += mem_size * sizeof(Pel); @@ -179,7 +179,7 @@ static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2 return total_mem_size; } -Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format ) +Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel ) { m_pppcInputPel = NULL; m_pcARGB32 = NULL; @@ -187,13 +187,11 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format ) m_uiHeight = height; m_iPixelFormat = pel_format; m_iNumberChannels = 3; - m_iBitsChannels = 8; + m_iBitsPel = bitsPixel; - Int max_bits_per_pel = sizeof(Pel) * 8; - - if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || m_iBitsChannels > max_bits_per_pel ) + if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 ) { - return; + throw "Cannot create a PlYUVerFrame of this type"; } m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); @@ -225,19 +223,20 @@ UInt PlaYUVerFrame::getNumberChannels() const UInt64 PlaYUVerFrame::getBytesPerFrame() { - return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); + return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_iBitsPel ); } -UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ) +UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel ) { PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); + UInt bytesPerPixel = bitsPixel / 8; UInt64 numberBytes = uiWidth * uiHeight; if( pcPelFormat->numberChannels > 1 ) { UInt64 numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight ); numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma; } - return numberBytes; + return numberBytes * bytesPerPixel; } UInt PlaYUVerFrame::getChromaWidth() const @@ -501,7 +500,7 @@ Void PlaYUVerFrame::fromCvMat( Void* voidFrame ) if( !isValid() ) { - init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat ); + init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat, 8 ); } m_bHasRGBPel = false; diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 271da41..965f963 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -158,7 +158,7 @@ public: * pixel format * @return number of bytes per frame */ - static UInt64 getBytesPerFrame( UInt, UInt, Int ); + static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel ); /** * Convert a Pixel to a new color space @@ -177,7 +177,7 @@ public: * * @note this function might misbehave if the pixel format enum is not correct */ - PlaYUVerFrame( UInt width, UInt height, Int pel_format = 0 ); + PlaYUVerFrame( UInt width, UInt height, Int pelFormat = 0, Int bitsPixel = 8 ); /** * Creates and new frame with the configuration of an @@ -236,9 +236,9 @@ public: { return m_iPixelFormat; } - Int getBitsChannel() const + Int getBitsPel() const { - return m_iBitsChannels; + return m_iBitsPel; } Bool isValid() const { @@ -334,7 +334,7 @@ private: UInt m_uiHeight; //!< Height of the frame Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats) Int m_iNumberChannels; //!< Number of channels - Int m_iBitsChannels; //!< Bits per pixel/channel + Int m_iBitsPel; //!< Bits per pixel/channel Pel*** m_pppcInputPel; @@ -349,7 +349,7 @@ private: * @param pel_format pixel format index (always use PixelFormats enum) * */ - Void init( UInt width, UInt height, Int pel_format ); + Void init( UInt width, UInt height, Int pel_format, Int bitsPixel ); Void openPixfc(); Void closePixfc(); diff --git a/lib/PlaYUVerFrameStats.cpp b/lib/PlaYUVerFrameStats.cpp index 8337fe2..4b33e22 100644 --- a/lib/PlaYUVerFrameStats.cpp +++ b/lib/PlaYUVerFrameStats.cpp @@ -56,7 +56,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op m_uiImageHeight = pcFrame->getHeight(); m_uiChannels = pcFrame->getNumberChannels(); - m_uiHistoSegments = ( pcFrame->getBitsChannel() == 16 ) ? 65536 : 256; + m_uiHistoSegments = 1 << pcFrame->getBitsPel(); imageColorSpace = pcFrame->getColorSpace(); imageChromaSize = pcFrame->getChromaLength(); diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 4b5b85f..6f58a5d 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -163,7 +163,7 @@ PlaYUVerStream::~PlaYUVerStream() close(); } -Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput ) +Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt bitsPel, UInt frame_rate, Bool bInput ) { UInt width; UInt height; @@ -185,10 +185,10 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st break; } } - return open( filename, width, height, input_format, frame_rate, bInput ); + return open( filename, width, height, input_format, bitsPel, frame_rate, bInput ); } -Bool PlaYUVerStream::open( std::string 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 bitsPel, UInt frame_rate, Bool bInput ) { if( m_bInit ) { @@ -200,6 +200,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in m_uiWidth = width; m_uiHeight = height; m_iPixelFormat = input_format; + m_uiBitsPerPixel = bitsPel; m_dFrameRate = frame_rate; m_pchFilename = new Char[m_cFilename.size() + 1]; @@ -254,6 +255,10 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in } } #endif + if( m_uiBitsPerPixel != 8 ) + { + m_uiStreamHandler = YUV_IO; + } m_uiFrameBufferSize = 2; } else @@ -311,8 +316,11 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in getMem1D( &m_ppcFrameBuffer, m_uiFrameBufferSize ); for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) { - m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); - if( !m_ppcFrameBuffer[i] ) + try + { + m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel ); + } + catch( const char *msg ) { close(); throw "[PlaYUVerStream] Cannot allocated frame buffer"; @@ -384,7 +392,7 @@ Bool PlaYUVerStream::openFile() { return false; } - if ( m_bIsInput ) + if( m_bIsInput ) { fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET ); } @@ -433,13 +441,14 @@ Void PlaYUVerStream::close() m_bInit = false; } -Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, UInt& rFrameRate ) { if( m_bInit ) { rWidth = m_uiWidth; rHeight = m_uiHeight; rInputFormat = m_iPixelFormat; + rBitsPerPel = m_uiBitsPerPixel; rFrameRate = m_dFrameRate; } else @@ -447,6 +456,7 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, rWidth = 0; rHeight = 0; rInputFormat = PlaYUVerFrame::YUV420p; + rBitsPerPel = 8; rFrameRate = 30; } } @@ -471,7 +481,7 @@ Void PlaYUVerStream::loadAll() getMem1D( &m_ppcFrameBuffer, m_uiFrameBufferSize ); for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) { - m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); + m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel ); if( !m_ppcFrameBuffer[i] ) { close(); diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index a9429ab..ee31ec7 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -82,6 +82,7 @@ private: Int m_iFileFormat; Int m_iPixelFormat; + UInt m_uiBitsPerPixel; Pel* m_pStreamBuffer; @@ -121,14 +122,14 @@ public: END_OF_SEQ, }; - Bool open( std::string filename, std::string resolution, std::string 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 ); + Bool open( std::string filename, std::string resolution, std::string input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true ); + Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true ); Void close(); Bool openFile(); Void closeFile(); - Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, UInt& rFrameRate ); Void loadAll(); diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 2da3fbf..07a8f3b 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -79,7 +79,7 @@ Int PlaYUVerTools::openInputs() pcStream = new PlaYUVerStream; try { - if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 1 ) ) + if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 8, 1 ) ) { m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2; @@ -132,11 +132,11 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) if( m_cCmdLineHandler.Opts()["quality"]->count() ) { std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric; - if( m_apcInputStreams.size() != 2 ) - { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); - return 2; - } +// if( m_apcInputStreams.size() != 2 ) +// { +// m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); +// return 2; +// } for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) { if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) ) @@ -193,7 +193,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) { PlaYUVerFrame* pcModFrame = applyFrameModule(); PlaYUVerStream* pcModStream = new PlaYUVerStream; - if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), 1, false ) ) + if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), 8, 1, false ) ) { delete pcModStream; pcModStream = NULL; From a38f9c32838ab410bb14108ff389ec81217de57a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 2 Apr 2015 17:44:10 +0100 Subject: [PATCH 51/94] Add a variable to control the number of bits per pixel --- app/FramePropertiesSidebar.cpp | 12 +++++++----- lib/PlaYUVerFrameStats.cpp | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/FramePropertiesSidebar.cpp b/app/FramePropertiesSidebar.cpp index 205ed42..bdbef5e 100644 --- a/app/FramePropertiesSidebar.cpp +++ b/app/FramePropertiesSidebar.cpp @@ -284,7 +284,7 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) if( m_iLastFrameType != colorSpace ) { m_iLastFrameType = colorSpace; - if ( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB ) + if( colorSpace == PlaYUVerFrame::COLOR_RGB || colorSpace == PlaYUVerFrame::COLOR_ARGB ) { channelCB->clear(); channelCB->clear(); @@ -339,8 +339,11 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) colorsLabel->hide(); } } + UInt rangePel = ( 1 << pcFrame->getBitsPel() ) - 1; + minInterv->setRange( 0, rangePel ); + maxInterv->setRange( 0, rangePel ); setEnabled( true ); - if( m_pcFrame || !(*pbMainPlaySwitch) ) + if( m_pcFrame || !( *pbMainPlaySwitch ) ) { m_pcFrame = pcFrame; updateDataHistogram(); @@ -360,9 +363,8 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea ) if( selectionArea.isValid() ) { histogramWidget->stopHistogramComputation(); - histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame, - selectionArea.x(), selectionArea.y(), - selectionArea.width(), selectionArea.height() ) ); + histogramWidget->updateSelectionData( + new PlaYUVerFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(), selectionArea.height() ) ); fullImageButton->show(); selectionImageButton->show(); selectionImageButton->click(); diff --git a/lib/PlaYUVerFrameStats.cpp b/lib/PlaYUVerFrameStats.cpp index 4b33e22..5fbe55a 100644 --- a/lib/PlaYUVerFrameStats.cpp +++ b/lib/PlaYUVerFrameStats.cpp @@ -56,7 +56,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op m_uiImageHeight = pcFrame->getHeight(); m_uiChannels = pcFrame->getNumberChannels(); - m_uiHistoSegments = 1 << pcFrame->getBitsPel(); + m_uiHistoSegments = ( 1 << pcFrame->getBitsPel() ) - 1; imageColorSpace = pcFrame->getColorSpace(); imageChromaSize = pcFrame->getChromaLength(); From c8079e87cb7b2fc022a1d9476b1a779ba636e906 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 2 Apr 2015 18:53:26 +0100 Subject: [PATCH 52/94] Implement n bits per pixel in Frame to buffer and from buffer --- app/FramePropertiesSidebar.cpp | 7 +- app/FramePropertiesSidebar.h | 2 +- app/HistogramWidget.cpp | 10 +- app/HistogramWidget.h | 2 +- app/VideoSubWindow.cpp | 2 +- lib/PlaYUVerFrame.cpp | 34 +++-- lib/PlaYUVerFramePixelFormats.cpp | 233 +++++++++++++++++++----------- lib/PlaYUVerFramePixelFormats.h | 2 +- 8 files changed, 181 insertions(+), 111 deletions(-) diff --git a/app/FramePropertiesSidebar.cpp b/app/FramePropertiesSidebar.cpp index bdbef5e..bd271f3 100644 --- a/app/FramePropertiesSidebar.cpp +++ b/app/FramePropertiesSidebar.cpp @@ -235,7 +235,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPla connect( renderingButtonGroup, SIGNAL( buttonClicked(int) ), this, SLOT( slotRenderingChanged(int) ) ); connect( histogramWidget, SIGNAL( signalIntervalChanged( int, int ) ), this, SLOT( slotUpdateInterval(int, int) ) ); connect( histogramWidget, SIGNAL( signalMaximumValueChanged(int) ), this, SLOT( slotUpdateIntervRange(int) ) ); - connect( histogramWidget, SIGNAL( signalHistogramComputationDone(bool) ), this, SLOT( slotRefreshOptions(bool) ) ); + connect( histogramWidget, SIGNAL( signalHistogramComputationDone(int) ), this, SLOT( slotRefreshOptions(int) ) ); connect( histogramWidget, SIGNAL( signalHistogramComputationFailed(void) ), this, SLOT( slotHistogramComputationFailed(void) ) ); connect( minInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMinValueChanged(int) ) ); connect( maxInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMaxValueChanged(int) ) ); @@ -339,9 +339,6 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) colorsLabel->hide(); } } - UInt rangePel = ( 1 << pcFrame->getBitsPel() ) - 1; - minInterv->setRange( 0, rangePel ); - maxInterv->setRange( 0, rangePel ); setEnabled( true ); if( m_pcFrame || !( *pbMainPlaySwitch ) ) { @@ -456,7 +453,7 @@ Void FramePropertiesSideBar::stopHistogram() // SLOTS //////////////////////////////////////////////////////////////////////////////// -Void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/) +Void FramePropertiesSideBar::slotRefreshOptions( int range ) { if( !isVisible() ) return; diff --git a/app/FramePropertiesSidebar.h b/app/FramePropertiesSidebar.h index 71a9b0f..7120acf 100644 --- a/app/FramePropertiesSidebar.h +++ b/app/FramePropertiesSidebar.h @@ -116,7 +116,7 @@ private: Void updateDataHistogram(); private Q_SLOTS: - void slotRefreshOptions( bool sixteenBit ); + void slotRefreshOptions( int range ); void slotHistogramComputationFailed( void ); void slotChannelChanged( int channel ); void slotScaleChanged( int scale ); diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp index d1502bf..6e06867 100644 --- a/app/HistogramWidget.cpp +++ b/app/HistogramWidget.cpp @@ -125,7 +125,7 @@ public: HistogramWidgetPrivate() { blinkTimer = 0; - sixteenBits = false; + imageBits = 8; inSelected = false; blinkFlag = false; clearFlag = HistogramNone; @@ -146,7 +146,7 @@ public: // Image informations Int imageChannels; Int imageColorSpace; - bool sixteenBits; + Int imageBits; bool guideVisible; // Display color guide. bool statisticsVisible; // Display tooltip histogram statistics. @@ -313,7 +313,7 @@ Void HistogramWidget::customEvent( QEvent *event ) setUpdatesEnabled( false ); notifyValuesChanged(); - emit signalHistogramComputationDone( d->sixteenBits ); + emit signalHistogramComputationDone( d->range ); setUpdatesEnabled( true ); update(); @@ -397,7 +397,7 @@ Void HistogramWidget::stopHistogramComputation() Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFrame *pcFrameSelection ) { - d->sixteenBits = false; + d->imageBits = pcFrame->getBitsPel(); //d->imageColorSpace = image.getPelFormat(); d->imageColorSpace = pcFrame->getColorSpace(); d->imageChannels = pcFrame->getNumberChannels(); @@ -409,7 +409,7 @@ Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFr // Do not using PlaYUVerFrameStatistics::getHistogramSegment() // method here because histogram hasn't yet been computed. - d->range = d->sixteenBits ? 65535 : 255; + d->range = ( 1 << d->imageBits ) - 1; emit signalMaximumValueChanged( d->range ); m_imageHistogram = ( PlaYUVerFrameStats* )pcFrame; diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h index 393f63f..a5242ec 100644 --- a/app/HistogramWidget.h +++ b/app/HistogramWidget.h @@ -152,7 +152,7 @@ public: Q_SIGNALS: void signalIntervalChanged( int min, int max ); void signalMaximumValueChanged( int ); - void signalHistogramComputationDone( bool ); + void signalHistogramComputationDone( int ); void signalHistogramComputationFailed( void ); public Q_SLOTS: diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 839a58e..1449627 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -43,8 +43,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat - << d.m_uiFrameRate << d.m_uiBitsPelPixel + << d.m_uiFrameRate << d.m_uiFileSize; } return out; diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 82bb1bf..dbb78f8 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -197,13 +197,14 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); m_bHasRGBPel = false; + UInt m_uiWidthBytes = m_uiWidth * ( ( m_iBitsPel - 1 ) / 8 + 1 ); if( m_pcPelFormat->colorSpace == COLOR_GRAY ) { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 1 ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, 1, 1 ); } else { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); } getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 ); @@ -229,7 +230,7 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel ) { PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); - UInt bytesPerPixel = bitsPixel / 8; + UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1; UInt64 numberBytes = uiWidth * uiHeight; if( pcPelFormat->numberChannels > 1 ) { @@ -261,6 +262,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) Pel* ppBuff[MAX_NUMBER_PLANES]; Pel* pTmpPel, *pTmpBuff; + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Int ratioH, ratioW, step; UInt i, ch; @@ -281,7 +283,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane] + ( m_pcPelFormat->comp[ch].offset_plus1 - 1 ); - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) { *pTmpPel++ = *pTmpBuff; pTmpBuff += step; @@ -294,6 +296,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) { + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Pel* ppBuff[MAX_NUMBER_PLANES]; Pel* pTmpPel, *pTmpBuff; Int ratioH, ratioW, step; @@ -316,7 +319,7 @@ Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane]; - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) { *pTmpBuff = *pTmpPel++; pTmpBuff += step; @@ -329,13 +332,26 @@ Void PlaYUVerFrame::fillRGBBuffer() { if( m_bHasRGBPel ) return; - if( m_pcPelFormat->colorSpace == COLOR_RGB ) + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; + Int iR, iG, iB; + UInt* pARGB = ( UInt* )m_pcARGB32; + if( m_pcPelFormat->colorSpace == COLOR_GRAY ) + { + Pel* pY = m_pppcInputPel[LUMA][0]; + for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) + { + iR = *pY++; + iG = *pY++; + iB = *pY++; + *pARGB++ = PEL_RGB( iR, iG, iB ); + } + } + else if( m_pcPelFormat->colorSpace == COLOR_RGB ) { Pel* pR = m_pppcInputPel[COLOR_R][0]; Pel* pG = m_pppcInputPel[COLOR_G][0]; Pel* pB = m_pppcInputPel[COLOR_B][0]; - Int iR, iG, iB; - UInt* pARGB = ( UInt* )m_pcARGB32; + for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) { iR = *pR++; @@ -346,7 +362,7 @@ Void PlaYUVerFrame::fillRGBBuffer() } else { - m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight ); + m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight, bytesPixel ); } m_bHasRGBPel = true; } diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp index 2ad9565..ae8a8bc 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PlaYUVerFramePixelFormats.cpp @@ -52,8 +52,7 @@ namespace plaYUVer #define ADD_FFMPEG_PEL_FMT( fmt ) 0 #endif - -Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt ratioChromaHor, UInt ratioChromaVer ) +Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt depth, UInt ratioChromaHor, UInt ratioChromaVer ) { Pel* pLineY = in[LUMA][0]; Pel* pLineU = in[CHROMA_U][0]; @@ -78,7 +77,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r { iU = *pU++; iV = *pV++; - for( Int j = 0; j < 1 << ratioChromaHor; j++ ) + for( Int j = 0; j < ( 1 << ratioChromaHor ) * depth; j++ ) { iY = *pY++; YUV2RGB( iY, iU, iV, iR, iG, iB ); @@ -93,7 +92,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r } } -Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { #ifdef USE_SSE if( ( width % 16 ) == 0 ) @@ -184,14 +183,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) b00 = _mm_srai_epi16( _mm_add_epi16( y00r0, bu00 ), 6 ); b01 = _mm_srai_epi16( _mm_add_epi16( y01r0, bu01 ), 6 ); - r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated - g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated - b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated + r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated + g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated + b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated - r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r.. - gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb.. - rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb.. - rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb.. + r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r.. + gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb.. + rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb.. + rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb.. r01 = _mm_unpackhi_epi8( r00, zero ); gbgb = _mm_unpackhi_epi8( b00, g00 ); @@ -211,14 +210,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) b00 = _mm_srai_epi16( _mm_add_epi16( y00r1, bu00 ), 6 ); b01 = _mm_srai_epi16( _mm_add_epi16( y01r1, bu01 ), 6 ); - r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated - g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated - b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated + r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated + g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated + b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated - r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r.. - gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb.. - rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb.. - rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb.. + r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r.. + gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb.. + rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb.. + rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb.. r01 = _mm_unpackhi_epi8( r00, zero ); gbgb = _mm_unpackhi_epi8( b00, g00 ); @@ -236,50 +235,20 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) else #endif { - fillARGB32bufferYUV( in, out, width, height, 1, 1 ); + fillARGB32bufferYUV( in, out, width, height, depth, 1, 1 ); } } -Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { - fillARGB32bufferYUV( in, out, width, height, 0, 0 ); + fillARGB32bufferYUV( in, out, width, height, depth, 0, 0 ); } -Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { - fillARGB32bufferYUV( in, out, width, height, 1, 0 ); + fillARGB32bufferYUV( in, out, width, height, depth, 1, 0 ); } -Void fillARGB32bufferGray( Pel*** in, UChar* out, UInt width, UInt height ) -{ - Pel *inPel = in[0][0]; - Pel iY; - UInt* buff = ( UInt* )out; - for( UInt i = 0; i < height * width; i++ ) - { - iY = *inPel; - *buff++ = PEL_RGB( iY, iY, iY ); - inPel++; - } -} - -Void fillARGB32bufferRGB( Pel*** in, UChar* out, UInt width, UInt height ) -{ - Pel* pR = in[COLOR_R][0]; - Pel* pG = in[COLOR_G][0]; - Pel* pB = in[COLOR_B][0]; - Int iR, iG, iB; - UInt* buff = ( UInt* )out; - for( UInt i = 0; i < height * width; i++ ) - { - iR = *pR++; - iG = *pG++; - iB = *pB++; - *buff++ = PEL_RGB( iR, iG, iB ); - } -} - - PlaYUVerPixFmtDescriptor yuv420p = { "YUV420p", @@ -290,12 +259,26 @@ PlaYUVerPixFmtDescriptor yuv420p = 1, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV420p, -}; + fillARGB32bufferYUV420p, }; PlaYUVerPixFmtDescriptor yuv422p = { @@ -307,12 +290,26 @@ PlaYUVerPixFmtDescriptor yuv422p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV422, -}; + fillARGB32bufferYUV422, }; PlaYUVerPixFmtDescriptor yuv444p = { @@ -324,12 +321,26 @@ PlaYUVerPixFmtDescriptor yuv444p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV444p, -}; + fillARGB32bufferYUV444p, }; PlaYUVerPixFmtDescriptor yuyv422 = { @@ -341,12 +352,26 @@ PlaYUVerPixFmtDescriptor yuyv422 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), { - { 0, 1, 1, 0, 7 }, /* Y */ - { 0, 3, 2, 0, 7 }, /* U */ - { 0, 3, 4, 0, 7 }, /* V */ + { + 0, + 1, + 1, + 0, + 7 }, /* Y */ + { + 0, + 3, + 2, + 0, + 7 }, /* U */ + { + 0, + 3, + 4, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV422, -}; + fillARGB32bufferYUV422, }; PlaYUVerPixFmtDescriptor gray = { @@ -357,9 +382,14 @@ PlaYUVerPixFmtDescriptor gray = 0, 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ), - { { 0, 0, 1, 0, 7 } }, /* Y */ - fillARGB32bufferGray, -}; + { + { + 0, + 0, + 1, + 0, + 7 } }, /* Y */ + NULL, }; PlaYUVerPixFmtDescriptor RGB24 = { @@ -371,12 +401,26 @@ PlaYUVerPixFmtDescriptor RGB24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), { - { 0, 2, 1, 0, 7 }, /* R */ - { 0, 2, 2, 0, 7 }, /* G */ - { 0, 2, 3, 0, 7 }, /* B */ + { + 0, + 2, + 1, + 0, + 7 }, /* R */ + { + 0, + 2, + 2, + 0, + 7 }, /* G */ + { + 0, + 2, + 3, + 0, + 7 }, /* B */ }, - fillARGB32bufferRGB, -}; + NULL, }; PlaYUVerPixFmtDescriptor BGR24 = { @@ -388,12 +432,26 @@ PlaYUVerPixFmtDescriptor BGR24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), { - { 0, 2, 3, 0, 7 }, /* R */ - { 0, 2, 2, 0, 7 }, /* G */ - { 0, 2, 1, 0, 7 }, /* B */ + { + 0, + 2, + 3, + 0, + 7 }, /* R */ + { + 0, + 2, + 2, + 0, + 7 }, /* G */ + { + 0, + 2, + 1, + 0, + 7 }, /* B */ }, - fillARGB32bufferRGB, -}; + NULL, }; PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] = { @@ -403,7 +461,6 @@ PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS yuyv422, gray, RGB24, - BGR24, -}; + BGR24, }; } // NAMESPACE diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h index 1052ade..c84c71e 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PlaYUVerFramePixelFormats.h @@ -156,7 +156,7 @@ typedef struct PlaYUVerPixFmtDescriptor */ PlaYUVerComponentDescriptor comp[4]; - Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height ); + Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ); } PlaYUVerPixFmtDescriptor; From e2385a81c295afc2fe0f071ae36043bfe9b23272 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 3 Apr 2015 13:04:20 +0100 Subject: [PATCH 53/94] Save pixels in Short instead of UChar --- lib/LibOpenCVHandler.cpp | 12 ++++++---- lib/PlaYUVerDefs.h | 14 +++++------ lib/PlaYUVerFrame.cpp | 28 +++++++++++----------- lib/PlaYUVerFrame.h | 4 ++-- lib/PlaYUVerFrameStats.cpp | 48 +++++++++++++++++++------------------- lib/PlaYUVerFrameStats.h | 2 +- lib/PlaYUVerStream.cpp | 20 ++++------------ lib/PlaYUVerStream.h | 2 +- 8 files changed, 63 insertions(+), 67 deletions(-) diff --git a/lib/LibOpenCVHandler.cpp b/lib/LibOpenCVHandler.cpp index a4ca1d8..cb8e9da 100644 --- a/lib/LibOpenCVHandler.cpp +++ b/lib/LibOpenCVHandler.cpp @@ -127,10 +127,9 @@ Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename ) } cv::Mat pcCvFrame( pcFrame->getHeight(), pcFrame->getWidth(), cvType ); - + UChar* pCvPel = pcCvFrame.data; if( pcFrame->getColorSpace() != PlaYUVerFrame::COLOR_GRAY ) { - UChar* pCvPel = pcCvFrame.data; UChar* pARGB = pcFrame->getRGBBuffer(); for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) { @@ -140,9 +139,14 @@ Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename ) pARGB++; } } - else + if( pcFrame->getColorSpace() == PlaYUVerFrame::COLOR_GRAY ) { - memcpy( pcCvFrame.data, pcFrame->getPelBufferYUV()[LUMA][0], pcFrame->getHeight() * pcFrame->getWidth() * sizeof(Pel) ); + + Pel* pPel = pcFrame->getPelBufferYUV()[LUMA][0]; + for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) + { + *pCvPel++ = *pPel++; + } } return cv::imwrite( filename, pcCvFrame ); } diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index e60b894..40652cd 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -18,13 +18,13 @@ */ /** - * \file TypeDef.h + * \file PlaYUVerDefs.h * \ingroup PlaYUVerLib * \brief Define basic types, new types and enumerations */ -#ifndef __TYPEDEF_H__ -#define __TYPEDEF_H__ +#ifndef __PLAYUVERDEFS_H__ +#define __PLAYUVERDEFS_H__ #include #include @@ -75,9 +75,9 @@ typedef unsigned long long UInt64; // Type definition // ==================================================================================================================== -typedef UChar Pel; ///< 8-bit pixel type -typedef UChar SBytePel; ///< 8-bit pixel type -//typedef Short Pel; ///< 16-bit pixel type +//typedef UChar Pel; ///< 8-bit pixel type +typedef Short Pel; ///< 16-bit pixel type +typedef UChar Byte; // ==================================================================================================================== // Limits definition @@ -131,4 +131,4 @@ inline std::string lowercase( const std::string& in ) } // NAMESPACE -#endif // __TYPEDEF_H__ +#endif // __PLAYUVERDEFS_H__ diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index dbb78f8..32dfad3 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -145,16 +145,16 @@ PlaYUVerFrame::~PlaYUVerFrame() closePixfc(); } -static Int getMem3ImageComponents( SBytePel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth ) +static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth ) { Int dim0 = 3; Int i; UInt64 total_mem_size = 0; UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) * CHROMASHIFT( dim2, log2ChromaWidth ) * 2 ); - total_mem_size += getMem2D( array3D, dim0, dim1 ); + total_mem_size += getMem2D( array3D, dim0, dim1 ); - if( ( ( *array3D )[0][0] = ( SBytePel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL ) + if( ( ( *array3D )[0][0] = ( Pel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL ) printf( "getMem3DImageComponents: array1D" ); total_mem_size += mem_size * sizeof(Pel); @@ -197,7 +197,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); m_bHasRGBPel = false; - UInt m_uiWidthBytes = m_uiWidth * ( ( m_iBitsPel - 1 ) / 8 + 1 ); + UInt m_uiWidthBytes = m_uiWidth; //* ( ( m_iBitsPel - 1 ) / 8 + 1 ); if( m_pcPelFormat->colorSpace == COLOR_GRAY ) { getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, 1, 1 ); @@ -255,13 +255,14 @@ UInt PlaYUVerFrame::getChromaLength() const return getChromaWidth() * getChromaHeight(); } -Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) +Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize ) { if( uiBuffSize != getBytesPerFrame() ) return; - Pel* ppBuff[MAX_NUMBER_PLANES]; - Pel* pTmpPel, *pTmpBuff; + Byte* ppBuff[MAX_NUMBER_PLANES]; + Byte* pTmpBuff; + Pel* pTmpPel; UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Int ratioH, ratioW, step; UInt i, ch; @@ -283,7 +284,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane] + ( m_pcPelFormat->comp[ch].offset_plus1 - 1 ); - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) { *pTmpPel++ = *pTmpBuff; pTmpBuff += step; @@ -294,11 +295,12 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) m_bHasHistogram = false; } -Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) +Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer ) { UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; - Pel* ppBuff[MAX_NUMBER_PLANES]; - Pel* pTmpPel, *pTmpBuff; + Byte* ppBuff[MAX_NUMBER_PLANES]; + Byte* pTmpBuff; + Pel* pTmpPel; Int ratioH, ratioW, step; UInt i, ch; @@ -319,7 +321,7 @@ Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane]; - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) { *pTmpBuff = *pTmpPel++; pTmpBuff += step; @@ -527,7 +529,7 @@ Void PlaYUVerFrame::fromCvMat( Void* voidFrame ) Pel* pInputPelY = m_pppcInputPel[LUMA][0]; Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0]; Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0]; - Pel* pcRGBPelInterlaced = m_pcARGB32; + UChar* pcRGBPelInterlaced = m_pcARGB32; memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 4 * sizeof(Pel) ); UInt* buff = ( UInt* )pcRGBPelInterlaced; for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 965f963..77ee887 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -214,8 +214,8 @@ public: UInt getChromaHeight() const; UInt getChromaLength() const; - Void frameFromBuffer( Pel*, UInt64 ); - Void frameToBuffer( Pel* ); + Void frameFromBuffer( Byte*, UInt64 ); + Void frameToBuffer( Byte* ); Void fillRGBBuffer(); diff --git a/lib/PlaYUVerFrameStats.cpp b/lib/PlaYUVerFrameStats.cpp index 5fbe55a..981f780 100644 --- a/lib/PlaYUVerFrameStats.cpp +++ b/lib/PlaYUVerFrameStats.cpp @@ -36,15 +36,15 @@ namespace plaYUVer { PlaYUVerFrameStats::PlaYUVerFrameStats() : - m_pdHistogram( NULL ), + m_puiHistogram( NULL ), m_bHasHistogram( false ) { } PlaYUVerFrameStats::~PlaYUVerFrameStats() { - if( m_pdHistogram ) - freeMem1D( m_pdHistogram ); + if( m_puiHistogram ) + freeMem1D( m_puiHistogram ); } @@ -77,9 +77,9 @@ Void PlaYUVerFrameStats::calcHistogram() //m_bHasHistogram = false; if( m_bHasHistogram ) return; - getMem1D( &( m_pdHistogram ), m_uiHistoSegments * histoChannels ); + getMem1D( &( m_puiHistogram ), m_uiHistoSegments * histoChannels ); - if( !m_pdHistogram ) + if( !m_puiHistogram ) { // qWarning( ) << "PlaYUVerFrameStats::calcHistogramValuess: " // "Unable to allocate memory!" @@ -97,14 +97,14 @@ Void PlaYUVerFrameStats::calcHistogram() data[CHROMA_V] = m_pppImageData[CHROMA_V][0]; for( i = 0; i < m_uiImageHeight * m_uiImageWidth; i++ ) { - m_pdHistogram[*( data[LUMA] ) + LUMA * m_uiHistoSegments]++; + m_puiHistogram[*( data[LUMA] ) + LUMA * m_uiHistoSegments]++; data[LUMA] += 1; } for( i = 0; ( i < imageChromaSize ) && m_bRunningFlag; i++ ) { for( j = 1; j < m_uiChannels; j++ ) { - m_pdHistogram[*( data[j] ) + j * m_uiHistoSegments]++; + m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++; } for( j = 1; j < m_uiChannels; j++ ) data[j] += 1; @@ -122,13 +122,13 @@ Void PlaYUVerFrameStats::calcHistogram() { for( j = 0; j < m_uiChannels; j++ ) { - m_pdHistogram[*( data[j] ) + j * m_uiHistoSegments]++; + m_puiHistogram[*( data[j] ) + j * m_uiHistoSegments]++; } if( calcLuma && ( imageColorSpace == PlaYUVerFrame::COLOR_RGB || imageColorSpace == PlaYUVerFrame::COLOR_ARGB ) ) { PlaYUVerFrame::Pixel currPixel( imageColorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ), *( data[COLOR_B] ) ); luma = PlaYUVerFrame::ConvertPixel( currPixel, PlaYUVerFrame::COLOR_YUV ).Y(); - m_pdHistogram[luma + j * m_uiHistoSegments]++; + m_puiHistogram[luma + j * m_uiHistoSegments]++; } for( j = 0; j < m_uiChannels; j++ ) data[j] += 1; @@ -228,7 +228,7 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end ) Int indexStart; Double count = 0.0; - if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) + if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) { return 0.0; } @@ -244,14 +244,14 @@ Double PlaYUVerFrameStats::getCount( Int channel, UInt start, UInt end ) for( i = start; i <= end; i++ ) { - count += m_pdHistogram[indexStart + i]; + count += m_puiHistogram[indexStart + i]; } return count; } Double PlaYUVerFrameStats::getPixels() { - if( !m_pdHistogram ) + if( !m_puiHistogram ) { return 0.0; } @@ -266,7 +266,7 @@ Double PlaYUVerFrameStats::getMean( Int channel, UInt start, UInt end ) Double mean = 0.0; Double count; - if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) + if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) { return 0.0; } @@ -282,7 +282,7 @@ Double PlaYUVerFrameStats::getMean( Int channel, UInt start, UInt end ) for( UInt i = start; i <= end; i++ ) { - mean += i * m_pdHistogram[indexStart + i]; + mean += i * m_puiHistogram[indexStart + i]; } count = getCount( channel, start, end ); @@ -302,7 +302,7 @@ Int PlaYUVerFrameStats::getMedian( Int channel, UInt start, UInt end ) Double sum = 0.0; Double count; - if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) + if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) { return 0; } @@ -320,7 +320,7 @@ Int PlaYUVerFrameStats::getMedian( Int channel, UInt start, UInt end ) for( UInt i = start; i <= end; i++ ) { - sum += m_pdHistogram[indexStart + i]; + sum += m_puiHistogram[indexStart + i]; if( sum * 2 > count ) return i; } @@ -336,7 +336,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end ) Double count; Double mean; - if( !m_pdHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) + if( !m_puiHistogram || start < 0 || end > m_uiHistoSegments - 1 || start > end ) { return 0.0; } @@ -359,7 +359,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end ) for ( i = start ; i <= end ; i++ ) { - dev += ( i - mean ) * ( i - mean ) * m_pdHistogram[indexStart +i]; + dev += ( i - mean ) * ( i - mean ) * m_puiHistogram[indexStart +i]; } return sqrt( dev / count ); @@ -368,7 +368,7 @@ Double PlaYUVerFrameStats::getStdDev( Int channel, UInt start, UInt end ) for( UInt i = start; i <= end; i++ ) { - dev += ( i * i ) * m_pdHistogram[indexStart + i]; + dev += ( i * i ) * m_puiHistogram[indexStart + i]; } return sqrt( ( dev - count * mean * mean ) / ( count - 1 ) ); @@ -381,7 +381,7 @@ Double PlaYUVerFrameStats::getHistogramValue( Int channel, UInt bin ) Int histoChannel; Int indexStart; - if( !m_pdHistogram || bin < 0 || bin > m_uiHistoSegments - 1 ) + if( !m_puiHistogram || bin < 0 || bin > m_uiHistoSegments - 1 ) return 0.0; histoChannel = getRealHistoChannel( channel ); @@ -393,7 +393,7 @@ Double PlaYUVerFrameStats::getHistogramValue( Int channel, UInt bin ) indexStart = histoChannel * m_uiHistoSegments; - value = m_pdHistogram[indexStart + bin]; + value = m_puiHistogram[indexStart + bin]; return value; } @@ -405,7 +405,7 @@ Double PlaYUVerFrameStats::getMaximum( Int channel ) Int histoChannel; Int indexStart; - if( !m_pdHistogram ) + if( !m_puiHistogram ) return 0.0; histoChannel = getRealHistoChannel( channel ); @@ -419,9 +419,9 @@ Double PlaYUVerFrameStats::getMaximum( Int channel ) for( UInt x = 0; x < m_uiHistoSegments; x++ ) { - if( m_pdHistogram[indexStart + x] > max ) + if( m_puiHistogram[indexStart + x] > max ) { - max = m_pdHistogram[indexStart + x]; + max = m_puiHistogram[indexStart + x]; } } diff --git a/lib/PlaYUVerFrameStats.h b/lib/PlaYUVerFrameStats.h index d853a87..dce1c84 100644 --- a/lib/PlaYUVerFrameStats.h +++ b/lib/PlaYUVerFrameStats.h @@ -95,7 +95,7 @@ public: private: /** The histogram data.*/ - Double* m_pdHistogram; + UInt* m_puiHistogram; /** If true, calc the luminosity channel histogram when the image is RGB */ Bool calcLuma; diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 6f58a5d..0b78e7c 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -364,7 +364,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in return m_bInit; } - if( !getMem1D( &m_pStreamBuffer, m_pcCurrFrame->getBytesPerFrame() ) ) + if( !getMem1D( &m_pStreamBuffer, m_pcCurrFrame->getBytesPerFrame() ) ) { close(); throw "[PlaYUVerStream] Cannot allocated memory"; @@ -432,7 +432,7 @@ Void PlaYUVerStream::close() } if( m_pStreamBuffer ) - freeMem1D( m_pStreamBuffer ); + freeMem1D( m_pStreamBuffer ); if( m_pchFilename ) delete[] m_pchFilename; @@ -563,7 +563,7 @@ Void PlaYUVerStream::readFrame() if( m_uiStreamHandler == YUV_IO ) { UInt64 frame_bytes_input = m_pcNextFrame->getBytesPerFrame(); - UInt64 bytes_read = fread( m_pStreamBuffer, sizeof(Pel), frame_bytes_input, m_pFile ); + UInt64 bytes_read = fread( m_pStreamBuffer, sizeof(Byte), frame_bytes_input, m_pFile ); if( bytes_read != frame_bytes_input ) { throw "[PlaYUVerStream] Cannot read file"; @@ -577,17 +577,7 @@ Void PlaYUVerStream::readFrame() Void PlaYUVerStream::writeFrame() { - if( m_uiStreamHandler == YUV_IO ) - { - UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame(); - m_pcCurrFrame->frameToBuffer( m_pStreamBuffer ); - UInt64 bytes_read = fwrite( m_pStreamBuffer, sizeof(Pel), frame_bytes_input, m_pFile ); - if( bytes_read != frame_bytes_input ) - { - throw "[PlaYUVerStream] Cannot write into the file"; - } - } - return; + writeFrame( m_pcCurrFrame ); } Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame ) @@ -596,7 +586,7 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame ) { UInt64 frame_bytes_input = pcFrame->getBytesPerFrame(); pcFrame->frameToBuffer( m_pStreamBuffer ); - UInt64 bytes_read = fwrite( m_pStreamBuffer, sizeof(Pel), frame_bytes_input, m_pFile ); + UInt64 bytes_read = fwrite( m_pStreamBuffer, sizeof(Byte), frame_bytes_input, m_pFile ); if( bytes_read != frame_bytes_input ) { throw "[PlaYUVerStream] Cannot write into the file"; diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index ee31ec7..fc99d9a 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -84,7 +84,7 @@ private: Int m_iPixelFormat; UInt m_uiBitsPerPixel; - Pel* m_pStreamBuffer; + Byte* m_pStreamBuffer; UInt m_uiFrameBufferSize; PlaYUVerFrame **m_ppcFrameBuffer; From 3af35f67278ffa2379e6f06a51f8bd71ef47539f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 3 Apr 2015 13:12:22 +0100 Subject: [PATCH 54/94] Fix number of HistoSegments --- lib/PlaYUVerFrameStats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PlaYUVerFrameStats.cpp b/lib/PlaYUVerFrameStats.cpp index 981f780..ab455ef 100644 --- a/lib/PlaYUVerFrameStats.cpp +++ b/lib/PlaYUVerFrameStats.cpp @@ -56,7 +56,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op m_uiImageHeight = pcFrame->getHeight(); m_uiChannels = pcFrame->getNumberChannels(); - m_uiHistoSegments = ( 1 << pcFrame->getBitsPel() ) - 1; + m_uiHistoSegments = 1 << pcFrame->getBitsPel(); imageColorSpace = pcFrame->getColorSpace(); imageChromaSize = pcFrame->getChromaLength(); @@ -95,7 +95,7 @@ Void PlaYUVerFrameStats::calcHistogram() data[LUMA] = m_pppImageData[LUMA][0]; data[CHROMA_U] = m_pppImageData[CHROMA_U][0]; data[CHROMA_V] = m_pppImageData[CHROMA_V][0]; - for( i = 0; i < m_uiImageHeight * m_uiImageWidth; i++ ) + for( i = 0; i < m_uiImageHeight * m_uiImageWidth && m_bRunningFlag; i++ ) { m_puiHistogram[*( data[LUMA] ) + LUMA * m_uiHistoSegments]++; data[LUMA] += 1; From 735b6b8efb6f8c46f928954edccc42ed26f80393 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 3 Apr 2015 13:59:32 +0100 Subject: [PATCH 55/94] Improve multy byte per pixel support - still incomplete --- lib/PlaYUVerFrame.cpp | 62 +++++++-- lib/PlaYUVerFramePixelFormats.cpp | 204 +++++------------------------- lib/PlaYUVerFramePixelFormats.h | 2 - 3 files changed, 83 insertions(+), 185 deletions(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 32dfad3..37be54f 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -197,14 +197,13 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); m_bHasRGBPel = false; - UInt m_uiWidthBytes = m_uiWidth; //* ( ( m_iBitsPel - 1 ) / 8 + 1 ); if( m_pcPelFormat->colorSpace == COLOR_GRAY ) { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, 1, 1 ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 1 ); } else { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); } getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 ); @@ -265,14 +264,14 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize ) Pel* pTmpPel; UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Int ratioH, ratioW, step; - UInt i, ch; + UInt i, ch, b; ppBuff[0] = Buff; - for( Int i = 1; i < MAX_NUMBER_PLANES; i++ ) + for( i = 1; i < MAX_NUMBER_PLANES; i++ ) { ratioW = i > 1 ? m_pcPelFormat->log2ChromaWidth : 0; ratioH = i > 1 ? m_pcPelFormat->log2ChromaHeight : 0; - ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); + ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; } for( ch = 0; ch < m_pcPelFormat->numberChannels; ch++ ) @@ -286,7 +285,14 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize ) for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) { - *pTmpPel++ = *pTmpBuff; + *pTmpPel = 0; + for( b = 0; b < bytesPixel; b++ ) + { + *pTmpPel = ( *pTmpPel << ( m_iBitsPel - 8 * b ) ); + *pTmpPel += *pTmpBuff++; + } + pTmpBuff--; + pTmpPel++; pTmpBuff += step; } } @@ -362,9 +368,47 @@ Void PlaYUVerFrame::fillRGBBuffer() *pARGB++ = PEL_RGB( iR, iG, iB ); } } - else + else if( m_pcPelFormat->colorSpace == COLOR_YUV ) { - m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight, bytesPixel ); + Int shiftBits = m_iBitsPel - 8; + Pel* pLineY = m_pppcInputPel[LUMA][0]; + Pel* pLineU = m_pppcInputPel[CHROMA_U][0]; + Pel* pLineV = m_pppcInputPel[CHROMA_V][0]; + UInt uiChromaStride = CHROMASHIFT( m_uiWidth, m_pcPelFormat->log2ChromaWidth ); + Pel* pY; + Pel* pU; + Pel* pV; + Int iY, iU, iV, iR, iG, iB; + UInt* pARGBLine = pARGB; + UInt* pARGB; + + UInt y, x; + Int i, j; + for( y = 0; y < m_uiHeight >> m_pcPelFormat->log2ChromaHeight; y++ ) + { + for( i = 0; i < 1 << m_pcPelFormat->log2ChromaHeight; i++ ) + { + pY = pLineY; + pU = pLineU; + pV = pLineV; + pARGB = pARGBLine; + for( x = 0; x < m_uiWidth >> m_pcPelFormat->log2ChromaWidth; x++ ) + { + iU = ( *pU++ ) >> shiftBits; + iV = ( *pV++ ) >> shiftBits; + for( j = 0; j < ( 1 << m_pcPelFormat->log2ChromaWidth ); j++ ) + { + iY = *pY++ >> shiftBits; + YUV2RGB( iY, iU, iV, iR, iG, iB ); + *pARGB++ = PEL_RGB( iR, iG, iB ); + } + } + pLineY += m_uiWidth; + pARGBLine += m_uiWidth; + } + pLineU += uiChromaStride; + pLineV += uiChromaStride; + } } m_bHasRGBPel = true; } diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp index ae8a8bc..a916622 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PlaYUVerFramePixelFormats.cpp @@ -52,46 +52,7 @@ namespace plaYUVer #define ADD_FFMPEG_PEL_FMT( fmt ) 0 #endif -Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt depth, UInt ratioChromaHor, UInt ratioChromaVer ) -{ - Pel* pLineY = in[LUMA][0]; - Pel* pLineU = in[CHROMA_U][0]; - Pel* pLineV = in[CHROMA_V][0]; - UInt uiChromaStride = CHROMASHIFT( width, ratioChromaHor ); - Pel* pY; - Pel* pU; - Pel* pV; - Int iY, iU, iV, iR, iG, iB; - UInt* pARGBLine = ( UInt* )out; - UInt* pARGB; - - for( UInt y = 0; y < height >> ratioChromaVer; y++ ) - { - for( Int i = 0; i < 1 << ratioChromaVer; i++ ) - { - pY = pLineY; - pU = pLineU; - pV = pLineV; - pARGB = pARGBLine; - for( UInt x = 0; x < width >> ratioChromaHor; x++ ) - { - iU = *pU++; - iV = *pV++; - for( Int j = 0; j < ( 1 << ratioChromaHor ) * depth; j++ ) - { - iY = *pY++; - YUV2RGB( iY, iU, iV, iR, iG, iB ); - *pARGB++ = PEL_RGB( iR, iG, iB ); - } - } - pLineY += width; - pARGBLine += width; - } - pLineU += uiChromaStride; - pLineV += uiChromaStride; - } -} - +#if 0 Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { #ifdef USE_SSE @@ -238,16 +199,7 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UI fillARGB32bufferYUV( in, out, width, height, depth, 1, 1 ); } } - -Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) -{ - fillARGB32bufferYUV( in, out, width, height, depth, 0, 0 ); -} - -Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) -{ - fillARGB32bufferYUV( in, out, width, height, depth, 1, 0 ); -} +#endif PlaYUVerPixFmtDescriptor yuv420p = { @@ -259,26 +211,11 @@ PlaYUVerPixFmtDescriptor yuv420p = 1, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, - fillARGB32bufferYUV420p, }; +}; PlaYUVerPixFmtDescriptor yuv422p = { @@ -290,26 +227,11 @@ PlaYUVerPixFmtDescriptor yuv422p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, - fillARGB32bufferYUV422, }; +}; PlaYUVerPixFmtDescriptor yuv444p = { @@ -321,26 +243,11 @@ PlaYUVerPixFmtDescriptor yuv444p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ), { - { - 0, - 0, - 1, - 0, - 7 }, /* Y */ - { - 1, - 0, - 1, - 0, - 7 }, /* U */ - { - 2, - 0, - 1, - 0, - 7 }, /* V */ + { 0, 0, 1, 0, 7 }, /* Y */ + { 1, 0, 1, 0, 7 }, /* U */ + { 2, 0, 1, 0, 7 }, /* V */ }, - fillARGB32bufferYUV444p, }; +}; PlaYUVerPixFmtDescriptor yuyv422 = { @@ -352,26 +259,11 @@ PlaYUVerPixFmtDescriptor yuyv422 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), { - { - 0, - 1, - 1, - 0, - 7 }, /* Y */ - { - 0, - 3, - 2, - 0, - 7 }, /* U */ - { - 0, - 3, - 4, - 0, - 7 }, /* V */ + { 0, 1, 1, 0, 7 }, /* Y */ + { 0, 3, 2, 0, 7 }, /* U */ + { 0, 3, 4, 0, 7 }, /* V */ }, - fillARGB32bufferYUV422, }; +}; PlaYUVerPixFmtDescriptor gray = { @@ -382,14 +274,8 @@ PlaYUVerPixFmtDescriptor gray = 0, 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ), - { - { - 0, - 0, - 1, - 0, - 7 } }, /* Y */ - NULL, }; + { { 0, 0, 1, 0, 7 } }, /* Y */ +}; PlaYUVerPixFmtDescriptor RGB24 = { @@ -401,26 +287,11 @@ PlaYUVerPixFmtDescriptor RGB24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), { - { - 0, - 2, - 1, - 0, - 7 }, /* R */ - { - 0, - 2, - 2, - 0, - 7 }, /* G */ - { - 0, - 2, - 3, - 0, - 7 }, /* B */ + { 0, 2, 1, 0, 7 }, /* R */ + { 0, 2, 2, 0, 7 }, /* G */ + { 0, 2, 3, 0, 7 }, /* B */ }, - NULL, }; +}; PlaYUVerPixFmtDescriptor BGR24 = { @@ -432,26 +303,11 @@ PlaYUVerPixFmtDescriptor BGR24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), { - { - 0, - 2, - 3, - 0, - 7 }, /* R */ - { - 0, - 2, - 2, - 0, - 7 }, /* G */ - { - 0, - 2, - 1, - 0, - 7 }, /* B */ + { 0, 2, 3, 0, 7 }, /* R */ + { 0, 2, 2, 0, 7 }, /* G */ + { 0, 2, 1, 0, 7 }, /* B */ }, - NULL, }; +}; PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] = { @@ -461,6 +317,6 @@ PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS yuyv422, gray, RGB24, - BGR24, }; - + BGR24, +}; } // NAMESPACE diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h index c84c71e..deede8b 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PlaYUVerFramePixelFormats.h @@ -156,8 +156,6 @@ typedef struct PlaYUVerPixFmtDescriptor */ PlaYUVerComponentDescriptor comp[4]; - Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ); - } PlaYUVerPixFmtDescriptor; #define MAX_NUMBER_PLANES 3 From 1167ed653d731f16d1e07bf3eb357a0739518cd4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 5 Apr 2015 12:53:04 +0100 Subject: [PATCH 56/94] Fix using 16 bits per pixel component - now it supports read and write of up to 2 bytes pel data --- app/HistogramWidget.cpp | 2 +- app/ViewArea.cpp | 165 ++++++++++++++++++++-------------------- app/ViewArea.h | 1 + lib/PlaYUVerDefs.h | 3 +- lib/PlaYUVerFrame.cpp | 36 +++++---- lib/PlaYUVerStream.cpp | 2 +- 6 files changed, 106 insertions(+), 103 deletions(-) diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp index 6e06867..3c8e40c 100644 --- a/app/HistogramWidget.cpp +++ b/app/HistogramWidget.cpp @@ -58,7 +58,7 @@ public: if( m_histogram && m_parent ) { EventData *eventData = new EventData(); -// eventData->starting = true; +// eventDm_imageHistogramata->starting = true; // eventData->success = false; // eventData->histogram = m_histogram; // QCoreApplication::postEvent( m_parent, eventData ); diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index 5b3377c..fa57c7a 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -71,6 +71,7 @@ ViewArea::ViewArea( QWidget *parent ) : void ViewArea::setImage( PlaYUVerFrame* pcFrame ) { m_pcCurrFrame = pcFrame; + m_uiPixelHalfScale = 1 << ( m_pcCurrFrame->getBitsPel() - 1 ); m_pcCurrFrame->fillRGBBuffer(); QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB32 ); setImage( QPixmap::fromImage( qimg ) ); @@ -122,29 +123,28 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize return new_scale; Double zoomFactor = m_zoomFactor * scale * 100.0; - zoomFactor=round(zoomFactor); - zoomFactor=zoomFactor/100.0; - scale = zoomFactor/m_zoomFactor; + zoomFactor = round( zoomFactor ); + zoomFactor = zoomFactor / 100.0; + scale = zoomFactor / m_zoomFactor; - - if(!minimumSize.isNull()) + if( !minimumSize.isNull() ) { - Double cw = m_pixmap.width()*m_zoomFactor; - Double ch = m_pixmap.height()*m_zoomFactor; - Double fw = m_pixmap.width()*zoomFactor; - Double fh = m_pixmap.height()*zoomFactor; + Double cw = m_pixmap.width() * m_zoomFactor; + Double ch = m_pixmap.height() * m_zoomFactor; + Double fw = m_pixmap.width() * zoomFactor; + Double fh = m_pixmap.height() * zoomFactor; Double mw = minimumSize.width(); Double mh = minimumSize.height(); - if( (cw < mw) && (ch < mh) && (scale < 1) ) + if( ( cw < mw ) && ( ch < mh ) && ( scale < 1 ) ) { return new_scale; } - if( (fw < mw) && (fh < mh) && (scale < 1) ) + if( ( fw < mw ) && ( fh < mh ) && ( scale < 1 ) ) { - Double wfactor = mw/fw; - Double hfactor = mh/fh; + Double wfactor = mw / fw; + Double hfactor = mh / fh; if( wfactor < hfactor ) scale = wfactor; @@ -152,9 +152,9 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize scale = hfactor; zoomFactor = zoomFactor * scale * 100.0; - zoomFactor=round(zoomFactor); - zoomFactor=zoomFactor/100.0; - scale = zoomFactor/m_zoomFactor; + zoomFactor = round( zoomFactor ); + zoomFactor = zoomFactor / 100.0; + scale = zoomFactor / m_zoomFactor; } } @@ -163,14 +163,14 @@ Double ViewArea::scaleZoomFactor( Double scale, QPoint center, QSize minimumSize if( zoomFactor < minZoom ) { zoomFactor = minZoom; - new_scale = zoomFactor/m_zoomFactor; + new_scale = zoomFactor / m_zoomFactor; } else { if( zoomFactor > maxZoom ) { zoomFactor = maxZoom; - new_scale = zoomFactor/m_zoomFactor; + new_scale = zoomFactor / m_zoomFactor; } } @@ -335,7 +335,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) { QRect winRect = event->rect(); - if(visibleRegion().isEmpty()) + if( visibleRegion().isEmpty() ) return; if( size().isEmpty() || m_pixmap.isNull() ) @@ -384,13 +384,12 @@ void ViewArea::paintEvent( QPaintEvent *event ) painter.restore(); - // Draw a border around the image. -/* if( m_xOffset || m_yOffset ) - { - painter.setPen( Qt::black ); - painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_zoomFactor + 1, m_pixmap.height() * m_zoomFactor + 1 ); - }*/ + /* if( m_xOffset || m_yOffset ) + { + painter.setPen( Qt::black ); + painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() * m_zoomFactor + 1, m_pixmap.height() * m_zoomFactor + 1 ); + }*/ // Draw pixel values in grid if( m_zoomFactor >= 50.0 ) @@ -420,7 +419,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) { sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); - if( sPixelValue.Y() < 128 ) + if( sPixelValue.Y() < m_uiPixelHalfScale ) painter.setPen( QColor( Qt::white ) ); else painter.setPen( QColor( Qt::black ) ); @@ -433,7 +432,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) { sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); - if( sPixelValue.Y() < 128 ) + if( sPixelValue.Y() < m_uiPixelHalfScale ) painter.setPen( QColor( Qt::white ) ); else painter.setPen( QColor( Qt::black ) ); @@ -445,7 +444,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) { sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); - if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < 128 * 3 ) + if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) ) painter.setPen( QColor( Qt::white ) ); else painter.setPen( QColor( Qt::black ) ); @@ -457,7 +456,6 @@ void ViewArea::paintEvent( QPaintEvent *event ) } } - QColor color( Qt::white ); QPen mainPen = QPen( color, 1, Qt::SolidLine ); painter.setPen( mainPen ); @@ -513,7 +511,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) ); myPath.addRect( imgr ); - myPath.addRect( sr); //m_selectedArea + myPath.addRect( sr ); //m_selectedArea painter.drawPath( myPath ); // 2) Draw the selection rectangle @@ -600,14 +598,14 @@ void ViewArea::wheelEvent( QWheelEvent *event ) if( event->modifiers() & Qt::ControlModifier ) { scale = 0.001 * event->delta(); - if(scale>0) - scale=1.25; + if( scale > 0 ) + scale = 1.25; else - scale=0.8; + scale = 0.8; QWidget *p = parentWidget(); QSize minimumSize = QSize( p->size().width() - 5, p->size().height() - 5 ); - usedScale = scaleZoomFactor( scale , event->pos(), minimumSize ); + usedScale = scaleZoomFactor( scale, event->pos(), minimumSize ); if( usedScale != 1.0 ) { emit zoomFactorChanged_byWheel( usedScale, event->pos() ); @@ -736,7 +734,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event ) // From left to right if( m_lastPos.x() < actualPos.x() ) { - QPoint bottomR = actualPos;// - QPoint( 1, 1 ); + QPoint bottomR = actualPos; // - QPoint( 1, 1 ); m_selectedArea = QRect( m_lastPos, bottomR ); } // From right to left @@ -761,7 +759,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event ) // From right to left else { - QPoint bottomR = m_lastPos;// - QPoint( 1, 1 ); + QPoint bottomR = m_lastPos; // - QPoint( 1, 1 ); m_selectedArea = QRect( actualPos, bottomR ); } } @@ -868,57 +866,56 @@ void ViewArea::mouseReleaseEvent( QMouseEvent *event ) } } - //////////////////////////////////////////////////////////////////////////////// bool ViewArea::isPosValid( const QPoint &pos ) const { -if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() ) - return false; -else - return true; + if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() ) + return false; + else + return true; } //////////////////////////////////////////////////////////////////////////////// QPoint ViewArea::windowToView( const QPoint& pt ) const { -QPoint p; -p.setX( static_cast( ( pt.x() - m_xOffset ) / m_zoomFactor ) ); -p.setY( static_cast( ( pt.y() - m_yOffset ) / m_zoomFactor ) ); + QPoint p; + p.setX( static_cast( ( pt.x() - m_xOffset ) / m_zoomFactor ) ); + p.setY( static_cast( ( pt.y() - m_yOffset ) / m_zoomFactor ) ); -return p; + return p; } QRect ViewArea::windowToView( const QRect& rc ) const { -QRect r; + QRect r; -r.setTopLeft( windowToView( rc.topLeft() ) ); + r.setTopLeft( windowToView( rc.topLeft() ) ); // r.setRight ( (int)( ceil(( rc.right() - m_xOffset)/m_zoomFactor ))); // r.setBottom( (int)( ceil(( rc.bottom()- m_yOffset)/m_zoomFactor ))); // r.setRight ( static_cast(( rc.right() - m_xOffset ) / m_zoomFactor +1)); // r.setBottom( static_cast(( rc.bottom() - m_xOffset ) / m_zoomFactor+1)); -r.setBottomRight( windowToView( rc.bottomRight() ) ); -return r; + r.setBottomRight( windowToView( rc.bottomRight() ) ); + return r; } QPoint ViewArea::viewToWindow( const QPoint& pt ) const { -QPoint p; + QPoint p; -p.setX( static_cast( pt.x() * m_zoomFactor + m_xOffset ) ); -p.setY( static_cast( pt.y() * m_zoomFactor + m_yOffset ) ); + p.setX( static_cast( pt.x() * m_zoomFactor + m_xOffset ) ); + p.setY( static_cast( pt.y() * m_zoomFactor + m_yOffset ) ); -return p; + return p; } QRect ViewArea::viewToWindow( const QRect& rc ) const { -QRect r; + QRect r; -r.setTopLeft( viewToWindow( rc.topLeft() ) ); + r.setTopLeft( viewToWindow( rc.topLeft() ) ); // r.setRight ( (int)( ceil(( rc.right() +1+m_xOffset )*m_zoomFactor ) - 1 )); // r.setBottom( (int)( ceil(( rc.bottom()+1+m_yOffset )*m_zoomFactor ) - 1 )); // r.setRight ( (int)( ceil(( rc.right()+0.5)*m_zoomFactor )+ m_xOffset )-1); @@ -926,9 +923,9 @@ r.setTopLeft( viewToWindow( rc.topLeft() ) ); // qDebug()<<"Right = "<< r.right(); // r.setRight ( static_cast(( rc.right()+1) * m_zoomFactor + m_xOffset -1) ); // r.setBottom( static_cast(( rc.bottom()+1) * m_zoomFactor + m_yOffset -1)); -r.setBottomRight( viewToWindow( rc.bottomRight() ) ); + r.setBottomRight( viewToWindow( rc.bottomRight() ) ); -return r; + return r; } //////////////////////////////////////////////////////////////////////////////// @@ -936,41 +933,41 @@ return r; //////////////////////////////////////////////////////////////////////////////// void ViewArea::updateMask( const QRect &rect ) { -switch( tool() ) -{ -case MaskTool: -{ - // Add rect to the mask - QPainter painter( &m_mask ); - painter.setBrush( Qt::color1 ); - painter.setPen( Qt::NoPen ); - painter.drawRect( rect ); - painter.end(); - break; -} -case EraserTool: -{ - // Clears rect area in the mask - QPainter painter( &m_mask ); - painter.setBrush( Qt::color0 ); - painter.setPen( Qt::NoPen ); - painter.drawRect( rect ); - painter.end(); - break; -} -default: /* Do Nothing */ - ; -} + switch( tool() ) + { + case MaskTool: + { + // Add rect to the mask + QPainter painter( &m_mask ); + painter.setBrush( Qt::color1 ); + painter.setPen( Qt::NoPen ); + painter.drawRect( rect ); + painter.end(); + break; + } + case EraserTool: + { + // Clears rect area in the mask + QPainter painter( &m_mask ); + painter.setBrush( Qt::color0 ); + painter.setPen( Qt::NoPen ); + painter.drawRect( rect ); + painter.end(); + break; + } + default: /* Do Nothing */ + ; + } } void ViewArea::setInputStream( PlaYUVerStream *stream ) { -m_pStream = stream; + m_pStream = stream; } PlaYUVerStream* ViewArea::getInputStream() { -return m_pStream; + return m_pStream; } } // NameSpace plaYUVer diff --git a/app/ViewArea.h b/app/ViewArea.h index 4a1d4bd..de6f10f 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -163,6 +163,7 @@ private: QRect viewToWindow( const QRect& rc ) const; PlaYUVerFrame *m_pcCurrFrame; + UInt m_uiPixelHalfScale; QPixmap m_pixmap; QBitmap m_mask; QRect m_selectedArea; diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 40652cd..0d597d6 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -75,8 +75,7 @@ typedef unsigned long long UInt64; // Type definition // ==================================================================================================================== -//typedef UChar Pel; ///< 8-bit pixel type -typedef Short Pel; ///< 16-bit pixel type +typedef UShort Pel; ///< 16-bit pixel type typedef UChar Byte; // ==================================================================================================================== diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 37be54f..25f7a9f 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -285,18 +285,16 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize ) for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) { - *pTmpPel = 0; - for( b = 0; b < bytesPixel; b++ ) + *pTmpPel = *pTmpBuff; + for( b = 1; b < bytesPixel; b++ ) { - *pTmpPel = ( *pTmpPel << ( m_iBitsPel - 8 * b ) ); - *pTmpPel += *pTmpBuff++; + pTmpBuff++; + *pTmpPel |= ( *pTmpBuff << ( 8 * b ) ); } - pTmpBuff--; pTmpPel++; pTmpBuff += step; } } - m_bHasRGBPel = false; m_bHasHistogram = false; } @@ -308,14 +306,14 @@ Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer ) Byte* pTmpBuff; Pel* pTmpPel; Int ratioH, ratioW, step; - UInt i, ch; + UInt i, ch, b; ppBuff[0] = output_buffer; for( Int i = 1; i < MAX_NUMBER_PLANES; i++ ) { ratioW = i > 1 ? m_pcPelFormat->log2ChromaWidth : 0; ratioH = i > 1 ? m_pcPelFormat->log2ChromaHeight : 0; - ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); + ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; } for( ch = 0; ch < m_pcPelFormat->numberChannels; ch++ ) @@ -329,7 +327,13 @@ Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer ) for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) { - *pTmpBuff = *pTmpPel++; + *pTmpBuff = ( *pTmpPel & 0x00FF ); + for( b = 1; b < bytesPixel; b++ ) + { + pTmpBuff++; + *pTmpBuff = ( *pTmpPel >> ( 8 * b ) ) & 0x00FF; + } + pTmpPel++; pTmpBuff += step; } } @@ -340,7 +344,6 @@ Void PlaYUVerFrame::fillRGBBuffer() { if( m_bHasRGBPel ) return; - UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Int iR, iG, iB; UInt* pARGB = ( UInt* )m_pcARGB32; if( m_pcPelFormat->colorSpace == COLOR_GRAY ) @@ -348,8 +351,8 @@ Void PlaYUVerFrame::fillRGBBuffer() Pel* pY = m_pppcInputPel[LUMA][0]; for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) { - iR = *pY++; - iG = *pY++; + iR = *pY; + iG = *pY; iB = *pY++; *pARGB++ = PEL_RGB( iR, iG, iB ); } @@ -394,11 +397,14 @@ Void PlaYUVerFrame::fillRGBBuffer() pARGB = pARGBLine; for( x = 0; x < m_uiWidth >> m_pcPelFormat->log2ChromaWidth; x++ ) { - iU = ( *pU++ ) >> shiftBits; - iV = ( *pV++ ) >> shiftBits; + iU = *pU++; + iU >>= shiftBits; + iV = *pV++; + iV >>= shiftBits; for( j = 0; j < ( 1 << m_pcPelFormat->log2ChromaWidth ); j++ ) { - iY = *pY++ >> shiftBits; + iY = *pY++; + iY >>= shiftBits; YUV2RGB( iY, iU, iV, iR, iG, iB ); *pARGB++ = PEL_RGB( iR, iG, iB ); } diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 0b78e7c..70225b5 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -623,7 +623,7 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *save if( fmtExt == "yuv" ) { PlaYUVerStream auxFrameStream; - if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), 1, false ) ) + if( !auxFrameStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), saveFrame->getBitsPel(), 1, false ) ) { return false; } From 16ba68910153810997b2abc7c1375277fe168cbb Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 5 Apr 2015 12:53:13 +0100 Subject: [PATCH 57/94] Update modules --- modules/FilterComponent.cpp | 12 ++++++------ modules/FilterComponent.h | 2 +- modules/FrameBinarization.cpp | 2 +- modules/FrameCrop.cpp | 2 +- modules/FrameDifference.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/FilterComponent.cpp b/modules/FilterComponent.cpp index 17258fb..2fb6a58 100644 --- a/modules/FilterComponent.cpp +++ b/modules/FilterComponent.cpp @@ -34,10 +34,10 @@ FilterComponentModule::FilterComponentModule() m_pcFilteredFrame = NULL; } -Void FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight ) +Void FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel ) { m_pcFilteredFrame = NULL; - m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY ); + m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY, bitsPixel ); } PlaYUVerFrame* FilterComponentModule::filterComponent( PlaYUVerFrame* InputFrame, Int Component ) @@ -60,7 +60,7 @@ FilterComponentLuma::FilterComponentLuma() /* Module Definition */ m_iModuleType = FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence. // Currently only support for frame - m_pchModuleCategory = "FilterComponent"; // Category (sub-menu) + m_pchModuleCategory = "FilterComponent"; // Category (sub-menu) m_pchModuleName = "Luma"; // Name m_pchModuleTooltip = "Filter Y matrix of YUV frame"; // Description m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) @@ -70,7 +70,7 @@ FilterComponentLuma::FilterComponentLuma() Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame ) { - createFilter( InputFrame->getWidth(), InputFrame->getHeight() ); + createFilter( InputFrame->getWidth(), InputFrame->getHeight(), InputFrame->getBitsPel() ); } PlaYUVerFrame* FilterComponentLuma::process( PlaYUVerFrame* InputFrame ) @@ -91,7 +91,7 @@ FilterComponentChromaU::FilterComponentChromaU() Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame ) { - createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight(), InputFrame->getBitsPel() ); } PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame ) @@ -112,7 +112,7 @@ FilterComponentChromaV::FilterComponentChromaV() Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame ) { - createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight(), InputFrame->getBitsPel() ); } PlaYUVerFrame* FilterComponentChromaV::process( PlaYUVerFrame* InputFrame ) diff --git a/modules/FilterComponent.h b/modules/FilterComponent.h index 70e0352..9bc0a89 100644 --- a/modules/FilterComponent.h +++ b/modules/FilterComponent.h @@ -43,7 +43,7 @@ public: PlaYUVerFrame* process( PlaYUVerFrame* ) = 0; Void destroy(); - Void createFilter( UInt uiWidth, UInt uiHeight ); + Void createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel ); PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component ); }; diff --git a/modules/FrameBinarization.cpp b/modules/FrameBinarization.cpp index fc0a366..ed8662b 100644 --- a/modules/FrameBinarization.cpp +++ b/modules/FrameBinarization.cpp @@ -47,7 +47,7 @@ FrameBinarization::FrameBinarization() Void FrameBinarization::create( PlaYUVerFrame* frame ) { m_pcBinFrame = NULL; - m_pcBinFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), PlaYUVerFrame::GRAY ); + m_pcBinFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), PlaYUVerFrame::GRAY, 8 ); } PlaYUVerFrame* FrameBinarization::process( PlaYUVerFrame* frame ) diff --git a/modules/FrameCrop.cpp b/modules/FrameCrop.cpp index d4718cd..23c210f 100644 --- a/modules/FrameCrop.cpp +++ b/modules/FrameCrop.cpp @@ -61,7 +61,7 @@ Void FrameCrop::create( PlaYUVerFrame* frame ) { m_iYSize = frame->getHeight() - m_uiYPosition; } - m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat() ); + m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat(), frame->getBitsPel() ); } PlaYUVerFrame* FrameCrop::process( PlaYUVerFrame* frame ) diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index 2c47ce5..719b173 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -43,7 +43,7 @@ FrameDifference::FrameDifference() Void FrameDifference::create( PlaYUVerFrame* Input ) { - m_pcFrameDifference = new PlaYUVerFrame( Input->getWidth(), Input->getHeight(), PlaYUVerFrame::GRAY ); + m_pcFrameDifference = new PlaYUVerFrame( Input->getWidth(), Input->getHeight(), PlaYUVerFrame::GRAY, Input->getBitsPel() ); } PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 ) From 551b5d617d4adecd4ad1c115797043e9e6bb0514 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 5 Apr 2015 12:57:03 +0100 Subject: [PATCH 58/94] Add bpp in status bar --- app/VideoHandle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 6ba3c33..a3a383f 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -235,6 +235,7 @@ Void VideoHandle::update() if( pcFrame ) { + resolution.append( QString( " %1 bpp" ).arg( pcFrame->getBitsPel() ) ); m_pcResolutionLabel->setText( resolution ); } From 4508dcb178be1e97c62deb8a176ad05e4a493bfc Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:01:20 +0100 Subject: [PATCH 59/94] Init the version 2 of module API. The process functions include a std vector and the create function signals if the module can be created with the chosen inputs --- app/ModulesHandle.cpp | 35 +++++++++++--- app/ModulesHandle.h | 1 - app/PlaYUVerAppModuleIf.cpp | 55 +++++++++++++-------- app/VideoSubWindow.h | 6 ++- modules/AbsoluteFrameDifference.cpp | 10 ++-- modules/AbsoluteFrameDifference.h | 6 +-- modules/DisparityStereoVar.cpp | 24 ++++++---- modules/DisparityStereoVar.h | 4 +- modules/PlaYUVerModuleIf.h | 17 +++++-- tools/PlaYUVerTools.cpp | 74 +++++++++++++++++++++-------- 10 files changed, 162 insertions(+), 70 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index ef4d3a0..7a4d21b 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -164,24 +164,23 @@ Void ModulesHandle::updateMenus() { m_arrayActions.at( i )->setEnabled( false ); } - m_arrayActions[DISABLE_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[DISABLE_ALL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcPlaYUVerAppModuleIfList.size() > 0 ); + if( pcSubWindow ) { QList apcCurrentModule = pcSubWindow->getModuleArray(); + m_arrayActions[DISABLE_ACT]->setEnabled( apcCurrentModule.size() > 0 ); if( pcSubWindow->getDisplayModule() ) { m_arrayActions[APPLY_ALL_ACT]->setEnabled( true ); m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true ); - apcCurrentModule.append( pcSubWindow->getDisplayModule() ); } for( Int i = 0; i < apcCurrentModule.size(); i++ ) { currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction; currModuleAction->setChecked( true ); } - } } @@ -315,6 +314,31 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf ); moduleOptDialog.runConfiguration(); } + + // Create Module + Bool moduleCreated = false; + if( pcCurrModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_2 ) + { + std::vector apcFrameList; + for( UInt i = 0; i < pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; i++ ) + { + apcFrameList.push_back( pcCurrModuleIf->m_pcSubWindow[i]->getCurrFrame() ); + } + moduleCreated = pcCurrModuleIf->m_pcModule->create( apcFrameList ); + } + else if( pcCurrModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_1 ) + { + pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); + moduleCreated = true; + } + + if( !moduleCreated ) + { + qobject_cast( m_pcParent )->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); + destroyModuleIf( pcCurrModuleIf ); + return; + } + if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) { if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) @@ -346,9 +370,6 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) qobject_cast( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget ); } - // Create Module - pcCurrModuleIf->m_pcModule->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); - // Associate module with subwindows if( !pcCurrModuleIf->m_pcDisplaySubWindow && !pcCurrModuleIf->m_pcModuleDock ) { diff --git a/app/ModulesHandle.h b/app/ModulesHandle.h index 4329111..498a281 100644 --- a/app/ModulesHandle.h +++ b/app/ModulesHandle.h @@ -82,7 +82,6 @@ private: QMenu* m_pcModulesMenu; QList m_pcModulesSubMenuList; - QList m_pcPlaYUVerModulesIfList; QList m_pcPlaYUVerAppModuleIfList; QVector m_arrayModulesActions; diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index 5145312..37ab439 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -47,37 +47,52 @@ PlaYUVerAppModuleIf::PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaY void PlaYUVerAppModuleIf::run() { + m_pcProcessedFrame = NULL; m_dMeasurementResult = 0; + std::vector apcFrameList; + for( UInt i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ ) + { + apcFrameList.push_back( m_pcSubWindow[i]->getCurrFrame() ); + } + if( m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE ) { - switch( m_pcModule->m_uiNumberOfFrames ) + if( m_pcModule->m_iModuleAPI == MODULE_API_2 ) { - case MODULE_REQUIRES_ONE_FRAME: - m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); - break; - case MODULE_REQUIRES_THREE_FRAMES: - m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() ); - break; + m_pcProcessedFrame = m_pcModule->process( apcFrameList ); + } + else + { + switch( m_pcModule->m_uiNumberOfFrames ) + { + case MODULE_REQUIRES_ONE_FRAME: + m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() ); + break; + case MODULE_REQUIRES_TWO_FRAMES: + m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); + break; + } } } else if( m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { - switch( m_pcModule->m_uiNumberOfFrames ) + if( m_pcModule->m_iModuleAPI == MODULE_API_2 ) { - case MODULE_REQUIRES_ONE_FRAME: - m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); - break; - case MODULE_REQUIRES_THREE_FRAMES: - m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() ); - break; + m_dMeasurementResult = m_pcModule->measure( apcFrameList ); + } + else + { + switch( m_pcModule->m_uiNumberOfFrames ) + { + case MODULE_REQUIRES_ONE_FRAME: + m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() ); + break; + case MODULE_REQUIRES_TWO_FRAMES: + m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); + break; + } } } else diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index d714614..0da9fd1 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -189,7 +189,11 @@ public: QList getModuleArray() { - return m_apcCurrentModule; + QList apcModulesArray; + if( m_pcCurrentDisplayModule ) + apcModulesArray.append( m_pcCurrentDisplayModule ); + apcModulesArray.append( m_apcCurrentModule ); + return apcModulesArray; } Void setTool( UInt uiTool ) diff --git a/modules/AbsoluteFrameDifference.cpp b/modules/AbsoluteFrameDifference.cpp index d0c1405..46130b0 100644 --- a/modules/AbsoluteFrameDifference.cpp +++ b/modules/AbsoluteFrameDifference.cpp @@ -31,6 +31,7 @@ namespace plaYUVer AbsoluteFrameDifference::AbsoluteFrameDifference() { /* Module Definition */ + m_iModuleAPI = MODULE_API_2; m_iModuleType = FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Measurements"; m_pchModuleName = "AbsoluteFrameDifference"; @@ -40,13 +41,16 @@ AbsoluteFrameDifference::AbsoluteFrameDifference() m_pcFrameDifference = NULL; } -Void AbsoluteFrameDifference::create( PlaYUVerFrame* Input ) +Bool AbsoluteFrameDifference::create( std::vector apcFrameList ) { - m_pcFrameDifference = new PlaYUVerFrame( Input->getWidth(), Input->getHeight(), PlaYUVerFrame::GRAY ); + m_pcFrameDifference = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + return true; } -PlaYUVerFrame* AbsoluteFrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 ) +PlaYUVerFrame* AbsoluteFrameDifference::process( std::vector apcFrameList ) { + PlaYUVerFrame* Input1 = apcFrameList[0]; + PlaYUVerFrame* Input2 = apcFrameList[1]; Pel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; diff --git a/modules/AbsoluteFrameDifference.h b/modules/AbsoluteFrameDifference.h index 6f4c543..434d61a 100644 --- a/modules/AbsoluteFrameDifference.h +++ b/modules/AbsoluteFrameDifference.h @@ -34,7 +34,7 @@ namespace plaYUVer class AbsoluteFrameDifference: public PlaYUVerModuleIf { - REGISTER_CLASS_FACTORY( AbsoluteFrameDifference ) +REGISTER_CLASS_FACTORY( AbsoluteFrameDifference ) private: PlaYUVerFrame* m_pcFrameDifference; @@ -44,8 +44,8 @@ public: virtual ~AbsoluteFrameDifference() { } - Void create( PlaYUVerFrame* Input ); - PlaYUVerFrame* process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 ); + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); Void destroy(); }; diff --git a/modules/DisparityStereoVar.cpp b/modules/DisparityStereoVar.cpp index 210bc17..424cdf9 100644 --- a/modules/DisparityStereoVar.cpp +++ b/modules/DisparityStereoVar.cpp @@ -32,6 +32,7 @@ namespace plaYUVer DisparityStereoVar::DisparityStereoVar() { /* Module Definition */ + m_iModuleAPI = MODULE_API_2; m_iModuleType = FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Disparity"; m_pchModuleName = "StereoVar"; @@ -54,24 +55,27 @@ DisparityStereoVar::DisparityStereoVar() m_cStereoVar.flags = m_cStereoVar.USE_SMART_ID | m_cStereoVar.USE_AUTO_PARAMS | m_cStereoVar.USE_INITIAL_DISPARITY | m_cStereoVar.USE_MEDIAN_FILTERING; } -Void DisparityStereoVar::create( PlaYUVerFrame* InputFrame ) +Bool DisparityStereoVar::create( std::vector apcFrameList ) { - m_pcDisparityFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY ); - m_cStereoVar.minDisp = -( ( ( InputFrame->getWidth() / 8 ) + 15 ) & -16 ); + m_pcDisparityFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + m_cStereoVar.minDisp = -( ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16 ); + return true; } - -PlaYUVerFrame* DisparityStereoVar::process( PlaYUVerFrame* InputLeft, PlaYUVerFrame* InputRight ) +PlaYUVerFrame* DisparityStereoVar::process( std::vector apcFrameList ) { + PlaYUVerFrame* InputLeft = apcFrameList[0]; + PlaYUVerFrame* InputRight = apcFrameList[1]; + cv::Mat* leftImage; - InputLeft->getCvMat( (Void**)&leftImage ); + InputLeft->getCvMat( ( Void** )&leftImage ); cv::Mat* rightImage; - InputRight->getCvMat( (Void**)&rightImage ); + InputRight->getCvMat( ( Void** )&rightImage ); cv::Mat disparityImage, disparityImage8; - m_cStereoVar(*leftImage,*rightImage,disparityImage); - disparityImage.convertTo(disparityImage8,CV_8U); + m_cStereoVar( *leftImage, *rightImage, disparityImage ); + disparityImage.convertTo( disparityImage8, CV_8U ); - m_pcDisparityFrame->fromCvMat( (Void*)&disparityImage8); + m_pcDisparityFrame->fromCvMat( ( Void* )&disparityImage8 ); return m_pcDisparityFrame; } diff --git a/modules/DisparityStereoVar.h b/modules/DisparityStereoVar.h index 3c3b6be..3f7d3e1 100644 --- a/modules/DisparityStereoVar.h +++ b/modules/DisparityStereoVar.h @@ -47,8 +47,8 @@ public: { } - Void create( PlaYUVerFrame* InputFrame ); - PlaYUVerFrame* process( PlaYUVerFrame* InputLeft, PlaYUVerFrame* InputRight ); + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); Void destroy(); }; diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index 527bbda..b6e31d1 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -29,6 +29,7 @@ #include "lib/PlaYUVerFrame.h" #include "lib/PlaYUVerStream.h" #include "lib/ProgramOptions.h" +#include namespace plaYUVer { @@ -38,6 +39,12 @@ public: \ static PlaYUVerModuleIf* Create() { return new X(); } \ void Delete() { delete this; } +enum // Module API +{ + MODULE_API_1, + MODULE_API_2, +}; + enum // Module type { FRAME_PROCESSING_MODULE, @@ -66,6 +73,7 @@ class PlaYUVerModuleIf { public: + Int m_iModuleAPI; Int m_iModuleType; const Char* m_pchModuleCategory; const Char* m_pchModuleName; @@ -77,6 +85,7 @@ public: PlaYUVerModuleIf() { + m_iModuleAPI = MODULE_API_1; } virtual ~PlaYUVerModuleIf() { @@ -90,7 +99,9 @@ public: virtual Void create( PlaYUVerFrame* ) { } - + virtual Bool create( std::vector apcFrameList ) + { + } virtual PlaYUVerFrame* process( PlaYUVerFrame* ) { return NULL; @@ -99,7 +110,7 @@ public: { return NULL; } - virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) + virtual PlaYUVerFrame* process( std::vector ) { return NULL; } @@ -112,7 +123,7 @@ public: { return 0; } - virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame*, PlaYUVerFrame* ) + virtual Double measure( std::vector ) { return 0; } diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 07a8f3b..906aad4 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -178,10 +178,25 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) return 2; } - m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); - m_pcCurrModuleIf->m_cModuleOptions.scanArgv( argc, ( const Char** )argv ); + // Create Module + Bool moduleCreated = false; + std::vector apcFrameList; + for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) + { + apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() ); + } + if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + { + moduleCreated = m_pcCurrModuleIf->create( apcFrameList ); + } + else if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_1 ) + { + m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); + moduleCreated = true; + } + if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { // Check outputs @@ -191,7 +206,15 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) if( outputFileNames.size() == 1 ) { - PlaYUVerFrame* pcModFrame = applyFrameModule(); + PlaYUVerFrame* pcModFrame; + if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + { + pcModFrame = m_pcCurrModuleIf->process( apcFrameList ); + } + else + { + pcModFrame = applyFrameModule(); + } PlaYUVerStream* pcModStream = new PlaYUVerStream; if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), 8, 1, false ) ) { @@ -301,10 +324,6 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() case MODULE_REQUIRES_TWO_FRAMES: pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); break; - case MODULE_REQUIRES_THREE_FRAMES: - pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame(), - m_apcInputStreams[2]->getCurrFrame() ); - break; } } return pcProcessedFrame; @@ -312,6 +331,7 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() Int PlaYUVerTools::ModuleOperation() { + std::vector apcFrameList; m_cCmdLineHandler.log( CommandLineHandle::INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); PlaYUVerFrame* pcProcessedFrame = NULL; @@ -326,26 +346,40 @@ Int PlaYUVerTools::ModuleOperation() for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - + apcFrameList.clear(); + for( UInt i = 0; i < m_pcCurrModuleIf->m_uiNumberOfFrames; i++ ) + { + apcFrameList.push_back( m_apcInputStreams[i]->getCurrFrame() ); + } if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { - pcProcessedFrame = applyFrameModule(); + if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) + { + pcProcessedFrame = m_pcCurrModuleIf->process( apcFrameList ); + } + else + { + pcProcessedFrame = applyFrameModule(); + } m_apcOutputStreams[0]->writeFrame( pcProcessedFrame ); } else if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { - switch( m_pcCurrModuleIf->m_uiNumberOfFrames ) + if( m_pcCurrModuleIf->m_iModuleAPI == MODULE_API_2 ) { - case MODULE_REQUIRES_ONE_FRAME: - dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); - break; - case MODULE_REQUIRES_THREE_FRAMES: - dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame(), - m_apcInputStreams[2]->getCurrFrame() ); - break; + dMeasurementResult = m_pcCurrModuleIf->measure( apcFrameList ); + } + else + { + switch( m_pcCurrModuleIf->m_uiNumberOfFrames ) + { + case MODULE_REQUIRES_ONE_FRAME: + dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); + break; + case MODULE_REQUIRES_TWO_FRAMES: + dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); + break; + } } m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %8.3f \n", dMeasurementResult ); From 95c35373f4f7d11dece6ffda79eb98c716764206 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:34:40 +0100 Subject: [PATCH 60/94] Add full frame difference with plus 1 bit precision --- app/PlaYUVerAppModuleIf.cpp | 20 ++------------------ lib/PlaYUVerFrame.cpp | 11 +++++++---- modules/FrameDifference.cpp | 20 ++++++++++++-------- modules/FrameDifference.h | 7 ++++--- modules/PlaYUVerModuleIf.h | 10 +--------- tools/PlaYUVerTools.cpp | 20 ++------------------ 6 files changed, 28 insertions(+), 60 deletions(-) diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index 37ab439..9428850 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -65,15 +65,7 @@ void PlaYUVerAppModuleIf::run() } else { - switch( m_pcModule->m_uiNumberOfFrames ) - { - case MODULE_REQUIRES_ONE_FRAME: - m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); - break; - } + m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() ); } } else if( m_pcModule->m_iModuleType == FRAME_MEASUREMENT_MODULE ) @@ -84,15 +76,7 @@ void PlaYUVerAppModuleIf::run() } else { - switch( m_pcModule->m_uiNumberOfFrames ) - { - case MODULE_REQUIRES_ONE_FRAME: - m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); - break; - } + m_dMeasurementResult = m_pcModule->measure( m_pcSubWindow[0]->getCurrFrame() ); } } else diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 25f7a9f..4a85f15 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -345,15 +345,19 @@ Void PlaYUVerFrame::fillRGBBuffer() if( m_bHasRGBPel ) return; Int iR, iG, iB; + Int shiftBits = m_iBitsPel - 8; UInt* pARGB = ( UInt* )m_pcARGB32; if( m_pcPelFormat->colorSpace == COLOR_GRAY ) { Pel* pY = m_pppcInputPel[LUMA][0]; + Int iY; for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) { - iR = *pY; - iG = *pY; - iB = *pY++; + iY = *pY++; + iY >>= shiftBits; + iR = iY; + iG = iY; + iB = iY; *pARGB++ = PEL_RGB( iR, iG, iB ); } } @@ -373,7 +377,6 @@ Void PlaYUVerFrame::fillRGBBuffer() } else if( m_pcPelFormat->colorSpace == COLOR_YUV ) { - Int shiftBits = m_iBitsPel - 8; Pel* pLineY = m_pppcInputPel[LUMA][0]; Pel* pLineU = m_pppcInputPel[CHROMA_U][0]; Pel* pLineV = m_pppcInputPel[CHROMA_V][0]; diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index 719b173..f11ebe3 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -31,6 +31,7 @@ namespace plaYUVer FrameDifference::FrameDifference() { /* Module Definition */ + m_iModuleAPI = MODULE_API_2; m_iModuleType = FRAME_PROCESSING_MODULE; m_pchModuleCategory = "Measurements"; m_pchModuleName = "FrameDifference"; @@ -41,15 +42,18 @@ FrameDifference::FrameDifference() m_pcFrameDifference = NULL; } -Void FrameDifference::create( PlaYUVerFrame* Input ) +Bool FrameDifference::create( std::vector apcFrameList ) { - m_pcFrameDifference = new PlaYUVerFrame( Input->getWidth(), Input->getHeight(), PlaYUVerFrame::GRAY, Input->getBitsPel() ); + UInt bitsPixel = ( apcFrameList[0]->getBitsPel() + 1 ) & 0x0F; + m_iMaxDiffValue = ( 1 << ( bitsPixel - 1 ) ); + m_pcFrameDifference = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY, bitsPixel ); + return true; } -PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 ) +PlaYUVerFrame* FrameDifference::process( std::vector apcFrameList ) { - Pel* pInput1PelYUV = Input1->getPelBufferYUV()[0][0]; - Pel* pInput2PelYUV = Input2->getPelBufferYUV()[0][0]; + Pel* pInput1PelYUV = apcFrameList[0]->getPelBufferYUV()[0][0]; + Pel* pInput2PelYUV = apcFrameList[1]->getPelBufferYUV()[0][0]; Pel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0]; Int aux_pel_1, aux_pel_2; Int diff = 0; @@ -60,9 +64,9 @@ PlaYUVerFrame* FrameDifference::process( PlaYUVerFrame* Input1, PlaYUVerFrame* I aux_pel_1 = *pInput1PelYUV++; aux_pel_2 = *pInput2PelYUV++; diff = aux_pel_1 - aux_pel_2; - diff = std::min( diff, 127 ); - diff = std::max( diff, -128 ); - diff += 128; + diff = std::min( diff, m_iMaxDiffValue ); + diff = std::max( diff, -m_iMaxDiffValue ); + diff += m_iMaxDiffValue + 1; *pOutputPelYUV++ = diff; } return m_pcFrameDifference; diff --git a/modules/FrameDifference.h b/modules/FrameDifference.h index 93bf9c8..9b01b0c 100644 --- a/modules/FrameDifference.h +++ b/modules/FrameDifference.h @@ -34,9 +34,10 @@ namespace plaYUVer class FrameDifference: public PlaYUVerModuleIf { - REGISTER_CLASS_FACTORY( FrameDifference ) +REGISTER_CLASS_FACTORY( FrameDifference ) private: + Int m_iMaxDiffValue; PlaYUVerFrame* m_pcFrameDifference; public: @@ -44,8 +45,8 @@ public: virtual ~FrameDifference() { } - Void create( PlaYUVerFrame* Input ); - PlaYUVerFrame* process( PlaYUVerFrame* Input1, PlaYUVerFrame* Input2 ); + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); Void destroy(); }; diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index b6e31d1..81b4dcd 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -101,28 +101,20 @@ public: } virtual Bool create( std::vector apcFrameList ) { + return false; } virtual PlaYUVerFrame* process( PlaYUVerFrame* ) { return NULL; } - virtual PlaYUVerFrame* process( PlaYUVerFrame*, PlaYUVerFrame* ) - { - return NULL; - } virtual PlaYUVerFrame* process( std::vector ) { return NULL; } - virtual Double measure( PlaYUVerFrame* ) { return 0; } - virtual Double measure( PlaYUVerFrame*, PlaYUVerFrame* ) - { - return 0; - } virtual Double measure( std::vector ) { return 0; diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 906aad4..64110a4 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -316,15 +316,7 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() PlaYUVerFrame* pcProcessedFrame = NULL; if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { - switch( m_pcCurrModuleIf->m_uiNumberOfFrames ) - { - case MODULE_REQUIRES_ONE_FRAME: - pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); - break; - } + pcProcessedFrame = m_pcCurrModuleIf->process( m_apcInputStreams[0]->getCurrFrame() ); } return pcProcessedFrame; } @@ -371,15 +363,7 @@ Int PlaYUVerTools::ModuleOperation() } else { - switch( m_pcCurrModuleIf->m_uiNumberOfFrames ) - { - case MODULE_REQUIRES_ONE_FRAME: - dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame(), m_apcInputStreams[1]->getCurrFrame() ); - break; - } + dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); } m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %8.3f \n", dMeasurementResult ); From d3e27c10b8d4dd7466ca1fd64157183baf216c3b Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:40:50 +0100 Subject: [PATCH 61/94] Fix frame to ARGB from GRAY when bpp is different than 8 --- lib/PlaYUVerFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 4a85f15..da0c4eb 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -372,7 +372,7 @@ Void PlaYUVerFrame::fillRGBBuffer() iR = *pR++; iG = *pG++; iB = *pB++; - *pARGB++ = PEL_RGB( iR, iG, iB ); + *pARGB++ = PEL_RGB( ( iR >> shiftBits ), ( iG >> shiftBits ), ( iB >> shiftBits ) ); } } else if( m_pcPelFormat->colorSpace == COLOR_YUV ) From de1606e30252e53dcc00881715cf583ad67a5ba6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:45:02 +0100 Subject: [PATCH 62/94] Fix frame to ARGB from GRAY when bpp is different than 8 --- lib/PlaYUVerFrame.cpp | 2 +- lib/PlaYUVerStream.cpp | 8 ++++++++ lib/PlaYUVerStream.h | 16 +++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index da0c4eb..040ce69 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -187,7 +187,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_uiHeight = height; m_iPixelFormat = pel_format; m_iNumberChannels = 3; - m_iBitsPel = bitsPixel; + m_iBitsPel = bitsPixel > 8 ? bitsPixel : 8; if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 ) { diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 70225b5..e6c4dc1 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -371,6 +371,14 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in return m_bInit; } + if( m_pcCurrFrame ) + { + m_uiWidth = m_pcCurrFrame->getWidth(); + m_uiHeight = m_pcCurrFrame->getHeight(); + m_iPixelFormat = m_pcCurrFrame->getPelFormat(); + m_uiBitsPerPixel = m_pcCurrFrame->getBitsPel(); + } + m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); m_iCurrFrameNum = -1; diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index fc99d9a..6736c55 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -77,13 +77,17 @@ private: std::string m_cCodedName; std::string m_cPelFmtName; - FILE* m_pFile; /**< The input file pointer >*/ - std::fstream m_fsIOStream; /**< The input file pointer >*/ - Int m_iFileFormat; + UInt m_uiWidth; + UInt m_uiHeight; Int m_iPixelFormat; UInt m_uiBitsPerPixel; + Double m_dFrameRate; + UInt64 m_uiTotalFrameNum; + Int64 m_iCurrFrameNum; + FILE* m_pFile; /**< The input file pointer >*/ + std::fstream m_fsIOStream; /**< The input file pointer >*/ Byte* m_pStreamBuffer; UInt m_uiFrameBufferSize; @@ -93,12 +97,6 @@ private: UInt m_uiFrameBufferIndex; UInt64 m_uiCurrFrameFileIdx; - UInt m_uiWidth; - UInt m_uiHeight; - Double m_dFrameRate; - UInt64 m_uiTotalFrameNum; - Int64 m_iCurrFrameNum; - public: static std::vector supportedReadFormatsExt(); From 155d54d3bd458704702df9289b741de40ca513ae Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 00:51:27 +0100 Subject: [PATCH 63/94] Add a macro to perform basic verification to frame input list of modules --- modules/AbsoluteFrameDifference.cpp | 1 + modules/DisparityStereoVar.cpp | 1 + modules/FrameDifference.cpp | 1 + modules/PlaYUVerModuleIf.h | 15 +++++++++++++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/AbsoluteFrameDifference.cpp b/modules/AbsoluteFrameDifference.cpp index 46130b0..5dac1ac 100644 --- a/modules/AbsoluteFrameDifference.cpp +++ b/modules/AbsoluteFrameDifference.cpp @@ -43,6 +43,7 @@ AbsoluteFrameDifference::AbsoluteFrameDifference() Bool AbsoluteFrameDifference::create( std::vector apcFrameList ) { + _BASIC_MODULE_API_2_CHECK_ m_pcFrameDifference = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); return true; } diff --git a/modules/DisparityStereoVar.cpp b/modules/DisparityStereoVar.cpp index 424cdf9..907787e 100644 --- a/modules/DisparityStereoVar.cpp +++ b/modules/DisparityStereoVar.cpp @@ -57,6 +57,7 @@ DisparityStereoVar::DisparityStereoVar() Bool DisparityStereoVar::create( std::vector apcFrameList ) { + _BASIC_MODULE_API_2_CHECK_ m_pcDisparityFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); m_cStereoVar.minDisp = -( ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16 ); return true; diff --git a/modules/FrameDifference.cpp b/modules/FrameDifference.cpp index f11ebe3..b524811 100644 --- a/modules/FrameDifference.cpp +++ b/modules/FrameDifference.cpp @@ -44,6 +44,7 @@ FrameDifference::FrameDifference() Bool FrameDifference::create( std::vector apcFrameList ) { + _BASIC_MODULE_API_2_CHECK_ UInt bitsPixel = ( apcFrameList[0]->getBitsPel() + 1 ) & 0x0F; m_iMaxDiffValue = ( 1 << ( bitsPixel - 1 ) ); m_pcFrameDifference = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY, bitsPixel ); diff --git a/modules/PlaYUVerModuleIf.h b/modules/PlaYUVerModuleIf.h index 81b4dcd..f6e85a6 100644 --- a/modules/PlaYUVerModuleIf.h +++ b/modules/PlaYUVerModuleIf.h @@ -39,6 +39,13 @@ public: \ static PlaYUVerModuleIf* Create() { return new X(); } \ void Delete() { delete this; } +#define _BASIC_MODULE_API_2_CHECK_ \ +if( apcFrameList.size() != m_uiNumberOfFrames ) \ + return false; \ +for( UInt i = 0; i < apcFrameList.size(); i++ ) \ + if( !apcFrameList[i] ) \ + return false; + enum // Module API { MODULE_API_1, @@ -57,8 +64,11 @@ enum // Module type enum Module_NumberOfFrames { MODULE_REQUIRES_ONE_FRAME = 1, - MODULE_REQUIRES_TWO_FRAMES = 2, - MODULE_REQUIRES_THREE_FRAMES = 3, + MODULE_REQUIRES_TWO_FRAMES, + MODULE_REQUIRES_THREE_FRAMES, + MODULE_REQUIRES_FOUR_FRAMES, + MODULE_REQUIRES_FIVE_FRAMES, + MODULE_REQUIRES_SIX_FRAMES, }; enum Module_Requirements @@ -86,6 +96,7 @@ public: PlaYUVerModuleIf() { m_iModuleAPI = MODULE_API_1; + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; } virtual ~PlaYUVerModuleIf() { From 1cb6fed13513a20e3812cacc0d398b2a4f98b17f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 6 Apr 2015 21:52:00 +0100 Subject: [PATCH 64/94] Add EightBitsSampling module --- modules/CMakeLists.txt | 1 + modules/EightBitsSampling.cpp | 86 +++++++++++++++++++++++++++++++ modules/EightBitsSampling.h | 53 +++++++++++++++++++ modules/PlaYUVerModuleFactory.cpp | 1 + 4 files changed, 141 insertions(+) create mode 100644 modules/EightBitsSampling.cpp create mode 100644 modules/EightBitsSampling.h diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index b297cdd..20d0b75 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -38,6 +38,7 @@ ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) ADD_MODULE( FrameBinarization "FrameBinarization" ) +ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) IF( USE_OPENCV ) diff --git a/modules/EightBitsSampling.cpp b/modules/EightBitsSampling.cpp new file mode 100644 index 0000000..4ed2f20 --- /dev/null +++ b/modules/EightBitsSampling.cpp @@ -0,0 +1,86 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file EightBitsSampling.cpp + * \brief Binarize frame module + */ + +#include "EightBitsSampling.h" + +namespace plaYUVer +{ + +EightBitsSampling::EightBitsSampling() +{ + /* Module Definition */ + m_iModuleAPI = MODULE_API_2; + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Conversions"; + m_pchModuleName = "EightBitsSampling"; + m_pchModuleTooltip = "Sub-sampling frame to 8bpp"; + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + + m_pcSubSampledFrame = NULL; +} + +Bool EightBitsSampling::create( std::vector apcFrameList ) +{ + if( apcFrameList[0]->getBitsPel() > 8 ) + { + m_pcSubSampledFrame = NULL; + m_pcSubSampledFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(), 8 ); + return true; + } + return false; +} + +PlaYUVerFrame* EightBitsSampling::process( std::vector apcFrameList ) +{ + PlaYUVerFrame* pcFrame = apcFrameList[0]; + UInt uiShiftBits = pcFrame->getBitsPel() - 8; + Pel* pPelInput = pcFrame->getPelBufferYUV()[0][0]; + Pel* pPelSubSampled = m_pcSubSampledFrame->getPelBufferYUV()[0][0]; + Pel pelValue; + + for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) + { + pelValue = *pPelInput++; + pelValue = pelValue >> uiShiftBits; + *pPelSubSampled++ = pelValue; + } + for( UInt i = 0; i < pcFrame->getChromaLength() * 2; i++ ) + { + pelValue = *pPelInput++; + pelValue = pelValue >> uiShiftBits; + *pPelSubSampled++ = pelValue; + } + return m_pcSubSampledFrame; +} + +Void EightBitsSampling::destroy() +{ + if( m_pcSubSampledFrame ) + delete m_pcSubSampledFrame; + m_pcSubSampledFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/EightBitsSampling.h b/modules/EightBitsSampling.h new file mode 100644 index 0000000..98045b6 --- /dev/null +++ b/modules/EightBitsSampling.h @@ -0,0 +1,53 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file EightBitsSampling.h + * \brief Binarize frame module + */ + +#ifndef __EIGHTBITSSAMPLING_H__ +#define __EIGHTBITSSAMPLING_H__ + +#include "PlaYUVerModuleIf.h" + +namespace plaYUVer +{ + +class EightBitsSampling: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( EightBitsSampling ) + +private: + PlaYUVerFrame* m_pcSubSampledFrame; +public: + EightBitsSampling(); + virtual ~EightBitsSampling() + { + } + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __EIGHTBITSSAMPLING_H__ + diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 3716716..eb63928 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -40,6 +40,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create ); Register( "FrameCrop", &FrameCrop::Create ); Register( "FrameBinarization", &FrameBinarization::Create ); + Register( "EightBitsSampling", &EightBitsSampling::Create ); Register( "LumaAverage", &LumaAverage::Create ); #ifdef USE_OPENCV Register( "DisparityStereoVar", &DisparityStereoVar::Create ); From 67173911158307238dd936699cea598b02b00ff4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 00:55:26 +0100 Subject: [PATCH 65/94] Disable resize of some dialogs --- app/ConfigureFormatDialog.cpp | 2 ++ app/DialogSubWindowSelector.cpp | 3 +++ app/ModulesHandleOptDialog.cpp | 22 ++++++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index d16d6c0..ceccaf8 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -232,6 +232,8 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : m_comboBoxColorSpace->setCurrentIndex( 0 ); + setFixedSize( MainLayout->sizeHint() ); + } Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate ) diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index 3d6fe20..d340242 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -99,6 +99,9 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWi } update(); + + setFixedSize( mainLayout->sizeHint() ); + } Void DialogSubWindowSelector::updateSubWindowList() diff --git a/app/ModulesHandleOptDialog.cpp b/app/ModulesHandleOptDialog.cpp index 868cb3f..17e3ad3 100644 --- a/app/ModulesHandleOptDialog.cpp +++ b/app/ModulesHandleOptDialog.cpp @@ -36,19 +36,19 @@ namespace plaYUVer class OpionConfiguration: public QWidget { public: - OpionConfiguration( QWidget *parent, OptionBase* option ) : - QWidget( parent ) + OpionConfiguration( OptionBase* option ) { m_cName = option->opt_string; - m_pcDescription = new QLabel( this ); + m_pcDescription = new QLabel; m_pcDescription->setText( QString::fromStdString( option->opt_desc ) ); - m_pcValue = new QLineEdit( this ); + m_pcValue = new QLineEdit; m_pcValue->setMinimumWidth( 40 ); m_pcValue->setMaximumWidth( 65 ); - QHBoxLayout* layout = new QHBoxLayout( this ); + QHBoxLayout* layout = new QHBoxLayout; layout->addWidget( m_pcDescription, Qt::AlignLeft ); layout->addWidget( m_pcValue, Qt::AlignRight ); layout->setContentsMargins( 1, 1, 1, 1 ); + setLayout( layout ); } const QString getValue() const { @@ -74,14 +74,13 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu const Options::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList(); - QVBoxLayout* mainLayout = new QVBoxLayout( this ); - + QVBoxLayout* optionsLayout = new QVBoxLayout; OpionConfiguration* pcOption; for( Options::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it ) { - pcOption = new OpionConfiguration( this, ( *it )->opt ); + pcOption = new OpionConfiguration( ( *it )->opt ); m_apcOptionList.append( pcOption ); - mainLayout->addWidget( pcOption ); + optionsLayout->addWidget( pcOption ); } QDialogButtonBox* dialogButtonOkCancel = new QDialogButtonBox(); @@ -89,9 +88,12 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget *parent, PlaYUVerAppModu dialogButtonOkCancel->setStandardButtons( QDialogButtonBox::Cancel | QDialogButtonBox::Ok ); dialogButtonOkCancel->setCenterButtons( false ); + QVBoxLayout* mainLayout = new QVBoxLayout; + mainLayout->addItem( optionsLayout ); mainLayout->addWidget( dialogButtonOkCancel ); + setLayout( mainLayout ); - setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + setFixedSize( mainLayout->sizeHint() ); connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); From 32b27e48210a2db89cdd04bba309255d9798084d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:38:58 +0100 Subject: [PATCH 66/94] Improve ConfigureFormatDialog --- app/ConfigureFormatDialog.cpp | 44 +++++++++++++++++++++++++++-------- app/ConfigureFormatDialog.h | 3 ++- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index ceccaf8..8fdcdfd 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -114,14 +114,14 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : QLabel* widthLabel = new QLabel( "Width" ); widthLabel->setFont( normalFont ); m_spinBoxWidth = new QSpinBox(); - m_spinBoxWidth->setRange( 0, 9999 ); + m_spinBoxWidth->setRange( 0, 99999 ); m_spinBoxWidth->setValue( 0 ); m_spinBoxWidth->setFont( normalFont ); QLabel* heightLabel = new QLabel( "Height" ); heightLabel->setFont( normalFont ); m_spinBoxheight = new QSpinBox(); - m_spinBoxheight->setRange( 0, 9999 ); + m_spinBoxheight->setRange( 0, 99999 ); m_spinBoxheight->setValue( 0 ); m_spinBoxheight->setFont( normalFont ); @@ -225,7 +225,10 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); MainLayout->addWidget( dialogButtonOkCancel ); - connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( StandardResolutionSelection() ) ); + connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotStandardResolutionSelected(int) ) ); + connect( m_spinBoxWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) ); + connect( m_spinBoxheight, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) ); + connect( m_comboBoxColorSpace, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotColorSpaceChange(int) ) ); connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) ); @@ -271,6 +274,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) ) { m_comboBoxStandardResolution->setCurrentIndex( i ); + break; } } if( exec() == QDialog::Rejected ) @@ -287,6 +291,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi if( pelFmtName == PlaYUVerFrame::supportedPixelFormatListNames()[i] ) { rInputFormat = i; + break; } } rBits = m_spinBoxBits->value(); @@ -294,15 +299,34 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi return QDialog::Accepted; } -void ConfigureFormatDialog::StandardResolutionSelection() +void ConfigureFormatDialog::slotStandardResolutionSelected( Int idx ) { - Int currIdx = m_comboBoxStandardResolution->currentIndex(); - if( currIdx == -1 ) - return; + if( idx >= 0 ) + { + QSize currSize = standardResolutionSizes.at( idx ); + m_spinBoxWidth->blockSignals( true ); + m_spinBoxWidth->setValue( currSize.width() ); + m_spinBoxWidth->blockSignals( false ); + m_spinBoxheight->blockSignals( true ); + m_spinBoxheight->setValue( currSize.height() ); + m_spinBoxheight->blockSignals( false ); + } +} - QSize currSize = standardResolutionSizes.at( currIdx ); - m_spinBoxWidth->setValue( currSize.width() ); - m_spinBoxheight->setValue( currSize.height() ); +void ConfigureFormatDialog::slotResolutionChange() +{ + m_comboBoxStandardResolution->blockSignals( true ); + Int newIdx = -1; + for( Int i = 0; i < standardResolutionSizes.size(); i++ ) + { + if( standardResolutionSizes.at( i ) == QSize( m_spinBoxWidth->value(), m_spinBoxheight->value() ) ) + { + newIdx = i; + break; + } + } + m_comboBoxStandardResolution->setCurrentIndex( newIdx ); + m_comboBoxStandardResolution->blockSignals( false ); } Void ConfigureFormatDialog::slotColorSpaceChange( Int idx ) diff --git a/app/ConfigureFormatDialog.h b/app/ConfigureFormatDialog.h index b4c3e5d..fe74524 100644 --- a/app/ConfigureFormatDialog.h +++ b/app/ConfigureFormatDialog.h @@ -53,7 +53,8 @@ public: Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate ); private Q_SLOTS: - void StandardResolutionSelection(); + void slotStandardResolutionSelected( int ); + void slotResolutionChange(); void slotColorSpaceChange( int ); private: From e271fe502261474c58e5ee09197458fc4a8b6199 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:39:13 +0100 Subject: [PATCH 67/94] Format code --- app/ViewArea.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/ViewArea.h b/app/ViewArea.h index de6f10f..dafec9f 100644 --- a/app/ViewArea.h +++ b/app/ViewArea.h @@ -51,7 +51,8 @@ public: enum ViewMode { - NormalMode, MaskMode, + NormalMode, + MaskMode, }; typedef enum { @@ -60,7 +61,7 @@ public: BlockSelectionTool, MaskTool, EraserTool - }eTool; + } eTool; ViewArea( QWidget *parent = 0 ); @@ -116,7 +117,7 @@ public: PlaYUVerStream* getInputStream(); // Scale function. Return used scale value (it may change when it touches the min or max zoom value) - Double scaleZoomFactor(Double scale, QPoint center, QSize minimumSize); + Double scaleZoomFactor( Double scale, QPoint center, QSize minimumSize ); void setTool( eTool tool ); @@ -126,7 +127,7 @@ Q_SIGNALS: void selectionChanged( const QRect &rect ); void positionChanged( const QPoint &pos ); void scrollBarMoved( QPoint offset ); - void zoomFactorChanged_byWheel( const double factor , const QPoint center); + void zoomFactorChanged_byWheel( const double factor, const QPoint center ); public Q_SLOTS: void setNormalMode(); @@ -163,7 +164,7 @@ private: QRect viewToWindow( const QRect& rc ) const; PlaYUVerFrame *m_pcCurrFrame; - UInt m_uiPixelHalfScale; + Pel m_uiPixelHalfScale; QPixmap m_pixmap; QBitmap m_mask; QRect m_selectedArea; @@ -186,6 +187,6 @@ private: }; -} // NameSpace plaYUVer +} // NameSpace plaYUVer #endif // __VIEWAREA_H__ From 76a216bd3acb68f30271de20cadb2e98ffcb34e6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:40:04 +0100 Subject: [PATCH 68/94] Fix opencv conversion problems in PlaYUVerFrame --- lib/LibOpenCVHandler.cpp | 70 +------------------------------ lib/LibOpenCVHandler.h | 2 - lib/PlaYUVerFrame.cpp | 75 ++++++++++++++++++++-------------- lib/PlaYUVerFrame.h | 8 +++- lib/PlaYUVerStream.cpp | 17 ++++---- modules/DisparityStereoVar.cpp | 8 ++-- tools/PlaYUVerTools.cpp | 5 +++ 7 files changed, 69 insertions(+), 116 deletions(-) diff --git a/lib/LibOpenCVHandler.cpp b/lib/LibOpenCVHandler.cpp index cb8e9da..a28516b 100644 --- a/lib/LibOpenCVHandler.cpp +++ b/lib/LibOpenCVHandler.cpp @@ -76,79 +76,13 @@ std::vector LibOpenCVHandler::supportedSaveFormatsName() PlaYUVerFrame* LibOpenCVHandler::loadFrame( std::string filename ) { - cv::Mat pcCvFrame = cv::imread( filename ); - Int cvChannels = pcCvFrame.channels(); - std::string pelFormatName; - Int iPelFormat = -1; - switch( cvChannels ) - { - case 1: - pelFormatName = "GRAY"; - break; - case 3: - pelFormatName = "BRG24"; - break; - default: - return NULL; - } - - for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) - { - if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == pelFormatName ) - { - iPelFormat = i; - break; - } - } - - if( iPelFormat >= 0 ) - { - PlaYUVerFrame* pcFrame = new PlaYUVerFrame( pcCvFrame.cols, pcCvFrame.rows, iPelFormat ); - pcFrame->frameFromBuffer( pcCvFrame.ptr(), pcFrame->getBytesPerFrame() ); - return pcFrame; - } return NULL; } Bool LibOpenCVHandler::saveFrame( PlaYUVerFrame* pcFrame, std::string filename ) { - Int cvType = CV_8UC3; - switch( pcFrame->getNumberChannels() ) - { - case 3: - cvType = CV_8UC3; - break; - case 1: - cvType = CV_8UC1; - break; - default: - return false; - break; - } - - cv::Mat pcCvFrame( pcFrame->getHeight(), pcFrame->getWidth(), cvType ); - UChar* pCvPel = pcCvFrame.data; - if( pcFrame->getColorSpace() != PlaYUVerFrame::COLOR_GRAY ) - { - UChar* pARGB = pcFrame->getRGBBuffer(); - for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) - { - *pCvPel++ = *pARGB++; - *pCvPel++ = *pARGB++; - *pCvPel++ = *pARGB++; - pARGB++; - } - } - if( pcFrame->getColorSpace() == PlaYUVerFrame::COLOR_GRAY ) - { - - Pel* pPel = pcFrame->getPelBufferYUV()[LUMA][0]; - for( UInt i = 0; i < pcFrame->getHeight() * pcFrame->getWidth(); i++ ) - { - *pCvPel++ = *pPel++; - } - } - return cv::imwrite( filename, pcCvFrame ); + cv::Mat* pcCvFrame = pcFrame->getCvMat(); + return cv::imwrite( filename, *pcCvFrame ); } } // NAMESPACE diff --git a/lib/LibOpenCVHandler.h b/lib/LibOpenCVHandler.h index c310068..257ba5e 100644 --- a/lib/LibOpenCVHandler.h +++ b/lib/LibOpenCVHandler.h @@ -55,8 +55,6 @@ public: static PlaYUVerFrame* loadFrame( std::string filename ); static Bool saveFrame( PlaYUVerFrame* pcFrame, std::string filename ); -private: - std::string m_cFilename; }; } // NAMESPACE diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 040ce69..9e45dd7 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -521,47 +521,59 @@ Void PlaYUVerFrame::FrametoRGB8Pixfc() #endif } -Void PlaYUVerFrame::getCvMat( Void** ppCvFrame ) +cv::Mat* PlaYUVerFrame::getCvMat( Bool convertToGray ) { #ifdef USE_OPENCV - Int cvType = CV_8UC3; - switch( m_pcPelFormat->numberChannels ) + if( convertToGray && !( m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_YUV || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_GRAY ) ) { - case 3: - cvType = CV_8UC4; - break; - case 1: - cvType = CV_8UC1; - break; - default: - break; + return NULL; } + Int cvType = CV_MAKETYPE( CV_8U, convertToGray ? 1 : m_pcPelFormat->numberChannels ); cv::Mat *pcCvFrame = new cv::Mat( m_uiHeight, m_uiWidth, cvType ); - if( m_pcPelFormat->colorSpace != PlaYUVerFrame::COLOR_GRAY ) + UChar* pCvPel = pcCvFrame->data; + if( !convertToGray && ( m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_YUV || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_RGB ) ) { fillRGBBuffer(); - memcpy( pcCvFrame->data, m_pcARGB32, m_uiWidth * m_uiHeight * 4 * sizeof(UChar) ); + UChar* pARGB = m_pcARGB32; + for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ ) + { + *pCvPel++ = *pARGB++; + *pCvPel++ = *pARGB++; + *pCvPel++ = *pARGB++; + pARGB++; + } + } + else if( convertToGray || m_pcPelFormat->colorSpace == PlaYUVerFrame::COLOR_GRAY ) + { + Pel* pPel = m_pppcInputPel[LUMA][0]; + for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ ) + { + *pCvPel++ = *pPel++; + } } else { - memcpy( pcCvFrame->data, &( m_pppcInputPel[LUMA][0][0] ), m_uiWidth * m_uiHeight * sizeof(Pel) ); + if( pcCvFrame ) + delete pcCvFrame; + pcCvFrame = NULL; } - *ppCvFrame = pcCvFrame; + return pcCvFrame; +#else + return NULL; #endif } -Void PlaYUVerFrame::fromCvMat( Void* voidFrame ) +Void PlaYUVerFrame::fromCvMat( cv::Mat* pcCvFrame ) { #ifdef USE_OPENCV - cv::Mat* opencvFrame = ( cv::Mat* )voidFrame; if( m_iPixelFormat == NO_FMT ) { - switch( opencvFrame->channels() ) + switch( pcCvFrame->channels() ) { case 1: m_iPixelFormat = GRAY; break; - case 4: + case 3: m_iPixelFormat = RGB24; break; default: @@ -571,31 +583,32 @@ Void PlaYUVerFrame::fromCvMat( Void* voidFrame ) if( !isValid() ) { - init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat, 8 ); + init( pcCvFrame->cols, pcCvFrame->rows, m_iPixelFormat, 8 ); } m_bHasRGBPel = false; m_bHasHistogram = false; + UChar* pCvPel = pcCvFrame->data; if( m_iPixelFormat != GRAY ) { - Pel* pInputPelY = m_pppcInputPel[LUMA][0]; - Pel* pInputPelU = m_pppcInputPel[CHROMA_U][0]; - Pel* pInputPelV = m_pppcInputPel[CHROMA_V][0]; - UChar* pcRGBPelInterlaced = m_pcARGB32; - memcpy( pcRGBPelInterlaced, opencvFrame->data, m_uiWidth * m_uiHeight * 4 * sizeof(Pel) ); - UInt* buff = ( UInt* )pcRGBPelInterlaced; + Pel* pInputPelR = m_pppcInputPel[COLOR_R][0]; + Pel* pInputPelG = m_pppcInputPel[COLOR_G][0]; + Pel* pInputPelB = m_pppcInputPel[COLOR_B][0]; for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) { - *pInputPelY++ = pelRed( *buff ); - *pInputPelU++ = pelGreen( *buff ); - *pInputPelV++ = pelBlue( *buff++ ); + *pInputPelR++ = pelRed( *pCvPel++ ); + *pInputPelG++ = pelGreen( *pCvPel++ ); + *pInputPelB++ = pelBlue( *pCvPel++ ); } - m_bHasRGBPel = true; } else { - memcpy( m_pppcInputPel[LUMA][0], opencvFrame->data, m_uiWidth * m_uiHeight * sizeof(Pel) ); + Pel* pPel = m_pppcInputPel[LUMA][0]; + for( UInt i = 0; i < m_uiWidth * m_uiHeight; i++ ) + { + *pPel++ = *pCvPel++; + } } #endif } diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 77ee887..dd7b7c5 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -34,6 +34,10 @@ #include "PlaYUVerFrameStats.h" class PixFcSSE; +namespace cv +{ +class Mat; +} namespace plaYUVer { @@ -286,8 +290,8 @@ public: /** * Interface with OpenCV lib */ - Void getCvMat( Void** ); - Void fromCvMat( Void* ); + cv::Mat* getCvMat( Bool convertToGray = false ); + Void fromCvMat( cv::Mat* ); /** * @defgroup PlaYUVerLib_QualityMetrics Quality Metrics Interface diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index e6c4dc1..f3aa7f8 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -46,10 +46,10 @@ std::vector PlaYUVerStream::supportedReadFormatsExt() std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsExt(); formatsExt.insert( formatsExt.end(), libAvFmt.begin(), libAvFmt.end() ); #endif -#ifdef USE_OPENCV - std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsExt(); - formatsExt.insert( formatsExt.end(), opencvFmt.begin(), opencvFmt.end() ); -#endif +//#ifdef USE_OPENCV +// std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsExt(); +// formatsExt.insert( formatsExt.end(), opencvFmt.begin(), opencvFmt.end() ); +//#endif return formatsExt; } @@ -61,10 +61,10 @@ std::vector PlaYUVerStream::supportedReadFormatsName() std::vector libAvFmt = LibAvContextHandle::supportedReadFormatsName(); formatsName.insert( formatsName.end(), libAvFmt.begin(), libAvFmt.end() ); #endif -#ifdef USE_OPENCV - std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsName(); - formatsName.insert( formatsName.end(), opencvFmt.begin(), opencvFmt.end() ); -#endif +//#ifdef USE_OPENCV +// std::vector opencvFmt = LibOpenCVHandler::supportedReadFormatsName(); +// formatsName.insert( formatsName.end(), opencvFmt.begin(), opencvFmt.end() ); +//#endif return formatsName; } @@ -143,6 +143,7 @@ PlaYUVerStream::PlaYUVerStream() m_uiTotalFrameNum = 0; m_iCurrFrameNum = -1; m_iPixelFormat = -1; + m_uiBitsPerPixel = 8; m_dFrameRate = 30; m_iFileFormat = -1; m_pStreamBuffer = NULL; diff --git a/modules/DisparityStereoVar.cpp b/modules/DisparityStereoVar.cpp index 907787e..6099935 100644 --- a/modules/DisparityStereoVar.cpp +++ b/modules/DisparityStereoVar.cpp @@ -67,16 +67,14 @@ PlaYUVerFrame* DisparityStereoVar::process( std::vector apcFrame PlaYUVerFrame* InputLeft = apcFrameList[0]; PlaYUVerFrame* InputRight = apcFrameList[1]; - cv::Mat* leftImage; - InputLeft->getCvMat( ( Void** )&leftImage ); - cv::Mat* rightImage; - InputRight->getCvMat( ( Void** )&rightImage ); + cv::Mat* leftImage = InputLeft->getCvMat(); + cv::Mat* rightImage = InputRight->getCvMat(); cv::Mat disparityImage, disparityImage8; m_cStereoVar( *leftImage, *rightImage, disparityImage ); disparityImage.convertTo( disparityImage8, CV_8U ); - m_pcDisparityFrame->fromCvMat( ( Void* )&disparityImage8 ); + m_pcDisparityFrame->fromCvMat( &disparityImage8 ); return m_pcDisparityFrame; } diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 64110a4..547561b 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -196,6 +196,11 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) m_pcCurrModuleIf->create( m_apcInputStreams[0]->getCurrFrame() ); moduleCreated = true; } + if( !moduleCreated ) + { + m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Module is not supported with the selected inputs! " ); + return 2; + } if( m_pcCurrModuleIf->m_iModuleType == FRAME_PROCESSING_MODULE ) { From ddea2888e3cebf8aedc16c2226b4f520ee0895ef Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:40:26 +0100 Subject: [PATCH 69/94] Add DisparityStereoBM module --- modules/CMakeLists.txt | 1 + modules/DisparityStereoBM.cpp | 94 +++++++++++++++++++++++++++++++ modules/DisparityStereoBM.h | 58 +++++++++++++++++++ modules/PlaYUVerModuleFactory.cpp | 1 + 4 files changed, 154 insertions(+) create mode 100644 modules/DisparityStereoBM.cpp create mode 100644 modules/DisparityStereoBM.h diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 20d0b75..4167eb6 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -42,6 +42,7 @@ ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) IF( USE_OPENCV ) + ADD_MODULE( DisparityStereoBM "DisparityStereoBM" ) ADD_MODULE( DisparityStereoVar "DisparityStereoVar" ) ENDIF() diff --git a/modules/DisparityStereoBM.cpp b/modules/DisparityStereoBM.cpp new file mode 100644 index 0000000..e950391 --- /dev/null +++ b/modules/DisparityStereoBM.cpp @@ -0,0 +1,94 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file DisparityStereoBM.cpp + * \brief Measure the disparity between two images using the Stereo Var method (OpenCV) + */ + +#include + +#include "DisparityStereoBM.h" + +namespace plaYUVer +{ + +DisparityStereoBM::DisparityStereoBM() +{ + /* Module Definition */ + m_iModuleAPI = MODULE_API_2; + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Disparity"; + m_pchModuleName = "BlockMatching"; + m_pchModuleTooltip = "Measure the disparity between two images using the Stereo BM method (OpenCV)"; + m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES; + m_uiModuleRequirements = MODULE_REQUIRES_SKIP_WHILE_PLAY | MODULE_REQUIRES_NEW_WINDOW | MODULE_REQUIRES_OPTIONS; + + m_cModuleOptions.addOptions()/**/ + ( "block_size", m_cStereoBM.state->SADWindowSize, "Block Size (positive odd number) [9]" ); + + m_pcDisparityFrame = NULL; + + m_cStereoBM.state->preFilterCap = 31; + m_cStereoBM.state->SADWindowSize = 9; + m_cStereoBM.state->minDisparity = 0; + m_cStereoBM.state->textureThreshold = 10; + m_cStereoBM.state->uniquenessRatio = 15; + m_cStereoBM.state->speckleWindowSize = 100; + m_cStereoBM.state->speckleRange = 32; + m_cStereoBM.state->disp12MaxDiff = 1; + +} + +Bool DisparityStereoBM::create( std::vector apcFrameList ) +{ + _BASIC_MODULE_API_2_CHECK_ + m_pcDisparityFrame = new PlaYUVerFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), PlaYUVerFrame::GRAY ); + if( ( m_cStereoBM.state->SADWindowSize % 2 ) == 0 ) + { + m_cStereoBM.state->SADWindowSize++; + } + m_cStereoBM.state->numberOfDisparities = ( ( ( apcFrameList[0]->getWidth() / 8 ) + 15 ) & -16 ); + return true; +} +PlaYUVerFrame* DisparityStereoBM::process( std::vector apcFrameList ) +{ + PlaYUVerFrame* InputLeft = apcFrameList[0]; + PlaYUVerFrame* InputRight = apcFrameList[1]; + + cv::Mat* leftImage = InputLeft->getCvMat( true ); + cv::Mat* rightImage = InputRight->getCvMat( true ); + cv::Mat disparityImage, disparityImage8; + + m_cStereoBM( *leftImage, *rightImage, disparityImage ); + disparityImage.convertTo( disparityImage8, CV_8U ); + + m_pcDisparityFrame->fromCvMat( &disparityImage8 ); + return m_pcDisparityFrame; +} + +Void DisparityStereoBM::destroy() +{ + if( m_pcDisparityFrame ) + delete m_pcDisparityFrame; + m_pcDisparityFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/DisparityStereoBM.h b/modules/DisparityStereoBM.h new file mode 100644 index 0000000..5c40fe6 --- /dev/null +++ b/modules/DisparityStereoBM.h @@ -0,0 +1,58 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file DisparityStereoBM.h + * \brief Measure the disparity between two images using the Stereo Var method (OpenCV) + */ + +#ifndef __DISPARITYSTEREOBM_H__ +#define __DISPARITYSTEREOBM_H__ + +#include +#include "PlaYUVerModuleIf.h" +#include + +#include + +namespace plaYUVer +{ + +class DisparityStereoBM: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( DisparityStereoBM ) + +private: + PlaYUVerFrame* m_pcDisparityFrame; + cv::StereoBM m_cStereoBM; +public: + DisparityStereoBM(); + virtual ~DisparityStereoBM() + { + } + + Bool create( std::vector apcFrameList ); + PlaYUVerFrame* process( std::vector apcFrameList ); + Void destroy(); +}; + +} // NAMESPACE + +#endif // __DISPARITYSTEREOBM_H__ + diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index eb63928..1a7e67c 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -44,6 +44,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "LumaAverage", &LumaAverage::Create ); #ifdef USE_OPENCV Register( "DisparityStereoVar", &DisparityStereoVar::Create ); + Register( "DisparityStereoBM", &DisparityStereoBM::Create ); #endif } From 7459d3e1f57c681eb694e1cf146e504e6be6f998 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:43:36 +0100 Subject: [PATCH 70/94] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 0635d47..c698e3a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,25 @@ plaYUVer is an open-source video player with the following features: - Frame level quality measurement API based on the PlaYUVerFrame class - Command-line tool for quality and frame processing algorithms (uses the referred APIs) +Supported Quality Metrics +---------------------------------------------------------------- +- PSNR +- SSIM +- MSE + +Frame Processing Modules +---------------------------------------------------------------- +- FilterComponentLuma +- FilterComponentChromaU +- FilterComponentChromaV +- FrameDifference +- AbsoluteFrameDifference +- FrameCrop +- FrameBinarization +- EightBitsSampling +- LumaAverage +- DisparityStereoVar +- DisparityStereoBM Developers ---------------------------------------------------------------- From e7641bdc9fd758123d21dbbdd21db6e16abcae76 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 7 Apr 2015 02:46:59 +0100 Subject: [PATCH 71/94] Update README build section --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c698e3a..5c24121 100644 --- a/README.md +++ b/README.md @@ -42,25 +42,21 @@ Developers - Lui­s Lucas (luisfrlucas@gmail.com) -Builds +Build ---------------------------------------------------------------- Download update build for windows and linux from our SourceForge project page +To build yourself -Build/Install using cmake ----------------------------------------------------------------- - -1. The following are required for compilation: +1. Dependencies: - an ordinary C++ development environment (g++, make, C++ libraries and headers, ...) - cmake - a Qt development environment (libraries, headers, qmake, ...): only QtCore, QtGui and QtWidgets are required, at least in version 4 + - QtDBus (optional) + - OpenCv (optional) + - FFmpeg (optional) -2. Optional Dependencies: - - QtDBus - - OpenCv - - FFmpeg - -3. Run the following commands: (this will create an executable named playuver) +3. Example configuration command: ``` mkdir build cd build From 0301a11a264c8f4f45b7d26932efc9b299d36af3 Mon Sep 17 00:00:00 2001 From: jcarreira Date: Tue, 7 Apr 2015 02:50:08 +0100 Subject: [PATCH 72/94] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5c24121..b6a1604 100644 --- a/README.md +++ b/README.md @@ -46,17 +46,16 @@ Build ---------------------------------------------------------------- Download update build for windows and linux from our SourceForge project page -To build yourself +Building yourself -1. Dependencies: +1. Dependencies - an ordinary C++ development environment (g++, make, C++ libraries and headers, ...) - cmake - a Qt development environment (libraries, headers, qmake, ...): only QtCore, QtGui and QtWidgets are required, at least in version 4 - QtDBus (optional) - OpenCv (optional) - FFmpeg (optional) - -3. Example configuration command: +2. Example configuration command ``` mkdir build cd build From b6b3f3e7192a42ce0b0e4fbb9a73febd35de834f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 8 Apr 2015 01:37:48 +0100 Subject: [PATCH 73/94] Minor fixes in progress bar --- app/ProgressBar.cpp | 12 ++++++++---- app/ProgressBar.h | 1 + app/QualityHandle.cpp | 34 ++++++++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/app/ProgressBar.cpp b/app/ProgressBar.cpp index c264599..6f0104f 100644 --- a/app/ProgressBar.cpp +++ b/app/ProgressBar.cpp @@ -45,10 +45,13 @@ ProgressBar::ProgressBar( QWidget *parent, UInt maxValue ) : setLayout( mainLayout ); setWindowTitle( QStringLiteral( "Progress" ) ); - QSize screenSize = QApplication::desktop()->availableGeometry().size(); - QPoint screenCenter = QApplication::desktop()->availableGeometry().center(); - resize( screenSize.width() / 4, screenSize.height() / 10 ); - move( screenCenter.x() - screenSize.width() / 8, screenCenter.y() - screenSize.height() / 10 ); +// QSize appSize = QApplication::desktop()->availableGeometry().size(); +// QPoint appCenter = QApplication::desktop()->availableGeometry().center(); + QSize appSize = parent->size(); + QPoint appPos = parent->pos(); + QPoint appCenter = QPoint( appPos.x() + appSize.width() / 2, appPos.y() + appSize.height() / 2 ); + resize( appSize.width() / 4, appSize.height() / 10 ); + move( appCenter.x() - appSize.width() / 8, appCenter.y() - appSize.height() / 20 ); show(); } @@ -56,5 +59,6 @@ Void ProgressBar::incrementProgress( UInt increment ) { m_uiProgress += increment; m_pcProgressBar->setValue( m_uiProgress ); + update(); } } // NAMESPACE diff --git a/app/ProgressBar.h b/app/ProgressBar.h index fffa430..8cba896 100644 --- a/app/ProgressBar.h +++ b/app/ProgressBar.h @@ -27,6 +27,7 @@ #include "PlaYUVerAppDefs.h" #include +#include class QProgressBar; diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index ba4f630..9eb7719 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -106,14 +106,35 @@ QDockWidget* QualityHandle::createDock() Void QualityHandle::updateMenus() { - VideoSubWindow* pcSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); - Bool hasSubWindow = pcSubWindow ? true : false; + VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast( m_pcMainWindowManager->activeSubWindow() ); + Bool hasSubWindow = pcCurrentVideoSubWindow ? true : false; + Bool hasReference = false; + Bool isReference = false; + + if( hasSubWindow ) + { + hasReference = pcCurrentVideoSubWindow->getRefSubWindow() != NULL ? true : false; + if( hasSubWindow && !hasReference ) + { + VideoSubWindow* pcVideoSubWindow; + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + for( Int i = 0; i < subWindowList.size(); i++ ) + { + pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); + if( pcVideoSubWindow->getRefSubWindow() == pcCurrentVideoSubWindow ) + { + isReference = true; + break; + } + } + } + } m_pcSubMenuQualityMetrics->setEnabled( hasSubWindow ); m_arrayActions[SELECT_CURR_REF_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[PLOT_QUALITY]->setEnabled( hasSubWindow ); - m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasSubWindow ); + m_arrayActions[PLOT_QUALITY]->setEnabled( hasReference ); + m_arrayActions[PLOT_SEVERAL_QUALITY]->setEnabled( hasReference | isReference ); m_pcQualityHandleSideBar->updateSideBar( hasSubWindow ); } @@ -243,6 +264,7 @@ Void QualityHandle::slotSelectCurrentAsReference() } m_pcQualityHandleSideBar->updateSidebarData(); m_pcQualityHandleDock->show(); + emit changed(); } } @@ -264,7 +286,7 @@ Void QualityHandle::slotPlotQualitySingle() measureQuality( apcWindowList ); QApplication::restoreOverrideCursor(); //#endif - + emit changed(); } } } @@ -303,7 +325,7 @@ Void QualityHandle::slotPlotQualitySeveral() measureQuality( apcWindowList ); QApplication::restoreOverrideCursor(); //#endif - + emit changed(); } } } From c40194d4222552d3f38ed211ec0e91ef386a8f4d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 8 Apr 2015 01:55:36 +0100 Subject: [PATCH 74/94] Fix playing when sequence is preloaded --- lib/PlaYUVerStream.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index f3aa7f8..cc3f520 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -665,12 +665,19 @@ Bool PlaYUVerStream::setNextFrame() { m_pcCurrFrame = m_pcNextFrame; m_iCurrFrameNum++; - m_uiFrameBufferIndex++; - if( m_uiFrameBufferIndex == m_uiFrameBufferSize ) + if( m_iCurrFrameNum + 1 < Int( m_uiTotalFrameNum ) ) { - m_uiFrameBufferIndex = 0; + m_uiFrameBufferIndex++; + if( m_uiFrameBufferIndex == m_uiFrameBufferSize ) + { + m_uiFrameBufferIndex = 0; + } + m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + } + else + { + m_pcNextFrame = NULL; } - m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; } else { From 8c5c8966a3136bb0cbe43d95acbf5156a6bb028d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 8 Apr 2015 01:56:07 +0100 Subject: [PATCH 75/94] Minor fixes in GUI and disable playing fps debug print --- app/VideoHandle.cpp | 1 + app/VideoHandle.h | 2 +- app/VideoSubWindow.cpp | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index a3a383f..144f829 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -121,6 +121,7 @@ QToolBar* VideoHandle::createToolBar() m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] ); QLabel* pcLockLabel = new QLabel( "PlayingLock", this ); + pcLockLabel->setAlignment( Qt::AlignCenter ); m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel ); m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false ); diff --git a/app/VideoHandle.h b/app/VideoHandle.h index 7a92a75..8a8c23b 100644 --- a/app/VideoHandle.h +++ b/app/VideoHandle.h @@ -37,7 +37,7 @@ #include "WidgetFrameNumber.h" #include "FramePropertiesSidebar.h" -#define _CONTROL_PLAYING_TIME_ 1 +#define _CONTROL_PLAYING_TIME_ 0 class QElapsedTimer; diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 1449627..5ff8974 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -119,8 +119,10 @@ VideoSubWindow::~VideoSubWindow() Void VideoSubWindow::loadAll() { + QApplication::setOverrideCursor( Qt::WaitCursor ); m_pCurrStream->loadAll(); refreshFrame(); + QApplication::restoreOverrideCursor(); } Void VideoSubWindow::refreshSubWindow() From 4c8b6376d7d28cc440381526daa76017d019a8b5 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 8 Apr 2015 20:57:24 +0100 Subject: [PATCH 76/94] Add SetChromaHalfScale module --- modules/CMakeLists.txt | 1 + modules/FrameBinarization.h | 2 +- modules/PlaYUVerModuleFactory.cpp | 1 + modules/SetChromaHalfScale.cpp | 75 +++++++++++++++++++++++++++++++ modules/SetChromaHalfScale.h | 53 ++++++++++++++++++++++ 5 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 modules/SetChromaHalfScale.cpp create mode 100644 modules/SetChromaHalfScale.h diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 4167eb6..ac7afdd 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -38,6 +38,7 @@ ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) ADD_MODULE( FrameBinarization "FrameBinarization" ) +ADD_MODULE( SetChromaHalfScale "SetChromaHalfScale" ) ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) ADD_MODULE( LumaAverage "LumaAverage" ) diff --git a/modules/FrameBinarization.h b/modules/FrameBinarization.h index 5efca95..aa6439c 100644 --- a/modules/FrameBinarization.h +++ b/modules/FrameBinarization.h @@ -50,5 +50,5 @@ public: } // NAMESPACE -#endif // __LUMAAVERAGE_H__ +#endif // __FRAMEBINARIZATION_H__ diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 1a7e67c..db28eee 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -38,6 +38,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "FilterComponentChromaV", &FilterComponentChromaV::Create ); Register( "FrameDifference", &FrameDifference::Create ); Register( "AbsoluteFrameDifference", &AbsoluteFrameDifference::Create ); + Register( "SetChromaHalfScale", &SetChromaHalfScale::Create ); Register( "FrameCrop", &FrameCrop::Create ); Register( "FrameBinarization", &FrameBinarization::Create ); Register( "EightBitsSampling", &EightBitsSampling::Create ); diff --git a/modules/SetChromaHalfScale.cpp b/modules/SetChromaHalfScale.cpp new file mode 100644 index 0000000..af22c60 --- /dev/null +++ b/modules/SetChromaHalfScale.cpp @@ -0,0 +1,75 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file SetChromaHalfScale.cpp + * \brief Binarize frame module + */ + +#include "SetChromaHalfScale.h" + +namespace plaYUVer +{ + +SetChromaHalfScale::SetChromaHalfScale() +{ + /* Module Definition */ + m_iModuleType = FRAME_PROCESSING_MODULE; + m_pchModuleCategory = "Utilities"; + m_pchModuleName = "SetChromaHalfScale"; + m_pchModuleTooltip = "Copy frame only keeping luma component"; + m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; + m_uiModuleRequirements = MODULE_REQUIRES_NOTHING; + + m_pcProcessedFrame = NULL; + +} + +Void SetChromaHalfScale::create( PlaYUVerFrame* frame ) +{ + m_pcProcessedFrame = NULL; + m_pcProcessedFrame = new PlaYUVerFrame( frame->getWidth(), frame->getHeight(), frame->getPelFormat(), frame->getBitsPel() ); +} + +PlaYUVerFrame* SetChromaHalfScale::process( PlaYUVerFrame* frame ) +{ + Pel* pPelInput = frame->getPelBufferYUV()[LUMA][0]; + Pel* pPelOut = m_pcProcessedFrame->getPelBufferYUV()[0][0]; + Pel halfScaleValue = 1 << ( frame->getBitsPel() - 1 ); + for( UInt i = 0; i < frame->getHeight() * frame->getWidth(); i++ ) + { + *pPelOut++ = *pPelInput++; + } + pPelInput = frame->getPelBufferYUV()[CHROMA_U][0]; + for( UInt i = 0; i < m_pcProcessedFrame->getChromaLength() * 2; i++ ) + { + *pPelOut++ = halfScaleValue; + } + return m_pcProcessedFrame; +} + +Void SetChromaHalfScale::destroy() +{ + if( m_pcProcessedFrame ) + delete m_pcProcessedFrame; + m_pcProcessedFrame = NULL; +} + +} // NAMESPACE + diff --git a/modules/SetChromaHalfScale.h b/modules/SetChromaHalfScale.h new file mode 100644 index 0000000..4a36c17 --- /dev/null +++ b/modules/SetChromaHalfScale.h @@ -0,0 +1,53 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) + * Joao Carreira (jfmcarreira@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** + * \file SetChromaHalfScale.h + * \brief Binarize frame module + */ + +#ifndef __CHROMA128_H__ +#define __CHROMA128_H__ + +#include "PlaYUVerModuleIf.h" + +namespace plaYUVer +{ + +class SetChromaHalfScale: public PlaYUVerModuleIf +{ +REGISTER_CLASS_FACTORY( SetChromaHalfScale ) + +private: + PlaYUVerFrame* m_pcProcessedFrame; +public: + SetChromaHalfScale(); + virtual ~SetChromaHalfScale() + { + } + Void create( PlaYUVerFrame* ); + PlaYUVerFrame* process( PlaYUVerFrame* ); + Void destroy(); + +}; + +} // NAMESPACE + +#endif // __CHROMA128_H__ + From e51a5c828863464972879603ee3a420f9668f7ec Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 01:11:11 +0100 Subject: [PATCH 77/94] Add function to find the stream handler and fix problems with modules and stream info description --- app/VideoSubWindow.cpp | 33 +++++---- lib/PlaYUVerFrame.cpp | 2 +- lib/PlaYUVerFrame.h | 5 ++ lib/PlaYUVerStream.cpp | 154 ++++++++++++++++++++--------------------- lib/PlaYUVerStream.h | 10 +-- 5 files changed, 102 insertions(+), 102 deletions(-) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 5ff8974..bf222d7 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -111,6 +111,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget VideoSubWindow::~VideoSubWindow() { + m_pcCurrFrame = NULL; disableModule(); delete m_cViewArea; if( m_pCurrStream ) @@ -227,23 +228,23 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) Void VideoSubWindow::updateVideoWindowInfo() { - if( m_pCurrStream ) + m_cStreamInformation = ""; + if( m_bIsModule ) + { + m_cStreamInformation = "Module"; + } + else if( m_pCurrStream ) { 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_cStreamInformation = m_cFormatName + " | " + m_cCodedName + " | " + m_cPelFmtName; + m_cStreamInformation = m_cFormatName + " | " + m_cCodedName; } - else if( m_pcCurrFrame ) + if( m_pcCurrFrame ) { - if( m_bIsModule || m_pcCurrentDisplayModule ) - { - m_cStreamInformation = "Module | "; - } - QString m_cPelFmtName = QString::fromStdString( PlaYUVerFrame::supportedPixelFormatListNames()[m_pcCurrFrame->getPelFormat()].c_str() ); - m_cStreamInformation += m_cPelFmtName; + QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() ); + m_cStreamInformation += " | " + m_cPelFmtName; } - else + if( m_cStreamInformation.isEmpty() ) { m_cStreamInformation = " "; } @@ -404,8 +405,8 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) } if( bRefresh ) { - updateVideoWindowInfo(); refreshFrame(); + updateVideoWindowInfo(); } } @@ -416,8 +417,12 @@ Void VideoSubWindow::associateModule( PlaYUVerAppModuleIf* pcModule ) Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) { - m_pcCurrFrame = pcCurrFrame; - m_cViewArea->setImage( m_pcCurrFrame ); + // if( m_pcCurrFrame ) + { + m_pcCurrFrame = pcCurrFrame; + m_cViewArea->setImage( m_pcCurrFrame ); + updateVideoWindowInfo(); + } } Void VideoSubWindow::refreshFrameOperation() diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 9e45dd7..2137464 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -208,7 +208,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 ); xSetupStatistics( this ); - openPixfc(); + m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); } Int PlaYUVerFrame::getColorSpace() const diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index dd7b7c5..593d9ee 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -228,6 +228,10 @@ public: PlaYUVerFrame::Pixel getPixelValue( Int xPos, Int yPos, ColorSpace eColorSpace = COLOR_INVALID ); + std::string getPelFmtName() + { + return m_cPelFmtName; + } UInt getWidth() const { return m_uiWidth; @@ -333,6 +337,7 @@ private: //! Strcut with the pixel format description. PlaYUVerPixFmtDescriptor* m_pcPelFormat; + std::string m_cPelFmtName; UInt m_uiWidth; //!< Width of the frame UInt m_uiHeight; //!< Height of the frame diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index cc3f520..5b09f1e 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -135,7 +135,7 @@ PlaYUVerStream::PlaYUVerStream() m_bIsInput = true; m_bIsOpened = false; m_bLoadAll = false; - m_uiStreamHandler = 0; + m_iStreamHandler = INVALID_HANDLER; m_pFile = NULL; m_pchFilename = NULL; m_uiWidth = 0; @@ -145,7 +145,6 @@ PlaYUVerStream::PlaYUVerStream() m_iPixelFormat = -1; m_uiBitsPerPixel = 8; m_dFrameRate = 30; - m_iFileFormat = -1; m_pStreamBuffer = NULL; m_cFilename = ""; m_pcCurrFrame = NULL; @@ -164,6 +163,53 @@ PlaYUVerStream::~PlaYUVerStream() close(); } +Void PlaYUVerStream::findHandler() +{ + m_iStreamHandler = INVALID_HANDLER; + + if( m_uiBitsPerPixel != 8 ) + { + m_iStreamHandler = YUV_IO; + return; + } + + std::string currExt = m_cFilename.substr( m_cFilename.find_last_of( "." ) + 1 ); + if( m_bIsInput ) + { +#ifdef USE_FFMPEG + for( UInt i = 0; i < LibAvContextHandle::supportedReadFormatsExt().size(); i++ ) + { + if( LibAvContextHandle::supportedReadFormatsExt()[i] == currExt ) + { + m_cFormatName = LibAvContextHandle::supportedReadFormatsExt()[i]; + m_iStreamHandler = FFMPEG; + return; + } + } +#endif + if( m_iStreamHandler == INVALID_HANDLER ) + m_iStreamHandler = YUV_IO; + } + else + { +#ifdef USE_FFMPEG + for( UInt i = 0; i < LibAvContextHandle::supportedWriteFormatsExt().size(); i++ ) + { + if( LibAvContextHandle::supportedWriteFormatsExt()[i] == currExt ) + { + m_cFormatName = LibAvContextHandle::supportedWriteFormatsExt()[i]; + m_iStreamHandler = FFMPEG; + return; + } + } +#endif + if( currExt == "yuv" ) + { + m_iStreamHandler = YUV_IO; + } + } +} + Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt bitsPel, UInt frame_rate, Bool bInput ) { UInt width; @@ -208,69 +254,18 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in std::copy( m_cFilename.begin(), m_cFilename.end(), m_pchFilename ); m_pchFilename[m_cFilename.size()] = '\0'; // don't forget the terminating 0 - if( m_bIsInput ) + findHandler(); + if( m_iStreamHandler == INVALID_HANDLER ) { - m_iFileFormat = INVALID_HANDLER; - - std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 ); - for( UInt i = 0; i < PlaYUVerStream::supportedReadFormatsExt().size(); i++ ) - { - if( PlaYUVerStream::supportedReadFormatsExt()[i] == currExt ) - { - m_iFileFormat = i; - m_cFormatName = PlaYUVerStream::supportedReadFormatsExt()[i]; - break; - } - } - if( m_iFileFormat == INVALID_HANDLER ) - { - close(); - throw "Invalid file format"; - return m_bInit; - } - - if( m_cFormatName == "yuv" ) - { - m_uiStreamHandler = YUV_IO; - } -//#ifdef USE_OPENCV -// else if( m_cFormatName == "png" || m_cFormatName == "jpg" ) -// { -// m_uiStreamHandler = OPENCV_HANDLER; -// } -//#endif -#ifdef USE_FFMPEG - else - { - m_uiStreamHandler = FFMPEG; - } -#endif -#if 0 - if( !avStatus ) - { - switch( m_iFileFormat ) - { - case PGMINPUT: - - break; - } - } -#endif - if( m_uiBitsPerPixel != 8 ) - { - m_uiStreamHandler = YUV_IO; - } - m_uiFrameBufferSize = 2; - } - else - { - m_iFileFormat = 0; - m_uiStreamHandler = YUV_IO; - m_uiFrameBufferSize = 1; + close(); + throw "Invalid file format"; + return m_bInit; } + m_uiFrameBufferSize = m_bIsInput ? 2 : 1; + #ifdef USE_FFMPEG - if( m_uiStreamHandler == FFMPEG ) + if( m_iStreamHandler == FFMPEG ) { if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_dFrameRate, m_uiTotalFrameNum ) ) { @@ -281,7 +276,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in #endif #ifdef USE_OPENCV - if( m_uiStreamHandler == OPENCV_HANDLER ) + if( m_iStreamHandler == OPENCV_HANDLER ) { m_pcCurrFrame = LibOpenCVHandler::loadFrame( m_cFilename ); if( m_pcCurrFrame ) @@ -300,9 +295,9 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in return m_bInit; } - if( m_uiStreamHandler != OPENCV_HANDLER ) + if( m_iStreamHandler != OPENCV_HANDLER ) { - if( m_uiStreamHandler == YUV_IO ) + if( m_iStreamHandler == YUV_IO ) { if( !openFile() ) { @@ -333,7 +328,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame(); - if( m_uiStreamHandler == YUV_IO && m_bIsInput ) + if( m_iStreamHandler == YUV_IO && m_bIsInput ) { fseek( m_pFile, 0, SEEK_END ); UInt64 fileSize = ftell( m_pFile ); @@ -380,10 +375,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in m_uiBitsPerPixel = m_pcCurrFrame->getBitsPel(); } - m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); - m_iCurrFrameNum = -1; - m_bInit = true; seekInput( 0 ); @@ -394,7 +386,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in Bool PlaYUVerStream::openFile() { - //m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary ) +//m_fsIOStream.open( m_cFilename, std::ios::in | std::ios::binary ) m_pFile = NULL; m_pFile = fopen( m_pchFilename, m_bIsInput ? "rb" : "wb" ); if( m_pFile == NULL ) @@ -419,11 +411,11 @@ Void PlaYUVerStream::close() if( !m_bInit ) return; - if( m_uiStreamHandler == YUV_IO ) + if( m_iStreamHandler == YUV_IO ) closeFile(); #ifdef USE_FFMPEG - if( m_uiStreamHandler == FFMPEG ) + if( m_iStreamHandler == FFMPEG ) m_cLibAvContext->closeAvFormat(); delete m_cLibAvContext; #endif @@ -516,12 +508,14 @@ Void PlaYUVerStream::getDuration( Int* duration_array ) { Int hours, mins, secs; #ifdef USE_FFMPEG - if( m_cLibAvContext->getStatus() ) + if( m_iStreamHandler == FFMPEG ) { secs = m_cLibAvContext->getStreamDuration(); } else #endif + if( m_iStreamHandler == YUV_IO ) + { secs = m_uiTotalFrameNum / m_dFrameRate; } @@ -553,13 +547,13 @@ Void PlaYUVerStream::readFrame() return; } - if( m_uiStreamHandler == OPENCV_HANDLER ) + if( m_iStreamHandler == OPENCV_HANDLER ) { return; } #ifdef USE_FFMPEG - if( m_uiStreamHandler == FFMPEG ) + if( m_iStreamHandler == FFMPEG ) { if( !m_cLibAvContext->decodeAvFormat() ) { @@ -569,7 +563,7 @@ Void PlaYUVerStream::readFrame() m_pcNextFrame->frameFromBuffer( m_cLibAvContext->m_pchFrameBuffer, m_cLibAvContext->m_uiFrameBufferSize ); } #endif - if( m_uiStreamHandler == YUV_IO ) + if( m_iStreamHandler == YUV_IO ) { UInt64 frame_bytes_input = m_pcNextFrame->getBytesPerFrame(); UInt64 bytes_read = fread( m_pStreamBuffer, sizeof(Byte), frame_bytes_input, m_pFile ); @@ -591,7 +585,7 @@ Void PlaYUVerStream::writeFrame() Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame ) { - if( m_uiStreamHandler == YUV_IO ) + if( m_iStreamHandler == YUV_IO ) { UInt64 frame_bytes_input = pcFrame->getBytesPerFrame(); pcFrame->frameToBuffer( m_pStreamBuffer ); @@ -614,7 +608,7 @@ Bool PlaYUVerStream::saveFrame( const std::string& filename, PlaYUVerFrame *save Int iFileFormat = INVALID_HANDLER; std::string fmtExt; - //std::string currExt = QFileInfo( qtString ).suffix().toStdString(); +//std::string currExt = QFileInfo( qtString ).suffix().toStdString(); std::string currExt = filename.substr( filename.find_last_of( "." ) + 1 ); for( UInt i = 0; i < PlaYUVerStream::supportedSaveFormatsExt().size(); i++ ) @@ -738,17 +732,17 @@ Bool PlaYUVerStream::seekInput( UInt64 new_frame_num ) setNextFrame(); return true; } - if( m_uiStreamHandler == OPENCV_HANDLER ) + if( m_iStreamHandler == OPENCV_HANDLER ) { return true; } #ifdef USE_FFMPEG - if( m_uiStreamHandler == FFMPEG ) + if( m_iStreamHandler == FFMPEG ) { m_cLibAvContext->seekAvFormat( new_frame_num ); } #endif - if( m_uiStreamHandler == YUV_IO ) + if( m_iStreamHandler == YUV_IO ) { UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame(); UInt64 nbytes_seek = frame_bytes_input * new_frame_num; diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 6736c55..c0b1b82 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -67,7 +67,7 @@ private: FFMPEG, TOTAL_HANDLERR }; - UInt m_uiStreamHandler; + Int m_iStreamHandler; LibAvContextHandle* m_cLibAvContext; std::string m_cFilename; @@ -75,9 +75,7 @@ private: std::string m_cFormatName; std::string m_cCodedName; - std::string m_cPelFmtName; - Int m_iFileFormat; UInt m_uiWidth; UInt m_uiHeight; Int m_iPixelFormat; @@ -97,6 +95,8 @@ private: UInt m_uiFrameBufferIndex; UInt64 m_uiCurrFrameFileIdx; + Void findHandler(); + public: static std::vector supportedReadFormatsExt(); @@ -164,10 +164,6 @@ public: { return m_cCodedName; } - std::string getPelFmtName() - { - return m_cPelFmtName; - } UInt getFrameNum() { From 6b8847f6e417d9dfc77b2078239034dbd74f841d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 01:15:21 +0100 Subject: [PATCH 78/94] fix quality for less than 3 components formats --- app/QualityMeasurementSidebar.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp index 0d86888..04d6770 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/QualityMeasurementSidebar.cpp @@ -187,7 +187,7 @@ Void QualityMeasurementSidebar::updateCurrentWindow( VideoSubWindow *subWindow ) Void QualityMeasurementSidebar::updateSidebarData() { - QString value( "0.0000" ); + QString zeroValue( "0.0000" ); if( m_pcCurrentVideoSubWindow ) { VideoSubWindow* refSubWindow = m_pcCurrentVideoSubWindow->getRefSubWindow(); @@ -196,12 +196,18 @@ Void QualityMeasurementSidebar::updateSidebarData() PlaYUVerFrame* currFrame = m_pcCurrentVideoSubWindow->getCurrFrame(); PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame(); Double quality; - - for( Int component = 0; component < 3; component++ ) + QString value; + UInt component = 0; + for( ; component < currFrame->getNumberChannels(); component++ ) { quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component ); m_ppcLabelQualityValue[component]->setText( value.setNum( quality, 'f', 4 ) ); } + for( ; component < 3; component++ ) + { + quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component ); + m_ppcLabelQualityValue[component]->setText( zeroValue ); + } return; } else @@ -211,7 +217,7 @@ Void QualityMeasurementSidebar::updateSidebarData() } for( Int component = 0; component < 3; component++ ) { - m_ppcLabelQualityValue[component]->setText( value ); + m_ppcLabelQualityValue[component]->setText( zeroValue ); } } From d8f483c656ed83d4535f70c6b6d4da986cf4266d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 14:24:32 +0100 Subject: [PATCH 79/94] Add options to change between window modes --- app/PlaYUVerSubWindowHandle.cpp | 83 +++++++++++++++++++++++++-------- app/PlaYUVerSubWindowHandle.h | 8 +++- app/SubWindowHandle.cpp | 5 ++ app/SubWindowHandle.h | 2 +- 4 files changed, 76 insertions(+), 22 deletions(-) diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index f2af114..04848b4 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -59,9 +59,9 @@ private: PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : QWidget( parent ) { - m_uiWindowMode = 0; + m_iWindowMode = 0; - //setWindowMode( NormalSubWindows ); + setWindowMode( NormalSubWindows ); setWindowMode( MdiWSubWindows ); m_pcActiveWindow = NULL; @@ -71,9 +71,25 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : Void PlaYUVerSubWindowHandle::resetWindowMode() { - if( m_uiWindowMode == MdiWSubWindows ) + QList apcSubWindowList = m_apcSubWindowList; + + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { - removeAllSubWindow(); + m_apcSubWindowList.at( i )->setParent( NULL ); + m_apcSubWindowList.at( i )->sizeHint(); + m_apcSubWindowList.at( i )->show(); + } + + if( m_iWindowMode == NormalSubWindows ) + { + + } + if( m_iWindowMode == MdiWSubWindows ) + { + for( Int i = 0; i < m_apcMdiSubWindowList.size(); i++ ) + { + m_apcMdiSubWindowList.at( i )->close(); + } m_apcMdiSubWindowList.clear(); if( m_pcMdiArea ) delete m_pcMdiArea; @@ -82,19 +98,19 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() } } -Void PlaYUVerSubWindowHandle::setWindowMode( UInt uiWindowMode ) +Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) { - if( m_uiWindowMode == uiWindowMode ) + if( m_iWindowMode == iWindowMode ) return; resetWindowMode(); - if( uiWindowMode == NormalSubWindows ) + if( iWindowMode == NormalSubWindows ) { } - if( uiWindowMode == MdiWSubWindows ) + if( iWindowMode == MdiWSubWindows ) { m_pcMdiArea = new PlaYUVerMdiArea( this ); m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); @@ -104,12 +120,12 @@ Void PlaYUVerSubWindowHandle::setWindowMode( UInt uiWindowMode ) setLayout( m_pcWindowManagerLayout ); } - m_uiWindowMode = uiWindowMode; + m_iWindowMode = iWindowMode; } Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) { - if( m_uiWindowMode == NormalSubWindows ) + if( m_iWindowMode == NormalSubWindows ) { if( window ) { @@ -118,7 +134,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) } } - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { m_pcActiveWindow = NULL; QMdiSubWindow* mdiSubWindow = m_pcMdiArea->activeSubWindow(); @@ -148,12 +164,12 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowF connect( window, SIGNAL( updateStatusBar( const QString& ) ), qobject_cast( parent() ), SLOT( updateStatusBar( const QString& ) ) ); connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), qobject_cast( parent() ), SLOT( updateZoomFactorSBox() ) ); - if( m_uiWindowMode == NormalSubWindows ) + if( m_iWindowMode == NormalSubWindows ) { connect( window, SIGNAL( aboutToActivate( SubWindowHandle* ) ), this, SLOT( updateActiveSubWindow( SubWindowHandle* ) ) ); connect( window, SIGNAL( aboutToClose( SubWindowHandle* ) ), this, SLOT( removeSubWindow( SubWindowHandle* ) ) ); } - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow; mdiSubWindow->setWidget( window ); @@ -170,13 +186,13 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) { if( windowIdx >= 0 ) { - if( m_uiWindowMode == NormalSubWindows ) + if( m_iWindowMode == NormalSubWindows ) { SubWindowHandle* subWindow = m_apcSubWindowList.at( windowIdx ); m_apcSubWindowList.removeAt( windowIdx ); subWindow->close(); } - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { PlaYUVerMdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx ); m_apcMdiSubWindowList.removeAt( windowIdx ); @@ -273,11 +289,11 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) m_pcActiveWindow = qobject_cast( window ); - if( m_uiWindowMode == NormalSubWindows ) + if( m_iWindowMode == NormalSubWindows ) { m_pcActiveWindow->window()->activateWindow(); } - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { m_pcActiveWindow->setFocus(); } @@ -285,7 +301,7 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) Void PlaYUVerSubWindowHandle::tileSubWindows() { - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { m_pcMdiArea->tileSubWindows(); } @@ -293,7 +309,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() Void PlaYUVerSubWindowHandle::cascadeSubWindows() { - if( m_uiWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MdiWSubWindows ) { m_pcMdiArea->cascadeSubWindows(); } @@ -306,6 +322,32 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions.resize( TOTAL_ACT ); + // ------------ Tools ------------ + QActionGroup* actionGroupWindowMode = new QActionGroup( this ); + actionGroupWindowMode->setExclusive( true ); + + m_mapperWindowMode = new QSignalMapper( this ); + connect( m_mapperWindowMode, SIGNAL( mapped(int) ), this, SLOT( setWindowMode(int) ) ); + + m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] = new QAction( tr( "&Detached SubWindows" ), this ); + m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT]->setCheckable( true ); + actionGroupWindowMode->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); + connect( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); + m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], ViewArea::NavigationTool ); + + m_arrayActions[MDI_SUBWINDOW_MODE_ACT] = new QAction( "&MDI SubWindows", this ); + m_arrayActions[MDI_SUBWINDOW_MODE_ACT]->setCheckable( true ); + actionGroupWindowMode->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] ); + connect( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); + m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], ViewArea::NormalSelectionTool ); + + actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true ); + + m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); + m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); + m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) ); + connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) ); + m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) ); @@ -354,6 +396,9 @@ QMenu* PlaYUVerSubWindowHandle::createMenu() Void PlaYUVerSubWindowHandle::updateMenu() { m_pcMenuWindow->clear(); + m_pcMenuWindow->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); + m_pcMenuWindow->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] ); + m_pcMenuWindow->addSeparator(); m_pcMenuWindow->addAction( m_arrayActions[CLOSE_ACT] ); m_pcMenuWindow->addAction( m_arrayActions[CLOSE_ALL_ACT] ); m_pcMenuWindow->addSeparator(); diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index b7c682c..b71511a 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -68,7 +68,7 @@ public: }; private: - UInt m_uiWindowMode; + Int m_iWindowMode; QList m_apcSubWindowList; QHBoxLayout* m_pcWindowManagerLayout; @@ -79,6 +79,8 @@ private: enum { + NORMAL_SUBWINDOW_MODE_ACT, + MDI_SUBWINDOW_MODE_ACT, CLOSE_ACT, CLOSE_ALL_ACT, TILE_WINDOWS_ACT, @@ -89,6 +91,7 @@ private: TOTAL_ACT, }; QVector m_arrayActions; + QSignalMapper* m_mapperWindowMode; QSignalMapper* m_mapperWindow; QMenu* m_pcMenuWindow; @@ -96,10 +99,11 @@ private: * Internal functions */ Void resetWindowMode(); - Void setWindowMode( UInt uiWindowMode ); + Void removeSubWindow( Int windowIdx ); public Q_SLOTS: + void setWindowMode( int iWindowMode ); void updateActiveSubWindow( SubWindowHandle *window = 0 ); void setActiveSubWindow( QWidget *window ); void removeSubWindow( SubWindowHandle *window ); diff --git a/app/SubWindowHandle.cpp b/app/SubWindowHandle.cpp index 2ad5f1f..10622ab 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowHandle.cpp @@ -172,6 +172,11 @@ Bool SubWindowHandle::mayClose() return true; } +QSize SubWindowHandle::sizeHint( ) const +{ + return QSize(); +} + QSize SubWindowHandle::sizeHint( const QSize & ) const { return QSize(); diff --git a/app/SubWindowHandle.h b/app/SubWindowHandle.h index 62fb936..63e6431 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowHandle.h @@ -110,7 +110,7 @@ public: /** * Size related functions */ - //virtual QSize sizeHint() const; + virtual QSize sizeHint() const; virtual QSize sizeHint( const QSize & ) const; /** From 0b5970983929c2b8ece1789a7fdd4fc4dad13152 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 15:37:15 +0100 Subject: [PATCH 80/94] Fix problem of closing windows in detached subwindow mode --- app/ModulesHandle.cpp | 2 +- app/PlaYUVerSubWindowHandle.cpp | 55 ++++++++++++++++++++++++--------- app/PlaYUVerSubWindowHandle.h | 5 ++- app/PlotSubWindow.cpp | 2 +- app/PlotSubWindow.h | 2 +- app/QualityHandle.cpp | 2 +- app/VideoSubWindow.cpp | 24 +++++++------- app/VideoSubWindow.h | 4 +-- 8 files changed, 62 insertions(+), 34 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index 7a4d21b..c051662 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -343,7 +343,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) { if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) { - pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW, this ); + pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW ); pcModuleSubWindow->setWindowShortName( windowName ); pcModuleSubWindow->setWindowName( windowName ); diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 04848b4..3c2d14d 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -61,7 +61,7 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : { m_iWindowMode = 0; - setWindowMode( NormalSubWindows ); + //setWindowMode( NormalSubWindows ); setWindowMode( MdiWSubWindows ); m_pcActiveWindow = NULL; @@ -73,21 +73,21 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() { QList apcSubWindowList = m_apcSubWindowList; - for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) - { - m_apcSubWindowList.at( i )->setParent( NULL ); - m_apcSubWindowList.at( i )->sizeHint(); - m_apcSubWindowList.at( i )->show(); - } - if( m_iWindowMode == NormalSubWindows ) { } if( m_iWindowMode == MdiWSubWindows ) { + m_cMdiModeWindowPosition = parentWidget()->pos(); + m_cMdiModeWindowSize = parentWidget()->size(); + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + { + m_apcSubWindowList.at( i )->setParent( NULL ); + } for( Int i = 0; i < m_apcMdiSubWindowList.size(); i++ ) { + disconnect( m_apcMdiSubWindowList.at( i ), SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); m_apcMdiSubWindowList.at( i )->close(); } m_apcMdiSubWindowList.clear(); @@ -95,6 +95,7 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() delete m_pcMdiArea; if( m_pcWindowManagerLayout ) delete m_pcWindowManagerLayout; + //hide(); } } @@ -107,6 +108,16 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) if( iWindowMode == NormalSubWindows ) { + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + { + m_apcSubWindowList.at( i )->setParent( NULL ); + m_apcSubWindowList.at( i )->sizeHint(); + m_apcSubWindowList.at( i )->show(); + } + + QSize screenSize = QApplication::desktop()->availableGeometry().size(); + parentWidget()->move( 0, 0 ); + parentWidget()->resize( screenSize.width(), 5 ); } @@ -118,9 +129,18 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) m_pcWindowManagerLayout = new QHBoxLayout( this ); m_pcWindowManagerLayout->addWidget( m_pcMdiArea ); setLayout( m_pcWindowManagerLayout ); + show(); + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + { + addMdiSubWindow( m_apcSubWindowList.at( i ) ); + } + parentWidget()->move( m_cMdiModeWindowPosition ); + parentWidget()->resize( m_cMdiModeWindowSize ); } - m_iWindowMode = iWindowMode; + tileSubWindows(); + parentWidget()->update(); + qApp->processEvents(); } Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) @@ -157,6 +177,16 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) } +Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowHandle *window ) +{ + PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow; + mdiSubWindow->setWidget( window ); + m_pcMdiArea->addSubWindow( mdiSubWindow ); + m_apcMdiSubWindowList.append( mdiSubWindow ); + window->setSubWindow( mdiSubWindow ); + connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); +} + Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowFlags flags ) { if( window ) @@ -171,12 +201,7 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowF } if( m_iWindowMode == MdiWSubWindows ) { - PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow; - mdiSubWindow->setWidget( window ); - m_pcMdiArea->addSubWindow( mdiSubWindow ); - m_apcMdiSubWindowList.append( mdiSubWindow ); - window->setSubWindow( mdiSubWindow ); - connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); + addMdiSubWindow( window ); } m_apcSubWindowList.append( window ); } diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index b71511a..93874b6 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -77,6 +77,9 @@ private: SubWindowHandle* m_pcActiveWindow; + QPoint m_cMdiModeWindowPosition; + QSize m_cMdiModeWindowSize; + enum { NORMAL_SUBWINDOW_MODE_ACT, @@ -98,8 +101,8 @@ private: /** * Internal functions */ + Void addMdiSubWindow( SubWindowHandle *window ); Void resetWindowMode(); - Void removeSubWindow( Int windowIdx ); public Q_SLOTS: diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index ebaa8d5..a3c7b2a 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -41,7 +41,7 @@ Void PlotSubWindow::definePlotColors() m_arrayColorList.append( Qt::darkRed ); } -PlotSubWindow::PlotSubWindow( QWidget * parent, const QString& windowTitle ) : +PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) : SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW ) { diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index 5eb93a2..add5937 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -60,7 +60,7 @@ private: public: - PlotSubWindow( QWidget * parent, const QString& windowTitle ); + PlotSubWindow( const QString& windowTitle, QWidget * parent = NULL ); ~PlotSubWindow(); Void definePlotColors(); diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 9eb7719..554b70e 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -217,7 +217,7 @@ Void QualityHandle::measureQuality( QVector apcWindowList ) { plotWindowTitle += " - " + apcWindowList.at( 0 )->getWindowName(); } - PlotSubWindow* pcPlotWindow = new PlotSubWindow( m_pcParet, plotWindowTitle ); + PlotSubWindow* pcPlotWindow = new PlotSubWindow( plotWindowTitle ); pcPlotWindow->setAxisName( "Frame Number", QString::fromStdString( PlaYUVerFrame::supportedQualityMetricsList()[m_iQualityMetricIdx] ) ); if( apcWindowList.size() > 1 ) diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index bf222d7..39ba15f 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -698,17 +698,17 @@ QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const return isize; } -Void VideoSubWindow::closeEvent( QCloseEvent *event ) -{ - Bool bAccept = m_bIsPlaying ? false : true; - if( bAccept ) - { - event->accept(); - } - else - { - event->ignore(); - } -} +//Void VideoSubWindow::closeEvent( QCloseEvent *event ) +//{ +// Bool bAccept = m_bIsPlaying ? false : true; +// if( bAccept ) +// { +// event->accept(); +// } +// else +// { +// event->ignore(); +// } +//} } // NAMESPACE diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 0da9fd1..16241bf 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -238,8 +238,8 @@ public: return m_bIsModule; } -protected: - void closeEvent( QCloseEvent *event ); +//protected: + //void closeEvent( QCloseEvent *event ); public Q_SLOTS: void updateSelectedArea( QRect area ); From 65652df6ed6ad97fa1f985c68cf03a6633d03db2 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 15:53:56 +0100 Subject: [PATCH 81/94] Increase plot colors --- app/PlaYUVerSubWindowHandle.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 3c2d14d..904dd2d 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -95,7 +95,6 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() delete m_pcMdiArea; if( m_pcWindowManagerLayout ) delete m_pcWindowManagerLayout; - //hide(); } } @@ -118,7 +117,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) QSize screenSize = QApplication::desktop()->availableGeometry().size(); parentWidget()->move( 0, 0 ); parentWidget()->resize( screenSize.width(), 5 ); - + setVisible( false ); } if( iWindowMode == MdiWSubWindows ) @@ -129,13 +128,13 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) m_pcWindowManagerLayout = new QHBoxLayout( this ); m_pcWindowManagerLayout->addWidget( m_pcMdiArea ); setLayout( m_pcWindowManagerLayout ); - show(); for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { addMdiSubWindow( m_apcSubWindowList.at( i ) ); } parentWidget()->move( m_cMdiModeWindowPosition ); parentWidget()->resize( m_cMdiModeWindowSize ); + setVisible( true ); } m_iWindowMode = iWindowMode; tileSubWindows(); From dae6ab4156fa761db824f06abca9955338ee4a0e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 16:03:37 +0100 Subject: [PATCH 82/94] Fix minor issues when changing window modes. toolbars are not configured yet --- app/PlaYUVerSubWindowHandle.cpp | 8 +++++--- app/PlotSubWindow.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 904dd2d..d37ff26 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -113,15 +113,18 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) m_apcSubWindowList.at( i )->sizeHint(); m_apcSubWindowList.at( i )->show(); } - + setVisible( false ); + parentWidget()->update(); + parentWidget()->showNormal(); + qApp->processEvents(); QSize screenSize = QApplication::desktop()->availableGeometry().size(); parentWidget()->move( 0, 0 ); parentWidget()->resize( screenSize.width(), 5 ); - setVisible( false ); } if( iWindowMode == MdiWSubWindows ) { + setVisible( true ); m_pcMdiArea = new PlaYUVerMdiArea( this ); m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) ); @@ -134,7 +137,6 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) } parentWidget()->move( m_cMdiModeWindowPosition ); parentWidget()->resize( m_cMdiModeWindowSize ); - setVisible( true ); } m_iWindowMode = iWindowMode; tileSubWindows(); diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index a3c7b2a..ba0bc4d 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -39,6 +39,12 @@ Void PlotSubWindow::definePlotColors() m_arrayColorList.append( Qt::yellow ); m_arrayColorList.append( Qt::gray ); m_arrayColorList.append( Qt::darkRed ); + m_arrayColorList.append( Qt::darkGreen ); + m_arrayColorList.append( Qt::darkRed ); + m_arrayColorList.append( Qt::darkBlue ); + m_arrayColorList.append( Qt::darkMagenta ); + m_arrayColorList.append( Qt::darkCyan ); + m_arrayColorList.append( Qt::darkYellow ); } PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) : From 148981528de0b666334da7da07d5cf1e367cabf0 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Thu, 9 Apr 2015 17:08:41 +0100 Subject: [PATCH 83/94] Fix wrong label in configure dialog and complete the save of the last window mode --- app/ConfigureFormatDialog.cpp | 14 ++++++------ app/PlaYUVerApp.cpp | 2 ++ app/PlaYUVerSubWindowHandle.cpp | 38 +++++++++++++++++++++------------ app/PlaYUVerSubWindowHandle.h | 1 + lib/PlaYUVerFrame.cpp | 4 ++++ 5 files changed, 37 insertions(+), 22 deletions(-) diff --git a/app/ConfigureFormatDialog.cpp b/app/ConfigureFormatDialog.cpp index 8fdcdfd..ab3caf4 100644 --- a/app/ConfigureFormatDialog.cpp +++ b/app/ConfigureFormatDialog.cpp @@ -174,20 +174,18 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 ); pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 ); - /* - * Frame rate format - */ QHBoxLayout* bitsPerPelLayout = new QHBoxLayout(); QLabel* bitsPerPelLabel = new QLabel(); - bitsPerPelLabel->setFont( menusFont ); - bitsPerPelLabel->setText( "Frame Rate" ); + bitsPerPelLabel->setFont( normalFont ); + bitsPerPelLabel->setText( "Pixel bit depth" ); m_spinBoxBits = new QSpinBox(); + m_spinBoxBits->setFont( normalFont ); m_spinBoxBits->setMinimumWidth( 30 ); m_spinBoxBits->setRange( 0, 16 ); m_spinBoxBits->setValue( 8 ); - bitsPerPelLayout->addWidget( bitsPerPelLabel ); - bitsPerPelLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - bitsPerPelLayout->addWidget( m_spinBoxBits ); + pixelGridLayout->addWidget( bitsPerPelLabel, 2, 0 ); + pixelGridLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 2, 1 ); + pixelGridLayout->addWidget( m_spinBoxBits, 2, 2 ); /* * Frame rate format diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index e618a47..8a3e74c 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -929,6 +929,7 @@ Void plaYUVerApp::readSettings() m_appModuleVideo->readSettings(); m_appModuleQuality->readSettings(); m_appModuleExtensions->readSettings(); + m_pcWindowHandle->readSettings(); } Void plaYUVerApp::writeSettings() @@ -947,6 +948,7 @@ Void plaYUVerApp::writeSettings() m_appModuleVideo->writeSettings(); m_appModuleQuality->writeSettings(); m_appModuleExtensions->writeSettings(); + m_pcWindowHandle->writeSettings(); } } // NAMESPACE diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index d37ff26..117f171 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -59,14 +59,15 @@ private: PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : QWidget( parent ) { - m_iWindowMode = 0; - - //setWindowMode( NormalSubWindows ); - setWindowMode( MdiWSubWindows ); - + m_iWindowMode = -1; + m_pcWindowManagerLayout = NULL; + m_pcMdiArea = NULL; m_pcActiveWindow = NULL; m_apcSubWindowList.clear(); m_apcMdiSubWindowList.clear(); + + //setWindowMode( NormalSubWindows ); + setWindowMode( MdiWSubWindows ); } Void PlaYUVerSubWindowHandle::resetWindowMode() @@ -95,6 +96,7 @@ Void PlaYUVerSubWindowHandle::resetWindowMode() delete m_pcMdiArea; if( m_pcWindowManagerLayout ) delete m_pcWindowManagerLayout; + } } @@ -349,25 +351,25 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions.resize( TOTAL_ACT ); // ------------ Tools ------------ - QActionGroup* actionGroupWindowMode = new QActionGroup( this ); - actionGroupWindowMode->setExclusive( true ); + m_actionGroupWindowMode = new QActionGroup( this ); + m_actionGroupWindowMode->setExclusive( true ); m_mapperWindowMode = new QSignalMapper( this ); connect( m_mapperWindowMode, SIGNAL( mapped(int) ), this, SLOT( setWindowMode(int) ) ); m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] = new QAction( tr( "&Detached SubWindows" ), this ); m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT]->setCheckable( true ); - actionGroupWindowMode->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); + m_actionGroupWindowMode->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); connect( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); - m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], ViewArea::NavigationTool ); + m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], NormalSubWindows ); m_arrayActions[MDI_SUBWINDOW_MODE_ACT] = new QAction( "&MDI SubWindows", this ); m_arrayActions[MDI_SUBWINDOW_MODE_ACT]->setCheckable( true ); - actionGroupWindowMode->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] ); + m_actionGroupWindowMode->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] ); connect( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); - m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], ViewArea::NormalSelectionTool ); + m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], MdiWSubWindows ); - actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true ); + m_actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true ); m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this ); m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) ); @@ -472,12 +474,20 @@ Void PlaYUVerSubWindowHandle::updateMenu() Void PlaYUVerSubWindowHandle::readSettings() { - + QSettings appSettings; + m_cMdiModeWindowPosition = appSettings.value( "SubWindowManager/LastMdiPosition", QPoint( 200, 200 ) ).toPoint(); + m_cMdiModeWindowSize = appSettings.value( "SubWindowManager/LastMdiSize", QSize( 500, 400 ) ).toSize(); + Int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MdiWSubWindows ).toInt(); + setWindowMode( iWindowMode ); + m_actionGroupWindowMode->actions().at( iWindowMode )->setChecked( true ); } Void PlaYUVerSubWindowHandle::writeSettings() { - + QSettings appSettings; + appSettings.setValue( "SubWindowManager/LastMdiPosition", m_cMdiModeWindowPosition ); + appSettings.setValue( "SubWindowManager/LastMdiSize", m_cMdiModeWindowSize ); + appSettings.setValue( "SubWindowManager/SubWindowMode", m_iWindowMode ); } } // NAMESPACE diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 93874b6..1070e52 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -95,6 +95,7 @@ private: }; QVector m_arrayActions; QSignalMapper* m_mapperWindowMode; + QActionGroup* m_actionGroupWindowMode; QSignalMapper* m_mapperWindow; QMenu* m_pcMenuWindow; diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 2137464..ef90a67 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -241,11 +241,15 @@ UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelF UInt PlaYUVerFrame::getChromaWidth() const { + if( m_pcPelFormat->colorSpace == GRAY ) + return 0; return CHROMASHIFT( m_uiWidth, m_pcPelFormat->log2ChromaWidth ); } UInt PlaYUVerFrame::getChromaHeight() const { + if( m_pcPelFormat->colorSpace == GRAY ) + return 0; return CHROMASHIFT( m_uiHeight, m_pcPelFormat->log2ChromaHeight ); } From a4b140c7c8734342a8b507a2aa4ba8681b570eb1 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 10 Apr 2015 01:57:42 +0100 Subject: [PATCH 84/94] Rename some class and files --- app/CMakeLists.txt | 4 +- app/DialogSubWindowSelector.cpp | 4 +- app/DialogSubWindowSelector.h | 10 +- ...iesSidebar.cpp => FramePropertiesDock.cpp} | 40 +++--- ...pertiesSidebar.h => FramePropertiesDock.h} | 14 +-- app/ModulesHandle.cpp | 7 +- app/PlaYUVerApp.cpp | 114 ++++++++++-------- app/PlaYUVerApp.h | 32 +++-- app/PlaYUVerAppAdaptor.cpp | 2 +- app/PlaYUVerAppAdaptor.h | 6 +- app/PlaYUVerAppModuleIf.cpp | 1 + app/PlaYUVerMdiSubWindow.cpp | 5 +- app/PlaYUVerMdiSubWindow.h | 7 +- app/PlaYUVerSubWindowHandle.cpp | 44 +++---- app/PlaYUVerSubWindowHandle.h | 22 ++-- app/PlotSubWindow.cpp | 2 +- app/PlotSubWindow.h | 6 +- app/QualityHandle.cpp | 6 +- app/QualityMeasurementSidebar.cpp | 2 +- ...WindowHandle.cpp => SubWindowAbstract.cpp} | 43 ++++--- ...{SubWindowHandle.h => SubWindowAbstract.h} | 36 +++--- app/VideoHandle.cpp | 35 ++++-- app/VideoHandle.h | 26 ++-- app/VideoSubWindow.cpp | 6 +- app/VideoSubWindow.h | 17 ++- app/main.cpp | 10 +- lib/LibAvContextHandle.cpp | 14 +-- 27 files changed, 275 insertions(+), 240 deletions(-) rename app/{FramePropertiesSidebar.cpp => FramePropertiesDock.cpp} (94%) rename app/{FramePropertiesSidebar.h => FramePropertiesDock.h} (91%) rename app/{SubWindowHandle.cpp => SubWindowAbstract.cpp} (82%) rename app/{SubWindowHandle.h => SubWindowAbstract.h} (87%) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 6f4c803..7eccdda 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -48,13 +48,13 @@ set(plaYUVer_App_SRCS PlaYUVerApp.cpp PlaYUVerSubWindowHandle.cpp PlaYUVerMdiSubWindow.cpp - SubWindowHandle.cpp + SubWindowAbstract.cpp Settings.cpp # Module Video VideoSubWindow.cpp ViewArea.cpp VideoHandle.cpp - FramePropertiesSidebar.cpp + FramePropertiesDock.cpp # Module Quality QualityHandle.cpp QualityMeasurementSidebar.cpp diff --git a/app/DialogSubWindowSelector.cpp b/app/DialogSubWindowSelector.cpp index d340242..fd9a644 100644 --- a/app/DialogSubWindowSelector.cpp +++ b/app/DialogSubWindowSelector.cpp @@ -84,7 +84,7 @@ DialogSubWindowSelector::DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWi m_mapperWindowsList = new QSignalMapper( this ); connect( m_mapperWindowsList, SIGNAL( mapped(int) ), this, SLOT( toggleSubWindow(int) ) ); - SubWindowHandle *subWindow; + SubWindowAbstract *subWindow; QString currSubWindowName; QCheckBox* windowCheckBox; m_apcSubWindowList = m_pcMainWindowManager->findSubWindow( m_uiCategory ); @@ -143,7 +143,7 @@ Void DialogSubWindowSelector::updateSubWindowList() // << m_apcSelectedSubWindowList.size(); } -Void DialogSubWindowSelector::selectSubWindow( SubWindowHandle * subWindow ) +Void DialogSubWindowSelector::selectSubWindow( SubWindowAbstract * subWindow ) { Int iIdx = m_apcSubWindowList.indexOf( subWindow ); if( iIdx >= 0 ) diff --git a/app/DialogSubWindowSelector.h b/app/DialogSubWindowSelector.h index eb1fa7c..619b508 100644 --- a/app/DialogSubWindowSelector.h +++ b/app/DialogSubWindowSelector.h @@ -45,7 +45,7 @@ namespace plaYUVer { class PlaYUVerSubWindowHandle; -class SubWindowHandle; +class SubWindowAbstract; /** * Class to define the dialog box to select sub windows @@ -58,8 +58,8 @@ Q_OBJECT public: DialogSubWindowSelector( QWidget *parent, PlaYUVerSubWindowHandle *windowManager, UInt uiCategory, Int minWindowsSelected = 1, Int maxWindowsSelected = -1 ); - Void selectSubWindow( SubWindowHandle* subWindow ); - QList getSelectedWindows() + Void selectSubWindow( SubWindowAbstract* subWindow ); + QList getSelectedWindows() { return m_apcSelectedSubWindowList; } @@ -69,8 +69,8 @@ private: Int m_iMaxSlectedWindows; PlaYUVerSubWindowHandle* m_pcMainWindowManager; - QList m_apcSubWindowList; - QList m_apcSelectedSubWindowList; + QList m_apcSubWindowList; + QList m_apcSelectedSubWindowList; QSignalMapper* m_mapperWindowsList; QGroupBox* m_pcGroupCheckBox; diff --git a/app/FramePropertiesSidebar.cpp b/app/FramePropertiesDock.cpp similarity index 94% rename from app/FramePropertiesSidebar.cpp rename to app/FramePropertiesDock.cpp index bd271f3..dfa2c33 100644 --- a/app/FramePropertiesSidebar.cpp +++ b/app/FramePropertiesDock.cpp @@ -18,19 +18,19 @@ */ /** - * \file FramePropertiesSideBar.cpp + * \file FramePropertiesDock.cpp * \brief Main side bar definition */ #include #include #include -#include "FramePropertiesSidebar.h" +#include "FramePropertiesDock.h" namespace plaYUVer { -FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPlaySwitch ) : +FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ) : QWidget( parent ), pbMainPlaySwitch( pbMainPlaySwitch ) { @@ -242,7 +242,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPla } -FramePropertiesSideBar::~FramePropertiesSideBar() +FramePropertiesDock::~FramePropertiesDock() { // If there is a currently histogram computation when dialog is closed, // stop it before the image data are deleted automatically! @@ -251,7 +251,7 @@ FramePropertiesSideBar::~FramePropertiesSideBar() delete histogramWidget; } -QSize FramePropertiesSideBar::sizeHint() const +QSize FramePropertiesDock::sizeHint() const { QSize currSize = size(); QSize bestSize( 180, currSize.height() ); @@ -260,7 +260,7 @@ QSize FramePropertiesSideBar::sizeHint() const return currSize; } -Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) +Void FramePropertiesDock::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) { m_pbIsPlaying = isPlaying; if( !pcFrame ) @@ -348,7 +348,7 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) } } -Void FramePropertiesSideBar::setSelection( const QRect &selectionArea ) +Void FramePropertiesDock::setSelection( const QRect &selectionArea ) { // This is necessary to stop computation because image.bits() is // currently used by threaded histogram algorithm. @@ -376,7 +376,7 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea ) } } -Void FramePropertiesSideBar::updateDataHistogram() +Void FramePropertiesDock::updateDataHistogram() { if( m_pcFrame->isValid() && isVisible() ) { @@ -403,7 +403,7 @@ Void FramePropertiesSideBar::updateDataHistogram() } } -Void FramePropertiesSideBar::updateStatistiques() +Void FramePropertiesDock::updateStatistiques() { QString value; @@ -444,7 +444,7 @@ Void FramePropertiesSideBar::updateStatistiques() } } -Void FramePropertiesSideBar::stopHistogram() +Void FramePropertiesDock::stopHistogram() { histogramWidget->stopHistogramComputation(); } @@ -453,7 +453,7 @@ Void FramePropertiesSideBar::stopHistogram() // SLOTS //////////////////////////////////////////////////////////////////////////////// -Void FramePropertiesSideBar::slotRefreshOptions( int range ) +Void FramePropertiesDock::slotRefreshOptions( int range ) { if( !isVisible() ) return; @@ -476,12 +476,12 @@ Void FramePropertiesSideBar::slotRefreshOptions( int range ) } } -Void FramePropertiesSideBar::slotHistogramComputationFailed() +Void FramePropertiesDock::slotHistogramComputationFailed() { m_pcFrame = NULL; } -Void FramePropertiesSideBar::slotChannelChanged( Int channel ) +Void FramePropertiesDock::slotChannelChanged( Int channel ) { if( m_pcFrame->getColorSpace() == PlaYUVerFrame::COLOR_YUV ) channel += 1; @@ -519,13 +519,13 @@ Void FramePropertiesSideBar::slotChannelChanged( Int channel ) updateStatistiques(); } -Void FramePropertiesSideBar::slotScaleChanged( Int scale ) +Void FramePropertiesDock::slotScaleChanged( Int scale ) { histogramWidget->m_scaleType = scale; histogramWidget->update(); } -Void FramePropertiesSideBar::slotColorsChanged( Int color ) +Void FramePropertiesDock::slotColorsChanged( Int color ) { switch( color ) { @@ -544,14 +544,14 @@ Void FramePropertiesSideBar::slotColorsChanged( Int color ) updateStatistiques(); } -Void FramePropertiesSideBar::slotRenderingChanged( Int rendering ) +Void FramePropertiesDock::slotRenderingChanged( Int rendering ) { histogramWidget->m_renderingType = rendering; histogramWidget->update(); updateStatistiques(); } -Void FramePropertiesSideBar::slotMinValueChanged( Int min ) +Void FramePropertiesDock::slotMinValueChanged( Int min ) { // Called when user changes values of spin box. // Communicate the change to histogram widget. @@ -565,7 +565,7 @@ Void FramePropertiesSideBar::slotMinValueChanged( Int min ) updateStatistiques(); } -Void FramePropertiesSideBar::slotMaxValueChanged( Int max ) +Void FramePropertiesDock::slotMaxValueChanged( Int max ) { if( max == minInterv->value() - 1 ) minInterv->setValue( max ); @@ -575,7 +575,7 @@ Void FramePropertiesSideBar::slotMaxValueChanged( Int max ) updateStatistiques(); } -Void FramePropertiesSideBar::slotUpdateInterval( Int min, Int max ) +Void FramePropertiesDock::slotUpdateInterval( Int min, Int max ) { // Called when value is set from within histogram widget. // Block signals to prevent slotMinValueChanged and @@ -593,7 +593,7 @@ Void FramePropertiesSideBar::slotUpdateInterval( Int min, Int max ) updateStatistiques(); } -Void FramePropertiesSideBar::slotUpdateIntervRange( Int range ) +Void FramePropertiesDock::slotUpdateIntervRange( Int range ) { maxInterv->blockSignals( true ); maxInterv->setMaximum( range ); diff --git a/app/FramePropertiesSidebar.h b/app/FramePropertiesDock.h similarity index 91% rename from app/FramePropertiesSidebar.h rename to app/FramePropertiesDock.h index 7120acf..dbb34ad 100644 --- a/app/FramePropertiesSidebar.h +++ b/app/FramePropertiesDock.h @@ -18,12 +18,12 @@ */ /** - * \file FramePropertiesSidebar.h + * \file FramePropertiesDock.h * \brief Main side bar definition */ -#ifndef __FRAMEPROPERTIESSIDEBAR_H__ -#define __FRAMEPROPERTIESSIDEBAR_H__ +#ifndef __FRAMEPROPERTIESDOCK_H__ +#define __FRAMEPROPERTIESDOCK_H__ #include "config.h" #include "PlaYUVerAppDefs.h" @@ -40,12 +40,12 @@ namespace plaYUVer { -class FramePropertiesSideBar: public QWidget +class FramePropertiesDock: public QWidget { Q_OBJECT public: - FramePropertiesSideBar( QWidget* parent, Bool* pbMainPlaySwitch ); - ~FramePropertiesSideBar(); + FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitch ); + ~FramePropertiesDock(); QSize sizeHint() const; @@ -132,4 +132,4 @@ private Q_SLOTS: } // NAMESPACE -#endif // __FRAMEPROPERTIESSIDEBAR_H__ +#endif // __FRAMEPROPERTIESDOCK_H__ diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index c051662..d2ff4b0 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -25,6 +25,7 @@ #include #include "ModulesHandle.h" #include "PlaYUVerSubWindowHandle.h" +#include "VideoSubWindow.h" #include "VideoHandle.h" #include "PlaYUVerModuleFactory.h" #include "DialogSubWindowSelector.h" @@ -251,8 +252,8 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) Int numberOfFrames = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames; if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { - DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowHandle::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); - QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowAbstract::VIDEO_SUBWINDOW, numberOfFrames, numberOfFrames ); + QList windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); if( windowsList.size() <= numberOfFrames ) { @@ -269,7 +270,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( dialogWindowsSelection.exec() == QDialog::Accepted ) { VideoSubWindow *videoSubWindow; - QList subWindowList = dialogWindowsSelection.getSelectedWindows(); + QList subWindowList = dialogWindowsSelection.getSelectedWindows(); for( Int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 8a3e74c..298179c 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -19,16 +19,26 @@ /** * \file PlaYUVerApp.cpp - * \brief Main definition of the plaYUVerApp app + * \brief Main definition of the PlaYUVerApp app */ #include +#include +#include +#include +#include +#include +#include +#include #include "PlaYUVerApp.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif #include "lib/PlaYUVerCmdParser.h" #include "PlaYUVerSubWindowHandle.h" +#include "AboutDialog.h" +#include "SubWindowAbstract.h" +#include "VideoSubWindow.h" #include "VideoHandle.h" #include "QualityHandle.h" #include "ModulesHandle.h" @@ -39,7 +49,7 @@ namespace plaYUVer { -plaYUVerApp::plaYUVerApp() : +PlaYUVerApp::PlaYUVerApp() : m_pcCurrentSubWindow( NULL ), m_pcCurrentVideoSubWindow( NULL ), m_pcAboutDialog( NULL ) @@ -83,7 +93,7 @@ plaYUVerApp::plaYUVerApp() : } -Bool plaYUVerApp::parseArgs( Int argc, Char *argv[] ) +Bool PlaYUVerApp::parseArgs( Int argc, Char *argv[] ) { Bool bRet = false; m_pcCmdParser = new PlaYUVerCmdParser(); @@ -126,19 +136,19 @@ Bool plaYUVerApp::parseArgs( Int argc, Char *argv[] ) return bRet; } -Void plaYUVerApp::about() +Void PlaYUVerApp::about() { if( !m_pcAboutDialog ) m_pcAboutDialog = new AboutDialog( this ); m_pcAboutDialog->exec(); } -Void plaYUVerApp::closeEvent( QCloseEvent *event ) +Void PlaYUVerApp::closeEvent( QCloseEvent *event ) { Int mayCloseAll = true; Int msgBoxCloseRet = QMessageBox::Yes; - QList subWindowList = m_pcWindowHandle->findSubWindow(); + QList subWindowList = m_pcWindowHandle->findSubWindow(); if( subWindowList.size() >= 1 ) { QMessageBox msgBoxClose( QMessageBox::Question, "PlaYUVer", "There are open files!", QMessageBox::Yes | QMessageBox::No, this ); @@ -173,26 +183,26 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) } } -Void plaYUVerApp::closeAll() +Void PlaYUVerApp::closeAll() { m_pcWindowHandle->removeAllSubWindow(); } -Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) +Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) { if( !QFileInfo( fileName ).exists() ) { statusBar()->showMessage( "File " + fileName + " do not exist!", 2000 ); return; } - VideoSubWindow *videoSubWindow = plaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); + VideoSubWindow *videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); if( videoSubWindow ) { m_pcWindowHandle->setActiveSubWindow( videoSubWindow ); return; } videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); //createSubWindow(); - SubWindowHandle *subWindow = videoSubWindow; + SubWindowAbstract *subWindow = videoSubWindow; if( !pStreamInfo ) { Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, fileName ); @@ -216,7 +226,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) ); - connect( subWindow, SIGNAL( aboutToClose( SubWindowHandle* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowHandle* ) ) ); + connect( subWindow, SIGNAL( aboutToClose( SubWindowAbstract* ) ), m_appModuleVideo, SLOT( closeSubWindow( SubWindowAbstract* ) ) ); connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo, SLOT( zoomToFactorAll( double, QPoint ) ) ); connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) ); @@ -246,7 +256,7 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) // ----------------------- File Functions ----------------------- -Void plaYUVerApp::open() +Void PlaYUVerApp::open() { QString supported = tr( "Supported Files (" ); QStringList formatsList; @@ -282,7 +292,7 @@ Void plaYUVerApp::open() } } -Void plaYUVerApp::openRecent() +Void PlaYUVerApp::openRecent() { QAction *action = qobject_cast( sender() ); PlaYUVerStreamInfo recentFile = action->data().value(); @@ -290,7 +300,7 @@ Void plaYUVerApp::openRecent() loadFile( recentFile.m_cFilename, &recentFile ); } -Void plaYUVerApp::save() +Void PlaYUVerApp::save() { if( m_pcCurrentVideoSubWindow ) { @@ -333,7 +343,7 @@ Void plaYUVerApp::save() } } -Void plaYUVerApp::format() +Void PlaYUVerApp::format() { if( m_pcCurrentVideoSubWindow ) { @@ -358,7 +368,7 @@ Void plaYUVerApp::format() } } -Void plaYUVerApp::reload() +Void PlaYUVerApp::reload() { if( m_pcCurrentSubWindow ) { @@ -368,17 +378,17 @@ Void plaYUVerApp::reload() } } -Void plaYUVerApp::reloadAll() +Void PlaYUVerApp::reloadAll() { UInt windowCategoryOrder[] = { - SubWindowHandle::VIDEO_STREAM_SUBWINDOW, - SubWindowHandle::MODULE_SUBWINDOW, - SubWindowHandle::MODULE_SUBWINDOW }; + SubWindowAbstract::VIDEO_STREAM_SUBWINDOW, + SubWindowAbstract::MODULE_SUBWINDOW, + SubWindowAbstract::MODULE_SUBWINDOW }; for( UInt c = 0; c < 3; c++ ) { - QList subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] ); + QList subWindowList = m_pcWindowHandle->findSubWindow( windowCategoryOrder[c] ); for( Int i = 0; i < subWindowList.size(); i++ ) { subWindowList.at( i )->refreshSubWindow(); @@ -388,7 +398,7 @@ Void plaYUVerApp::reloadAll() update(); } -Void plaYUVerApp::loadAll() +Void PlaYUVerApp::loadAll() { if( m_pcCurrentVideoSubWindow ) { @@ -398,11 +408,11 @@ Void plaYUVerApp::loadAll() } } -Void plaYUVerApp::setTool( Int idxTool ) +Void PlaYUVerApp::setTool( Int idxTool ) { m_uiViewTool = idxTool; actionGroupTools->actions().at( m_uiViewTool )->setChecked( true ); - QList subWindowList = m_pcWindowHandle->findSubWindow(); + QList subWindowList = m_pcWindowHandle->findSubWindow(); for( Int i = 0; i < subWindowList.size(); i++ ) { subWindowList.at( i )->setTool( m_uiViewTool ); @@ -411,7 +421,7 @@ Void plaYUVerApp::setTool( Int idxTool ) // ----------------------- Zoom Functions ----------------------- -Void plaYUVerApp::normalSize() +Void PlaYUVerApp::normalSize() { if( m_pcCurrentSubWindow ) { @@ -420,7 +430,7 @@ Void plaYUVerApp::normalSize() } } -Void plaYUVerApp::zoomToFit() +Void PlaYUVerApp::zoomToFit() { if( m_pcCurrentSubWindow ) { @@ -429,10 +439,10 @@ Void plaYUVerApp::zoomToFit() } } -Void plaYUVerApp::zoomToFitAll() +Void PlaYUVerApp::zoomToFitAll() { VideoSubWindow *videoSubWindow; - QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + QList subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { videoSubWindow = qobject_cast( subWindowList.at( i ) ); @@ -443,7 +453,7 @@ Void plaYUVerApp::zoomToFitAll() updateZoomFactorSBox(); } -Void plaYUVerApp::scaleFrame( int ratio ) +Void PlaYUVerApp::scaleFrame( int ratio ) { if( m_pcCurrentSubWindow ) { @@ -452,9 +462,9 @@ Void plaYUVerApp::scaleFrame( int ratio ) } } -Void plaYUVerApp::zoomFromSBox( double zoom ) +Void PlaYUVerApp::zoomFromSBox( double zoom ) { - SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow(); + SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow(); Double factor = zoom / 100; if( activeSubWindow ) { @@ -462,7 +472,7 @@ Void plaYUVerApp::zoomFromSBox( double zoom ) } } -Void plaYUVerApp::updateZoomFactorSBox() +Void PlaYUVerApp::updateZoomFactorSBox() { Double factor; if( m_pcCurrentSubWindow ) @@ -474,14 +484,14 @@ Void plaYUVerApp::updateZoomFactorSBox() // ----------------------- Drag and drop functions ---------------------- -Void plaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) +Void PlaYUVerApp::dragEnterEvent( QDragEnterEvent *event ) { //setText(tr("")); //mdiArea->setBackgroundRole( QPalette::Highlight ); event->acceptProposedAction(); } -Void plaYUVerApp::dropEvent( QDropEvent *event ) +Void PlaYUVerApp::dropEvent( QDropEvent *event ) { const QMimeData *mimeData = event->mimeData(); QList urlList = mimeData->urls(); @@ -495,11 +505,11 @@ Void plaYUVerApp::dropEvent( QDropEvent *event ) // ----------------------- Sub Window Functions ----------------------- -VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName ) +VideoSubWindow* PlaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHandle* windowManager, const QString& fileName ) { QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); VideoSubWindow* pcSubWindow; - QList subWindowList = windowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + QList subWindowList = windowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { pcSubWindow = qobject_cast( subWindowList.at( i ) ); @@ -511,9 +521,9 @@ VideoSubWindow* plaYUVerApp::findVideoStreamSubWindow( const PlaYUVerSubWindowHa // ----------------------- Update Functions ----------------------- -Void plaYUVerApp::update() +Void PlaYUVerApp::update() { - SubWindowHandle *activeSubWindow = m_pcWindowHandle->activeSubWindow(); + SubWindowAbstract *activeSubWindow = m_pcWindowHandle->activeSubWindow(); QCoreApplication::processEvents(); //if( activeSubWindow() != m_pcCurrentSubWindow ) { @@ -523,7 +533,7 @@ Void plaYUVerApp::update() { m_pcCurrentSubWindow = activeSubWindow; - if( m_pcCurrentSubWindow->getCategory() & SubWindowHandle::VIDEO_SUBWINDOW ) + if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_SUBWINDOW ) { m_pcCurrentVideoSubWindow = qobject_cast( m_pcCurrentSubWindow ); } @@ -543,7 +553,7 @@ Void plaYUVerApp::update() updateMenus(); } -Void plaYUVerApp::updateStatusBar( const QString& statusBarString ) +Void PlaYUVerApp::updateStatusBar( const QString& statusBarString ) { if( !statusBarString.isEmpty() ) { @@ -555,13 +565,13 @@ Void plaYUVerApp::updateStatusBar( const QString& statusBarString ) } } -Void plaYUVerApp::updateMenus() +Void PlaYUVerApp::updateMenus() { Bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 ); Bool hasVideoStreamSubWindow = false; if( m_pcCurrentSubWindow ) - if( m_pcCurrentSubWindow->getCategory() & SubWindowHandle::VIDEO_STREAM_SUBWINDOW ) + if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ) hasVideoStreamSubWindow = true; m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false ); @@ -592,7 +602,7 @@ Void plaYUVerApp::updateMenus() // ----------------------- Create Functions ----------------------- -Void plaYUVerApp::createActions() +Void PlaYUVerApp::createActions() { m_arrayActions.resize( TOTAL_ACT ); @@ -732,7 +742,7 @@ Void plaYUVerApp::createActions() connect( m_arrayActions[ABOUTQT_ACT], SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) ); } -Void plaYUVerApp::createMenus() +Void PlaYUVerApp::createMenus() { m_arrayMenu.resize( TOTAL_MENUS ); @@ -800,7 +810,7 @@ Void plaYUVerApp::createMenus() } -Void plaYUVerApp::createToolBars() +Void PlaYUVerApp::createToolBars() { m_arrayToolBars.resize( TOTAL_TOOLBAR ); @@ -835,7 +845,7 @@ Void plaYUVerApp::createToolBars() } -Void plaYUVerApp::createDockWidgets() +Void PlaYUVerApp::createDockWidgets() { // Properties Dock Window m_arraySideBars.resize( TOTAL_DOCK ); @@ -843,14 +853,14 @@ Void plaYUVerApp::createDockWidgets() addDockWidget( Qt::RightDockWidgetArea, m_appModuleQuality->createDock() ); } -Void plaYUVerApp::createStatusBar() +Void PlaYUVerApp::createStatusBar() { //! Warning: the following widget cannot change size too much statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); statusBar()->showMessage( tr( "Ready" ) ); } -Void plaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) +Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) { Int idx = findPlaYUVerStreamInfo( m_aRecentFileStreamInfo, streamInfo.m_cFilename ); if( idx >= 0 ) @@ -861,7 +871,7 @@ Void plaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) updateRecentFileActions(); } -Void plaYUVerApp::updateRecentFileActions() +Void PlaYUVerApp::updateRecentFileActions() { Int numRecentFiles = m_aRecentFileStreamInfo.size(); numRecentFiles = qMin( numRecentFiles, MAX_RECENT_FILES ); @@ -884,7 +894,7 @@ Void plaYUVerApp::updateRecentFileActions() m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false ); } -Void plaYUVerApp::checkRecentFileActions() +Void PlaYUVerApp::checkRecentFileActions() { Int i = 0; while( i < m_aRecentFileStreamInfo.size() ) @@ -907,7 +917,7 @@ Void plaYUVerApp::checkRecentFileActions() } } -Void plaYUVerApp::readSettings() +Void PlaYUVerApp::readSettings() { QSettings appSettings; @@ -932,7 +942,7 @@ Void plaYUVerApp::readSettings() m_pcWindowHandle->readSettings(); } -Void plaYUVerApp::writeSettings() +Void PlaYUVerApp::writeSettings() { QSettings appSettings; diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index c980297..8160ed1 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -20,7 +20,7 @@ /** * \file PlaYUVerApp.h * \ingroup PlaYUVerApp - * \brief Main definition of the plaYUVerApp app + * \brief Main definition of the PlaYUVerApp app * * @defgroup PlaYUVerApp PlaYUVer App (GUI) * @{ @@ -37,21 +37,23 @@ #define __PLAYUVERAPP_H__ #include "config.h" +#include +#include +#include #include "PlaYUVerAppDefs.h" -#if( QT_VERSION_PLAYUVER == 5 ) -#include -#elif( QT_VERSION_PLAYUVER == 4 ) -#include -#endif #ifdef USE_QTDBUS #include "PlaYUVerAppAdaptor.h" #endif -#include - -#include "SubWindowHandle.h" -#include "AboutDialog.h" #include "VideoSubWindow.h" +class QCloseEvent; +class QDragEnterEvent; +class QDropEvent; +class QDoubleSpinBox; +class QActionGroup; +class QAction; +class QSignalMapper; + namespace plaYUVer { @@ -62,13 +64,16 @@ class VideoHandle; class QualityHandle; class ModulesHandle; class PlaYUVerAppAdaptor; +class VideoSubWindow; +class SubWindowAbstract; +class AboutDialog; -class plaYUVerApp: public QMainWindow +class PlaYUVerApp: public QMainWindow { Q_OBJECT public: - plaYUVerApp(); + PlaYUVerApp(); Bool parseArgs( Int argc, Char *argv[] ); Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); @@ -118,7 +123,7 @@ private: /** * Save the current subwindow for every category */ - SubWindowHandle* m_pcCurrentSubWindow; //!< General always set + SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set VideoSubWindow* m_pcCurrentVideoSubWindow; QString m_cLastOpenPath; @@ -247,3 +252,4 @@ private: } // NAMESPACE #endif // __PLAYUVERAPP_H__ + diff --git a/app/PlaYUVerAppAdaptor.cpp b/app/PlaYUVerAppAdaptor.cpp index fb40288..ff1d86d 100644 --- a/app/PlaYUVerAppAdaptor.cpp +++ b/app/PlaYUVerAppAdaptor.cpp @@ -29,7 +29,7 @@ namespace plaYUVer { -PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( plaYUVerApp *app ) : +PlaYUVerAppAdaptor::PlaYUVerAppAdaptor( PlaYUVerApp *app ) : QDBusAbstractAdaptor( app ), m_app( app ) { diff --git a/app/PlaYUVerAppAdaptor.h b/app/PlaYUVerAppAdaptor.h index 4210724..ae64e69 100644 --- a/app/PlaYUVerAppAdaptor.h +++ b/app/PlaYUVerAppAdaptor.h @@ -38,7 +38,7 @@ namespace plaYUVer #define PLAYUVER_DBUS_SESSION_NAME "org.pixlra.PlaYUVer.application" #define PLAYUVER_DBUS_PATH "/MainApplication" -class plaYUVerApp; +class PlaYUVerApp; class PlaYUVerAppAdaptor: public QDBusAbstractAdaptor { @@ -46,7 +46,7 @@ Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.pixlra.PlaYUVer.application") Q_PROPERTY(QString activeSession READ activeSession) public: - PlaYUVerAppAdaptor( plaYUVerApp *app ); + PlaYUVerAppAdaptor( PlaYUVerApp *app ); ~PlaYUVerAppAdaptor(); /** * emit the exiting signal @@ -78,7 +78,7 @@ Q_SIGNALS: public: QString activeSession(); private: - plaYUVerApp *m_app; + PlaYUVerApp *m_app; }; } // NAMESPACE diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index 9428850..1732cf9 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -24,6 +24,7 @@ #include "PlaYUVerAppModuleIf.h" #include "VideoSubWindow.h" +#include "VideoSubWindow.h" namespace plaYUVer { diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/PlaYUVerMdiSubWindow.cpp index e29348f..e84d946 100644 --- a/app/PlaYUVerMdiSubWindow.cpp +++ b/app/PlaYUVerMdiSubWindow.cpp @@ -22,8 +22,9 @@ * \brief Re-implementation QMdiSubWindow */ +#include #include "PlaYUVerMdiSubWindow.h" -#include "SubWindowHandle.h" +#include "SubWindowAbstract.h" namespace plaYUVer { @@ -38,7 +39,7 @@ QSize PlaYUVerMdiSubWindow::sizeHint() const QSize maxSize; if( parent() ) maxSize = parentWidget()->size(); - QSize sizeHint = qobject_cast( widget() )->sizeHint( maxSize ); + QSize sizeHint = qobject_cast( widget() )->sizeHint( maxSize ); return sizeHint; } diff --git a/app/PlaYUVerMdiSubWindow.h b/app/PlaYUVerMdiSubWindow.h index 5b78920..6982339 100644 --- a/app/PlaYUVerMdiSubWindow.h +++ b/app/PlaYUVerMdiSubWindow.h @@ -27,11 +27,8 @@ #include "config.h" #include "PlaYUVerAppDefs.h" -#if( QT_VERSION_PLAYUVER == 5 ) -#include -#elif( QT_VERSION_PLAYUVER == 4 ) -#include -#endif +#include + namespace plaYUVer { diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 117f171..275bf78 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -25,7 +25,7 @@ #include "PlaYUVerApp.h" #include "PlaYUVerSubWindowHandle.h" #include "PlaYUVerMdiSubWindow.h" -#include "SubWindowHandle.h" +#include "SubWindowAbstract.h" namespace plaYUVer { @@ -72,7 +72,7 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : Void PlaYUVerSubWindowHandle::resetWindowMode() { - QList apcSubWindowList = m_apcSubWindowList; + QList apcSubWindowList = m_apcSubWindowList; if( m_iWindowMode == NormalSubWindows ) { @@ -146,7 +146,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) qApp->processEvents(); } -Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) +Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window ) { if( m_iWindowMode == NormalSubWindows ) { @@ -164,7 +164,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) if( mdiSubWindow ) { QWidget* activeWidget = m_pcMdiArea->activeSubWindow()->widget(); - Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) ); + Int windowIdx = m_apcSubWindowList.indexOf( qobject_cast( activeWidget ) ); if( windowIdx >= 0 ) { m_pcActiveWindow = m_apcSubWindowList.at( windowIdx ); @@ -180,7 +180,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowHandle *window ) } -Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowHandle *window ) +Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract *window ) { PlaYUVerMdiSubWindow* mdiSubWindow = new PlaYUVerMdiSubWindow; mdiSubWindow->setWidget( window ); @@ -190,17 +190,17 @@ Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowHandle *window ) connect( mdiSubWindow, SIGNAL( aboutToClose( PlaYUVerMdiSubWindow* ) ), this, SLOT( removeMdiSubWindow( PlaYUVerMdiSubWindow* ) ) ); } -Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowHandle *window, Qt::WindowFlags flags ) +Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::WindowFlags flags ) { if( window ) { - connect( window, SIGNAL( updateStatusBar( const QString& ) ), qobject_cast( parent() ), SLOT( updateStatusBar( const QString& ) ) ); - connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), qobject_cast( parent() ), + connect( window, SIGNAL( updateStatusBar( const QString& ) ), qobject_cast( parent() ), SLOT( updateStatusBar( const QString& ) ) ); + connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), qobject_cast( parent() ), SLOT( updateZoomFactorSBox() ) ); if( m_iWindowMode == NormalSubWindows ) { - connect( window, SIGNAL( aboutToActivate( SubWindowHandle* ) ), this, SLOT( updateActiveSubWindow( SubWindowHandle* ) ) ); - connect( window, SIGNAL( aboutToClose( SubWindowHandle* ) ), this, SLOT( removeSubWindow( SubWindowHandle* ) ) ); + connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this, SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) ); + connect( window, SIGNAL( aboutToClose( SubWindowAbstract* ) ), this, SLOT( removeSubWindow( SubWindowAbstract* ) ) ); } if( m_iWindowMode == MdiWSubWindows ) { @@ -216,7 +216,7 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) { if( m_iWindowMode == NormalSubWindows ) { - SubWindowHandle* subWindow = m_apcSubWindowList.at( windowIdx ); + SubWindowAbstract* subWindow = m_apcSubWindowList.at( windowIdx ); m_apcSubWindowList.removeAt( windowIdx ); subWindow->close(); } @@ -238,7 +238,7 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) } } -Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowHandle* window ) +Void PlaYUVerSubWindowHandle::removeSubWindow( SubWindowAbstract* window ) { removeSubWindow( m_apcSubWindowList.indexOf( window ) ); } @@ -261,14 +261,14 @@ Void PlaYUVerSubWindowHandle::removeActiveSubWindow() removeSubWindow( m_pcActiveWindow ); } -SubWindowHandle* PlaYUVerSubWindowHandle::activeSubWindow() const +SubWindowAbstract* PlaYUVerSubWindowHandle::activeSubWindow() const { return m_pcActiveWindow; } -QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const +QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCategory ) const { - QList apcSubWindowList; + QList apcSubWindowList; if( uiCategory == 0 ) { apcSubWindowList = m_apcSubWindowList; @@ -284,10 +284,10 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const UInt uiCat return apcSubWindowList; } -QList PlaYUVerSubWindowHandle::findSubWindow( const QString &windowName, const UInt uiCategory ) const +QList PlaYUVerSubWindowHandle::findSubWindow( const QString &windowName, const UInt uiCategory ) const { - QList subWindowList = findSubWindow( uiCategory ); - QList apcSubWindowList; + QList subWindowList = findSubWindow( uiCategory ); + QList apcSubWindowList; if( !windowName.isEmpty() ) { for( Int i = 0; i < subWindowList.size(); i++ ) @@ -299,9 +299,9 @@ QList PlaYUVerSubWindowHandle::findSubWindow( const QString &w return apcSubWindowList; } -SubWindowHandle* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowHandle* subWindow ) const +SubWindowAbstract* PlaYUVerSubWindowHandle::findSubWindow( const SubWindowAbstract* subWindow ) const { - QList subWindowList = findSubWindow(); + QList subWindowList = findSubWindow(); for( Int i = 0; i < subWindowList.size(); i++ ) { if( subWindow == subWindowList.at( i ) ) @@ -315,7 +315,7 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) if( !window ) return; - m_pcActiveWindow = qobject_cast( window ); + m_pcActiveWindow = qobject_cast( window ); if( m_iWindowMode == NormalSubWindows ) { @@ -453,7 +453,7 @@ Void PlaYUVerSubWindowHandle::updateMenu() for( Int i = 0; i < number_windows; ++i ) { - SubWindowHandle *subWindow = m_apcSubWindowList.at( i ); + SubWindowAbstract *subWindow = m_apcSubWindowList.at( i ); QString text; if( i < 9 ) diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 1070e52..0741f03 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -36,7 +36,7 @@ namespace plaYUVer { -class SubWindowHandle; +class SubWindowAbstract; class PlaYUVerMdiArea; class PlaYUVerMdiSubWindow; @@ -47,13 +47,13 @@ Q_OBJECT public: PlaYUVerSubWindowHandle( QWidget *parent ); - Void addSubWindow( SubWindowHandle *widget, Qt::WindowFlags flags = 0 ); + Void addSubWindow( SubWindowAbstract *widget, Qt::WindowFlags flags = 0 ); - SubWindowHandle *activeSubWindow() const; + SubWindowAbstract *activeSubWindow() const; - QList findSubWindow( const UInt uiCategory = 0 ) const; - QList findSubWindow( const QString &aName, const UInt uiCategory = 0 ) const; - SubWindowHandle* findSubWindow( const SubWindowHandle* subWindow ) const; + QList findSubWindow( const UInt uiCategory = 0 ) const; + QList findSubWindow( const QString &aName, const UInt uiCategory = 0 ) const; + SubWindowAbstract* findSubWindow( const SubWindowAbstract* subWindow ) const; Void createActions(); QMenu* createMenu(); @@ -69,13 +69,13 @@ public: private: Int m_iWindowMode; - QList m_apcSubWindowList; + QList m_apcSubWindowList; QHBoxLayout* m_pcWindowManagerLayout; PlaYUVerMdiArea* m_pcMdiArea; QList m_apcMdiSubWindowList; - SubWindowHandle* m_pcActiveWindow; + SubWindowAbstract* m_pcActiveWindow; QPoint m_cMdiModeWindowPosition; QSize m_cMdiModeWindowSize; @@ -102,15 +102,15 @@ private: /** * Internal functions */ - Void addMdiSubWindow( SubWindowHandle *window ); + Void addMdiSubWindow( SubWindowAbstract *window ); Void resetWindowMode(); Void removeSubWindow( Int windowIdx ); public Q_SLOTS: void setWindowMode( int iWindowMode ); - void updateActiveSubWindow( SubWindowHandle *window = 0 ); + void updateActiveSubWindow( SubWindowAbstract *window = 0 ); void setActiveSubWindow( QWidget *window ); - void removeSubWindow( SubWindowHandle *window ); + void removeSubWindow( SubWindowAbstract *window ); void removeMdiSubWindow( PlaYUVerMdiSubWindow* window ); void removeActiveSubWindow(); void removeAllSubWindow(); diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index ba0bc4d..1941b0c 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -48,7 +48,7 @@ Void PlotSubWindow::definePlotColors() } PlotSubWindow::PlotSubWindow( const QString& windowTitle, QWidget * parent ) : - SubWindowHandle( parent, SubWindowHandle::PLOT_SUBWINDOW ) + SubWindowAbstract( parent, SubWindowAbstract::PLOT_SUBWINDOW ) { definePlotColors(); diff --git a/app/PlotSubWindow.h b/app/PlotSubWindow.h index add5937..81538a6 100644 --- a/app/PlotSubWindow.h +++ b/app/PlotSubWindow.h @@ -32,14 +32,14 @@ #elif( QT_VERSION_PLAYUVER == 4 ) #include #endif -#include "SubWindowHandle.h" +#include "SubWindowAbstract.h" class QCustomPlot; namespace plaYUVer { -class PlotSubWindow: public SubWindowHandle +class PlotSubWindow: public SubWindowAbstract { Q_OBJECT @@ -75,7 +75,7 @@ public: } /** - * Virtual functions from SubWindowHandle + * Virtual functions from SubWindowAbstract */ Void normalSize(); Void zoomToFit(); diff --git a/app/QualityHandle.cpp b/app/QualityHandle.cpp index 554b70e..ab20471 100644 --- a/app/QualityHandle.cpp +++ b/app/QualityHandle.cpp @@ -117,7 +117,7 @@ Void QualityHandle::updateMenus() if( hasSubWindow && !hasReference ) { VideoSubWindow* pcVideoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); @@ -255,7 +255,7 @@ Void QualityHandle::slotSelectCurrentAsReference() if( pcRefSubWindow ) { VideoSubWindow* pcVideoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); @@ -305,7 +305,7 @@ Void QualityHandle::slotPlotQualitySeveral() } VideoSubWindow* pcVideoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); diff --git a/app/QualityMeasurementSidebar.cpp b/app/QualityMeasurementSidebar.cpp index 04d6770..b8772bc 100644 --- a/app/QualityMeasurementSidebar.cpp +++ b/app/QualityMeasurementSidebar.cpp @@ -136,7 +136,7 @@ Void QualityMeasurementSidebar::updateSubWindowList() m_pcVideoWindowList.clear(); VideoSubWindow* pcVideoSubWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { pcVideoSubWindow = qobject_cast( subWindowList.at( i ) ); diff --git a/app/SubWindowHandle.cpp b/app/SubWindowAbstract.cpp similarity index 82% rename from app/SubWindowHandle.cpp rename to app/SubWindowAbstract.cpp index 10622ab..43ee401 100644 --- a/app/SubWindowHandle.cpp +++ b/app/SubWindowAbstract.cpp @@ -18,16 +18,21 @@ */ /** - * \file SubWindowHandle.cpp - * \brief Sub windows handling + * \file SubWindowAbstract.cpp + * \brief Abstract class to handle subwindows */ -#include "SubWindowHandle.h" +#include +#include +#include +#include +#include "SubWindowAbstract.h" #include "PlaYUVerMdiSubWindow.h" + namespace plaYUVer { -SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : +SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) : QScrollArea( parent ), m_cSubWindow( NULL ) { @@ -52,22 +57,22 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, UInt category ) : connect(this, SIGNAL(destroyed()), this, SLOT(onDestroyed())); } -void SubWindowHandle::onDestroyed() +void SubWindowAbstract::onDestroyed() { return; } -SubWindowHandle::~SubWindowHandle() +SubWindowAbstract::~SubWindowAbstract() { return; } -QSize SubWindowHandle::getScrollSize() +QSize SubWindowAbstract::getScrollSize() { return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 ); } -Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) +Void SubWindowAbstract::adjustScrollBarByOffset( QPoint Offset ) { QPoint cLastScroll = m_cCurrScroll; QScrollBar *scrollBarH, *scrollBarV; @@ -97,7 +102,7 @@ Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset ) // This function was developed with help of the schematics presented in // http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position -Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) +Void SubWindowAbstract::adjustScrollBarByScale( Double scale, QPoint center ) { QPoint cLastScroll = m_cCurrScroll; QScrollBar *scrollBarH, *scrollBarV; @@ -140,7 +145,7 @@ Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center ) } -Void SubWindowHandle::updateCurScrollValues() +Void SubWindowAbstract::updateCurScrollValues() { QScrollBar *scrollBar = horizontalScrollBar(); m_cCurrScroll.setX( scrollBar->value() ); @@ -148,7 +153,7 @@ Void SubWindowHandle::updateCurScrollValues() m_cCurrScroll.setY( scrollBar->value() ); } -Void SubWindowHandle::setCurScrollValues() +Void SubWindowAbstract::setCurScrollValues() { QScrollBar *scrollBar = horizontalScrollBar(); scrollBar->setValue(m_cCurrScroll.x() ); @@ -156,44 +161,44 @@ Void SubWindowHandle::setCurScrollValues() scrollBar->setValue(m_cCurrScroll.y() ); } -Void SubWindowHandle::setWindowName( QString name ) +Void SubWindowAbstract::setWindowName( QString name ) { m_cWindowName = name; setWindowTitle( m_cWindowName ); } -QString SubWindowHandle::getWindowName() +QString SubWindowAbstract::getWindowName() { return m_cWindowName; } -Bool SubWindowHandle::mayClose() +Bool SubWindowAbstract::mayClose() { return true; } -QSize SubWindowHandle::sizeHint( ) const +QSize SubWindowAbstract::sizeHint( ) const { return QSize(); } -QSize SubWindowHandle::sizeHint( const QSize & ) const +QSize SubWindowAbstract::sizeHint( const QSize & ) const { return QSize(); } -Void SubWindowHandle::focusInEvent( QFocusEvent * event ) +Void SubWindowAbstract::focusInEvent( QFocusEvent * event ) { emit aboutToActivate( this ); } -Void SubWindowHandle::closeEvent( QCloseEvent *event ) +Void SubWindowAbstract::closeEvent( QCloseEvent *event ) { emit aboutToClose( this ); event->accept(); } -Void SubWindowHandle::closeSubWindow() +Void SubWindowAbstract::closeSubWindow() { close(); if( m_cSubWindow ) diff --git a/app/SubWindowHandle.h b/app/SubWindowAbstract.h similarity index 87% rename from app/SubWindowHandle.h rename to app/SubWindowAbstract.h index 63e6431..a795851 100644 --- a/app/SubWindowHandle.h +++ b/app/SubWindowAbstract.h @@ -18,9 +18,9 @@ */ /** - * \file SubWindowHandle.h + * \file SubWindowAbstract.h * \ingroup PlaYUVerApp PlaYUVerApp_Subwindow - * \brief Sub windows handling + * \brief Abstract class to handle subwindows * * @defgroup PlaYUVerApp_Subwindow SubWindow definition * @{ @@ -34,23 +34,25 @@ * @} */ -#ifndef __SUBWINDOWHANDLE_H__ -#define __SUBWINDOWHANDLE_H__ +#ifndef __SUBWINDOWABSTRACT_H__ +#define __SUBWINDOWABSTRACT_H__ #include "config.h" #include "PlaYUVerAppDefs.h" -#if( QT_VERSION_PLAYUVER == 5 ) -#include -#elif( QT_VERSION_PLAYUVER == 4 ) -#include -#endif +#include +#include +#include +#include + +class QFocusEvent; +class QCloseEvent; namespace plaYUVer { class PlaYUVerMdiSubWindow; -class SubWindowHandle: public QScrollArea +class SubWindowAbstract: public QScrollArea { Q_OBJECT @@ -73,8 +75,8 @@ public: PLOT_SUBWINDOW = 8, }; - SubWindowHandle( QWidget *, UInt ); - ~SubWindowHandle(); + SubWindowAbstract( QWidget *, UInt ); + ~SubWindowAbstract(); /** * Show the image at its original size @@ -152,8 +154,8 @@ public: Void closeSubWindow(); protected: - void focusInEvent( QFocusEvent * event ); - void closeEvent( QCloseEvent *event ); + void focusInEvent( QFocusEvent* event ); + void closeEvent( QCloseEvent* event ); QSize getScrollSize(); Q_SIGNALS: @@ -170,8 +172,8 @@ Q_SIGNALS: */ void updateStatusBar( const QString& ); - void aboutToActivate( SubWindowHandle* ); - void aboutToClose( SubWindowHandle* ); + void aboutToActivate( SubWindowAbstract* ); + void aboutToClose( SubWindowAbstract* ); public Q_SLOTS: void onDestroyed(); @@ -184,5 +186,5 @@ public Q_SLOTS: } // NAMESPACE -#endif // __SUBWINDOWHANDLE_H__ +#endif // __SUBWINDOWABSTRACT_H__ diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 144f829..8fc0233 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -22,10 +22,19 @@ * \brief Class to handle video playback */ -#include -#include "PlaYUVerSubWindowHandle.h" #include "VideoHandle.h" +#include "VideoSubWindow.h" +#include "PlaYUVerSubWindowHandle.h" #include "DialogSubWindowSelector.h" +#include "FramePropertiesDock.h" +#include "WidgetFrameNumber.h" +#include +#include +#include +#include +#include +#include +#include #if( _CONTROL_PLAYING_TIME_ == 1 ) #include #endif @@ -137,7 +146,7 @@ QToolBar* VideoHandle::createToolBar() QDockWidget* VideoHandle::createDock() { - m_pcFramePropertiesSideBar = new FramePropertiesSideBar( this, &m_bIsPlaying ); + m_pcFramePropertiesSideBar = new FramePropertiesDock( this, &m_bIsPlaying ); m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), this ); m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar ); @@ -278,7 +287,7 @@ Void VideoHandle::updateSelectionArea( QRect area ) } } -Void VideoHandle::closeSubWindow( SubWindowHandle* subWindow ) +Void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow ) { VideoSubWindow* videoSubWindow = qobject_cast( subWindow ); @@ -303,8 +312,8 @@ Void VideoHandle::zoomToFactorAll( const Double scale, const QPoint center ) factor = m_pcCurrentVideoSubWindow->getScaleFactor(); - SubWindowHandle *subWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + SubWindowAbstract *subWindow; + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); for( Int i = 0; i < subWindowList.size(); i++ ) { subWindow = subWindowList.at( i ); @@ -323,8 +332,8 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) QPoint newOffset = offset; if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { - SubWindowHandle *subWindow; - QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowHandle::VIDEO_SUBWINDOW ); + SubWindowAbstract *subWindow; + QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); QScrollBar *scrollBar; scrollBar = m_pcCurrentVideoSubWindow->horizontalScrollBar(); @@ -408,9 +417,9 @@ Void VideoHandle::setTimerStatus() if( m_pcPlayControlTimer && m_pcPlayingTimer->interval() > 0 ) { qDebug( ) << "Desired Fps: " - << 1000 / m_pcPlayingTimer->interval() - << "Real Fps: " - << 1000 / m_dAverageFps; + << 1000 / m_pcPlayingTimer->interval() + << "Real Fps: " + << 1000 / m_dAverageFps; delete m_pcPlayControlTimer; m_pcPlayControlTimer = NULL; @@ -574,7 +583,7 @@ Void VideoHandle::seekSliderEvent( Int new_frame_num ) Void VideoHandle::videoSelectionButtonEvent() { - DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, SubWindowHandle::VIDEO_STREAM_SUBWINDOW ); + DialogSubWindowSelector dialogWindowsSelection( this, m_pcMainWindowManager, SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ); QStringList cWindowListNames; for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) { @@ -584,7 +593,7 @@ Void VideoHandle::videoSelectionButtonEvent() { m_acPlayingSubWindows.clear(); VideoSubWindow *videoSubWindow; - QList selectedSubWindowList = dialogWindowsSelection.getSelectedWindows(); + QList selectedSubWindowList = dialogWindowsSelection.getSelectedWindows(); for( Int i = 0; i < selectedSubWindowList.size(); i++ ) { videoSubWindow = qobject_cast( selectedSubWindowList.at( i ) ); diff --git a/app/VideoHandle.h b/app/VideoHandle.h index 8a8c23b..60d6c90 100644 --- a/app/VideoHandle.h +++ b/app/VideoHandle.h @@ -27,25 +27,29 @@ #include "config.h" #include "PlaYUVerAppDefs.h" -#include -#if( QT_VERSION_PLAYUVER == 5 ) -#include -#elif( QT_VERSION_PLAYUVER == 4 ) -#include -#endif -#include "VideoSubWindow.h" -#include "WidgetFrameNumber.h" -#include "FramePropertiesSidebar.h" + +#include +#include +#include +#include #define _CONTROL_PLAYING_TIME_ 0 +class QToolBar; +class QDockWidget; +class QSignalMapper; +class QLabel; +class QSlider; class QElapsedTimer; namespace plaYUVer { class PlaYUVerSubWindowHandle; +class SubWindowAbstract; class VideoSubWindow; +class FramePropertiesDock; +class WidgetFrameNumber; class VideoHandle: public QWidget { @@ -91,7 +95,7 @@ private: QToolBar* m_toolbarVideo; QDockWidget* m_pcFramePropertiesDock; - FramePropertiesSideBar* m_pcFramePropertiesSideBar; + FramePropertiesDock* m_pcFramePropertiesSideBar; QLabel* m_pcVideoFormatLabel; QLabel* m_pcResolutionLabel; @@ -117,7 +121,7 @@ Q_SIGNALS: private Q_SLOTS: void update(); void updateSelectionArea( QRect area ); - void closeSubWindow( SubWindowHandle* subWindow ); + void closeSubWindow( SubWindowAbstract* subWindow ); void zoomToFactorAll( const double factor, const QPoint center = QPoint() ); void moveAllScrollBars( const QPoint offset ); void play(); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 39ba15f..fea5e35 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -24,8 +24,8 @@ #include "VideoSubWindow.h" #include "ModulesHandle.h" -#include "SubWindowHandle.h" #include "ConfigureFormatDialog.h" +#include "SubWindowAbstract.h" #if( QT_VERSION_PLAYUVER == 5 ) #include "QtConcurrent/qtconcurrentrun.h" #endif @@ -78,7 +78,7 @@ Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename ) } VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget * parent ) : - SubWindowHandle( parent, SubWindowHandle::VIDEO_SUBWINDOW | category ), + SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category ), m_pCurrStream( NULL ), m_pcCurrFrame( NULL ), m_pcCurrentDisplayModule( NULL ), @@ -128,7 +128,7 @@ Void VideoSubWindow::loadAll() Void VideoSubWindow::refreshSubWindow() { - if( getCategory() & SubWindowHandle::VIDEO_STREAM_SUBWINDOW ) + if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW ) { Int currFrameNum = m_pCurrStream->getCurrFrameNum(); if( !loadFile( m_cFilename, false ) ) diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 16241bf..b0d5966 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -26,15 +26,14 @@ #define __VIDEOSUBWINDOW_H__ #include "config.h" +#include +#include +#include +#include +#include #include "PlaYUVerAppDefs.h" -#if( QT_VERSION_PLAYUVER == 5 ) -#include -#elif( QT_VERSION_PLAYUVER == 4 ) -#include -#endif -#include "QFuture" #include "lib/PlaYUVerStream.h" -#include "SubWindowHandle.h" +#include "SubWindowAbstract.h" #include "ViewArea.h" namespace plaYUVer @@ -59,7 +58,7 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& d ); QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& d ); Int findPlaYUVerStreamInfo( PlaYUVerStreamInfoVector array, QString filename ); -class VideoSubWindow: public SubWindowHandle +class VideoSubWindow: public SubWindowAbstract { Q_OBJECT @@ -202,7 +201,7 @@ public: } /** - * Virtual functions from SubWindowHandle + * Virtual functions from SubWindowAbstract */ Void normalSize(); Void zoomToFit(); diff --git a/app/main.cpp b/app/main.cpp index abc4855..458419f 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -23,10 +23,10 @@ */ #include "config.h" -#include "PlaYUVerAppDefs.h" #include +#include "PlaYUVerAppDefs.h" #include "PlaYUVerApp.h" -#include "SubWindowHandle.h" +#include "VideoSubWindow.h" #ifdef USE_QTDBUS #include "PlaYUVerAppAdaptor.h" #endif @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) */ QDBusConnection::sessionBus().registerService( PLAYUVER_DBUS_SESSION_NAME ); #endif - plaYUVerApp mainwindow; + PlaYUVerApp mainwindow; mainwindow.show(); if( mainwindow.parseArgs( argc, argv ) ) { @@ -136,8 +136,8 @@ int main( int argc, char *argv[] ) } #ifdef USE_FERVOR - FvUpdater::sharedUpdater()->SetFeedURL("http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml"); - FvUpdater::sharedUpdater()->SetDependencies("ALL"); + FvUpdater::sharedUpdater()->SetFeedURL( "http://192.168.96.201/share/PlaYUVerProject/PlaYUVerUpdate-" UPDATE_CHANNEL ".xml" ); + FvUpdater::sharedUpdater()->SetDependencies( "ALL" ); #endif return application.exec(); diff --git a/lib/LibAvContextHandle.cpp b/lib/LibAvContextHandle.cpp index f9c5055..4c0c3aa 100644 --- a/lib/LibAvContextHandle.cpp +++ b/lib/LibAvContextHandle.cpp @@ -216,10 +216,10 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& frame_rate = fr; /*if( video_stream->nb_frames ) - { - num_frames = video_stream->nb_frames; - } - else*/ if( fmt_ctx->duration != AV_NOPTS_VALUE ) + { + num_frames = video_stream->nb_frames; + } + else*/if( fmt_ctx->duration != AV_NOPTS_VALUE ) { Int64 duration = fmt_ctx->duration + 5000; m_uiSecs = duration / AV_TIME_BASE; @@ -316,8 +316,7 @@ Bool LibAvContextHandle::decodeVideoPkt() { pkt.size = 0; } - Bool bRet = got_frame > 0 ? true : false; - return bRet; + return got_frame > 0 ? true : false; } Bool LibAvContextHandle::decodeAvFormat() @@ -356,7 +355,8 @@ Bool LibAvContextHandle::decodeAvFormat() av_image_copy_to_buffer( m_pchFrameBuffer, m_uiFrameBufferSize, frame->data, frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, video_dec_ctx->height, 1 ); - av_free_packet( &orig_pkt ); + if( orig_pkt.size ) + av_free_packet( &orig_pkt ); return true; } From 957f4870e7d0643c9703be2bff6d32c6656951a1 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 10 Apr 2015 20:26:03 +0100 Subject: [PATCH 85/94] change SetChromaHalfScale module category --- modules/SetChromaHalfScale.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/SetChromaHalfScale.cpp b/modules/SetChromaHalfScale.cpp index af22c60..7b8dc56 100644 --- a/modules/SetChromaHalfScale.cpp +++ b/modules/SetChromaHalfScale.cpp @@ -31,7 +31,7 @@ SetChromaHalfScale::SetChromaHalfScale() { /* Module Definition */ m_iModuleType = FRAME_PROCESSING_MODULE; - m_pchModuleCategory = "Utilities"; + m_pchModuleCategory = "Conversions"; m_pchModuleName = "SetChromaHalfScale"; m_pchModuleTooltip = "Copy frame only keeping luma component"; m_uiNumberOfFrames = MODULE_REQUIRES_ONE_FRAME; From ebbaaaf876da3ff0f1cb245fe9b0bbdf09d02537 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 10 Apr 2015 20:26:18 +0100 Subject: [PATCH 86/94] Add tilling arragement in detached window mode --- app/PlaYUVerSubWindowHandle.cpp | 86 ++++++++++++++++++++++++++++----- app/PlaYUVerSubWindowHandle.h | 2 + 2 files changed, 77 insertions(+), 11 deletions(-) diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 275bf78..217c83c 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -66,6 +66,7 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : m_apcSubWindowList.clear(); m_apcMdiSubWindowList.clear(); + m_pcApp = qobject_cast( parentWidget() ); //setWindowMode( NormalSubWindows ); setWindowMode( MdiWSubWindows ); } @@ -112,7 +113,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { m_apcSubWindowList.at( i )->setParent( NULL ); - m_apcSubWindowList.at( i )->sizeHint(); + m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() ); m_apcSubWindowList.at( i )->show(); } setVisible( false ); @@ -122,6 +123,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) QSize screenSize = QApplication::desktop()->availableGeometry().size(); parentWidget()->move( 0, 0 ); parentWidget()->resize( screenSize.width(), 5 ); + parentWidget()->setWindowTitle( QApplication::applicationName() ); } if( iWindowMode == MdiWSubWindows ) @@ -136,12 +138,17 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { addMdiSubWindow( m_apcSubWindowList.at( i ) ); + m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() ); } parentWidget()->move( m_cMdiModeWindowPosition ); parentWidget()->resize( m_cMdiModeWindowSize ); + if( m_pcActiveWindow ) + { + parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); + } } m_iWindowMode = iWindowMode; - tileSubWindows(); + //tileSubWindows(); parentWidget()->update(); qApp->processEvents(); } @@ -171,13 +178,11 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window ) emit changed(); } } + if( m_pcActiveWindow ) + { + parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); + } } - - if( m_pcActiveWindow ) - { - parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); - } - } Void PlaYUVerSubWindowHandle::addMdiSubWindow( SubWindowAbstract *window ) @@ -194,9 +199,8 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::Windo { if( window ) { - connect( window, SIGNAL( updateStatusBar( const QString& ) ), qobject_cast( parent() ), SLOT( updateStatusBar( const QString& ) ) ); - connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), qobject_cast( parent() ), - SLOT( updateZoomFactorSBox() ) ); + connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( updateStatusBar( const QString& ) ) ); + connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) ); if( m_iWindowMode == NormalSubWindows ) { connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this, SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) ); @@ -329,10 +333,70 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) Void PlaYUVerSubWindowHandle::tileSubWindows() { + UInt numberOfWindows = m_apcSubWindowList.size(); + if( numberOfWindows == 0 ) + return; + + if( m_iWindowMode == NormalSubWindows ) + { + QSize screenSize = QApplication::desktop()->availableGeometry().size(); + UInt minWindowsInRow = 1; + while( ( screenSize.width() / minWindowsInRow ) > 500 ) + { + minWindowsInRow++; + } + parentWidget()->showNormal(); + qApp->processEvents(); + parentWidget()->move( 0, 0 ); + parentWidget()->resize( screenSize.width(), 5 ); + QSize appSize = m_pcApp->size(); + QPoint topLeftCornerWindow( 0, appSize.height() ); + //Select the arrangement based on the number of windows + + if( numberOfWindows % 2 != 0 && numberOfWindows > minWindowsInRow ) + { + numberOfWindows++; + } + UInt numberTillingRows = 1; + UInt numberTillingColumns; + if( numberOfWindows > minWindowsInRow ) + { + numberTillingColumns = minWindowsInRow; + for( Int i = numberOfWindows; i > 0; ) + { + numberTillingRows = ( numberOfWindows + numberTillingColumns - 1 ) / numberTillingColumns; + if( numberTillingColumns > numberTillingRows ) + { + break; + } + numberTillingColumns++; + } + } + else + { + numberTillingColumns = numberOfWindows; + } + if( numberOfWindows / numberTillingRows == 1 ) + { + numberTillingColumns = numberTillingRows; + } + + QSize totalWindowsSize( screenSize.width(), screenSize.height() - topLeftCornerWindow.y() ); + QSize windowsSize( totalWindowsSize.width() / numberTillingColumns, totalWindowsSize.height() / numberTillingRows ); + QPoint windowRelativePos; + for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) + { + windowRelativePos.setY( ( i / numberTillingColumns ) * windowsSize.height() ); + windowRelativePos.setX( ( i % numberTillingColumns ) * windowsSize.width() ); + m_apcSubWindowList.at( i )->resize( windowsSize ); + m_apcSubWindowList.at( i )->move( topLeftCornerWindow + windowRelativePos ); + } + } if( m_iWindowMode == MdiWSubWindows ) { m_pcMdiArea->tileSubWindows(); } + } Void PlaYUVerSubWindowHandle::cascadeSubWindows() diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 0741f03..f00f223 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -36,6 +36,7 @@ namespace plaYUVer { +class PlaYUVerApp; class SubWindowAbstract; class PlaYUVerMdiArea; class PlaYUVerMdiSubWindow; @@ -68,6 +69,7 @@ public: }; private: + PlaYUVerApp* m_pcApp; Int m_iWindowMode; QList m_apcSubWindowList; From 6fc22dfc04d2b1977b300baaf80d0b261a0c2525 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 11 Apr 2015 13:49:37 +0100 Subject: [PATCH 87/94] Minor fixes in windows manager --- app/PlaYUVerMdiSubWindow.cpp | 2 + app/PlaYUVerSubWindowHandle.cpp | 79 ++++++++++++++++----------------- app/PlaYUVerSubWindowHandle.h | 4 +- app/PlotSubWindow.cpp | 4 +- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/app/PlaYUVerMdiSubWindow.cpp b/app/PlaYUVerMdiSubWindow.cpp index e84d946..7f407d6 100644 --- a/app/PlaYUVerMdiSubWindow.cpp +++ b/app/PlaYUVerMdiSubWindow.cpp @@ -32,6 +32,8 @@ namespace plaYUVer PlaYUVerMdiSubWindow::PlaYUVerMdiSubWindow( QWidget *parent ) : QMdiSubWindow( parent ) { + setAttribute( Qt::WA_DeleteOnClose ); + setBackgroundRole( QPalette::Background ); } QSize PlaYUVerMdiSubWindow::sizeHint() const diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 217c83c..9289c21 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -33,7 +33,7 @@ namespace plaYUVer class PlaYUVerMdiArea: public QMdiArea { public: - PlaYUVerMdiArea( QWidget *parent ) : + PlaYUVerMdiArea( QWidget *parent = 0 ) : QMdiArea( parent ), m_pixmapLogo( ":/images/playuver-backgroud-logo.png" ) { @@ -44,13 +44,12 @@ protected: { QMdiArea::paintEvent( event ); QPainter painter( viewport() ); - QPixmap pixFinalLogo = m_pixmapLogo.scaled( 2 * size() / 3, Qt::KeepAspectRatio ); - // Calculate the logo position - the bottom right corner of the mdi area. int x = width() / 2 - pixFinalLogo.width() / 2; int y = height() / 2 - pixFinalLogo.height() / 2; painter.drawPixmap( x, y, pixFinalLogo ); +// QPoint bottomLeftCorner( 0, viewport()->height() ); } private: QPixmap m_pixmapLogo; @@ -67,22 +66,22 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : m_apcMdiSubWindowList.clear(); m_pcApp = qobject_cast( parentWidget() ); - //setWindowMode( NormalSubWindows ); - setWindowMode( MdiWSubWindows ); + //setWindowMode( DETACHEDSUBWINDOWMODE ); + setWindowMode( MDISUBWINDOWMODE ); } Void PlaYUVerSubWindowHandle::resetWindowMode() { QList apcSubWindowList = m_apcSubWindowList; - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { - m_cMdiModeWindowPosition = parentWidget()->pos(); - m_cMdiModeWindowSize = parentWidget()->size(); + m_cMdiModeWindowPosition = m_pcApp->pos(); + m_cMdiModeWindowSize = m_pcApp->size(); for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { m_apcSubWindowList.at( i )->setParent( NULL ); @@ -108,7 +107,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) resetWindowMode(); - if( iWindowMode == NormalSubWindows ) + if( iWindowMode == DETACHEDSUBWINDOWMODE ) { for( Int i = 0; i < m_apcSubWindowList.size(); i++ ) { @@ -118,18 +117,18 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) } setVisible( false ); parentWidget()->update(); - parentWidget()->showNormal(); + m_pcApp->showNormal(); qApp->processEvents(); QSize screenSize = QApplication::desktop()->availableGeometry().size(); - parentWidget()->move( 0, 0 ); - parentWidget()->resize( screenSize.width(), 5 ); - parentWidget()->setWindowTitle( QApplication::applicationName() ); + m_pcApp->move( 0, 0 ); + m_pcApp->resize( screenSize.width(), 5 ); + m_pcApp->setWindowTitle( QApplication::applicationName() ); } - if( iWindowMode == MdiWSubWindows ) + if( iWindowMode == MDISUBWINDOWMODE ) { setVisible( true ); - m_pcMdiArea = new PlaYUVerMdiArea( this ); + m_pcMdiArea = new PlaYUVerMdiArea; m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder ); connect( m_pcMdiArea, SIGNAL( subWindowActivated(QMdiSubWindow*) ), this, SLOT( updateActiveSubWindow() ) ); m_pcWindowManagerLayout = new QHBoxLayout( this ); @@ -140,11 +139,11 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) addMdiSubWindow( m_apcSubWindowList.at( i ) ); m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() ); } - parentWidget()->move( m_cMdiModeWindowPosition ); - parentWidget()->resize( m_cMdiModeWindowSize ); + m_pcApp->move( m_cMdiModeWindowPosition ); + m_pcApp->resize( m_cMdiModeWindowSize ); if( m_pcActiveWindow ) { - parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); + m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); } } m_iWindowMode = iWindowMode; @@ -155,7 +154,7 @@ Void PlaYUVerSubWindowHandle::setWindowMode( Int iWindowMode ) Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window ) { - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { if( window ) { @@ -164,7 +163,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window ) } } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { m_pcActiveWindow = NULL; QMdiSubWindow* mdiSubWindow = m_pcMdiArea->activeSubWindow(); @@ -180,7 +179,7 @@ Void PlaYUVerSubWindowHandle::updateActiveSubWindow( SubWindowAbstract *window ) } if( m_pcActiveWindow ) { - parentWidget()->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); + m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() ); } } } @@ -201,12 +200,12 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::Windo { connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( updateStatusBar( const QString& ) ) ); connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) ); - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this, SLOT( updateActiveSubWindow( SubWindowAbstract* ) ) ); connect( window, SIGNAL( aboutToClose( SubWindowAbstract* ) ), this, SLOT( removeSubWindow( SubWindowAbstract* ) ) ); } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { addMdiSubWindow( window ); } @@ -218,13 +217,13 @@ Void PlaYUVerSubWindowHandle::removeSubWindow( Int windowIdx ) { if( windowIdx >= 0 ) { - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { SubWindowAbstract* subWindow = m_apcSubWindowList.at( windowIdx ); m_apcSubWindowList.removeAt( windowIdx ); subWindow->close(); } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { PlaYUVerMdiSubWindow* mdiSubWindow = m_apcMdiSubWindowList.at( windowIdx ); m_apcMdiSubWindowList.removeAt( windowIdx ); @@ -321,11 +320,11 @@ Void PlaYUVerSubWindowHandle::setActiveSubWindow( QWidget *window ) m_pcActiveWindow = qobject_cast( window ); - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { m_pcActiveWindow->window()->activateWindow(); } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { m_pcActiveWindow->setFocus(); } @@ -337,7 +336,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() if( numberOfWindows == 0 ) return; - if( m_iWindowMode == NormalSubWindows ) + if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { QSize screenSize = QApplication::desktop()->availableGeometry().size(); UInt minWindowsInRow = 1; @@ -345,10 +344,10 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() { minWindowsInRow++; } - parentWidget()->showNormal(); + m_pcApp->showNormal(); qApp->processEvents(); - parentWidget()->move( 0, 0 ); - parentWidget()->resize( screenSize.width(), 5 ); + m_pcApp->move( 0, 0 ); + m_pcApp->resize( screenSize.width(), 5 ); QSize appSize = m_pcApp->size(); QPoint topLeftCornerWindow( 0, appSize.height() ); //Select the arrangement based on the number of windows @@ -392,7 +391,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() m_apcSubWindowList.at( i )->move( topLeftCornerWindow + windowRelativePos ); } } - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { m_pcMdiArea->tileSubWindows(); } @@ -401,7 +400,7 @@ Void PlaYUVerSubWindowHandle::tileSubWindows() Void PlaYUVerSubWindowHandle::cascadeSubWindows() { - if( m_iWindowMode == MdiWSubWindows ) + if( m_iWindowMode == MDISUBWINDOWMODE ) { m_pcMdiArea->cascadeSubWindows(); } @@ -425,13 +424,13 @@ Void PlaYUVerSubWindowHandle::createActions() m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT]->setCheckable( true ); m_actionGroupWindowMode->addAction( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT] ); connect( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); - m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], NormalSubWindows ); + m_mapperWindowMode->setMapping( m_arrayActions[NORMAL_SUBWINDOW_MODE_ACT], DETACHEDSUBWINDOWMODE ); m_arrayActions[MDI_SUBWINDOW_MODE_ACT] = new QAction( "&MDI SubWindows", this ); m_arrayActions[MDI_SUBWINDOW_MODE_ACT]->setCheckable( true ); m_actionGroupWindowMode->addAction( m_arrayActions[MDI_SUBWINDOW_MODE_ACT] ); connect( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], SIGNAL( triggered() ), m_mapperWindowMode, SLOT( map() ) ); - m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], MdiWSubWindows ); + m_mapperWindowMode->setMapping( m_arrayActions[MDI_SUBWINDOW_MODE_ACT], MDISUBWINDOWMODE ); m_actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true ); @@ -497,9 +496,9 @@ Void PlaYUVerSubWindowHandle::updateMenu() m_pcMenuWindow->addAction( m_arrayActions[TILE_WINDOWS_ACT] ); m_pcMenuWindow->addAction( m_arrayActions[CASCADE_WINDOWS_ACT] ); m_pcMenuWindow->addSeparator(); - m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] ); - m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] ); - m_pcMenuWindow->addSeparator(); +// m_pcMenuWindow->addAction( m_arrayActions[NEXT_WINDOWS_ACT] ); +// m_pcMenuWindow->addAction( m_arrayActions[PREVIOUS_WINDOWS_ACT] ); +// m_pcMenuWindow->addSeparator(); Int number_windows = m_apcSubWindowList.size(); if( number_windows > 1 ) @@ -541,7 +540,7 @@ Void PlaYUVerSubWindowHandle::readSettings() QSettings appSettings; m_cMdiModeWindowPosition = appSettings.value( "SubWindowManager/LastMdiPosition", QPoint( 200, 200 ) ).toPoint(); m_cMdiModeWindowSize = appSettings.value( "SubWindowManager/LastMdiSize", QSize( 500, 400 ) ).toSize(); - Int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MdiWSubWindows ).toInt(); + Int iWindowMode = appSettings.value( "SubWindowManager/SubWindowMode", MDISUBWINDOWMODE ).toInt(); setWindowMode( iWindowMode ); m_actionGroupWindowMode->actions().at( iWindowMode )->setChecked( true ); } diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index f00f223..6a55969 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -64,8 +64,8 @@ public: enum WindowMode { - NormalSubWindows = 0, - MdiWSubWindows = 1, + DETACHEDSUBWINDOWMODE = 0, + MDISUBWINDOWMODE = 1, }; private: diff --git a/app/PlotSubWindow.cpp b/app/PlotSubWindow.cpp index 1941b0c..9916e03 100644 --- a/app/PlotSubWindow.cpp +++ b/app/PlotSubWindow.cpp @@ -198,14 +198,14 @@ Void PlotSubWindow::setAxisRange( PlotSubWindow::Axis eAxis, const Int& axisStar if( eAxis == HORIZONTAL ) { m_cPlotArea->xAxis->setRange( axisStart, axisEnd ); - horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); + //horizontalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); m_aAxisRange[HORIZONTAL][0] = axisStart; m_aAxisRange[HORIZONTAL][1] = axisEnd; } if( eAxis == VERTICAL ) { m_cPlotArea->yAxis->setRange( axisStart, axisEnd ); - verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); + //verticalScrollBar()->setRange( axisStart * 100, axisEnd * 100 ); m_aAxisRange[VERTICAL][0] = axisStart; m_aAxisRange[VERTICAL][1] = axisEnd; } From 045ad923e737289f2a310baaca74e2ff2036bc52 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 11 Apr 2015 20:27:39 +0100 Subject: [PATCH 88/94] Move scroll area into VideoSubWindow --- app/SubWindowAbstract.cpp | 116 ++++--------------------------- app/SubWindowAbstract.h | 16 ++--- app/VideoHandle.cpp | 12 ++-- app/VideoSubWindow.cpp | 142 ++++++++++++++++++++++++++++++++++---- app/VideoSubWindow.h | 20 +++++- 5 files changed, 171 insertions(+), 135 deletions(-) diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp index 43ee401..6aadfae 100644 --- a/app/SubWindowAbstract.cpp +++ b/app/SubWindowAbstract.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "SubWindowAbstract.h" #include "PlaYUVerMdiSubWindow.h" @@ -33,7 +34,7 @@ namespace plaYUVer { SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) : - QScrollArea( parent ), + QWidget( parent ), m_cSubWindow( NULL ) { setParent( parent ); @@ -44,22 +45,12 @@ SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) : setWindowIcon( QIcon( ":/images/playuver.png" ) ); - // Create a new scroll area inside the sub-window - connect( horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); - connect( verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); - - setWidgetResizable( true ); - + //setWidgetResizable( true ); + m_pcLayout = NULL; m_uiCategory = category; - m_cLastScroll = QPoint(); m_cWindowName = QString( " " ); - connect(this, SIGNAL(destroyed()), this, SLOT(onDestroyed())); -} - -void SubWindowAbstract::onDestroyed() -{ - return; + connect( this, SIGNAL( destroyed() ), this, SLOT( onDestroyed() ) ); } SubWindowAbstract::~SubWindowAbstract() @@ -67,98 +58,17 @@ SubWindowAbstract::~SubWindowAbstract() return; } -QSize SubWindowAbstract::getScrollSize() +Void SubWindowAbstract::setWidget( QWidget* widget ) { - return QSize( viewport()->size().width() - 5, viewport()->size().height() - 5 ); + if( !m_pcLayout ) + m_pcLayout = new QHBoxLayout( this ); + + m_pcLayout->addWidget( widget ); } -Void SubWindowAbstract::adjustScrollBarByOffset( QPoint Offset ) +void SubWindowAbstract::onDestroyed() { - QPoint cLastScroll = m_cCurrScroll; - QScrollBar *scrollBarH, *scrollBarV; - Int valueX, valueY; - - valueX = int( cLastScroll.x() + Offset.x() ); - valueY = int( cLastScroll.y() + Offset.y() ); - - scrollBarH = horizontalScrollBar(); - if( valueX > scrollBarH->maximum() ) - valueX = scrollBarH->maximum(); - if( valueX < scrollBarH->minimum() ) - valueX = scrollBarH->minimum(); - m_cCurrScroll.setX(valueX); - - scrollBarV = verticalScrollBar(); - if( valueY > scrollBarV->maximum() ) - valueY = scrollBarV->maximum(); - if( valueY < scrollBarV->minimum() ) - valueY = scrollBarV->minimum(); - m_cCurrScroll.setY( valueY ); - - // Update window scroll - scrollBarH->setValue( m_cCurrScroll.x() ); - scrollBarV->setValue( m_cCurrScroll.y() ); -} - -// This function was developed with help of the schematics presented in -// http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position -Void SubWindowAbstract::adjustScrollBarByScale( Double scale, QPoint center ) -{ - QPoint cLastScroll = m_cCurrScroll; - QScrollBar *scrollBarH, *scrollBarV; - - scrollBarH = horizontalScrollBar(); - if( center.isNull() ) - { - m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) )); - } - else - { - Int x = center.x() - cLastScroll.x(); - Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); - if( value > scrollBarH->maximum() ) - value = scrollBarH->maximum(); - if( value < scrollBarH->minimum() ) - value = scrollBarH->minimum(); - m_cCurrScroll.setX(value); - } - - scrollBarV = verticalScrollBar(); - if( center.isNull() ) - { - m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) )); - } - else - { - Int y = center.y() - cLastScroll.y(); - Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); - if( value > scrollBarV->maximum() ) - value = scrollBarV->maximum(); - if( value < scrollBarV->minimum() ) - value = scrollBarV->minimum(); - m_cCurrScroll.setY(value); - } - - // Update window scroll - scrollBarH->setValue( m_cCurrScroll.x() ); - scrollBarV->setValue( m_cCurrScroll.y() ); - -} - -Void SubWindowAbstract::updateCurScrollValues() -{ - QScrollBar *scrollBar = horizontalScrollBar(); - m_cCurrScroll.setX( scrollBar->value() ); - scrollBar = verticalScrollBar(); - m_cCurrScroll.setY( scrollBar->value() ); -} - -Void SubWindowAbstract::setCurScrollValues() -{ - QScrollBar *scrollBar = horizontalScrollBar(); - scrollBar->setValue(m_cCurrScroll.x() ); - scrollBar = verticalScrollBar(); - scrollBar->setValue(m_cCurrScroll.y() ); + return; } Void SubWindowAbstract::setWindowName( QString name ) @@ -177,7 +87,7 @@ Bool SubWindowAbstract::mayClose() return true; } -QSize SubWindowAbstract::sizeHint( ) const +QSize SubWindowAbstract::sizeHint() const { return QSize(); } diff --git a/app/SubWindowAbstract.h b/app/SubWindowAbstract.h index a795851..cd89aff 100644 --- a/app/SubWindowAbstract.h +++ b/app/SubWindowAbstract.h @@ -39,11 +39,12 @@ #include "config.h" #include "PlaYUVerAppDefs.h" -#include +#include #include #include #include +class QHBoxLayout; class QFocusEvent; class QCloseEvent; @@ -52,14 +53,12 @@ namespace plaYUVer class PlaYUVerMdiSubWindow; -class SubWindowAbstract: public QScrollArea +class SubWindowAbstract: public QWidget { Q_OBJECT private: - QPoint m_cLastScroll; - QPoint m_cCurrScroll; - + QHBoxLayout* m_pcLayout; UInt m_uiCategory; QString m_cWindowName; @@ -156,7 +155,8 @@ public: protected: void focusInEvent( QFocusEvent* event ); void closeEvent( QCloseEvent* event ); - QSize getScrollSize(); + + Void setWidget( QWidget* widget ); Q_SIGNALS: /** @@ -177,10 +177,6 @@ Q_SIGNALS: public Q_SLOTS: void onDestroyed(); - void adjustScrollBarByScale( double scale, QPoint center ); - void adjustScrollBarByOffset( QPoint Offset ); - void updateCurScrollValues(); - void setCurScrollValues(); }; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index 8fc0233..fabacf1 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -332,11 +332,11 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) QPoint newOffset = offset; if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() ) { - SubWindowAbstract *subWindow; + VideoSubWindow *videoSubWindow; QList subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW ); QScrollBar *scrollBar; - scrollBar = m_pcCurrentVideoSubWindow->horizontalScrollBar(); + scrollBar = m_pcCurrentVideoSubWindow->getScroll()->horizontalScrollBar(); // Do not move other images, if current image reached maximum or minimum scroll position if( scrollBar->value() == scrollBar->maximum() && offset.x() > 0 ) @@ -344,7 +344,7 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) if( scrollBar->value() == scrollBar->minimum() && offset.x() < 0 ) newOffset.setX( 0 ); - scrollBar = m_pcCurrentVideoSubWindow->verticalScrollBar(); + scrollBar = m_pcCurrentVideoSubWindow->getScroll()->verticalScrollBar(); if( scrollBar->value() == scrollBar->maximum() && offset.y() > 0 ) newOffset.setY( 0 ); if( scrollBar->value() == scrollBar->minimum() && offset.y() < 0 ) @@ -352,12 +352,12 @@ Void VideoHandle::moveAllScrollBars( const QPoint offset ) for( Int i = 0; i < subWindowList.size(); i++ ) { - subWindow = subWindowList.at( i ); - if( m_pcCurrentVideoSubWindow == subWindow ) + videoSubWindow = qobject_cast( subWindowList.at( i ) ); + if( m_pcCurrentVideoSubWindow == videoSubWindow ) continue; else { - subWindow->adjustScrollBarByOffset( newOffset ); + videoSubWindow->adjustScrollBarByOffset( newOffset ); } } } diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index fea5e35..b519a22 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -26,6 +26,7 @@ #include "ModulesHandle.h" #include "ConfigureFormatDialog.h" #include "SubWindowAbstract.h" +#include #if( QT_VERSION_PLAYUVER == 5 ) #include "QtConcurrent/qtconcurrentrun.h" #endif @@ -87,6 +88,13 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget m_bIsModule( category == MODULE_SUBWINDOW ) { + // 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() ) ); + + m_cLastScroll = QPoint(); + // Create a new interface to show images m_cViewArea = new ViewArea( this ); connect( m_cViewArea, SIGNAL( zoomFactorChanged_byWheel( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) ); @@ -98,12 +106,15 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); - setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // Define the cViewArea as the widget inside the scroll area m_cViewArea->setMinimumSize( size() ); - setWidget( m_cViewArea ); + + m_pcScrollArea->setWidget( m_cViewArea ); + + setWidget( m_pcScrollArea ); m_apcCurrentModule.clear(); @@ -229,7 +240,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo ) Void VideoSubWindow::updateVideoWindowInfo() { m_cStreamInformation = ""; - if( m_bIsModule ) + if( m_pcCurrentDisplayModule ) { m_cStreamInformation = "Module"; } @@ -425,7 +436,8 @@ Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) } } -Void VideoSubWindow::refreshFrameOperation() +Void VideoSubWindow::paintEvent( QPaintEvent *event ) +//Void VideoSubWindow::refreshFrameOperation() { Bool bSetFrame = false; if( m_pCurrStream ) @@ -446,20 +458,26 @@ Void VideoSubWindow::refreshFrameOperation() { ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); } + //m_cViewArea->update(); + m_pcScrollArea->update(); +// QPainter p( this ); +// p.setPen( QColor( "red" ) ); +// p.drawLine( 0, 0, width(), height() ); } Void VideoSubWindow::refreshFrame( Bool bThreaded ) { -#ifndef QT_NO_CONCURRENT - m_cRefreshResult.waitForFinished(); - if( bThreaded ) +//#ifndef QT_NO_CONCURRENT +// m_cRefreshResult.waitForFinished(); +// if( bThreaded ) +// { +// m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation ); +// } +// else +//#endif { - m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation ); - } - else -#endif - { - refreshFrameOperation(); + //refreshFrameOperation(); + update(); } } @@ -553,6 +571,100 @@ Void VideoSubWindow::stop() return; } +QSize VideoSubWindow::getScrollSize() +{ + return QSize( m_pcScrollArea->viewport()->size().width() - 5, m_pcScrollArea->viewport()->size().height() - 5 ); +} + +Void VideoSubWindow::adjustScrollBarByOffset( QPoint Offset ) +{ + QPoint cLastScroll = m_cCurrScroll; + QScrollBar *scrollBarH, *scrollBarV; + Int valueX, valueY; + + valueX = int( cLastScroll.x() + Offset.x() ); + valueY = int( cLastScroll.y() + Offset.y() ); + + scrollBarH = m_pcScrollArea->horizontalScrollBar(); + if( valueX > scrollBarH->maximum() ) + valueX = scrollBarH->maximum(); + if( valueX < scrollBarH->minimum() ) + valueX = scrollBarH->minimum(); + m_cCurrScroll.setX( valueX ); + + scrollBarV = m_pcScrollArea->verticalScrollBar(); + if( valueY > scrollBarV->maximum() ) + valueY = scrollBarV->maximum(); + if( valueY < scrollBarV->minimum() ) + valueY = scrollBarV->minimum(); + m_cCurrScroll.setY( valueY ); + + // Update window scroll + scrollBarH->setValue( m_cCurrScroll.x() ); + scrollBarV->setValue( m_cCurrScroll.y() ); +} + +// This function was developed with help of the schematics presented in +// http://stackoverflow.com/questions/13155382/jscrollpane-zoom-relative-to-mouse-position +Void VideoSubWindow::adjustScrollBarByScale( Double scale, QPoint center ) +{ + QPoint cLastScroll = m_cCurrScroll; + QScrollBar *scrollBarH, *scrollBarV; + + scrollBarH = m_pcScrollArea->horizontalScrollBar(); + if( center.isNull() ) + { + m_cCurrScroll.setX( int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ) ); + } + else + { + Int x = center.x() - cLastScroll.x(); + Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) ); + if( value > scrollBarH->maximum() ) + value = scrollBarH->maximum(); + if( value < scrollBarH->minimum() ) + value = scrollBarH->minimum(); + m_cCurrScroll.setX( value ); + } + + scrollBarV = m_pcScrollArea->verticalScrollBar(); + if( center.isNull() ) + { + m_cCurrScroll.setY( int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ) ); + } + else + { + Int y = center.y() - cLastScroll.y(); + Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) ); + if( value > scrollBarV->maximum() ) + value = scrollBarV->maximum(); + if( value < scrollBarV->minimum() ) + value = scrollBarV->minimum(); + m_cCurrScroll.setY( value ); + } + + // Update window scroll + scrollBarH->setValue( m_cCurrScroll.x() ); + scrollBarV->setValue( m_cCurrScroll.y() ); + +} + +Void VideoSubWindow::updateCurScrollValues() +{ + QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar(); + m_cCurrScroll.setX( scrollBar->value() ); + scrollBar = m_pcScrollArea->verticalScrollBar(); + m_cCurrScroll.setY( scrollBar->value() ); +} + +Void VideoSubWindow::setCurScrollValues() +{ + QScrollBar *scrollBar = m_pcScrollArea->horizontalScrollBar(); + scrollBar->setValue( m_cCurrScroll.x() ); + scrollBar = m_pcScrollArea->verticalScrollBar(); + scrollBar->setValue( m_cCurrScroll.y() ); +} + Void VideoSubWindow::normalSize() { Double factor = 1.0; @@ -711,4 +823,4 @@ QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const // } //} -} // NAMESPACE +}// NAMESPACE diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index b0d5966..eb7ead7 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -36,6 +36,8 @@ #include "SubWindowAbstract.h" #include "ViewArea.h" +class QScrollArea; + namespace plaYUVer { @@ -64,6 +66,10 @@ Q_OBJECT private: + QScrollArea* m_pcScrollArea; + QPoint m_cLastScroll; + QPoint m_cCurrScroll; + ViewArea* m_cViewArea; QString m_cFilename; @@ -102,9 +108,13 @@ private: * zoom to fit */ Void scaleView( const QSize & size, QPoint center = QPoint() ); - Void updateVideoWindowInfo(); + QSize getScrollSize(); + +protected: + Void paintEvent( QPaintEvent *event ); + public: enum VideoSubWindowCategories { @@ -136,6 +146,10 @@ public: Void setCurrFrame( PlaYUVerFrame* pcCurrFrame ); + QScrollArea* getScroll() + { + return m_pcScrollArea; + } PlaYUVerStreamInfo getStreamInfo() { return m_sStreamInfo; @@ -241,6 +255,10 @@ public: //void closeEvent( QCloseEvent *event ); public Q_SLOTS: + void adjustScrollBarByScale( double scale, QPoint center ); + void adjustScrollBarByOffset( QPoint Offset ); + void updateCurScrollValues(); + void setCurScrollValues(); void updateSelectedArea( QRect area ); void updatePixelValueStatusBar( const QPoint& pos ); }; From 27c135d00381dfe3cae69218aa85f1c42f761b12 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 12 Apr 2015 13:22:13 +0100 Subject: [PATCH 89/94] Minor fixes into layout management --- app/SubWindowAbstract.cpp | 4 +++- app/VideoSubWindow.cpp | 33 ++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp index 6aadfae..7a465fb 100644 --- a/app/SubWindowAbstract.cpp +++ b/app/SubWindowAbstract.cpp @@ -61,8 +61,10 @@ SubWindowAbstract::~SubWindowAbstract() Void SubWindowAbstract::setWidget( QWidget* widget ) { if( !m_pcLayout ) + { m_pcLayout = new QHBoxLayout( this ); - + m_pcLayout->setContentsMargins( 0, 0, 0, 0 ); + } m_pcLayout->addWidget( widget ); } diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index b519a22..184b072 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -106,11 +106,11 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); - m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + //m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + //m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // Define the cViewArea as the widget inside the scroll area - m_cViewArea->setMinimumSize( size() ); + // m_cViewArea->setMinimumSize( size() ); m_pcScrollArea->setWidget( m_cViewArea ); @@ -465,6 +465,29 @@ Void VideoSubWindow::paintEvent( QPaintEvent *event ) // p.drawLine( 0, 0, width(), height() ); } +Void VideoSubWindow::refreshFrameOperation() +{ + Bool bSetFrame = false; + if( m_pCurrStream ) + { + m_pcCurrFrame = m_pCurrStream->getCurrFrame(); + bSetFrame = m_pcCurrFrame ? true : false; + } + if( m_pcCurrentDisplayModule ) + { + ModulesHandle::applyModuleIf( m_pcCurrentDisplayModule, m_bIsPlaying ); + bSetFrame = false; + } + if( bSetFrame ) + { + m_cViewArea->setImage( m_pcCurrFrame ); + } + for( Int i = 0; i < m_apcCurrentModule.size(); i++ ) + { + ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); + } +} + Void VideoSubWindow::refreshFrame( Bool bThreaded ) { //#ifndef QT_NO_CONCURRENT @@ -476,8 +499,8 @@ Void VideoSubWindow::refreshFrame( Bool bThreaded ) // else //#endif { - //refreshFrameOperation(); - update(); + refreshFrameOperation(); + //update(); } } From dd5b6941025066227e96fe2b9c54bab92440f0e6 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 12 Apr 2015 21:09:13 +0100 Subject: [PATCH 90/94] Move QScrollArea into VideoSubWindow --- app/SubWindowAbstract.cpp | 9 +++---- app/VideoSubWindow.cpp | 57 ++++++++++----------------------------- app/VideoSubWindow.h | 3 --- 3 files changed, 17 insertions(+), 52 deletions(-) diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp index 7a465fb..ab88e7a 100644 --- a/app/SubWindowAbstract.cpp +++ b/app/SubWindowAbstract.cpp @@ -60,12 +60,9 @@ SubWindowAbstract::~SubWindowAbstract() Void SubWindowAbstract::setWidget( QWidget* widget ) { - if( !m_pcLayout ) - { - m_pcLayout = new QHBoxLayout( this ); - m_pcLayout->setContentsMargins( 0, 0, 0, 0 ); - } - m_pcLayout->addWidget( widget ); + QGridLayout *layout = new QGridLayout( this ); + layout->setContentsMargins( 0, 0, 0, 0 ); + layout->addWidget( widget, 0, 0 ); } void SubWindowAbstract::onDestroyed() diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 184b072..479590d 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -93,10 +93,8 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget connect( m_pcScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); connect( m_pcScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateCurScrollValues() ) ); - m_cLastScroll = QPoint(); - // Create a new interface to show images - m_cViewArea = new ViewArea( this ); + 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 ) ) ); @@ -106,16 +104,19 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) ); connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) ); - //m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); - //m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + m_pcScrollArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + m_pcScrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // Define the cViewArea as the widget inside the scroll area // m_cViewArea->setMinimumSize( size() ); m_pcScrollArea->setWidget( m_cViewArea ); + m_pcScrollArea->setWidgetResizable( true ); setWidget( m_pcScrollArea ); + m_cLastScroll = QPoint(); + m_apcCurrentModule.clear(); } @@ -436,35 +437,6 @@ Void VideoSubWindow::setCurrFrame( PlaYUVerFrame* pcCurrFrame ) } } -Void VideoSubWindow::paintEvent( QPaintEvent *event ) -//Void VideoSubWindow::refreshFrameOperation() -{ - Bool bSetFrame = false; - if( m_pCurrStream ) - { - m_pcCurrFrame = m_pCurrStream->getCurrFrame(); - bSetFrame = m_pcCurrFrame ? true : false; - } - if( m_pcCurrentDisplayModule ) - { - ModulesHandle::applyModuleIf( m_pcCurrentDisplayModule, m_bIsPlaying ); - bSetFrame = false; - } - if( bSetFrame ) - { - m_cViewArea->setImage( m_pcCurrFrame ); - } - for( Int i = 0; i < m_apcCurrentModule.size(); i++ ) - { - ModulesHandle::applyModuleIf( m_apcCurrentModule.at( i ), m_bIsPlaying ); - } - //m_cViewArea->update(); - m_pcScrollArea->update(); -// QPainter p( this ); -// p.setPen( QColor( "red" ) ); -// p.drawLine( 0, 0, width(), height() ); -} - Void VideoSubWindow::refreshFrameOperation() { Bool bSetFrame = false; @@ -490,17 +462,16 @@ Void VideoSubWindow::refreshFrameOperation() Void VideoSubWindow::refreshFrame( Bool bThreaded ) { -//#ifndef QT_NO_CONCURRENT -// m_cRefreshResult.waitForFinished(); -// if( bThreaded ) -// { -// m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation ); -// } -// else -//#endif +#ifndef QT_NO_CONCURRENT + m_cRefreshResult.waitForFinished(); + if( bThreaded ) + { + m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrameOperation ); + } + else +#endif { refreshFrameOperation(); - //update(); } } diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index eb7ead7..8654e00 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -112,9 +112,6 @@ private: QSize getScrollSize(); -protected: - Void paintEvent( QPaintEvent *event ); - public: enum VideoSubWindowCategories { From e63075119b9b3cb8ce8c52b66d992acffe2103b3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 12 Apr 2015 21:53:06 +0100 Subject: [PATCH 91/94] Add support for log messages. Show them inside the MdiArea --- app/ModulesHandle.cpp | 5 ++-- app/PlaYUVerApp.cpp | 42 +++++++++++++++++------------- app/PlaYUVerApp.h | 5 +++- app/PlaYUVerSubWindowHandle.cpp | 26 +++++++++++++++++-- app/PlaYUVerSubWindowHandle.h | 2 ++ app/VideoHandle.cpp | 1 + lib/PlaYUVerDefs.h | 8 ++++++ tools/CommandLineHandle.cpp | 2 +- tools/CommandLineHandle.h | 7 ----- tools/PlaYUVerTools.cpp | 45 ++++++++++++++++----------------- 10 files changed, 90 insertions(+), 53 deletions(-) diff --git a/app/ModulesHandle.cpp b/app/ModulesHandle.cpp index d2ff4b0..6470667 100644 --- a/app/ModulesHandle.cpp +++ b/app/ModulesHandle.cpp @@ -23,6 +23,7 @@ */ #include +#include "PlaYUVerApp.h" #include "ModulesHandle.h" #include "PlaYUVerSubWindowHandle.h" #include "VideoSubWindow.h" @@ -296,7 +297,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( videoSubWindowList.size() == 0 ) { - qobject_cast( m_pcParent )->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); + qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be applied", LOG_ERROR ); destroyModuleIf( pcCurrModuleIf ); return; } @@ -335,7 +336,7 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf ) if( !moduleCreated ) { - qobject_cast( m_pcParent )->statusBar()->showMessage( "Error! Module cannot be applied", 2000 ); + qobject_cast( m_pcParent )->printMessage( "Error! Module cannot be applied", LOG_ERROR ); destroyModuleIf( pcCurrModuleIf ); return; } diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 298179c..d00aaae 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -192,7 +192,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) { if( !QFileInfo( fileName ).exists() ) { - statusBar()->showMessage( "File " + fileName + " do not exist!", 2000 ); + printMessage( "File " + fileName + " do not exist!", LOG_ERROR ); return; } VideoSubWindow *videoSubWindow = PlaYUVerApp::findVideoStreamSubWindow( m_pcWindowHandle, fileName ); @@ -220,7 +220,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) if( opened ) { - statusBar()->showMessage( tr( "Loading file..." ) ); + printMessage( "Loading file...", LOG_INFO ); m_pcWindowHandle->addSubWindow( videoSubWindow ); videoSubWindow->show(); @@ -236,7 +236,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) addStreamInfoToRecentList( videoSubWindow->getStreamInfo() ); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); + printMessage( "File loaded", LOG_INFO ); m_cLastOpenPath = QFileInfo( fileName ).path(); } else @@ -249,8 +249,7 @@ Void PlaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo ) videoSubWindow->close(); QString warningMsg = "Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + msg; QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - statusBar()->showMessage( warningMsg, 2000 ); - qDebug( ) << warningMsg; + printMessage( warningMsg, LOG_ERROR ); } } @@ -359,7 +358,7 @@ Void PlaYUVerApp::format() { QString warningMsg = "Cannot change format of " + QFileInfo( pcVideoSubWindow->getCurrentFileName() ).fileName() + " with the following error: \n" + msg; QMessageBox::warning( this, QApplication::applicationName(), warningMsg ); - statusBar()->showMessage( warningMsg, 2000 ); + printMessage( warningMsg, LOG_ERROR ); qDebug( ) << warningMsg; m_pcCurrentSubWindow->close(); } @@ -402,9 +401,9 @@ Void PlaYUVerApp::loadAll() { if( m_pcCurrentVideoSubWindow ) { - statusBar()->showMessage( tr( "Loading file into memory ..." ) ); + printMessage( "Loading file into memory...", LOG_INFO ); m_pcCurrentVideoSubWindow->loadAll(); - statusBar()->showMessage( tr( "File loaded" ), 2000 ); + printMessage( "File loaded", LOG_INFO ); } } @@ -553,16 +552,25 @@ Void PlaYUVerApp::update() updateMenus(); } -Void PlaYUVerApp::updateStatusBar( const QString& statusBarString ) +Void PlaYUVerApp::printMessage( const QString& msg ) { - if( !statusBarString.isEmpty() ) + printMessage( msg, 0 ); +} + +Void PlaYUVerApp::printMessage( const QString& msg, UInt logLevel ) +{ + if( !msg.isEmpty() ) { - statusBar()->showMessage( statusBarString, 5000 ); - } - else - { - statusBar()->showMessage( " " ); + statusBar()->showMessage( msg, 5000 ); + if( logLevel >= LOG_INFO ) + { + m_pcWindowHandle->processLogMsg( msg ); + } } +// else +// { +// statusBar()->showMessage( " " ); +// } } Void PlaYUVerApp::updateMenus() @@ -855,9 +863,9 @@ Void PlaYUVerApp::createDockWidgets() Void PlaYUVerApp::createStatusBar() { -//! Warning: the following widget cannot change size too much + //! Warning: the following widget cannot change size too much statusBar()->addPermanentWidget( m_appModuleVideo->createStatusBarMessage() ); - statusBar()->showMessage( tr( "Ready" ) ); + printMessage( "Ready!", LOG_INFO ); } Void PlaYUVerApp::addStreamInfoToRecentList( PlaYUVerStreamInfo streamInfo ) diff --git a/app/PlaYUVerApp.h b/app/PlaYUVerApp.h index 8160ed1..be14e14 100644 --- a/app/PlaYUVerApp.h +++ b/app/PlaYUVerApp.h @@ -77,6 +77,10 @@ public: Bool parseArgs( Int argc, Char *argv[] ); Void loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo = NULL ); +public Q_SLOTS: + void printMessage( const QString& msg ); + void printMessage( const QString& msg, UInt logLevel ); + protected: Void closeEvent( QCloseEvent *event ); @@ -114,7 +118,6 @@ private Q_SLOTS: void update(); void updateZoomFactorSBox(); - void updateStatusBar( const QString& ); private: diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 9289c21..f377814 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -22,8 +22,8 @@ * \brief Handle multiple sub-windows */ -#include "PlaYUVerApp.h" #include "PlaYUVerSubWindowHandle.h" +#include "PlaYUVerApp.h" #include "PlaYUVerMdiSubWindow.h" #include "SubWindowAbstract.h" @@ -39,6 +39,14 @@ public: { setBackgroundRole( QPalette::Background ); } + + Void appendLogMessage( const QString& msg ) + { + m_acLogMessages.push_front( msg ); + if( m_acLogMessages.size() > 5 ) + m_acLogMessages.removeLast(); + update(); + } protected: void paintEvent( QPaintEvent *event ) { @@ -49,9 +57,15 @@ protected: int x = width() / 2 - pixFinalLogo.width() / 2; int y = height() / 2 - pixFinalLogo.height() / 2; painter.drawPixmap( x, y, pixFinalLogo ); + +// for( Int i = 0; i < m_acLogMessages.size(); i++ ) +// { +// painter.drawText( 5, height() - 5 - i * 15, m_acLogMessages.at( i ) ); +// } // QPoint bottomLeftCorner( 0, viewport()->height() ); } private: + QVector m_acLogMessages; QPixmap m_pixmapLogo; }; @@ -70,6 +84,14 @@ PlaYUVerSubWindowHandle::PlaYUVerSubWindowHandle( QWidget *parent ) : setWindowMode( MDISUBWINDOWMODE ); } +Void PlaYUVerSubWindowHandle::processLogMsg( const QString& msg ) +{ + if( m_pcMdiArea ) + { + m_pcMdiArea->appendLogMessage( msg ); + } +} + Void PlaYUVerSubWindowHandle::resetWindowMode() { QList apcSubWindowList = m_apcSubWindowList; @@ -198,7 +220,7 @@ Void PlaYUVerSubWindowHandle::addSubWindow( SubWindowAbstract *window, Qt::Windo { if( window ) { - connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( updateStatusBar( const QString& ) ) ); + connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( printMessage( const QString& ) ) ); connect( window, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) ); if( m_iWindowMode == DETACHEDSUBWINDOWMODE ) { diff --git a/app/PlaYUVerSubWindowHandle.h b/app/PlaYUVerSubWindowHandle.h index 6a55969..ad7412f 100644 --- a/app/PlaYUVerSubWindowHandle.h +++ b/app/PlaYUVerSubWindowHandle.h @@ -48,6 +48,8 @@ Q_OBJECT public: PlaYUVerSubWindowHandle( QWidget *parent ); + Void processLogMsg( const QString& msg ); + Void addSubWindow( SubWindowAbstract *widget, Qt::WindowFlags flags = 0 ); SubWindowAbstract *activeSubWindow() const; diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index fabacf1..7d53411 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -22,6 +22,7 @@ * \brief Class to handle video playback */ +#include "PlaYUVerApp.h" #include "VideoHandle.h" #include "VideoSubWindow.h" #include "PlaYUVerSubWindowHandle.h" diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 0d597d6..00c2985 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -106,6 +106,14 @@ typedef UChar Byte; // PlaYUVer definitions // ==================================================================================================================== +enum LOG_LEVEL +{ + LOG_INFO = 1, + LOG_WARNINGS = 2, + LOG_RESULT = 3, + LOG_ERROR = 4, +}; + enum YUVcomponent { LUMA = 0, diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index 75fb37c..70fad11 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -84,7 +84,7 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) if( m_bQuiet ) { - m_uiLogLevel = RESULT; + m_uiLogLevel = LOG_RESULT; } if( Opts()["module"]->count() && Opts()["help"]->count() ) diff --git a/tools/CommandLineHandle.h b/tools/CommandLineHandle.h index e778d1e..df25f05 100644 --- a/tools/CommandLineHandle.h +++ b/tools/CommandLineHandle.h @@ -42,13 +42,6 @@ public: CommandLineHandle(); ~CommandLineHandle(); - enum LOG_LEVEL - { - INFO = 0, - WARNINGS = 1, - RESULT = 2, - ERROR = 3, - }; Void setLogLevel( enum LOG_LEVEL level ) { m_uiLogLevel = level; diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 547561b..0f37c51 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -81,14 +81,14 @@ Int PlaYUVerTools::openInputs() { if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 8, 1 ) ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); + m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2; } m_apcInputStreams.push_back( pcStream ); } catch( const char *msg ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); + m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg ); return 2; } } @@ -134,7 +134,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric; // if( m_apcInputStreams.size() != 2 ) // { -// m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); +// m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); // return 2; // } for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) @@ -146,12 +146,12 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( m_uiQualityMetric == -1 ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid quality metric! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Invalid quality metric! " ); return 2; } m_uiOperation = QUALITY_OPERATION; m_fpProcess = &PlaYUVerTools::QualityOperation; - m_cCmdLineHandler.log( CommandLineHandle::INFO, "PlaYUVer Quality\n" ); + m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Quality\n" ); } /** @@ -174,7 +174,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) if( m_apcInputStreams.size() != m_pcCurrModuleIf->m_uiNumberOfFrames ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Invalid number of inputs! " ); return 2; } @@ -198,7 +198,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } if( !moduleCreated ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Module is not supported with the selected inputs! " ); + m_cCmdLineHandler.log( LOG_ERROR, "Module is not supported with the selected inputs! " ); return 2; } @@ -231,19 +231,19 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] ) } else { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "One output is required! " ); + m_cCmdLineHandler.log( LOG_ERROR, "One output is required! " ); return 2; } } m_uiOperation = MODULE_OPERATION; m_fpProcess = &PlaYUVerTools::ModuleOperation; - m_cCmdLineHandler.log( CommandLineHandle::INFO, "PlaYUVer Module\n" ); + m_cCmdLineHandler.log( LOG_INFO, "PlaYUVer Module\n" ); } if( m_uiOperation == INVALID_OPERATION ) { - m_cCmdLineHandler.log( CommandLineHandle::ERROR, "No operation was selected! " ); + m_cCmdLineHandler.log( LOG_ERROR, "No operation was selected! " ); return 2; } return iRet; @@ -267,8 +267,7 @@ Int PlaYUVerTools::QualityOperation() Double adAverageQuality[MAX_NUMBER_INPUTS - 1][MAX_NUMBER_COMPONENTS]; Double dQuality; - m_cCmdLineHandler.log( CommandLineHandle::INFO, " Measuring Quality using %s ... \n", - PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str() ); + m_cCmdLineHandler.log( LOG_INFO, " Measuring Quality using %s ... \n", PlaYUVerFrame::supportedQualityMetricsList()[m_uiQualityMetric].c_str() ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { @@ -280,21 +279,21 @@ Int PlaYUVerTools::QualityOperation() } for( UInt frame = 0; frame < m_uiNumberOfFrames; frame++ ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); + m_cCmdLineHandler.log( LOG_INFO, " %3d", frame ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) apcCurrFrame[s] = m_apcInputStreams[s]->getCurrFrame(); for( UInt s = 1; s < m_apcInputStreams.size(); s++ ) { - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " " ); + m_cCmdLineHandler.log( LOG_RESULT, " " ); for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { dQuality = apcCurrFrame[s]->getQuality( m_uiQualityMetric, apcCurrFrame[0], c ); adAverageQuality[s - 1][c] = ( adAverageQuality[s - 1][c] * Double( frame ) + dQuality ) / Double( frame + 1 ); - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %5.3f", dQuality ); + m_cCmdLineHandler.log( LOG_RESULT, " %5.3f", dQuality ); } } - m_cCmdLineHandler.log( CommandLineHandle::RESULT, "\n" ); + m_cCmdLineHandler.log( LOG_RESULT, "\n" ); for( UInt s = 0; s < m_apcInputStreams.size(); s++ ) { abEOF[s] = m_apcInputStreams[s]->setNextFrame(); @@ -304,15 +303,15 @@ Int PlaYUVerTools::QualityOperation() } } } - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n Mean Values: \n " ); + m_cCmdLineHandler.log( LOG_INFO, "\n Mean Values: \n " ); for( UInt s = 0; s < m_apcInputStreams.size() - 1; s++ ) { for( UInt c = 0; c < m_uiNumberOfComponents; c++ ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %5.3f", adAverageQuality[s][c] ); + m_cCmdLineHandler.log( LOG_INFO, " %5.3f", adAverageQuality[s][c] ); } } - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n" ); + m_cCmdLineHandler.log( LOG_INFO, "\n" ); return 0; } @@ -329,7 +328,7 @@ PlaYUVerFrame* PlaYUVerTools::applyFrameModule() Int PlaYUVerTools::ModuleOperation() { std::vector apcFrameList; - m_cCmdLineHandler.log( CommandLineHandle::INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); + m_cCmdLineHandler.log( LOG_INFO, " Applying Module %s/%s ...\n", m_pcCurrModuleIf->m_pchModuleCategory, m_pcCurrModuleIf->m_pchModuleName ); PlaYUVerFrame* pcProcessedFrame = NULL; Double dMeasurementResult = 0.0; @@ -370,8 +369,8 @@ Int PlaYUVerTools::ModuleOperation() { dMeasurementResult = m_pcCurrModuleIf->measure( m_apcInputStreams[0]->getCurrFrame() ); } - m_cCmdLineHandler.log( CommandLineHandle::INFO, " %3d", frame ); - m_cCmdLineHandler.log( CommandLineHandle::RESULT, " %8.3f \n", dMeasurementResult ); + m_cCmdLineHandler.log( LOG_INFO, " %3d", frame ); + m_cCmdLineHandler.log( LOG_RESULT, " %8.3f \n", dMeasurementResult ); dAveragedMeasurementResult = ( dAveragedMeasurementResult * Double( frame ) + dMeasurementResult ) / Double( frame + 1 ); } @@ -387,7 +386,7 @@ Int PlaYUVerTools::ModuleOperation() if( m_pcCurrModuleIf->m_iModuleType == FRAME_MEASUREMENT_MODULE ) { - m_cCmdLineHandler.log( CommandLineHandle::INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); + m_cCmdLineHandler.log( LOG_INFO, "\n Mean Value: \n %8.3f\n", dAveragedMeasurementResult ); } return 0; From bfb26534b9e0e0bdc2c858d3e5f1b33d9469f893 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 12 Apr 2015 22:00:33 +0100 Subject: [PATCH 92/94] Change name and organization --- app/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 458419f..4c86951 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -48,8 +48,7 @@ int main( int argc, char *argv[] ) QApplication application( argc, argv ); QApplication::setApplicationName( "PlaYUVer" ); QApplication::setApplicationVersion( PLAYUVER_VERSION_STRING ); - QApplication::setOrganizationName( "pixlra" ); - QApplication::setOrganizationDomain( "playuver.pixlra" ); + QApplication::setOrganizationName( "PixLRA" ); #ifdef USE_QTDBUS /** From c30487118edc1a2c18a8933ecafa596b37fbbd50 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 14 Apr 2015 00:13:13 +0100 Subject: [PATCH 93/94] Remove commented code --- app/PlaYUVerApp.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index d00aaae..de6f705 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -567,10 +567,6 @@ Void PlaYUVerApp::printMessage( const QString& msg, UInt logLevel ) m_pcWindowHandle->processLogMsg( msg ); } } -// else -// { -// statusBar()->showMessage( " " ); -// } } Void PlaYUVerApp::updateMenus() From 852e8e59a6fb5a8856bc570b09721a7fa9014e1c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 14 Apr 2015 23:07:40 +0100 Subject: [PATCH 94/94] Add support for bits per pixel in playuverTools --- tools/CommandLineHandle.cpp | 1 + tools/CommandLineHandle.h | 1 + tools/PlaYUVerTools.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/CommandLineHandle.cpp b/tools/CommandLineHandle.cpp index 70fad11..33055ce 100644 --- a/tools/CommandLineHandle.cpp +++ b/tools/CommandLineHandle.cpp @@ -70,6 +70,7 @@ Int CommandLineHandle::parseToolsArgs( Int argc, Char *argv[] ) ( "output,o", m_strOutput, "output file" ) /**/ ( "size,s", m_strResolution, "size (WxH)" ) /**/ ( "pel_fmt", m_strPelFmt, "pixel format" ) /**/ + ( "bits_pel", m_uiBitsPerPixel, "bits per pixel" ) /**/ ( "frames,f", m_iFrames, "number of frames to parse" ); Opts().addOptions()/**/ diff --git a/tools/CommandLineHandle.h b/tools/CommandLineHandle.h index df25f05..afc9871 100644 --- a/tools/CommandLineHandle.h +++ b/tools/CommandLineHandle.h @@ -78,6 +78,7 @@ private: std::string m_strOutput; std::string m_strResolution; std::string m_strPelFmt; + UInt m_uiBitsPerPixel; Bool m_bListPelFmts; Int m_iFrames; diff --git a/tools/PlaYUVerTools.cpp b/tools/PlaYUVerTools.cpp index 0f37c51..a28aa5e 100644 --- a/tools/PlaYUVerTools.cpp +++ b/tools/PlaYUVerTools.cpp @@ -70,6 +70,11 @@ Int PlaYUVerTools::openInputs() { fmtString = m_cCmdLineHandler.m_strPelFmt; } + UInt uiBitPerPixel = 8; + if( m_cCmdLineHandler.Opts()["bits_pel"]->count() ) + { + uiBitPerPixel = m_cCmdLineHandler.m_uiBitsPerPixel; + } std::vector inputFileNames = m_cCmdLineHandler.m_apcInputs; @@ -79,7 +84,7 @@ Int PlaYUVerTools::openInputs() pcStream = new PlaYUVerStream; try { - if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 8, 1 ) ) + if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitPerPixel, 1 ) ) { m_cCmdLineHandler.log( LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); return 2;