Change formating and copyrights

This commit is contained in:
2018-01-15 23:47:58 +00:00
parent bc5258a94d
commit 06cdda6d8a
122 changed files with 14058 additions and 12613 deletions
+72 -39
View File
@@ -1,6 +1,6 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2017 by Luis Lucas (luisfrlucas@gmail.com)
* Joao Carreira (jfmcarreira@gmail.com)
/* This file is a part of PlaYUVer project
* Copyright (C) 2014-2018 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@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
@@ -23,6 +23,7 @@
*/
#include "ModulesHandle.h"
#include "DialogSubWindowSelector.h"
#include "ModulesHandleOptDialog.h"
#include "PlaYUVerApp.h"
@@ -30,6 +31,7 @@
#include "VideoHandle.h"
#include "VideoSubWindow.h"
#include "modules/PlaYUVerModuleFactory.h"
#include <cstdio>
ModulesHandle::ModulesHandle( QWidget* parent, PlaYUVerSubWindowHandle* windowManager, VideoHandle* moduleVideo )
@@ -74,8 +76,9 @@ Void ModulesHandle::createActions()
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip( "Show module result in a new window. Some modules already force this "
"feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip(
"Show module result in a new window. Some modules already force this "
"feature" );
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setCheckable( true );
}
@@ -93,7 +96,8 @@ Void ModulesHandle::buildMenu()
QAction* currAction;
QMenu* currSubMenu;
for( Int i = 0; i < m_arrayModulesActions.size(); i++ ) {
for( Int i = 0; i < m_arrayModulesActions.size(); i++ )
{
delete m_arrayModulesActions.at( i );
}
m_arrayModulesActions.clear();
@@ -102,14 +106,16 @@ Void ModulesHandle::buildMenu()
PlaYUVerModuleFactoryMap& PlaYUVerModuleFactoryMap = PlaYUVerModuleFactory::Get()->getMap();
PlaYUVerModuleFactoryMap::iterator it = PlaYUVerModuleFactoryMap.begin();
for( ; it != PlaYUVerModuleFactoryMap.end(); ++it ) {
for( ; it != PlaYUVerModuleFactoryMap.end(); ++it )
{
pcCurrModuleIf = it->second();
ModuleIfInternalName = QString::fromLocal8Bit( it->first );
currSubMenu = NULL;
if( pcCurrModuleIf->m_pchModuleCategory )
{
for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ ) {
for( Int j = 0; j < m_pcModulesSubMenuList.size(); j++ )
{
if( m_pcModulesSubMenuList.at( j )->title() == QString( pcCurrModuleIf->m_pchModuleCategory ) )
{
currSubMenu = m_pcModulesSubMenuList.at( j );
@@ -153,16 +159,19 @@ Void ModulesHandle::updateMenus()
Bool hasSubWindow = pcSubWindow ? true : false;
QAction* currModuleAction;
for( Int i = 0; i < m_arrayModulesActions.size(); i++ ) {
for( Int i = 0; i < m_arrayModulesActions.size(); i++ )
{
currModuleAction = m_arrayModulesActions.at( i );
currModuleAction->setEnabled( hasSubWindow );
currModuleAction->setChecked( false );
}
for( Int i = 0; i < m_pcModulesSubMenuList.size(); i++ ) {
for( Int i = 0; i < m_pcModulesSubMenuList.size(); i++ )
{
m_pcModulesSubMenuList.at( i )->setEnabled( hasSubWindow );
}
for( Int i = 0; i < m_arrayActions.size(); i++ ) {
for( Int i = 0; i < m_arrayActions.size(); i++ )
{
m_arrayActions.at( i )->setEnabled( false );
}
m_arrayActions[LOAD_EXTERNAL_ACT]->setEnabled( true );
@@ -178,7 +187,8 @@ Void ModulesHandle::updateMenus()
m_arrayActions[APPLY_ALL_ACT]->setEnabled( true );
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true );
}
for( Int i = 0; i < apcCurrentModule.size(); i++ ) {
for( Int i = 0; i < apcCurrentModule.size(); i++ )
{
currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction;
currModuleAction->setChecked( true );
}
@@ -232,9 +242,11 @@ Void ModulesHandle::loadExternalModule()
formatsList << "Shared Libraries (*.so)";
QStringList filter;
filter << supported << formatsList << tr( "All Files (*)" );
QStringList fileNames = QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
QStringList fileNames =
QFileDialog::getOpenFileNames( m_pcParent, tr( "Open File" ), QString(), filter.join( ";;" ) );
for( Int i = 0; i < fileNames.size(); i++ ) {
for( Int i = 0; i < fileNames.size(); i++ )
{
bUpdate |= PlaYUVerModuleFactory::Get()->RegisterDl( fileNames.at( i ).toStdString().data() );
}
if( bUpdate )
@@ -259,7 +271,8 @@ Void ModulesHandle::activateModule()
}
QString ModuleIfName = pcAction->data().toString();
PlaYUVerModuleIf* pcCurrModuleIf = PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
PlaYUVerModuleIf* pcCurrModuleIf =
PlaYUVerModuleFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
PlaYUVerAppModuleIf* pcCurrAppModuleIf = new PlaYUVerAppModuleIf( this, pcAction, pcCurrModuleIf );
QList<VideoSubWindow*> videoSubWindowList;
@@ -273,13 +286,14 @@ Void ModulesHandle::activateModule()
minNumFrames = 0;
maxNumFrames = 255;
}
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager, SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames,
maxNumFrames );
DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMainWindowManager,
SubWindowAbstract::VIDEO_SUBWINDOW, minNumFrames, maxNumFrames );
QList<SubWindowAbstract*> windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
if( windowsList.size() == minNumFrames && windowsList.size() == maxNumFrames )
{
for( Int i = 0; i < windowsList.size(); i++ ) {
for( Int i = 0; i < windowsList.size(); i++ )
{
videoSubWindowList.append( qobject_cast<VideoSubWindow*>( windowsList.at( i ) ) );
}
}
@@ -287,7 +301,8 @@ Void ModulesHandle::activateModule()
{
if( windowsList.size() <= minNumFrames )
{
for( Int i = 0; i < windowsList.size(); i++ ) {
for( Int i = 0; i < windowsList.size(); i++ )
{
dialogWindowsSelection.selectSubWindow( windowsList.at( i ) );
}
}
@@ -299,7 +314,8 @@ Void ModulesHandle::activateModule()
{
VideoSubWindow* videoSubWindow;
QList<SubWindowAbstract*> subWindowList = dialogWindowsSelection.getSelectedWindows();
for( Int i = 0; i < subWindowList.size(); i++ ) {
for( Int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
videoSubWindowList.append( videoSubWindow );
}
@@ -308,7 +324,8 @@ Void ModulesHandle::activateModule()
if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_1 )
{
// Check for same fmt in more than one frame modules
for( Int i = 1; i < videoSubWindowList.size(); i++ ) {
for( Int i = 1; i < videoSubWindowList.size(); i++ )
{
if( !videoSubWindowList.at( i )->getCurrFrame()->haveSameFmt( videoSubWindowList.at( 0 )->getCurrFrame() ) )
{
videoSubWindowList.clear();
@@ -326,12 +343,14 @@ Void ModulesHandle::activateModule()
if( videoSubWindowList.size() == 0 )
{
qobject_cast<PlaYUVerApp*>( m_pcParent )->printMessage( "Error! There is no windows to apply the module", LOG_ERROR );
qobject_cast<PlaYUVerApp*>( m_pcParent )
->printMessage( "Error! There is no windows to apply the module", LOG_ERROR );
destroyModuleIf( pcCurrAppModuleIf );
return;
}
for( Int i = 0; i < videoSubWindowList.size(); i++ ) {
for( Int i = 0; i < videoSubWindowList.size(); i++ )
{
pcCurrAppModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i );
}
@@ -353,16 +372,19 @@ Void ModulesHandle::activateModule()
VideoSubWindow* pcModuleSubWindow = NULL;
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
{
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) ||
bShowModulesNewWindow )
{
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
windowName.append( QStringLiteral( "Module " ) );
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) );
connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
SLOT( updateSelectionArea( QRect ) ) );
connect( pcModuleSubWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), m_appModuleVideo,
SLOT( zoomToFactorAll( double, QPoint ) ) );
connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo, SLOT( moveAllScrollBars( const QPoint ) ) );
connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
SLOT( moveAllScrollBars( const QPoint ) ) );
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
}
@@ -378,7 +400,8 @@ Void ModulesHandle::activateModule()
pcCurrAppModuleIf->m_pcDockWidget->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
pcCurrAppModuleIf->m_pcDockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
pcCurrAppModuleIf->m_pcDockWidget->setWidget( pcCurrAppModuleIf->m_pcModuleDock );
qobject_cast<QMainWindow*>( m_pcParent )->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
qobject_cast<QMainWindow*>( m_pcParent )
->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
}
// Associate module with subwindows
@@ -390,7 +413,8 @@ Void ModulesHandle::activateModule()
{
if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrAppModuleIf );
for( Int i = 0; i < videoSubWindowList.size(); i++ ) {
for( Int i = 0; i < videoSubWindowList.size(); i++ )
{
pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf );
}
}
@@ -400,7 +424,8 @@ Void ModulesHandle::activateModule()
if( pcCurrAppModuleIf->m_pcModule->m_iModuleAPI == MODULE_API_2 )
{
std::vector<PlaYUVerFrame*> apcFrameList;
for( Int i = 0; i < videoSubWindowList.size(); i++ ) {
for( Int i = 0; i < videoSubWindowList.size(); i++ )
{
apcFrameList.push_back( pcCurrAppModuleIf->m_pcSubWindow[i]->getCurrFrame() );
}
moduleCreated = pcCurrAppModuleIf->m_pcModule->create( apcFrameList );
@@ -460,7 +485,8 @@ Void ModulesHandle::destroyWindowModules()
Void ModulesHandle::destroyAllModulesIf()
{
for( Int i = 0; i < m_pcPlaYUVerAppModuleIfList.size(); i++ ) {
for( Int i = 0; i < m_pcPlaYUVerAppModuleIfList.size(); i++ )
{
destroyModuleIf( m_pcPlaYUVerAppModuleIfList.at( i ) );
}
emit changed();
@@ -468,7 +494,8 @@ Void ModulesHandle::destroyAllModulesIf()
Void ModulesHandle::applyModuleIf( QList<PlaYUVerAppModuleIf*> pcCurrModuleIfList, Bool isPlaying, Bool disableThreads )
{
for( Int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ ) {
for( Int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ )
{
pcCurrModuleIfList.at( i )->apply( isPlaying, disableThreads );
}
}
@@ -486,13 +513,15 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
QStringList formatsList;
std::vector<PlaYUVerSupportedFormat> supportedFmts = PlaYUVerStream::supportedWriteFormats();
for( UInt i = 0; i < supportedFmts.size(); i++ ) {
for( UInt i = 0; i < supportedFmts.size(); i++ )
{
std::vector<String> arrayExt = supportedFmts[i].getExts();
if( arrayExt.size() > 0 )
{
QString currFmt( QString::fromStdString( supportedFmts[i].formatName ) );
currFmt.append( " (" );
for( std::vector<String>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e ) {
for( std::vector<String>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
{
supported.append( " *." );
currFmt.append( "*." );
supported.append( QString::fromStdString( *e ) );
@@ -519,8 +548,8 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, PLAYUVER_LITTLE_ENDIAN, FrameRate,
false ) )
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel,
PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) )
{
delete pcCurrModuleIf->m_pcModuleStream;
pcCurrModuleIf->m_pcModuleStream = NULL;
@@ -533,23 +562,27 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf* pcCurrModuleIf )
UInt numberOfWindows = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames;
UInt64 currFrames = 0;
UInt64 numberOfFrames = INT_MAX;
for( UInt i = 0; i < numberOfWindows; i++ ) {
for( UInt i = 0; i < numberOfWindows; i++ )
{
currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getInputStream()->getFrameNum();
if( currFrames < numberOfFrames )
numberOfFrames = currFrames;
pcCurrModuleIf->m_pcSubWindow[i]->stop();
}
QApplication::setOverrideCursor( Qt::WaitCursor );
for( UInt f = 1; f < numberOfFrames; f++ ) {
for( UInt f = 1; f < numberOfFrames; f++ )
{
pcCurrModuleIf->apply( false, true );
QCoreApplication::processEvents();
pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame );
for( UInt i = 0; i < numberOfWindows; i++ ) {
for( UInt i = 0; i < numberOfWindows; i++ )
{
pcCurrModuleIf->m_pcSubWindow[i]->play();
pcCurrModuleIf->m_pcSubWindow[i]->playEvent();
}
}
for( UInt i = 0; i < numberOfWindows; i++ ) {
for( UInt i = 0; i < numberOfWindows; i++ )
{
pcCurrModuleIf->m_pcSubWindow[i]->stop();
}
QApplication::restoreOverrideCursor();