From 48dee6ccfd5a819f15c49fe3c93466c4bf5051d9 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 16:07:49 +0000 Subject: [PATCH 01/19] Add initial class to handle different modules. Class for if also defined --- CMakeLists.txt | 5 +++ source/ModulesHandle.cpp | 49 ++++++++++++++++++++++++++++ source/ModulesHandle.h | 70 ++++++++++++++++++++++++++++++++++++++++ source/plaYUVerApp.cpp | 60 ++++++++++++++++++---------------- source/plaYUVerApp.h | 28 +++++++++++----- 5 files changed, 176 insertions(+), 36 deletions(-) create mode 100644 source/ModulesHandle.cpp create mode 100644 source/ModulesHandle.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d1d0719..880b77d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,11 @@ ENDIF() INCLUDE( cmake/LibFFmpeg.cmake ) +###################################################################################### +# PlaYUVer modules build +###################################################################################### +SET( MODULES_DIR ${SRC_DIR}/modules ) + ###################################################################################### # Create config.h ###################################################################################### diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp new file mode 100644 index 0000000..c516c0e --- /dev/null +++ b/source/ModulesHandle.cpp @@ -0,0 +1,49 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 by plaYUVer developers + * + * 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 ModulesHandle.cpp + * \brief PlaYUVer modules handle + */ + +#include + +#include "ModulesHandle.h" + + +namespace plaYUVer +{ + +ModulesHandle::ModulesHandle() +{ + +} + +ModulesHandle::~ModulesHandle() +{ + +} + +Void ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) +{ + MainAppMenuBar->addMenu( "&Modules" ); +} + + +} // NAMESPACE + diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h new file mode 100644 index 0000000..2780bec --- /dev/null +++ b/source/ModulesHandle.h @@ -0,0 +1,70 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 by plaYUVer developers + * + * 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 ModulesHandle.h + * \brief PlaYUVer modules handle + */ + +#ifndef __MODULESHANDLE_H__ +#define __MODULESHANDLE_H__ + +#include "config.h" + +#include +#include + +#include +#if( QT_VERSION_PLAYUVER == 5 ) +#include +#elif( QT_VERSION_PLAYUVER == 4 ) +#include +#endif + +#include "TypeDef.h" + +namespace plaYUVer +{ + +class ModulesHandle +{ + +public: + ModulesHandle(); + ~ModulesHandle(); + + Void createMenus( QMenuBar *MainAppMenuBar ); + +private: + +}; + +class PlaYUVerModuleIf +{ +public: + virtual Void create(); + virtual Void process(); + virtual Void close(); + + virtual ~PlaYUVerModuleIf() {} +}; + +} // NAMESPACE + +#endif // __PLAYUVERFRAME_H__ + diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 53580c5..0290c13 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -245,16 +245,16 @@ Void plaYUVerApp::updateMenus() void plaYUVerApp::updateWindowMenu() { - menuWindow->clear(); - menuWindow->addAction( actionClose ); - menuWindow->addAction( actionCloseAll ); - menuWindow->addSeparator(); - menuWindow->addAction( actionTile ); - menuWindow->addAction( actionCascade ); - menuWindow->addSeparator(); - menuWindow->addAction( actionNext ); - menuWindow->addAction( actionPrevious ); - menuWindow->addAction( actionSeparator ); + m_arrayMenu[WINDOW_MENU]->clear(); + m_arrayMenu[WINDOW_MENU]->addAction( actionClose ); + m_arrayMenu[WINDOW_MENU]->addAction( actionCloseAll ); + m_arrayMenu[WINDOW_MENU]->addSeparator(); + m_arrayMenu[WINDOW_MENU]->addAction( actionTile ); + m_arrayMenu[WINDOW_MENU]->addAction( actionCascade ); + m_arrayMenu[WINDOW_MENU]->addSeparator(); + m_arrayMenu[WINDOW_MENU]->addAction( actionNext ); + m_arrayMenu[WINDOW_MENU]->addAction( actionPrevious ); + m_arrayMenu[WINDOW_MENU]->addAction( actionSeparator ); updateMenus(); @@ -286,7 +286,7 @@ void plaYUVerApp::updateWindowMenu() { text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() ); } - QAction *action = menuWindow->addAction( text ); + QAction *action = m_arrayMenu[WINDOW_MENU]->addAction( text ); action->setCheckable( true ); action->setChecked( child == activeSubWindow() ); connect( action, SIGNAL( triggered() ), mapperWindow, SLOT( map() ) ); @@ -445,29 +445,33 @@ Void plaYUVerApp::createActions() Void plaYUVerApp::createMenus() { - menuFile = menuBar()->addMenu( tr( "&File" ) ); - menuFile->addAction( actionOpen ); - menuFile->addSeparator(); - menuFile->addAction( actionSave ); - menuFile->addSeparator(); - menuFile->addAction( actionClose ); - menuFile->addAction( actionExit ); + m_arrayMenu.resize(4); - menuView = new QMenu( tr( "&View" ), this ); - menuView->addAction( actionZoomIn ); - menuView->addAction( actionZoomOut ); - menuView->addAction( actionNormalSize ); - menuView->addAction( actionZoomToFit ); + m_arrayMenu[OTHER_MENU] = menuBar()->addMenu( tr( "&File" ) ); + m_arrayMenu[OTHER_MENU]->addAction( actionOpen ); + m_arrayMenu[OTHER_MENU]->addSeparator(); + m_arrayMenu[OTHER_MENU]->addAction( actionSave ); + m_arrayMenu[OTHER_MENU]->addSeparator(); + m_arrayMenu[OTHER_MENU]->addAction( actionClose ); + m_arrayMenu[OTHER_MENU]->addAction( actionExit ); - menuWindow = menuBar()->addMenu( tr( "&Window" ) ); + m_arrayMenu[OTHER_MENU+1] = menuBar()->addMenu( tr( "&View" ) ); + m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomIn ); + m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomOut ); + m_arrayMenu[OTHER_MENU+1]->addAction( actionNormalSize ); + m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomToFit ); + + m_pcModulesHandle->createMenus( menuBar() ); + + m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) ); updateWindowMenu(); - connect( menuWindow, SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) ); + connect( m_arrayMenu[WINDOW_MENU], SIGNAL( aboutToShow() ), this, SLOT( updateWindowMenu() ) ); menuBar()->addSeparator(); - menuHelp = menuBar()->addMenu( tr( "&Help" ) ); - menuHelp->addAction( actionAbout ); - menuHelp->addAction( actionAboutQt ); + m_arrayMenu[OTHER_MENU+2] = menuBar()->addMenu( tr( "&Help" ) ); + m_arrayMenu[OTHER_MENU+2]->addAction( actionAbout ); + m_arrayMenu[OTHER_MENU+2]->addAction( actionAboutQt ); } Void plaYUVerApp::createToolBars() diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index bd3b8db..1981e8d 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -34,6 +34,8 @@ #include #include "TypeDef.h" +#include "ModulesHandle.h" + namespace plaYUVer { @@ -41,7 +43,7 @@ class SubWindowHandle; class plaYUVerApp: public QMainWindow { - Q_OBJECT +Q_OBJECT public: plaYUVerApp(); @@ -60,7 +62,7 @@ private Q_SLOTS: void pause(); void stop(); void playEvent(); - void seekSliderEvent(int new_frame_num ); + void seekSliderEvent( int new_frame_num ); /** * Scale the image by a given factor * @param factor factor of scale. Ex: 120 scale the image up by 20% and @@ -80,13 +82,14 @@ private Q_SLOTS: /* * Drag and drop functions */ - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); + void dragEnterEvent( QDragEnterEvent *event ); + void dropEvent( QDropEvent *event ); void setActiveSubWindow( QWidget *window ); private: QMdiArea *mdiArea; + ModulesHandle *m_pcModulesHandle; QString m_cLastOpenPath; QTimer *playingTimer; @@ -111,10 +114,19 @@ private: QSignalMapper *mapperZoom; QSignalMapper *mapperWindow; - QMenu *menuFile; - QMenu *menuView; - QMenu *menuWindow; - QMenu *menuHelp; + /** + * Array of menus for the main app + * @param position description: + * 0 - Window + * 1 - File + * 2 - View + * 3 - Help + */ + enum MAIN_APP_MENU_LIST + { + WINDOW_MENU = 0, OTHER_MENU, + }; + QVector m_arrayMenu; QToolBar *toolbarFile; QToolBar *toolbarView; From 4513f764a876041fc77bc1cb9c2cefd0148777e3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 22:36:36 +0000 Subject: [PATCH 02/19] Add refresh frame function --- source/SubWindowHandle.cpp | 19 ++++++++++--------- source/SubWindowHandle.h | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 9ea4ca6..7ac4e09 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -94,9 +94,7 @@ bool SubWindowHandle::loadFile( const QString &fileName ) QApplication::restoreOverrideCursor(); - m_pCurrStream->getFrame( m_pCurrFrameQImage ); - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); - + refreshFrame(); normalSize(); m_cWindowName = QString( " " ); @@ -109,6 +107,12 @@ bool SubWindowHandle::loadFile( const QString &fileName ) return true; } +Void SubWindowHandle::refreshFrame() +{ + m_pCurrStream->getFrame( m_pCurrFrameQImage ); + m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); +} + bool SubWindowHandle::save() { QString supported = tr( "Supported Files" ); @@ -154,8 +158,7 @@ bool SubWindowHandle::playEvent() { iRet = false; } - m_pCurrStream->getFrame( m_pCurrFrameQImage ); - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); + refreshFrame(); return iRet; } return false; @@ -165,16 +168,14 @@ Void SubWindowHandle::seekEvent( UInt new_frame_num ) { m_pCurrStream->seekInput( new_frame_num ); m_pCurrStream->readFrame(); - m_pCurrStream->getFrame( m_pCurrFrameQImage ); - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); + refreshFrame(); } Void SubWindowHandle::stopEvent() { m_pCurrStream->seekInput( 0 ); m_pCurrStream->readFrame(); - m_pCurrStream->getFrame( m_pCurrFrameQImage ); - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); + refreshFrame(); return; } diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index e92233b..985bc2e 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -70,6 +70,8 @@ public: Void stopEvent(); Void seekEvent( UInt new_frame_num ); + Void refreshFrame(); + InputStream* getInputStream() { return m_pCurrStream; From 65858b219268b8a691800ff7930f5ddcf018f159 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 22:45:27 +0000 Subject: [PATCH 03/19] Add filter frame lib. initial commit --- CMakeLists.txt | 2 ++ cmake/ModuleFilterFrame.cmake | 6 ++++ source/ModulesHandle.h | 12 +------ source/modules/FilterFrame.cpp | 48 +++++++++++++++++++++++++++ source/modules/FilterFrame.h | 54 +++++++++++++++++++++++++++++++ source/modules/PlaYUVerModuleIf.h | 54 +++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+), 11 deletions(-) create mode 100644 cmake/ModuleFilterFrame.cmake create mode 100644 source/modules/FilterFrame.cpp create mode 100644 source/modules/FilterFrame.h create mode 100644 source/modules/PlaYUVerModuleIf.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 880b77d..4114040 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,8 @@ INCLUDE( cmake/LibFFmpeg.cmake ) # PlaYUVer modules build ###################################################################################### SET( MODULES_DIR ${SRC_DIR}/modules ) +FILE( GLOB ModuleCMakeFiles cmake/Module*.cmake ) +INCLUDE( ${ModuleCMakeFiles} ) ###################################################################################### # Create config.h diff --git a/cmake/ModuleFilterFrame.cmake b/cmake/ModuleFilterFrame.cmake new file mode 100644 index 0000000..cd6ad4f --- /dev/null +++ b/cmake/ModuleFilterFrame.cmake @@ -0,0 +1,6 @@ +###################################################################################### +# Filter frame module +###################################################################################### + +INCLUDE_DIRECTORIES( ${MODULES_DIR} ) +ADD_LIBRARY( ModuleFilterFrame ${MODULES_DIR}/FilterFrame.cpp ) diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h index 2780bec..1fa3d61 100644 --- a/source/ModulesHandle.h +++ b/source/ModulesHandle.h @@ -54,17 +54,7 @@ private: }; -class PlaYUVerModuleIf -{ -public: - virtual Void create(); - virtual Void process(); - virtual Void close(); - - virtual ~PlaYUVerModuleIf() {} -}; - } // NAMESPACE -#endif // __PLAYUVERFRAME_H__ +#endif // __MODULESHANDLE_H__ diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp new file mode 100644 index 0000000..2e2526e --- /dev/null +++ b/source/modules/FilterFrame.cpp @@ -0,0 +1,48 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 by plaYUVer developers + * + * 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 FilterFrame.cpp + * \brief Filter frame module + */ + +#include + +#include "FilterFrame.h" +#include "PlaYUVerFrame.h" + +namespace plaYUVer +{ + +FilterFrame::FilterFrame() +{ + +} + +FilterFrame::~FilterFrame() +{ + +} + +PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ) +{ + +} + +} // NAMESPACE + diff --git a/source/modules/FilterFrame.h b/source/modules/FilterFrame.h new file mode 100644 index 0000000..d99145b --- /dev/null +++ b/source/modules/FilterFrame.h @@ -0,0 +1,54 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 by plaYUVer developers + * + * 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 FilterFrame.h + * \brief Filter frame module + */ + +#ifndef __FILTERFRAME_H__ +#define __FILTERFRAME_H__ + +#include "config.h" + +#include +#include +#include "TypeDef.h" +#include "PlaYUVerFrame.h" +#include "PlaYUVerModuleIf.h" + + +namespace plaYUVer +{ + +class FilterFrame : public PlaYUVerModuleIf +{ +public: + FilterFrame(); + ~FilterFrame(); + + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); + +private: + +}; + +} // NAMESPACE + +#endif // __FILTERFRAME_H__ + diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h new file mode 100644 index 0000000..cd3555b --- /dev/null +++ b/source/modules/PlaYUVerModuleIf.h @@ -0,0 +1,54 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 by plaYUVer developers + * + * 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 PlaYUVerModuleIf.h + * \brief PlaYUVer modules interface + */ + +#ifndef __PLAYUVERMODULESIF_H__ +#define __PLAYUVERMODULESIF_H__ + +#include "config.h" + +#include +#include + +#include "TypeDef.h" +#include "PlaYUVerFrame.h" + +namespace plaYUVer +{ + +class PlaYUVerModuleIf +{ +public: + virtual Void create(); + + virtual Void process(); + virtual PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); + + virtual Void close(); + + virtual ~PlaYUVerModuleIf() {} +}; + +} // NAMESPACE + +#endif // __PLAYUVERMODULESIF_H__ + From c9549d5d4072666666179db8fe43d69152ed61bb Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 23:32:17 +0000 Subject: [PATCH 04/19] Add a function to copy PlaYUVerFrame --- source/PlaYUVerFrame.cpp | 27 +++++++++++++++++++++++++-- source/PlaYUVerFrame.h | 5 +++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index 7f93389..f0ad873 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -165,9 +165,7 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) { return; } - UInt64 frame_bytes_input = m_uiWidth * m_uiHeight; - switch( m_iPixelFormat ) { case YUV420: @@ -185,6 +183,31 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) } } +Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) +{ + if( m_iPixelFormat != input_frame->getPelFormat() ) + { + return; + } + UInt64 num_bytes = m_uiWidth * m_uiHeight; + switch( m_iPixelFormat ) + { + case YUV420: + input_frame->getPelBufferYUV() + memcpy( &m_pppcInputPel[0][0][0], &( input_frame->getPelBufferYUV()[0][0][0] ), num_bytes * sizeof(Pel) ); + memcpy( &m_pppcInputPel[1][0][0], &( input_frame->getPelBufferYUV()[1][0][0] ), num_bytes / 4 * sizeof(Pel) ); + memcpy( &m_pppcInputPel[2][0][0], &( input_frame->getPelBufferYUV()[2][0][0] ), num_bytes / 4 * sizeof(Pel) ); + YUV420toRGB(); + break; + case YUV422: + break; + case YUV400: + break; + case RGB: + break; + } +} + UInt64 PlaYUVerFrame::getBytesPerFrame() { switch( m_iPixelFormat ) diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index 5823561..7a2961f 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -45,6 +45,7 @@ public: static QStringList supportedPixelFormatList(); Void FrameFromBuffer( Pel *input_buffer, Int pel_format ); + Void CopyFrom( PlaYUVerFrame* ); UInt64 getBytesPerFrame(); @@ -56,6 +57,10 @@ public: { return m_pppcRGBPel; } + Int getPelFormat() + { + return m_iPixelFormat; + } private: Void YUV420toRGB(); From 401fdf3c329f26bc1c80fd05997116f4a08fc39f Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 23:33:13 +0000 Subject: [PATCH 05/19] Bug fix: remove unused code --- source/PlaYUVerFrame.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index f0ad873..6c84840 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -193,7 +193,6 @@ Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) switch( m_iPixelFormat ) { case YUV420: - input_frame->getPelBufferYUV() memcpy( &m_pppcInputPel[0][0][0], &( input_frame->getPelBufferYUV()[0][0][0] ), num_bytes * sizeof(Pel) ); memcpy( &m_pppcInputPel[1][0][0], &( input_frame->getPelBufferYUV()[1][0][0] ), num_bytes / 4 * sizeof(Pel) ); memcpy( &m_pppcInputPel[2][0][0], &( input_frame->getPelBufferYUV()[2][0][0] ), num_bytes / 4 * sizeof(Pel) ); From 8d5d98c8ac9bf629afc74415feb31a8b237e855c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 8 Feb 2014 23:39:30 +0000 Subject: [PATCH 06/19] Add function to return PlaYUVerFrame size --- source/PlaYUVerFrame.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index 7a2961f..cb048b0 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -57,6 +57,14 @@ public: { return m_pppcRGBPel; } + UInt getWidth() + { + return m_uiWidth; + } + UInt getHeight() + { + return m_uiHeight; + } Int getPelFormat() { return m_iPixelFormat; From 589622f18a2d28c91c6f814c799a47caa93f6b34 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 04:23:05 +0000 Subject: [PATCH 07/19] Finish first version of the modules inferface. still missing the proper connections --- CMakeLists.txt | 5 +-- cmake/CMakeMacros.cmake | 11 ++++++- source/ModulesHandle.cpp | 40 ++++++++++++++++++++--- source/ModulesHandle.h | 25 +++++++++++--- source/modules/PlaYUVerModuleIf.h | 54 +++++++++++++++++++++++++++---- source/plaYUVerApp.cpp | 2 ++ 6 files changed, 118 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4114040..4ab9297 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,11 +70,12 @@ INCLUDE( cmake/LibFFmpeg.cmake ) # PlaYUVer modules build ###################################################################################### SET( MODULES_DIR ${SRC_DIR}/modules ) +INCLUDE_DIRECTORIES( ${MODULES_DIR} ) FILE( GLOB ModuleCMakeFiles cmake/Module*.cmake ) INCLUDE( ${ModuleCMakeFiles} ) ###################################################################################### -# Create config.h +# Main config.h ###################################################################################### CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h ) @@ -83,7 +84,7 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_D ###################################################################################### ADD_EXECUTABLE( ${PROJECT_NAME} ${SOURCES_FILES} ${HEADERS_MOC_FILES} ${FORMS_HEADERS_FILES} ${RESOURCES_RCC_FILES} ) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LINKER_LIBS} ) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${MODULES_LIBS} ${LINKER_LIBS} ) IF( NOT USE_QT4) QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} ) diff --git a/cmake/CMakeMacros.cmake b/cmake/CMakeMacros.cmake index 3b381f6..bd11e8c 100644 --- a/cmake/CMakeMacros.cmake +++ b/cmake/CMakeMacros.cmake @@ -94,4 +94,13 @@ function(status text) else() message(STATUS "${text}") endif() -endfunction() \ No newline at end of file +endfunction() + + +macro(ADD_MODULE name files ) + set(__modulename "Module${name}") + add_library( ${__modulename} ${files} ) + set(MODULES_LIBS ${MODULES_LIBS} ${__modulename}) + ADD_DEFINITIONS( -DUSE_${name} ) + unset(__modulename) +endmacro() \ No newline at end of file diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index c516c0e..b3d2ddf 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -24,14 +24,18 @@ #include #include "ModulesHandle.h" - +#include "FilterFrame.h" namespace plaYUVer { -ModulesHandle::ModulesHandle() +ModulesHandle::ModulesHandle( QWidget * parent ) { + setParent( parent ); + m_uiModulesCount = 0; + // Register Modules + REGISTER_MODULE( FilterFrame ); } ModulesHandle::~ModulesHandle() @@ -39,11 +43,37 @@ ModulesHandle::~ModulesHandle() } -Void ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) +Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule ) { - MainAppMenuBar->addMenu( "&Modules" ); + m_pcPlaYUVerModules.append( pIfModule ); + m_uiModulesCount++; + } +Void ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) +{ + PlaYUVerModuleIf* currModuleIf; + QAction* currAction; + + m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); + + //m_arrayModulesActions.resize( m_uiModulesCount ); + + for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) + { + + currModuleIf = m_pcPlaYUVerModules.at( i ); + + currAction = new QAction( tr( currModuleIf->m_pchModuleName ), parent() ); + currAction->setStatusTip( tr( currModuleIf->m_pchModuleTooltip ) ); + + m_arrayModulesActions.append( currAction ); + + m_pcModulesMenu->addAction( currAction ); + } + + //MainAppMenuBar-> +} } // NAMESPACE - + diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h index 1fa3d61..5506561 100644 --- a/source/ModulesHandle.h +++ b/source/ModulesHandle.h @@ -37,24 +37,39 @@ #endif #include "TypeDef.h" +#include "PlaYUVerModuleIf.h" namespace plaYUVer { -class ModulesHandle -{ +#define REGISTER_MODULE(X) \ + { \ + if( USE_##X ) \ + { \ + X *pMod = new X(); \ + appendModule( pMod ); \ + } \ + } +class ModulesHandle : public QObject +{ + Q_OBJECT public: - ModulesHandle(); + ModulesHandle( QWidget * parent = 0 ); ~ModulesHandle(); Void createMenus( QMenuBar *MainAppMenuBar ); private: - + QMenu* m_pcModulesMenu; + UInt m_uiModulesCount; + QList m_pcPlaYUVerModules; + QVector m_arrayModulesActions; + + Void appendModule( PlaYUVerModuleIf* ); }; } // NAMESPACE #endif // __MODULESHANDLE_H__ - + diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index cd3555b..00be23c 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -32,23 +32,65 @@ #include "TypeDef.h" #include "PlaYUVerFrame.h" +class QImage; + namespace plaYUVer { +#define REGISTER_MODULE_NAME( type, name, tooltip ) \ + m_pchModuleType = type; \ + m_pchModuleName = name; \ + m_pchModuleTooltip = tooltip; + + class PlaYUVerModuleIf { public: - virtual Void create(); + PlaYUVerModuleIf() : + m_pchModuleType( NULL ), m_pchModuleName( NULL ), m_pchModuleTooltip( NULL ) + { + } + virtual ~PlaYUVerModuleIf() + { + } - virtual Void process(); - virtual PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); + const Char* m_pchModuleType; + const Char* m_pchModuleName; + const Char* m_pchModuleTooltip; - virtual Void close(); + virtual Void create() + { + } + + virtual Void create( QImage* ) + { + } + + virtual Void create( PlaYUVerFrame* ) + { + } + + virtual Void process() + { + } + + virtual QImage* process( QImage* ) + { + return NULL; + } + + virtual PlaYUVerFrame* process( PlaYUVerFrame* ) + { + return NULL; + } + + virtual Void destroy() + { + } - virtual ~PlaYUVerModuleIf() {} }; } // NAMESPACE #endif // __PLAYUVERMODULESIF_H__ - + diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 0290c13..06bd797 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -51,6 +51,8 @@ plaYUVerApp::plaYUVerApp() mapperWindow = new QSignalMapper( this ); connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) ); + m_pcModulesHandle = new ModulesHandle(this); + createActions(); createMenus(); createToolBars(); From f8345f54e5c58158f724ee7826717216e2da50a7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 04:23:53 +0000 Subject: [PATCH 08/19] Add first test module --- cmake/ModuleFilterFrame.cmake | 4 ++-- source/modules/FilterFrame.cpp | 17 ++++++++++------- source/modules/FilterFrame.h | 31 ++++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/cmake/ModuleFilterFrame.cmake b/cmake/ModuleFilterFrame.cmake index cd6ad4f..a443698 100644 --- a/cmake/ModuleFilterFrame.cmake +++ b/cmake/ModuleFilterFrame.cmake @@ -2,5 +2,5 @@ # Filter frame module ###################################################################################### -INCLUDE_DIRECTORIES( ${MODULES_DIR} ) -ADD_LIBRARY( ModuleFilterFrame ${MODULES_DIR}/FilterFrame.cpp ) +ADD_MODULE( FilterFrame "${MODULES_DIR}/FilterFrame.cpp" ) + diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 2e2526e..d503680 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -26,23 +26,26 @@ #include "FilterFrame.h" #include "PlaYUVerFrame.h" + + namespace plaYUVer { -FilterFrame::FilterFrame() +Void FilterFrame::create( PlaYUVerFrame* InputFrame ) { - + m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), InputFrame->getPelFormat() ); } -FilterFrame::~FilterFrame() +PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) { - + m_pcFilteredFrame->CopyFrom( InputFrame ); + return m_pcFilteredFrame; } -PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ) +Void FilterFrame::destroy() { - + delete m_pcFilteredFrame; } } // NAMESPACE - + diff --git a/source/modules/FilterFrame.h b/source/modules/FilterFrame.h index d99145b..b40dcc9 100644 --- a/source/modules/FilterFrame.h +++ b/source/modules/FilterFrame.h @@ -32,23 +32,36 @@ #include "PlaYUVerFrame.h" #include "PlaYUVerModuleIf.h" +#include namespace plaYUVer { -class FilterFrame : public PlaYUVerModuleIf +const Char ModuleType[] = "Filter"; +const Char ModuleName[] = "Y_Filter"; +const Char ModuleTooltip[] = "Filter Y matrix of YUV frame"; + +class FilterFrame: public PlaYUVerModuleIf { -public: - FilterFrame(); - ~FilterFrame(); - - PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); - private: - + PlaYUVerFrame* m_pcFilteredFrame; + +public: + FilterFrame() + { + REGISTER_MODULE_NAME(ModuleType, ModuleName, ModuleTooltip ) + m_pcFilteredFrame = NULL; + } + virtual ~FilterFrame() + { + } + + Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); + Void destroy(); }; } // NAMESPACE #endif // __FILTERFRAME_H__ - + From 1c28febd179e622fdd5b38401c515ebb1dec3b16 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 18:24:55 +0000 Subject: [PATCH 09/19] Add a function to return a PlaYUVerFrame in InputStream --- source/InputStream.cpp | 14 +++++++++++++- source/InputStream.h | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/InputStream.cpp b/source/InputStream.cpp index 9e7c478..be94925 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -249,7 +249,7 @@ Bool InputStream::writeFrame( const QString& filename ) return true; } -Void InputStream::getFrame( QImage *qimage ) +QImage* InputStream::getFrame( QImage *qimage ) { Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB(); @@ -267,6 +267,18 @@ Void InputStream::getFrame( QImage *qimage ) { Q_ASSERT( 0 ); } + return qimage; +} + +PlaYUVerFrame* InputStream::getFrame( PlaYUVerFrame *pyuv_image ) +{ + Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB(); + + if( pyuv_image == NULL ) + pyuv_image = new PlaYUVerFrame( m_cCurrFrame->getWidth(), m_cCurrFrame->getHeight(), m_cCurrFrame->getPelFormat() ); + + pyuv_image->CopyFrom(m_cCurrFrame); + return pyuv_image; } #ifdef USE_OPENCV diff --git a/source/InputStream.h b/source/InputStream.h index 7935d41..cda8c39 100755 --- a/source/InputStream.h +++ b/source/InputStream.h @@ -103,7 +103,8 @@ public: Bool writeFrame( const QString& filename ); - Void getFrame( QImage *qimage ); + QImage* getFrame( QImage *qimage ); + PlaYUVerFrame* getFrame( PlaYUVerFrame *qimage ); #ifdef USE_OPENCV cv::Mat getFrameCvMat(); #endif From 4be68f5bae9a081baa7f1212de9421d98cce18ed Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 18:25:28 +0000 Subject: [PATCH 10/19] Interface for modules in SubWindowHandle and plaYUVerApp --- source/ModulesHandle.cpp | 38 +++++++++++++++++++++++------- source/ModulesHandle.h | 10 ++++++-- source/SubWindowHandle.cpp | 20 +++++++++++++--- source/SubWindowHandle.h | 9 +++++++ source/modules/FilterFrame.cpp | 14 +++++++++-- source/modules/FilterFrame.h | 6 +++++ source/modules/PlaYUVerModuleIf.h | 33 +++++--------------------- source/plaYUVerApp.cpp | 39 ++++++++++++++++++++++--------- source/plaYUVerApp.h | 3 +++ 9 files changed, 119 insertions(+), 53 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index b3d2ddf..fac9a67 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -31,11 +31,15 @@ namespace plaYUVer ModulesHandle::ModulesHandle( QWidget * parent ) { - setParent( parent ); - m_uiModulesCount = 0; - // Register Modules REGISTER_MODULE( FilterFrame ); + + + + // configure class + setParent( parent ); + m_uiModulesCount = 0; + m_uiModuleSelected= -1; } ModulesHandle::~ModulesHandle() @@ -46,32 +50,50 @@ ModulesHandle::~ModulesHandle() Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule ) { m_pcPlaYUVerModules.append( pIfModule ); - m_uiModulesCount++; + m_uiModulesCount++; } -Void ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) +void ModulesHandle::selectModule( int index ) +{ + m_uiModuleSelected = index; +} + +PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf() +{ + PlaYUVerModuleIf* currModuleIf = NULL; + if( m_uiModuleSelected >= 0 ) + return m_pcPlaYUVerModules.at( m_uiModuleSelected ); + m_uiModuleSelected = -1; + return currModuleIf; +} + +QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) { PlaYUVerModuleIf* currModuleIf; QAction* currAction; + m_pcActionMapper = new QSignalMapper( this ); + connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) ); + m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); //m_arrayModulesActions.resize( m_uiModulesCount ); for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) { - currModuleIf = m_pcPlaYUVerModules.at( i ); currAction = new QAction( tr( currModuleIf->m_pchModuleName ), parent() ); currAction->setStatusTip( tr( currModuleIf->m_pchModuleTooltip ) ); - + currAction->setCheckable( true ); + connect( currAction, SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) ); + m_pcActionMapper->setMapping( currAction, i ); m_arrayModulesActions.append( currAction ); m_pcModulesMenu->addAction( currAction ); } - + return m_pcModulesMenu; //MainAppMenuBar-> } diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h index 5506561..4391828 100644 --- a/source/ModulesHandle.h +++ b/source/ModulesHandle.h @@ -58,15 +58,21 @@ public: ModulesHandle( QWidget * parent = 0 ); ~ModulesHandle(); - Void createMenus( QMenuBar *MainAppMenuBar ); + QMenu* createMenus( QMenuBar *MainAppMenuBar ); + PlaYUVerModuleIf* getSelectedModuleIf(); private: - QMenu* m_pcModulesMenu; UInt m_uiModulesCount; + Int m_uiModuleSelected; + QMenu* m_pcModulesMenu; QList m_pcPlaYUVerModules; + QSignalMapper* m_pcActionMapper; QVector m_arrayModulesActions; Void appendModule( PlaYUVerModuleIf* ); + +private Q_SLOTS: + void selectModule( int index ); }; } // NAMESPACE diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 7ac4e09..9119127 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -46,6 +46,8 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : // Define the cViewArea as the widget inside the scroll area m_cScrollArea->setWidget( m_cViewArea ); + m_pcCurrentModule = NULL; + m_cWindowName = QString( " " ); m_bIsPlaying = true; m_dScaleFactor = 1; @@ -107,10 +109,23 @@ bool SubWindowHandle::loadFile( const QString &fileName ) return true; } +Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) +{ + m_pcCurrentModule = select_module; + m_pcCurrentModule->create( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); + refreshFrame(); +} + Void SubWindowHandle::refreshFrame() { - m_pCurrStream->getFrame( m_pCurrFrameQImage ); - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); + if( m_pcCurrentModule ) + { + m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); + } + else + { + m_cViewArea->setImage( QPixmap::fromImage( *( m_pCurrStream->getFrame( m_pCurrFrameQImage ) ) ) ); + } } bool SubWindowHandle::save() @@ -179,7 +194,6 @@ Void SubWindowHandle::stopEvent() return; } - Void SubWindowHandle::normalSize() { m_dScaleFactor = 1.0; diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index 985bc2e..6423487 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -35,6 +35,7 @@ #include "TypeDef.h" #include "InputStream.h" #include "viewarea.h" +#include "PlaYUVerModuleIf.h" namespace plaYUVer { @@ -50,6 +51,8 @@ private: QScrollArea* m_cScrollArea; ViewArea* m_cViewArea; + PlaYUVerModuleIf* m_pcCurrentModule; + InputStream* m_pCurrStream; QImage* m_pCurrFrameQImage; @@ -77,6 +80,12 @@ public: return m_pCurrStream; } + /** + * Function to enable a module in the + * current SubWindow + */ + Void enableModule( PlaYUVerModuleIf* select_module ); + /** * Show the image at its original size */ diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index d503680..849af81 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -26,8 +26,6 @@ #include "FilterFrame.h" #include "PlaYUVerFrame.h" - - namespace plaYUVer { @@ -38,7 +36,19 @@ Void FilterFrame::create( PlaYUVerFrame* InputFrame ) PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) { + Pel*** pppPelYUV = m_pcFilteredFrame->getPelBufferYUV(); + m_pcFilteredFrame->CopyFrom( InputFrame ); + + for( Int y = 0; y < m_pcFilteredFrame->getHeight() / 2; y++ ) + { + for( Int x = 0; x < m_pcFilteredFrame->getWidth() / 2; x++ ) + { + pppPelYUV[1][y][x] = 128; + pppPelYUV[2][y][x] = 128; + } + } + return m_pcFilteredFrame; } diff --git a/source/modules/FilterFrame.h b/source/modules/FilterFrame.h index b40dcc9..891c1e9 100644 --- a/source/modules/FilterFrame.h +++ b/source/modules/FilterFrame.h @@ -57,8 +57,14 @@ public: } Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); Void destroy(); + + PlaYUVerFrame* getModImage() + { + return m_pcFilteredFrame; + } }; } // NAMESPACE diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 00be23c..86ebd56 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -58,35 +58,14 @@ public: const Char* m_pchModuleName; const Char* m_pchModuleTooltip; - virtual Void create() - { - } + virtual Void create() {}; + virtual Void process() {}; - virtual Void create( QImage* ) - { - } + virtual Void create( PlaYUVerFrame* ) {}; + virtual PlaYUVerFrame* process( PlaYUVerFrame* ) {}; + virtual PlaYUVerFrame* getModImage() {}; - virtual Void create( PlaYUVerFrame* ) - { - } - - virtual Void process() - { - } - - virtual QImage* process( QImage* ) - { - return NULL; - } - - virtual PlaYUVerFrame* process( PlaYUVerFrame* ) - { - return NULL; - } - - virtual Void destroy() - { - } + virtual Void destroy() {}; }; diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 06bd797..b035590 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -51,7 +51,7 @@ plaYUVerApp::plaYUVerApp() mapperWindow = new QSignalMapper( this ); connect( mapperWindow, SIGNAL( mapped(QWidget*) ), this, SLOT( setActiveSubWindow(QWidget*) ) ); - m_pcModulesHandle = new ModulesHandle(this); + m_pcModulesHandle = new ModulesHandle( this ); createActions(); createMenus(); @@ -133,6 +133,22 @@ void plaYUVerApp::save() activeSubWindow()->save(); } +// ----------------------- Modules Selection -------------------- + +void plaYUVerApp::selectModule( QAction *curr_action ) +{ + //emit curr_action->triggered(); + + if( m_pcModulesHandle->getSelectedModuleIf() ) + { + if( activeSubWindow() ) + { + activeSubWindow()->enableModule( m_pcModulesHandle->getSelectedModuleIf() ); + } + } + return; +} + // ----------------------- Playing Functions -------------------- void plaYUVerApp::play() @@ -447,7 +463,7 @@ Void plaYUVerApp::createActions() Void plaYUVerApp::createMenus() { - m_arrayMenu.resize(4); + m_arrayMenu.resize( 4 ); m_arrayMenu[OTHER_MENU] = menuBar()->addMenu( tr( "&File" ) ); m_arrayMenu[OTHER_MENU]->addAction( actionOpen ); @@ -457,13 +473,14 @@ Void plaYUVerApp::createMenus() m_arrayMenu[OTHER_MENU]->addAction( actionClose ); m_arrayMenu[OTHER_MENU]->addAction( actionExit ); - m_arrayMenu[OTHER_MENU+1] = menuBar()->addMenu( tr( "&View" ) ); - m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomIn ); - m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomOut ); - m_arrayMenu[OTHER_MENU+1]->addAction( actionNormalSize ); - m_arrayMenu[OTHER_MENU+1]->addAction( actionZoomToFit ); + m_arrayMenu[OTHER_MENU + 1] = menuBar()->addMenu( tr( "&View" ) ); + m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomIn ); + m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomOut ); + m_arrayMenu[OTHER_MENU + 1]->addAction( actionNormalSize ); + m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomToFit ); - m_pcModulesHandle->createMenus( menuBar() ); + QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); + connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) ); m_arrayMenu[WINDOW_MENU] = menuBar()->addMenu( tr( "&Window" ) ); updateWindowMenu(); @@ -471,9 +488,9 @@ Void plaYUVerApp::createMenus() menuBar()->addSeparator(); - m_arrayMenu[OTHER_MENU+2] = menuBar()->addMenu( tr( "&Help" ) ); - m_arrayMenu[OTHER_MENU+2]->addAction( actionAbout ); - m_arrayMenu[OTHER_MENU+2]->addAction( actionAboutQt ); + m_arrayMenu[OTHER_MENU + 2] = menuBar()->addMenu( tr( "&Help" ) ); + m_arrayMenu[OTHER_MENU + 2]->addAction( actionAbout ); + m_arrayMenu[OTHER_MENU + 2]->addAction( actionAboutQt ); } Void plaYUVerApp::createToolBars() diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index 1981e8d..a6c2ec0 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -63,6 +63,9 @@ private Q_SLOTS: void stop(); void playEvent(); void seekSliderEvent( int new_frame_num ); + + void selectModule( QAction * ); + /** * Scale the image by a given factor * @param factor factor of scale. Ex: 120 scale the image up by 20% and From a96db8ea57e18199d4766f2a0019fa85ed2c91fb Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 18:48:27 +0000 Subject: [PATCH 11/19] Add full interface to enable and disable a module in each SubWindow --- source/SubWindowHandle.cpp | 32 ++++++++++++++++++++++++++++++-- source/SubWindowHandle.h | 4 +++- source/modules/FilterFrame.cpp | 2 +- source/plaYUVerApp.cpp | 6 ++++++ source/plaYUVerApp.h | 1 + 5 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 9119127..47281f8 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -109,6 +109,10 @@ bool SubWindowHandle::loadFile( const QString &fileName ) return true; } +/** + * Functions to enable a module in the + * current SubWindow + */ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) { m_pcCurrentModule = select_module; @@ -116,16 +120,40 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) refreshFrame(); } +Void SubWindowHandle::disableModule() +{ + m_pcCurrentModule->destroy(); + m_pcCurrentModule = NULL; + refreshFrame(); +} + +QImage* SubWindowHandle::FrameToQImage( PlaYUVerFrame* curr_frame ) +{ + Pel*** bufferRGB = curr_frame->getPelBufferRGB(); + + curr_frame->YUV420toRGB(); + + for( Int y = 0; y < curr_frame->getHeight(); y++ ) + { + for( Int x = 0; x < curr_frame->getWidth(); x++ ) + { + m_pCurrFrameQImage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) ); + } + } + return m_pCurrFrameQImage; +} + Void SubWindowHandle::refreshFrame() { if( m_pcCurrentModule ) { - m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); + FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ) ); } else { - m_cViewArea->setImage( QPixmap::fromImage( *( m_pCurrStream->getFrame( m_pCurrFrameQImage ) ) ) ); + FrameToQImage( m_pCurrStream->getFrame( (PlaYUVerFrame*) NULL ) ); } + m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); } bool SubWindowHandle::save() diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index 6423487..4d90f98 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -73,6 +73,7 @@ public: Void stopEvent(); Void seekEvent( UInt new_frame_num ); + QImage* FrameToQImage( PlaYUVerFrame* curr_frame ); Void refreshFrame(); InputStream* getInputStream() @@ -81,10 +82,11 @@ public: } /** - * Function to enable a module in the + * Functions to enable a module in the * current SubWindow */ Void enableModule( PlaYUVerModuleIf* select_module ); + Void disableModule(); /** * Show the image at its original size diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 849af81..8aa66b3 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -48,7 +48,7 @@ PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) pppPelYUV[2][y][x] = 128; } } - + m_pcFilteredFrame->YUV420toRGB(); return m_pcFilteredFrame; } diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index b035590..9401a07 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -71,6 +71,8 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); + + m_pcCurrentSubWindow = NULL; } Void plaYUVerApp::closeEvent( QCloseEvent *event ) @@ -231,8 +233,12 @@ void plaYUVerApp::chageSubWindowSelection() playingTimer->stop(); if( activeSubWindow() ) { + if( m_pcCurrentSubWindow ) + m_pcCurrentSubWindow->disableModule(); + m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); + m_pcCurrentSubWindow = activeSubWindow(); } updateMenus(); //updateWindowMenu(); diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index a6c2ec0..a7b3705 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -92,6 +92,7 @@ private Q_SLOTS: private: QMdiArea *mdiArea; + SubWindowHandle *m_pcCurrentSubWindow; ModulesHandle *m_pcModulesHandle; QString m_cLastOpenPath; From 87cad865fecea5d80a44705392a5b73e1acd3a82 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 9 Feb 2014 18:57:24 +0000 Subject: [PATCH 12/19] Remove unecessary conversion from YUV2RGB inside PlaYUVerFrame --- source/PlaYUVerFrame.cpp | 4 ++-- source/PlaYUVerFrame.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index 6c84840..cfbd498 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -172,7 +172,7 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) memcpy( &m_pppcInputPel[0][0][0], input_buffer, frame_bytes_input * sizeof(Pel) ); memcpy( &m_pppcInputPel[1][0][0], input_buffer + frame_bytes_input, frame_bytes_input / 4 * sizeof(Pel) ); memcpy( &m_pppcInputPel[2][0][0], input_buffer + frame_bytes_input * 5 / 4, frame_bytes_input / 4 * sizeof(Pel) ); - YUV420toRGB(); + //YUV420toRGB(); break; case YUV422: break; @@ -196,7 +196,7 @@ Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) memcpy( &m_pppcInputPel[0][0][0], &( input_frame->getPelBufferYUV()[0][0][0] ), num_bytes * sizeof(Pel) ); memcpy( &m_pppcInputPel[1][0][0], &( input_frame->getPelBufferYUV()[1][0][0] ), num_bytes / 4 * sizeof(Pel) ); memcpy( &m_pppcInputPel[2][0][0], &( input_frame->getPelBufferYUV()[2][0][0] ), num_bytes / 4 * sizeof(Pel) ); - YUV420toRGB(); + //YUV420toRGB(); break; case YUV422: break; diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index cb048b0..e57d65c 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -44,6 +44,8 @@ public: static QStringList supportedPixelFormatList(); + Void YUV420toRGB(); + Void FrameFromBuffer( Pel *input_buffer, Int pel_format ); Void CopyFrom( PlaYUVerFrame* ); @@ -70,9 +72,6 @@ public: return m_iPixelFormat; } private: - - Void YUV420toRGB(); - UInt m_uiWidth; UInt m_uiHeight; Int m_iPixelFormat; From 468d525b165a2090a3a64e5cc302ea28f52bd25d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 21 Feb 2014 18:58:07 +0000 Subject: [PATCH 13/19] Add feature to disable current module --- source/ModulesHandle.cpp | 7 ++++++- source/SubWindowHandle.cpp | 7 +++++++ source/modules/FilterFrame.cpp | 8 ++++++-- source/modules/PlaYUVerModuleIf.h | 5 +++++ source/plaYUVerApp.cpp | 8 ++++---- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index fac9a67..68fd201 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -62,8 +62,11 @@ void ModulesHandle::selectModule( int index ) PlaYUVerModuleIf* ModulesHandle::getSelectedModuleIf() { PlaYUVerModuleIf* currModuleIf = NULL; + if( m_uiModuleSelected >= 0 ) - return m_pcPlaYUVerModules.at( m_uiModuleSelected ); + //if( m_arrayModulesActions.at(m_uiModuleSelected)->isChecked() ) + currModuleIf = m_pcPlaYUVerModules.at( m_uiModuleSelected ); + m_uiModuleSelected = -1; return currModuleIf; } @@ -92,6 +95,8 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) m_arrayModulesActions.append( currAction ); m_pcModulesMenu->addAction( currAction ); + + currModuleIf->m_pcAction = currAction; } return m_pcModulesMenu; //MainAppMenuBar-> diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 47281f8..f780d61 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -115,6 +115,11 @@ bool SubWindowHandle::loadFile( const QString &fileName ) */ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) { + if( m_pcCurrentModule == select_module ) + { + disableModule(); + return; + } m_pcCurrentModule = select_module; m_pcCurrentModule->create( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); refreshFrame(); @@ -122,6 +127,8 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) Void SubWindowHandle::disableModule() { + if( !m_pcCurrentModule ) + return; m_pcCurrentModule->destroy(); m_pcCurrentModule = NULL; refreshFrame(); diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 8aa66b3..ec1ea51 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -31,6 +31,8 @@ namespace plaYUVer Void FilterFrame::create( PlaYUVerFrame* InputFrame ) { + if( m_pcFilteredFrame ) + delete m_pcFilteredFrame; m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), InputFrame->getPelFormat() ); } @@ -48,13 +50,15 @@ PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) pppPelYUV[2][y][x] = 128; } } - m_pcFilteredFrame->YUV420toRGB(); + //m_pcFilteredFrame->YUV420toRGB(); return m_pcFilteredFrame; } Void FilterFrame::destroy() { - delete m_pcFilteredFrame; + if( m_pcFilteredFrame ) + delete m_pcFilteredFrame; + m_pcFilteredFrame = NULL; } } // NAMESPACE diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 86ebd56..21677cd 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -33,6 +33,7 @@ #include "PlaYUVerFrame.h" class QImage; +class QAction; namespace plaYUVer { @@ -54,6 +55,8 @@ public: { } + QAction* m_pcAction; + const Char* m_pchModuleType; const Char* m_pchModuleName; const Char* m_pchModuleTooltip; @@ -65,6 +68,8 @@ public: virtual PlaYUVerFrame* process( PlaYUVerFrame* ) {}; virtual PlaYUVerFrame* getModImage() {}; + virtual QImage* process( QImage* ) {}; + virtual Void destroy() {}; }; diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 9401a07..dafb56d 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -140,12 +140,12 @@ void plaYUVerApp::save() void plaYUVerApp::selectModule( QAction *curr_action ) { //emit curr_action->triggered(); - - if( m_pcModulesHandle->getSelectedModuleIf() ) + if( activeSubWindow() ) { - if( activeSubWindow() ) + PlaYUVerModuleIf* pcCurrMod = m_pcModulesHandle->getSelectedModuleIf(); + if( pcCurrMod ) { - activeSubWindow()->enableModule( m_pcModulesHandle->getSelectedModuleIf() ); + activeSubWindow()->enableModule( pcCurrMod ); } } return; From 4560b4e2d89ff830be48689bd1660554489df17e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 21 Feb 2014 18:58:26 +0000 Subject: [PATCH 14/19] Increase the resolution limit --- source/ConfigureFormatDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ConfigureFormatDialog.cpp b/source/ConfigureFormatDialog.cpp index 31848df..1c068af 100755 --- a/source/ConfigureFormatDialog.cpp +++ b/source/ConfigureFormatDialog.cpp @@ -124,7 +124,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : widthLabel->setText( QApplication::translate( "ConfigureFormat", "Width", 0 ) ); widthSpinBox = new QSpinBox(); widthSpinBox->setObjectName( QStringLiteral( "widthSpinBox" ) ); - widthSpinBox->setRange( 0, 5000 ); + widthSpinBox->setRange( 0, 7240 ); widthSpinBox->setValue( 0 ); heightLabel = new QLabel(); @@ -132,7 +132,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : heightLabel->setText( QApplication::translate( "ConfigureFormat", "Height", 0 ) ); heightSpinBox = new QSpinBox(); heightSpinBox->setObjectName( QStringLiteral( "heightSpinBox" ) ); - heightSpinBox->setRange( 0, 5000 ); + heightSpinBox->setRange( 0, 5432 ); heightSpinBox->setValue( 0 ); pixelsLabel = new QLabel(); From 0d6aa2b5bc3567b72dd2c72b51baab81a936b9b5 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 23 Feb 2014 01:16:03 +0000 Subject: [PATCH 15/19] Change functions related with PlaYUVerFrame and QImage --- source/InputStream.cpp | 30 ++++++------------------------ source/InputStream.h | 4 ++-- source/PlaYUVerFrame.cpp | 24 ++++++++++++++++++++++++ source/PlaYUVerFrame.h | 4 ++++ source/SubWindowHandle.cpp | 4 ++-- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/source/InputStream.cpp b/source/InputStream.cpp index be94925..7ae34bc 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -243,33 +243,10 @@ Void InputStream::readFrame() Bool InputStream::writeFrame( const QString& filename ) { - QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 ); - getFrame( &img ); - img.save( filename ); + m_cCurrFrame->getQimage().save( filename ); return true; } -QImage* InputStream::getFrame( QImage *qimage ) -{ - Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB(); - - if( sizeof(Pel) == sizeof(unsigned char) ) - { - for( Int y = 0; y < m_uiHeight; y++ ) - { - for( Int x = 0; x < m_uiWidth; x++ ) - { - qimage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) ); - } - } - } - else - { - Q_ASSERT( 0 ); - } - return qimage; -} - PlaYUVerFrame* InputStream::getFrame( PlaYUVerFrame *pyuv_image ) { Pel*** bufferRGB = m_cCurrFrame->getPelBufferRGB(); @@ -281,6 +258,11 @@ PlaYUVerFrame* InputStream::getFrame( PlaYUVerFrame *pyuv_image ) return pyuv_image; } +PlaYUVerFrame* InputStream::getFrame() +{ + return m_cCurrFrame; +} + #ifdef USE_OPENCV cv::Mat InputStream::getFrameCvMat() { diff --git a/source/InputStream.h b/source/InputStream.h index cda8c39..07251c0 100755 --- a/source/InputStream.h +++ b/source/InputStream.h @@ -103,8 +103,8 @@ public: Bool writeFrame( const QString& filename ); - QImage* getFrame( QImage *qimage ); - PlaYUVerFrame* getFrame( PlaYUVerFrame *qimage ); + PlaYUVerFrame* getFrame(); + PlaYUVerFrame* getFrame( PlaYUVerFrame * ); #ifdef USE_OPENCV cv::Mat getFrameCvMat(); #endif diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index cfbd498..459977c 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -25,6 +25,8 @@ #include "PlaYUVerFrame.h" #include "LibMemAlloc.h" +#include + namespace plaYUVer { @@ -207,6 +209,28 @@ Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) } } +QImage PlaYUVerFrame::getQimage() +{ + QImage img( m_uiWidth, m_uiHeight, QImage::Format_RGB888 ); + Pel*** bufferRGB = getPelBufferRGB(); + + if( sizeof(Pel) == sizeof(unsigned char) ) + { + for( Int y = 0; y < m_uiHeight; y++ ) + { + for( Int x = 0; x < m_uiWidth; x++ ) + { + img.setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) ); + } + } + } + else + { + Q_ASSERT( 0 ); + } + return img; +} + UInt64 PlaYUVerFrame::getBytesPerFrame() { switch( m_iPixelFormat ) diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index e57d65c..b98a086 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -33,6 +33,8 @@ #include "TypeDef.h" +class QImage; + namespace plaYUVer { @@ -59,6 +61,8 @@ public: { return m_pppcRGBPel; } + QImage getQimage(); + UInt getWidth() { return m_uiWidth; diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index f780d61..0d73b54 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -121,7 +121,7 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) return; } m_pcCurrentModule = select_module; - m_pcCurrentModule->create( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ); + m_pcCurrentModule->create( m_pCurrStream->getFrame() ); refreshFrame(); } @@ -154,7 +154,7 @@ Void SubWindowHandle::refreshFrame() { if( m_pcCurrentModule ) { - FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getFrame( m_pcCurrentModule->getModImage() ) ) ); + FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getFrame() ) ); } else { From 8b098468afa7b608b980186c1c9e40637336b22d Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 23 Feb 2014 01:16:58 +0000 Subject: [PATCH 16/19] Change module definition --- source/ModulesHandle.cpp | 4 ++-- source/modules/FilterFrame.cpp | 13 +++++++++++++ source/modules/FilterFrame.h | 10 +--------- source/modules/PlaYUVerModuleIf.h | 21 +++++++++------------ 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index 68fd201..b0ae046 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -87,8 +87,8 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) { currModuleIf = m_pcPlaYUVerModules.at( i ); - currAction = new QAction( tr( currModuleIf->m_pchModuleName ), parent() ); - currAction->setStatusTip( tr( currModuleIf->m_pchModuleTooltip ) ); + currAction = new QAction( tr( currModuleIf->m_cModuleDef.m_pchModuleName ), parent() ); + currAction->setStatusTip( tr( currModuleIf->m_cModuleDef.m_pchModuleTooltip ) ); currAction->setCheckable( true ); connect( currAction, SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) ); m_pcActionMapper->setMapping( currAction, i ); diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index ec1ea51..912e1a3 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -29,6 +29,19 @@ namespace plaYUVer { +PlaYUVerModuleDefinition FilterFrameDef = { + "FrameLevel", + "Y_Filter", + "Filter Y matrix of YUV frame", +}; + +FilterFrame::FilterFrame() +{ + m_cModuleDef = FilterFrameDef; + + m_pcFilteredFrame = NULL; +} + Void FilterFrame::create( PlaYUVerFrame* InputFrame ) { if( m_pcFilteredFrame ) diff --git a/source/modules/FilterFrame.h b/source/modules/FilterFrame.h index 891c1e9..36bbf23 100644 --- a/source/modules/FilterFrame.h +++ b/source/modules/FilterFrame.h @@ -37,21 +37,13 @@ namespace plaYUVer { -const Char ModuleType[] = "Filter"; -const Char ModuleName[] = "Y_Filter"; -const Char ModuleTooltip[] = "Filter Y matrix of YUV frame"; - class FilterFrame: public PlaYUVerModuleIf { private: PlaYUVerFrame* m_pcFilteredFrame; public: - FilterFrame() - { - REGISTER_MODULE_NAME(ModuleType, ModuleName, ModuleTooltip ) - m_pcFilteredFrame = NULL; - } + FilterFrame(); virtual ~FilterFrame() { } diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 21677cd..4a4b15b 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -38,18 +38,20 @@ class QAction; namespace plaYUVer { -#define REGISTER_MODULE_NAME( type, name, tooltip ) \ - m_pchModuleType = type; \ - m_pchModuleName = name; \ - m_pchModuleTooltip = tooltip; +typedef struct __PlaYUVerModuleDefinition +{ + const char *m_pchModuleType; + const char *m_pchModuleName; + const char *m_pchModuleTooltip; +}PlaYUVerModuleDefinition; class PlaYUVerModuleIf { public: - PlaYUVerModuleIf() : - m_pchModuleType( NULL ), m_pchModuleName( NULL ), m_pchModuleTooltip( NULL ) + PlaYUVerModuleIf() { + m_pcAction = NULL; } virtual ~PlaYUVerModuleIf() { @@ -57,18 +59,13 @@ public: QAction* m_pcAction; - const Char* m_pchModuleType; - const Char* m_pchModuleName; - const Char* m_pchModuleTooltip; + PlaYUVerModuleDefinition m_cModuleDef; virtual Void create() {}; virtual Void process() {}; virtual Void create( PlaYUVerFrame* ) {}; virtual PlaYUVerFrame* process( PlaYUVerFrame* ) {}; - virtual PlaYUVerFrame* getModImage() {}; - - virtual QImage* process( QImage* ) {}; virtual Void destroy() {}; From b4979106b922130b7e077e992d58ca8a42f1f317 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 22 Mar 2014 15:51:23 +0000 Subject: [PATCH 17/19] Improve modules interface. Add a variable to mark the module category and type. change some function in the plaYUVerApp to fix modules disabling when closing a sub window --- source/ModulesHandle.cpp | 21 +++++++++++++---- source/ModulesHandle.h | 1 + source/SubWindowHandle.cpp | 6 +++++ source/modules/FilterFrame.cpp | 3 ++- source/modules/PlaYUVerModuleIf.h | 13 ++++++++--- source/plaYUVerApp.cpp | 39 +++++++++++++++++-------------- source/plaYUVerApp.h | 6 ++++- 7 files changed, 63 insertions(+), 26 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index b0ae046..ae189ec 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -35,7 +35,6 @@ ModulesHandle::ModulesHandle( QWidget * parent ) REGISTER_MODULE( FilterFrame ); - // configure class setParent( parent ); m_uiModulesCount = 0; @@ -51,7 +50,6 @@ Void ModulesHandle::appendModule( PlaYUVerModuleIf* pIfModule ) { m_pcPlaYUVerModules.append( pIfModule ); m_uiModulesCount++; - } void ModulesHandle::selectModule( int index ) @@ -75,6 +73,7 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) { PlaYUVerModuleIf* currModuleIf; QAction* currAction; + Bool bCategoryExists = false; m_pcActionMapper = new QSignalMapper( this ); connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) ); @@ -82,11 +81,16 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); //m_arrayModulesActions.resize( m_uiModulesCount ); - +Int total = 0; for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) { currModuleIf = m_pcPlaYUVerModules.at( i ); + for( Int j = 0; j < total; j++ ) + { + + } + currAction = new QAction( tr( currModuleIf->m_cModuleDef.m_pchModuleName ), parent() ); currAction->setStatusTip( tr( currModuleIf->m_cModuleDef.m_pchModuleTooltip ) ); currAction->setCheckable( true ); @@ -99,7 +103,16 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) currModuleIf->m_pcAction = currAction; } return m_pcModulesMenu; - //MainAppMenuBar-> +} + +Void ModulesHandle::updateMenus( Bool hasSubWindow ) +{ + QAction* currModuleAction; + for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) + { + currModuleAction = m_arrayModulesActions.at( i ); + currModuleAction->setEnabled( hasSubWindow ); + } } } // NAMESPACE diff --git a/source/ModulesHandle.h b/source/ModulesHandle.h index 4391828..7f11044 100644 --- a/source/ModulesHandle.h +++ b/source/ModulesHandle.h @@ -59,6 +59,7 @@ public: ~ModulesHandle(); QMenu* createMenus( QMenuBar *MainAppMenuBar ); + Void updateMenus( Bool hasSubWindow ); PlaYUVerModuleIf* getSelectedModuleIf(); private: diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 0d73b54..645dfe5 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -57,6 +57,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) : SubWindowHandle::~SubWindowHandle() { delete m_cViewArea; + if( !m_pcCurrentModule ) + return; + m_pcCurrentModule->m_pcAction->setChecked( false ); + m_pcCurrentModule->destroy(); + m_pcCurrentModule = NULL; } bool SubWindowHandle::loadFile( const QString &fileName ) @@ -129,6 +134,7 @@ Void SubWindowHandle::disableModule() { if( !m_pcCurrentModule ) return; + m_pcCurrentModule->destroy(); m_pcCurrentModule = NULL; refreshFrame(); diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp index 912e1a3..e3842d0 100644 --- a/source/modules/FilterFrame.cpp +++ b/source/modules/FilterFrame.cpp @@ -30,7 +30,8 @@ namespace plaYUVer { PlaYUVerModuleDefinition FilterFrameDef = { - "FrameLevel", + FRAME_LEVEL_MODULE, + "Filters" "Y_Filter", "Filter Y matrix of YUV frame", }; diff --git a/source/modules/PlaYUVerModuleIf.h b/source/modules/PlaYUVerModuleIf.h index 4a4b15b..5f2fe6f 100644 --- a/source/modules/PlaYUVerModuleIf.h +++ b/source/modules/PlaYUVerModuleIf.h @@ -38,11 +38,18 @@ class QAction; namespace plaYUVer { +enum __PlaYUVerModuleTypes +{ + FRAME_LEVEL_MODULE, + VIDEO_LEVEL_MODULE, +}; + typedef struct __PlaYUVerModuleDefinition { - const char *m_pchModuleType; - const char *m_pchModuleName; - const char *m_pchModuleTooltip; + int m_pchModuleType; + char* m_pchModuleCategory; + char* m_pchModuleName; + char* m_pchModuleTooltip; }PlaYUVerModuleDefinition; diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 964b6d5..5ee2767 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -237,11 +237,14 @@ void plaYUVerApp::chageSubWindowSelection() { if( m_pcCurrentSubWindow ) m_pcCurrentSubWindow->disableModule(); - m_pcFrameSlider->setMaximum( activeSubWindow()->getInputStream()->getFrameNum() - 1 ); m_pcFrameSlider->setValue( activeSubWindow()->getInputStream()->getCurrFrameNum() ); m_pcCurrentSubWindow = activeSubWindow(); } + else + { + m_pcCurrentSubWindow = NULL; + } updateMenus(); //updateWindowMenu(); } @@ -267,6 +270,8 @@ Void plaYUVerApp::updateMenus() actionVideoBackward->setEnabled( hasSubWindow ); actionVideoForward->setEnabled( hasSubWindow ); m_pcFrameSlider->setEnabled( hasSubWindow ); + + m_pcModulesHandle->updateMenus( hasSubWindow ); } void plaYUVerApp::updateWindowMenu() @@ -471,21 +476,21 @@ Void plaYUVerApp::createActions() Void plaYUVerApp::createMenus() { - m_arrayMenu.resize( 4 ); + m_arrayMenu.resize( TOTAL_MENUS ); - m_arrayMenu[OTHER_MENU] = menuBar()->addMenu( tr( "&File" ) ); - m_arrayMenu[OTHER_MENU]->addAction( actionOpen ); - m_arrayMenu[OTHER_MENU]->addSeparator(); - m_arrayMenu[OTHER_MENU]->addAction( actionSave ); - m_arrayMenu[OTHER_MENU]->addSeparator(); - m_arrayMenu[OTHER_MENU]->addAction( actionClose ); - m_arrayMenu[OTHER_MENU]->addAction( actionExit ); + m_arrayMenu[FILE_MENU] = menuBar()->addMenu( tr( "&File" ) ); + m_arrayMenu[FILE_MENU]->addAction( actionOpen ); + m_arrayMenu[FILE_MENU]->addSeparator(); + m_arrayMenu[FILE_MENU]->addAction( actionSave ); + m_arrayMenu[FILE_MENU]->addSeparator(); + m_arrayMenu[FILE_MENU]->addAction( actionClose ); + m_arrayMenu[FILE_MENU]->addAction( actionExit ); - m_arrayMenu[OTHER_MENU + 1] = menuBar()->addMenu( tr( "&View" ) ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomIn ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomOut ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionNormalSize ); - m_arrayMenu[OTHER_MENU + 1]->addAction( actionZoomToFit ); + m_arrayMenu[VIEW_MENU] = menuBar()->addMenu( tr( "&View" ) ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomIn ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomOut ); + m_arrayMenu[VIEW_MENU]->addAction( actionNormalSize ); + m_arrayMenu[VIEW_MENU]->addAction( actionZoomToFit ); QMenu* modules_menu = m_pcModulesHandle->createMenus( menuBar() ); connect( modules_menu, SIGNAL( triggered(QAction *) ), this, SLOT( selectModule(QAction *) ) ); @@ -496,9 +501,9 @@ Void plaYUVerApp::createMenus() menuBar()->addSeparator(); - m_arrayMenu[OTHER_MENU + 2] = menuBar()->addMenu( tr( "&Help" ) ); - m_arrayMenu[OTHER_MENU + 2]->addAction( actionAbout ); - m_arrayMenu[OTHER_MENU + 2]->addAction( actionAboutQt ); + m_arrayMenu[ABOUT_MENU] = menuBar()->addMenu( tr( "&Help" ) ); + m_arrayMenu[ABOUT_MENU]->addAction( actionAbout ); + m_arrayMenu[ABOUT_MENU]->addAction( actionAboutQt ); } Void plaYUVerApp::createToolBars() diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index a7b3705..82e9a0a 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -128,7 +128,11 @@ private: */ enum MAIN_APP_MENU_LIST { - WINDOW_MENU = 0, OTHER_MENU, + FILE_MENU = 0, + VIEW_MENU, + WINDOW_MENU, + ABOUT_MENU, + TOTAL_MENUS, }; QVector m_arrayMenu; From c84dc1b95d6a9ae907dcc4551884ef1c78988399 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 22 Mar 2014 16:05:16 +0000 Subject: [PATCH 18/19] Minor bugfix due to incomplete code --- source/ModulesHandle.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/ModulesHandle.cpp b/source/ModulesHandle.cpp index ae189ec..9b6b1a1 100644 --- a/source/ModulesHandle.cpp +++ b/source/ModulesHandle.cpp @@ -74,6 +74,7 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) PlaYUVerModuleIf* currModuleIf; QAction* currAction; Bool bCategoryExists = false; + Int iNumberCategories = 0; m_pcActionMapper = new QSignalMapper( this ); connect( m_pcActionMapper, SIGNAL( mapped(int) ), this, SLOT( selectModule(int) ) ); @@ -81,16 +82,11 @@ QMenu* ModulesHandle::createMenus( QMenuBar *MainAppMenuBar ) m_pcModulesMenu = MainAppMenuBar->addMenu( "&Modules" ); //m_arrayModulesActions.resize( m_uiModulesCount ); -Int total = 0; + for( Int i = 0; i < m_pcPlaYUVerModules.size(); i++ ) { currModuleIf = m_pcPlaYUVerModules.at( i ); - for( Int j = 0; j < total; j++ ) - { - - } - currAction = new QAction( tr( currModuleIf->m_cModuleDef.m_pchModuleName ), parent() ); currAction->setStatusTip( tr( currModuleIf->m_cModuleDef.m_pchModuleTooltip ) ); currAction->setCheckable( true ); From c6fe21ef9ca2aa7fb984474a9a1fc8c71749ff6a Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 22 Mar 2014 16:06:06 +0000 Subject: [PATCH 19/19] Add an output message to display build type --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc74fa..4d2058e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,8 @@ IF( NOT USE_QT4) QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} ) ENDIF() - +status("Configuration:") +status(" Build type:" ${CMAKE_BUILD_TYPE} ) status("Dependencies:") status(" QT:" USE_QT4 THEN "QT4" ELSE "QT5" ) status(" Use OpenCV:" USE_OPENCV THEN YES ELSE NO)