diff --git a/CMakeLists.txt b/CMakeLists.txt index e5caf0d..5af4797 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ ENDIF(UNIX) SET( PROJECT_NAME "playuver" ) PROJECT( ${PROJECT_NAME} ) -INCLUDE( PlaYUVerVersion.cmake ) +INCLUDE( cmake/PlaYUVerVersion.cmake ) INCLUDE( cmake/CMakeMacros.cmake ) @@ -52,6 +52,7 @@ ADD_DEFINITIONS( "-DPLAYUVER" ) ###################################################################################### # Variables ###################################################################################### +ADD_OPTION(PLAYUVER_LONGVERSIONNAME "Use long version name in deb" OFF ) ADD_OPTION(PLAYUVER_WERROR "Warnings as errors" OFF ) ADD_OPTION(PLAYUVER_THREADED_MODULES "Warnings as errors" ON ) ADD_OPTION(PLAYUVER_INSTALL_LIBS "Install PlaYUVer Lib" ON ) @@ -82,7 +83,6 @@ INCLUDE( cmake/LibPixfc.cmake ) ###################################################################################### SET( MODULES_DIR ${SRC_DIR}/modules ) INCLUDE_DIRECTORIES( ${MODULES_DIR} ) -FILE( GLOB ModuleCMakeFiles cmake/Module*.cmake ) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "// This files defines the macro to \n" "// define a list of modules\n" @@ -90,8 +90,12 @@ file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "// This files defin "#define REGISTER_ALL_MODULES ") file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "// This files add the header files of each module\n" - "#ifndef __MODULESLISTHEADER_H__\n#define __MODULESLISTHEADER_H__\n" ) -INCLUDE( ${ModuleCMakeFiles} ) + + "#ifndef __MODULESLISTHEADER_H__\n#define __MODULESLISTHEADER_H__\n" ) + +# FILE( GLOB ModuleCMakeFiles ModuleDefinition.cmake ) +# INCLUDE( ${ModuleCMakeFiles} ) +INCLUDE( ModuleDefinition.cmake ) file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "\n#endif // __MODULESLISTMACRO_H__\n" ) file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#endif // __MODULESLISTHEADER_H__\n" ) @@ -124,8 +128,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) @@ -133,15 +137,17 @@ INCLUDE(cmake/Install.cmake) ###################################################################################### # Final information dump ###################################################################################### +status("Version:" "${PLAYUVER_VERSION}") status("Configuration:") -status(" Build type:" ${CMAKE_BUILD_TYPE} ) -status(" Build flags:" "${CMAKE_CXX_FLAGS}" ) -status(" Warnings as errors:" USE_WERROR THEN YES ELSE NO) +status(" Build type:" "${CMAKE_BUILD_TYPE}") +status(" Build flags:" "${CMAKE_CXX_FLAGS}") +status(" Warnings as errors:" USE_WERROR THEN YES ELSE NO) +status(" Package Name:" "${PACKAGE_FILE_NAME}" ) status("Dependencies:") -status(" QT:" USE_QT4 THEN "QT4" ELSE "QT5" ) -status(" OpenCV:" USE_OPENCV THEN YES ELSE NO) -status(" FFMPEG:" USE_FFMPEG THEN YES ELSE NO) -status(" Fervor:" USE_FERVOR THEN YES ELSE NO) -status(" Pixfc-sse:" USE_PIXFC THEN YES ELSE NO) +status(" QT:" USE_QT4 THEN "QT4" ELSE "QT5") +status(" OpenCV:" USE_OPENCV THEN YES ELSE NO) +status(" FFMPEG:" USE_FFMPEG THEN YES ELSE NO) +status(" Fervor:" USE_FERVOR THEN YES ELSE NO) +status(" Pixfc-sse:" USE_PIXFC THEN YES ELSE NO) status("Features:") -status(" Modules List:" "${MODULES_LIST}" ) +status(" Modules List:" "${MODULES_LIST}" ) diff --git a/ModuleDefinition.cmake b/ModuleDefinition.cmake new file mode 100644 index 0000000..e6b14a5 --- /dev/null +++ b/ModuleDefinition.cmake @@ -0,0 +1,14 @@ +###################################################################################### +# Default Modules +###################################################################################### + +ADD_MODULE( FilterComponentLuma "FilterComponent" ) +ADD_MODULE( FilterComponentChromaU "FilterComponent" ) +ADD_MODULE( FilterComponentChromaV "FilterComponent" ) +ADD_MODULE( FrameDifference "FrameDifference" ) +ADD_MODULE( MeasurePSNR "MeasurePSNR" ) + +IF( USE_OPENCV ) + ADD_MODULE( DisparityStereoVar "DisparityStereoVar" ) +ENDIF() + diff --git a/PlaYUVerVersion.cmake b/PlaYUVerVersion.cmake deleted file mode 100644 index 634bc49..0000000 --- a/PlaYUVerVersion.cmake +++ /dev/null @@ -1,4 +0,0 @@ -SET( PLAYUVER_VERSION_MAJOR "0" ) -SET( PLAYUVER_VERSION_MINOR "0" ) -SET( PLAYUVER_VERSION_PATCH "9999" ) -SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}") \ No newline at end of file diff --git a/cmake/CMakeMacros.cmake b/cmake/CMakeMacros.cmake index f81bb7c..e3fb168 100644 --- a/cmake/CMakeMacros.cmake +++ b/cmake/CMakeMacros.cmake @@ -105,7 +105,7 @@ macro(ADD_MODULE name file ) set(MODULES_LIBS ${MODULES_LIBS} ${__modulename}) add_definitions( -DUSE_${name} ) LIST(APPEND MODULES_LIST ${name} ) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#include \"${name}.h\"\n") + file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListHeader.h "#include \"${file}.h\"\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/ModulesListMacro.h "\\\n REGISTER_MODULE( ${name} ); ") endif() unset(__modulename) diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 0000000..2ff2c33 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,130 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 0000000..8a085b2 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 842b95b..722a762 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 ) @@ -81,15 +46,21 @@ IF( UNIX ) SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE} ) SET(CPACK_DEBIAN_PACKAGE_DEPENDS "") IF( USE_QT4 ) - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4 (>= 4:4.8.5~), libqtgui4 (>= 4:4.8.5~)" ) + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqtcore4 (>= 4:4.8.5), libqtgui4 (>= 4:4.8.5)" ) ELSE() LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a, libqt5gui5, libqt5widgets5") ENDIF() + IF( USE_OPENCV ) + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ",") + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libopencv-dev (>= 2.4.8)") + ENDIF() IF( USE_FFMPEG ) LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ",") - LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libavformat53 (>= 6:0.8.10~), libcodec53 (>= 6:0.8.3-1~), libavutil51 (>= 6:0.8.3-1~)") + LIST(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libavformat54, libavcodec54, libavutil52") ENDIF() - + + STRING(REPLACE ";" "" CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS} ) + #EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE DAY) #string(STRIP ${DAY} DAY) @@ -117,6 +88,16 @@ IF( USE_OPENCV ) SET( APPEND_VERSION "${APPEND_VERSION}_wOpenCV" ) ENDIF() -SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${APPEND_VERSION}-${OS}-${CPACK_PACKAGE_ARCHITECTURE}" ) +IF( PLAYUVER_LONGVERSIONNAME ) + SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${APPEND_VERSION}-${OS}-${CPACK_PACKAGE_ARCHITECTURE}" ) + SET( PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME} ) +ELSE() +# message(STATUS ${GIT_BRANCH} ) + STRING(REPLACE "master" "stable" __version_name_deb ${GIT_BRANCH} ) + STRING(REPLACE "devel" "latest" __version_name_deb ${GIT_BRANCH} ) + message(STATUS ${GIT_BRANCH} ) + SET( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${__version_name_deb}${APPEND_VERSION}-${OS}-${CPACK_PACKAGE_ARCHITECTURE}" ) + SET( PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME} ) +ENDIF() INCLUDE(CPack) diff --git a/cmake/LibFFmpeg.cmake b/cmake/LibFFmpeg.cmake index d0efd7c..7075741 100644 --- a/cmake/LibFFmpeg.cmake +++ b/cmake/LibFFmpeg.cmake @@ -10,7 +10,8 @@ IF( USE_FFMPEG ) - SET( FFMPEG_HEADERS avformat.h avcodec.h avutil.h avdevice.h ) +# SET( FFMPEG_HEADERS avformat.h avcodec.h avutil.h avdevice.h ) + SET( FFMPEG_HEADERS avformat.h avcodec.h avutil.h ) SET( FFMPEG_PATH_SUFFIXES libavformat libavcodec libavutil libavdevice libffmpeg ) SET( FFMPEG_SWS_HEADERS swscale.h ) SET( FFMPEG_SWS_PATH_SUFFIXES libswscale ) 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 06a0e68..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( ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_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} ${Qt5Network_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 deleted file mode 100644 index c8cba74..0000000 --- a/cmake/ModuleDefault.cmake +++ /dev/null @@ -1,12 +0,0 @@ -###################################################################################### -# Default Modules -###################################################################################### - -ADD_MODULE( FilterFrame "FilterFrame.cpp" ) -ADD_MODULE( FrameDifference "FrameDifference.cpp" ) -ADD_MODULE( MeasurePSNR "MeasurePSNR.cpp" ) - -IF( USE_OPENCV ) - ADD_MODULE( DisparityStereoVar "DisparityStereoVar.cpp" ) -ENDIF() - diff --git a/cmake/PlaYUVerVersion.cmake b/cmake/PlaYUVerVersion.cmake new file mode 100644 index 0000000..7da6349 --- /dev/null +++ b/cmake/PlaYUVerVersion.cmake @@ -0,0 +1,32 @@ + +include(cmake/GetGitRevisionDescription.cmake) + +git_describe(__version --tags) + +string(REPLACE "-" ";" __version_list ${__version}) +list(GET __version_list 0 __version) +list(GET __version_list 1 __patch) +string(REPLACE "." ";" __version_list ${__version}) +list(GET __version_list 0 __major) +list(GET __version_list 1 __minor) + + +SET( PLAYUVER_VERSION_MAJOR ${__major}) +SET( PLAYUVER_VERSION_MINOR ${__minor}) +SET( PLAYUVER_VERSION_PATCH ${__patch}) +SET( PLAYUVER_VERSION "${PLAYUVER_VERSION_MAJOR}.${PLAYUVER_VERSION_MINOR}.${PLAYUVER_VERSION_PATCH}") + +execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE +) + + +unset(__version_list) +unset(__version) +unset(__patch) +unset(__major) +unset(__minor) + diff --git a/config.h.in b/config.h.in index 960df62..eced5f1 100644 --- a/config.h.in +++ b/config.h.in @@ -31,6 +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 */ 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/modules/FilterFrame.h b/source/app/AboutDialog.h similarity index 61% rename from source/modules/FilterFrame.h rename to source/app/AboutDialog.h index 03d33d1..4470655 100644 --- a/source/modules/FilterFrame.h +++ b/source/app/AboutDialog.h @@ -18,44 +18,22 @@ */ /** - * \file FilterFrame.h - * \brief Filter frame module + * \file AboutDialog.h + * \brief About Dialog + * Based on the work of Glad Deschrijver in KTikZ project */ -#ifndef __FILTERFRAME_H__ -#define __FILTERFRAME_H__ +#ifndef __ABOUTDIALOG_H__ +#define __ABOUTDIALOG_H__ -#include "config.h" -#include "PlaYUVerDefs.h" -#include -#include -#include "PlaYUVerFrame.h" -#include "PlaYUVerModuleIf.h" +#include -#include - -namespace plaYUVer +class AboutDialog : public QDialog { - -class FilterFrame: public PlaYUVerModuleIf -{ -private: - PlaYUVerFrame* m_pcFilteredFrame; + Q_OBJECT public: - FilterFrame(); - virtual ~FilterFrame() - { - } - - Void create( PlaYUVerFrame* InputFrame ); - - PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); - Void destroy(); - + AboutDialog(QWidget *parent = 0); }; -} // NAMESPACE - -#endif // __FILTERFRAME_H__ - +#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/ModulesHandle.cpp b/source/app/ModulesHandle.cpp index a4301ce..ee857c0 100644 --- a/source/app/ModulesHandle.cpp +++ b/source/app/ModulesHandle.cpp @@ -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( " <" ); @@ -209,6 +209,12 @@ 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(); } @@ -262,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(); } @@ -466,6 +472,7 @@ Void ModulesHandle::updateMenus( Bool hasSubWindow ) currModuleAction = m_arrayModulesActions.at( i ); currModuleAction->setEnabled( hasSubWindow ); } + m_arrayActions[APPLY_ALL_ACT]->setEnabled( hasSubWindow ); m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( hasSubWindow ); } diff --git a/source/app/PlaYUVerModuleIf.h b/source/app/PlaYUVerModuleIf.h index 12c8656..1a0025f 100644 --- a/source/app/PlaYUVerModuleIf.h +++ b/source/app/PlaYUVerModuleIf.h @@ -102,8 +102,6 @@ private: QDockWidget* m_pcDockWidget; ModuleHandleDock* m_pcModuleDock; - PlaYUVerModuleDefinition m_cModuleDef; - PlaYUVerStream* m_pcModuleStream; PlaYUVerFrame* m_pcProcessedFrame; Double m_dMeasurementResult; @@ -144,7 +142,8 @@ public: PlaYUVerModuleDefinition getModuleDefinition() { return m_cModuleDef; } protected: - virtual void run(); + PlaYUVerModuleDefinition m_cModuleDef; + virtual void run(); }; } // NAMESPACE diff --git a/source/app/PropertiesSidebar.cpp b/source/app/PropertiesSidebar.cpp index 55e8448..0fe5a3f 100644 --- a/source/app/PropertiesSidebar.cpp +++ b/source/app/PropertiesSidebar.cpp @@ -349,8 +349,8 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool *pbIsPlayi statisticsLayout->addWidget( labelStdDevValue, 3, 1 ); statisticsLayout->addWidget( medianLabel, 4, 0 ); statisticsLayout->addWidget( labelMedianValue, 4, 1 ); - statisticsLayout->addWidget( percentileLabel, 5, 0 ); - statisticsLayout->addWidget( labelPercentileValue, 5, 1 ); +// statisticsLayout->addWidget( percentileLabel, 5, 0 ); +// statisticsLayout->addWidget( labelPercentileValue, 5, 1 ); QGroupBox *statisticsGroup = new QGroupBox( tr( "Statistics" ) ); statisticsGroup->setLayout( statisticsLayout ); diff --git a/source/app/QualityMeasurementSidebar.cpp b/source/app/QualityMeasurementSidebar.cpp index cfe9b57..c1cadd7 100644 --- a/source/app/QualityMeasurementSidebar.cpp +++ b/source/app/QualityMeasurementSidebar.cpp @@ -38,19 +38,30 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea // Side bar area ----------------------------------------------------- + QLabel *MetricLabel = new QLabel( tr( "Metric:" ) ); + MetricLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); + 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_comboBoxMetric = new QComboBox; + m_comboBoxMetric->insertItems( 0, PlaYUVerFrame::supportedQualityMetricsList()); + m_comboBoxMetric->setSizeAdjustPolicy( QComboBox::AdjustToContents ); + m_comboBoxMetric->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed); + 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 ); + mainLayout->addWidget( MetricLabel, 0, 0, Qt::AlignLeft ); + mainLayout->addWidget( m_comboBoxMetric, 0, 1, Qt::AlignLeft ); + mainLayout->addWidget( RefLabel, 1, 0, Qt::AlignLeft ); + mainLayout->addWidget( m_comboBoxRef, 1, 1, Qt::AlignLeft ); m_ppcLabelQualityLabel[LUMA] = new QLabel( "PSNR Y:" ); m_ppcLabelQualityLabel[LUMA]->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); @@ -75,7 +86,8 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea qualityResultsLayout->addWidget( m_ppcLabelQualityLabel[CHROMA_V], 2, 0 ); qualityResultsLayout->addWidget( m_ppcLabelQualityValue[CHROMA_V], 2, 1 ); - QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) ); + //QGroupBox *statisticsGroup = new QGroupBox( tr( "Quality" ) ); + QGroupBox *statisticsGroup = new QGroupBox; statisticsGroup->setLayout( qualityResultsLayout ); statisticsGroup->setWhatsThis( tr( "

