diff --git a/CMakeLists.txt b/CMakeLists.txt index ee98942..b755155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,8 +125,8 @@ ADD_EXECUTABLE( ${PROJECT_NAME} ${SOURCES_FILES} ${HEADERS_MOC_FILES} ${FORMS_HE TARGET_LINK_LIBRARIES( ${PROJECT_NAME} PlaYUVerLib ${MODULES_LIBS} ${LINKER_LIBS} ) -IF( NOT USE_QT4) - QT5_USE_MODULES( ${PROJECT_NAME} ${CURR_QT_MODULES} ) +IF( NOT USE_QT4 ) + QT5_USE_MODULES( ${PROJECT_NAME} ${QT_MODULES} ) ENDIF() INCLUDE(cmake/Install.cmake) diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 642c0ee..5f4fd68 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -9,42 +9,7 @@ INSTALL(FILES ${RSC_DIR}/x-raw.xml DESTINATION share/mime/video ) INSTALL(FILES ${CMAKE_BINARY_DIR}/PlaYUVerConfig.cmake DESTINATION share/playuver ) IF( WIN32 ) - IF( NOT USE_QT4 ) - INSTALL(FILES ${QT_DIR}/bin/QT5Core${QT_DLL_POSTFIX}.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/Qt5Gui${QT_DLL_POSTFIX}.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/Qt5Widgets${QT_DLL_POSTFIX}.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/libGLESv2${QT_DLL_POSTFIX}.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/libEGL${QT_DLL_POSTFIX}.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/icudt52.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/icuin52.dll DESTINATION bin ) - INSTALL(FILES ${QT_DIR}/bin/icuuc52.dll DESTINATION bin ) - - INSTALL(FILES ${QT_DIR}/plugins/platforms/qminimal.dll DESTINATION bin/platforms ) - INSTALL(FILES ${QT_DIR}/plugins/platforms/qoffscreen.dll DESTINATION bin/platforms ) - INSTALL(FILES ${QT_DIR}/plugins/platforms/qwindows.dll DESTINATION bin/platforms ) - ENDIF() - IF( USE_OPENCV ) - SET(OpenCV_DLL_DIR "${OpenCV_DIR}/bin" CACHE PATH "Where to find OpenCV dlls") - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_core${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_contrib${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_highgui${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_contrib${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_imgproc${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_calib3d${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_features2d${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_flann${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_ml${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_video${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_videostab${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_superres${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_stitching${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_photo${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_objdetect${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_nonfree${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_legacy${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_gpu${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) - ENDIF() - + SET(MSVC_DLL_DIR "MSVC_DLL_DIR" CACHE PATH "Where to find MSVC dlls") INSTALL(FILES ${MSVC_DLL_DIR}/msvcr120.dll DESTINATION bin ) INSTALL(FILES ${MSVC_DLL_DIR}/msvcp120.dll DESTINATION bin ) diff --git a/cmake/LibFervor.cmake b/cmake/LibFervor.cmake index b6fb941..ac13ba5 100644 --- a/cmake/LibFervor.cmake +++ b/cmake/LibFervor.cmake @@ -13,6 +13,34 @@ IF( USE_FERVOR ) ADD_SUBDIRECTORY( ${FERVOR_DIR} ) INCLUDE_DIRECTORIES( ${FERVOR_DIR} ) LIST(APPEND LINKER_LIBS "Fervor" ) + + FIND_PACKAGE( Qt5Network REQUIRED ) + FIND_PACKAGE( Qt5WebKit REQUIRED ) + FIND_PACKAGE( Qt5WebKitWidgets REQUIRED ) + LIST(APPEND LINKER_LIBS ${FERVOR_DEPENDENCIES} ) + INCLUDE_DIRECTORIES( ${FERVOR_INCLUDE_DIRS} ) + + SET(QT_USE_QTNETWORK true) + SET(QT_USE_QTWEBKIT true) + + IF( WIN32 ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Network${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5WebKit${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5WebKitWidgets${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Quick${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Qml${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Multimedia${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Sql${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Positioning${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Sensors${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5MultimediaWidgets${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5OpenGL${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5PrintSupport${QT_DLL_POSTFIX}.dll DESTINATION bin ) + + ENDIF() + + LIST(APPEND QT_MODULES Network WebKit WebKitWidgets ) + ELSE() MESSAGE( "Fervor lib source code is not find in ${FERVOR_DIR}... Disabling it!" ) SET( USE_FERVOR False ) diff --git a/cmake/LibOpenCV.cmake b/cmake/LibOpenCV.cmake index 39b4be6..1437796 100644 --- a/cmake/LibOpenCV.cmake +++ b/cmake/LibOpenCV.cmake @@ -9,4 +9,26 @@ IF( USE_OPENCV ) ELSE() LIST(APPEND LINKER_LIBS ${OpenCV_LIBRARIES} ) ENDIF() + + IF( WIN32 ) + SET(OpenCV_DLL_DIR "${OpenCV_DIR}/bin" CACHE PATH "Where to find OpenCV dlls") + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_core${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_contrib${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_highgui${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_contrib${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_imgproc${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_calib3d${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_features2d${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_flann${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_ml${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_video${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_videostab${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_superres${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_stitching${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_photo${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_objdetect${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_nonfree${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_legacy${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + INSTALL(FILES ${OpenCV_DLL_DIR}/opencv_gpu${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll DESTINATION bin ) + ENDIF() ENDIF() \ No newline at end of file diff --git a/cmake/LibQT.cmake b/cmake/LibQT.cmake index 223f167..99944ff 100644 --- a/cmake/LibQT.cmake +++ b/cmake/LibQT.cmake @@ -9,32 +9,51 @@ IF( WIN32 ) ENDIF() IF( USE_QT4 ) - FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui QtNetwork QtWebKit ) - IF( NOT QT4_FOUND) - SET(USE_QT4 FALSE) - ENDIF() - INCLUDE( ${QT_USE_FILE} ) - ADD_DEFINITIONS( ${QT_DEFINITIONS} ) - - QT4_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} ) - QT4_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} ) - LIST(APPEND LINKER_LIBS ${QT_LIBRARIES} ) + + FIND_PACKAGE( Qt4 REQUIRED QtCore QtGui QtNetwork QtWebKit ) + IF( NOT QT4_FOUND) + SET(USE_QT4 FALSE) + ENDIF() + INCLUDE( ${QT_USE_FILE} ) + ADD_DEFINITIONS( ${QT_DEFINITIONS} ) + + QT4_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} ) + QT4_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} ) + LIST(APPEND LINKER_LIBS ${QT_LIBRARIES} ) + ENDIF() IF( NOT USE_QT4 ) - FIND_PACKAGE( Qt5Core REQUIRED ) - FIND_PACKAGE( Qt5Gui REQUIRED ) - FIND_PACKAGE( Qt5Widgets REQUIRED ) - FIND_PACKAGE( Qt5Network REQUIRED ) + + FIND_PACKAGE( Qt5Core REQUIRED ) + FIND_PACKAGE( Qt5Gui REQUIRED ) + FIND_PACKAGE( Qt5Widgets REQUIRED ) + + INCLUDE_DIRECTORIES( ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ) + # QT5_WRAP_CPP( HEADERS_MOC_FILES ${HEADERS_FILES} ) + QT5_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} ) + QT5_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} ) + + # Add compiler flags for building executables (-fPIE) + LIST(APPEND CMAKE_CXX_FLAGS ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} ) + + LIST(APPEND LINKER_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ) + + IF( WIN32 ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Core${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Gui${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/Qt5Widgets${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/libGLESv2${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/libEGL${QT_DLL_POSTFIX}.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/icudt52.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/icuin52.dll DESTINATION bin ) + INSTALL(FILES ${QT_DIR}/bin/icuuc52.dll DESTINATION bin ) - INCLUDE_DIRECTORIES( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ) - # QT5_WRAP_CPP( HEADERS_MOC_FILES ${HEADERS_FILES} ) - QT5_WRAP_UI( FORMS_HEADERS_FILES ${FORMS_FILES} ) - QT5_ADD_RESOURCES( RESOURCES_RCC_FILES ${RESOURCES_FILES} ) - - # Add compiler flags for building executables (-fPIE) - LIST(APPEND CMAKE_CXX_FLAGS ${Qt5Core_EXECUTABLE_COMPILE_FLAGS} ) - - LIST(APPEND LINKER_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ) - SET( CURR_QT_MODULES Core Gui Widgets ) + INSTALL(FILES ${QT_DIR}/plugins/platforms/qminimal.dll DESTINATION bin/platforms ) + INSTALL(FILES ${QT_DIR}/plugins/platforms/qoffscreen.dll DESTINATION bin/platforms ) + INSTALL(FILES ${QT_DIR}/plugins/platforms/qwindows.dll DESTINATION bin/platforms ) + ENDIF() + + LIST(APPEND QT_MODULES Core Gui Widgets ) + ENDIF() diff --git a/cmake/ModuleDefault.cmake b/cmake/ModuleDefault.cmake index cefe152..c8cba74 100644 --- a/cmake/ModuleDefault.cmake +++ b/cmake/ModuleDefault.cmake @@ -4,7 +4,7 @@ ADD_MODULE( FilterFrame "FilterFrame.cpp" ) ADD_MODULE( FrameDifference "FrameDifference.cpp" ) -#ADD_MODULE( MeasurePSNR "MeasurePSNR.cpp" ) +ADD_MODULE( MeasurePSNR "MeasurePSNR.cpp" ) IF( USE_OPENCV ) ADD_MODULE( DisparityStereoVar "DisparityStereoVar.cpp" ) diff --git a/config.h.in b/config.h.in index 960df62..be6401b 100644 --- a/config.h.in +++ b/config.h.in @@ -31,7 +31,7 @@ #define PLAYUVER_VERSION_MINOR @PLAYUVER_VERSION_MINOR@ #define PLAYUVER_VERSION_PATCH @PLAYUVER_VERSION_PATCH@ #define PLAYUVER_VERSION @PLAYUVER_VERSION@ - +#define PLAYUVER_VERSION_STRING "@PLAYUVER_VERSION@" /* QT definition */ #cmakedefine USE_QT4 diff --git a/resources/playuver-background-logo.png b/resources/playuver-background-logo.png new file mode 100644 index 0000000..6792338 Binary files /dev/null and b/resources/playuver-background-logo.png differ diff --git a/resources/playuver.qrc b/resources/playuver.qrc index 7a54937..5c16513 100755 --- a/resources/playuver.qrc +++ b/resources/playuver.qrc @@ -1,6 +1,8 @@ icons/playuver.png + playuver-background-logo.png + icons/open.png icons/save.png icons/close.png diff --git a/source/app/AboutDialog.cpp b/source/app/AboutDialog.cpp new file mode 100644 index 0000000..ff6142f --- /dev/null +++ b/source/app/AboutDialog.cpp @@ -0,0 +1,74 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 AboutDialog.cpp + * \brief About Dialog + * Based on the work of Glad Deschrijver in KTikZ project + */ + + +#include "AboutDialog.h" +#include +#include +#include +#include +#include + +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) +{ + QLabel *pixmapLabel = new QLabel; + //pixmapLabel->setPixmap(QPixmap(":/icons/qtikz-128.png")); + QLabel *label = new QLabel(QString("

%1 %2

%3

%4

") + .arg(QApplication::applicationName()) + .arg(QApplication::applicationVersion()) + .arg(tr("Copyright 2014 Luis Lucas and Joao Carreira")) + .arg(tr("plaYUVer is an open-source QT based raw video player."))); + label->setWordWrap(true); + + QWidget *topWidget = new QWidget; + QHBoxLayout *topLayout = new QHBoxLayout; + topLayout->addWidget(pixmapLabel); + topLayout->addWidget(label); + topWidget->setLayout(topLayout); + + QTextEdit *textEdit = new QTextEdit(tr("

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.

")); + textEdit->setReadOnly(true); + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok); + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + + QVBoxLayout *mainLayout = new QVBoxLayout(this); + mainLayout->addWidget(topWidget); + mainLayout->addWidget(textEdit); + mainLayout->addWidget(buttonBox); + mainLayout->setSpacing(10); + buttonBox->setFocus(); + + setWindowTitle(tr("About %1").arg("playuver")); +} diff --git a/source/app/AboutDialog.h b/source/app/AboutDialog.h new file mode 100644 index 0000000..4470655 --- /dev/null +++ b/source/app/AboutDialog.h @@ -0,0 +1,39 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 AboutDialog.h + * \brief About Dialog + * Based on the work of Glad Deschrijver in KTikZ project + */ + +#ifndef __ABOUTDIALOG_H__ +#define __ABOUTDIALOG_H__ + +#include + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + AboutDialog(QWidget *parent = 0); +}; + +#endif // __ABOUTDIALOG_H__ diff --git a/source/app/ConfigureFormatDialog.cpp b/source/app/ConfigureFormatDialog.cpp index d2d1105..5425404 100644 --- a/source/app/ConfigureFormatDialog.cpp +++ b/source/app/ConfigureFormatDialog.cpp @@ -43,10 +43,12 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : // Config dialog - setStandardResolutionSizes(); + struct PlaYUVerStream::StandardResolution stdRes = PlaYUVerStream::standardResolutionSizes(); + standardResolutionNames = stdRes.stringListFullName; + standardResolutionSizes = stdRes.sizeResolution; setObjectName( QStringLiteral( "ConfigureFormat" ) ); - resize( 392, 350 ); + resize( 392, 370 ); setWindowTitle( "Configure Resolution" ); setWindowIcon( QIcon( ":/images/configureformat.png" ) ); @@ -68,6 +70,20 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : 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->setText( "Test" ); + filenameLayout->addWidget( filenameLabel ); + filenameLayout->addItem( new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + filenameLayout->addWidget( m_labelFilename ); + MainLayout->addLayout( filenameLayout ); + // standardResolutionLayout MainLayout->addItem( new QSpacerItem( 10, 20, QSizePolicy::Minimum ) ); QHBoxLayout* standardResolutionLayout = new QHBoxLayout(); @@ -177,16 +193,18 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) : } -Int ConfigureFormatDialog::runConfigureFormatDialog( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) +Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { // Set default values + m_labelFilename->setText( Filename ); + //m_labelFilename->setText( QFileInfo( Filename ).fileName() ); m_spinBoxWidth->setValue( rWidth ); m_spinBoxheight->setValue( rHeight ); m_comboBoxPixelFormat->setCurrentIndex( rInputFormat >= 0 ? rInputFormat : 0 ); m_spinBoxFrameRate->setValue( rFrameRate ); - for( Int i = 0; i < standardResolutionSizesList.size(); i++ ) + for( Int i = 0; i < standardResolutionSizes.size(); i++ ) { - if( standardResolutionSizesList.at( i ) == QSize( rWidth, rHeight ) ) + if( standardResolutionSizes.at( i ) == QSize( rWidth, rHeight ) ) { m_comboBoxStandardResolution->setCurrentIndex( i ); } @@ -208,7 +226,7 @@ void ConfigureFormatDialog::StandardResolutionSelection() if( currIdx == -1 ) return; - QSize currSize = standardResolutionSizesList.at( currIdx ); + QSize currSize = standardResolutionSizes.at( currIdx ); m_spinBoxWidth->setValue( currSize.width() ); m_spinBoxheight->setValue( currSize.height() ); } diff --git a/source/app/ConfigureFormatDialog.h b/source/app/ConfigureFormatDialog.h index 09b8536..c3d564e 100644 --- a/source/app/ConfigureFormatDialog.h +++ b/source/app/ConfigureFormatDialog.h @@ -56,37 +56,22 @@ Q_OBJECT public: ConfigureFormatDialog( QWidget *parent = 0 ); - Int runConfigureFormatDialog ( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Int runConfigureFormatDialog ( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); private Q_SLOTS: void StandardResolutionSelection(); private: QStringList standardResolutionNames; - QList standardResolutionSizesList; + QVector standardResolutionSizes; + QLabel* m_labelFilename; QComboBox *m_comboBoxStandardResolution; QSpinBox *m_spinBoxWidth; QSpinBox *m_spinBoxheight; QComboBox *m_comboBoxPixelFormat; QSpinBox *m_spinBoxFrameRate; - Void setStandardResolutionSizes() - { - ADD_STANDARD_RESOLUTION( "CIF (352x288)", 352, 288 ); - ADD_STANDARD_RESOLUTION( "VGA (640x480)", 640, 480 ); - ADD_STANDARD_RESOLUTION( "WVGA (832x480)", 832, 480 ); - ADD_STANDARD_RESOLUTION( "XVGA (1024x768)", 1024, 768 ); - ADD_STANDARD_RESOLUTION( "HD (1280x720)", 1280, 720 ); - ADD_STANDARD_RESOLUTION( "SXGA- (1280x900)", 1280, 900 ); - ADD_STANDARD_RESOLUTION( "SXGA (1280x1024)", 1280, 1024 ); - ADD_STANDARD_RESOLUTION( "WSXGA (1440x900)", 1440, 900 ); - ADD_STANDARD_RESOLUTION( "Full HD (1920x1080)", 1920, 1080 ); - ADD_STANDARD_RESOLUTION( "WQXGA (2560x1600)", 2560, 1600 ); - ADD_STANDARD_RESOLUTION( "Ultra HD (3840x2160)", 3840, 2160 ); - ADD_STANDARD_RESOLUTION( "8K", 8192, 4608 ); - } - }; } // NAMESPACE diff --git a/source/app/ModuleHandleDock.cpp b/source/app/ModuleHandleDock.cpp new file mode 100644 index 0000000..7f80c04 --- /dev/null +++ b/source/app/ModuleHandleDock.cpp @@ -0,0 +1,97 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 ModuleHandleDock.cpp + * \brief Module handle dock + */ + +#include +#include "ModuleHandleDock.h" +#include "PlaYUVerModuleIf.h" +#include "ModulesHandle.h" + +namespace plaYUVer +{ + +ModuleHandleDock::ModuleHandleDock( QWidget* parent, PlaYUVerModuleIf* moduleIf ) : + QWidget( parent ), + m_pcCurrModuleIf( moduleIf ) +{ + + PlaYUVerModuleDefinition ModuleDef = moduleIf->getModuleDefinition(); + + // ----------------- Dock definition ----------------- + + QString labelStr; + labelStr.append( ModuleDef.m_pchModuleName ); + labelStr.append( " Result:" ); + labelModulueValueLabel = new QLabel( labelStr ); + labelModulueValueLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + + labelModulueReturnValue = new QLabel; + labelModulueReturnValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + + QGridLayout *modulesPropertiesLayout = new QGridLayout; + Int layout_line = 0; + modulesPropertiesLayout->addWidget( labelModulueValueLabel, layout_line, 0 ); + modulesPropertiesLayout->addWidget( labelModulueReturnValue, layout_line, 1 ); + layout_line++; + + modulesPropertiesLayout->setRowStretch( 8, 10 ); + setLayout( modulesPropertiesLayout ); + + setEnabled( true ); + +} + +ModuleHandleDock::~ModuleHandleDock() +{ + +} + +Void ModuleHandleDock::setModulueReturnValue( Double value ) +{ + labelModulueReturnValue->clear(); + QString strValue = QString( "%1" ).arg( value ); + labelModulueReturnValue->setText( strValue ); +} + +Void ModuleHandleDock::visibilityChangedSlot( bool visiblity ) +{ + if( !visiblity && m_pcCurrModuleIf ) + { + PlaYUVerModuleIf* pcCurrentModule = m_pcCurrModuleIf; + m_pcCurrModuleIf = NULL; + ModulesHandle::destroyModuleIf( pcCurrentModule ); + } +} + +QSize ModuleHandleDock::sizeHint() const +{ + QSize currSize = size(); + QSize bestSize( 180, currSize.height() ); + if( currSize.width() < bestSize.width() ) + return bestSize; + else + return currSize; +} + +} // NAMESPACE + diff --git a/source/app/ModuleHandleDock.h b/source/app/ModuleHandleDock.h new file mode 100644 index 0000000..72010bb --- /dev/null +++ b/source/app/ModuleHandleDock.h @@ -0,0 +1,69 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 ModuleHandleDock.h + * \brief Module handle dock + */ + +#ifndef __MODULEHANDLEDOCK_H__ +#define __MODULEHANDLEDOCK_H__ + +#include "config.h" +#include "PlaYUVerDefs.h" +#if( QT_VERSION_PLAYUVER == 5 ) +#include +#elif( QT_VERSION_PLAYUVER == 4 ) +#include +#include +#endif + + +namespace plaYUVer +{ + +class PlaYUVerModuleIf; + +class ModuleHandleDock: public QWidget +{ +Q_OBJECT +public: + ModuleHandleDock( QWidget* parent, PlaYUVerModuleIf* moduleIf ); + ~ModuleHandleDock(); + + Void setModulueReturnValue( Double value ); + + QSize sizeHint() const; + +private: + + PlaYUVerModuleIf* m_pcCurrModuleIf; + + Bool m_bIsVisible; + QLabel* labelModulueValueLabel; + QLabel* labelModulueReturnValue; + +public Q_SLOTS: + void visibilityChangedSlot( bool ); + +}; + +} // NAMESPACE + +#endif // __MODULEHANDLEDOCK_H__ diff --git a/source/app/ModulesHandle.cpp b/source/app/ModulesHandle.cpp index 4e7bfdf..ee857c0 100644 --- a/source/app/ModulesHandle.cpp +++ b/source/app/ModulesHandle.cpp @@ -33,7 +33,7 @@ namespace plaYUVer { -ModulesHandle::ModulesHandle( QWidget * parent, QMdiArea *mdiArea ) : +ModulesHandle::ModulesHandle( QMainWindow * parent, QMdiArea *mdiArea ) : QObject( parent ), m_pcParent( parent ), m_pcMdiArea( mdiArea ), @@ -106,7 +106,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf QString windowName; UInt numberOfFrames = pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames; - if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) + if( numberOfFrames > MODULE_REQUIRES_ONE_FRAME ) // Show dialog to select sub windows { DialogSubWindowSelector dialogWindowsSelection( m_pcParent, m_pcMdiArea, numberOfFrames ); if( dialogWindowsSelection.exec() == QDialog::Accepted ) @@ -133,7 +133,7 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf } else { - windowName.append( pcSubWindow->userFriendlyCurrentFile() ); + windowName.append( pcSubWindow->getWindowName() ); pcCurrModuleIf->m_pcSubWindow[0] = pcSubWindow; } windowName.append( " <" ); @@ -141,18 +141,41 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf windowName.append( ">" ); pcCurrModuleIf->m_pcDisplaySubWindow = NULL; - if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) + if( pcCurrModuleIf->m_cModuleDef.m_iModuleType == FRAME_PROCESSING_MODULE ) { - interfaceChild = new SubWindowHandle( m_pcParent, true ); - interfaceChild->setWindowName( windowName ); - connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent, - SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) ); - pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild; - pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf ); + if( ( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow ) + { + interfaceChild = new SubWindowHandle( m_pcParent, true ); + interfaceChild->setWindowName( windowName ); + connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &, PlaYUVerFrame *) ), m_pcParent, + SLOT( updatePixelValueStatusBar(const QPoint &, PlaYUVerFrame *) ) ); + pcCurrModuleIf->m_pcDisplaySubWindow = interfaceChild; + pcCurrModuleIf->m_pcDisplaySubWindow->setModule( pcCurrModuleIf ); + } + } + else if( pcCurrModuleIf->m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE ) + { + if( pcCurrModuleIf->m_cModuleDef.m_uiModuleRequirements & MODULE_REQUIRES_SIDEBAR ) + { + pcCurrModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrModuleIf ); + QString titleDockWidget; + titleDockWidget.append( pcCurrModuleIf->m_cModuleDef.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 ); + //pcCurrModuleIf->m_pcDockWidget->setAttribute( Qt::WA_DeleteOnClose ); + m_pcParent->addDockWidget( Qt::RightDockWidgetArea, pcCurrModuleIf->m_pcDockWidget ); + + //connect( pcCurrModuleIf->m_pcDockWidget, SIGNAL( visibilityChanged(bool) ), pcCurrModuleIf->m_pcModuleDock, SLOT( visibilityChangedSlot(bool) ) ); + } } + // Create Module pcCurrModuleIf->create( pcCurrModuleIf->m_pcSubWindow[0]->getCurrFrame() ); + // Associate module with subwindows for( UInt i = 0; i < numberOfFrames; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->enableModule( pcCurrModuleIf ); @@ -164,7 +187,16 @@ SubWindowHandle* ModulesHandle::enableModuleIf( PlaYUVerModuleIf *pcCurrModuleIf Void ModulesHandle::destroyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf ) { - pcCurrModuleIf->m_pcAction->setChecked( false ); + if( pcCurrModuleIf->m_pcModuleDock ) + { + pcCurrModuleIf->m_pcModuleDock->close(); + pcCurrModuleIf->m_pcModuleDock = NULL; + } + if( pcCurrModuleIf->m_pcDockWidget ) + { + pcCurrModuleIf->m_pcDockWidget->close(); + pcCurrModuleIf->m_pcDockWidget = NULL; + } if( pcCurrModuleIf->m_pcDisplaySubWindow ) pcCurrModuleIf->m_pcDisplaySubWindow->close(); pcCurrModuleIf->m_pcDisplaySubWindow = NULL; @@ -177,6 +209,13 @@ Void ModulesHandle::destroyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf ) pcCurrModuleIf->m_pcSubWindow[i] = NULL; } } + if( pcCurrModuleIf->m_pcModuleStream ) + { + pcCurrModuleIf->m_pcModuleStream->close(); + delete pcCurrModuleIf->m_pcModuleStream; + pcCurrModuleIf->m_pcModuleStream = NULL; + } + pcCurrModuleIf->m_pcAction->setChecked( false ); pcCurrModuleIf->destroy(); } @@ -200,7 +239,7 @@ Bool ModulesHandle::applyModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Bool isPlay #endif pcCurrModuleIf->run(); - if( pcCurrModuleIf->m_pcDisplaySubWindow ) + if( pcCurrModuleIf->m_pcDisplaySubWindow || pcCurrModuleIf->m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE ) { bRet = true; } @@ -229,14 +268,14 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerModuleIf *pcCurrModuleIf ) QApplication::setOverrideCursor( Qt::WaitCursor ); for( UInt f = 0; f < numberOfFrames; f++ ) { + applyModuleIf( pcCurrModuleIf, false, true ); + //QCoreApplication::processEvents(); + pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame ); for( UInt i = 0; i < numberOfWindows; i++ ) { pcCurrModuleIf->m_pcSubWindow[i]->play(); pcCurrModuleIf->m_pcSubWindow[i]->playEvent(); } - applyModuleIf( pcCurrModuleIf, false, false ); - QCoreApplication::processEvents(); - pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame ); } QApplication::restoreOverrideCursor(); } @@ -251,7 +290,6 @@ Void ModulesHandle::openModuleIfStream( PlaYUVerModuleIf *pcCurrModuleIf ) UInt Width = 0, Height = 0, FrameRate = 30; Int InputFormat = -1; - QString supported = tr( "Supported Files (" ); QStringList formatsList; QStringList formatsExt = PlaYUVerStream::supportedWriteFormatsExt(); @@ -308,6 +346,13 @@ Bool ModulesHandle::showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, PlaYUVerFram return bRet; } +Bool ModulesHandle::showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Double moduleResult ) +{ + Bool bRet = false; + pcCurrModuleIf->m_pcModuleDock->setModulueReturnValue(moduleResult); + return bRet; +} + Void ModulesHandle::swapModulesWindowsIf( PlaYUVerModuleIf *pcCurrModuleIf ) { if( pcCurrModuleIf->m_cModuleDef.m_uiNumberOfFrames == MODULE_REQUIRES_TWO_FRAMES ) @@ -327,7 +372,15 @@ Void ModulesHandle::customEvent( QEvent *event ) PlaYUVerModuleIf::EventData *eventData = ( PlaYUVerModuleIf::EventData* )event; if( eventData->m_bSuccess ) { - showModuleIf( eventData->m_pcModule, eventData->m_pcProcessedFrame ); + switch( eventData->m_pcModule->m_cModuleDef.m_iModuleType ) + { + case FRAME_PROCESSING_MODULE: + showModuleIf( eventData->m_pcModule, eventData->m_pcModule->m_pcProcessedFrame ); + break; + case FRAME_MEASUREMENT_MODULE: + showModuleIf( eventData->m_pcModule, eventData->m_pcModule->m_dMeasurementResult ); + break; + } } } diff --git a/source/app/ModulesHandle.h b/source/app/ModulesHandle.h index 161b800..d65238d 100644 --- a/source/app/ModulesHandle.h +++ b/source/app/ModulesHandle.h @@ -36,19 +36,20 @@ #elif( QT_VERSION_PLAYUVER == 4 ) #include #endif - #include "PlaYUVerModuleIf.h" +#include "PlaYUVerFrame.h" namespace plaYUVer { +class PlaYUVerModuleIf; class SubWindowHandle; class ModulesHandle: public QObject { Q_OBJECT public: - ModulesHandle( QWidget * parent = 0, QMdiArea *mdiArea = 0 ); + ModulesHandle( QMainWindow* parent = 0, QMdiArea *mdiArea = 0 ); ~ModulesHandle(); QMenu* createMenus( QMenuBar* MainAppMenuBar ); @@ -59,11 +60,11 @@ public: static Bool applyModuleIf( PlaYUVerModuleIf* pcCurrModuleIf, Bool isPlaying, Bool disableThreads = false ); static Void swapModulesWindowsIf( PlaYUVerModuleIf *pcCurrModuleIf ); static Bool showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, PlaYUVerFrame* processedFrame ); - + static Bool showModuleIf( PlaYUVerModuleIf *pcCurrModuleIf, Double moduleResult ); static Void applyAllModuleIf( PlaYUVerModuleIf* pcCurrModuleIf ); private: - QWidget *m_pcParent; + QMainWindow *m_pcParent; QMdiArea *m_pcMdiArea; UInt m_uiModulesCount; Int m_iOptionSelected; @@ -101,6 +102,7 @@ private: private Q_SLOTS: void selectModule( int index ); void destroyAllModulesIf(); + }; } // NAMESPACE diff --git a/source/app/PlaYUVerModuleIf.cpp b/source/app/PlaYUVerModuleIf.cpp index 96e531a..3c3172b 100644 --- a/source/app/PlaYUVerModuleIf.cpp +++ b/source/app/PlaYUVerModuleIf.cpp @@ -31,6 +31,8 @@ namespace plaYUVer PlaYUVerModuleIf::PlaYUVerModuleIf() : m_pcAction( NULL ), m_pcDisplaySubWindow( NULL ), + m_pcDockWidget( NULL ), + m_pcModuleDock( NULL ), m_pcModuleStream( NULL ), m_pcProcessedFrame( NULL ) { @@ -42,28 +44,51 @@ PlaYUVerModuleIf::PlaYUVerModuleIf() : void PlaYUVerModuleIf::run() { - switch( m_cModuleDef.m_uiNumberOfFrames ) + m_pcProcessedFrame = NULL; + m_dMeasurementResult = 0; + + if( m_cModuleDef.m_iModuleType == FRAME_PROCESSING_MODULE ) { - case MODULE_REQUIRES_ONE_FRAME: - m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame() ); - break; - case MODULE_REQUIRES_TWO_FRAMES: - m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); - break; - case MODULE_REQUIRES_THREE_FRAMES: - m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() ); - break; + switch( m_cModuleDef.m_uiNumberOfFrames ) + { + case MODULE_REQUIRES_ONE_FRAME: + m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame() ); + break; + case MODULE_REQUIRES_TWO_FRAMES: + m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); + break; + case MODULE_REQUIRES_THREE_FRAMES: + m_pcProcessedFrame = process( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() ); + break; + } } - postProgress( true, m_pcProcessedFrame ); + else if( m_cModuleDef.m_iModuleType == FRAME_MEASUREMENT_MODULE ) + { + switch( m_cModuleDef.m_uiNumberOfFrames ) + { + case MODULE_REQUIRES_ONE_FRAME: + m_dMeasurementResult = measure( m_pcSubWindow[0]->getCurrFrame() ); + break; + case MODULE_REQUIRES_TWO_FRAMES: + m_dMeasurementResult = measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame() ); + break; + case MODULE_REQUIRES_THREE_FRAMES: + m_dMeasurementResult = measure( m_pcSubWindow[0]->getCurrFrame(), m_pcSubWindow[1]->getCurrFrame(), m_pcSubWindow[2]->getCurrFrame() ); + break; + } + } + else + { + return; + } + postProgress( true ); + return; } -Void PlaYUVerModuleIf::postProgress( Bool success, PlaYUVerFrame* pcProcessedFrame ) +Void PlaYUVerModuleIf::postProgress( Bool success ) { - EventData *eventData = new EventData(); - eventData->m_bSuccess = success; - eventData->m_pcProcessedFrame = pcProcessedFrame; - eventData->m_pcModule = this; - if( parent() && pcProcessedFrame ) + EventData *eventData = new EventData( success, this ); + if( parent() ) QCoreApplication::postEvent( parent(), eventData ); } diff --git a/source/app/PlaYUVerModuleIf.h b/source/app/PlaYUVerModuleIf.h index 7c45b42..12c8656 100644 --- a/source/app/PlaYUVerModuleIf.h +++ b/source/app/PlaYUVerModuleIf.h @@ -31,6 +31,7 @@ #include #include "PlaYUVerFrame.h" #include "PlaYUVerStream.h" +#include "ModuleHandleDock.h" class QAction; @@ -40,7 +41,6 @@ namespace plaYUVer enum // Module type { FRAME_PROCESSING_MODULE, - VIDEO_PROCESSING_MODULE, FRAME_MEASUREMENT_MODULE, }; @@ -96,26 +96,30 @@ class PlaYUVerModuleIf private: QAction* m_pcAction; SubWindowHandle* m_pcSubWindow[MAX_NUMBER_FRAMES]; + SubWindowHandle* m_pcDisplaySubWindow; + + QDockWidget* m_pcDockWidget; + ModuleHandleDock* m_pcModuleDock; + PlaYUVerModuleDefinition m_cModuleDef; PlaYUVerStream* m_pcModuleStream; PlaYUVerFrame* m_pcProcessedFrame; + Double m_dMeasurementResult; - Void postProgress( Bool success, PlaYUVerFrame* pcProcessedFrame ); + Void postProgress( Bool success ); public: class EventData: public QEvent { public: - EventData() : + EventData( bool success = false, PlaYUVerModuleIf* module = NULL ) : QEvent( QEvent::User ) { - m_bSuccess = false; - m_pcProcessedFrame = NULL; - m_pcModule = NULL; + m_bSuccess = success; + m_pcModule = module; } Bool m_bSuccess; - PlaYUVerFrame* m_pcProcessedFrame; PlaYUVerModuleIf* m_pcModule; }; @@ -126,14 +130,18 @@ public: virtual Void create() {} virtual Void create( PlaYUVerFrame* ) {} - virtual Void process() {} 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 Void destroy() { } - Void setModuleDefinition( PlaYUVerModuleDefinition def ) { m_cModuleDef = def; } + Void setModuleDefinition( PlaYUVerModuleDefinition def ) { m_cModuleDef = def; } + PlaYUVerModuleDefinition getModuleDefinition() { return m_cModuleDef; } protected: virtual void run(); diff --git a/source/app/PlaYUVerSettings.cpp b/source/app/PlaYUVerSettings.cpp index 13bd8db..f1cab01 100644 --- a/source/app/PlaYUVerSettings.cpp +++ b/source/app/PlaYUVerSettings.cpp @@ -73,16 +73,18 @@ Void PlaYUVerSettings::setSelectedTool( Int tool ) m_settings.setValue( "MainWindow/SelectedTool", tool ); } -Void PlaYUVerSettings::setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties ) +Void PlaYUVerSettings::setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties, Bool statusQualityMeasurement ) { m_settings.setValue( "Dock/StreamProperties", statusStreamProperties ); m_settings.setValue( "Dock/FrameProperties", statusFrameProperties ); + m_settings.setValue( "Dock/QualityMeasurement", statusQualityMeasurement ); } -Void PlaYUVerSettings::getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties ) +Void PlaYUVerSettings::getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties, Bool& statusQualityMeasurement ) { statusStreamProperties = m_settings.value( "Dock/StreamProperties", true ).toBool(); statusFrameProperties = m_settings.value( "Dock/FrameProperties", true ).toBool(); + statusQualityMeasurement = m_settings.value( "Dock/QualityMeasurement", true ).toBool(); } // - - - - - - - - - - - - PLaying Settings - - - - - - - - - - - - - - - - diff --git a/source/app/PlaYUVerSettings.h b/source/app/PlaYUVerSettings.h index 889ef5c..58fe9b9 100644 --- a/source/app/PlaYUVerSettings.h +++ b/source/app/PlaYUVerSettings.h @@ -56,8 +56,8 @@ public: Bool getVideoLock(); Void setPlayingSettings( Bool repeat, Bool lock ); - Void setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties ); - Void getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties ); + Void setDockVisibility( Bool statusStreamProperties, Bool statusFrameProperties, Bool statusQualityMeasurement ); + Void getDockVisibility( Bool& statusStreamProperties, Bool& statusFrameProperties, Bool& statusQualityMeasurement ); // - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - GridManager::Style gridStyle(); diff --git a/source/app/PropertiesSidebar.cpp b/source/app/PropertiesSidebar.cpp index c2017a9..55e8448 100644 --- a/source/app/PropertiesSidebar.cpp +++ b/source/app/PropertiesSidebar.cpp @@ -269,7 +269,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool *pbIsPlayi // ------------------------------------------------------------- - histogramWidget = new HistogramWidget( 256, 140 ); + histogramWidget = new HistogramWidget( 256, 100 ); histogramWidget->setOptions( HistogramWidget::BlinkComputation | HistogramWidget::SelectMode | HistogramWidget::ShowLumaChannel ); histogramWidget->setWhatsThis( tr( "

This is the histogram drawing of " "the selected image channel" ) ); diff --git a/source/app/QualityMeasurementSidebar.cpp b/source/app/QualityMeasurementSidebar.cpp new file mode 100644 index 0000000..a5ad62a --- /dev/null +++ b/source/app/QualityMeasurementSidebar.cpp @@ -0,0 +1,192 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 QualityMeasurementSidebar.cpp + * \brief Definition of the quality measurement sidebar + */ + +#include "PlaYUVerDefs.h" +#include +#include "QualityMeasurementSidebar.h" +#include "SubWindowHandle.h" + +namespace plaYUVer +{ + +QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea *mdiArea ) : + QWidget( parent ), + m_pcMainWindowMdiArea( mdiArea ), + m_pcCurrentSubWindow( NULL ) +{ + + // Side bar area ----------------------------------------------------- + + QLabel *RefLabel = new QLabel( tr( "Ref:" ) ); + RefLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); + + QLabel *RecLabel = new QLabel( tr( "Rec:" ) ); + RecLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); + + m_comboBoxRef = new QComboBox; + m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLength ); + m_comboBoxRef->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed); + updateSubWindowList(); + + QGridLayout *mainLayout = new QGridLayout; + mainLayout->addWidget( RefLabel, 0, 0, Qt::AlignLeft ); + mainLayout->addWidget( m_comboBoxRef, 0, 1, Qt::AlignLeft ); + + m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" ); + m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[LUMA] = new QLabel; + m_ppcLabelQualityValue[LUMA]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + + m_ppcLabelQualityLabel[CHROMA_U] = new QLabel( "PSNR U:" ); + m_ppcLabelQualityLabel[CHROMA_U]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[CHROMA_U] = new QLabel; + m_ppcLabelQualityValue[CHROMA_U]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + + m_ppcLabelQualityLabel[CHROMA_V] = new QLabel( "PSNR V:" ); + m_ppcLabelQualityLabel[CHROMA_V]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + m_ppcLabelQualityValue[CHROMA_V] = new QLabel; + m_ppcLabelQualityValue[CHROMA_V]->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + + QGridLayout *qualityResultsLayout = new QGridLayout; + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[LUMA], 0, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[LUMA], 0, 1 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_U], 1, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_U], 1, 1 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 ); + qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 ); + + QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) ); + statisticsGroup->setLayout( qualityResultsLayout ); + statisticsGroup->setWhatsThis( tr( "

Here you can see the quality results calculated for the " + "selected windows." ) ); + + mainLayout->addWidget( statisticsGroup, 4, 0, 3, 3 ); + + mainLayout->setRowStretch( 8, 10 ); + setLayout( mainLayout ); + + connect( m_comboBoxRef, SIGNAL( activated(int) ), this, SLOT( slotReferenceChanged(int) ) ); + +} + +QualityMeasurementSidebar::~QualityMeasurementSidebar() +{ + +} + +QSize QualityMeasurementSidebar::sizeHint() const +{ + QSize currSize = size(); + QSize bestSize( 240, currSize.height() ); + if( currSize.width() < bestSize.width() ) + return bestSize; + else + return currSize; +} + +Void QualityMeasurementSidebar::updateSubWindowList() +{ + SubWindowHandle *subWindow; + QString currSubWindowName; + m_pcWindowListNames.clear(); + for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ ) + { + subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); + if( subWindow ) + { + currSubWindowName = subWindow->getWindowShortName(); + if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() ) + m_pcWindowListNames.append( currSubWindowName ); + } + } + m_comboBoxRef->clear(); + m_comboBoxRef->insertItems( 0, m_pcWindowListNames ); + + m_comboBoxRef->setCurrentIndex( -1 ); + if( m_pcCurrentSubWindow ) + { + if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() ) + { + Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowShortName() ); + m_comboBoxRef->setCurrentIndex( index ); + } + } + m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents ); +} + +Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow ) +{ + m_pcCurrentSubWindow = subWindow; + updateSidebarData(); +} + +Void QualityMeasurementSidebar::updateSidebarData() +{ + QString value( "0.00" ); + if( m_pcCurrentSubWindow ) + { + if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() ) + { + Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowName() ); + m_comboBoxRef->setCurrentIndex( index ); + + PlaYUVerFrame* currFrame = m_pcCurrentSubWindow->getCurrFrame(); + PlaYUVerFrame* refFrame = refSubWindow->getCurrFrame(); + Double quality; + + for( Int component = 0; component < 3; component++ ) + { + quality = currFrame->getPSNR( refFrame, component ); + m_ppcLabelQualityValue[component]->setText( value.setNum( quality, 'f', 2 ) ); + } + return; + } + } + for( Int component = 0; component < 3; component++ ) + { + m_ppcLabelQualityValue[component]->setText( value ); + } + +} + +Void QualityMeasurementSidebar::slotReferenceChanged( Int index ) +{ + if( index > -1 && m_pcCurrentSubWindow ) + { + SubWindowHandle *subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( index ) ); + if( subWindow ) + { + if( m_pcCurrentSubWindow->getCurrFrame()->haveSameFmt( subWindow->getCurrFrame() ) ) + { + m_pcCurrentSubWindow->setRefSubWindow( subWindow ); + updateSidebarData(); + return; + } + } + } + m_comboBoxRef->setCurrentIndex( -1 ); +} + +} // NAMESPACE + diff --git a/source/app/QualityMeasurementSidebar.h b/source/app/QualityMeasurementSidebar.h new file mode 100644 index 0000000..51bf01e --- /dev/null +++ b/source/app/QualityMeasurementSidebar.h @@ -0,0 +1,81 @@ +/* This file is a part of plaYUVer project + * Copyright (C) 2014 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 QualityMeasurementSidebar.h + * \brief Definition of the quality measurement sidebar + */ + +#ifndef __QUALITYMEASUREMENTSIDEBAR_H__ +#define __QUALITYMEASUREMENTSIDEBAR_H__ + +#include "config.h" +#include "PlaYUVerDefs.h" +#if( QT_VERSION_PLAYUVER == 5 ) +#include +#elif( QT_VERSION_PLAYUVER == 4 ) +#include +#include +#endif +#include "PlaYUVerStream.h" +#include "PlaYUVerFrame.h" +#include "HistogramWidget.h" + +namespace plaYUVer +{ + +class SubWindowHandle; + +class QualityMeasurementSidebar: public QWidget +{ +Q_OBJECT +public: + QualityMeasurementSidebar( QWidget*, QMdiArea * ); + ~QualityMeasurementSidebar(); + + QSize sizeHint() const; + + Void updateSubWindowList(); + Void updateCurrentWindow( SubWindowHandle * ); + Void updateSidebarData(); + +private: + QMdiArea* m_pcMainWindowMdiArea; + + QStringList m_pcWindowListNames; + QStringList m_pcSelectedWindowListNames; + + SubWindowHandle *m_pcCurrentSubWindow; + + QComboBox *m_comboBoxRef; + QComboBox *m_comboBoxRec; + + QLabel* m_ppcLabelQualityLabel[3]; + QLabel* m_ppcLabelQualityValue[3]; + + HistogramWidget *histogramWidget; + +private Q_SLOTS: + void slotReferenceChanged( int ); + +}; + +} // NAMESPACE + +#endif // __QUALITYMEASUREMENTSIDEBAR_H__ diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 1e08a1e..11d7305 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -31,6 +31,11 @@ namespace plaYUVer SubWindowHandle::SubWindowHandle( QWidget * parent, Bool isModule ) : QMdiSubWindow( parent ), + m_pCurrStream( NULL ), + m_pcCurrFrame( NULL ), + m_pcCurrentModule( NULL ), + m_pcReferenceSubWindow( NULL ), + m_bIsPlaying( false ), m_bIsModule( isModule ) { setParent( parent ); @@ -50,17 +55,11 @@ SubWindowHandle::SubWindowHandle( QWidget * parent, Bool isModule ) : connect( m_cScrollArea->horizontalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); connect( m_cScrollArea->verticalScrollBar(), SIGNAL( actionTriggered( int ) ), this, SLOT( updateLastScrollValue() ) ); - // Define the cViewArea as the widget inside the scroll area +// Define the cViewArea as the widget inside the scroll area m_cScrollArea->setWidget( m_cViewArea ); m_cScrollArea->setWidgetResizable( true ); - m_pCurrStream = NULL; - //m_pCurrStream = new PlaYUVerStream; - m_pcCurrFrame = NULL; - m_pcCurrentModule = NULL; - m_cWindowName = QString( " " ); - m_bIsPlaying = false; m_cLastScroll = QPoint(); } @@ -95,7 +94,7 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) if( m_pCurrStream->guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) { ConfigureFormatDialog formatDialog( this ); - if( formatDialog.runConfigureFormatDialog( Width, Height, InputFormat, FrameRate ) == QDialog::Rejected ) + if( formatDialog.runConfigureFormatDialog( cFilename, Width, Height, InputFormat, FrameRate ) == QDialog::Rejected ) { return false; } @@ -115,6 +114,7 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) m_cCurrFileName = cFilename; m_cWindowName = m_pCurrStream->getStreamInformationString(); + m_cWindowShortName = QFileInfo( cFilename ).fileName(); setWindowTitle( m_cWindowName ); return true; } @@ -130,7 +130,7 @@ Void SubWindowHandle::enableModule( PlaYUVerModuleIf* select_module ) disableModule(); } m_pcCurrentModule = select_module; - // refreshFrame(); +// refreshFrame(); } Void SubWindowHandle::disableModule() @@ -202,8 +202,33 @@ Void SubWindowHandle::refreshFrame() Bool SubWindowHandle::save( QString filename ) { + Bool iRet = false; QApplication::setOverrideCursor( Qt::WaitCursor ); - Bool iRet = m_pCurrStream->saveFrame( filename ); + if( !m_pCurrStream ) + { + if( !m_pcCurrFrame ) + { + return false; + } + Int iFileFormat = PlaYUVerStream::INVALID_INPUT; + QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt(); + QString currExt = QFileInfo( filename ).suffix(); + if( formatsExt.contains( currExt ) ) + { + iFileFormat = formatsExt.indexOf( currExt ); + } + if( iFileFormat == PlaYUVerStream::YUVINPUT ) + { + return false; + } + m_pcCurrFrame->FrametoRGB8(); + QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 ); + iRet = qimg.save( filename ); + } + else + { + iRet = m_pCurrStream->saveFrame( filename ); + } QApplication::restoreOverrideCursor(); return iRet; } @@ -282,7 +307,7 @@ Void SubWindowHandle::normalSize() Void SubWindowHandle::zoomToFit() { - // Scale to a smaller size that the real to a nicer look +// Scale to a smaller size that the real to a nicer look QSize niceFit( m_cScrollArea->viewport()->size().width() - 5, m_cScrollArea->viewport()->size().height() - 5 ); scaleView( niceFit ); } @@ -309,7 +334,7 @@ Void SubWindowHandle::scaleView( const QSize & size ) QSize newSize = imgViewSize; newSize.scale( size, Qt::KeepAspectRatio ); - // Calc the zoom factor +// Calc the zoom factor Double wfactor = 1; Double hfactor = 1; @@ -390,7 +415,7 @@ void SubWindowHandle::updateLastScrollValue() QSize SubWindowHandle::sizeHint() const { QSize maxSize; // The size of the parent (viewport widget - // of the QMdiArea). +// of the QMdiArea). QWidget *p = parentWidget(); if( p ) @@ -404,8 +429,8 @@ QSize SubWindowHandle::sizeHint() const else if( m_pCurrStream ) isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 ); - // If the SubWindowHandle needs more space that the avaiable, we'll give - // to the subwindow a reasonable size preserving the image aspect ratio. +// If the SubWindowHandle needs more space that the avaiable, we'll give +// to the subwindow a reasonable size preserving the image aspect ratio. if( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) { return isize; diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 6a68ba2..41c14ab 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -38,6 +38,7 @@ namespace plaYUVer { +class SubWindowHandle; class SubWindowHandle: public QMdiSubWindow { @@ -48,12 +49,15 @@ private: QScrollArea* m_cScrollArea; ViewArea* m_cViewArea; - PlaYUVerModuleIf* m_pcCurrentModule; - PlaYUVerStream* m_pCurrStream; PlaYUVerFrame* m_pcCurrFrame; + PlaYUVerModuleIf* m_pcCurrentModule; + + SubWindowHandle* m_pcReferenceSubWindow; + QString m_cWindowName; + QString m_cWindowShortName; QString m_cCurrFileName; Bool m_bIsPlaying; @@ -68,7 +72,7 @@ public: Bool mayClose(); Bool loadFile( QString cFilename, Bool bForceDialog = false ); Void reloadFile(); - Bool save( QString filename ); + Bool save( QString filename ); Bool play(); Void pause(); @@ -117,6 +121,15 @@ public: return m_pcCurrentModule; } + Void setRefSubWindow( SubWindowHandle* subWindow ) + { + m_pcReferenceSubWindow = subWindow; + } + SubWindowHandle* getRefSubWindow() + { + return m_pcReferenceSubWindow; + } + /** * Functions to enable a module in the * current SubWindow @@ -171,13 +184,11 @@ public: { return m_cWindowName; } - - QString userFriendlyCurrentFile() + QString getWindowShortName() { - return m_cWindowName; + return m_cWindowShortName; } - - QString currentFile() + QString getCurrentFileName() { return m_cCurrFileName; } diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 1e5851d..dbba02c 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -109,6 +109,14 @@ void ViewArea::clearMask() // return QSize( w, h ); // } +Void ViewArea::setZoomFactor( Double f ) +{ + m_zoomFactor = f; + + updateSize(); + update(); +} + Void ViewArea::zoomChangeEvent( Double factor, QPoint center ) { Double zoomFactor; @@ -134,14 +142,6 @@ Void ViewArea::zoomChangeEvent( Double factor, QPoint center ) } -void ViewArea::setZoomFactor( double f ) -{ - m_zoomFactor = f; - - updateSize(); - update(); -} - void ViewArea::setMode( ViewMode mode ) { if( m_mode == mode ) @@ -519,13 +519,15 @@ void ViewArea::wheelEvent( QWheelEvent *event ) { Double factor; - factor = 0.001 * event->delta(); - if( factor > 0 ) - factor = 1.25; - else - factor = 0.8; - - zoomChangeEvent( factor, event->pos() ); + if( event->modifiers() & Qt::ControlModifier ) + { + factor = 0.001 * event->delta(); + if(factor>0) + factor=1.25; + else + factor=0.8; + zoomChangeEvent( factor , event->pos() ); + } } void ViewArea::mousePressEvent( QMouseEvent *event ) @@ -534,6 +536,10 @@ void ViewArea::mousePressEvent( QMouseEvent *event ) QPoint vpos = windowToView( event->pos() ); + if( event->button() == Qt::MidButton ) + { + + } if( event->button() == Qt::LeftButton ) { if( tool() == NavigationTool ) diff --git a/source/app/ViewArea.h b/source/app/ViewArea.h index de6f103..4604589 100644 --- a/source/app/ViewArea.h +++ b/source/app/ViewArea.h @@ -108,6 +108,7 @@ public: PlaYUVerStream* getInputStream(); Void zoomChangeEvent(Double factor, QPoint center); + void setTool( enum eTool tool ); // QSize sizeHint() const; @@ -128,7 +129,7 @@ public Q_SLOTS: void setGridVisible( bool enable ); void setSnapToGrid( bool enable ); void setSelectedArea( QRect &rect ); - void setZoomFactor( double f ); + void setZoomFactor( double ); protected: void paintEvent( QPaintEvent *event ); diff --git a/source/app/main.cpp b/source/app/main.cpp index 6c9aae0..8ffc86c 100644 --- a/source/app/main.cpp +++ b/source/app/main.cpp @@ -23,18 +23,23 @@ */ #include +#include "config.h" #include "plaYUVerApp.h" #ifdef USE_FERVOR #include "fvupdater.h" #endif using namespace plaYUVer; +#if _WIN32 +#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") +#endif + int main( int argc, char *argv[] ) { QApplication a( argc, argv ); - QApplication::setApplicationName("playuver"); - QApplication::setApplicationVersion("0.1"); - QApplication::setOrganizationName("playuver"); + QApplication::setApplicationName("PlaYUVer"); + QApplication::setApplicationVersion(PLAYUVER_VERSION_STRING); + QApplication::setOrganizationName("pixlra"); QApplication::setOrganizationDomain("playuver.pixlra"); plaYUVerApp w; w.show(); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 059a608..1c7ea0c 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -49,7 +49,7 @@ plaYUVerApp::plaYUVerApp() setWindowModality( Qt::ApplicationModal ); - mdiArea = new QMdiArea; + mdiArea = new PlaYUVerMdiArea; setCentralWidget( mdiArea ); //mdiArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); //mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); @@ -70,7 +70,7 @@ plaYUVerApp::plaYUVerApp() readSettings(); - setWindowTitle( tr( "plaYUVer" ) ); + setWindowTitle( QApplication::applicationName() ); setWindowIcon( QIcon( ":/images/playuver.png" ) ); setUnifiedTitleAndToolBarOnMac( true ); @@ -84,6 +84,7 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); + m_pcAboutDialog = NULL; m_pcCurrentSubWindow = NULL; } @@ -102,13 +103,16 @@ Void plaYUVerApp::parseArgs( Int argc, Char *argv[] ) Void plaYUVerApp::about() { - QString about_message; - about_message.append( "The plaYUVer is an open-source raw video player! " ); - about_message.append( "Developed by " ); - about_message.append( "João Carreira " ); - about_message.append( "and " ); - about_message.append( "Luís Lucas" ); - QMessageBox::about( this, "About plaYUVer", about_message ); + if (!m_pcAboutDialog) + m_pcAboutDialog = new AboutDialog(this); + m_pcAboutDialog->exec(); +// QString about_message; +// about_message.append( "The plaYUVer is an open-source raw video player! " ); +// about_message.append( "Developed by " ); +// about_message.append( "João Carreira " ); +// about_message.append( "and " ); +// about_message.append( "Luís Lucas" ); +// QMessageBox::about( this, "About plaYUVer", about_message ); } Void plaYUVerApp::closeEvent( QCloseEvent *event ) @@ -155,14 +159,14 @@ Void plaYUVerApp::closeEvent( QCloseEvent *event ) Void plaYUVerApp::loadFile( QString fileName ) { - QMdiSubWindow *existing = findSubWindow( fileName ); - if( existing ) + SubWindowHandle *interfaceChild = plaYUVerApp::findSubWindow( mdiArea, fileName ); + if( interfaceChild ) { - mdiArea->setActiveSubWindow( existing ); + mdiArea->setActiveSubWindow( interfaceChild ); return; } - SubWindowHandle *interfaceChild = new SubWindowHandle( this ); //createSubWindow(); + interfaceChild = new SubWindowHandle( this ); //createSubWindow(); if( interfaceChild->loadFile( fileName ) ) { statusBar()->showMessage( tr( "Loading file..." ) ); @@ -211,12 +215,15 @@ Void plaYUVerApp::open() << formatsList << tr( "All Files (*)" ); - QString fileName = QFileDialog::getOpenFileName( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) ); + QStringList fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) ); - if( !fileName.isEmpty() ) + for( Int i = 0; i < fileNameList.size(); i++ ) { - m_cLastOpenPath = QFileInfo( fileName ).path(); - loadFile( fileName ); + if( !fileNameList.at( i ).isEmpty() ) + { + m_cLastOpenPath = QFileInfo( fileNameList.at( i ) ).path(); + loadFile( fileNameList.at( i ) ); + } } } @@ -266,7 +273,7 @@ Void plaYUVerApp::format() { if( m_pcCurrentSubWindow ) { - m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->currentFile(), true ); + m_pcCurrentSubWindow->loadFile( m_pcCurrentSubWindow->getCurrentFileName(), true ); m_pcCurrentSubWindow = NULL; chageSubWindowSelection(); } @@ -562,9 +569,6 @@ Void plaYUVerApp::playEvent() if( !m_arrayActions[VIDEO_LOOP_ACT]->isChecked() ) { stop(); - updateCurrFrameNum(); - updateFrameProperties(); - return; } else { @@ -587,6 +591,7 @@ Void plaYUVerApp::playEvent() } updateCurrFrameNum(); updateFrameProperties(); + m_pcQualityMeasurement->updateSidebarData(); m_uiAveragePlayInterval = ( m_uiAveragePlayInterval + time ) / 2; } @@ -629,6 +634,7 @@ Void plaYUVerApp::seekEvent( Int direction ) { m_pcCurrentSubWindow->seekRelativeEvent( direction > 0 ? true : false ); } + m_pcQualityMeasurement->updateSidebarData(); updateFrameProperties(); updateCurrFrameNum(); } @@ -649,6 +655,7 @@ Void plaYUVerApp::seekSliderEvent( Int new_frame_num ) { m_pcCurrentSubWindow->seekAbsoluteEvent( ( UInt )new_frame_num ); } + m_pcQualityMeasurement->updateSidebarData(); updateFrameProperties(); updateCurrFrameNum(); } @@ -661,7 +668,7 @@ Void plaYUVerApp::lockButtonEvent() if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) { m_acPlayingSubWindows.clear(); - m_acPlayingSubWindows.append(m_pcCurrentSubWindow); + m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); } else { @@ -758,6 +765,7 @@ Void plaYUVerApp::zoomToFitAll() subWindow = qobject_cast( mdiArea->subWindowList().at( i ) ); subWindow->zoomToFit(); } + updateZoomFactorSBox(); } Void plaYUVerApp::scaleFrame( int ratio ) @@ -802,6 +810,10 @@ Void plaYUVerApp::chageSubWindowSelection() if( activeSubWindow() ) { m_pcCurrentSubWindow = new_window; + if( !plaYUVerApp::findSubWindow( mdiArea, m_pcCurrentSubWindow->getRefSubWindow() ) ) + { + m_pcCurrentSubWindow->setRefSubWindow( NULL ); + } updateCurrFrameNum(); updateTotalFrameNum(); updateStreamProperties(); @@ -812,6 +824,8 @@ Void plaYUVerApp::chageSubWindowSelection() } updateStreamProperties(); updateFrameProperties(); + m_pcQualityMeasurement->updateCurrentWindow( m_pcCurrentSubWindow ); + m_pcQualityMeasurement->updateSubWindowList(); updateMenus(); } @@ -872,18 +886,28 @@ SubWindowHandle *plaYUVerApp::activeSubWindow() return 0; } -QMdiSubWindow *plaYUVerApp::findSubWindow( const QString &fileName ) +SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const QString& fileName ) { QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath(); foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ SubWindowHandle *mdiChild = qobject_cast( window); - if( mdiChild->currentFile() == canonicalFilePath ) - return window; + if( mdiChild->getCurrentFileName() == canonicalFilePath ) + return mdiChild; } return 0; } +SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow ) +{ + foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ + SubWindowHandle *mdiChild = qobject_cast( window); + if( mdiChild == subWindow ) + return mdiChild; +} +return 0; +} + Void plaYUVerApp::setNavigationTool() { m_appTool = NavigationTool; @@ -986,11 +1010,11 @@ Void plaYUVerApp::updateWindowMenu() QString text; if( i < 9 ) { - text = tr( "&%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() ); + text = tr( "&%1 %2" ).arg( i + 1 ).arg( child->getWindowName() ); } else { - text = tr( "%1 %2" ).arg( i + 1 ).arg( child->userFriendlyCurrentFile() ); + text = tr( "%1 %2" ).arg( i + 1 ).arg( child->getWindowName() ); } QAction *action = m_arrayMenu[WINDOW_MENU]->addAction( text ); action->setCheckable( true ); @@ -1030,7 +1054,7 @@ Void plaYUVerApp::createActions() m_arrayActions[RELOAD_ALL_ACT] = new QAction( tr( "Reload All" ), this ); //m_arrayActions[RELOAD_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); m_arrayActions[RELOAD_ALL_ACT]->setStatusTip( tr( "Reload all sequences" ) ); - connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) ); + connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reloadAll() ) ); m_arrayActions[LOAD_ALL_ACT] = new QAction( tr( "Preload" ), this ); //m_arrayActions[LOAD_ALL_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); @@ -1315,21 +1339,31 @@ Void plaYUVerApp::createToolBars() Void plaYUVerApp::createDockWidgets() { // Properties Dock Window - m_arraySideBars.resize( TOTAL_SIDEBAR ); + m_arraySideBars.resize( TOTAL_DOCK ); m_pcStreamProperties = new StreamPropertiesSideBar( this ); - m_arraySideBars[STREAM_SIDEBAR] = new QDockWidget( tr( "Stream Information" ), this ); - m_arraySideBars[STREAM_SIDEBAR]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); - m_arraySideBars[STREAM_SIDEBAR]->setWidget( m_pcStreamProperties ); - addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[STREAM_SIDEBAR] ); - connect( m_arraySideBars[STREAM_SIDEBAR], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); + m_arraySideBars[STREAM_DOCK] = new QDockWidget( tr( "Stream Information" ), this ); + m_arraySideBars[STREAM_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); + m_arraySideBars[STREAM_DOCK]->setWidget( m_pcStreamProperties ); + addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[STREAM_DOCK] ); + connect( m_arraySideBars[STREAM_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); m_pcFrameProperties = new FramePropertiesSideBar( this, &m_bIsPlaying ); - m_arraySideBars[FRAME_SIDEBAR] = new QDockWidget( tr( "Frame Information" ), this ); - m_arraySideBars[FRAME_SIDEBAR]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); - m_arraySideBars[FRAME_SIDEBAR]->setWidget( m_pcFrameProperties ); - addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[FRAME_SIDEBAR] ); - connect( m_arraySideBars[FRAME_SIDEBAR], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); + m_arraySideBars[FRAME_DOCK] = new QDockWidget( tr( "Frame Information" ), this ); + m_arraySideBars[FRAME_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); + m_arraySideBars[FRAME_DOCK]->setWidget( m_pcFrameProperties ); + addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[FRAME_DOCK] ); + connect( m_arraySideBars[FRAME_DOCK], SIGNAL( visibilityChanged(bool) ), this, SLOT( updateProperties() ) ); + + QMainWindow::tabifyDockWidget( m_arraySideBars[FRAME_DOCK], m_arraySideBars[STREAM_DOCK] ); + //QMainWindow::setTabPosition(Qt::RightDockWidgetArea, QTabWidget::North); + + m_pcQualityMeasurement = new QualityMeasurementSidebar( this, mdiArea ); + m_arraySideBars[QUALITY_DOCK] = new QDockWidget( tr( "Quality Measurement" ), this ); + m_arraySideBars[QUALITY_DOCK]->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea ); + m_arraySideBars[QUALITY_DOCK]->setWidget( m_pcQualityMeasurement ); + addDockWidget( Qt::RightDockWidgetArea, m_arraySideBars[QUALITY_DOCK] ); + } Void plaYUVerApp::createStatusBar() @@ -1349,12 +1383,14 @@ Void plaYUVerApp::readSettings() setAllSubWindowTool(); m_arrayActions[VIDEO_LOOP_ACT]->setChecked( settings.getRepeat() ); m_arrayActions[VIDEO_LOCK_ACT]->setChecked( settings.getVideoLock() ); - Bool visibleStreamProp, visibleFrameProp; - settings.getDockVisibility( visibleStreamProp, visibleFrameProp ); + Bool visibleStreamProp, visibleFrameProp, visibleQualityMeasure; + settings.getDockVisibility( visibleStreamProp, visibleFrameProp, visibleQualityMeasure ); if( !visibleStreamProp ) - m_arraySideBars[STREAM_SIDEBAR]->close(); + m_arraySideBars[STREAM_DOCK]->close(); if( !visibleFrameProp ) - m_arraySideBars[FRAME_SIDEBAR]->close(); + m_arraySideBars[FRAME_DOCK]->close(); + if( !visibleQualityMeasure ) + m_arraySideBars[QUALITY_DOCK]->close(); } @@ -1365,7 +1401,7 @@ Void plaYUVerApp::writeSettings() settings.setMainWindowSize( size() ); settings.setLastOpenPath( m_cLastOpenPath ); settings.setSelectedTool( ( Int )m_appTool ); - settings.setDockVisibility( m_pcStreamProperties->isVisible(), m_pcFrameProperties->isVisible() ); + settings.setDockVisibility( m_pcStreamProperties->isVisible(), m_pcFrameProperties->isVisible(), m_pcQualityMeasurement->isVisible() ); settings.setPlayingSettings( m_arrayActions[VIDEO_LOOP_ACT]->isChecked(), m_arrayActions[VIDEO_LOCK_ACT]->isChecked() ); } diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index a347cb9..12973df 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -35,6 +35,8 @@ #include #include "ModulesHandle.h" #include "PropertiesSidebar.h" +#include "QualityMeasurementSidebar.h" +#include "AboutDialog.h" namespace plaYUVer { @@ -112,7 +114,36 @@ private Q_SLOTS: void setSelectionTool(); private: - QMdiArea *mdiArea; + + class PlaYUVerMdiArea: public QMdiArea + { + public: + PlaYUVerMdiArea( QWidget *parent = 0 ) : + QMdiArea( parent ), + m_pixmapLogo( ":/images/playuver-backgroud-logo.png" ) + { + } + protected: + void paintEvent( QPaintEvent *event ) + { + QMdiArea::paintEvent( event ); + QPainter painter( viewport() ); + QSize logoSize = 2 * size() / 3; + + QPixmap pixFinalLogo = m_pixmapLogo.scaled(logoSize,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 ); + } + private: + // Store the logo image. + QPixmap m_pixmapLogo; + }; + + //QMdiArea *mdiArea; + PlaYUVerMdiArea *mdiArea; SubWindowHandle *m_pcCurrentSubWindow; ModulesHandle *m_pcModulesHandle; @@ -147,7 +178,9 @@ private: Void writeSettings(); SubWindowHandle *activeSubWindow(); - QMdiSubWindow *findSubWindow( const QString &fileName ); + + static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const QString& fileName ); + static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow ); QVector m_acPlayingSubWindows; QSlider *m_pcFrameSlider; @@ -181,14 +214,16 @@ private: enum SIDEBAR_LIST { - STREAM_SIDEBAR = 0, - FRAME_SIDEBAR, - TOTAL_SIDEBAR, + STREAM_DOCK = 0, + FRAME_DOCK, + QUALITY_DOCK, + TOTAL_DOCK, }; QVector m_arraySideBars; StreamPropertiesSideBar* m_pcStreamProperties; FramePropertiesSideBar* m_pcFrameProperties; + QualityMeasurementSidebar* m_pcQualityMeasurement; enum TOOLBAR_LIST { @@ -243,6 +278,8 @@ private: QAction *actionSelectionTool; enum eTool m_appTool; + AboutDialog* m_pcAboutDialog; + }; } // NAMESPACE diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 1ce5a1a..79d9c7b 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -489,7 +489,17 @@ Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) Int diff = 0; Double ssd = 0; - for( UInt i = 0; i < Org->getHeight() * Org->getWidth(); i++ ) + UInt numberOfPixels = 0; + if( component == LUMA ) + { + numberOfPixels = Org->getHeight() * Org->getWidth(); + } + else + { + numberOfPixels = getChromaLength(); + } + + for( UInt i = 0; i < numberOfPixels; i++ ) { aux_pel_1 = *pPelYUV++; aux_pel_2 = *pOrgPelYUV++; @@ -514,23 +524,28 @@ Double PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) UInt64 PlaYUVerFrame::getBytesPerFrame() { - switch( m_iPixelFormat ) + return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); +} + +UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ) +{ + switch( iPixelFormat ) { case YUV420p: - return m_uiWidth * m_uiHeight * 1.5; + return uiWidth * uiHeight * 1.5; break; case YUV444p: - return m_uiWidth * m_uiHeight * 3; + return uiWidth * uiHeight * 3; break; case YUV422p: case YUYV422: - return m_uiWidth * m_uiHeight * 2; + return uiWidth * uiHeight * 2; break; case GRAY: - return m_uiWidth * m_uiHeight; + return uiWidth * uiHeight; break; case RGB8: - return m_uiWidth * m_uiHeight * 3; + return uiWidth * uiHeight * 3; break; default: return 0; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index d936d1c..1f3deb7 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -118,6 +118,7 @@ public: Double getPSNR( PlaYUVerFrame* Org, Int component ); UInt64 getBytesPerFrame(); + static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ); UInt getChromaLength() const; @@ -170,6 +171,10 @@ public: { return ( m_uiWidth > 0 ) && ( m_uiHeight > 0 ) && ( m_iPixelFormat >= 0 ); } + Bool haveSameFmt( PlaYUVerFrame* other ) const + { + return ( m_uiWidth == other->getWidth() ) && ( m_uiHeight == other->getHeight() ) && ( m_iPixelFormat == other->getPelFormat() ); + } private: UInt m_uiWidth; diff --git a/source/lib/PlaYUVerStream.cpp b/source/lib/PlaYUVerStream.cpp index e1da6ba..3f283c5 100644 --- a/source/lib/PlaYUVerStream.cpp +++ b/source/lib/PlaYUVerStream.cpp @@ -38,6 +38,7 @@ PlaYUVerStream::PlaYUVerStream() { m_bInit = false; m_bIsInput = true; + m_bIsOpened = false; m_bLoadAll = false; m_iErrorStatus = 0; @@ -82,6 +83,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ m_cFilename = filename; m_uiWidth = width; m_uiHeight = height; + m_iPixelFormat = input_format; m_uiFrameRate = frame_rate; if( m_bIsInput ) @@ -101,8 +103,6 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ } m_cFormatName = PlaYUVerStream::supportedReadFormatsExt().at( m_iFileFormat ).toUpper(); - m_iPixelFormat = input_format; - #ifdef USE_FFMPEG if( m_iFileFormat != YUVINPUT ) { @@ -115,7 +115,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ { switch( m_iFileFormat ) { - case PGMINPUT: + case PGMINPUT: break; } @@ -131,6 +131,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( m_uiWidth <= 0 || m_uiHeight <= 0 || m_iPixelFormat < 0 ) { + qDebug( ) << "Incorrect configuration"; close(); return m_bInit; } @@ -141,6 +142,7 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); if( !m_ppcFrameBuffer[i] ) { + qDebug( ) << "Cannot allocated frame buffer"; close(); return m_bInit; } @@ -150,14 +152,20 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame(); + if( !avStatus ) + { + if( !openFile() ) + { + close(); + return m_bInit; + } + m_cFormatName = QString::fromUtf8( "YUV" ); + m_cCodedName = QString::fromUtf8( "Raw Video" ); + } + if( !avStatus && m_iFileFormat == YUVINPUT ) { - m_pFile = NULL; - Char *filename = new char[m_cFilename.length() + 1]; - memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) ); - m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" ); - delete[] filename; - if( m_pFile == NULL ) + if( !openFile() ) { close(); return m_bInit; @@ -165,15 +173,26 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ if( m_bIsInput ) { fseek( m_pFile, 0, SEEK_END ); - m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); + UInt64 fileSize = ftell( m_pFile ); +#if 0 + if( fileSize % frame_bytes_input ) + { + Int remaining = fileSize % frame_bytes_input; + qDebug( ) << "Incorrect configuration: failed ( fileSize % frame_bytes_input = " << remaining << " )" ; + close(); + return m_bInit; + } +#endif + m_uiTotalFrameNum = fileSize / frame_bytes_input; fseek( m_pFile, 0, SEEK_SET ); } m_cFormatName = QString::fromUtf8( "YUV" ); m_cCodedName = QString::fromUtf8( "Raw Video" ); } - if( m_uiTotalFrameNum <= 0 ) + if( m_bIsInput && m_uiTotalFrameNum <= 0 ) { + qDebug( ) << "Incorrect configuration: less than one frame"; close(); return m_bInit; } @@ -198,7 +217,6 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ m_bInit = true; seekInput( 0 ); -//loadAll(); m_cTimer.start(); m_uiAveragePlayInterval = 0; @@ -207,10 +225,34 @@ Bool PlaYUVerStream::open( QString filename, UInt width, UInt height, Int input_ return m_bInit; } +Bool PlaYUVerStream::openFile() +{ + m_pFile = NULL; + Char *filename = new char[m_cFilename.length() + 1]; + memcpy( filename, m_cFilename.toUtf8().constData(), m_cFilename.length() + 1 * sizeof(char) ); + m_pFile = fopen( filename, m_bIsInput ? "rb" : "wb" ); + delete[] filename; + if( m_pFile == NULL ) + { + return false; + } + fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET ); + return true; +} + +Void PlaYUVerStream::closeFile() +{ + if( !m_bInit && m_pFile ) + return; + fclose( m_pFile ); +} + Void PlaYUVerStream::close() { - if( m_pFile ) - fclose( m_pFile ); + if( !m_bInit ) + return; + + closeFile(); #ifdef USE_FFMPEG m_cLibAvContext->closeAvFormat(); @@ -252,7 +294,7 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, { rWidth = 0; rHeight = 0; - rInputFormat = -1; + rInputFormat = PlaYUVerFrame::YUV420p; rFrameRate = 30; } } @@ -260,40 +302,106 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, Bool PlaYUVerStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) { Bool bRet = false; + QString FilenameShort = QFileInfo( filename ).fileName(); QString fileExtension = QFileInfo( filename ).suffix(); if( !fileExtension.compare( "yuv" ) ) { bRet = true; -// Guess resolution - match %dx%d -#if( QT_VERSION_PLAYUVER == 5 ) - QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( filename ); - if( resolutionMatch.hasMatch() ) - { - QString resolutionString = resolutionMatch.captured( 0 ); - if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) ) - { - resolutionString.remove( "_" ); - QStringList resolutionArgs = resolutionString.split( "x" ); - qDebug( ) << "Found resolution = " - << resolutionArgs; - if( resolutionArgs.size() == 2 ) - { - rWidth = resolutionArgs.at( 0 ).toUInt(); - rHeight = resolutionArgs.at( 1 ).toUInt(); - } - } - } -#endif -// Guess pixel format + // Guess pixel format QStringList formats_list = PlaYUVerFrame::supportedPixelFormatList(); for( Int i = 0; i < formats_list.size(); i++ ) { - if( filename.contains( formats_list.at( i ), Qt::CaseInsensitive ) ) + if( FilenameShort.contains( formats_list.at( i ), Qt::CaseInsensitive ) ) { rInputFormat = i; break; } } + + if( rWidth == 0 || rHeight == 0 ) + { + // Guess resolution - match resolution name + Int iMatch = -1; + QStringList stdResName = standardResolutionSizes().stringListName; + for( Int i = 0; i < stdResName.size(); i++ ) + { + if( FilenameShort.contains( stdResName.at( i ) ) ) + { + if( iMatch >= 0 ) + { + if( stdResName.at( i ).size() > stdResName.at( iMatch ).size() ) + { + iMatch = i; + } + } + else + { + iMatch = i; + } + } + } + if( iMatch >= 0 ) + { + rWidth = standardResolutionSizes().sizeResolution.at( iMatch ).width(); + rHeight = standardResolutionSizes().sizeResolution.at( iMatch ).height(); + } + // Guess resolution - match %dx%d +#if( QT_VERSION_PLAYUVER == 5 ) + QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort ); + if( resolutionMatch.hasMatch() ) + { + QString resolutionString = resolutionMatch.captured( 0 ); + if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) ) + { + resolutionString.remove( "_" ); + QStringList resolutionArgs = resolutionString.split( "x" ); + qDebug( ) << "Found resolution = " + << resolutionArgs; + if( resolutionArgs.size() == 2 ) + { + rWidth = resolutionArgs.at( 0 ).toUInt(); + rHeight = resolutionArgs.at( 1 ).toUInt(); + } + } + } +#endif + } + + // Guess resolution by file size + if( rWidth == 0 && rHeight == 0 ) + { + + Char *filename_char = new char[filename.length() + 1]; + memcpy( filename_char, filename.toUtf8().constData(), filename.length() + 1 * sizeof(char) ); + FILE* pF = fopen( filename_char, "rb" ); + fseek( pF, 0, SEEK_END ); + UInt64 uiFileSize = ftell( pF ); + fclose( pF ); + delete[] filename_char; + + if( pF != NULL ) + { + Int count = 0, module, frame_bytes, match; + QVector sizeResolution = standardResolutionSizes().sizeResolution; + for( Int i = 0; i < sizeResolution.size(); i++ ) + { + frame_bytes = PlaYUVerFrame::getBytesPerFrame( sizeResolution.at( i ).width(), sizeResolution.at( i ).height(), rInputFormat ); + module = uiFileSize % frame_bytes; + if( module == 0 ) + { + match = i; + count++; + } + } + if( count == 1 ) + { + rWidth = sizeResolution.at( match ).width(); + rHeight = sizeResolution.at( match ).height(); + } + } + + } + if( rWidth > 0 && rHeight > 0 && rInputFormat >= 0 ) bRet = false; } @@ -330,7 +438,8 @@ Void PlaYUVerStream::loadAll() m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; m_iCurrFrameNum = -1; seekInput( 0 ); - for( UInt i = 0; i < m_uiFrameBufferSize - 1; i++ ) + setNextFrame(); + for( UInt i = m_uiFrameBufferIndex; i < m_uiFrameBufferSize; i++ ) { readFrame(); setNextFrame(); @@ -433,8 +542,33 @@ Void PlaYUVerStream::writeFrame( PlaYUVerFrame *pcFrame ) Bool PlaYUVerStream::saveFrame( const QString& filename ) { - QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 ); - return qimg.save( filename ); + Int iFileFormat = INVALID_INPUT; + + QStringList formatsExt = PlaYUVerStream::supportedReadFormatsExt(); + QString currExt = QFileInfo( filename ).suffix(); + if( formatsExt.contains( currExt ) ) + { + iFileFormat = formatsExt.indexOf( currExt ); + } + + if( iFileFormat == YUVINPUT ) + { + PlaYUVerStream auxFrameStream; + if( !auxFrameStream.open( filename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, false ) ) + { + return false; + } + auxFrameStream.writeFrame( m_pcCurrFrame ); + auxFrameStream.close(); + return true; + } + else + { + m_pcCurrFrame->FrametoRGB8(); + QImage qimg = QImage( m_pcCurrFrame->getQImageBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), QImage::Format_RGB888 ); + return qimg.save( filename ); + } + return false; } Void PlaYUVerStream::setNextFrame() diff --git a/source/lib/PlaYUVerStream.h b/source/lib/PlaYUVerStream.h index f8c1dd9..c420779 100644 --- a/source/lib/PlaYUVerStream.h +++ b/source/lib/PlaYUVerStream.h @@ -42,6 +42,8 @@ private: Bool m_bInit; Bool m_bIsInput; + Bool m_bIsOpened; + Bool m_bLoadAll; Int m_iErrorStatus; @@ -156,7 +158,8 @@ public: static QStringList supportedSaveFormatsExt() { QStringList formatsExt; - formatsExt << "bmp" + formatsExt << "yuv" + << "bmp" << "jpeg" << "png" // portable network graphics ; @@ -166,12 +169,43 @@ public: static QStringList supportedSaveFormatsName() { QStringList formatsName; - formatsName << "Windows Bitmap" + formatsName << "Raw Video" + << "Windows Bitmap" << "Joint Photographic Experts Group" << "Portable Network Graphics"; return formatsName; } +#define REGIST_STANDARD_RESOLUTION( name, width, height) \ + stdRes.stringListName.append( QString( name ) ); \ + stdRes.stringListFullName.append( QString( "%1 (%2x%3)" ).arg( name ).arg( width ).arg( height ) ); \ + stdRes.sizeResolution.append( QSize( width, height ) ) + + struct StandardResolution + { + QStringList stringListName; + QStringList stringListFullName; + QVector sizeResolution; + }; + + static struct StandardResolution standardResolutionSizes() + { + struct StandardResolution stdRes; + REGIST_STANDARD_RESOLUTION( "CIF", 352, 288 ); + REGIST_STANDARD_RESOLUTION( "VGA", 640, 480 ); + REGIST_STANDARD_RESOLUTION( "WVGA", 832, 480 ); + REGIST_STANDARD_RESOLUTION( "XVGA", 1024, 768 ); + REGIST_STANDARD_RESOLUTION( "HD", 1280, 720 ); + REGIST_STANDARD_RESOLUTION( "SXGA-", 1280, 900 ); + REGIST_STANDARD_RESOLUTION( "SXGA", 1280, 1024 ); + REGIST_STANDARD_RESOLUTION( "WSXGA", 1440, 900 ); + REGIST_STANDARD_RESOLUTION( "FullHD", 1920, 1080 ); + REGIST_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 ); + REGIST_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 ); + REGIST_STANDARD_RESOLUTION( "8K", 8192, 4608 ); + return stdRes; + } + enum PlaYUVerStreamErrors { NO_STREAM_ERROR = 0, @@ -184,7 +218,11 @@ public: Bool open( QString filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true ); Void close(); - Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Bool openFile(); + Void closeFile(); + + static Bool guessFormat( QString filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); + Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); Void loadAll(); diff --git a/source/modules/MeasurePSNR.cpp b/source/modules/MeasurePSNR.cpp index e20dfd3..e69d4bf 100644 --- a/source/modules/MeasurePSNR.cpp +++ b/source/modules/MeasurePSNR.cpp @@ -19,7 +19,7 @@ /** * \file MeasurePSNR.cpp - * \brief Measure PSNR module + * \brief Frame Difference module */ #include @@ -34,35 +34,59 @@ static PlaYUVerModuleDefinition MeasurePSNRDef = { FRAME_MEASUREMENT_MODULE, "Quality", - "PSNR", + "PSNR Y", "Measure the PSNR between two images", MODULE_REQUIRES_TWO_FRAMES, - MODULE_REQUIRES_NEW_WINDOW, - APPLY_WHILE_PLAYING, -}; + MODULE_REQUIRES_SIDEBAR, + APPLY_WHILE_PLAYING, }; MeasurePSNR::MeasurePSNR() { - m_pcFilteredFrame = NULL; setModuleDefinition( MeasurePSNRDef ); } -Void MeasurePSNR::create( PlaYUVerFrame* InputFrame ) +Void MeasurePSNR::create( PlaYUVerFrame* Org ) { - m_pcFilteredFrame = NULL; - m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY ); } -PlaYUVerFrame* MeasurePSNR::process( PlaYUVerFrame* InputFrame ) +Double MeasurePSNR::getMSE( PlaYUVerFrame* Org, PlaYUVerFrame* Rec, Int component ) { - return m_pcFilteredFrame; + Pel* pInput1PelYUV = Org->getPelBufferYUV()[component][0]; + Pel* pInput2PelYUV = Rec->getPelBufferYUV()[component][0]; + + Int aux_pel_1, aux_pel_2; + Int diff = 0; + Double ssd = 0; + + for( UInt y = 0; y < Org->getHeight(); y++ ) + for( UInt x = 0; x < Org->getWidth(); x++ ) + { + aux_pel_1 = *pInput1PelYUV++; + aux_pel_2 = *pInput2PelYUV++; + diff = aux_pel_1 - aux_pel_2; + ssd += ( Double )( diff * diff ); + } + if( ssd == 0.0 ) + { + return 0.0; + } + return ssd / ( Org->getWidth() * Org->getHeight() ); +} + +Double MeasurePSNR::measure( PlaYUVerFrame* Org, PlaYUVerFrame* Rec ) +{ + Double psnrY = 100; + Double mseY = MeasurePSNR::getMSE( Org, Rec, LUMA ); + + if( mseY != 0 ) + psnrY = 10 * log10( 65025 / mseY ); + + return psnrY; } Void MeasurePSNR::destroy() { - if( m_pcFilteredFrame ) - delete m_pcFilteredFrame; - m_pcFilteredFrame = NULL; + } } // NAMESPACE diff --git a/source/modules/MeasurePSNR.h b/source/modules/MeasurePSNR.h index 5de073c..9224a87 100644 --- a/source/modules/MeasurePSNR.h +++ b/source/modules/MeasurePSNR.h @@ -19,17 +19,16 @@ /** * \file MeasurePSNR.h - * \brief Measure PSNR module + * \brief Frame Difference module */ #ifndef __MEASUREPSNR_H__ #define __MEASUREPSNR_H__ #include "config.h" - +#include "PlaYUVerDefs.h" #include #include -#include "TypeDef.h" #include "PlaYUVerFrame.h" #include "PlaYUVerModuleIf.h" @@ -41,18 +40,17 @@ namespace plaYUVer class MeasurePSNR: public PlaYUVerModuleIf { private: - public: MeasurePSNR(); virtual ~MeasurePSNR() { } - - Void create( PlaYUVerFrame* InputFrame ); - - PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); + Void create( PlaYUVerFrame* ); + Double measure( PlaYUVerFrame*, PlaYUVerFrame* ); Void destroy(); + static Double getMSE( PlaYUVerFrame* Org, PlaYUVerFrame* Rec, Int component ); + }; } // NAMESPACE