25 Commits
Author SHA1 Message Date
jfmcarreira 944bc0116b fix: build errors 2024-10-03 01:31:38 +01:00
jfmcarreira 303d15cbc2 Merge remote-tracking branch 'upstream/devel' into devel 2024-10-02 23:51:57 +01:00
jfmcarreira 05be89459e refactor: modernize code 2024-10-02 23:33:21 +01:00
jfmcarreira 0cf79bf7a5 ci: update build workflow 2024-04-28 01:06:14 +01:00
jfmcarreira e0db35d087 build: remove libfmt dependency 2024-04-27 22:18:18 +01:00
jfmcarreira 0d70ab8a84 build(fmt): find missing depency to libfmt 2023-09-24 21:58:58 +01:00
jfmcarreira d1e9a1cb2d fix(lib): add missing include and replace vector with span 2023-09-24 21:05:03 +01:00
Joao Carreira 18c69b8529 build(app): remove Qt6 dependency from qcustomplot 2023-04-29 01:56:40 +01:00
Joao Carreira 2f9abe7e47 fix(qt): make Qt6 optional 2023-04-28 23:32:36 +01:00
Joao Carreira 2f1d8dbb8b ci: add coverage to build without Qt6 2023-04-28 22:38:25 +01:00
Joao Carreira a2262ca3a7 feat(tests): update catch to version 3 2023-04-02 22:29:25 +01:00
Joao Carreira acb04c2360 fix: build errors and add support for Qt6 2023-03-28 01:07:32 +01:00
Joao Carreira cbefa2be2e refactor(pixel): add nameless namespace to CalypPixel 2022-11-13 21:34:43 +00:00
Joao Carreira 7dedd2f388 refactor(modules): remove the use of a macro to create a module 2022-11-13 21:33:54 +00:00
Joao Carreira aa2725e427 Merge branch 'master' into devel 2022-03-07 00:17:00 +00:00
Joao Carreira 8358ea0a3a Fix build on mac due to FFmpeg 2022-02-18 23:35:21 +00:00
jfmcarreira 8e15de8ce5 Merge branch 'master' into devel 2022-02-05 14:06:25 +00:00
jfmcarreira da40950ebe Minor changes in code format and repo 2022-02-05 14:06:09 +00:00
jfmcarreira 3380ad18b8 Work on resources 2022-02-05 14:01:20 +00:00
jfmcarreira d3c665605e Remove ivars that keep the active subwindow 2021-12-26 12:23:08 +00:00
jfmcarreira d01a91651b Finish refactor of load and format stream 2021-12-26 12:09:18 +00:00
jfmcarreira cd547a964b Fix keeping an history of open files 2021-12-25 02:51:02 +00:00
jfmcarreira f43e6e2634 Inital refactor to use resource independent from the video windows 2021-12-24 16:43:23 +00:00
jfmcarreira 7f8be0cb0e Merge branch 'master' into devel 2021-12-19 15:25:20 +00:00
jfmcarreira c1dd45662a Code formatting 2021-12-19 14:16:07 +00:00
83 changed files with 16073 additions and 16213 deletions

No files matched your search