Here you can see the quality results calculated for the " "selected windows." ) ); @@ -86,6 +98,7 @@ QualityMeasurementSidebar::QualityMeasurementSidebar( QWidget* parent, QMdiArea setLayout( mainLayout ); connect( m_comboBoxRef, SIGNAL( activated(int) ), this, SLOT( slotReferenceChanged(int) ) ); + connect( m_comboBoxMetric, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotQualityMetricChanged() ) ); } @@ -112,22 +125,28 @@ Void QualityMeasurementSidebar::updateSubWindowList() for( Int i = 0; i < m_pcMainWindowMdiArea->subWindowList().size(); i++ ) { subWindow = qobject_cast( m_pcMainWindowMdiArea->subWindowList().at( i ) ); - currSubWindowName = subWindow->getWindowName(); - if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() ) - m_pcWindowListNames.append( currSubWindowName ); + if( subWindow ) + { + currSubWindowName = subWindow->getWindowShortName(); + if( !m_pcSelectedWindowListNames.contains( currSubWindowName ) && !subWindow->getIsModule() ) + { + m_pcWindowListNames.append( currSubWindowName ); + //m_comboBoxRef->setItemText( currIdx++, currSubWindowName ); + } + } } m_comboBoxRef->clear(); - m_comboBoxRef->insertItems( 0, m_pcWindowListNames ); - + m_comboBoxRef->insertItems( -1, m_pcWindowListNames ); m_comboBoxRef->setCurrentIndex( -1 ); if( m_pcCurrentSubWindow ) { if( SubWindowHandle* refSubWindow = m_pcCurrentSubWindow->getRefSubWindow() ) { - Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowName() ); + Int index = m_pcWindowListNames.indexOf( refSubWindow->getWindowShortName() ); m_comboBoxRef->setCurrentIndex( index ); } } + m_comboBoxRef->setSizeAdjustPolicy( QComboBox::AdjustToContents ); } Void QualityMeasurementSidebar::updateCurrentWindow( SubWindowHandle *subWindow ) @@ -152,11 +171,15 @@ Void QualityMeasurementSidebar::updateSidebarData() for( Int component = 0; component < 3; component++ ) { - quality = currFrame->getPSNR( refFrame, component ); + quality = currFrame->getQuality( m_comboBoxMetric->currentIndex(), refFrame, component ); m_ppcLabelQualityValue[component]->setText( value.setNum( quality, 'f', 2 ) ); } return; } + else + { + m_comboBoxRef->setCurrentIndex( -1 ); + } } for( Int component = 0; component < 3; component++ ) { @@ -176,12 +199,24 @@ Void QualityMeasurementSidebar::slotReferenceChanged( Int index ) { m_pcCurrentSubWindow->setRefSubWindow( subWindow ); updateSidebarData(); + m_comboBoxRef->setCurrentIndex( index ); return; } } } - m_comboBoxRef->setCurrentIndex( -1 ); + else + { + m_comboBoxRef->setCurrentIndex( -1 ); + } } +Void QualityMeasurementSidebar::slotQualityMetricChanged() +{ + QString labelQuality = PlaYUVerFrame::supportedQualityMetricsList().at( m_comboBoxMetric->currentIndex() ); + m_ppcLabelQualityLabel[LUMA]->setText( labelQuality + " Y"); + m_ppcLabelQualityLabel[CHROMA_U]->setText( labelQuality + " U"); + m_ppcLabelQualityLabel[CHROMA_V]->setText( labelQuality + " V"); + updateSidebarData(); +} } // NAMESPACE diff --git a/source/app/QualityMeasurementSidebar.h b/source/app/QualityMeasurementSidebar.h index 51bf01e..8e342cf 100644 --- a/source/app/QualityMeasurementSidebar.h +++ b/source/app/QualityMeasurementSidebar.h @@ -63,6 +63,8 @@ private: SubWindowHandle *m_pcCurrentSubWindow; + QComboBox *m_comboBoxMetric; + QComboBox *m_comboBoxRef; QComboBox *m_comboBoxRec; @@ -73,6 +75,7 @@ private: private Q_SLOTS: void slotReferenceChanged( int ); + void slotQualityMetricChanged(); }; diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 0979b0b..66b8a69 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -94,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; } @@ -118,6 +118,7 @@ Bool SubWindowHandle::loadFile( QString cFilename, Bool bForceDialog ) m_sStreamInfo.m_uiFrameRate = FrameRate; m_cWindowName = m_pCurrStream->getStreamInformationString(); + m_cWindowShortName = QFileInfo( cFilename ).fileName(); setWindowTitle( m_cWindowName ); return true; } @@ -205,8 +206,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; } diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 6ba8b5b..b2a8b35 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -73,6 +73,9 @@ private: QString m_cWindowName; + QString m_cWindowShortName; + QString m_cCurrFileName; + Bool m_bIsPlaying; Bool m_bIsModule; @@ -202,13 +205,11 @@ public: { return m_cWindowName; } - - QString userFriendlyCurrentFile() + QString getWindowShortName() { - return m_cWindowName; + return m_cWindowShortName; } - - QString currentFile() + QString getCurrentFileName() { return m_sStreamInfo.m_cFilename; } diff --git a/source/app/main.cpp b/source/app/main.cpp index a973489..f82e4c2 100644 --- a/source/app/main.cpp +++ b/source/app/main.cpp @@ -23,6 +23,7 @@ */ #include +#include "config.h" #include "plaYUVerApp.h" #include "SubWindowHandle.h" #ifdef USE_FERVOR @@ -30,11 +31,15 @@ #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("PLAYUVER_VERSION"); + QApplication::setApplicationName("PlaYUVer"); + QApplication::setApplicationVersion(PLAYUVER_VERSION_STRING); QApplication::setOrganizationName("pixlra"); QApplication::setOrganizationDomain("playuver.pixlra"); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index e2ef8b5..72f8626 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -48,7 +48,7 @@ plaYUVerApp::plaYUVerApp() setWindowModality( Qt::ApplicationModal ); - mdiArea = new QMdiArea; + mdiArea = new PlaYUVerMdiArea; setCentralWidget( mdiArea ); //mdiArea->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); //mdiArea->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); @@ -69,7 +69,7 @@ plaYUVerApp::plaYUVerApp() readSettings(); - setWindowTitle( tr( "plaYUVer" ) ); + setWindowTitle( QApplication::applicationName() ); setWindowIcon( QIcon( ":/images/playuver.png" ) ); setUnifiedTitleAndToolBarOnMac( true ); @@ -83,6 +83,7 @@ plaYUVerApp::plaYUVerApp() setAcceptDrops( true ); mdiArea->setAcceptDrops( true ); + m_pcAboutDialog = NULL; m_pcCurrentSubWindow = NULL; } @@ -101,13 +102,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 ) @@ -212,12 +216,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 ) ); + } } } @@ -225,6 +232,7 @@ Void plaYUVerApp::save() { if( m_pcCurrentSubWindow ) { + SubWindowHandle *saveWindow = m_pcCurrentSubWindow; QString supported = tr( "Supported Files (" ); QStringList formatsList; QStringList formatsExt = PlaYUVerStream::supportedSaveFormatsExt(); @@ -253,7 +261,7 @@ Void plaYUVerApp::save() if( !fileName.isEmpty() ) { m_cLastOpenPath = QFileInfo( fileName ).path(); - if( !m_pcCurrentSubWindow->save( fileName ) ) + if( !saveWindow->save( fileName ) ) { QApplication::restoreOverrideCursor(); QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot save file %1" ).arg( fileName ) ); @@ -267,7 +275,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(); } @@ -435,8 +443,11 @@ Void plaYUVerApp::setTimerStatus() } if( status ) { - m_cTimer.start(); - m_bIsPlaying = true; + if( !m_bIsPlaying ) + { + m_cTimer.start(); + m_bIsPlaying = true; + } } else { @@ -468,32 +479,57 @@ Void plaYUVerApp::play() if( !m_pcCurrentSubWindow->getInputStream() ) return; - if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() && m_acPlayingSubWindows.size() ) + if( !m_pcCurrentSubWindow->isPlaying() ) { - if( !m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + if( m_arrayActions[VIDEO_LOCK_ACT]->isChecked() && m_acPlayingSubWindows.size() ) { if( !m_pcCurrentSubWindow->play() ) { return; } - m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); - m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); - updateTotalFrameNum(); + if( !m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); + m_pcCurrentSubWindow->seekAbsoluteEvent( m_acPlayingSubWindows.at( 0 )->getInputStream()->getCurrFrameNum() ); + updateTotalFrameNum(); + } } + else + { + m_pcPlayingTimer->stop(); + m_acPlayingSubWindows.clear(); + if( !m_pcCurrentSubWindow->play() ) + { + return; + } + m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); + m_uiAveragePlayInterval = 0; + m_bIsPlaying = false; + } + startPlay(); + m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) ); } else { - m_pcPlayingTimer->stop(); - m_acPlayingSubWindows.clear(); - if( !m_pcCurrentSubWindow->play() ) + if( m_pcCurrentSubWindow ) { - return; + if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) + { + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->pause(); + } + } + else + { + m_pcCurrentSubWindow->pause(); + } + updateCurrFrameNum(); } - m_acPlayingSubWindows.append( m_pcCurrentSubWindow ); - m_uiAveragePlayInterval = 0; - m_bIsPlaying = false; + setTimerStatus(); + updateFrameProperties(); + m_arrayActions[PLAY_ACT]->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); } - startPlay(); } Void plaYUVerApp::pause() @@ -883,7 +919,7 @@ SubWindowHandle* plaYUVerApp::findSubWindow( const QMdiArea* mdiArea, const QStr foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ SubWindowHandle *mdiChild = qobject_cast( window); - if( mdiChild->currentFile() == canonicalFilePath ) + if( mdiChild->getCurrentFileName() == canonicalFilePath ) return mdiChild; } return 0; @@ -944,12 +980,13 @@ Void plaYUVerApp::updateMenus() m_pcZoomFactorSBox->setEnabled( hasSubWindow ); m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow ); - m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow ); + //m_arrayActions[PAUSE_ACT]->setEnabled( hasSubWindow ); m_arrayActions[STOP_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_BACKWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_FORWARD_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_LOOP_ACT]->setEnabled( hasSubWindow ); m_arrayActions[VIDEO_LOCK_ACT]->setEnabled( hasSubWindow ); + m_arrayActions[VIDEO_LOCK_SELECTION_ACT]->setEnabled( hasSubWindow ); m_pcFrameSlider->setEnabled( hasSubWindow ); if( !hasSubWindow ) { @@ -1000,11 +1037,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 ); @@ -1019,13 +1056,13 @@ Void plaYUVerApp::createActions() m_arrayActions.resize( TOTAL_ACT ); // ------------ File ------------ - m_arrayActions[OPEN_ACT] = new QAction( QIcon( ":/images/open.png" ), tr( "&Open..." ), this ); + m_arrayActions[OPEN_ACT] = new QAction( QIcon( ":/images/open.png" ), tr( "&Open" ), this ); m_arrayActions[OPEN_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogOpenButton ) ); m_arrayActions[OPEN_ACT]->setShortcuts( QKeySequence::Open ); m_arrayActions[OPEN_ACT]->setStatusTip( tr( "Open stream" ) ); connect( m_arrayActions[OPEN_ACT], SIGNAL( triggered() ), this, SLOT( open() ) ); - m_arrayActions[SAVE_ACT] = new QAction( QIcon( ":/images/save.png" ), tr( "&Save..." ), this ); + m_arrayActions[SAVE_ACT] = new QAction( QIcon( ":/images/save.png" ), tr( "&Save Frame" ), this ); m_arrayActions[SAVE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogSaveButton ) ); m_arrayActions[SAVE_ACT]->setShortcuts( QKeySequence::SaveAs ); m_arrayActions[SAVE_ACT]->setStatusTip( tr( "Save current frame" ) ); @@ -1033,18 +1070,20 @@ Void plaYUVerApp::createActions() m_arrayActions[FORMAT_ACT] = new QAction( tr( "&Format" ), this ); m_arrayActions[FORMAT_ACT]->setIcon( QIcon( ":/images/configuredialog.png" ) ); + m_arrayActions[FORMAT_ACT]->setShortcut( Qt::CTRL + Qt::Key_F ); m_arrayActions[FORMAT_ACT]->setStatusTip( tr( "Open format dialog" ) ); connect( m_arrayActions[FORMAT_ACT], SIGNAL( triggered() ), this, SLOT( format() ) ); m_arrayActions[RELOAD_ACT] = new QAction( tr( "&Reload" ), this ); m_arrayActions[RELOAD_ACT]->setIcon( style()->standardIcon( QStyle::SP_BrowserReload ) ); + m_arrayActions[RELOAD_ACT]->setShortcut( Qt::CTRL + Qt::Key_R ); m_arrayActions[RELOAD_ACT]->setStatusTip( tr( "Reload current sequence" ) ); connect( m_arrayActions[RELOAD_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) ); 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" ) ); @@ -1094,18 +1133,19 @@ Void plaYUVerApp::createActions() m_arrayActions[ZOOM_FIT_ACT] = new QAction( tr( "Zoom to &Fit" ), this ); m_arrayActions[ZOOM_FIT_ACT]->setIcon( QIcon( ":/images/fittowindow.png" ) ); m_arrayActions[ZOOM_FIT_ACT]->setStatusTip( tr( "Zoom in or out to fit on the window." ) ); - m_arrayActions[ZOOM_FIT_ACT]->setShortcut( tr( "Ctrl+F" ) ); + //m_arrayActions[ZOOM_FIT_ACT]->setShortcut( tr( "Ctrl+F" ) ); connect( m_arrayActions[ZOOM_FIT_ACT], SIGNAL( triggered() ), this, SLOT( zoomToFit() ) ); // ------------ Playing ------------ m_arrayActions[PLAY_ACT] = new QAction( "Play", this ); m_arrayActions[PLAY_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ) ); + m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space ); connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) ); - m_arrayActions[PAUSE_ACT] = new QAction( "Pause", this ); - m_arrayActions[PAUSE_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) ); - connect( m_arrayActions[PAUSE_ACT], SIGNAL( triggered() ), this, SLOT( pause() ) ); +// m_arrayActions[PAUSE_ACT] = new QAction( "Pause", this ); +// m_arrayActions[PAUSE_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaPause ) ) ); +// connect( m_arrayActions[PAUSE_ACT], SIGNAL( triggered() ), this, SLOT( pause() ) ); m_arrayActions[STOP_ACT] = new QAction( "Stop", this ); m_arrayActions[STOP_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) ); @@ -1116,11 +1156,13 @@ Void plaYUVerApp::createActions() m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this ); m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); + m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left ); connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) ); mapperSeekVideo->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 ); m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this ); m_arrayActions[VIDEO_FORWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); + m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right ); connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) ); mapperSeekVideo->setMapping( m_arrayActions[VIDEO_FORWARD_ACT], 1 ); @@ -1247,7 +1289,7 @@ Void plaYUVerApp::createMenus() m_arrayMenu[VIDEO_MENU] = menuBar()->addMenu( tr( "Video" ) ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PLAY_ACT] ); - m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PAUSE_ACT] ); + //m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[PAUSE_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[STOP_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] ); m_arrayMenu[VIDEO_MENU]->addAction( m_arrayActions[VIDEO_FORWARD_ACT] ); @@ -1307,7 +1349,7 @@ Void plaYUVerApp::createToolBars() m_arrayToolBars[VIDEO_TOOLBAR] = new QToolBar( tr( "Video" ) ); m_arrayToolBars[VIDEO_TOOLBAR]->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea ); m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PLAY_ACT] ); - m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PAUSE_ACT] ); + //m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[PAUSE_ACT] ); m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[STOP_ACT] ); m_arrayToolBars[VIDEO_TOOLBAR]->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] ); m_arrayToolBars[VIDEO_TOOLBAR]->addWidget( m_pcFrameSlider ); @@ -1323,7 +1365,7 @@ Void plaYUVerApp::createToolBars() m_pcTotalFrameNumLabel->setText( "-" ); m_arrayToolBars[VIDEO_TOOLBAR]->addWidget( m_pcTotalFrameNumLabel ); - addToolBar( Qt::BottomToolBarArea, m_arrayToolBars[VIDEO_TOOLBAR] ); + addToolBar( Qt::TopToolBarArea, m_arrayToolBars[VIDEO_TOOLBAR] ); } Void plaYUVerApp::createDockWidgets() diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index a7e7c1b..d9a1071 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -37,6 +37,7 @@ #include "ModulesHandle.h" #include "PropertiesSidebar.h" #include "QualityMeasurementSidebar.h" +#include "AboutDialog.h" namespace plaYUVer { @@ -118,7 +119,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; @@ -160,7 +190,6 @@ private: static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const QString& fileName ); static SubWindowHandle* findSubWindow( const QMdiArea* mdiArea, const SubWindowHandle* subWindow ); - QVector m_acPlayingSubWindows; QSlider *m_pcFrameSlider; QLabel *m_pcCurrFrameNumLabel; @@ -229,7 +258,7 @@ private: ZOOM_FIT_ACT, ZOOM_NORMAL_ACT, PLAY_ACT, - PAUSE_ACT, + /*PAUSE_ACT,*/ STOP_ACT, VIDEO_FORWARD_ACT, VIDEO_BACKWARD_ACT, @@ -259,6 +288,8 @@ private: PlaYUVerRecentFileListInfo m_aRecentFileStreamInfo; + AboutDialog* m_pcAboutDialog; + }; } // NAMESPACE diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 6d366d3..402cde0 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -390,30 +390,30 @@ Void PlaYUVerFrame::FrameToBuffer( Pel *output_buffer ) memcpy( output_buffer + frame_bytes_input * 5 / 4, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 4 * sizeof(Pel) ); break; case YUV444p: - memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); - memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input * sizeof(Pel) ); - memcpy( output_buffer + frame_bytes_input * 2, &m_pppcInputPel[CHROMA_V][0][0],frame_bytes_input * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input * sizeof(Pel) ); break; case YUV422p: - memcpy( output_buffer + frame_bytes_input * 0,&m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); - memcpy( output_buffer + frame_bytes_input * 1,&m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 2 * sizeof(Pel) ); - memcpy( output_buffer + frame_bytes_input * 3 / 2,&m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 2 * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 1, &m_pppcInputPel[CHROMA_U][0][0], frame_bytes_input / 2 * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 3 / 2, &m_pppcInputPel[CHROMA_V][0][0], frame_bytes_input / 2 * sizeof(Pel) ); break; case YUYV422: for( UInt i = 0; i < m_uiHeight * m_uiWidth / 2; i++ ) { - *output_buffer++ = *pInputPelY++ ; - *output_buffer++ = *pInputPelU++ ; - *output_buffer++ = *pInputPelY++ ; - *output_buffer++ = *pInputPelV++ ; + *output_buffer++ = *pInputPelY++; + *output_buffer++ = *pInputPelU++; + *output_buffer++ = *pInputPelY++; + *output_buffer++ = *pInputPelV++; } break; case GRAY: - memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); + memcpy( output_buffer + frame_bytes_input * 0, &m_pppcInputPel[LUMA][0][0], frame_bytes_input * sizeof(Pel) ); break; case RGB8: FrametoRGB8(); - memcpy( output_buffer, pcRGBPelInterlaced, frame_bytes_input * sizeof(Pel) * 3 ); + memcpy( output_buffer, pcRGBPelInterlaced, frame_bytes_input * sizeof(Pel) * 3 ); break; } } @@ -480,67 +480,73 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos ) } } -Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) -{ - Pel* pPelYUV = getPelBufferYUV()[component][0]; - Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; - - Int aux_pel_1, aux_pel_2; - Int diff = 0; - Double ssd = 0; - - 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++; - 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 PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) -{ - Double dPSNR = 100; - Double dMSE = getMSE( Org, component ); - if( dMSE != 0 ) - dPSNR = 10 * log10( 65025 / dMSE ); - return dPSNR; -} - UInt64 PlaYUVerFrame::getBytesPerFrame() +{ + return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); +} + +UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ) +{ + switch( iPixelFormat ) + { + case YUV420p: + return uiWidth * uiHeight * 1.5; + break; + case YUV444p: + return uiWidth * uiHeight * 3; + break; + case YUV422p: + case YUYV422: + return uiWidth * uiHeight * 2; + break; + case GRAY: + return uiWidth * uiHeight; + break; + case RGB8: + return uiWidth * uiHeight * 3; + break; + default: + return 0; + } + return 0; +} + +UInt PlaYUVerFrame::getChromaWidth() const { switch( m_iPixelFormat ) { case YUV420p: - return m_uiWidth * m_uiHeight * 1.5; + return m_uiWidth / 2; break; case YUV444p: - return m_uiWidth * m_uiHeight * 3; - break; case YUV422p: case YUYV422: - return m_uiWidth * m_uiHeight * 2; + case RGB8: + return m_uiWidth; break; case GRAY: - return m_uiWidth * m_uiHeight; + return 0; break; + default: + return 0; + } + return 0; +} + +UInt PlaYUVerFrame::getChromaHeight() const +{ + switch( m_iPixelFormat ) + { + case YUV420p: + case YUV422p: + case YUYV422: + return m_uiHeight / 2; + break; + case YUV444p: case RGB8: - return m_uiWidth * m_uiHeight * 3; + return m_uiHeight; + case GRAY: + return 0; break; default: return 0; @@ -652,19 +658,19 @@ cv::Mat PlaYUVerFrame::getCvMat() Int cvType = CV_8UC3; switch( m_iPixelFormat ) { - case YUV420p: - case YUV444p: - case YUV422p: - case YUYV422: + case YUV420p: + case YUV444p: + case YUV422p: + case YUYV422: cvType = CV_8UC3; break; - case GRAY: + case GRAY: cvType = CV_8UC1; break; - case RGB8: + case RGB8: cvType = CV_8UC3; break; - default: + default: break; } cv::Mat opencvFrame( m_uiHeight, m_uiWidth, cvType ); @@ -681,7 +687,6 @@ cv::Mat PlaYUVerFrame::getCvMat() } #endif - #ifdef USE_OPENCV Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame ) { @@ -689,13 +694,13 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame ) { switch( opencvFrame->channels() ) { - case 1: + case 1: m_iPixelFormat = GRAY; break; - case 3: + case 3: m_iPixelFormat = RGB8; break; - default: + default: return; } } @@ -728,5 +733,150 @@ Void PlaYUVerFrame::copyFrom( cv::Mat* opencvFrame ) } } #endif + +/** + * Quality Related Function API + */ + +Double PlaYUVerFrame::getQuality( Int Metric, PlaYUVerFrame* Org, Int component ) +{ + switch( Metric ) + { + case PSNR_METRIC: + return getPSNR( Org, component ); + break; + case MSE_METRIC: + return getMSE( Org, component ); + break; + case SSIM_METRIC: + return getSSIM( Org, component ); + break; + default: + assert( 0 ); + }; + return 0; } -// NAMESPACE + +Double PlaYUVerFrame::getMSE( PlaYUVerFrame* Org, Int component ) +{ + Pel* pPelYUV = getPelBufferYUV()[component][0]; + Pel* pOrgPelYUV = Org->getPelBufferYUV()[component][0]; + + Int aux_pel_1, aux_pel_2; + Int diff = 0; + Double ssd = 0; + + 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++; + 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 PlaYUVerFrame::getPSNR( PlaYUVerFrame* Org, Int component ) +{ + Double dPSNR = 100; + Double dMSE = getMSE( Org, component ); + if( dMSE != 0 ) + dPSNR = 10 * log10( 65025 / dMSE ); + return dPSNR; +} + +float compute_ssim( Pel **refImg, Pel **encImg, Int width, Int height, Int win_width, Int win_height, Int max_pel_value_comp, Int overlapSize ) +{ + static const float K1 = 0.01f, K2 = 0.03f; + float max_pix_value_sqd; + float C1, C2; + float win_pixels = ( float )( win_width * win_height ); +#ifdef UNBIASED_VARIANCE + float win_pixels_bias = win_pixels - 1; +#else + float win_pixels_bias = win_pixels; +#endif + float mb_ssim, meanOrg, meanEnc; + float varOrg, varEnc, covOrgEnc; + int imeanOrg, imeanEnc, ivarOrg, ivarEnc, icovOrgEnc; + float cur_distortion = 0.0; + int i, j, n, m, win_cnt = 0; + + max_pix_value_sqd = ( float )( max_pel_value_comp * max_pel_value_comp ); + C1 = K1 * K1 * max_pix_value_sqd; + C2 = K2 * K2 * max_pix_value_sqd; + + for( j = 0; j <= height - win_height; j += overlapSize ) + { + for( i = 0; i <= width - win_width; i += overlapSize ) + { + imeanOrg = 0; + imeanEnc = 0; + ivarOrg = 0; + ivarEnc = 0; + icovOrgEnc = 0; + + for( n = j; n < j + win_height; n++ ) + { + for( m = i; m < i + win_width; m++ ) + { + imeanOrg += refImg[n][m]; + imeanEnc += encImg[n][m]; + ivarOrg += refImg[n][m] * refImg[n][m]; + ivarEnc += encImg[n][m] * encImg[n][m]; + icovOrgEnc += refImg[n][m] * encImg[n][m]; + } + } + + meanOrg = ( float )imeanOrg / win_pixels; + meanEnc = ( float )imeanEnc / win_pixels; + + varOrg = ( ( float )ivarOrg - ( ( float )imeanOrg ) * meanOrg ) / win_pixels_bias; + varEnc = ( ( float )ivarEnc - ( ( float )imeanEnc ) * meanEnc ) / win_pixels_bias; + covOrgEnc = ( ( float )icovOrgEnc - ( ( float )imeanOrg ) * meanEnc ) / win_pixels_bias; + + mb_ssim = ( float )( ( 2.0 * meanOrg * meanEnc + C1 ) * ( 2.0 * covOrgEnc + C2 ) ); + mb_ssim /= ( float )( meanOrg * meanOrg + meanEnc * meanEnc + C1 ) * ( varOrg + varEnc + C2 ); + + cur_distortion += mb_ssim; + win_cnt++; + } + } + + cur_distortion /= ( float )win_cnt; + + if( cur_distortion >= 1.0 && cur_distortion < 1.01 ) // avoid float accuracy problem at very low QP(e.g.2) + cur_distortion = 1.0; + + return cur_distortion; +} + +Double PlaYUVerFrame::getSSIM( PlaYUVerFrame* Org, Int component ) +{ + Double dSSIM = 1; + if( component == LUMA ) + { + dSSIM = compute_ssim( m_pppcInputPel[component], Org->getPelBufferYUV()[component], m_uiWidth, m_uiHeight, 8, 8, 255, 8 ); + } + else + { + dSSIM = compute_ssim( m_pppcInputPel[component], Org->getPelBufferYUV()[component], getChromaWidth(), getChromaHeight(), 4, 4, 255, 8 ); + } + return dSSIM; +} + +} // NAMESPACE diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index a182bc5..a52f42d 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -112,13 +112,13 @@ public: Void FrameToBuffer( Pel* ); Void copyFrom( PlaYUVerFrame* ); - Void copyFrom( PlaYUVerFrame*, UInt, UInt); - - Double getMSE( PlaYUVerFrame* Org, Int component ); - Double getPSNR( PlaYUVerFrame* Org, Int component ); + Void copyFrom( PlaYUVerFrame*, UInt, UInt ); UInt64 getBytesPerFrame(); + static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ); + UInt getChromaWidth() const; + UInt getChromaHeight() const; UInt getChromaLength() const; Pel*** getPelBufferYUV() const @@ -146,6 +146,31 @@ public: Void copyFrom( cv::Mat* ); #endif + enum QualityMetrics + { + NO_METRIC = -1, + PSNR_METRIC = 0, + MSE_METRIC, + SSIM_METRIC, + NUMBER_METRICS, + }; + + static QStringList supportedQualityMetricsList() + { + QStringList metrics; + metrics << "PSNR" + << "MSE" + << "SSIM" // SSIM + ; + assert( metrics.size() == NUMBER_METRICS ); + return metrics; + } + + Double getQuality( Int Metric, PlaYUVerFrame* Org, Int component ); + Double getMSE( PlaYUVerFrame* Org, Int component ); + Double getPSNR( PlaYUVerFrame* Org, Int component ); + Double getSSIM( PlaYUVerFrame* Org, Int component ); + UInt getWidth() const { return m_uiWidth; @@ -171,9 +196,9 @@ 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() ); - } + { + 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 0af75e1..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; } @@ -331,7 +439,7 @@ Void PlaYUVerStream::loadAll() m_iCurrFrameNum = -1; seekInput( 0 ); setNextFrame(); - for( UInt i = m_uiFrameBufferIndex; i < m_uiFrameBufferSize ; i++ ) + for( UInt i = m_uiFrameBufferIndex; i < m_uiFrameBufferSize; i++ ) { readFrame(); setNextFrame(); @@ -434,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/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h index dcdc947..5a08ec1 100644 --- a/source/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -40,7 +40,7 @@ extern "C" #include #include #include -#include +//#include #include } diff --git a/source/modules/FilterComponent.cpp b/source/modules/FilterComponent.cpp new file mode 100644 index 0000000..fecf005 --- /dev/null +++ b/source/modules/FilterComponent.cpp @@ -0,0 +1,141 @@ +/* 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 FilterComponent.cpp + * \brief Filter component frame module + */ + +#include + +#include "FilterComponent.h" + +namespace plaYUVer +{ + +FilterComponent::FilterComponent() +{ + m_pcFilteredFrame = NULL; +} + +Void FilterComponent::createFilter( UInt uiWidth, UInt uiHeight ) +{ + m_pcFilteredFrame = NULL; + m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY ); +} + +PlaYUVerFrame* FilterComponent::filterComponent( PlaYUVerFrame* InputFrame, Int Component ) +{ + Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV(); + Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV(); + memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[Component][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) ); + return m_pcFilteredFrame; +} + +Void FilterComponent::destroy() +{ + if( m_pcFilteredFrame ) + delete m_pcFilteredFrame; + m_pcFilteredFrame = NULL; +} + + +PlaYUVerModuleDefinition FilterComponentLumaDef = { + FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. + // Currently only support for frame + "Filter Component", // Category (sub-menu) + "Luma", // Name + "Filter Y matrix of YUV frame", // Description + MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h). + // Several requirements should be "or" between each others. + APPLY_WHILE_PLAYING, // Apply module while playing +}; + +FilterComponentLuma::FilterComponentLuma() +{ + setModuleDefinition( FilterComponentLumaDef ); +} + +Void FilterComponentLuma::create( PlaYUVerFrame* InputFrame ) +{ + createFilter( InputFrame->getWidth(), InputFrame->getHeight() ); +} + +PlaYUVerFrame* FilterComponentLuma::process( PlaYUVerFrame* InputFrame ) +{ + return filterComponent( InputFrame, LUMA ); +} + +PlaYUVerModuleDefinition FilterComponentCbDef = { + FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. + // Currently only support for frame + "Filter Component", // Category (sub-menu) + "Chroma U", // Name + "Filter Y matrix of YUV frame", // Description + MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h). + // Several requirements should be "or" between each others. + APPLY_WHILE_PLAYING, // Apply module while playing +}; + +FilterComponentChromaU::FilterComponentChromaU() +{ + setModuleDefinition( FilterComponentCbDef ); +} + +Void FilterComponentChromaU::create( PlaYUVerFrame* InputFrame ) +{ + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); +} + +PlaYUVerFrame* FilterComponentChromaU::process( PlaYUVerFrame* InputFrame ) +{ + return filterComponent( InputFrame, CHROMA_U ); +} + +PlaYUVerModuleDefinition FilterComponentCrDef = { + FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. + // Currently only support for frame + "Filter Component", // Category (sub-menu) + "Chroma R", // Name + "Filter Y matrix of YUV frame", // Description + MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) + MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h). + // Several requirements should be "or" between each others. + APPLY_WHILE_PLAYING, // Apply module while playing +}; + +FilterComponentChromaV::FilterComponentChromaV() +{ + setModuleDefinition( FilterComponentCrDef ); +} + +Void FilterComponentChromaV::create( PlaYUVerFrame* InputFrame ) +{ + createFilter( InputFrame->getChromaWidth(), InputFrame->getChromaHeight() ); +} + +PlaYUVerFrame* FilterComponentChromaV::process( PlaYUVerFrame* InputFrame ) +{ + return filterComponent( InputFrame, CHROMA_V ); +} + +} // NAMESPACE + diff --git a/source/modules/FilterComponent.h b/source/modules/FilterComponent.h new file mode 100644 index 0000000..d2698a5 --- /dev/null +++ b/source/modules/FilterComponent.h @@ -0,0 +1,90 @@ +/* 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 FilterComponent.h + * \brief Filter component frame module + */ + +#ifndef __FILTERCOMPONENT_H__ +#define __FILTERCOMPONENT_H__ + +#include "config.h" +#include "PlaYUVerDefs.h" +#include +#include +#include "PlaYUVerFrame.h" +#include "PlaYUVerModuleIf.h" + +#include + +namespace plaYUVer +{ + +class FilterComponent +{ +private: + PlaYUVerFrame* m_pcFilteredFrame; +public: + FilterComponent(); + virtual ~FilterComponent() + { + } + Void createFilter( UInt uiWidth, UInt uiHeight ); + PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component ); + Void destroy(); +}; + +class FilterComponentLuma: public FilterComponent, public PlaYUVerModuleIf +{ +public: + FilterComponentLuma(); + virtual ~FilterComponentLuma() + { + } + Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); +}; + +class FilterComponentChromaU: public FilterComponent, public PlaYUVerModuleIf +{ +public: + FilterComponentChromaU(); + virtual ~FilterComponentChromaU() + { + } + Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); +}; + +class FilterComponentChromaV: public FilterComponent, public PlaYUVerModuleIf +{ +public: + FilterComponentChromaV(); + virtual ~FilterComponentChromaV() + { + } + Void create( PlaYUVerFrame* InputFrame ); + PlaYUVerFrame* process( PlaYUVerFrame* InputFrame ); +}; + +} // NAMESPACE + +#endif // __FILTERFRAME_H__ + diff --git a/source/modules/FilterFrame.cpp b/source/modules/FilterFrame.cpp deleted file mode 100644 index fc97496..0000000 --- a/source/modules/FilterFrame.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* 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 FilterFrame.cpp - * \brief Filter frame module - */ - -#include - -#include "FilterFrame.h" -#include "PlaYUVerFrame.h" - -namespace plaYUVer -{ - -PlaYUVerModuleDefinition FilterFrameDef = { - FRAME_PROCESSING_MODULE, // Apply module to the frames or to the whole sequence. - // Currently only support for frame - "Filters", // Category (sub-menu) - "Y_Filter", // Name - "Filter Y matrix of YUV frame", // Description - MODULE_REQUIRES_ONE_FRAME, // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES) - MODULE_REQUIRES_NOTHING, // Module requirements (check PlaYUVerModulesIf.h). - // Several requirements should be "or" between each others. - APPLY_WHILE_PLAYING, // Apply module while playing -}; - -FilterFrame::FilterFrame() -{ - setModuleDefinition( FilterFrameDef ); - m_pcFilteredFrame = NULL; -} - -Void FilterFrame::create( PlaYUVerFrame* InputFrame ) -{ - m_pcFilteredFrame = NULL; - m_pcFilteredFrame = new PlaYUVerFrame( InputFrame->getWidth(), InputFrame->getHeight(), PlaYUVerFrame::GRAY ); -} - -PlaYUVerFrame* FilterFrame::process( PlaYUVerFrame* InputFrame ) -{ - Pel*** pppOutputPelYUV = m_pcFilteredFrame->getPelBufferYUV(); - Pel*** pppInputPelYUV = InputFrame->getPelBufferYUV(); - memcpy( pppOutputPelYUV[LUMA][0], pppInputPelYUV[LUMA][0], m_pcFilteredFrame->getWidth() * m_pcFilteredFrame->getHeight() * sizeof(Pel) ); - return m_pcFilteredFrame; -} - -Void FilterFrame::destroy() -{ - if( m_pcFilteredFrame ) - delete m_pcFilteredFrame; - m_pcFilteredFrame = NULL; -} - -} // NAMESPACE -