+37 -38
View File
@@ -1,19 +1,19 @@
---
BasedOnStyle: Google
Language: Cpp
ColumnLimit: 0
BasedOnStyle: Google
Language: Cpp
ColumnLimit: 120
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
@@ -21,17 +21,17 @@ AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterNamespace: true
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
AfterControlStatement: true
AfterObjCDeclaration: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
AfterNamespace: true
AfterClass: true
AfterEnum: true
AfterFunction: true
AfterStruct: true
AfterUnion: true
AfterControlStatement: true
AfterObjCDeclaration: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
BreakBeforeBraces: Custom
BreakBeforeBinaryOperators: None
BreakBeforeInheritanceComma: false
@@ -40,31 +40,31 @@ BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
CommentPragmas: '^ IWYU pragma:'
CommentPragmas: "^ IWYU pragma:"
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH]
IncludeCategories:
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
- Regex: '^<.*\.h>'
Priority: 1
- Regex: "^<.*"
Priority: 2
- Regex: ".*"
Priority: 3
IncludeIsMainRegex: "([-_](test|unittest))?$"
IndentCaseLabels: false
IndentWidth: 2
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
@@ -77,21 +77,20 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
ReflowComments: true
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SortIncludes: true
SortIncludes: true
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 2
UseTab: Never
...
Standard: Auto
TabWidth: 2
UseTab: Never
---
+64 -43
View File
@@ -1,45 +1,66 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-owning-memory, -cppcoreguidelines-pro-bounds-constant-array-index, -readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
Checks: "*,-modernize-use-nodiscard,-llvmlibc-*,-fuchsia-trailing-return,-fuchsia*,-altera-*,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-implicit-widening-of-multiplication-result,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers, -readability-identifier-length"
WarningsAsErrors: ""
HeaderFilterRegex: ""
FormatStyle: file
CheckOptions:
- key: llvm-else-after-return.WarnOnConditionVariables
value: '0'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: '0'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: llvm-qualified-auto.AddConstToQualified
value: '0'
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: llvm-else-after-return.WarnOnUnfixable
value: '0'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: '1'
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.ClassMemberCase
value: camelBack
- key: readability-identifier-naming.ClassMethodCase
value: camelBack
- key: readability-identifier-naming.ParameterCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberPrefix
value: m_
- key: readability-identifier-length.IgnoredVariableNames
value: "^(id|to)$"
- key: llvm-else-after-return.WarnOnConditionVariables
value: "0"
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: "0"
- key: google-readability-namespace-comments.ShortNamespaceLines
value: "10"
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: "0"
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: "1"
- key: cert-dcl16-c.NewSuffixes
value: "L;LL;LU;LLU"
- key: google-readability-braces-around-statements.ShortStatementLines
value: "1"
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: google-readability-namespace-comments.SpacesBeforeComments
value: "2"
- key: modernize-loop-convert.MaxCopySize
value: "16"
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: "1"
- key: modernize-use-nullptr.NullMacros
value: "NULL"
- key: llvm-qualified-auto.AddConstToQualified
value: "0"
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: llvm-else-after-return.WarnOnUnfixable
value: "0"
- key: google-readability-function-size.StatementThreshold
value: "800"
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: "1"
- key: readability-braces-around-statements.ShortStatementLines
value: "1"
- key: google-readability-braces-around-statements.ShortStatementLines
value: "1"
- key: hicpp-braces-around-statements.ShortStatementLines
value: "1"
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: "1"
+63 -35
View File
@@ -1,4 +1,4 @@
name: Build on Linux
name: Build/Test Pipeline
on:
push:
@@ -6,59 +6,87 @@ on:
- master
- devel
pull_request:
branches: [ master ]
branches: [master]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
check-build:
check-build-linux:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
name: Build (Linux)
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install gcc-10 g++-10 cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build with default options
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON; cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Build with default options
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Build without threads
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON -DCALYP_MANAGED_RESOURCES=OFF -DCALYP_THREADED_MODULES=OFF; cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Build without threads
run: |
cmake -B ${{github.workspace}}/build-without-thread -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON -DCALYP_MANAGED_RESOURCES=OFF -DCALYP_THREADED_MODULES=OFF
cmake --build ${{github.workspace}}/build-without-thread --config ${{env.BUILD_TYPE}}
- name: Build without dependencies
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON -DUSE_OPENCV=OFF -DUSE_FFMPEG=OFF; cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Build without dependencies
run: |
cmake -B ${{github.workspace}}/build-without-deps -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON -DUSE_OPENCV=OFF -DUSE_FFMPEG=OFF
cmake --build ${{github.workspace}}/build-without-deps --config ${{env.BUILD_TYPE}}
check-tests:
runs-on: ubuntu-latest
- name: Install Qt&
run: sudo apt-get install qt6-base-dev
- name: Build with Qt& (autodetect)
run: |
cmake -B ${{github.workspace}}/build-qt6 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
cmake --build ${{github.workspace}}/build-qt6 --config ${{env.BUILD_TYPE}}
check-build-macos:
name: Build (macOS)
runs-on: macos-latest
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install gcc-10 g++-10 cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
- uses: actions/checkout@v4
- name: Install dependencies
run: brew install cmake qt opencv ffmpeg
- name: Build with default options
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- uses: actions/checkout@v2
check-tests-linux:
name: Tests (Linux)
runs-on: ubuntu-24.04
needs: check-build-linux
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install cmake qtbase5-dev qt6-base-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
- name: Check out tests data
uses: actions/checkout@master
with:
repository: 'pixlra/calyp-testdata'
path: ${{github.workspace}}/tests_data
- uses: actions/checkout@v4
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON -DCALYP_TEST_DATA_DIR=${{github.workspace}}/tests_data
- name: Check out tests data
uses: actions/checkout@master
with:
repository: "pixlra/calyp-testdata"
path: ${{github.workspace}}/tests_data
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON -DCALYP_TEST_DATA_DIR=${{github.workspace}}/tests_data
- name: CalypLib tests
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t test
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: CalypLib tests
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -t test
+2
View File
@@ -1,6 +1,8 @@
# Created by https://www.gitignore.io/api/c++,clion,linux
# Edit at https://www.gitignore.io/?templates=c++,clion,linux
deps/**
templates/**
### C++ ###
# Prerequisites
*.d
+3 -2
View File
@@ -129,7 +129,7 @@ IF(BUILD_TESTS)
FETCHCONTENT_DECLARE(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.1
GIT_TAG v3.3.2
)
SET_PACKAGE_PROPERTIES(
@@ -147,8 +147,9 @@ IF(BUILD_TESTS)
)
FETCHCONTENT_MAKEAVAILABLE(googletest Catch2)
INCLUDE(${CMAKE_BINARY_DIR}/deps/catch2-src/contrib/Catch.cmake)
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/deps/catch2-src/extras)
INCLUDE(CTest)
INCLUDE(Catch)
ENABLE_TESTING()
SET(CALYP_TEST_DATA_DIR
+44 -23
View File
@@ -3,19 +3,33 @@
#
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/dialog
${CMAKE_CURRENT_SOURCE_DIR}/docks ${CMAKE_CURRENT_SOURCE_DIR}/widgets
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/dialog
${CMAKE_CURRENT_SOURCE_DIR}/docks
${CMAKE_CURRENT_SOURCE_DIR}/widgets
${CMAKE_CURRENT_SOURCE_DIR}/models
)
OPTION(USE_QTDBUS "Build with QtDBus" ON)
OPTION(USE_QT6 "Build with Qt6" ON)
OPTION(USE_QTDBUS "Build with QtDBus" OFF)
OPTION(USE_FERVOR "Add Fervor support" OFF)
OPTION(CALYP_MANAGED_RESOURCES "Handle streams in separate threads" ON)
OPTION(CALYP_THREADED_MODULES "Use threads for modules" ON)
IF(${USE_QT6})
FIND_PACKAGE(Qt6 QUIET COMPONENTS Core Gui Widgets Concurrent)
IF (NOT Qt6_FOUND)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent)
ENDIF()
ELSE()
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent)
ENDIF()
ADD_SUBDIRECTORY(external)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent)
LIST(APPEND QT_LINKER_LIBS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent)
LIST(APPEND QT_LINKER_LIBS Qt::Core Qt::Gui Qt::Widgets Qt::Concurrent)
LIST(APPEND QT_MODULES Core Gui Widgets Concurrent)
IF(USE_QTDBUS)
@@ -31,11 +45,12 @@ IF(USE_QTDBUS)
${Qt5DBus_FOUND}
PARENT_SCOPE
)
LIST(APPEND QT_LINKER_LIBS Qt5::DBus)
LIST(APPEND QT_LINKER_LIBS Qt::DBus)
LIST(APPEND QT_MODULES DBus)
ENDIF()
ENDIF()
ADD_DEFINITIONS(
-DQT_NO_CAST_TO_ASCII
# -DQT_NO_CAST_FROM_ASCII
@@ -44,28 +59,30 @@ ADD_DEFINITIONS(
# -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_USE_QSTRINGBUILDER
)
SET(Calyp_App_SRCS
SET(Calyp_App_Module_SRCS # Module Video
models/VideostreamResource.cpp ResourceHandle.cpp
)
SET(Calyp_App_GUI_SRCS
${Calyp_App_Module_SRCS}
# Models
ModulesHandle.cpp
SubWindowHandle.cpp
VideoHandle.cpp
CalypAppModuleIf.cpp
QualityHandle.cpp
# Main
main.cpp
MainWindow.cpp
# Module SubWindow
SubWindowHandle.cpp
MdiSubWindow.cpp
SubWindowAbstract.cpp
# Module Video
ResourceHandle.cpp
VideoHandle.cpp
VideoSubWindow.cpp
VideoStreamSubWindow.cpp
ModuleSubWindow.cpp
ViewArea.cpp
GridManager.cpp
# Module Quality
QualityHandle.cpp
PlotSubWindow.cpp
# Module Plugins
ModulesHandle.cpp
CalypAppModuleIf.cpp
# Dialogs
dialog/AboutDialog.cpp
dialog/ConfigureFormatDialog.cpp
@@ -83,7 +100,7 @@ SET(Calyp_App_SRCS
)
IF(USE_QTDBUS)
LIST(APPEND Calyp_App_SRCS DBusAppAdaptor.cpp)
LIST(APPEND Calyp_App_GUI_SRCS DBusAppAdaptor.cpp)
ENDIF()
SET(Calyp_App_UI "")
@@ -107,7 +124,7 @@ IF(USE_FERVOR)
FIND_PACKAGE(Qt5 REQUIRED Network WebKit WebKitWidgets)
LIST(APPEND QT_LINKER_LIBS Qt5::Network Qt5::WebKit Qt5::WebKitWidgets)
LIST(APPEND QT_LINKER_LIBS Qt::Network Qt::WebKit Qt::WebKitWidgets)
LIST(APPEND QT_MODULES Network WebKit WebKitWidgets)
# LIST(APPEND APP_LINKER_LIBS ${FERVOR_DEPENDENCIES} )
@@ -130,8 +147,8 @@ SET_PACKAGE_PROPERTIES(
)
ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.")
QT5_WRAP_UI(Calyp_App_UI_Wrap ${Calyp_App_UI})
QT5_ADD_RESOURCES(Calyp_App_RCC ${Calyp_App_RCC})
QT_WRAP_UI(Calyp_App_UI_Wrap ${Calyp_App_UI})
QT_ADD_RESOURCES(Calyp_App_RCC ${Calyp_App_RCC})
# Instruct CMake to run moc automatically when needed.
SET(CMAKE_AUTOMOC ON)
@@ -158,7 +175,7 @@ IF(WIN32)
COMMENT "Add icon on windows platform"
)
ENDIF()
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${WINDOWS_RES_FILE})
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_GUI_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${WINDOWS_RES_FILE})
ELSEIF(CMAKE_HOST_APPLE)
SET(CMAKE_MACOSX_BUNDLE ON)
SET(MACOSX_BUNDLE_EXECUTABLE_NAME ${PROJECT_NAME})
@@ -166,9 +183,9 @@ ELSEIF(CMAKE_HOST_APPLE)
SET(MACOSX_BUNDLE_BUNDLE_NAME Calyp)
SET(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/resources/calyp.icns)
SET_SOURCE_FILES_PROPERTIES(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
ADD_EXECUTABLE(${PROJECT_NAME} MACOSX_BUNDLE ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${APP_ICON_MACOSX})
ADD_EXECUTABLE(${PROJECT_NAME} MACOSX_BUNDLE ${Calyp_App_GUI_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${APP_ICON_MACOSX})
ELSE()
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC})
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_GUI_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC})
ENDIF()
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PROJECT_LIBRARY} CalypModules ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib)
@@ -178,3 +195,7 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
INSTALL(FILES resources/calyp.desktop DESTINATION share/applications)
INSTALL(FILES resources/calyp.png DESTINATION share/pixmaps)
INSTALL(FILES resources/calyp.xml DESTINATION share/mime/packages)
IF(BUILD_TESTS)
ADD_SUBDIRECTORY(catch2)
ENDIF()
+151 -129
View File
@@ -36,6 +36,7 @@
#include <memory>
#include "AboutDialog.h"
#include "ConfigureFormatDialog.h"
#include "ModulesHandle.h"
#include "QualityHandle.h"
#include "SubWindowAbstract.h"
@@ -44,12 +45,12 @@
#include "VideoHandle.h"
#include "VideoSubWindow.h"
#include "lib/CalypOptions.h"
#include "models/VideostreamResource.h"
#ifdef USE_FERVOR
#include "fvupdater.h"
#endif
MainWindow::MainWindow()
: m_pcCurrentSubWindow( NULL ), m_pcCurrentVideoSubWindow( NULL ), m_pcAboutDialog( NULL )
{
setWindowModality( Qt::ApplicationModal );
setWindowModality( Qt::NonModal );
@@ -134,8 +135,7 @@ bool MainWindow::parseArgs( int argc, char* argv[] )
void MainWindow::about()
{
if( !m_pcAboutDialog )
m_pcAboutDialog = new AboutDialog( this );
if( !m_pcAboutDialog ) m_pcAboutDialog = new AboutDialog( this );
m_pcAboutDialog->exec();
}
@@ -185,55 +185,82 @@ void MainWindow::closeAll()
m_pcWindowHandle->removeAllSubWindow();
}
void MainWindow::loadFile( CalypFileInfo pStreamInfo )
void MainWindow::loadFile( const CalypFileInfo& pStreamInfo )
{
QString filename{ pStreamInfo.m_cFilename };
loadFile( std::move( filename ), std::move( pStreamInfo ) );
loadFile( pStreamInfo.m_cFilename, pStreamInfo );
}
void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> streamInfo )
void MainWindow::loadFile( const QString& fileName, std::optional<CalypFileInfo> streamInfoOpt, bool forceDialog )
{
qDebug() << fileName;
if( !QFileInfo( fileName ).exists() )
{
printMessage( "File " + fileName + " do not exist!", CLP_LOG_ERROR );
return;
}
auto* videoSubWindow = MainWindow::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
if( videoSubWindow )
if( auto* videoSubWindow = MainWindow::findVideoStreamSubWindow( m_pcWindowHandle, fileName ) )
{
m_pcWindowHandle->setActiveSubWindow( videoSubWindow );
return;
}
videoSubWindow = new VideoStreamSubWindow(); // createSubWindow();
videoSubWindow->setResourceManaget( m_appResourceHandle.get() );
if( !streamInfo.has_value() )
if( !streamInfoOpt.has_value() )
{
auto idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
if( idx >= 0 )
streamInfo = m_aRecentFileStreamInfo.at( idx );
if( idx >= 0 ) streamInfoOpt = m_aRecentFileStreamInfo.at( idx );
}
auto streamInfo = streamInfoOpt.has_value() ? *streamInfoOpt : CalypFileInfo{ .m_cFilename = fileName };
auto videoResource = std::make_unique<VideostreamResource>();
bool opened = false;
try
{
bool opened = false;
[[maybe_unused]] auto guessed = video_resource_guess_format(
streamInfo.m_cFilename, streamInfo.m_uiWidth, streamInfo.m_uiHeight, streamInfo.m_iPelFormat,
streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness, streamInfo.m_uiFrameRate );
if( streamInfo.has_value() )
if( !forceDialog )
{
try
{
opened = videoSubWindow->loadFile( std::move( *streamInfo ) );
}
catch( CalypFailure& e )
{
}
opened = videoResource->loadFile( streamInfo, false );
}
if( !opened )
opened = videoSubWindow->loadFile( fileName );
{
ConfigureFormatDialog formatDialog( this );
if( streamInfo.m_uiWidth == 0 )
{
streamInfo.m_uiWidth = m_lastOpenWidth;
}
if( streamInfo.m_uiHeight == 0 )
{
streamInfo.m_uiHeight = m_lastOpenHeight;
}
if( streamInfo.m_uiBitsPelPixel == 0 )
{
streamInfo.m_uiBitsPelPixel = m_lastOpenBitPerPixel;
}
if( formatDialog.runConfigureFormatDialog( QFileInfo( streamInfo.m_cFilename ).fileName(), streamInfo.m_uiWidth,
streamInfo.m_uiHeight, streamInfo.m_iPelFormat,
streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness,
streamInfo.m_uiFrameRate ) != QDialog::Accepted )
{
return;
}
opened = videoResource->loadFile( streamInfo, false );
}
if( opened )
{
const auto openedStreamInfo = videoResource->getStreamInfo();
auto resource_id = m_appResourceHandle->appendResource( std::move( videoResource ) );
auto* videoSubWindow = new VideoStreamSubWindow( m_appResourceHandle.get() ); // createSubWindow();
videoSubWindow->setResource( resource_id );
printMessage( "Loading file...", CLP_LOG_INFO );
m_pcWindowHandle->addSubWindow( videoSubWindow );
videoSubWindow->show();
@@ -242,19 +269,17 @@ void MainWindow::loadFile( QString fileName, std::optional<CalypFileInfo> stream
updateZoomFactorSBox();
addStreamInfoToRecentList( videoSubWindow->getStreamInfo() );
m_lastOpenPath = QFileInfo( openedStreamInfo.m_cFilename ).path();
m_lastOpenWidth = openedStreamInfo.m_uiWidth;
m_lastOpenHeight = openedStreamInfo.m_uiHeight;
m_lastOpenBitPerPixel = openedStreamInfo.m_uiBitsPelPixel;
addStreamInfoToRecentList( std::move( openedStreamInfo ) );
printMessage( "File loaded", CLP_LOG_INFO );
m_cLastOpenPath = QFileInfo( fileName ).path();
}
else
{
videoSubWindow->close();
}
}
catch( CalypFailure& e )
{
videoSubWindow->close();
QString warningMsg =
"Cannot open file " + QFileInfo( fileName ).fileName() + " with the following error: \n" + e.what();
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
@@ -302,13 +327,12 @@ QStringList MainWindow::showFileDialog( bool bRead )
fileNameList.clear();
if( bRead )
{
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_lastOpenPath, filter.join( ";;" ) );
}
else
{
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_cLastOpenPath, filter.join( ";;" ) );
if( !fileName.isEmpty() )
fileNameList.append( fileName );
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_lastOpenPath, filter.join( ";;" ) );
if( !fileName.isEmpty() ) fileNameList.append( fileName );
}
return fileNameList;
}
@@ -341,18 +365,17 @@ void MainWindow::openRecent()
void MainWindow::saveFrame()
{
if( m_pcCurrentVideoSubWindow )
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
if( pcVideoSubWindow != nullptr )
{
VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow;
QStringList fileNameList = showFileDialog( false );
if( fileNameList.size() == 1 )
{
QString fileName = fileNameList[0];
m_cLastOpenPath = QFileInfo( fileName ).path();
m_lastOpenPath = QFileInfo( fileName ).path();
try
{
saveWindow->save( fileName );
pcVideoSubWindow->save( fileName );
}
catch( CalypFailure& e )
{
@@ -369,18 +392,17 @@ void MainWindow::saveFrame()
void MainWindow::saveStream()
{
if( m_pcCurrentVideoSubWindow )
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
if( pcVideoSubWindow != nullptr )
{
VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow;
QStringList fileNameList = showFileDialog( false );
if( fileNameList.size() == 1 )
{
QString fileName = fileNameList[0];
m_cLastOpenPath = QFileInfo( fileName ).path();
m_lastOpenPath = QFileInfo( fileName ).path();
try
{
saveWindow->save( fileName );
pcVideoSubWindow->save( fileName );
}
catch( CalypFailure& e )
{
@@ -397,14 +419,19 @@ void MainWindow::saveStream()
void MainWindow::format()
{
if( auto* pcVideoSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
if( pcVideoSubWindow )
{
try
{
if( pcVideoSubWindow->loadFile( pcVideoSubWindow->getCurrentFileName(), true ) )
{
addStreamInfoToRecentList( pcVideoSubWindow->getStreamInfo() );
}
auto resourceId = pcVideoSubWindow->getResourceId();
CalypFileInfo streamInfo;
m_appResourceHandle->executeResourceAction<VideostreamResource>( resourceId, [&streamInfo]( auto* resource ) {
streamInfo = resource->getStreamInfo();
return true;
} );
m_pcWindowHandle->removeSubWindow( pcVideoSubWindow );
loadFile( streamInfo.m_cFilename, streamInfo, true );
}
catch( CalypFailure& e )
{
@@ -413,19 +440,17 @@ void MainWindow::format()
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
printMessage( warningMsg, CLP_LOG_ERROR );
qDebug() << warningMsg;
m_pcCurrentSubWindow->close();
}
m_pcCurrentSubWindow = NULL;
updateMainWindow();
}
}
void MainWindow::reload()
{
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow<SubWindowAbstract>();
if( activeSubWindow != nullptr )
{
m_pcCurrentSubWindow->refreshSubWindow();
m_pcCurrentSubWindow = NULL;
activeSubWindow->refreshSubWindow();
updateMainWindow();
}
}
@@ -446,16 +471,16 @@ void MainWindow::reloadAll()
subWindowList.at( i )->refreshSubWindow();
}
}
m_pcCurrentSubWindow = NULL;
updateMainWindow();
}
void MainWindow::loadAll()
{
if( auto* pcVideoSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
if( activeSubWindow != nullptr )
{
printMessage( "Loading file into memory...", CLP_LOG_INFO );
pcVideoSubWindow->loadAll();
activeSubWindow->loadAll();
printMessage( "File loaded", CLP_LOG_INFO );
}
}
@@ -464,40 +489,45 @@ void MainWindow::loadAll()
void MainWindow::normalSize()
{
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
if( activeSubWindow != nullptr )
{
m_pcCurrentSubWindow->normalSize();
activeSubWindow->normalSize();
updateZoomFactorSBox();
}
}
void MainWindow::zoomToFit()
{
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
if( activeSubWindow != nullptr )
{
m_pcCurrentSubWindow->zoomToFit();
activeSubWindow->zoomToFit();
updateZoomFactorSBox();
}
}
void MainWindow::zoomToFitAll()
{
VideoSubWindow* videoSubWindow;
QList<SubWindowAbstract*> subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
auto* videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
videoSubWindow->zoomToFit();
}
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
if( activeSubWindow != nullptr )
{
updateZoomFactorSBox();
}
}
void MainWindow::scaleFrame( int ratio )
{
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
if( activeSubWindow != nullptr )
{
m_pcCurrentSubWindow->scaleView( (double)( ratio ) / 100.0 );
activeSubWindow->scaleView( (double)( ratio ) / 100.0 );
updateZoomFactorSBox();
}
}
@@ -514,10 +544,10 @@ void MainWindow::zoomFromSBox( double zoom )
void MainWindow::updateZoomFactorSBox()
{
double factor;
if( m_pcCurrentSubWindow )
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
if( activeSubWindow != nullptr )
{
factor = m_pcCurrentSubWindow->getScaleFactor();
auto factor = activeSubWindow->getScaleFactor();
m_pcZoomFactorSBox->setValue( factor * 100 );
}
}
@@ -538,7 +568,7 @@ void MainWindow::dropEvent( QDropEvent* event )
if( urlList.size() == 1 )
{
QString fileName = urlList.at( 0 ).toLocalFile();
m_cLastOpenPath = QFileInfo( fileName ).path();
m_lastOpenPath = QFileInfo( fileName ).path();
loadFile( fileName );
}
}
@@ -553,8 +583,7 @@ VideoStreamSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandl
for( int i = 0; i < subWindowList.size(); i++ )
{
auto* pcSubWindow = qobject_cast<VideoStreamSubWindow*>( subWindowList.at( i ) );
if( pcSubWindow->getCurrentFileName() == canonicalFilePath )
return pcSubWindow;
if( pcSubWindow->getCurrentFileName() == canonicalFilePath ) return pcSubWindow;
}
return nullptr;
}
@@ -563,34 +592,24 @@ VideoStreamSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandl
void MainWindow::updateMainWindow()
{
SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow();
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
auto* activeVideoSubWindow = qobject_cast<VideoSubWindow*>( activeSubWindow );
QCoreApplication::processEvents();
// if( activeSubWindow() != m_pcCurrentSubWindow )
{
m_pcCurrentSubWindow = NULL;
m_pcCurrentVideoSubWindow = NULL;
if( activeSubWindow )
{
m_pcCurrentSubWindow = activeSubWindow;
if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_SUBWINDOW )
if( activeVideoSubWindow != nullptr &&
!m_pcWindowHandle->findSubWindow( activeVideoSubWindow->getRefSubWindow() ) )
{
m_pcCurrentVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcCurrentSubWindow );
}
if( m_pcCurrentVideoSubWindow )
{
if( !m_pcWindowHandle->findSubWindow( m_pcCurrentVideoSubWindow->getRefSubWindow() ) )
{
m_pcCurrentVideoSubWindow->setRefSubWindow( NULL );
}
activeVideoSubWindow->setRefSubWindow( nullptr );
}
updateZoomFactorSBox();
}
}
//! Check this - these two function should swap order
m_appModuleQuality->update( m_pcCurrentVideoSubWindow );
m_appModuleVideo->update( m_pcCurrentVideoSubWindow );
m_appModuleQuality->update( activeVideoSubWindow );
m_appModuleVideo->update( activeVideoSubWindow );
updateMenus();
}
@@ -617,14 +636,11 @@ void MainWindow::updateMenus()
bool hasVideoStreamSubWindow{ false };
bool supportsFormat{ false };
if( m_pcCurrentSubWindow && m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
if( pcVideoSubWindow != nullptr && pcVideoSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
{
hasVideoStreamSubWindow = true;
if( auto* pcVideoSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
{
supportsFormat = pcVideoSubWindow->supportsFormatConfiguration();
}
supportsFormat = pcVideoSubWindow->supportsFormatConfiguration();
}
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
@@ -690,19 +706,19 @@ void MainWindow::createActions()
m_arrayActions[FORMAT_ACT] = new QAction( tr( "&Format" ), this );
m_arrayActions[FORMAT_ACT]->setIcon( QIcon::fromTheme( "transform-scale" ) );
m_arrayActions[FORMAT_ACT]->setShortcut( Qt::CTRL + Qt::Key_F );
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]->setShortcut( Qt::CTRL | Qt::Key_R );
m_arrayActions[RELOAD_ACT]->setShortcut( Qt::Key_F5 );
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_ALL_ACT]->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_R );
m_arrayActions[RELOAD_ALL_ACT]->setShortcut( Qt::CTRL | Qt::SHIFT | Qt::Key_R );
m_arrayActions[RELOAD_ALL_ACT]->setStatusTip( tr( "Reload all sequences" ) );
connect( m_arrayActions[RELOAD_ALL_ACT], SIGNAL( triggered() ), this, SLOT( reloadAll() ) );
@@ -725,22 +741,17 @@ void MainWindow::createActions()
connect( m_arrayActions[EXIT_ACT], SIGNAL( triggered() ), qApp, SLOT( closeAllWindows() ) );
// ------------ View ------------
mapperZoom = new QSignalMapper( this );
connect( mapperZoom, SIGNAL( mapped( int ) ), this, SLOT( scaleFrame( int ) ) );
m_arrayActions[ZOOM_IN_ACT] = new QAction( tr( "Zoom &In (+25%)" ), this );
m_arrayActions[ZOOM_IN_ACT]->setIcon( QIcon::fromTheme( "zoom-in" ) );
m_arrayActions[ZOOM_IN_ACT]->setShortcut( tr( "Ctrl++" ) );
m_arrayActions[ZOOM_IN_ACT]->setStatusTip( tr( "Scale the image up by 25%" ) );
connect( m_arrayActions[ZOOM_IN_ACT], SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
mapperZoom->setMapping( m_arrayActions[ZOOM_IN_ACT], 125 );
connect( m_arrayActions[ZOOM_IN_ACT], &QAction::triggered, [this] { scaleFrame( 125 ); } );
m_arrayActions[ZOOM_OUT_ACT] = new QAction( tr( "Zoom &Out (-25%)" ), this );
m_arrayActions[ZOOM_OUT_ACT]->setIcon( QIcon::fromTheme( "zoom-out" ) );
m_arrayActions[ZOOM_OUT_ACT]->setShortcut( tr( "Ctrl+-" ) );
m_arrayActions[ZOOM_OUT_ACT]->setStatusTip( tr( "Scale the image down by 25%" ) );
connect( m_arrayActions[ZOOM_OUT_ACT], SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
mapperZoom->setMapping( m_arrayActions[ZOOM_OUT_ACT], 80 );
connect( m_arrayActions[ZOOM_OUT_ACT], &QAction::triggered, [this] { scaleFrame( 80 ); } );
m_arrayActions[ZOOM_NORMAL_ACT] = new QAction( tr( "&Normal Size" ), this );
m_arrayActions[ZOOM_NORMAL_ACT]->setIcon( QIcon::fromTheme( "zoom-original" ) );
@@ -846,19 +857,17 @@ void MainWindow::createMenus()
void MainWindow::createToolBars()
{
m_arrayToolBars.resize( TOTAL_TOOLBAR );
auto* fileToolbar = addToolBar( tr( "File" ) );
fileToolbar->addAction( m_arrayActions[OPEN_ACT] );
fileToolbar->addAction( m_arrayActions[SAVE_ACT] );
fileToolbar->addAction( m_arrayActions[FORMAT_ACT] );
fileToolbar->addAction( m_arrayActions[RELOAD_ACT] );
fileToolbar->addAction( m_arrayActions[CLOSE_ACT] );
fileToolbar->setMovable( false );
addToolBar( Qt::TopToolBarArea, fileToolbar );
m_arrayToolBars[FILE_TOOLBAR] = new QToolBar( tr( "File" ) );
m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[OPEN_ACT] );
m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[SAVE_ACT] );
m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[FORMAT_ACT] );
m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[RELOAD_ACT] );
m_arrayToolBars[FILE_TOOLBAR]->addAction( m_arrayActions[CLOSE_ACT] );
auto* viewToolBar = addToolBar( tr( "View" ) );
m_arrayToolBars[FILE_TOOLBAR]->setMovable( false );
addToolBar( Qt::TopToolBarArea, m_arrayToolBars[FILE_TOOLBAR] );
m_arrayToolBars[VIEW_TOOLBAR] = new QToolBar( tr( "View" ) );
m_pcZoomFactorSBox = new QDoubleSpinBox;
m_pcZoomFactorSBox->setRange( 1.0, 10000.0 );
m_pcZoomFactorSBox->setDecimals( 0 );
@@ -866,14 +875,15 @@ void MainWindow::createToolBars()
m_pcZoomFactorSBox->setValue( 100.0 );
m_pcZoomFactorSBox->setSuffix( "%" );
connect( m_pcZoomFactorSBox, SIGNAL( valueChanged( double ) ), this, SLOT( zoomFromSBox( double ) ) );
m_arrayToolBars[VIEW_TOOLBAR]->addWidget( m_pcZoomFactorSBox );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_IN_ACT] );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_OUT_ACT] );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_NORMAL_ACT] );
m_arrayToolBars[VIEW_TOOLBAR]->addAction( m_arrayActions[ZOOM_FIT_ACT] );
m_arrayToolBars[FILE_TOOLBAR]->setMovable( false );
addToolBar( Qt::TopToolBarArea, m_arrayToolBars[VIEW_TOOLBAR] );
viewToolBar->addWidget( m_pcZoomFactorSBox );
viewToolBar->addAction( m_arrayActions[ZOOM_IN_ACT] );
viewToolBar->addAction( m_arrayActions[ZOOM_OUT_ACT] );
viewToolBar->addAction( m_arrayActions[ZOOM_NORMAL_ACT] );
viewToolBar->addAction( m_arrayActions[ZOOM_FIT_ACT] );
viewToolBar->setMovable( false );
addToolBar( Qt::TopToolBarArea, viewToolBar );
addToolBar( Qt::TopToolBarArea, m_appModuleVideo->createToolBar() );
}
@@ -896,12 +906,17 @@ void MainWindow::createStatusBar()
void MainWindow::addStreamInfoToRecentList( CalypFileInfo streamInfo )
{
int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, streamInfo.m_cFilename );
if( idx >= 0 )
m_aRecentFileStreamInfo.remove( idx );
if( idx >= 0 ) m_aRecentFileStreamInfo.remove( idx );
m_aRecentFileStreamInfo.prepend( streamInfo );
while( m_aRecentFileStreamInfo.size() > MAX_RECENT_FILES )
{
m_aRecentFileStreamInfo.remove( m_aRecentFileStreamInfo.size() - 1 );
}
updateRecentFileActions();
QSettings appSettings;
QVariant var;
var.setValue( m_aRecentFileStreamInfo );
appSettings.setValue( "MainWindow/RecentFileList", var );
}
void MainWindow::updateRecentFileActions()
@@ -941,6 +956,7 @@ void MainWindow::checkRecentFileActions()
else
{
unsigned long long int fileSize = QFileInfo( m_aRecentFileStreamInfo.at( i ).m_cFilename ).size();
std::cout << m_aRecentFileStreamInfo.at( i ).m_uiFileSize << std::endl;
if( m_aRecentFileStreamInfo.at( i ).m_uiFileSize != fileSize )
{
m_aRecentFileStreamInfo.remove( i );
@@ -960,7 +976,10 @@ void MainWindow::readSettings()
move( pos );
resize( size );
m_cLastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString();
m_lastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString();
m_lastOpenWidth = appSettings.value( "MainWindow/LastWidth" ).value<unsigned int>();
m_lastOpenHeight = appSettings.value( "MainWindow/LastHeight" ).value<unsigned int>();
m_lastOpenBitPerPixel = appSettings.value( "MainWindow/LastBitsPerPixel" ).value<unsigned int>();
QVariant value = appSettings.value( "MainWindow/RecentFileList" );
m_aRecentFileStreamInfo = value.value<CalypFileInfoVector>();
@@ -979,10 +998,13 @@ void MainWindow::writeSettings()
appSettings.setValue( "MainWindow/Position", pos() );
appSettings.setValue( "MainWindow/Size", size() );
appSettings.setValue( "MainWindow/LastOpenPath", m_cLastOpenPath );
appSettings.setValue( "MainWindow/LastOpenPath", m_lastOpenPath );
appSettings.setValue( "MainWindow/LastWidth", m_lastOpenWidth );
appSettings.setValue( "MainWindow/LastHeight", m_lastOpenHeight );
appSettings.setValue( "MainWindow/LastBitsPerPixel", m_lastOpenBitPerPixel );
QVariant var;
var.setValue<CalypFileInfoVector>( m_aRecentFileStreamInfo );
var.setValue( m_aRecentFileStreamInfo );
appSettings.setValue( "MainWindow/RecentFileList", var );
m_appModuleVideo->writeSettings();
+10 -19
View File
@@ -49,6 +49,7 @@
#include "DBusAppAdaptor.h"
#endif
#include "ResourceHandle.h"
#include "VideostreamResource.h"
class QCloseEvent;
class QDragEnterEvent;
@@ -77,8 +78,8 @@ class MainWindow : public QMainWindow
public:
MainWindow();
bool parseArgs( int argc, char* argv[] );
void loadFile( CalypFileInfo pStreamInfo );
void loadFile( QString fileName, std::optional<CalypFileInfo> pStreamInfo = {} );
void loadFile( const CalypFileInfo& pStreamInfo );
void loadFile( const QString& fileName, std::optional<CalypFileInfo> streamInfoOpt = {}, bool forceDialog = false );
public Q_SLOTS:
void printMessage( const QString& msg );
@@ -128,10 +129,13 @@ private:
/**
* Save the current subwindow for every category
*/
SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set
VideoSubWindow* m_pcCurrentVideoSubWindow;
// SubWindowAbstract* m_pcCurrentSubWindow; //!< General always set
// VideoSubWindow* m_pcCurrentVideoSubWindow;
QString m_cLastOpenPath;
QString m_lastOpenPath;
unsigned int m_lastOpenWidth;
unsigned int m_lastOpenHeight;
unsigned int m_lastOpenBitPerPixel;
QStringList showFileDialog( bool bRead );
static VideoStreamSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager,
@@ -154,7 +158,6 @@ private:
QDoubleSpinBox* m_pcZoomFactorSBox;
QSignalMapper* mapperZoom;
QSignalMapper* mapperWindow;
/**
@@ -199,18 +202,6 @@ private:
};
QVector<QDockWidget*> m_arraySideBars;
/**
* Array of tool bars for the main app
*/
enum TOOLBAR_LIST
{
FILE_TOOLBAR = 0,
VIEW_TOOLBAR,
VIDEO_TOOLBAR,
TOTAL_TOOLBAR,
};
QVector<QToolBar*> m_arrayToolBars;
/**
* Array of actions for the main app
*/
@@ -243,7 +234,7 @@ private:
QVector<QAction*> m_arrayRecentFilesActions;
CalypFileInfoVector m_aRecentFileStreamInfo;
AboutDialog* m_pcAboutDialog;
AboutDialog* m_pcAboutDialog{ nullptr };
};
#endif // __MAINWINDOW_H__
+98 -38
View File
@@ -30,21 +30,31 @@
#include <QFileInfo>
#include <QMutex>
#include <QThread>
#include <chrono>
#include <iostream>
#include <memory>
#include <optional>
ResourceWorker::ResourceWorker( std::shared_ptr<CalypStream> stream )
: m_pcStream{ stream }
auto get_new_resource_id() -> std::size_t
{
static std::size_t unique_id{ 0 };
return unique_id++;
}
ResourceWorker::~ResourceWorker()
{
stop();
}
void ResourceWorker::stop()
{
while( m_bStarting )
{
}
m_bStop = true;
wake();
wait();
if( m_bStarted )
{
wake();
wait();
}
m_bStarted = false;
}
void ResourceWorker::wake()
@@ -54,39 +64,85 @@ void ResourceWorker::wake()
m_Mutex.unlock();
}
void ResourceWorker::start()
{
m_bStarting = true;
QThread::start();
}
void ResourceWorker::run()
{
m_bStop = false;
m_bStarted = true;
m_bStarting = false;
// Loop forever
while( !m_bStop )
for( ;; )
{
// auto start = std::chrono::steady_clock::now();
m_pcStream->readNextFrameFillRGBBuffer();
// auto end = std::chrono::steady_clock::now();
// std::cout << "Elapsed time reading and processing a frame: "
// << std::chrono::duration_cast<std::chrono::milliseconds>( end - start ).count()
// << " ms" << std::endl;
while( !m_bStop && !m_pcStream->hasWritingSlot() )
while( !m_bStop && !m_resource->isReady() )
{
// Wait here
m_Mutex.lock();
m_ResourceIdle.wait( &m_Mutex );
m_Mutex.unlock();
}
// auto start = std::chrono::steady_clock::now();
if( m_bStop || !m_resource->iteration() )
{
break;
}
// auto end = std::chrono::steady_clock::now();
// std::cout << "Elapsed time reading and processing a frame: "
// << std::chrono::duration_cast<std::chrono::milliseconds>( end - start ).count()
// << " ms" << std::endl;
}
m_bStarted = false;
m_bStop = false;
}
ResourceHandle::ResourceHandle()
class OldStreamResource : public CalypResource
{
}
public:
OldStreamResource() = default;
CalypStream m_stream;
auto getResourceName() -> std::string override { return m_stream.getFileName(); };
auto getResource() -> CalypStream* override { return &m_stream; };
auto iteration() -> bool override
{
if( m_stream.getFrameNum() < 2 )
{
return false;
}
m_stream.readNextFrameFillRGBBuffer();
return true;
}
auto isReady() -> bool override { return m_stream.hasWritingSlot(); }
};
ResourceHandle::ResourceHandle() : m_thread{ std::make_unique<QThread>() }
{
moveToThread( m_thread.get() );
m_thread->start();
};
ResourceHandle::~ResourceHandle()
{
QMetaObject::invokeMethod( this, "cleanup" );
m_thread->wait();
};
void ResourceHandle::cleanup()
{
m_thread->quit();
};
auto ResourceHandle::addResource() -> std::size_t
{
auto resource_id = unique_id;
unique_id++;
auto newStreamResource = std::make_shared<CalypStream>();
auto resource_id = get_new_resource_id();
;
auto newStreamResource = std::make_shared<OldStreamResource>();
auto newStreamResourceWorker = std::make_unique<ResourceWorker>( newStreamResource );
m_apcStreamResourcesList[resource_id] = newStreamResource;
m_apcStreamResourcesWorkersList[resource_id] = std::move( newStreamResourceWorker );
@@ -99,8 +155,10 @@ auto ResourceHandle::getResource( CalypStream* ptr ) -> std::size_t
{
for( std::size_t i = 0; i < m_apcStreamResourcesList.size(); i++ )
{
if( m_apcStreamResourcesList[i].get() == ptr )
return i;
if( auto* resource = dynamic_cast<OldStreamResource*>( m_apcStreamResourcesList[i].get() ) )
{
if( &resource->m_stream == ptr ) return i;
}
}
}
return addResource();
@@ -108,16 +166,22 @@ auto ResourceHandle::getResource( CalypStream* ptr ) -> std::size_t
auto ResourceHandle::getResourceAsset( std::size_t id ) -> CalypStream*
{
if( m_apcStreamResourcesWorkersList.count( id ) )
{
return m_apcStreamResourcesList[id].get();
}
return nullptr;
if( !m_apcStreamResourcesWorkersList.contains( id ) ) return nullptr;
return m_apcStreamResourcesList[id]->getResource();
}
auto ResourceHandle::appendResource( std::unique_ptr<CalypResource>&& resource ) -> std::size_t
{
auto resource_id = get_new_resource_id();
m_apcStreamResourcesList[resource_id] = std::move( resource );
m_apcStreamResourcesWorkersList[resource_id] =
std::make_unique<ResourceWorker>( m_apcStreamResourcesList[resource_id] );
return resource_id;
}
void ResourceHandle::removeResource( std::size_t id )
{
if( !m_apcStreamResourcesWorkersList.count( id ) )
if( !m_apcStreamResourcesList.contains( id ) )
{
assert( false );
return;
@@ -133,7 +197,7 @@ void ResourceHandle::removeResource( std::size_t id )
void ResourceHandle::stopResourceWorker( std::size_t id )
{
if( !m_apcStreamResourcesWorkersList.count( id ) )
if( !m_apcStreamResourcesWorkersList.contains( id ) )
{
assert( false );
return;
@@ -143,27 +207,23 @@ void ResourceHandle::stopResourceWorker( std::size_t id )
void ResourceHandle::startResourceWorker( std::size_t id )
{
if( !m_apcStreamResourcesWorkersList.count( id ) )
if( !m_apcStreamResourcesWorkersList.contains( id ) )
{
assert( false );
return;
}
if( m_apcStreamResourcesList[id]->getFrameNum() < 2 )
{
return; // No work to be done!
}
m_apcStreamResourcesWorkersList[id]->setObjectName(
"RW-" +
QFileInfo( QString::fromStdString( m_apcStreamResourcesList[id]->getFileName() ) ).completeBaseName() );
QFileInfo( QString::fromStdString( m_apcStreamResourcesList[id]->getResourceName() ) ).completeBaseName() );
m_apcStreamResourcesWorkersList[id]->start();
}
void ResourceHandle::wakeResourceWorker( std::size_t id )
{
if( !m_apcStreamResourcesWorkersList.count( id ) )
if( !m_apcStreamResourcesWorkersList.contains( id ) )
{
assert( false );
return;
}
m_apcStreamResourcesWorkersList[id]->wake();
}
}
+49 -9
View File
@@ -26,12 +26,13 @@
#define __RESOURCEHANDLE_H__
#include <QMutex>
#include <QMutexLocker>
#include <QThread>
#include <QVector>
#include <QWaitCondition>
#include <atomic>
#include "CommonDefs.h"
#include "CalypResource.h"
#include "lib/CalypStream.h"
class ResourceWorker : public QThread
@@ -39,35 +40,74 @@ class ResourceWorker : public QThread
private:
QMutex m_Mutex;
QWaitCondition m_ResourceIdle;
std::shared_ptr<CalypStream> m_pcStream;
std::shared_ptr<CalypResource> m_resource;
std::atomic<bool> m_bStop{ false };
std::atomic<bool> m_bStarted{ false };
std::atomic<bool> m_bStarting{ false };
public:
ResourceWorker( std::shared_ptr<CalypStream> stream );
explicit ResourceWorker( std::shared_ptr<CalypResource> resource ) : m_resource{ std::move( resource ) } {}
ResourceWorker( ResourceWorker&& other ) noexcept = delete;
ResourceWorker( const ResourceWorker& other ) = delete;
auto operator=( ResourceWorker&& other ) noexcept -> ResourceWorker& = delete;
auto operator=( const ResourceWorker& other ) -> ResourceWorker& = delete;
~ResourceWorker() override;
void stop();
void wake();
void run();
void start();
void run() override;
auto mutex() -> QMutex* { return &m_Mutex; }
};
class ResourceHandle
class ResourceWorker;
class ResourceHandle : public QObject
{
Q_OBJECT
public:
ResourceHandle();
~ResourceHandle() = default;
ResourceHandle( ResourceHandle&& other ) noexcept = delete;
ResourceHandle( const ResourceHandle& other ) = delete;
auto operator=( ResourceHandle&& other ) noexcept -> ResourceHandle& = delete;
auto operator=( const ResourceHandle& other ) -> ResourceHandle& = delete;
~ResourceHandle() override;
auto getResource( CalypStream* ptr ) -> std::size_t;
auto getResourceAsset( std::size_t id ) -> CalypStream*;
auto appendResource( std::unique_ptr<CalypResource>&& resource ) -> std::size_t;
void removeResource( std::size_t id );
void stopResourceWorker( std::size_t id );
void startResourceWorker( std::size_t id );
void wakeResourceWorker( std::size_t id );
template <typename T>
auto executeResourceAction( std::size_t id, const std::function<bool( T* )>& action ) -> bool
{
static_assert( std::is_base_of<CalypResource, T>::value, "T must inherit from CalypResource" );
if( !m_apcStreamResourcesList.contains( id ) )
{
assert( false );
return false;
}
bool result{ false };
if( auto* resource = dynamic_cast<T*>( m_apcStreamResourcesList[id].get() ) )
{
QMutexLocker locker( m_apcStreamResourcesWorkersList[id]->mutex() );
result = action( resource );
}
m_apcStreamResourcesWorkersList[id]->wake();
return result;
}
void cleanup();
private:
auto addResource() -> std::size_t;
private:
std::size_t unique_id{ 0 };
std::map<std::size_t, std::shared_ptr<CalypStream>> m_apcStreamResourcesList;
private: // NOLINT
std::unique_ptr<QThread> m_thread;
std::map<std::size_t, std::shared_ptr<CalypResource>> m_apcStreamResourcesList;
std::map<std::size_t, std::unique_ptr<ResourceWorker>> m_apcStreamResourcesWorkersList;
};
-1
View File
@@ -28,7 +28,6 @@
#include <QAction>
#include <QActionGroup>
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QHBoxLayout>
#include <QMdiArea>
+60 -46
View File
@@ -32,6 +32,7 @@
#include <QTimer>
#include <QToolBar>
#include <QtGui>
#include <limits>
#include <memory>
#include "FrameNumberWidget.h"
@@ -45,15 +46,13 @@
#include "lib/CalypFrame.h"
VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager )
: m_pcParent( parent ), m_pcMainWindowManager( windowManager )
: m_pcParent{ parent }
, m_pcMainWindowManager{ windowManager }
, m_pcPlayingTimer{ new QTimer{ this } }
, m_pcFrameRateFeedbackTimer{ std::make_unique<QElapsedTimer>() }
{
m_pcCurrentVideoSubWindow = NULL;
m_bIsPlaying = false;
m_pcPlayingTimer = new QTimer( this );
m_pcFrameRateFeedbackTimer = std::make_unique<QElapsedTimer>();
m_pcPlayingTimer->setTimerType( Qt::PreciseTimer );
connect( m_pcPlayingTimer, &QTimer::timeout,
this, &VideoHandle::playEvent );
connect( m_pcPlayingTimer, &QTimer::timeout, this, &VideoHandle::playEvent );
m_acPlayingSubWindows.clear();
}
@@ -61,6 +60,10 @@ VideoHandle::~VideoHandle() = default;
void VideoHandle::createActions()
{
if( m_pcParent == nullptr )
{
return;
}
m_arrayActions.resize( TOTAL_ACT );
m_arrayActions[PLAY_ACT] = new QAction( "Play", this );
m_arrayActions[PLAY_ACT]->setStatusTip( "Play/Pause" );
@@ -153,7 +156,7 @@ void VideoHandle::createActions()
m_arrayActions[NAVIGATION_TOOL_ACT] = new QAction( tr( "Navigation Tool" ), this );
m_arrayActions[NAVIGATION_TOOL_ACT]->setCheckable( true );
m_arrayActions[NAVIGATION_TOOL_ACT]->setChecked( true );
m_arrayActions[NAVIGATION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_1 );
m_arrayActions[NAVIGATION_TOOL_ACT]->setShortcut( Qt::CTRL | Qt::Key_1 );
m_actionGroupTools->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] );
connect( m_arrayActions[NAVIGATION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) );
m_mapperTools->setMapping( m_arrayActions[NAVIGATION_TOOL_ACT], ViewArea::NavigationView );
@@ -161,7 +164,7 @@ void VideoHandle::createActions()
m_arrayActions[SELECTION_TOOL_ACT] = new QAction( "Selection Tool", this );
m_arrayActions[SELECTION_TOOL_ACT]->setCheckable( true );
m_arrayActions[SELECTION_TOOL_ACT]->setChecked( false );
m_arrayActions[SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_2 );
m_arrayActions[SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL | Qt::Key_2 );
m_actionGroupTools->addAction( m_arrayActions[SELECTION_TOOL_ACT] );
connect( m_arrayActions[SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) );
m_mapperTools->setMapping( m_arrayActions[SELECTION_TOOL_ACT], ViewArea::NormalSelectionView );
@@ -169,7 +172,7 @@ void VideoHandle::createActions()
m_arrayActions[BLOCK_SELECTION_TOOL_ACT] = new QAction( "Block Selection Tool", this );
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setCheckable( true );
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setChecked( false );
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL + Qt::Key_3 );
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setShortcut( Qt::CTRL | Qt::Key_3 );
m_actionGroupTools->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] );
connect( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], SIGNAL( triggered() ), m_mapperTools, SLOT( map() ) );
m_mapperTools->setMapping( m_arrayActions[BLOCK_SELECTION_TOOL_ACT], ViewArea::BlockSelectionView );
@@ -199,6 +202,10 @@ void VideoHandle::createActions()
QMenu* VideoHandle::createVideoMenu()
{
if( m_pcParent == nullptr )
{
return nullptr;
}
m_pcMenuVideo = new QMenu( "Video", m_pcParent );
m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] );
m_pcMenuVideo->addAction( m_arrayActions[STOP_ACT] );
@@ -214,6 +221,10 @@ QMenu* VideoHandle::createVideoMenu()
QMenu* VideoHandle::createImageMenu()
{
if( m_pcParent == nullptr )
{
return nullptr;
}
m_pcMenuImage = new QMenu( "Image", m_pcParent );
m_menuComponent = m_pcMenuImage->addMenu( "Component" );
m_menuComponent->addActions( m_actionGroupComponent->actions() );
@@ -227,14 +238,16 @@ QMenu* VideoHandle::createImageMenu()
return m_pcMenuImage;
}
QToolBar* VideoHandle::createToolBar()
auto VideoHandle::createToolBar() -> QPointer<QToolBar>
{
m_toolbarVideo = new QToolBar( tr( "Video" ) );
if( m_pcParent == nullptr ) return nullptr;
QPointer m_toolbarVideo = new QToolBar( tr( "Video" ) );
m_toolbarVideo->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea );
m_toolbarVideo->addAction( m_arrayActions[PLAY_ACT] );
m_toolbarVideo->addAction( m_arrayActions[STOP_ACT] );
QLabel* pcLockLabel = new QLabel( "PlayingLock" );
QPointer pcLockLabel = new QLabel( "PlayingLock" );
pcLockLabel->setAlignment( Qt::AlignCenter );
m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel );
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
@@ -243,6 +256,7 @@ QToolBar* VideoHandle::createToolBar()
m_toolbarVideo->addWidget( m_pcFrameSlider );
m_toolbarVideo->addAction( m_arrayActions[VIDEO_FORWARD_ACT] );
m_toolbarVideo->addWidget( new QLabel );
m_pcFrameNumInfo = new FrameNumberWidget;
m_toolbarVideo->addWidget( m_pcFrameNumInfo );
@@ -251,6 +265,10 @@ QToolBar* VideoHandle::createToolBar()
QDockWidget* VideoHandle::createDock()
{
if( m_pcParent == nullptr )
{
return nullptr;
}
m_pcFramePropertiesSideBar = new FramePropertiesDock( m_pcParent, &m_bIsPlaying );
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), m_pcParent );
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
@@ -262,6 +280,10 @@ QDockWidget* VideoHandle::createDock()
QWidget* VideoHandle::createStatusBarMessage()
{
if( m_pcParent == nullptr )
{
return nullptr;
}
QWidget* pcStatusBarWidget = new QWidget;
QHBoxLayout* mainlayout = new QHBoxLayout;
@@ -384,8 +406,7 @@ void VideoHandle::readSettings()
QSettings appSettings;
m_arrayActions[VIDEO_REPEAT_ACT]->setChecked( appSettings.value( "VideoHandle/Repeat", false ).toBool() );
m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->setChecked( appSettings.value( "VideoHandle/VideoZoomLock", false ).toBool() );
if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() )
m_pcFramePropertiesDock->close();
if( !appSettings.value( "VideoHandle/FrameProperties", true ).toBool() ) m_pcFramePropertiesDock->close();
m_uiViewTool = appSettings.value( "VideoHandle/SelectedTool", ViewArea::NavigationView ).toUInt();
setTool( m_uiViewTool );
@@ -507,14 +528,11 @@ void VideoHandle::addSubWindow( VideoSubWindow* window )
window->getViewArea()->setTool( m_uiViewTool );
window->getViewArea()->setGridVisible( m_arrayActions[SHOW_GRID_ACT]->isChecked() );
connect( window, &SubWindowAbstract::aboutToClose,
this, &VideoHandle::closeSubWindow );
connect( window, &SubWindowAbstract::aboutToClose, this, &VideoHandle::closeSubWindow );
connect( window, &SubWindowAbstract::zoomFactorChanged,
this, &VideoHandle::zoomToFactorAll );
connect( window, &SubWindowAbstract::zoomFactorChanged, this, &VideoHandle::zoomToFactorAll );
connect( window, &SubWindowAbstract::scrollBarMoved,
this, &VideoHandle::moveAllScrollBars );
connect( window, &SubWindowAbstract::scrollBarMoved, this, &VideoHandle::moveAllScrollBars );
connect( window->getViewArea(), SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectionArea( QRect ) ) );
}
@@ -540,18 +558,15 @@ void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow )
void VideoHandle::zoomToFactorAll( const double scale, const QPoint center )
{
double factor;
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() )
{
factor = m_pcCurrentVideoSubWindow->getScaleFactor();
double factor = m_pcCurrentVideoSubWindow->getScaleFactor();
SubWindowAbstract* subWindow;
QList<SubWindowAbstract*> subWindowList =
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( int i = 0; i < subWindowList.size(); i++ )
{
subWindow = subWindowList.at( i );
SubWindowAbstract* subWindow = subWindowList.at( i );
if( m_pcCurrentVideoSubWindow == subWindow )
continue;
else
@@ -605,12 +620,12 @@ void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa
{
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() && m_pcCurrentVideoSubWindow )
{
VideoSubWindow* videoSubWindow;
QList<SubWindowAbstract*> subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
QList<SubWindowAbstract*> subWindowList =
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
for( int i = 0; i < subWindowList.size(); i++ )
{
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
VideoSubWindow* videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
if( m_pcCurrentVideoSubWindow == videoSubWindow )
continue;
else
@@ -624,17 +639,15 @@ void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa
unsigned long VideoHandle::getMaxFrameNumber()
{
unsigned long currFrames;
unsigned long maxFrames = INT_MAX;
std::uint64_t maxFrames = std::numeric_limits<std::uint64_t>::max();
if( m_pcCurrentVideoSubWindow )
{
if( m_acPlayingSubWindows.contains( qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) ) )
{
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
{
currFrames = m_acPlayingSubWindows.at( i )->getFrameNum();
if( currFrames < maxFrames )
maxFrames = currFrames;
auto currFrames = m_acPlayingSubWindows.at( i )->getFrameNum();
if( currFrames < maxFrames ) maxFrames = currFrames;
}
}
else
@@ -685,8 +698,7 @@ void VideoHandle::play()
{
auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow );
if( videoStreamSubWindow == nullptr )
return;
if( videoStreamSubWindow == nullptr ) return;
if( !videoStreamSubWindow->isPlaying() ) // Not playing
{
@@ -751,9 +763,13 @@ void VideoHandle::stop()
void VideoHandle::calculateRealFrameRate()
{
double average_time_between_frames_ms = m_uiNumberPlayedFrames > 0 ? 1000.0 / m_uiRealAverageFrameRate : 0;
double time_elapsed_since_last_frame_ms = m_pcFrameRateFeedbackTimer->elapsed();
average_time_between_frames_ms = double( average_time_between_frames_ms * m_uiNumberPlayedFrames + time_elapsed_since_last_frame_ms ) / double( m_uiNumberPlayedFrames + 1 );
m_uiRealAverageFrameRate = 1000.0 / average_time_between_frames_ms;
auto time_elapsed_since_last_frame_ms = static_cast<double>( m_pcFrameRateFeedbackTimer->elapsed() );
average_time_between_frames_ms =
double( average_time_between_frames_ms * m_uiNumberPlayedFrames + time_elapsed_since_last_frame_ms ) /
double( m_uiNumberPlayedFrames + 1 );
m_uiRealAverageFrameRate =
std::round<unsigned int>( static_cast<unsigned int>( 1000.0 / average_time_between_frames_ms ) );
m_uiNumberPlayedFrames++;
m_pcFrameRateFeedbackTimer->restart();
}
@@ -796,14 +812,14 @@ void VideoHandle::playEvent()
}
catch( const char* msg )
{
QString warningMsg = "Error while playing " + m_pcCurrentVideoSubWindow->getWindowName() + " with the following error: \n" + msg;
QString warningMsg =
"Error while playing " + m_pcCurrentVideoSubWindow->getWindowName() + " with the following error: \n" + msg;
QMessageBox::warning( m_pcParent, QApplication::applicationName(), warningMsg );
qDebug() << warningMsg;
stop();
m_pcCurrentVideoSubWindow->close();
}
if( bShouldRefreshUI )
emit changed();
if( bShouldRefreshUI ) emit changed();
// auto end = std::chrono::steady_clock::now();
// std::cout << "Elapsed time going to next frame: "
@@ -861,8 +877,7 @@ void VideoHandle::seekVideo()
void VideoHandle::seekSliderEvent( int new_frame_num )
{
// TODO: Fix this slot
if( m_bIsPlaying )
return;
if( m_bIsPlaying ) return;
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
{
@@ -943,8 +958,7 @@ void VideoHandle::videoSelectionButtonEvent()
void VideoHandle::setComponent( int component )
{
if( m_pcCurrentVideoSubWindow == nullptr )
return;
if( m_pcCurrentVideoSubWindow == nullptr ) return;
if( component < 0 )
{
m_pcCurrentVideoSubWindow->getViewArea()->clearFilteredChannel();
+4 -4
View File
@@ -59,7 +59,7 @@ public:
void createActions();
QMenu* createVideoMenu();
QMenu* createImageMenu();
QToolBar* createToolBar();
QPointer<QToolBar> createToolBar();
QDockWidget* createDock();
QWidget* createStatusBarMessage();
void updateMenus();
@@ -113,7 +113,7 @@ private:
QMenu* m_pcMenuVideo;
QMenu* m_pcMenuImage;
QToolBar* m_toolbarVideo;
// QToolBar* m_toolbarVideo;
QDockWidget* m_pcFramePropertiesDock;
FramePropertiesDock* m_pcFramePropertiesSideBar;
@@ -122,11 +122,11 @@ private:
QLabel* m_pcVideoFormatLabel;
QLabel* m_pcResolutionLabel;
QPointer<VideoSubWindow> m_pcCurrentVideoSubWindow;
QPointer<VideoSubWindow> m_pcCurrentVideoSubWindow{ nullptr };
QVector<VideoStreamSubWindow*> m_acPlayingSubWindows;
QTimer* m_pcPlayingTimer;
bool m_bIsPlaying;
bool m_bIsPlaying{ false };
unsigned int m_uiNumberPlayedFrames{ 0 };
unsigned int m_uiRealAverageFrameRate{ 0 };
+122 -303
View File
@@ -37,65 +37,17 @@
#define QT_NO_CONCURRENT
/**
* \brief Functions to control data stream from stream information
*/
QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& array )
{
CalypFileInfo d;
out << array.size();
for( int i = 0; i < array.size(); i++ )
{
d = array.at( i );
out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat << d.m_uiBitsPelPixel << d.m_iEndianness
<< d.m_uiFrameRate << d.m_uiFileSize << d.m_bForceRaw;
}
return out;
}
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array )
{
CalypFileInfo d;
int array_size{ 0 };
in >> array_size;
for( int i = 0; i < array_size; i++ )
{
in >> d.m_cFilename;
in >> d.m_uiWidth;
in >> d.m_uiHeight;
in >> d.m_iPelFormat;
in >> d.m_uiBitsPelPixel;
in >> d.m_iEndianness;
in >> d.m_uiFrameRate;
in >> d.m_uiFileSize;
in >> d.m_bForceRaw;
array.append( d );
}
return in;
}
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int
{
for( int i = 0; i < array.size(); i++ )
if( array.at( i ).m_cFilename == filename )
return i;
return -1;
}
VideoStreamSubWindow::VideoStreamSubWindow( QWidget* parent )
VideoStreamSubWindow::VideoStreamSubWindow( ResourceHandle* resourceManager, QWidget* parent )
: VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW, parent )
, m_pcResourceManager( nullptr )
, m_pCurrStream( NULL )
, m_bIsPlaying( false )
, m_pcResourceManager{ resourceManager }
, m_pCurrStream{ NULL }
, m_bIsPlaying{ false }
{
}
VideoStreamSubWindow::~VideoStreamSubWindow()
{
if( m_pcResourceManager )
m_pcResourceManager->removeResource( m_uiResourceId );
if( m_pcResourceManager ) m_pcResourceManager->removeResource( m_uiResourceId );
}
void VideoStreamSubWindow::resetWindowName()
@@ -141,8 +93,7 @@ void VideoStreamSubWindow::updateVideoWindowInfo()
{
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrameAsset->getPelFmtName() );
if( m_pCurrStream )
if( !m_pCurrStream->isNative() )
m_cPelFmtName += "*";
if( !m_pCurrStream->isNative() ) m_cPelFmtName += "*";
m_cStreamInformation += " | " + m_cPelFmtName;
}
if( m_cStreamInformation.isEmpty() )
@@ -159,82 +110,10 @@ void VideoStreamSubWindow::loadAll()
QApplication::restoreOverrideCursor();
}
bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
void VideoStreamSubWindow::setResource( std::size_t id )
{
assert( m_pcResourceManager != nullptr );
ConfigureFormatDialog formatDialog( this );
unsigned int Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
int Endianness = CLP_LITTLE_ENDIAN;
auto InputFormat = ClpPixelFormats::YUV420p;
QSettings appSettings;
if( m_pCurrStream )
m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
else
m_uiResourceId = m_pcResourceManager->getResource( nullptr );
m_uiResourceId = id;
m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
bool bConfig = true;
if( !bForceDialog )
{
bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
if( bConfig )
{
// Pre-load values with last opened file
Width = appSettings.value( "VideoStreamSubWindow/LastWidth" ).value<unsigned int>();
Height = appSettings.value( "VideoStreamSubWindow/LastHeight" ).value<unsigned int>();
BitsPel = appSettings.value( "VideoStreamSubWindow/LastBitsPerPixel" ).value<unsigned int>();
}
}
bool bRet{ false };
bool forceRaw{ false };
for( int iPass = 0; iPass < 2 && !bRet; iPass++ )
{
if( iPass || bConfig )
{
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel,
Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
}
try
{
bRet = m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate, iPass == 1, CalypStream::Type::Input );
forceRaw = iPass > 0;
}
catch( CalypFailure& e )
{
if( iPass > 0 )
throw( e );
}
}
if( !bRet )
{
return false;
}
m_sStreamInfo.m_cFilename = cFilename;
m_sStreamInfo.m_uiWidth = Width;
m_sStreamInfo.m_uiHeight = Height;
m_sStreamInfo.m_iPelFormat = static_cast<std::int64_t>( InputFormat );
m_sStreamInfo.m_uiBitsPelPixel = BitsPel;
m_sStreamInfo.m_iEndianness = Endianness;
m_sStreamInfo.m_uiFrameRate = FrameRate;
m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size();
m_sStreamInfo.m_bForceRaw = forceRaw;
QVariant var;
var.setValue<unsigned int>( Width );
appSettings.setValue( "VideoStreamSubWindow/LastWidth", var );
var.setValue<unsigned int>( Height );
appSettings.setValue( "VideoStreamSubWindow/LastHeight", var );
var.setValue<unsigned int>( BitsPel );
appSettings.setValue( "VideoStreamSubWindow/LastBitsPerPixel", var );
#ifdef CALYP_MANAGED_RESOURCES
m_pcResourceManager->startResourceWorker( m_uiResourceId );
#endif
@@ -243,195 +122,137 @@ bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
refreshFrame();
m_cFilename = cFilename;
m_cFilename = QString::fromStdString( m_pCurrStream->getFileName() );
updateVideoWindowInfo();
setWindowName( QFileInfo( m_cFilename ).fileName() );
return true;
}
bool VideoStreamSubWindow::loadFile( CalypFileInfo streamInfo )
{
assert( m_pcResourceManager != nullptr );
// bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
// {
// assert( m_pcResourceManager != nullptr );
m_uiResourceId = m_pcResourceManager->getResource( m_pCurrStream );
m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
// ConfigureFormatDialog formatDialog( this );
// unsigned int Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
// int Endianness = CLP_LITTLE_ENDIAN;
// auto InputFormat = ClpPixelFormats::YUV420p;
// QSettings appSettings;
if( !m_pCurrStream->open( streamInfo.m_cFilename.toStdString(), streamInfo.m_uiWidth, streamInfo.m_uiHeight,
static_cast<ClpPixelFormats>( streamInfo.m_iPelFormat ), streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness,
streamInfo.m_uiFrameRate, streamInfo.m_bForceRaw, CalypStream::Type::Input ) )
{
return false;
}
// if( m_pCurrStream )
// m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
// else
// m_uiResourceId = m_pcResourceManager->getResource( nullptr );
m_cFilename = streamInfo.m_cFilename;
m_sStreamInfo = std::move( streamInfo );
// m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
#ifdef CALYP_MANAGED_RESOURCES
m_pcResourceManager->startResourceWorker( m_uiResourceId );
#endif
// bool bConfig = true;
// if( !bForceDialog )
// {
// bConfig = guessFormat( cFilename, Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
// if( bConfig )
// {
// // Pre-load values with last opened file
// Width = appSettings.value( "VideoStreamSubWindow/LastWidth" ).value<unsigned int>();
// Height = appSettings.value( "VideoStreamSubWindow/LastHeight" ).value<unsigned int>();
// BitsPel = appSettings.value( "VideoStreamSubWindow/LastBitsPerPixel" ).value<unsigned int>();
// }
// }
// bool bRet{ false };
// bool forceRaw{ false };
// for( int iPass = 0; iPass < 2 && !bRet; iPass++ )
// {
// if( iPass || bConfig )
// {
// if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat,
// BitsPel,
// Endianness, FrameRate ) == QDialog::Rejected )
// {
// return false;
// }
// }
// try
// {
// bRet = m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness,
// FrameRate,
// iPass == 1, CalypStream::Type::Input );
// forceRaw = iPass > 0;
// }
// catch( CalypFailure& e )
// {
// if( iPass > 0 )
// throw( e );
// }
// }
QApplication::restoreOverrideCursor();
// if( !bRet )
// {
// return false;
// }
refreshFrame();
// m_sStreamInfo.m_cFilename = cFilename;
// m_sStreamInfo.m_uiWidth = Width;
// m_sStreamInfo.m_uiHeight = Height;
// m_sStreamInfo.m_iPelFormat = InputFormat;
// m_sStreamInfo.m_uiBitsPelPixel = BitsPel;
// m_sStreamInfo.m_iEndianness = Endianness;
// m_sStreamInfo.m_uiFrameRate = FrameRate;
// m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size();
// m_sStreamInfo.m_bForceRaw = forceRaw;
updateVideoWindowInfo();
setWindowName( QFileInfo( m_cFilename ).fileName() );
return true;
}
// QVariant var;
// var.setValue<unsigned int>( Width );
// appSettings.setValue( "VideoStreamSubWindow/LastWidth", var );
// var.setValue<unsigned int>( Height );
// appSettings.setValue( "VideoStreamSubWindow/LastHeight", var );
// var.setValue<unsigned int>( BitsPel );
// appSettings.setValue( "VideoStreamSubWindow/LastBitsPerPixel", var );
bool VideoStreamSubWindow::guessFormat( const QString& filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel,
int& rEndianness, unsigned int& rFrameRate )
{
std::vector<CalypStandardResolution> stdResList = CalypStream::stdResolutionSizes();
bool bGuessed = true;
bool bGuessedByFilesize = false;
QString FilenameShort = QFileInfo( filename ).fileName();
QString fileExtension = QFileInfo( filename ).suffix();
// #ifdef CALYP_MANAGED_RESOURCES
// m_pcResourceManager->startResourceWorker( m_uiResourceId );
// #endif
if( filename.startsWith( "/dev/" ) )
{
return false;
}
if( !fileExtension.compare( "yuv", Qt::CaseInsensitive ) || !fileExtension.compare( "rgb", Qt::CaseInsensitive ) ||
!fileExtension.compare( "gray", Qt::CaseInsensitive ) )
{
bGuessed = false;
// Guess pixel format
const auto& formats_list = CalypFrame::supportedPixelFormatListNames();
for( const auto& [key, name] : formats_list )
{
if( FilenameShort.contains( QString::fromStdString( std::string( name ) ), Qt::CaseInsensitive ) )
{
rInputFormat = key;
break;
}
}
// QApplication::restoreOverrideCursor();
if( rWidth == 0 || rHeight == 0 )
{
// Guess resolution - match resolution name
int iMatch = -1;
for( unsigned int i = 0; i < stdResList.size(); i++ )
{
if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) )
{
iMatch = i;
}
}
if( iMatch >= 0 )
{
rWidth = stdResList[iMatch].uiWidth;
rHeight = stdResList[iMatch].uiHeight;
}
// refreshFrame();
// Guess resolution - match %dx%d
// QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_[0-9]+x[0-9]+" ).match( FilenameShort );
if( resolutionMatch.hasMatch() )
{
QString resolutionString = resolutionMatch.captured( resolutionMatch.lastCapturedIndex() );
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
{
resolutionString.remove( "_" );
QStringList resolutionArgs = resolutionString.split( "x" );
if( resolutionArgs.size() == 2 )
{
rWidth = resolutionArgs.at( 0 ).toUInt();
rHeight = resolutionArgs.at( 1 ).toUInt();
}
}
}
}
// m_cFilename = cFilename;
// Guess resolution by file size
if( rWidth == 0 && rHeight == 0 )
{
FILE* pF = fopen( filename.toStdString().c_str(), "rb" );
if( pF )
{
fseek( pF, 0, SEEK_END );
unsigned long long int uiFileSize = ftell( pF );
fclose( pF );
// updateVideoWindowInfo();
// setWindowName( QFileInfo( m_cFilename ).fileName() );
int count = 0, module, frame_bytes, match;
for( unsigned int i = 0; i < stdResList.size(); i++ )
{
frame_bytes =
CalypFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
module = uiFileSize % frame_bytes;
if( module == 0 )
{
match = i;
count++;
}
}
if( count == 1 )
{
rWidth = stdResList[match].uiWidth;
rHeight = stdResList[match].uiHeight;
bGuessedByFilesize = true;
}
}
}
// return true;
// }
// [.|_]
// Guess bits per pixel - match %dbpp
QRegularExpressionMatch BppMatch = QRegularExpression( "_[0-9]+bpp" ).match( FilenameShort );
if( BppMatch.hasMatch() )
{
QString matchString = BppMatch.captured( BppMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "bpp" );
rBitsPerPixel = matchString.toUInt();
if( !( rBitsPerPixel > 0 && rBitsPerPixel < 16 ) )
{
rBitsPerPixel = -1;
}
}
QRegularExpressionMatch BppOnlybMatch = QRegularExpression( "_[0-9]+b" ).match( FilenameShort );
if( BppOnlybMatch.hasMatch() )
{
QString matchString = BppOnlybMatch.captured( BppOnlybMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "b" );
rBitsPerPixel = matchString.toUInt();
if( !( rBitsPerPixel > 0 && rBitsPerPixel < 16 ) )
{
rBitsPerPixel = -1;
}
}
// bool VideoStreamSubWindow::loadFile( CalypFileInfo streamInfo )
// {
// assert( m_pcResourceManager != nullptr );
// Guess frame rate - match %dbpp
QRegularExpressionMatch FpsMatch = QRegularExpression( "_[0-9]+fps" ).match( FilenameShort );
if( FpsMatch.hasMatch() )
{
QString matchString = FpsMatch.captured( FpsMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "fps" );
rFrameRate = matchString.toUInt();
if( rFrameRate < 0 )
{
rFrameRate = 30;
}
}
// m_uiResourceId = m_pcResourceManager->getResource( m_pCurrStream );
// m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
// Guess Endianness
if( FilenameShort.contains( QStringLiteral( "be" ), Qt::CaseInsensitive ) )
{
rEndianness = CLP_BIG_ENDIAN;
}
if( FilenameShort.contains( QStringLiteral( "le" ), Qt::CaseInsensitive ) )
{
rEndianness = CLP_LITTLE_ENDIAN;
}
// if( !m_pCurrStream->open( streamInfo.m_cFilename.toStdString(), streamInfo.m_uiWidth, streamInfo.m_uiHeight,
// static_cast<ClpPixelFormats>( streamInfo.m_iPelFormat ), streamInfo.m_uiBitsPelPixel,
// streamInfo.m_iEndianness, streamInfo.m_uiFrameRate, streamInfo.m_bForceRaw,
// CalypStream::Type::Input ) )
// {
// return false;
// }
if( rWidth > 0 && rHeight > 0 && rInputFormat != ClpPixelFormats::Invalid )
bGuessed = true && !bGuessedByFilesize;
}
return !bGuessed;
}
// m_cFilename = streamInfo.m_cFilename;
// m_sStreamInfo = std::move( streamInfo );
// #ifdef CALYP_MANAGED_RESOURCES
// m_pcResourceManager->startResourceWorker( m_uiResourceId );
// #endif
// QApplication::restoreOverrideCursor();
// refreshFrame();
// updateVideoWindowInfo();
// setWindowName( QFileInfo( m_cFilename ).fileName() );
// return true;
// }
void VideoStreamSubWindow::refreshSubWindow()
{
@@ -462,8 +283,7 @@ void VideoStreamSubWindow::refreshFrame()
m_pcDisplayModule->apply( m_bIsPlaying, true );
bSetFrame = false;
}
if( bSetFrame )
VideoSubWindow::refreshFrame();
if( bSetFrame ) VideoSubWindow::refreshFrame();
}
void VideoStreamSubWindow::refreshFrame( bool bThreaded )
@@ -564,8 +384,7 @@ void VideoStreamSubWindow::seekAbsoluteEvent( unsigned int new_frame_num )
{
if( m_pCurrStream )
{
if( m_pCurrStream->seekInput( new_frame_num ) )
refreshFrame();
if( m_pCurrStream->seekInput( new_frame_num ) ) refreshFrame();
#ifdef CALYP_MANAGED_RESOURCES
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
@@ -573,17 +392,17 @@ void VideoStreamSubWindow::seekAbsoluteEvent( unsigned int new_frame_num )
}
}
void VideoStreamSubWindow::seekRelativeEvent( bool bIsFoward )
void VideoStreamSubWindow::seekRelativeEvent( bool bIsForward )
{
if( m_pCurrStream )
{
if( bIsFoward )
if( bIsForward )
{
goToNextFrame( true );
}
else
{
m_pCurrStream->seekInputRelative( bIsFoward );
m_pCurrStream->seekInputRelative( bIsForward );
#ifdef CALYP_MANAGED_RESOURCES
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
#endif
+7 -30
View File
@@ -36,6 +36,7 @@
#include "VideoSubWindow.h"
#include "config.h"
#include "lib/CalypStream.h"
#include "models/VideostreamResource.h"
class QScrollArea;
@@ -44,30 +45,12 @@ class VideoStreamSubWindow;
class ResourceHandle;
class CalypAppModuleIf;
struct CalypFileInfo
{
QString m_cFilename;
unsigned int m_uiWidth;
unsigned int m_uiHeight;
int m_iPelFormat;
unsigned int m_uiBitsPelPixel;
int m_iEndianness;
unsigned int m_uiFrameRate;
unsigned long long int m_uiFileSize;
bool m_bForceRaw{ false };
};
using CalypFileInfoVector = QVector<CalypFileInfo>;
QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d );
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d );
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int;
class VideoStreamSubWindow : public VideoSubWindow
{
Q_OBJECT
public:
VideoStreamSubWindow( QWidget* parent = 0 );
VideoStreamSubWindow( ResourceHandle* resourceManager, QWidget* parent = 0 );
~VideoStreamSubWindow();
void resetWindowName() override;
@@ -78,12 +61,12 @@ public:
void advanceOneFrame() override { goToNextFrame( true ); }
auto getFrameNum() -> std::uint64_t override { return m_pCurrStream->getFrameNum(); }
void setResourceManaget( ResourceHandle* resourceManager ) { m_pcResourceManager = resourceManager; }
bool supportsFormatConfiguration() const { return m_pCurrStream->supportsFormatConfiguration(); };
bool loadFile( QString cFilename, bool bForceDialog = false );
bool loadFile( CalypFileInfo streamInfo );
void setResource( std::size_t id );
auto getResourceId() const -> std::size_t { return m_uiResourceId; };
// bool loadFile( QString cFilename, bool bForceDialog = false );
// bool loadFile( CalypFileInfo streamInfo );
void loadAll();
bool saveStream( const QString& filename );
@@ -107,15 +90,12 @@ public:
private:
bool goToNextFrame( bool bThreaded );
static bool guessFormat( const QString& filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel,
int& rEndianness, unsigned int& rFrameRate );
private: // NO_LINT
ResourceHandle* m_pcResourceManager;
std::size_t m_uiResourceId;
QString m_cFilename;
CalypFileInfo m_sStreamInfo;
std::size_t m_uiResourceId;
CalypStream* m_pCurrStream;
QString m_cCurrFileName;
@@ -129,7 +109,4 @@ private: // NO_LINT
QFuture<void> m_cReadResult;
};
Q_DECLARE_METATYPE( CalypFileInfo ) // NOLINT
Q_DECLARE_METATYPE( CalypFileInfoVector ) // NOLINT
#endif // __VIDEOSTREAMSUBWINDOW_H__
+21
View File
@@ -0,0 +1,21 @@
#
# CMakeLists for Calyp lis tests using catch2
#
FETCHCONTENT_MAKEAVAILABLE(Catch2)
SET(Calyp_App_Catch2_Tests_SRCS CalypAppTests.cpp CalypResourcesTests.cpp)
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
ADD_EXECUTABLE(CalypAppCatch2Tests ${Calyp_App_Catch2_Tests_SRCS})
TARGET_LINK_LIBRARIES(
CalypAppCatch2Tests
${PROJECT_LIBRARY}
CalypModules
${APP_LINKER_LIBS}
${QT_LINKER_LIBS}
QCustomPlotLib
Catch2::Catch2WithMain
)
CATCH_DISCOVER_TESTS(CalypAppCatch2Tests)
+26
View File
@@ -0,0 +1,26 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 CalypLibTests.cpp
* \brief CalypLib main test file
*/
#define CATCH_CONFIG_MAIN
#include <catch2/catch_test_macros.hpp>
+285
View File
@@ -0,0 +1,285 @@
/* This file is a part of plaYUVer project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 CalypResourcesTests.cpp
* \brief Resouce handling tests
*/
#include <QString>
#include <catch2/catch_all.hpp>
#include <filesystem>
#include <iostream>
#include <variant>
#include "ResourceHandle.h"
#include "lib/CalypFrame.h"
#include "lib/CalypStream.h"
#include "models/VideostreamResource.h"
using namespace std::chrono_literals;
constexpr int kFrameRate{ 30 };
constexpr auto kStreamType = CalypStream::Type::Input;
auto getFileTestFilename( const char* test_sequence ) -> std::string
{
return std::string( CALYP_TEST_DATA_DIR ) + std::string( "/" ) + std::string( test_sequence );
}
TEST_CASE( "Can construct and destruct a resource", "VideoResource" )
{
auto videoResource = std::make_unique<VideostreamResource>();
CHECK( videoResource != nullptr );
}
TEST_CASE( "Can load a YUV file", "VideoResource" )
{
constexpr unsigned int kWidth{ 352 };
constexpr unsigned int kHeight{ 288 };
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
constexpr unsigned int kBitsPel{ 8 };
constexpr auto KEndianness{ CLP_LITTLE_ENDIAN };
const auto kFilename = getFileTestFilename( "Foreman.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
auto resourceHandle = std::make_unique<ResourceHandle>();
auto videoResource = std::make_unique<VideostreamResource>();
CalypFileInfo streamInfo{ .m_cFilename = QString::fromStdString( kFilename ) };
CHECK_FALSE( videoResource->loadFile( streamInfo, false ) );
SECTION( "Now use a valid config" )
{
streamInfo = CalypFileInfo{ .m_cFilename = QString::fromStdString( kFilename ),
.m_uiWidth = kWidth,
.m_uiHeight = kHeight,
.m_iPelFormat = kInputFormat,
.m_uiBitsPelPixel = kBitsPel,
.m_iEndianness = KEndianness,
.m_uiFrameRate = kFrameRate };
REQUIRE( videoResource->loadFile( streamInfo ) );
const auto& test_stream = videoResource->getStream();
CHECK( test_stream.getWidth() == kWidth );
CHECK( test_stream.getHeight() == kHeight );
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
CHECK( test_stream.getFormatName() == "YUV" );
CHECK( test_stream.getCodecName() == "Raw Video" );
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );
auto frame = videoResource->getCurrFrame();
CHECK( frame->getPixel( 2, 0 ) == CalypPixel{ CLP_COLOR_YUV, 201, 129, 125 } );
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
}
}
TEST_CASE( "Can load a MKV file", "VideoResource" )
{
constexpr unsigned int kWidth{ 352 };
constexpr unsigned int kHeight{ 288 };
constexpr unsigned int kBitsPel{ 8 };
const auto kFilename = getFileTestFilename( "Foreman.mkv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
auto resourceHandle = std::make_unique<ResourceHandle>();
auto videoResource = std::make_unique<VideostreamResource>( nullptr );
CalypFileInfo streamInfo{ .m_cFilename = QString::fromStdString( kFilename ) };
REQUIRE( videoResource->loadFile( streamInfo ) );
const auto& test_stream = videoResource->getStream();
CHECK( test_stream.getWidth() == kWidth );
CHECK( test_stream.getHeight() == kHeight );
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
CHECK( test_stream.getFormatName() == "MKV" );
CHECK( test_stream.getCodecName() == "h264" );
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );
auto frame = videoResource->getCurrFrame();
CHECK( frame->getPixel( 311, 255 ) == CalypPixel{ CLP_COLOR_YUV, 83, 120, 132 } );
}
TEST_CASE( "Can load a PNG file", "VideoResource" )
{
constexpr unsigned int kWidth{ 352 };
constexpr unsigned int kHeight{ 288 };
constexpr unsigned int kBitsPel{ 8 };
const auto kFilename = getFileTestFilename( "Foreman.png" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
auto resourceHandle = std::make_unique<ResourceHandle>();
auto videoResource = std::make_unique<VideostreamResource>( nullptr );
CalypFileInfo streamInfo{ .m_cFilename = QString::fromStdString( kFilename ) };
REQUIRE( videoResource->loadFile( streamInfo ) );
const auto& test_stream = videoResource->getStream();
CHECK( test_stream.getWidth() == kWidth );
CHECK( test_stream.getHeight() == kHeight );
CHECK( test_stream.getBitsPerPixel() == kBitsPel );
CHECK( test_stream.getFormatName() == "PNG" );
CHECK( test_stream.getCodecName() == "png" );
CHECK( test_stream.getEndianess() == CLP_BIG_ENDIAN );
auto frame = videoResource->getCurrFrame();
CHECK( frame->getPixel( 292, 263 ) == CalypPixel{ CLP_COLOR_RGB, 92, 83, 54 } );
}
TEST_CASE( "Resource handle can store a video resource", "VideoResource" )
{
constexpr unsigned int kWidth{ 352 };
constexpr unsigned int kHeight{ 288 };
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
constexpr unsigned int kBitsPel{ 8 };
constexpr auto KEndianness{ CLP_LITTLE_ENDIAN };
const auto kFilename = getFileTestFilename( "Foreman.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
auto resourceHandle = std::make_unique<ResourceHandle>();
CalypFileInfo streamInfo{ .m_cFilename = QString::fromStdString( kFilename ),
.m_uiWidth = kWidth,
.m_uiHeight = kHeight,
.m_iPelFormat = kInputFormat,
.m_uiBitsPelPixel = kBitsPel,
.m_iEndianness = KEndianness,
.m_uiFrameRate = kFrameRate };
{
auto videoResource = std::make_unique<VideostreamResource>( nullptr );
REQUIRE( videoResource != nullptr );
CHECK( videoResource->loadFile( streamInfo ) );
CHECK( resourceHandle->appendResource( std::move( videoResource ) ) == 0 );
}
auto videoResource = std::make_unique<VideostreamResource>( nullptr );
REQUIRE( videoResource != nullptr );
CHECK( videoResource->loadFile( streamInfo ) );
auto resource_id = resourceHandle->appendResource( std::move( videoResource ) );
CHECK( resource_id == 1 );
SECTION( "Can start and stop resource" )
{
resourceHandle->startResourceWorker( resource_id );
std::this_thread::sleep_for( 20ms );
resourceHandle->stopResourceWorker( resource_id );
CHECK( true );
}
SECTION( "Can start without stopping (RAII will clear resource)" )
{
resourceHandle->startResourceWorker( resource_id );
CHECK( true );
}
resourceHandle->removeResource( resource_id );
}
TEST_CASE( "Resource handle can play a video resource", "VideoResource" )
{
constexpr unsigned int kWidth{ 352 };
constexpr unsigned int kHeight{ 288 };
constexpr auto kInputFormat{ ClpPixelFormats::YUV420p };
constexpr unsigned int kBitsPel{ 8 };
constexpr auto KEndianness{ CLP_LITTLE_ENDIAN };
const auto kFilename = getFileTestFilename( "Foreman.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
auto resourceHandle = std::make_unique<ResourceHandle>();
CalypFileInfo streamInfo{ .m_cFilename = QString::fromStdString( kFilename ),
.m_uiWidth = kWidth,
.m_uiHeight = kHeight,
.m_iPelFormat = kInputFormat,
.m_uiBitsPelPixel = kBitsPel,
.m_iEndianness = KEndianness,
.m_uiFrameRate = kFrameRate };
auto videoResource = std::make_unique<VideostreamResource>( nullptr );
REQUIRE( videoResource != nullptr );
CHECK( videoResource->loadFile( streamInfo ) );
auto frame = videoResource->getCurrFrame();
CHECK( frame->getPixel( 2, 0 ) == CalypPixel{ CLP_COLOR_YUV, 201, 129, 125 } );
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
auto resource_id = resourceHandle->appendResource( std::move( videoResource ) );
resourceHandle->executeResourceAction<VideostreamResource>( resource_id, []( auto* resource ) {
resource->play();
return true;
} );
resourceHandle->startResourceWorker( resource_id );
resourceHandle->executeResourceAction<VideostreamResource>( resource_id, [&frame]( auto* resource ) {
resource->playEvent();
frame = resource->getCurrFrame();
return true;
} );
CHECK( frame->getPixel( 298, 237 ) == CalypPixel{ CLP_COLOR_YUV, 82, 115, 134 } );
resourceHandle->executeResourceAction<VideostreamResource>( resource_id, [&frame]( auto* resource ) {
resource->playEvent();
frame = resource->getCurrFrame();
return true;
} );
CHECK_FALSE( frame->getPixel( 298, 237 ) == CalypPixel{ CLP_COLOR_YUV, 82, 115, 134 } );
SECTION( "Can Stop" )
{
resourceHandle->executeResourceAction<VideostreamResource>( resource_id, [&frame]( auto* resource ) {
resource->playEvent();
frame = resource->getCurrFrame();
return true;
} );
resourceHandle->executeResourceAction<VideostreamResource>( resource_id, [&frame]( auto* resource ) {
resource->stop();
frame = resource->getCurrFrame();
return true;
} );
CHECK( frame->getPixel( 2, 0 ) == CalypPixel{ CLP_COLOR_YUV, 201, 129, 125 } );
CHECK( frame->getPixel( 336, 278 ) == CalypPixel{ CLP_COLOR_YUV, 99, 111, 142 } );
}
resourceHandle->stopResourceWorker( resource_id );
}
+16 -11
View File
@@ -73,8 +73,7 @@ QDataStream& operator>>( QDataStream& in, CalypStandardResolutionVector& array )
class AddCustomFormat : public QDialog
{
public:
AddCustomFormat( QWidget* parent = NULL )
: QDialog( parent, Qt::Dialog | Qt::WindowTitleHint )
AddCustomFormat( QWidget* parent = NULL ) : QDialog( parent, Qt::Dialog | Qt::WindowTitleHint )
{
setWindowModality( Qt::ApplicationModal );
setWindowTitle( "Add custom resolution" );
@@ -137,8 +136,7 @@ private:
QSpinBox* m_spinHeight;
};
ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent )
: QDialog( parent )
ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( parent )
{
QString Name;
unsigned int uiWidth, uiHeight;
@@ -175,12 +173,18 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent )
QFont titleFont, menusFont, normalFont;
#if QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 )
auto fontWeight = QFont::Weight::Bold;
#else
auto fontWeight = 75;
#endif
titleFont.setPointSize( 12 );
titleFont.setBold( true );
titleFont.setWeight( 75 );
titleFont.setWeight( fontWeight );
menusFont.setBold( true );
titleFont.setWeight( 75 );
titleFont.setWeight( fontWeight );
normalFont.setBold( false );
// menusFont.setPointSize( 12 );
@@ -402,8 +406,10 @@ auto findPelFormatColorSpace( ClpPixelFormats rInputFormat ) -> std::pair<int, s
return std::make_pair( 0, 0 );
}
int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight,
ClpPixelFormats& rInputFormat, unsigned int& rBits, int& rEndianess, unsigned int& rFrameRate )
auto ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth,
unsigned int& rHeight, ClpPixelFormats& rInputFormat,
unsigned int& rBits, int& rEndianess,
unsigned int& rFrameRate ) -> QDialog::DialogCode
{
// Set default values
// setWindowTitle( "Configure resolution for " + Filename );
@@ -504,8 +510,7 @@ void ConfigureFormatDialog::slotResolutionChange()
void ConfigureFormatDialog::slotColorSpaceChange( int idx )
{
if( idx == -1 )
return;
if( idx == -1 ) return;
m_comboBoxPixelFormat->clear();
const auto& formats_list = CalypFrame::supportedPixelFormatListNames( idx );
@@ -539,6 +544,6 @@ void ConfigureFormatDialog::writeSettings()
{
QSettings appSettings;
QVariant var;
var.setValue<CalypStandardResolutionVector>( aRCustomFileFormats );
var.setValue( aRCustomFileFormats );
appSettings.setValue( "ConfigureFormatDialog/CustomFormats", var );
}
+3 -2
View File
@@ -51,8 +51,9 @@ class ConfigureFormatDialog : public QDialog
public:
ConfigureFormatDialog( QWidget* parent = 0 );
int runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBits,
int& rEndianess, unsigned int& rFrameRate );
auto runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight,
ClpPixelFormats& rInputFormat, unsigned int& rBits, int& rEndianess,
unsigned int& rFrameRate ) -> QDialog::DialogCode;
void readSettings();
void writeSettings();
-1
View File
@@ -25,7 +25,6 @@
#include "ProgressBar.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QLabel>
#include <QProgressBar>
#include <QVBoxLayout>
+10 -2
View File
@@ -2,7 +2,15 @@
# CMakeLists for qcustomplot
#
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
IF(${USE_QT6})
FIND_PACKAGE(Qt6 QUIET COMPONENTS Core Gui Widgets PrintSupport)
IF (NOT Qt6_FOUND)
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
ENDIF()
ELSE()
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
ENDIF()
SET(qcustomplot_SRCS qcustomplot.cpp qcustomplot.h)
@@ -13,5 +21,5 @@ IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
ENDIF()
ADD_LIBRARY(QCustomPlotLib STATIC ${qcustomplot_SRCS})
TARGET_LINK_LIBRARIES(QCustomPlotLib Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
TARGET_LINK_LIBRARIES(QCustomPlotLib Qt::Core Qt::Gui Qt::Widgets Qt::PrintSupport)
TARGET_INCLUDE_DIRECTORIES(QCustomPlotLib PUBLIC .)
Vendored Regular → Executable
+18
View File
@@ -1,3 +1,21 @@
#### Version 2.1.1 released on 06.11.22 ####
Added features:
- Qt6.4 Compatibility
Bugfixes:
- dynamically changing device pixel ratios (e.g. when moving between different DPI screens) is handled properly
- bugfix Colormap autoscaling: recalculateDataBounds() if (0, 0) data point is NaN.
- minor bugfix in getMantissa for certain values due to rounding errors
- Graphs with line style lsImpulse properly ignore NaN data points
- fixed issue where QCP wasn't greyed out together with the rest of the UI on embedded systems when a modal dialog is shown
(QCustomPlot no longer has the Qt::WA_OpaquePaintEvent attribute enabled by default)
Other:
- in QCPAxisPainterPrivate::getTickLabelData, don't use fixed 'e', but locale aware character of parent plot locale
- Axis rescaling now ignores +/- Inf in data values
- slight performance improvements of QCPColorMap colorization and fills.
#### Version 2.1.0 released on 29.03.21 ####
Added features:
+10309 -10898
View File
File diff suppressed because it is too large. Load diff
+3453 -3706
View File
File diff suppressed because it is too large. Load diff
+9 -4
View File
@@ -22,6 +22,10 @@
* \brief main file
*/
#include <QApplication>
#include <QMetaType>
#include <QStyleFactory>
#include "CommonDefs.h"
#include "ConfigureFormatDialog.h"
#include "MainWindow.h"
@@ -30,8 +34,7 @@
#ifdef USE_QTDBUS
#include "DBusAppAdaptor.h"
#endif
#include <QApplication>
#include <QStyleFactory>
#ifdef USE_FERVOR
#include "fvupdater.h"
#endif
@@ -43,10 +46,12 @@
int main( int argc, char* argv[] )
{
qRegisterMetaType<CalypFileInfoVector>();
qRegisterMetaTypeStreamOperators<CalypFileInfoVector>();
qRegisterMetaType<CalypStandardResolutionVector>();
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
qRegisterMetaTypeStreamOperators<CalypFileInfoVector>();
qRegisterMetaTypeStreamOperators<CalypStandardResolutionVector>();
#endif
QApplication::setStyle( "macOS" );
QApplication application( argc, argv );
QApplication::setApplicationName( QStringLiteral( "Calyp" ) );
QApplication::setApplicationVersion( QStringLiteral( CALYP_VERSION_STRING ) );
+52
View File
@@ -0,0 +1,52 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 CalypResource.h
* \brief Abstract calyp resource
*/
#ifndef __CALYPRESOURCE_H__
#define __CALYPRESOURCE_H__
#include <QObject>
#include "lib/CalypStream.h"
class CalypResource
{
public:
virtual ~CalypResource() = default;
virtual auto iteration() -> bool = 0;
virtual auto isReady() -> bool = 0;
virtual auto getResourceName() -> std::string = 0;
// TODO(JC) [[deprecated( "Do not directly access the resource" )]] after refactoring
virtual auto getResource() -> CalypStream* = 0;
protected:
CalypResource() = default;
CalypResource( CalypResource&& other ) noexcept = default;
CalypResource( const CalypResource& other ) = default;
auto operator=( CalypResource&& other ) noexcept -> CalypResource& = default;
auto operator=( const CalypResource& other ) -> CalypResource& = default;
};
#endif // __CALYPRESOURCE_H__
+351
View File
@@ -0,0 +1,351 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 VideostreamResource.h
* \brief Class to control video playback
*/
#include "VideostreamResource.h"
#include <qfileinfo.h>
#include <QDataStream>
#include <QElapsedTimer>
#include <QFileInfo>
#include <QRegularExpression>
#include <memory>
#include "lib/CalypFrame.h"
/**
* \brief Functions to control data stream from stream information
*/
auto operator<<( QDataStream& out, const CalypFileInfoVector& infos ) -> QDataStream&
{
out << infos.size();
for( const auto& info : infos )
{
out << info.m_cFilename << info.m_uiWidth << info.m_uiHeight << static_cast<int>( info.m_iPelFormat )
<< info.m_uiBitsPelPixel << info.m_iEndianness << info.m_uiFrameRate << info.m_uiFileSize << info.m_bForceRaw;
}
return out;
}
auto operator>>( QDataStream& in, CalypFileInfoVector& infos ) -> QDataStream&
{
auto array_size = infos.size();
in >> array_size;
for( int i = 0; i < array_size; i++ )
{
CalypFileInfo d;
int pelFormat{ 0 };
in >> d.m_cFilename;
in >> d.m_uiWidth;
in >> d.m_uiHeight;
in >> pelFormat;
in >> d.m_uiBitsPelPixel;
in >> d.m_iEndianness;
in >> d.m_uiFrameRate;
in >> d.m_uiFileSize;
in >> d.m_bForceRaw;
d.m_iPelFormat = static_cast<ClpPixelFormats>( pelFormat );
infos.append( d );
}
return in;
}
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int
{
for( int i = 0; i < array.size(); i++ )
{
if( array.at( i ).m_cFilename == filename ) return i;
}
return -1;
}
VideostreamResource::VideostreamResource( QObject* parent ) : QObject{ parent } {}
VideostreamResource::~VideostreamResource() = default;
auto VideostreamResource::iteration() -> bool
{
m_currStream.readNextFrameFillRGBBuffer();
return true;
}
auto VideostreamResource::isReady() -> bool
{
return m_currStream.hasWritingSlot();
}
bool VideostreamResource::loadFile( const CalypFileInfo& streamInfo, bool optimistic )
{
m_sStreamInfo = streamInfo;
ClpPixelFormats inputFormat = static_cast<ClpPixelFormats>( m_sStreamInfo.m_iPelFormat );
try
{
if( !m_currStream.open( streamInfo.m_cFilename.toStdString(), streamInfo.m_uiWidth, streamInfo.m_uiHeight,
inputFormat, streamInfo.m_uiBitsPelPixel, streamInfo.m_iEndianness,
streamInfo.m_uiFrameRate, streamInfo.m_bForceRaw, CalypStream::Type::Input ) )
{
return false;
}
}
catch( CalypFailure& e )
{
if( !optimistic )
{
return false;
}
throw( e );
}
m_currStream.getFormat( m_sStreamInfo.m_uiWidth, m_sStreamInfo.m_uiHeight, m_sStreamInfo.m_iPelFormat,
m_sStreamInfo.m_uiBitsPelPixel, m_sStreamInfo.m_iEndianness, m_sStreamInfo.m_uiFrameRate );
m_sStreamInfo.m_uiFileSize = QFileInfo{ streamInfo.m_cFilename }.size();
return true;
}
auto VideostreamResource::getCurrFrame() -> std::shared_ptr<CalypFrame>
{
return m_currStream.getCurrFrameAsset();
}
bool VideostreamResource::play()
{
bool isPlaying = false;
if( m_currStream.getFrameNum() > 1 )
{
isPlaying = true;
}
m_bIsPlaying = isPlaying;
return m_bIsPlaying;
}
bool VideostreamResource::playEvent()
{
bool bEndOfSeq = false;
if( m_bIsPlaying )
{
bEndOfSeq = goToNextFrame( true );
}
return bEndOfSeq;
}
void VideostreamResource::pause()
{
m_bIsPlaying = false;
triggerRefresh();
}
void VideostreamResource::seekAbsoluteEvent( unsigned int new_frame_num )
{
if( m_currStream.seekInput( new_frame_num ) ) triggerRefresh();
}
void VideostreamResource::seekRelativeEvent( bool bIsForward )
{
if( bIsForward )
{
goToNextFrame( true );
}
else
{
m_currStream.seekInputRelative( bIsForward );
triggerRefresh();
}
}
void VideostreamResource::stop()
{
m_bIsPlaying = false;
seekAbsoluteEvent( 0 );
return;
}
auto VideostreamResource::goToNextFrame( bool bThreaded ) -> bool
{
while( !m_currStream.hasNextFrame() && !m_currStream.isEof() )
{
}
bool bEndOfSeq = m_currStream.setNextFrame();
if( !bEndOfSeq )
{
triggerRefresh();
}
return bEndOfSeq;
}
void VideostreamResource::triggerRefresh() {}
auto video_resource_guess_format( const QString& filename, unsigned int& rWidth, unsigned int& rHeight,
ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel, int& rEndianness,
unsigned int& rFrameRate ) -> bool
{
std::vector<CalypStandardResolution> stdResList = CalypStream::stdResolutionSizes();
bool bGuessed = true;
bool bGuessedByFilesize = false;
QString FilenameShort = QFileInfo( filename ).fileName();
QString fileExtension = QFileInfo( filename ).suffix();
if( filename.startsWith( "/dev/" ) )
{
return true;
}
if( !fileExtension.compare( "yuv", Qt::CaseInsensitive ) || !fileExtension.compare( "rgb", Qt::CaseInsensitive ) ||
!fileExtension.compare( "gray", Qt::CaseInsensitive ) )
{
bGuessed = false;
// Guess pixel format
const auto& formats_list = CalypFrame::supportedPixelFormatListNames();
for( const auto& [key, name] : formats_list )
{
if( FilenameShort.contains( QString::fromStdString( std::string( name ) ), Qt::CaseInsensitive ) )
{
rInputFormat = key;
break;
}
}
if( rWidth == 0 || rHeight == 0 )
{
// Guess resolution - match resolution name
int iMatch = -1;
for( unsigned int i = 0; i < stdResList.size(); i++ )
{
if( FilenameShort.contains( QString::fromStdString( stdResList[i].shortName ) ) )
{
iMatch = i;
}
}
if( iMatch >= 0 )
{
rWidth = stdResList[iMatch].uiWidth;
rHeight = stdResList[iMatch].uiHeight;
}
// Guess resolution - match %dx%d
// QRegularExpressionMatch resolutionMatch = QRegularExpression( "_\\d*x\\d*" ).match( FilenameShort );
QRegularExpressionMatch resolutionMatch = QRegularExpression( "_[0-9]+x[0-9]+" ).match( FilenameShort );
if( resolutionMatch.hasMatch() )
{
QString resolutionString = resolutionMatch.captured( resolutionMatch.lastCapturedIndex() );
if( resolutionString.startsWith( "_" ) || resolutionString.endsWith( "_" ) )
{
resolutionString.remove( "_" );
QStringList resolutionArgs = resolutionString.split( "x" );
if( resolutionArgs.size() == 2 )
{
rWidth = resolutionArgs.at( 0 ).toUInt();
rHeight = resolutionArgs.at( 1 ).toUInt();
}
}
}
}
// Guess resolution by file size
if( rWidth == 0 && rHeight == 0 )
{
FILE* pF = fopen( filename.toStdString().c_str(), "rb" );
if( pF )
{
fseek( pF, 0, SEEK_END );
unsigned long long int uiFileSize = ftell( pF );
fclose( pF );
int count = 0;
int match = -1;
for( unsigned int i = 0; i < stdResList.size(); i++ )
{
auto frame_bytes =
CalypFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
auto module = uiFileSize % frame_bytes;
if( module == 0 )
{
match = i;
count++;
}
}
if( count == 1 )
{
rWidth = stdResList[match].uiWidth;
rHeight = stdResList[match].uiHeight;
bGuessedByFilesize = true;
}
}
}
// [.|_]
// Guess bits per pixel - match %dbpp
QRegularExpressionMatch BppMatch = QRegularExpression( "_[0-9]+bpp" ).match( FilenameShort );
if( BppMatch.hasMatch() )
{
QString matchString = BppMatch.captured( BppMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "bpp" );
rBitsPerPixel = matchString.toUInt();
if( !( rBitsPerPixel > 0 && rBitsPerPixel < 16 ) )
{
rBitsPerPixel = -1;
}
}
QRegularExpressionMatch BppOnlyMatch = QRegularExpression( "_[0-9]+b" ).match( FilenameShort );
if( BppOnlyMatch.hasMatch() )
{
QString matchString = BppOnlyMatch.captured( BppOnlyMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "b" );
rBitsPerPixel = matchString.toUInt();
if( !( rBitsPerPixel > 0 && rBitsPerPixel < 16 ) )
{
rBitsPerPixel = -1;
}
}
// Guess frame rate - match %dbpp
QRegularExpressionMatch FpsMatch = QRegularExpression( "_[0-9]+fps" ).match( FilenameShort );
if( FpsMatch.hasMatch() )
{
QString matchString = FpsMatch.captured( FpsMatch.lastCapturedIndex() );
matchString.remove( "_" );
matchString.remove( "fps" );
rFrameRate = matchString.toUInt();
if( rFrameRate < 0 )
{
rFrameRate = 30;
}
}
// Guess Endianness
if( FilenameShort.contains( QStringLiteral( "be" ), Qt::CaseInsensitive ) )
{
rEndianness = CLP_BIG_ENDIAN;
}
if( FilenameShort.contains( QStringLiteral( "le" ), Qt::CaseInsensitive ) )
{
rEndianness = CLP_LITTLE_ENDIAN;
}
if( rWidth > 0 && rHeight > 0 && rInputFormat != ClpPixelFormats::Invalid ) bGuessed = true && !bGuessedByFilesize;
}
return bGuessed;
}
+106
View File
@@ -0,0 +1,106 @@
/* This file is a part of Calyp project
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
* Luis Lucas (luisfrlucas@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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 VideostreamResource.h
* \brief Class to control video playback
*/
#ifndef __VIDEOSTREAMRESOURCE_H__
#define __VIDEOSTREAMRESOURCE_H__
#include <QElapsedTimer>
#include <QWidget>
#include "CalypResource.h"
#include "CommonDefs.h"
#include "config.h"
#include "lib/CalypStream.h"
struct CalypFileInfo
{
QString m_cFilename;
unsigned int m_uiWidth;
unsigned int m_uiHeight;
ClpPixelFormats m_iPelFormat;
unsigned int m_uiBitsPelPixel{ 8 };
int m_iEndianness{ CLP_LITTLE_ENDIAN };
unsigned int m_uiFrameRate{ 30 };
unsigned long long int m_uiFileSize;
bool m_bForceRaw{ false };
};
using CalypFileInfoVector = QVector<CalypFileInfo>;
auto operator<<( QDataStream& out, const CalypFileInfoVector& infos ) -> QDataStream&;
auto operator>>( QDataStream& in, CalypFileInfoVector& infos ) -> QDataStream&;
auto findCalypStreamInfo( const CalypFileInfoVector& array, const QString& filename ) -> int;
class VideostreamResource : public QObject, public CalypResource
{
Q_OBJECT
public:
VideostreamResource( QObject* parent = nullptr );
VideostreamResource( VideostreamResource&& other ) noexcept = delete;
VideostreamResource& operator=( VideostreamResource&& other ) noexcept = delete;
VideostreamResource( const VideostreamResource& other ) = delete;
VideostreamResource& operator=( const VideostreamResource& other ) = delete;
~VideostreamResource();
auto getResourceName() -> std::string override { return m_currStream.getFileName(); };
auto iteration() -> bool override;
auto isReady() -> bool override;
auto loadFile( const CalypFileInfo& streamInfo, bool optimistic = true ) -> bool;
auto getStreamInfo() const -> CalypFileInfo { return m_sStreamInfo; }
auto getResource() -> CalypStream* override { return &m_currStream; };
auto getStream() const -> const CalypStream& { return m_currStream; };
auto getCurrFrame() -> std::shared_ptr<CalypFrame>;
bool play();
void pause();
void stop();
bool playEvent();
void seekAbsoluteEvent( unsigned int new_frame_num );
void seekRelativeEvent( bool bIsForward );
private:
auto goToNextFrame( bool bThreaded ) -> bool;
void triggerRefresh();
// Q_SIGNALS:
// private Q_SLOTS:
private: // NOLINT
CalypStream m_currStream;
CalypFileInfo m_sStreamInfo;
bool m_bIsPlaying;
};
auto video_resource_guess_format( const QString& filename, unsigned int& rWidth, unsigned int& rHeight,
ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPixel, int& rEndianness,
unsigned int& rFrameRate ) -> bool;
Q_DECLARE_METATYPE( CalypFileInfo ) // NOLINT
Q_DECLARE_METATYPE( CalypFileInfoVector ) // NOLINT
#endif // __VIDEOSTREAMRESOURCE_H__
+1 -1
View File
@@ -35,7 +35,7 @@ class QLabel;
class FrameNumberWidget : public QWidget
{
public:
FrameNumberWidget( QWidget* parent = 0 );
explicit FrameNumberWidget( QWidget* parent = 0 );
void setCurrFrameNum( int number );
void setTotalFrameNum( int number );
void clear();
@@ -29,10 +29,8 @@
#include "CalypModuleIf.h"
class AbsoluteFrameDifferenceExample : public CalypModuleIf
class AbsoluteFrameDifferenceExample : public CalypModuleIf, public CalypModuleInstance<AbsoluteFrameDifferenceExample>
{
REGISTER_CLASS_FACTORY( AbsoluteFrameDifferenceExample )
private:
CalypFrame* m_pcFrameDifference;
+1 -3
View File
@@ -27,10 +27,8 @@
#include "CalypModuleIf.h"
class FrameBinarizationAPIv1 : public CalypModuleIf
class FrameBinarizationAPIv1 : public CalypModuleIf, public CalypModuleInstance<FrameBinarizationAPIv1>
{
REGISTER_CLASS_FACTORY( FrameBinarizationAPIv1 )
private:
CalypFrame* m_pcBinFrame;
unsigned int m_uiThreshold;
+2
View File
@@ -8,6 +8,8 @@ EXPORT(PACKAGE MyLib)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp)
SET(Calyp_Lib_Stream_SRCS
+7 -10
View File
@@ -27,6 +27,7 @@
#define __CALYPDEFS_H__
#include <algorithm>
#include <format>
#include <iterator>
#include <memory>
#include <string>
@@ -58,20 +59,16 @@ inline std::string clpUppercase( const std::string& in )
struct CalypFailure : public std::exception
{
std::string m_class_name;
std::string m_error_msg;
CalypFailure( std::string error_msg ) throw()
: m_error_msg( error_msg ) {}
CalypFailure( std::string error_msg ) throw() : m_error_msg{ std::move( error_msg ) } {}
CalypFailure( std::string class_name, std::string error_msg ) throw()
: m_class_name( class_name ), m_error_msg( error_msg )
: m_error_msg{ std::format( "[%s] %s", class_name, error_msg ) }
{
}
~CalypFailure() throw() {}
const char* what() const throw()
{
std::string* msg = new std::string( "[" + m_class_name + "] " + m_error_msg );
return msg->c_str();
}
auto what() const throw() -> const char* { return m_error_msg.c_str(); }
private:
std::string m_error_msg;
};
#endif // __CALYPDEFS_H__
+363 -414
View File
File diff suppressed because it is too large. Load diff
+75 -69
View File
@@ -27,6 +27,7 @@
#define __CALYPFRAME_H__
#include <array>
#include <cstdint>
#include <map>
#include <memory>
#include <optional>
@@ -37,7 +38,7 @@
namespace cv
{
class Mat;
}
} // namespace cv
using ClpPel = std::uint16_t;
using ClpByte = std::uint8_t;
@@ -99,7 +100,10 @@ enum CLP_Endianness
CLP_LITTLE_ENDIAN = 1,
};
#define CHROMASHIFT( SIZE, SHIFT ) (unsigned int)( -( ( -( (int)( SIZE ) ) ) >> ( SHIFT ) ) )
constexpr auto CHROMASHIFT( unsigned int size, unsigned int shift ) -> unsigned int
{
return -( ( -( static_cast<int>( size ) ) ) >> ( shift ) ); // NOLINT
}
/**
* \class CalypPixel
@@ -117,9 +121,9 @@ public:
static constexpr std::size_t getMaxNumberOfComponents() { return kMaxNumberOfComponents; }
CalypPixel() = default;
CalypPixel( const int CalypColorSpace, const ClpPel c0 = 0 );
CalypPixel( const int CalypColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 );
CalypPixel( const int CalypColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 );
explicit CalypPixel( int calypColorSpace, ClpPel c0 = 0 );
CalypPixel( int calypColorSpace, ClpPel c0, ClpPel c1, ClpPel c2 );
CalypPixel( int calypColorSpace, ClpPel c0, ClpPel c1, ClpPel c2, ClpPel c3 );
CalypPixel( const CalypPixel& other ) noexcept = default;
CalypPixel( CalypPixel&& other ) noexcept = default;
auto operator=( const CalypPixel& other ) -> CalypPixel& = default;
@@ -131,20 +135,20 @@ public:
auto components() const -> const std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
auto components() -> std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
ClpPel operator[]( const std::size_t channel ) const { return m_pelComp[channel]; }
ClpPel& operator[]( const std::size_t channel ) { return m_pelComp[channel]; }
auto operator[]( const std::size_t channel ) const -> ClpPel { return m_pelComp[channel]; }
auto operator[]( const std::size_t channel ) -> ClpPel& { return m_pelComp[channel]; }
CalypPixel& operator+=( const CalypPixel& );
CalypPixel& operator-=( const CalypPixel& );
CalypPixel& operator*=( const double );
auto operator+=( const CalypPixel& ) -> CalypPixel&;
auto operator-=( const CalypPixel& ) -> CalypPixel&;
auto operator*=( double ) -> CalypPixel&;
CalypPixel operator+( const CalypPixel& ) const;
CalypPixel operator-( const CalypPixel& ) const;
CalypPixel operator*( const double ) const;
auto operator+( const CalypPixel& ) const -> CalypPixel;
auto operator-( const CalypPixel& ) const -> CalypPixel;
auto operator*( double ) const -> CalypPixel;
auto operator==( const CalypPixel& other ) const -> bool;
friend std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
friend auto operator<<( std::ostream& os, const CalypPixel& p ) -> std::ostream&;
/**
* Convert a Pixel to a new color space
@@ -152,10 +156,10 @@ public:
* @param eOutputSpace output color space
* @return converted pixel
*/
CalypPixel convertPixel( CalypColorSpace eOutputSpace ) const;
auto convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel;
};
std::ostream& operator<<( std::ostream& os, const CalypPixel& p );
auto operator<<( std::ostream& stream, const CalypPixel& pixel ) -> std::ostream&;
/**
* \class CalypPlane
@@ -221,11 +225,11 @@ public:
*/
static constexpr auto numberOfFormats() -> std::size_t;
static auto findPixelFormat( const std::string& name ) -> std::optional<ClpPixelFormats>;
static auto findPixelFormat( const std::string_view name ) -> std::optional<ClpPixelFormats>;
static auto findPixelFormat( std::string_view name ) -> std::optional<ClpPixelFormats>;
static auto pelFormatColorSpace( ClpPixelFormats idx ) -> int;
static auto supportedPixelFormatListNames() -> std::map<ClpPixelFormats, std::string_view>;
static auto supportedPixelFormatListNames( int colorSpace ) -> std::map<ClpPixelFormats, std::string_view>;
static auto pixelFormatName( ClpPixelFormats idx ) -> const std::string_view;
static auto pixelFormatName( ClpPixelFormats idx ) -> std::string_view;
/**
* Creates a new frame using the following configuration
@@ -247,21 +251,22 @@ public:
*
* @note this function might misbehave if the pixel format enum is not correct
*/
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel, bool has_negative_values );
CalypFrame( unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned bitsPixel,
bool hasNegativeValues );
/**
* Move contructor
*
* @param other existing frame to copy from
*/
CalypFrame( CalypFrame&& other ) noexcept;
CalypFrame( CalypFrame&& other ) noexcept = default;
/**
* Move assignement contructor
*
* @param other existing frame to copy from
*/
CalypFrame& operator=( CalypFrame&& other ) noexcept;
auto operator=( CalypFrame&& other ) noexcept -> CalypFrame& = default;
/**
* Copy contructor
@@ -275,7 +280,7 @@ public:
*
* @param other existing frame to copy from
*/
CalypFrame& operator=( const CalypFrame& other );
auto operator=( const CalypFrame& other ) -> CalypFrame&;
/**
* Creates and new frame with the configuration of an existing one and copy
@@ -312,14 +317,14 @@ public:
* @param match matching conditions (use enum FormatMatching)
* @return true if format matches
*/
bool haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const;
bool haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const;
auto haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const -> bool;
auto haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const -> bool;
/**
* Get pixel format information
* @return pixel format index
*/
ClpPixelFormats getPelFormat() const;
auto getPelFormat() const -> ClpPixelFormats;
/**
* Get pixel format information
@@ -331,90 +336,91 @@ public:
* Get color space information
* @return get color space index
*/
int getColorSpace() const;
auto getColorSpace() const -> int;
/**
* Get the number of channels
* @return number of channels
*/
unsigned getNumberChannels() const;
auto getNumberChannels() const -> unsigned;
/**
* Get width of the frame
* @param channel/component
* @return number of pixels
*/
unsigned int getWidth( unsigned channel = 0 ) const;
auto getWidth( unsigned channel = 0 ) const -> unsigned int;
/**
* Get height of the frame
* @param channel/component
* @return number of pixels
*/
unsigned int getHeight( unsigned channel = 0 ) const;
auto getHeight( unsigned channel = 0 ) const -> unsigned int;
/**
* Check if frame has negative values
* @return Boolean with the flag value
*/
bool getHasNegativeValues() const;
auto getHasNegativeValues() const -> bool;
/**
* Get number of pixels of the frame
* @param channel/component
* @return number of pixels
*/
std::uint64_t getPixels( unsigned channel = 0 ) const;
auto getPixels( unsigned channel = 0 ) const -> std::uint64_t;
/**
* Get the total number of pixels of the frame
* @return number of pixels
*/
std::uint64_t getTotalNumberOfPixels() const;
auto getTotalNumberOfPixels() const -> std::uint64_t;
/**
* Get chroma width ratio
* @return ratio multiple of 2
*/
unsigned getChromaWidthRatio() const;
auto getChromaWidthRatio() const -> unsigned;
/**
* Get chroma height ratio
* @return ratio multiple of 2
*/
unsigned getChromaHeightRatio() const;
auto getChromaHeightRatio() const -> unsigned;
/**
* Get number of pixels in each chroma channel
* @return number of pixels
*/
std::uint64_t getChromaLength() const;
auto getChromaLength() const -> std::uint64_t;
/**
* Get number of bits per pixel
* @return number of bits
*/
unsigned int getBitsPel() const;
auto getBitsPel() const -> unsigned int;
/**
* Get number of bytes per frame of an existing frame
* @return number of bytes per frame
*/
std::uint64_t getBytesPerFrame() const;
auto getBytesPerFrame() const -> std::uint64_t;
/**
* Get number of bytes per frame of a specific pixel format
* @return number of bytes per frame
*/
static std::uint64_t getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat, unsigned int bitsPixel );
static auto getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat,
unsigned int bitsPixel ) -> std::uint64_t;
/**
* Reset frame pixels to zero
*/
void reset();
ClpPel*** getPelBufferYUV() const;
ClpPel*** getPelBufferYUV();
auto getPelBufferYUV() const -> ClpPel***;
auto getPelBufferYUV() -> ClpPel***;
auto getRGBBuffer() const -> std::optional<std::span<const std::uint8_t>>;
@@ -426,7 +432,7 @@ public:
* @param absolute whether it should return positive/negative values
* @return pixel value
*/
ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const;
auto operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const -> ClpPel;
/**
* Get pixel value at coordinates
@@ -434,7 +440,7 @@ public:
* @param yPos position in Y axis
* @return pixel value
*/
CalypPixel operator()( unsigned int xPos, unsigned int yPos ) const;
auto operator()( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
/**
* Get pixel value at coordinates
@@ -442,7 +448,7 @@ public:
* @param yPos position in Y axis
* @return pixel value
*/
CalypPixel getPixel( unsigned int xPos, unsigned int yPos ) const;
auto getPixel( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
/**
* Get pixel value at coordinates
@@ -452,7 +458,7 @@ public:
* @param eColorSpace desired color space
* @return pixel value
*/
CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const;
auto getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const -> CalypPixel;
/**
* Set pixel value at coordinates to a given value
@@ -488,9 +494,9 @@ public:
void copyTo( const CalypFrame& other, unsigned x, unsigned y ) const;
void copyTo( const CalypFrame* other, unsigned x, unsigned y ) const;
void frameFromBuffer( const std::vector<ClpByte>&, int, unsigned long );
void frameFromBuffer( const std::vector<ClpByte>&, int );
void frameToBuffer( std::vector<ClpByte>&, int ) const;
void frameFromBuffer( std::span<const ClpByte>, int iEndianness, std::uint64_t uiBuffSize );
void frameFromBuffer( std::span<const ClpByte>, int iEndianness );
void frameToBuffer( std::span<ClpByte>, int iEndianness ) const;
void fillRGBBuffer( std::optional<std::size_t> channel ) const;
void fillRGBBuffer() const;
@@ -516,24 +522,24 @@ public:
};
void calcHistogram();
unsigned int getMinimumPelValue( unsigned channel ) const;
unsigned int getMaximumPelValue( unsigned channel ) const;
auto getMinimumPelValue( unsigned channel ) const -> unsigned int;
auto getMaximumPelValue( unsigned channel ) const -> unsigned int;
unsigned int getMaximum( unsigned channel ) const;
unsigned int getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const;
double getMean( unsigned channel, unsigned int start, unsigned int end ) const;
int getMedian( unsigned channel, unsigned int start, unsigned int end ) const;
double getStdDev( unsigned channel, unsigned int start, unsigned int end ) const;
double getHistogramValue( unsigned channel, unsigned int bin ) const;
unsigned int getNEBins( unsigned channel ) const;
int getNumHistogramSegment() const;
double getEntropy( unsigned channel, unsigned int start, unsigned int end ) const;
auto getMaximum( unsigned channel ) const -> unsigned int;
auto getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end ) const -> unsigned int;
auto getMean( unsigned channel, unsigned int start, unsigned int end ) const -> double;
auto getMedian( unsigned channel, unsigned int start, unsigned int end ) const -> int;
auto getStdDev( unsigned channel, unsigned int start, unsigned int end ) const -> double;
auto getHistogramValue( unsigned channel, unsigned int bin ) const -> double;
auto getNEBins( unsigned channel ) const -> unsigned int;
auto getNumHistogramSegment() const -> int;
auto getEntropy( unsigned channel, unsigned int start, unsigned int end ) const -> double;
/**
* interface with OpenCV lib
*/
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const;
bool fromMat( cv::Mat& cvMat, int iChannel = -1 );
auto toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const -> bool;
auto fromMat( cv::Mat& cvMat, int iChannel = -1 ) -> bool;
/**
* \ingroup CalypFrameGrp
@@ -553,18 +559,18 @@ public:
NUMBER_METRICS,
};
static std::vector<std::string> supportedQualityMetricsList();
static std::vector<std::string> supportedQualityMetricsUnitsList();
double getQuality( int Metric, CalypFrame* Org, unsigned int component );
double getMSE( CalypFrame* Org, unsigned int component );
double getPSNR( CalypFrame* Org, unsigned int component );
double getSSIM( CalypFrame* Org, unsigned int component );
double getWSPNR( CalypFrame* Org, unsigned int component );
static auto supportedQualityMetricsList() -> std::vector<std::string>;
static auto supportedQualityMetricsUnitsList() -> std::vector<std::string>;
auto getQuality( int metric, CalypFrame* org, unsigned int component ) -> double;
auto getMSE( CalypFrame* org, unsigned int component ) -> double;
auto getPSNR( CalypFrame* org, unsigned int component ) -> double;
auto getSSIM( CalypFrame* org, unsigned int component ) -> double;
auto getWSPNR( CalypFrame* org, unsigned int component ) -> double;
/** @} */
private:
class CalypFramePrivate;
std::unique_ptr<CalypFramePrivate> d;
struct CalypFramePrivate;
std::unique_ptr<CalypFramePrivate> m_d;
};
#endif // __CALYPFRAME_H__
+2 -17
View File
@@ -40,18 +40,6 @@
#include "CalypFrame.h"
#include "CalypOptions.h"
#define REGISTER_CLASS_MAKER( X ) \
extern "C" CalypModulePtr Maker() { return std::make_unique<X>(); }
#define REGISTER_CLASS_FACTORY( X ) \
public: \
X( const X& buffer ) \
noexcept = delete; \
X( X&& buffer ) \
noexcept = delete; \
auto operator=( const X& buffer )->X& = delete; \
auto operator=( X&& buffer ) noexcept->X& = delete; \
static CalypModulePtr Create() { return std::make_unique<X>(); }
#define _BASIC_MODULE_API_2_CHECK_ \
if( apcFrameList.size() != m_uiNumberOfFrames ) \
return false; \
@@ -204,10 +192,7 @@ public:
void destroy();
// API using OpenCV
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList )
{
return nullptr;
};
virtual cv::Mat* create_using_opencv( const std::vector<Mat>& apcFrameList ) { return nullptr; };
virtual Mat* process_using_opencv( const std::vector<Mat>& apcFrameList ) = 0;
virtual void destroy_using_opencv(){};
@@ -220,7 +205,7 @@ protected:
using CalypModulePtr = std::unique_ptr<CalypModuleIf>;
template <typename T>
class CalypModuleInstace
class CalypModuleInstance
{
public:
static CalypModulePtr Create() { return std::make_unique<T>(); }
+51 -73
View File
@@ -24,153 +24,130 @@
#include <algorithm>
#include <cassert>
#include <memory>
#include <numeric>
#include "CalypFrame.h"
#include "PixelFormats.h"
#include "config.h"
namespace
{
constexpr auto kMinPixelValue{ 0 };
constexpr auto kMaxPixelValue{ 255 };
static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB )
constexpr void yuvToRgb( int iY, int iU, int iV, int& iR, int& iG, int& iB )
{
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
iR = std::clamp( iY + ( ( 1436 * ( iV - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
iG = std::clamp( iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 ), kMinPixelValue,
kMaxPixelValue ); // NOLINT
iB = std::clamp( iY + ( ( 1812 * ( iU - 128 ) ) >> 10 ), kMinPixelValue, kMaxPixelValue ); // NOLINT
}
static inline void rgbToYuv( const int& iR, const int& iG, const int& iB, int& iY, int& iU, int& iV )
constexpr void rgbToYuv( int iR, int iG, int iB, int& iY, int& iU, int& iV )
{
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000; // NOLINT
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772; // NOLINT
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402; // NOLINT
}
} // namespace
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0 )
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0 ) : m_colorSpace( colorSpace )
{
m_colorSpace = ColorSpace;
m_pelComp[0] = c0;
}
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 )
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 ) : m_colorSpace( colorSpace )
{
m_colorSpace = ColorSpace;
m_pelComp[0] = c0;
m_pelComp[1] = c1;
m_pelComp[2] = c2;
}
CalypPixel::CalypPixel( const int ColorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 )
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 )
: m_colorSpace( colorSpace )
{
m_colorSpace = ColorSpace;
m_pelComp[0] = c0;
m_pelComp[1] = c1;
m_pelComp[2] = c2;
m_pelComp[3] = c3;
}
CalypPixel& CalypPixel::operator+=( const CalypPixel& in )
auto CalypPixel::operator+=( const CalypPixel& in ) -> CalypPixel&
{
assert( in.colorSpace() == m_colorSpace );
const auto& other_comp = in.components();
std::transform( other_comp.begin(),
other_comp.end(),
m_pelComp.begin(),
m_pelComp.begin(),
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs + rhs; } );
return *this;
}
CalypPixel& CalypPixel::operator-=( const CalypPixel& in )
auto CalypPixel::operator-=( const CalypPixel& in ) -> CalypPixel&
{
assert( in.colorSpace() == m_colorSpace );
const auto& other_comp = in.components();
std::transform( other_comp.begin(),
other_comp.end(),
m_pelComp.begin(),
m_pelComp.begin(),
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs - rhs; } );
return *this;
}
CalypPixel& CalypPixel::operator*=( const double op )
auto CalypPixel::operator*=( double op ) -> CalypPixel&
{
std::transform( m_pelComp.begin(),
m_pelComp.end(),
m_pelComp.begin(),
[&op]( auto& p1 ) { return p1 * op; } );
std::ranges::transform( m_pelComp, m_pelComp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
return *this;
}
CalypPixel CalypPixel::operator+( const CalypPixel& in ) const
auto CalypPixel::operator+( const CalypPixel& in ) const -> CalypPixel
{
assert( in.colorSpace() == m_colorSpace );
const auto& other_comp = in.components();
CalypPixel result{ m_colorSpace };
std::transform( other_comp.begin(),
other_comp.end(),
m_pelComp.begin(),
result.components().begin(),
[]( auto& p1, auto& p2 ) { return p1 + p2; } );
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
[]( auto& lhs, auto& rhs ) { return lhs + rhs; } );
return result;
}
CalypPixel CalypPixel::operator-( const CalypPixel& in ) const
auto CalypPixel::operator-( const CalypPixel& input ) const -> CalypPixel
{
assert( in.colorSpace() == m_colorSpace );
const auto& other_comp = in.components();
assert( input.colorSpace() == m_colorSpace );
const auto& other_comp = input.components();
CalypPixel result{ m_colorSpace };
std::transform( other_comp.begin(),
other_comp.end(),
m_pelComp.begin(),
result.components().begin(),
[]( auto& p1, auto& p2 ) { return p1 - p2; } );
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
[]( auto& lhs, auto& rhs ) { return lhs - rhs; } );
return result;
}
CalypPixel CalypPixel::operator*( const double op ) const
auto CalypPixel::operator*( double op ) const -> CalypPixel
{
CalypPixel result{ m_colorSpace };
auto& comp = result.components();
std::transform( comp.begin(),
comp.end(),
comp.begin(),
[&op]( auto& p1 ) { return p1 * op; } );
std::ranges::transform( comp, comp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
return result;
}
auto CalypPixel::operator==( const CalypPixel& other ) const -> bool
{
return colorSpace() == other.colorSpace() &&
std::equal( m_pelComp.begin(), m_pelComp.end(), other.components().begin() );
return colorSpace() == other.colorSpace() && std::ranges::equal( m_pelComp, other.components() );
}
std::ostream& operator<<( std::ostream& os, const CalypPixel& p )
auto operator<<( std::ostream& stream, const CalypPixel& pixel ) -> std::ostream&
{
#ifdef CLP_DEBUG
if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
{
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
}
else
{
os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
}
#endif
return os;
// #ifdef CLP_DEBUG
// if( p.colorSpace() == CLP_COLOR_RGB || p.colorSpace() == CLP_COLOR_YUV )
// {
// os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
// }
// else
// {
// os << "(" << p[0] << ", " << p[1] << ", " << p[2] << ", " << p[3] << ")";
// }
// #endif
return stream;
}
CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
auto CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel
{
if( m_colorSpace == eOutputSpace )
return *this;
if( m_colorSpace == eOutputSpace ) return *this;
int outA = 0;
int outB = 0;
int outC = 0;
int outD = 0;
int outA{ 0 };
int outB{ 0 };
int outC{ 0 };
int outD{ 0 };
if( m_colorSpace == CLP_COLOR_YUV )
{
switch( eOutputSpace )
@@ -203,5 +180,6 @@ CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const
break;
}
}
return CalypPixel( eOutputSpace, outA, outB, outC, outD );
return { eOutputSpace, static_cast<ClpPel>( outA ), static_cast<ClpPel>( outB ), static_cast<ClpPel>( outC ),
static_cast<ClpPel>( outD ) };
}
+46 -46
View File
@@ -113,7 +113,8 @@ struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuf
std::vector<std::unique_ptr<CalypFrame>> framePool;
std::size_t bufferIdx{ 0 };
CalypStreamFrameBuffer( std::size_t size, unsigned int width, unsigned int height, ClpPixelFormats pelFormat, unsigned int bitsPixel, bool hasNegative )
CalypStreamFrameBuffer( std::size_t size, unsigned int width, unsigned int height, ClpPixelFormats pelFormat,
unsigned int bitsPixel, bool hasNegative )
{
framePool.reserve( size );
for( std::size_t i = 0; i < size; i++ )
@@ -136,10 +137,8 @@ struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuf
auto oldSize = framePool.size();
for( std::size_t i = oldSize; i < newSize; i++ )
{
framePool.push_back( std::make_unique<CalypFrame>( framePool[0]->getWidth(),
framePool[0]->getHeight(),
framePool[0]->getPelFormat(),
framePool[0]->getBitsPel(),
framePool.push_back( std::make_unique<CalypFrame>( framePool[0]->getWidth(), framePool[0]->getHeight(),
framePool[0]->getPelFormat(), framePool[0]->getBitsPel(),
framePool[0]->getHasNegativeValues() ) );
}
bufferIdx += newSize - oldSize;
@@ -191,13 +190,11 @@ public:
iCurrFrameNum = -1;
}
~CalypStreamPrivate()
{
close();
}
~CalypStreamPrivate() { close(); }
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness, bool hasNegative,
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate, bool forceRaw,
CalypStream::Type type )
{
if( isInit )
{
@@ -256,12 +253,9 @@ public:
std::size_t bufferSize = isInput ? 6 : 1;
try
{
frameBuffer = std::make_shared<CalypStreamFrameBuffer>( bufferSize,
handler->m_uiWidth,
handler->m_uiHeight,
handler->m_iPixelFormat,
handler->m_uiBitsPerPixel,
hasNegative );
frameBuffer =
std::make_shared<CalypStreamFrameBuffer>( bufferSize, handler->m_uiWidth, handler->m_uiHeight,
handler->m_iPixelFormat, handler->m_uiBitsPerPixel, hasNegative );
}
catch( CalypFailure& e )
{
@@ -339,7 +333,8 @@ public:
{
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
if( !isInit || streamType != CalypStream::Type::Input || handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
if( !isInit || streamType != CalypStream::Type::Input ||
handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
return false;
if( bLoadAll )
@@ -376,10 +371,7 @@ std::vector<std::string> CalypStreamFormat::getExts()
return arrayExt;
}
CalypStream::CalypStream()
: d{ std::make_unique<CalypStreamPrivate>() }
{
}
CalypStream::CalypStream() : d{ std::make_unique<CalypStreamPrivate>() } {}
CalypStream::~CalypStream() = default;
@@ -392,8 +384,9 @@ std::string CalypStream::getCodecName() const
return !d->handler ? "" : d->handler->getCodecName();
}
bool CalypStream::open( std::string filename, std::string resolution, std::string input_format_name, unsigned int bitsPel, int endianness, bool hasNegative,
unsigned int frame_rate, CalypStream::Type type )
bool CalypStream::open( std::string filename, std::string resolution, std::string input_format_name,
unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
CalypStream::Type type )
{
unsigned int width = 0;
unsigned int height = 0;
@@ -412,25 +405,31 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
{
return false;
}
return d->open( std::move( filename ), width, height, *input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
return d->open( std::move( filename ), width, height, *input_format, bitsPel, endianness, hasNegative, frame_rate,
false, type );
}
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
unsigned int frame_rate, CalypStream::Type type )
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, unsigned int frame_rate, CalypStream::Type type )
{
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, false, type );
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, false,
type );
}
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness, bool hasNegative,
unsigned int frame_rate, CalypStream::Type type )
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
CalypStream::Type type )
{
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, false, type );
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate,
false, type );
}
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
unsigned int frame_rate, bool forceRaw, CalypStream::Type type )
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, unsigned int frame_rate, bool forceRaw,
CalypStream::Type type )
{
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, forceRaw, type );
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, forceRaw,
type );
}
bool CalypStream::supportsFormatConfiguration()
@@ -454,8 +453,9 @@ bool CalypStream::reload()
d->handler->calculateFrameNumber();
d->handler->configureBuffer( *refFrame );
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat == ClpPixelFormats::Invalid ||
d->handler->m_uiBitsPerPixel == 0 || d->handler->m_uiTotalNumberFrames == 0 )
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 ||
d->handler->m_iPixelFormat == ClpPixelFormats::Invalid || d->handler->m_uiBitsPerPixel == 0 ||
d->handler->m_uiTotalNumberFrames == 0 )
{
return false;
}
@@ -509,8 +509,8 @@ long CalypStream::getCurrFrameNum() const
return d->iCurrFrameNum;
}
void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
unsigned int& rFrameRate ) const
void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat,
unsigned int& rBitsPerPel, int& rEndianness, unsigned int& rFrameRate ) const
{
if( d->isInit )
{
@@ -570,7 +570,14 @@ void CalypStream::loadAll()
d->iCurrFrameNum = 0;
}
std::unique_ptr<CalypFrame> CalypStream::getCurrFrame( std::unique_ptr<CalypFrame> buffer )
auto CalypStream::getCurrFrameAsset() -> std::shared_ptr<CalypFrame>
{
if( d->bLoadAll )
return d->frameFifo[d->iCurrFrameNum];
return d->frameFifo.front();
}
auto CalypStream::getCurrFrame( std::unique_ptr<CalypFrame> buffer ) const -> std::unique_ptr<CalypFrame>
{
if( buffer == nullptr )
buffer = std::make_unique<CalypFrame>( *d->frameFifo.front() );
@@ -579,13 +586,6 @@ std::unique_ptr<CalypFrame> CalypStream::getCurrFrame( std::unique_ptr<CalypFram
return buffer;
}
auto CalypStream::getCurrFrameAsset() -> std::shared_ptr<CalypFrame>
{
if( d->bLoadAll )
return d->frameFifo[d->iCurrFrameNum];
return d->frameFifo.front();
}
auto CalypStream::getCurrFrame() -> CalypFrame*
{
if( d->bLoadAll )
+11 -31
View File
@@ -88,34 +88,14 @@ public:
std::string getFormatName() const;
std::string getCodecName() const;
bool open( std::string filename,
std::string resolution,
std::string input_format,
unsigned int bitsPel,
int endianness,
bool hasNegative,
unsigned int frame_rate,
Type type );
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format, unsigned int bitsPel, int endianness,
unsigned int frame_rate, CalypStream::Type type );
bool open( std::string filename,
unsigned int width,
unsigned int height,
ClpPixelFormats input_format,
unsigned int bitsPel,
int endianness,
bool hasNegative,
unsigned int frame_rate,
Type type );
bool open( std::string filename,
unsigned int width,
unsigned int height,
ClpPixelFormats input_format,
unsigned int bitsPel,
int endianness,
unsigned int frame_rate,
bool forceRaw,
Type type );
bool open( std::string filename, std::string resolution, std::string input_format, unsigned int bitsPel,
int endianness, bool hasNegative, unsigned int frame_rate, Type type );
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, unsigned int frame_rate, CalypStream::Type type );
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate, Type type );
bool open( std::string filename, unsigned int width, unsigned int height, ClpPixelFormats input_format,
unsigned int bitsPel, int endianness, unsigned int frame_rate, bool forceRaw, Type type );
bool supportsFormatConfiguration();
bool reload();
@@ -129,15 +109,15 @@ public:
int getEndianess() const;
long getCurrFrameNum() const;
double getFrameRate() const;
void getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
unsigned int& rFrameRate ) const;
void getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPixelFormats& rInputFormat, unsigned int& rBitsPerPel,
int& rEndianness, unsigned int& rFrameRate ) const;
auto hasNextFrame() -> bool;
auto hasWritingSlot() -> bool;
void loadAll();
std::unique_ptr<CalypFrame> getCurrFrame( std::unique_ptr<CalypFrame> buffer );
auto getCurrFrameAsset() -> std::shared_ptr<CalypFrame>;
auto getCurrFrame( std::unique_ptr<CalypFrame> buffer ) const -> std::unique_ptr<CalypFrame>;
auto getCurrFrame() -> CalypFrame*;
bool isEof();
bool setNextFrame();
+29 -26
View File
@@ -35,6 +35,10 @@
#define FF_USER_CODEC_PARAM
#endif
#if( LIBAVCODEC_VERSION_MAJOR >= 59 && LIBAVFORMAT_VERSION_MAJOR >= 59 )
#define FF_API_LAVF_AVCTX
#endif
std::vector<CalypStreamFormat> StreamHandlerLibav::supportedReadFormats()
{
INI_REGIST_CALYP_SUPPORTED_FMT;
@@ -123,7 +127,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
#else
int codecId = m_cStream->codec->codec_id;
#endif
AVCodec* dec = avcodec_find_decoder( AVCodecID( codecId ) );
auto* dec = avcodec_find_decoder( AVCodecID( codecId ) );
if( !dec )
{
std::cout << "Failed to find video coded" << std::endl;
@@ -150,7 +154,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
if( avcodec_open2( m_cCodedCtx, dec, NULL ) < 0 )
{
std::cout << "Failed to open video coded" << std::endl;
std::cout << "Failed to open video codec" << std::endl;
return false;
}
@@ -200,9 +204,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
m_iPixelFormat = ClpPixelFormats::Invalid;
m_bNative = false;
auto found_fmt = std::find_if( g_CalypPixFmtDescriptorsMap.begin(), g_CalypPixFmtDescriptorsMap.end(),
[auxPixFmt]( const auto& fmt ) {
return fmt.second.ffmpegPelFormat == auxPixFmt;
} );
[auxPixFmt]( const auto& fmt ) { return fmt.second.ffmpegPelFormat == auxPixFmt; } );
if( found_fmt != g_CalypPixFmtDescriptorsMap.end() )
{
m_bNative = true;
@@ -272,8 +274,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
AVPixelFormat newAvFmt = AVPixelFormat( g_CalypPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat );
/* create scaling context */
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ),
m_uiWidth, m_uiHeight, newAvFmt,
m_ScalerCtx = sws_getContext( m_uiWidth, m_uiHeight, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, newAvFmt,
SWS_BILINEAR, NULL, NULL, NULL );
m_cConvertedFrame = av_frame_alloc();
@@ -283,8 +284,9 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
return false;
}
if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize,
m_uiWidth, m_uiHeight, newAvFmt, 16 ) < 0 )
auto alloc_error =
av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize, m_uiWidth, m_uiHeight, newAvFmt, 16 );
if( alloc_error < 0 )
{
closeHandler();
return false;
@@ -296,10 +298,10 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
m_uiFrameBufferSize = av_image_get_buffer_size( AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
/* initialize packet, set data to NULL, let the demuxer fill it */
av_init_packet( &m_cPacket );
m_cPacket.data = NULL;
m_cPacket.size = 0;
m_cOrgPacket = m_cPacket;
m_cPacket = av_packet_alloc();
m_cPacket->data = NULL;
m_cPacket->size = 0;
m_cOrgPacket = *m_cPacket;
m_bHasStream = true;
return true;
@@ -316,6 +318,7 @@ void StreamHandlerLibav::closeHandler()
avformat_close_input( &m_cFmtCtx );
av_free( m_cFrame );
av_packet_free( &m_cPacket );
}
m_bHasStream = false;
}
@@ -373,13 +376,13 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
bGotFrame = 1;
}
#else
if( m_cPacket.stream_index == m_iStreamIdx )
if( m_cPacket->stream_index == m_iStreamIdx )
{
if( ( iRet = avcodec_decode_video2( m_cCodedCtx, m_cFrame, &bGotFrame, &m_cPacket ) ) < 0 )
if( ( iRet = avcodec_decode_video2( m_cCodedCtx, m_cFrame, &bGotFrame, m_cPacket ) ) < 0 )
return false;
m_cPacket.data += iRet;
m_cPacket.size -= iRet;
if( m_cPacket.size <= 0 )
m_cPacket->data += iRet;
m_cPacket->size -= iRet;
if( m_cPacket->size <= 0 )
{
bReadPkt = true;
av_packet_unref( &m_cOrgPacket );
@@ -392,7 +395,7 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
{
bReadPkt = false;
av_packet_unref( &m_cOrgPacket );
if( ( iRet = av_read_frame( m_cFmtCtx, &m_cPacket ) ) < 0 )
if( ( iRet = av_read_frame( m_cFmtCtx, m_cPacket ) ) < 0 )
{
if( iRet == AVERROR_EOF )
{
@@ -401,10 +404,10 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
}
return false;
}
m_cOrgPacket = m_cPacket;
m_cOrgPacket = *m_cPacket;
#ifdef FF_SEND_RECEIVE_API
if( m_cPacket.stream_index == m_iStreamIdx )
if( ( iRet = avcodec_send_packet( m_cCodedCtx, &m_cPacket ) ) < 0 )
if( m_cPacket->stream_index == m_iStreamIdx )
if( ( iRet = avcodec_send_packet( m_cCodedCtx, m_cPacket ) ) < 0 )
return false;
#endif
}
@@ -415,13 +418,13 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
AVFrame* decFrame = m_cFrame;
if( !m_bNative )
{
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0,
decFrame->height, (uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
sws_scale( m_ScalerCtx, (const uint8_t* const*)decFrame->data, decFrame->linesize, 0, decFrame->height,
(uint8_t* const*)m_cConvertedFrame->data, m_cConvertedFrame->linesize );
decFrame = m_cConvertedFrame;
}
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data,
decFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data, decFrame->linesize,
AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
pcFrame.frameFromBuffer( m_pStreamBuffer, m_iEndianness );
m_uiCurrFrameFileIdx++;
+2 -1
View File
@@ -40,6 +40,7 @@
#endif
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavutil/imgutils.h>
@@ -87,7 +88,7 @@ private:
int m_ffPixFmt;
AVFrame* m_cFrame;
AVPacket m_cOrgPacket;
AVPacket m_cPacket;
AVPacket* m_cPacket;
bool m_bHasStream;
+8 -6
View File
@@ -46,8 +46,7 @@ std::vector<CalypStreamFormat> StreamHandlerRaw::supportedWriteFormats()
END_REGIST_CALYP_SUPPORTED_FMT;
}
StreamHandlerRaw::StreamHandlerRaw()
: CalypStreamHandlerIf{ true }
StreamHandlerRaw::StreamHandlerRaw() : CalypStreamHandlerIf{ true }
{
m_pchHandlerName = "RawVideo";
}
@@ -55,9 +54,9 @@ StreamHandlerRaw::StreamHandlerRaw()
bool StreamHandlerRaw::openHandler( std::string strFilename, bool bInput )
{
m_bIsInput = bInput;
m_pFile = NULL;
m_pFile = nullptr;
m_pFile = fopen( strFilename.c_str(), bInput ? "rb" : "wb" );
if( m_pFile == NULL )
if( m_pFile == nullptr )
{
return false;
}
@@ -73,6 +72,7 @@ void StreamHandlerRaw::closeHandler()
{
if( m_pFile )
fclose( m_pFile );
m_pFile = nullptr;
}
bool StreamHandlerRaw::configureBuffer( const CalypFrame& pcFrame )
@@ -107,7 +107,8 @@ bool StreamHandlerRaw::read( CalypFrame& pcFrame )
{
if( !m_pFile || m_pStreamBuffer.empty() || m_uiNBytesPerFrame == 0 )
return false;
unsigned long long int processed_bytes = fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
unsigned long long int processed_bytes =
fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
if( processed_bytes != m_uiNBytesPerFrame )
return false;
m_uiCurrFrameFileIdx++;
@@ -118,7 +119,8 @@ bool StreamHandlerRaw::read( CalypFrame& pcFrame )
bool StreamHandlerRaw::write( const CalypFrame& pcFrame )
{
pcFrame.frameToBuffer( m_pStreamBuffer, m_iEndianness );
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
unsigned long long int processed_bytes =
fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
if( processed_bytes != m_uiNBytesPerFrame )
return false;
return true;
+1 -1
View File
@@ -14,5 +14,5 @@ SET(Calyp_Lib_Catch2_Tests_SRCS
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS})
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2)
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2WithMain)
CATCH_DISCOVER_TESTS(CalypLibCatch2Tests)
+1 -1
View File
@@ -22,7 +22,7 @@
* \brief CalypFrame general tests
*/
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include "CalypFrame.h"
+1 -1
View File
@@ -23,4 +23,4 @@
*/
#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
+27 -26
View File
@@ -22,7 +22,7 @@
* \brief CalypStream general tests
*/
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <filesystem>
#include <iostream>
#include <variant>
@@ -51,7 +51,8 @@ TEST_CASE( "Can open a YUV 420p file", "CalypStream" )
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
@@ -76,11 +77,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
auto common_checks = []( auto& stream ) {
return stream.getWidth() == kWidth &&
stream.getHeight() == kHeight &&
stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" &&
stream.getCodecName() == "Raw Video" &&
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
SECTION( "YUV420p" )
@@ -90,7 +88,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -106,7 +105,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -122,7 +122,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -138,7 +139,8 @@ TEST_CASE( "Can open a YUV file", "CalypStream" )
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -157,11 +159,8 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
auto common_checks = []( auto& stream ) {
return stream.getWidth() == kWidth &&
stream.getHeight() == kHeight &&
stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" &&
stream.getCodecName() == "Raw Video" &&
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
SECTION( "RGB24" )
@@ -170,7 +169,8 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
const auto kFilename = getFileTestFilename( "Foreman_352x288_rgb24.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -187,7 +187,8 @@ TEST_CASE( "Can open a RGB file", "CalypStream" )
const auto kFilename = getFileTestFilename( "Foreman_352x288_bgr24.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -205,18 +206,16 @@ TEST_CASE( "Can open a GRAY file", "CalypStream" )
constexpr auto KEndianness{ CLP_INVALID_ENDIANESS };
auto common_checks = []( auto& stream ) {
return stream.getWidth() == kWidth &&
stream.getHeight() == kHeight &&
stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" &&
stream.getCodecName() == "Raw Video" &&
return stream.getWidth() == kWidth && stream.getHeight() == kHeight && stream.getBitsPerPixel() == kBitsPel &&
stream.getFormatName() == "YUV" && stream.getCodecName() == "Raw Video" &&
stream.getEndianess() == CLP_BIG_ENDIAN;
};
constexpr auto kInputFormat{ ClpPixelFormats::Gray };
const auto kFilename = getFileTestFilename( "Foreman_352x288_gray.yuv" );
REQUIRE( std::filesystem::exists( std::filesystem::path( kFilename ) ) );
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
auto result =
test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, kStreamType );
REQUIRE( result );
CHECK( common_checks( test_stream ) );
const auto* frame = test_stream.getCurrFrame();
@@ -245,7 +244,8 @@ TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
bool result{ false };
try
{
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw,
kStreamType );
}
catch( ... )
{
@@ -260,7 +260,8 @@ TEST_CASE( "Can open .batatas file as RAW video", "CalypStream" )
force_raw = true;
CalypStream test_stream;
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate, force_raw, kStreamType );
auto result = test_stream.open( kFilename, kWidth, kHeight, kInputFormat, kBitsPel, KEndianness, kFrameRate,
force_raw, kStreamType );
REQUIRE( result );
+2 -3
View File
@@ -28,8 +28,7 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class AbsoluteFrameDifference : public CalypModuleIf,
public CalypModuleInstace<AbsoluteFrameDifference>
class AbsoluteFrameDifference : public CalypModuleIf, public CalypModuleInstance<AbsoluteFrameDifference>
{
private:
std::unique_ptr<CalypFrame> m_pcFrameDifference;
@@ -40,4 +39,4 @@ public:
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
};
#endif // __FRAMEDIFFERENCE_H__
#endif // __ABSOLUTEFRAMEDIFFERENCE_H__
+1 -3
View File
@@ -32,10 +32,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class DisparityStereoBM : public CalypModuleIf
class DisparityStereoBM : public CalypModuleIf, public CalypModuleInstance<DisparityStereoBM>
{
REGISTER_CLASS_FACTORY( DisparityStereoBM )
private:
CalypFrame* m_pcDisparityFrame;
int m_uiNumberOfDisparities;
+1 -3
View File
@@ -51,10 +51,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class DisparityStereoSGBM : public CalypModuleIf
class DisparityStereoSGBM : public CalypModuleIf, public CalypModuleInstance<DisparityStereoSGBM>
{
REGISTER_CLASS_FACTORY( DisparityStereoSGBM )
private:
CalypFrame* m_pcDisparityFrame;
bool m_bUseHH;
+1 -3
View File
@@ -32,10 +32,8 @@
// CalypLib
#include "CalypModuleIf.h"
class DisparityStereoVar : public CalypModuleIf
class DisparityStereoVar : public CalypModuleIf, public CalypModuleInstance<DisparityStereoVar>
{
REGISTER_CLASS_FACTORY( DisparityStereoVar )
private:
CalypFrame* m_pcDisparityFrame;
cv::StereoVar m_cStereoVar;
+1 -2
View File
@@ -32,8 +32,7 @@
#include <opencv2/core/core.hpp>
#include <opencv2/saliency.hpp>
class DummyOpencvModule : public CalypOpenCVModuleIf,
public CalypModuleInstace<DummyOpencvModule>
class DummyOpencvModule : public CalypOpenCVModuleIf, public CalypModuleInstance<DummyOpencvModule>
{
using Mat = cv::Mat;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class EightBitsSampling : public CalypModuleIf
class EightBitsSampling : public CalypModuleIf, public CalypModuleInstance<EightBitsSampling>
{
REGISTER_CLASS_FACTORY( EightBitsSampling )
private:
int m_iNumberOfBits;
int m_iBitSifting;
+3 -6
View File
@@ -44,8 +44,7 @@ public:
CalypFrame* filterComponent( CalypFrame* InputFrame, int Component );
};
class FilterComponentLuma : public FilterComponentModule,
public CalypModuleInstace<FilterComponentLuma>
class FilterComponentLuma : public FilterComponentModule, public CalypModuleInstance<FilterComponentLuma>
{
public:
FilterComponentLuma();
@@ -54,8 +53,7 @@ public:
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
};
class FilterComponentChromaU : public FilterComponentModule,
public CalypModuleInstace<FilterComponentChromaU>
class FilterComponentChromaU : public FilterComponentModule, public CalypModuleInstance<FilterComponentChromaU>
{
public:
FilterComponentChromaU();
@@ -64,8 +62,7 @@ public:
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
};
class FilterComponentChromaV : public FilterComponentModule,
public CalypModuleInstace<FilterComponentChromaV>
class FilterComponentChromaV : public FilterComponentModule, public CalypModuleInstance<FilterComponentChromaV>
{
public:
FilterComponentChromaV();
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameBinarization : public CalypModuleIf
class FrameBinarization : public CalypModuleIf, public CalypModuleInstance<FrameBinarization>
{
REGISTER_CLASS_FACTORY( FrameBinarization )
private:
CalypFrame* m_pcBinFrame;
unsigned int m_uiThreshold;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameConcatenation : public CalypModuleIf
class FrameConcatenation : public CalypModuleIf, public CalypModuleInstance<FrameConcatenation>
{
REGISTER_CLASS_FACTORY( FrameConcatenation )
private:
CalypFrame* m_pcProcessedFrame;
int m_iShiftHor;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameCrop : public CalypModuleIf
class FrameCrop : public CalypModuleIf, public CalypModuleInstance<FrameCrop>
{
REGISTER_CLASS_FACTORY( FrameCrop )
private:
CalypFrame* m_pcCropedFrame;
unsigned int m_uiXPosition;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameDifference : public CalypModuleIf
class FrameDifference : public CalypModuleIf, public CalypModuleInstance<FrameDifference>
{
REGISTER_CLASS_FACTORY( FrameDifference )
private:
unsigned int m_uiBitsPixel;
unsigned int m_uiSumOperation;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameMask : public CalypModuleIf
class FrameMask : public CalypModuleIf, public CalypModuleInstance<FrameMask>
{
REGISTER_CLASS_FACTORY( FrameMask )
private:
int m_iWeight;
CalypFrame* m_pcFrameProcessed;
+1 -2
View File
@@ -36,9 +36,8 @@
* @}
*/
class FrameResampling : public CalypModuleIf
class FrameResampling : public CalypModuleIf, public CalypModuleInstance<FrameResampling>
{
REGISTER_CLASS_FACTORY( FrameResampling )
private:
int m_iWidth;
int m_iHeight;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameRotate : public CalypModuleIf
class FrameRotate : public CalypModuleIf, public CalypModuleInstance<FrameRotate>
{
REGISTER_CLASS_FACTORY( FrameRotate )
private:
int m_iAngle;
CalypFrame* m_pcFrameProcessed;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class FrameShift : public CalypModuleIf
class FrameShift : public CalypModuleIf, public CalypModuleInstance<FrameShift>
{
REGISTER_CLASS_FACTORY( FrameShift )
private:
CalypFrame* m_pcProcessedFrame;
int m_iShiftHor;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class HEVCIntraPrediction : public CalypModuleIf
class HEVCIntraPrediction : public CalypModuleIf, public CalypModuleInstance<HEVCIntraPrediction>
{
REGISTER_CLASS_FACTORY( HEVCIntraPrediction )
private:
CalypFrame* m_pcPredBlock;
unsigned int m_uiMode;
+1 -3
View File
@@ -29,10 +29,8 @@
#include "lib/CalypFrame.h"
#include "lib/CalypModuleIf.h"
class InterFrameVariance : public CalypModuleIf
class InterFrameVariance : public CalypModuleIf, public CalypModuleInstance<InterFrameVariance>
{
REGISTER_CLASS_FACTORY( InterFrameVariance )
private:
CalypFrame* m_pcFrameVariance;
CalypPlane<double> m_pVariance;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class LumaAverage : public CalypModuleIf
class LumaAverage : public CalypModuleIf, public CalypModuleInstance<LumaAverage>
{
REGISTER_CLASS_FACTORY( LumaAverage )
private:
public:
LumaAverage();
+1 -3
View File
@@ -31,10 +31,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class MeasureOpticalFlowDualTVL1 : public CalypModuleIf
class MeasureOpticalFlowDualTVL1 : public CalypModuleIf, public CalypModuleInstance<MeasureOpticalFlowDualTVL1>
{
REGISTER_CLASS_FACTORY( MeasureOpticalFlowDualTVL1 )
private:
bool m_bShowReconstruction;
int m_iStep;
+4 -8
View File
@@ -53,36 +53,32 @@ public:
void destroy();
};
class OpticalFlowDualTVL1 : public OpticalFlowModule
class OpticalFlowDualTVL1 : public OpticalFlowModule, public CalypModuleInstance<OpticalFlowDualTVL1>
{
REGISTER_CLASS_FACTORY( OpticalFlowDualTVL1 )
public:
OpticalFlowDualTVL1();
virtual ~OpticalFlowDualTVL1() {}
bool create( std::vector<CalypFrame*> apcFrameList );
};
class OpticalFlowSparseToDense : public OpticalFlowModule
class OpticalFlowSparseToDense : public OpticalFlowModule, public CalypModuleInstance<OpticalFlowSparseToDense>
{
REGISTER_CLASS_FACTORY( OpticalFlowSparseToDense )
public:
OpticalFlowSparseToDense();
virtual ~OpticalFlowSparseToDense() {}
bool create( std::vector<CalypFrame*> apcFrameList );
};
class OpticalFlowFarneback : public OpticalFlowModule
class OpticalFlowFarneback : public OpticalFlowModule, public CalypModuleInstance<OpticalFlowFarneback>
{
REGISTER_CLASS_FACTORY( OpticalFlowFarneback )
public:
OpticalFlowFarneback();
virtual ~OpticalFlowFarneback() {}
bool create( std::vector<CalypFrame*> apcFrameList );
};
class OpticalDeepFlow : public OpticalFlowModule
class OpticalDeepFlow : public OpticalFlowModule, public CalypModuleInstance<OpticalDeepFlow>
{
REGISTER_CLASS_FACTORY( OpticalDeepFlow )
public:
OpticalDeepFlow();
virtual ~OpticalDeepFlow() {}
+1 -3
View File
@@ -29,10 +29,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class OptimiseDisplay : public CalypModuleIf
class OptimiseDisplay : public CalypModuleIf, public CalypModuleInstance<OptimiseDisplay>
{
REGISTER_CLASS_FACTORY( OptimiseDisplay )
private:
std::unique_ptr<CalypFrame> m_pcOptimisedFrame;
+1 -3
View File
@@ -26,10 +26,8 @@
#include "lib/CalypModuleIf.h"
class SaliencyBasedFiltering : public CalypModuleIf
class SaliencyBasedFiltering : public CalypModuleIf, public CalypModuleInstance<SaliencyBasedFiltering>
{
REGISTER_CLASS_FACTORY( SaliencyBasedFiltering )
private:
std::unique_ptr<CalypFrame> m_pcProcessedFrame;
+3 -4
View File
@@ -65,8 +65,7 @@ public:
* approach. In Computer Vision and Pattern Recognition, 2007.
* CVPR'07. IEEE Conference on, pages 1–8. IEEE, 2007.
*/
class SaliencyDetectionSpectral : public SaliencyDetectionModule,
public CalypModuleInstace<SaliencyDetectionSpectral>
class SaliencyDetectionSpectral : public SaliencyDetectionModule, public CalypModuleInstance<SaliencyDetectionSpectral>
{
using Mat = cv::Mat;
@@ -91,7 +90,7 @@ public:
* In Image and Vision Computing, Vol. 28 Issue 3, pages 391–402. Elsevier, 2010.
*/
class SaliencyDetectionFineGrained : public SaliencyDetectionModule,
public CalypModuleInstace<SaliencyDetectionFineGrained>
public CalypModuleInstance<SaliencyDetectionFineGrained>
{
using Mat = cv::Mat;
@@ -110,7 +109,7 @@ public:
* in proc of IEEE Workshop on Change Detection, 2014
*/
class SaliencyDetectionBinWangApr2014 : public SaliencyDetectionModule,
public CalypModuleInstace<SaliencyDetectionBinWangApr2014>
public CalypModuleInstance<SaliencyDetectionBinWangApr2014>
{
using Mat = cv::Mat;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class SetChromaHalfScale : public CalypModuleIf
class SetChromaHalfScale : public CalypModuleIf, public CalypModuleInstance<SetChromaHalfScale>
{
REGISTER_CLASS_FACTORY( SetChromaHalfScale )
private:
CalypFrame* m_pcProcessedFrame;
+1 -3
View File
@@ -31,13 +31,11 @@
// OpenCV
#include <opencv2/core/core.hpp>
class ShapeDetection : public CalypOpenCVModuleIf,
public CalypModuleInstace<ShapeDetection>
class ShapeDetection : public CalypOpenCVModuleIf, public CalypModuleInstance<ShapeDetection>
{
using Mat = cv::Mat;
private:
bool m_bBinaryMap;
std::unique_ptr<Mat> m_resultImage;
cv::RNG m_rng;
+1 -2
View File
@@ -34,9 +34,8 @@ using cv::Mat;
using cv::Mat_;
using cv::Point;
class ThreeSixtyDownsampling : public CalypModuleIf
class ThreeSixtyDownsampling : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyDownsampling>
{
REGISTER_CLASS_FACTORY( ThreeSixtyDownsampling )
private:
unsigned m_uiDownsampling;
unsigned m_uiX0;
+1 -3
View File
@@ -43,10 +43,8 @@ struct ClpVideoFPStruct
ClpFaceProperty faces[60];
};
class ThreeSixtyDynamicDownsampling : public CalypModuleIf
class ThreeSixtyDynamicDownsampling : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyDynamicDownsampling>
{
REGISTER_CLASS_FACTORY( ThreeSixtyDynamicDownsampling )
private:
std::string m_arrayInputDefinitionString;
std::string m_arrayOutputDefinitionString;
+1 -3
View File
@@ -27,10 +27,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class ThreeSixtyFaceConcatenation : public CalypModuleIf
class ThreeSixtyFaceConcatenation : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyFaceConcatenation>
{
REGISTER_CLASS_FACTORY( ThreeSixtyFaceConcatenation )
private:
std::unique_ptr<CalypFrame> m_pcConcatenatedFaces;
unsigned m_uiProjectionType;
+1 -3
View File
@@ -27,10 +27,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class ThreeSixtyFaceExtraction : public CalypModuleIf
class ThreeSixtyFaceExtraction : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyFaceExtraction>
{
REGISTER_CLASS_FACTORY( ThreeSixtyFaceExtraction )
private:
std::unique_ptr<CalypFrame> m_pcFrameExtractionFrame;
std::unique_ptr<CalypFrame> m_pcTmpFrame;
+8 -29
View File
@@ -43,8 +43,7 @@ ThreeSixtyNxN::ThreeSixtyNxN()
m_pchModuleLongName = "ERP to NxN";
m_pchModuleTooltip = "Downsampling ERP to NxN";
m_uiNumberOfFrames = 1;
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying |
ClpModuleFeature::Options;
m_uiModuleRequirements = ClpModuleFeature::SkipWhilePlaying | ClpModuleFeature::Options;
m_cModuleOptions.addOptions() /**/
( "Downsampling", m_uiDownsampling, "ERP to NxN (0 for up, 1 for down and 2 for recon) [1]" ) /**/
@@ -60,11 +59,13 @@ bool ThreeSixtyNxN::create( std::vector<CalypFrame*> apcFrameList )
m_uiDownsampling = m_uiDownsampling > 2 ? 1 : m_uiDownsampling;
if( m_uiDownsampling == 0 )
{
m_pcOutputFrame = new CalypFrame( 2 * apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
m_pcOutputFrame = new CalypFrame( 2 * apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(),
apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
}
else
{
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(),
apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
}
return true;
@@ -73,23 +74,18 @@ bool ThreeSixtyNxN::create( std::vector<CalypFrame*> apcFrameList )
#define WIDTH_TRIM_START_POINT 0.0
#define WIDTH_FINAL 1.0
//#define CLAMP8BITS( in ) ( uint8_t )( ( in > 255 ? 255 : in < 0 ? 0 : in ) + 0.5 )
// #define CLAMP8BITS( in ) ( uint8_t )( ( in > 255 ? 255 : in < 0 ? 0 : in ) + 0.5 )
#define CLAMP_RANGE( X, MIN, MAX ) ( ( X ) < MIN ? MIN : ( ( X ) > MAX ? MAX : X ) )
#define CIRCULAR( a, b ) ( ( ( a < 0 ? b : 0 ) + ( a % b ) ) % b )
#define PI 3.14159265358979323846264338327950288419716939937510
#define s60 0.8660254037844386467637231707529361834714026269051
#define s45 0.7071067811865475244008443621048490392848359376884
//interpolação Lanczos3 360
// interpolação Lanczos3 360
static inline ClpPel interpol_lanczos3( ClpPel* image, double x, int N, int max_value )
{
static const double cs[][2] = {
{ 1, 0 },
{ -0.5, -s60 },
{ -0.5, s60 },
{ 1, 0 },
{ -0.5, -s60 },
{ -0.5, s60 },
{ 1, 0 }, { -0.5, -s60 }, { -0.5, s60 }, { 1, 0 }, { -0.5, -s60 }, { -0.5, s60 },
};
double sum_coeffs = 0, sum = 0, coeffs[6];
@@ -117,23 +113,6 @@ static inline ClpPel interpol_lanczos3( ClpPel* image, double x, int N, int max_
return CLAMP_RANGE( sum, 0, max_value );
}
//interpolação cúbica 360
static inline ClpPel interpol_cub( ClpPel* image, double x, int N, int max_value )
{
int x_int = floor( x );
x -= x_int;
bool n0 = x > 0;
ClpPel x1 = *( image + CIRCULAR( x_int, N ) );
if( !n0 )
return x1;
ClpPel x2 = *( image + CIRCULAR( x_int + n0, N ) );
ClpPel x0 = *( image + CIRCULAR( x_int - 1, N ) );
ClpPel x3 = *( image + CIRCULAR( x_int + n0 + 1, N ) );
ClpPel out = CLAMP_RANGE( x1 - x * ( x0 - x2 + x * ( 2 * x1 - 2 * x0 - x2 + x3 + x * ( x0 - x1 + x2 - x3 ) ) ), 0, max_value ); //cubic
return out;
}
void ThreeSixtyNxN::downsamplingOperation( const CalypFrame* pcInputFrame )
{
for( unsigned ch = 0; ch < m_pcOutputFrame->getNumberChannels(); ch++ )
+1 -2
View File
@@ -34,9 +34,8 @@ using cv::Mat;
using cv::Mat_;
using cv::Point;
class ThreeSixtyNxN : public CalypModuleIf
class ThreeSixtyNxN : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyNxN>
{
REGISTER_CLASS_FACTORY( ThreeSixtyNxN )
private:
unsigned m_uiDownsampling;
CalypFrame* m_pcOutputFrame;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class ThreeSixtySpatialtoTemporal : public CalypModuleIf
class ThreeSixtySpatialtoTemporal : public CalypModuleIf, public CalypModuleInstance<ThreeSixtySpatialtoTemporal>
{
REGISTER_CLASS_FACTORY( ThreeSixtySpatialtoTemporal )
private:
std::unique_ptr<CalypFrame> m_pcTempSpatialFrame;
std::unique_ptr<CalypFrame> m_pcTmpInputFrame;
+1 -3
View File
@@ -28,10 +28,8 @@
// CalypLib
#include "lib/CalypModuleIf.h"
class WeightedPSNR : public CalypModuleIf
class WeightedPSNR : public CalypModuleIf, public CalypModuleInstance<WeightedPSNR>
{
REGISTER_CLASS_FACTORY( WeightedPSNR )
private:
unsigned int m_uiComponent;
+13 -10
View File
@@ -52,8 +52,10 @@ CalypTools::~CalypTools() = default;
void CalypTools::reportStreamInfo( const CalypStream* stream, std::string strPrefix )
{
log( CLP_LOG_INFO, "%sStream name: %s \n", strPrefix.c_str(), stream->getFileName().c_str() );
log( CLP_LOG_INFO, "%sResolution: %dx%d@%d \n", strPrefix.c_str(), stream->getWidth(), stream->getHeight(), stream->getFrameRate() );
log( CLP_LOG_INFO, "%sBits/pel: %d (%s)\n", strPrefix.c_str(), stream->getBitsPerPixel(), stream->getEndianess() == CLP_BIG_ENDIAN ? "BE" : "LE" );
log( CLP_LOG_INFO, "%sResolution: %dx%d@%d \n", strPrefix.c_str(), stream->getWidth(), stream->getHeight(),
stream->getFrameRate() );
log( CLP_LOG_INFO, "%sBits/pel: %d (%s)\n", strPrefix.c_str(), stream->getBitsPerPixel(),
stream->getEndianess() == CLP_BIG_ENDIAN ? "BE" : "LE" );
}
int CalypTools::openInputs()
@@ -104,7 +106,8 @@ int CalypTools::openInputs()
pcStream = new CalypStream;
try
{
if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitsPerPixel, uiEndianness, hasNegativeValues, 1, CalypStream::Type::Input ) )
if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, uiBitsPerPixel, uiEndianness,
hasNegativeValues, 1, CalypStream::Type::Input ) )
{
log( CLP_LOG_ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() );
return -1;
@@ -115,7 +118,8 @@ int CalypTools::openInputs()
}
catch( const char* msg )
{
log( CLP_LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(), msg );
log( CLP_LOG_ERROR, "Cannot open input stream %s with the following error: \n%s\n", inputFileNames[i].c_str(),
msg );
return -1;
}
}
@@ -374,7 +378,8 @@ int CalypTools::Open( int argc, char* argv[] )
try
{
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(),
pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), m_uiOutEndianness, 1, CalypStream::Type::Output );
pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), m_uiOutEndianness, 1,
CalypStream::Type::Output );
log( CLP_LOG_INFO, "Output stream from module!\n" );
reportStreamInfo( pcModStream, "Module Output " );
}
@@ -680,7 +685,8 @@ int CalypTools::ListStatistics()
{
log( CLP_LOG_RESULT, "\x1B[32mInput:\t\t\t%d\x1B[0m\n", input );
log( CLP_LOG_RESULT, "No. Frames:\t\t%d\n", m_apcInputStreams[input]->getFrameNum() );
log( CLP_LOG_RESULT, "Pixels:\t\t\t%d\n", m_apcInputStreams[input]->getHeight() * m_apcInputStreams[input]->getWidth() );
log( CLP_LOG_RESULT, "Pixels:\t\t\t%d\n",
m_apcInputStreams[input]->getHeight() * m_apcInputStreams[input]->getWidth() );
for( unsigned int frame = 0; frame < m_apcInputStreams[input]->getFrameNum(); frame++ )
{
@@ -714,10 +720,7 @@ int CalypTools::ListStatistics()
log( CLP_LOG_RESULT, " Range: " );
for( unsigned channel = 0; channel < currFrame->getNumberChannels(); channel++ )
{
char buffer[14];
sprintf( buffer, "[%d:%d]", min[channel], max[channel] );
log( CLP_LOG_RESULT, "| %13s ", buffer );
log( CLP_LOG_RESULT, "[%d:%d]", min[channel], max[channel] );
}
log( CLP_LOG_RESULT, "|\n" );
+9
View File
@@ -63,6 +63,15 @@ void CalypToolsCmdParser::log( unsigned int level, const char* fmt, ... )
}
}
void CalypToolsCmdParser::log( unsigned int level, std::string log_msg )
{
if( level < m_uiLogLevel )
{
return;
}
std::cout << log_msg;
}
int CalypToolsCmdParser::parseToolsArgs( int argc, char* argv[] )
{
int iRet = 0;
+1
View File
@@ -51,6 +51,7 @@ public:
* @note this function might not be safe in C++ (try to upgrade it)
*/
void log( unsigned int level, const char* fmt, ... );
void log( unsigned int level, std::string log_msg );
int parseToolsArgs( int argc, char* argv[] );