Compare commits
1
Commits
devel
..
e064e4e62d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e064e4e62d |
No files matched your search
+12
-13
@@ -1,22 +1,22 @@
|
||||
image: Visual Studio 2019
|
||||
image: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform:
|
||||
- x64
|
||||
environment:
|
||||
access_token:
|
||||
secure: SMxOWNKN0RkPvICWhIet2FJM5g/zx5mguM/XAPjM2OrC3U2/LAqcBZw0veS9peS4
|
||||
|
||||
|
||||
clone_folder: C:\Projects\calyp
|
||||
|
||||
init:
|
||||
- ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
|
||||
- git config --global credential.helper store
|
||||
- git config --global user.email "jfmcarreira@gmail.com"
|
||||
- git config --global user.name "AppVeyor"
|
||||
- git config --global user.name "AppVeyor"
|
||||
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
|
||||
install:
|
||||
- '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64'
|
||||
- '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64'
|
||||
- choco install nsis
|
||||
- choco install opencv
|
||||
- 'C:\Tools\opencv\build\setup_vars_opencv4.cmd'
|
||||
@@ -25,22 +25,21 @@ install:
|
||||
- 7z x ffmpeg.7z -y -offmpeg
|
||||
- git clone https://github.com/pixlra/calyp-deployment.git
|
||||
- CALL calyp-deployment/scripts/extract_ffmpeg.bat
|
||||
- ps: rm C:\Projects\ffmpeg_libraries\bin\*.exe
|
||||
|
||||
|
||||
|
||||
|
||||
build_script:
|
||||
- mv C:\Projects\calyp C:\Projects\calyp-deployment\cmake-helper\
|
||||
- mkdir C:\Projects\calyp-build
|
||||
- cd C:\Projects\calyp-build
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DUSE_DYNLOAD=OFF -DOpenCV_DIR="C:/Tools/opencv/build" -DOpenCV_DLL_DIR="C:/Tools/opencv/build/x64/vc15/bin" -DOpenCV_INSTALL_MODULES="world" -DQT_DIR="C:\Qt\latest\msvc2019_64" -DQt5_DIR="C:\Qt\latest\msvc2019_64\lib\cmake\Qt5" -DUSE_QTDBUS=OFF -DAVFORMAT_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avformat.lib -DAVFORMAT_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DAVCODEC_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avcodec.lib -DAVCODEC_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DAVUTIL_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avutil.lib -DAVUTIL_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DSWSCALE_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/swscale.lib -DSWSCALE_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DAVDEVICE_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avdevice.lib -DAVDEVICE_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DPOSTPROC_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/postproc.lib -DPOSTPROC_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DFFMPEG_DIR=C:\Projects\ffmpeg_libraries -DSWRESAMPLE_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/swresample.lib -DSWRESAMPLE_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -G "Visual Studio 16 2019" -A x64 C:\Projects\calyp-deployment\cmake-helper
|
||||
- cmake --build . --target ALL_BUILD -- /p:Configuration=Release
|
||||
- cmake --build . --target INSTALL -- /p:Configuration=Release
|
||||
- cmake --build . --target PACKAGE -- /p:Configuration=Release
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DUSE_DYNLOAD=OFF -DOpenCV_DIR="C:/Tools/opencv/build" -DOpenCV_DLL_DIR="C:/Tools/opencv/build/x64/vc15/bin" -DOpenCV_INSTALL_MODULES="world" -DQT_DIR="C:\Qt\latest\msvc2017_64" -DQt5_DIR="C:\Qt\latest\msvc2017_64\lib\cmake\Qt5" -DUSE_QTDBUS=OFF -DAVFORMAT_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avformat.lib -DAVFORMAT_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DAVCODEC_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avcodec.lib -DAVCODEC_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DAVUTIL_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/avutil.lib -DAVUTIL_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -DSWSCALE_LIBRARIES=C:/Projects/ffmpeg_libraries/lib/swscale.lib -DSWSCALE_INCLUDE_DIRS=C:/Projects/ffmpeg_libraries/include -G "Visual Studio 15 2017 Win64" C:\Projects\calyp-deployment\cmake-helper
|
||||
- cmake --build . --target ALL_BUILD -- /p:Configuration=Release > log_build
|
||||
- cmake --build . --target INSTALL -- /p:Configuration=Release > log_install
|
||||
- cmake --build . --target PACKAGE -- /p:Configuration=Release > log_pkg
|
||||
|
||||
after_build:
|
||||
- IF "%APPVEYOR_REPO_BRANCH%" == "master" (CALL ..\calyp-deployment\scripts\deploy-to-github.bat)
|
||||
|
||||
|
||||
|
||||
on_failure:
|
||||
- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
|
||||
+38
-37
@@ -1,19 +1,19 @@
|
||||
---
|
||||
BasedOnStyle: Google
|
||||
Language: Cpp
|
||||
ColumnLimit: 120
|
||||
BasedOnStyle: Google
|
||||
Language: Cpp
|
||||
ColumnLimit: 0
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignOperands: true
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
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,20 +77,21 @@ PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
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
|
||||
...
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
---
|
||||
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: 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"
|
||||
@@ -0,0 +1,31 @@
|
||||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- devel
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Dependencies
|
||||
run: sudo apt-get install cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
|
||||
|
||||
- name: Build CMake
|
||||
uses: ashutoshvarma/action-cmake-build@v1
|
||||
with:
|
||||
build-dir: ${{ runner.workspace }}/build
|
||||
# will set the CC & CXX for cmake
|
||||
cc: gcc
|
||||
cxx: g++
|
||||
build-type: Release
|
||||
# Extra options pass to cmake while configuring project
|
||||
configure-options: -DBUILD_TESTS=ON -DUSE_WERROR=ON
|
||||
run-test: true
|
||||
#ctest-options: -R mytest
|
||||
# install the build using cmake --install
|
||||
install-build: true
|
||||
# run build using '-j [parallel]' to use multiple threads to build
|
||||
parallel: 14
|
||||
@@ -1,92 +0,0 @@
|
||||
name: Build/Test Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- devel
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
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-24.04
|
||||
name: Build (Linux)
|
||||
steps:
|
||||
- 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@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 -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-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-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}}
|
||||
|
||||
- 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:
|
||||
- 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}}
|
||||
|
||||
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
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check out tests data
|
||||
uses: actions/checkout@master
|
||||
with:
|
||||
repository: "pixlra/calyp-testdata"
|
||||
path: ${{github.workspace}}/tests_data
|
||||
|
||||
- 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: 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
|
||||
+1
-7
@@ -1,7 +1,5 @@
|
||||
# Created by https://www.gitignore.io/api/c++,clion,linux
|
||||
# Edit at https://www.gitignore.io/?templates=c++,clion,linux
|
||||
deps/**
|
||||
templates/**
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
@@ -78,7 +76,6 @@ templates/**
|
||||
# CMake
|
||||
bin/
|
||||
build/
|
||||
build-*
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
@@ -145,7 +142,4 @@ fabric.properties
|
||||
doc/
|
||||
|
||||
# CLang
|
||||
compile_commands.json
|
||||
|
||||
# Build dirs
|
||||
build*
|
||||
compile_commands.json
|
||||
+13
-15
@@ -1,6 +1,19 @@
|
||||
fail_fast: false
|
||||
|
||||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cmake-configure
|
||||
name: Cmake Configure
|
||||
entry: cmake -B build
|
||||
pass_filenames: false
|
||||
language: system
|
||||
- id: cmake-build
|
||||
name: Cmake Build
|
||||
entry: cmake --build build
|
||||
pass_filenames: false
|
||||
language: system
|
||||
|
||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||
rev: v0.6.10
|
||||
hooks:
|
||||
@@ -12,18 +25,3 @@ repos:
|
||||
hooks:
|
||||
- id: clang-format
|
||||
args: [--style=file, -i]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cmake-configure
|
||||
name: Cmake Configure
|
||||
entry: cmake -B build
|
||||
pass_filenames: false
|
||||
language: system
|
||||
#- id: cmake-build
|
||||
#name: Cmake Build
|
||||
#entry: cmake --build build
|
||||
#pass_filenames: false
|
||||
#language: system
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
language: cpp
|
||||
dist: bionic
|
||||
dist: xenial
|
||||
before_install:
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get install build-essential cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev libgtest-dev
|
||||
script:
|
||||
- mkdir -p build && cd build && cmake .. && make && cd ..
|
||||
- mkdir -p build && cd build && cmake -DBUILD_TESTS=ON .. && make && cd ..
|
||||
+46
-88
@@ -2,7 +2,15 @@
|
||||
# CMakeLists for calyp
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# CMake functions
|
||||
# ####################################################################################################################################################
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
INCLUDE(cmake/ModulesFct.cmake)
|
||||
INCLUDE(FeatureSummary)
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Project Definition
|
||||
@@ -17,28 +25,15 @@ SET(PROJECT_LIBRARY
|
||||
CACHE INTERNAL "" FORCE
|
||||
)
|
||||
|
||||
SET(CALYP_VERSION_MAJOR "2")
|
||||
SET(CALYP_VERSION_MINOR "2")
|
||||
PROJECT(${PROJECT_NAME})
|
||||
SET(CALYP_VERSION_MAJOR "1")
|
||||
SET(CALYP_VERSION_MINOR "1")
|
||||
SET(CALYP_VERSION_PATCH "0")
|
||||
SET(CALYP_VERSION
|
||||
"${CALYP_VERSION_MAJOR}.${CALYP_VERSION_MINOR}.${CALYP_VERSION_PATCH}"
|
||||
CACHE INTERNAL "" FORCE
|
||||
)
|
||||
|
||||
PROJECT(
|
||||
${PROJECT_NAME}
|
||||
VERSION ${CALYP_VERSION}
|
||||
LANGUAGES "CXX"
|
||||
)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# CMake functions
|
||||
# ####################################################################################################################################################
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
INCLUDE(cmake/ModulesFct.cmake)
|
||||
INCLUDE(FeatureSummary)
|
||||
INCLUDE(GNUInstallDirs)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Variables
|
||||
# ####################################################################################################################################################
|
||||
@@ -47,17 +42,14 @@ OPTION(BUILD_APP "Build GUI Application" ON)
|
||||
OPTION(BUILD_TOOLS "Build Command Line Application" ON)
|
||||
OPTION(BUILD_EXAMPLES "Build Examples" OFF)
|
||||
OPTION(BUILD_DOC "Build Documentation" OFF)
|
||||
OPTION(BUILD_TESTS "Build Tests" OFF)
|
||||
OPTION(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
|
||||
OPTION(BUILD_WITH_THREAD_SANITIZER "Build with thread sanitizer" OFF)
|
||||
OPTION(BUILD_TESTS "Build Google Tests" OFF)
|
||||
|
||||
OPTION(USE_FERVOR "Add Fervor support" OFF)
|
||||
|
||||
OPTION(USE_DYNLOAD "Use dynamic load of modules" ON)
|
||||
OPTION(USE_SSE "Build with SSE support" ON)
|
||||
OPTION(USE_SSE "Build with SSE support" OFF)
|
||||
OPTION(USE_WERROR "Warnings as errors" OFF)
|
||||
OPTION(USE_STATIC "Use static libs" OFF)
|
||||
OPTION(USE_IWYU "Use include what you use tool" OFF)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Release configuration
|
||||
@@ -102,11 +94,7 @@ SET(UPDATE_CHANNEL
|
||||
# ####################################################################################################################################################
|
||||
# Dependencies
|
||||
# ####################################################################################################################################################
|
||||
INCLUDE(FetchContent)
|
||||
|
||||
SET(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/deps")
|
||||
|
||||
# Doxygen
|
||||
IF(BUILD_DOC)
|
||||
FIND_PACKAGE(Doxygen)
|
||||
SET(BUILD_DOC ${Doxygen_FOUND})
|
||||
@@ -118,47 +106,19 @@ SET_PACKAGE_PROPERTIES(
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
# Catch2 and Google Tests
|
||||
IF(BUILD_TESTS)
|
||||
FETCHCONTENT_DECLARE(googletest URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
SET(gtest_force_shared_crt
|
||||
ON
|
||||
CACHE BOOL "" FORCE
|
||||
)
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v3.3.2
|
||||
)
|
||||
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
googletest PROPERTIES
|
||||
URL "https://github.com/google/googletest"
|
||||
DESCRIPTION "Google unit tests"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
Catch2 PROPERTIES
|
||||
URL "https://github.com/catchorg/Catch2"
|
||||
DESCRIPTION "Catch2 unit tests"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(googletest Catch2)
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/deps/catch2-src/extras)
|
||||
INCLUDE(CTest)
|
||||
INCLUDE(Catch)
|
||||
ENABLE_TESTING()
|
||||
|
||||
FIND_PACKAGE(GTest)
|
||||
SET(BUILD_DOC ${GTEST_FOUND})
|
||||
IF(GTEST_FOUND)
|
||||
ENABLE_TESTING()
|
||||
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
|
||||
ENDIF()
|
||||
SET(CALYP_TEST_DATA_DIR
|
||||
"CALYP_TEST_DATA_DIR"
|
||||
CACHE PATH "Location of video information for testing"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# OpenCV
|
||||
OPTION(USE_OPENCV "Add OpenCV support" ON)
|
||||
IF(USE_OPENCV)
|
||||
|
||||
@@ -184,10 +144,13 @@ SET_PACKAGE_PROPERTIES(
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
# FFmpeg
|
||||
OPTION(USE_FFMPEG "Add FFMPEG support" ON)
|
||||
IF(USE_FFMPEG)
|
||||
FIND_PACKAGE(FFmpeg COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
|
||||
IF("${AVCODEC_VERSION}" VERSION_LESS "56.0.0")
|
||||
SET(FFMPEG_FOUND FALSE)
|
||||
SET(FFmpeg_FOUND FALSE)
|
||||
ENDIF()
|
||||
SET(USE_FFMPEG ${FFMPEG_FOUND})
|
||||
ENDIF()
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
@@ -225,16 +188,9 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
# Compiler options
|
||||
# ####################################################################################################################################################
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 20)
|
||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
IF(MSVC)
|
||||
ADD_COMPILE_OPTIONS(/std:c++20)
|
||||
ELSE()
|
||||
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
|
||||
ADD_DEFINITIONS(-std=gnu++2a)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-std=c++20)
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_STANDARD 14)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS(-std=gnu++0x)
|
||||
ENDIF()
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
@@ -242,26 +198,31 @@ IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -funroll-loops")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
# -DQT_NO_CAST_FROM_ASCII
|
||||
-DQT_NO_URL_CAST_FROM_STRING
|
||||
-DQT_NO_CAST_FROM_BYTEARRAY
|
||||
# -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_USE_QSTRINGBUILDER
|
||||
)
|
||||
|
||||
# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") endif()
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlogical-op")
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
ENDIF()
|
||||
|
||||
IF(USE_WERROR)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -DCLP_DEBUG")
|
||||
IF(BUILD_WITH_SANITIZERS)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
|
||||
ENDIF()
|
||||
IF(BUILD_WITH_THREAD_SANITIZER)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread")
|
||||
ENDIF()
|
||||
|
||||
IF(USE_IWYU)
|
||||
FIND_PROGRAM(iwyu_path NAMES include-what-you-use iwyu REQUIRED)
|
||||
SET(CXX_INCLUDE_WHAT_YOU_USE ON)
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Configure targets
|
||||
@@ -274,10 +235,7 @@ ADD_FEATURE_INFO(SSE USE_SSE "SSE instructions support")
|
||||
ADD_FEATURE_INFO(WErrors USE_WERROR "Warnings as errors")
|
||||
|
||||
ADD_SUBDIRECTORY(lib)
|
||||
|
||||
IF(${BUILD_TOOLS} OR ${BUILD_APP})
|
||||
ADD_SUBDIRECTORY(modules)
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(modules)
|
||||
|
||||
IF(${BUILD_TOOLS})
|
||||
ADD_SUBDIRECTORY(tools)
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
## Build Status
|
||||
|
||||
| Master | Development |
|
||||
|--|--|
|
||||
|  |  |
|
||||
|
||||
[](https://ci.appveyor.com/project/jfmcarreira/calyp/branch/master)
|
||||
Master branch | Development branch
|
||||
------------ | -------------
|
||||
[](https://travis-ci.org/pixlra/calyp.svg?branch=master) [](https://ci.appveyor.com/project/jfmcarreira/calyp/branch/master) | Comming soon!
|
||||
|
||||
|
||||
## Features
|
||||
@@ -22,7 +20,7 @@
|
||||
- Constant growing libs for stream and frame processing (CalypStream and CalypFrame)
|
||||
- Advanced API for frame/video processing algorithms
|
||||
- Frame level quality measurement API based on the CalypFrame class
|
||||
- Powerful command-line tool for quality and frame processing algorithms (uses the referred APIs)
|
||||
- Powefull command-line tool for quality and frame processing algorithms (uses the referred APIs)
|
||||
|
||||
## Modules
|
||||
- CalypLib: Low level library
|
||||
@@ -32,7 +30,7 @@
|
||||
|
||||
## Supported Quality Metrics
|
||||
- Peak Signal-to-Noise Ratio (PSNR)
|
||||
- Structural SIMilarity (SSIM)
|
||||
- Structural SIMilarity (SSIM)
|
||||
- Mean Square Error (MSE)
|
||||
- Weighted Spherical PSNR (WS-PSNR)
|
||||
|
||||
@@ -75,13 +73,13 @@
|
||||
* **Dependencies**
|
||||
1. an ordinary C++ development environment (g++, make, C++ libraries and headers, ...)
|
||||
2. cmake
|
||||
3. a Qt development environment: QtCore, QtGui, QtWidgets, QtPrintSupport and QtConcurrent (version 5 or higher)
|
||||
3. a Qt development environment: QtCore, QtGui, QtWidgets, QtPrintSupport and QtConcurrent (version 4 or higher)
|
||||
4. Optional: QtDBus, OpenCV, FFmpeg
|
||||
* **List of required commands**
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DUSE_FFMPEG=ON -DUSE_OPENCV=ON .. (for FFmpeg and OpenCV support)
|
||||
cmake -DUSE_QT4=OFF -DUSE_FFMPEG=ON -DUSE_OPENCV=ON .. (for FFmpeg and OpenCV support)
|
||||
make
|
||||
make install
|
||||
```
|
||||
+21
-67
@@ -3,33 +3,17 @@
|
||||
#
|
||||
|
||||
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} ${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_QT6 "Build with Qt6" ON)
|
||||
OPTION(USE_QTDBUS "Build with QtDBus" OFF)
|
||||
OPTION(USE_QTDBUS "Build with QtDBus" ON)
|
||||
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)
|
||||
|
||||
LIST(APPEND QT_LINKER_LIBS Qt::Core Qt::Gui Qt::Widgets Qt::Concurrent)
|
||||
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_MODULES Core Gui Widgets Concurrent)
|
||||
|
||||
IF(USE_QTDBUS)
|
||||
@@ -45,44 +29,31 @@ IF(USE_QTDBUS)
|
||||
${Qt5DBus_FOUND}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
LIST(APPEND QT_LINKER_LIBS Qt::DBus)
|
||||
LIST(APPEND QT_LINKER_LIBS Qt5::DBus)
|
||||
LIST(APPEND QT_MODULES DBus)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
# -DQT_NO_CAST_FROM_ASCII
|
||||
-DQT_NO_URL_CAST_FROM_STRING
|
||||
-DQT_NO_CAST_FROM_BYTEARRAY
|
||||
# -DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_USE_QSTRINGBUILDER
|
||||
)
|
||||
|
||||
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
|
||||
SET(Calyp_App_SRCS
|
||||
# Main
|
||||
main.cpp
|
||||
MainWindow.cpp
|
||||
# Module SubWindow
|
||||
SubWindowHandle.cpp
|
||||
MdiSubWindow.cpp
|
||||
SubWindowAbstract.cpp
|
||||
# Module Video
|
||||
VideoHandle.cpp
|
||||
VideoSubWindow.cpp
|
||||
VideoStreamSubWindow.cpp
|
||||
ModuleSubWindow.cpp
|
||||
ViewArea.cpp
|
||||
GridManager.cpp
|
||||
# Module Quality
|
||||
QualityHandle.cpp
|
||||
PlotSubWindow.cpp
|
||||
external/qcustomplot/qcustomplot.cpp
|
||||
# Module Plugins
|
||||
ModulesHandle.cpp
|
||||
CalypAppModuleIf.cpp
|
||||
# Dialogs
|
||||
dialog/AboutDialog.cpp
|
||||
dialog/ConfigureFormatDialog.cpp
|
||||
@@ -100,7 +71,7 @@ SET(Calyp_App_GUI_SRCS
|
||||
)
|
||||
|
||||
IF(USE_QTDBUS)
|
||||
LIST(APPEND Calyp_App_GUI_SRCS DBusAppAdaptor.cpp)
|
||||
LIST(APPEND Calyp_App_SRCS DBusAppAdaptor.cpp)
|
||||
ENDIF()
|
||||
|
||||
SET(Calyp_App_UI "")
|
||||
@@ -124,7 +95,7 @@ IF(USE_FERVOR)
|
||||
|
||||
FIND_PACKAGE(Qt5 REQUIRED Network WebKit WebKitWidgets)
|
||||
|
||||
LIST(APPEND QT_LINKER_LIBS Qt::Network Qt::WebKit Qt::WebKitWidgets)
|
||||
LIST(APPEND QT_LINKER_LIBS Qt5::Network Qt5::WebKit Qt5::WebKitWidgets)
|
||||
LIST(APPEND QT_MODULES Network WebKit WebKitWidgets)
|
||||
|
||||
# LIST(APPEND APP_LINKER_LIBS ${FERVOR_DEPENDENCIES} )
|
||||
@@ -147,16 +118,12 @@ SET_PACKAGE_PROPERTIES(
|
||||
)
|
||||
ADD_FEATURE_INFO(Fervor USE_FERVOR "Fervor lib includes check for updates feature.")
|
||||
|
||||
QT_WRAP_UI(Calyp_App_UI_Wrap ${Calyp_App_UI})
|
||||
QT_ADD_RESOURCES(Calyp_App_RCC ${Calyp_App_RCC})
|
||||
QT5_WRAP_UI(Calyp_App_UI_Wrap ${Calyp_App_UI})
|
||||
QT5_ADD_RESOURCES(Calyp_App_RCC ${Calyp_App_RCC})
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-enum-enum-conversion")
|
||||
ENDIF()
|
||||
|
||||
# Windows application icon
|
||||
IF(WIN32)
|
||||
SET(WINDOWS_RES_FILE ${CMAKE_CURRENT_BINARY_DIR}/resources.obj)
|
||||
@@ -175,18 +142,9 @@ IF(WIN32)
|
||||
COMMENT "Add icon on windows platform"
|
||||
)
|
||||
ENDIF()
|
||||
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})
|
||||
SET(MACOSX_BUNDLE_ICON_FILE Contents/Resources/calyp.icns)
|
||||
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_GUI_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${APP_ICON_MACOSX})
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_GUI_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC})
|
||||
ENDIF()
|
||||
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${WINDOWS_RES_FILE})
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PROJECT_LIBRARY} CalypModules ${APP_LINKER_LIBS} ${QT_LINKER_LIBS} QCustomPlotLib)
|
||||
|
||||
# QT5_USE_MODULES( ${PROJECT_NAME} ${QT_MODULES} )
|
||||
@@ -195,7 +153,3 @@ 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()
|
||||
+105
-141
@@ -28,76 +28,39 @@
|
||||
#include <QApplication>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "ModuleHandleDock.h"
|
||||
#include "ModuleSubWindow.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModulePtr&& module )
|
||||
: m_pcModuleAction( action ), m_pcModule( std ::move( module ) )
|
||||
CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModuleIf* module )
|
||||
: m_bIsRunning( false )
|
||||
, m_pcModuleAction( action )
|
||||
, m_pcModule( module )
|
||||
, m_pcDisplaySubWindow( NULL )
|
||||
, m_pcDockWidget( NULL )
|
||||
, m_pcModuleDock( NULL )
|
||||
, m_pcModuleStream( NULL )
|
||||
, m_pcProcessedFrame( NULL )
|
||||
, m_dMeasurementResult( 0 )
|
||||
{
|
||||
setParent( parent );
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
setObjectName( m_pcModule->m_pchModuleName );
|
||||
#endif
|
||||
m_frameList.reserve( m_pcModule->m_uiNumberOfFrames );
|
||||
m_frameListPtr.reserve( m_pcModule->m_uiNumberOfFrames );
|
||||
m_pcSubWindow.resize( m_pcModule->m_uiNumberOfFrames, nullptr );
|
||||
}
|
||||
|
||||
CalypAppModuleIf::~CalypAppModuleIf()
|
||||
{
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
wait();
|
||||
#endif
|
||||
if( m_pcModuleDock )
|
||||
for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ )
|
||||
{
|
||||
auto* ptr = m_pcModuleDock;
|
||||
m_pcModuleDock = NULL;
|
||||
ptr->close();
|
||||
delete ptr;
|
||||
}
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
auto* ptr = m_pcDisplaySubWindow;
|
||||
m_pcDisplaySubWindow = NULL;
|
||||
ptr->closeSubWindow();
|
||||
delete ptr;
|
||||
}
|
||||
if( m_pcDockWidget )
|
||||
{
|
||||
m_pcDockWidget->close();
|
||||
delete m_pcDockWidget;
|
||||
}
|
||||
if( m_pcModule )
|
||||
{
|
||||
m_pcModule->destroy();
|
||||
m_pcModule = nullptr;
|
||||
m_pcSubWindow[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::update( bool isPlaying )
|
||||
void CalypAppModuleIf::update()
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
m_pcDisplaySubWindow->refreshSubWindow();
|
||||
m_pcDisplaySubWindow->refreshFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
apply( isPlaying );
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
// void CalypAppModuleIf::setPlaying( bool isPlaying )
|
||||
// {
|
||||
// if( m_pcDisplaySubWindow )
|
||||
// {
|
||||
// m_pcDisplaySubWindow->setPlaying( isPlaying );
|
||||
// }
|
||||
// }
|
||||
|
||||
bool CalypAppModuleIf::isRunning() const
|
||||
bool CalypAppModuleIf::isRunning()
|
||||
{
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
return QThread::isRunning();
|
||||
@@ -106,20 +69,12 @@ bool CalypAppModuleIf::isRunning() const
|
||||
#endif
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::run()
|
||||
{
|
||||
bool result = process();
|
||||
if( result )
|
||||
{
|
||||
EventData* eventData = new EventData( m_bSuccess, this );
|
||||
QCoreApplication::postEvent( parent(), eventData );
|
||||
}
|
||||
}
|
||||
|
||||
bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
{
|
||||
bool moduleExecuted = false;
|
||||
if( m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
bool bRet = false;
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
@@ -130,20 +85,8 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
m_pcSubWindow[0]->setFillWindow( true );
|
||||
}
|
||||
}
|
||||
|
||||
if( !( isPlaying && m_pcModule->has( ClpModuleFeature::SkipWhilePlaying ) ) )
|
||||
if( !( isPlaying && ( m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY ) ) )
|
||||
{
|
||||
m_frameList.clear();
|
||||
for( unsigned int i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ )
|
||||
{
|
||||
m_frameList.push_back( m_pcSubWindow[i]->getCurrFrameAsset() );
|
||||
}
|
||||
|
||||
// Skip module is is already running
|
||||
if( isRunning() )
|
||||
return moduleExecuted;
|
||||
|
||||
moduleExecuted = true;
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
if( !disableThreads )
|
||||
{
|
||||
@@ -153,51 +96,49 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
else
|
||||
#endif
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
process();
|
||||
QApplication::restoreOverrideCursor();
|
||||
run();
|
||||
show();
|
||||
}
|
||||
|
||||
if( m_pcDisplaySubWindow || m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
bRet = true;
|
||||
}
|
||||
}
|
||||
return moduleExecuted;
|
||||
else
|
||||
{
|
||||
bRet = true;
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool CalypAppModuleIf::process()
|
||||
void CalypAppModuleIf::run()
|
||||
{
|
||||
m_bIsRunning = true;
|
||||
m_bSuccess = false;
|
||||
|
||||
if( m_frameList.empty() )
|
||||
return false;
|
||||
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
QMutexLocker locker( &m_Mutex );
|
||||
#endif
|
||||
|
||||
m_frameListPtr.clear();
|
||||
for( auto& frame : m_frameList )
|
||||
std::vector<CalypFrame*> apcFrameList;
|
||||
for( unsigned int i = 0; i < m_pcModule->m_uiNumberOfFrames; i++ )
|
||||
{
|
||||
m_frameListPtr.push_back( frame.get() );
|
||||
apcFrameList.push_back( m_pcSubWindow[i]->getCurrFrame() );
|
||||
}
|
||||
|
||||
if( m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
CalypFrame* framePtr{ nullptr };
|
||||
if( m_pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
{
|
||||
framePtr = m_pcModule->process( m_frameListPtr );
|
||||
m_pcProcessedFrame = m_pcModule->process( apcFrameList );
|
||||
}
|
||||
else
|
||||
{
|
||||
framePtr = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() );
|
||||
m_pcProcessedFrame = m_pcModule->process( m_pcSubWindow[0]->getCurrFrame() );
|
||||
}
|
||||
assert( framePtr != nullptr );
|
||||
m_pcProcessedFrame = std::shared_ptr<CalypFrame>{ framePtr, []( CalypFrame* ptr ) {} };
|
||||
}
|
||||
else if( m_pcModule->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
else if( m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
if( m_pcModule->m_iModuleAPI >= CLP_MODULE_API_2 )
|
||||
{
|
||||
m_dMeasurementResult = m_pcModule->measure( m_frameListPtr );
|
||||
m_dMeasurementResult = m_pcModule->measure( apcFrameList );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -206,61 +147,84 @@ bool CalypAppModuleIf::process()
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
m_bSuccess = true;
|
||||
return true;
|
||||
m_bIsRunning = false;
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
EventData* eventData = new EventData( m_bSuccess, this );
|
||||
if( parent() )
|
||||
QCoreApplication::postEvent( parent(), eventData );
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::show()
|
||||
{
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
if( m_canceling )
|
||||
return;
|
||||
#endif
|
||||
switch( m_pcModule->m_iModuleType )
|
||||
{
|
||||
case ClpModuleType::FrameProcessing: {
|
||||
auto displayWindow = qobject_cast<VideoSubWindow*>( m_pcDisplaySubWindow );
|
||||
if( displayWindow == nullptr )
|
||||
displayWindow = m_pcSubWindow[0];
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
if( m_Mutex.try_lock() )
|
||||
case CLP_FRAME_PROCESSING_MODULE:
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
displayWindow->setFillWindow( false );
|
||||
displayWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
m_Mutex.unlock();
|
||||
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
m_pcDisplaySubWindow->setFillWindow( false );
|
||||
m_pcDisplaySubWindow->clearWindowBusy();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
|
||||
m_pcSubWindow[0]->setFillWindow( false );
|
||||
m_pcSubWindow[0]->clearWindowBusy();
|
||||
}
|
||||
#else
|
||||
displayWindow->setFillWindow( false );
|
||||
displayWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case ClpModuleType::FrameMeasurement:
|
||||
m_pcModuleDock->setModuleReturnValue( m_dMeasurementResult );
|
||||
case CLP_FRAME_MEASUREMENT_MODULE:
|
||||
m_pcModuleDock->setModulueReturnValue( m_dMeasurementResult );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::disable()
|
||||
void CalypAppModuleIf::destroy()
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
m_canceling = true;
|
||||
m_Mutex.lock();
|
||||
m_Mutex.unlock();
|
||||
#endif
|
||||
m_frameList.clear();
|
||||
m_frameListPtr.clear();
|
||||
while( m_pcSubWindow.size() > 0 )
|
||||
if( m_bIsRunning )
|
||||
{
|
||||
auto window = m_pcSubWindow.back();
|
||||
m_pcSubWindow.erase( m_pcSubWindow.end() - 1 );
|
||||
if( window != nullptr )
|
||||
window->disableModule( this );
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
while( m_bIsRunning )
|
||||
{
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
if( m_pcModuleDock )
|
||||
{
|
||||
m_pcModuleDock->close();
|
||||
m_pcModuleDock = NULL;
|
||||
}
|
||||
if( m_pcDockWidget )
|
||||
{
|
||||
m_pcDockWidget->close();
|
||||
m_pcDockWidget = NULL;
|
||||
}
|
||||
if( m_pcDisplaySubWindow )
|
||||
m_pcDisplaySubWindow->closeSubWindow();
|
||||
m_pcDisplaySubWindow = NULL;
|
||||
|
||||
for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ )
|
||||
{
|
||||
if( m_pcSubWindow[i] )
|
||||
{
|
||||
m_pcSubWindow[i]->disableModule( this );
|
||||
m_pcSubWindow[i] = NULL;
|
||||
}
|
||||
}
|
||||
if( m_pcModuleStream )
|
||||
{
|
||||
m_pcModuleStream->close();
|
||||
delete m_pcModuleStream;
|
||||
m_pcModuleStream = NULL;
|
||||
}
|
||||
if( m_pcModule )
|
||||
{
|
||||
m_pcModule->destroy();
|
||||
m_pcModule->Delete();
|
||||
m_pcModule = NULL;
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
+46
-55
@@ -26,98 +26,89 @@
|
||||
#define __CALYPAPPMODULESIF_H__
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPointer>
|
||||
#include <QVector>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#endif
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "ModuleHandleDock.h"
|
||||
// #include "lib/CalypFrame.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#include "lib/CalypModuleIf.h"
|
||||
// #include "lib/CalypStream.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class QAction;
|
||||
class QDockWidget;
|
||||
class CalypStream;
|
||||
class CalypFrame;
|
||||
|
||||
#define CLP_MODULE_MAX_NUM_FRAMES 5
|
||||
|
||||
class VideoSubWindow;
|
||||
class ModuleSubWindow;
|
||||
|
||||
class CalypAppModuleIf : std::enable_shared_from_this<CalypAppModuleIf>,
|
||||
class CalypAppModuleIf
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
public QThread
|
||||
: public QThread
|
||||
#else
|
||||
public QObject
|
||||
: public QObject
|
||||
#endif
|
||||
{
|
||||
friend class ModulesHandle;
|
||||
friend class ModuleHandleDock;
|
||||
friend class ModulesHandleOptDialog;
|
||||
|
||||
private:
|
||||
bool m_bIsRunning;
|
||||
bool m_bSuccess;
|
||||
|
||||
QAction* m_pcModuleAction;
|
||||
CalypModuleIf* m_pcModule;
|
||||
|
||||
VideoSubWindow* m_pcSubWindow[CLP_MODULE_MAX_NUM_FRAMES];
|
||||
|
||||
VideoSubWindow* m_pcDisplaySubWindow;
|
||||
|
||||
QDockWidget* m_pcDockWidget;
|
||||
ModuleHandleDock* m_pcModuleDock;
|
||||
|
||||
CalypStream* m_pcModuleStream;
|
||||
CalypFrame* m_pcProcessedFrame;
|
||||
double m_dMeasurementResult;
|
||||
|
||||
public:
|
||||
class EventData : public QEvent
|
||||
{
|
||||
public:
|
||||
EventData( bool success, CalypAppModuleIf* module )
|
||||
: QEvent( QEvent::User ), m_bSuccess{ success }, m_pcModule{ module }
|
||||
: QEvent( QEvent::User )
|
||||
{
|
||||
m_bSuccess = success;
|
||||
m_pcModule = module;
|
||||
}
|
||||
bool m_bSuccess;
|
||||
QPointer<CalypAppModuleIf> m_pcModule;
|
||||
CalypAppModuleIf* m_pcModule;
|
||||
};
|
||||
|
||||
CalypAppModuleIf( QObject* parent, QAction* action, CalypModulePtr&& module );
|
||||
~CalypAppModuleIf();
|
||||
CalypAppModuleIf( QObject* parent, QAction* action, CalypModuleIf* module );
|
||||
virtual ~CalypAppModuleIf() {}
|
||||
QList<VideoSubWindow*> getSubWindowList()
|
||||
{
|
||||
QList<VideoSubWindow*> arraySubWindows;
|
||||
for( int i = 0; i < CLP_MODULE_MAX_NUM_FRAMES; i++ )
|
||||
if( m_pcSubWindow[i] )
|
||||
arraySubWindows.append( m_pcSubWindow[i] );
|
||||
return arraySubWindows;
|
||||
}
|
||||
|
||||
auto getSubWindowList() const -> const std::vector<VideoSubWindow*>& { return m_pcSubWindow; }
|
||||
|
||||
CalypModuleIf* getModule() { return m_pcModule.get(); }
|
||||
auto hasFeature( ClpModuleFeature feature ) const -> bool { return m_pcModule->has( feature ); }
|
||||
std::string moduleInfo() const { return m_pcModule->moduleInfo(); }
|
||||
void update( bool isPlaying );
|
||||
CalypModuleIf* getModule() { return m_pcModule; }
|
||||
unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
|
||||
ClpString moduleInfo() { return m_pcModule->moduleInfo(); }
|
||||
void update();
|
||||
bool apply( bool isPlaying = false, bool disableThreads = false );
|
||||
bool process();
|
||||
bool isRunning() const;
|
||||
bool isRunning();
|
||||
void show();
|
||||
void disable();
|
||||
void destroy();
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
bool m_bSuccess{ false };
|
||||
|
||||
QAction* m_pcModuleAction{ nullptr };
|
||||
CalypModulePtr m_pcModule{ nullptr };
|
||||
|
||||
std::vector<VideoSubWindow*> m_pcSubWindow;
|
||||
|
||||
// The module owns the related widgets
|
||||
ModuleSubWindow* m_pcDisplaySubWindow{ nullptr };
|
||||
QDockWidget* m_pcDockWidget{ nullptr };
|
||||
ModuleHandleDock* m_pcModuleDock{ nullptr };
|
||||
|
||||
std::unique_ptr<CalypStream> m_pcModuleStream{ nullptr };
|
||||
|
||||
std::vector<std::shared_ptr<CalypFrame>> m_frameList;
|
||||
std::vector<CalypFrame*> m_frameListPtr;
|
||||
|
||||
std::shared_ptr<CalypFrame> m_pcProcessedFrame{ nullptr };
|
||||
double m_dMeasurementResult{ 0 };
|
||||
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
QMutex m_Mutex;
|
||||
std::atomic<bool> m_canceling{ false };
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // __CALYPAPPMODULESIF_H__
|
||||
+1
-1
@@ -52,7 +52,7 @@ void GridManager::setGridSize( int newsize )
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Grid Drawer
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void GridManager::drawGrid( const QImage& image, const QRect& area, QPainter* painter )
|
||||
void GridManager::drawGrid( QPixmap& image, const QRect& area, QPainter* painter )
|
||||
{
|
||||
int offsetx = 0; // Grid offset doesn't applies to SCODE
|
||||
int offsety = 0; // project for now...
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
void setGridSize( int newsize );
|
||||
|
||||
void drawGrid( const QImage& image, const QRect& area, QPainter* painter );
|
||||
void drawGrid( QPixmap& image, const QRect& area, QPainter* painter );
|
||||
|
||||
/**
|
||||
* @returns a QRect defined by the grid that contains the point (x, y).
|
||||
|
||||
+150
-196
@@ -33,10 +33,8 @@
|
||||
#include <QDropEvent>
|
||||
#include <QSignalMapper>
|
||||
#include <QtDebug>
|
||||
#include <memory>
|
||||
|
||||
#include "AboutDialog.h"
|
||||
#include "ConfigureFormatDialog.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "QualityHandle.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
@@ -45,12 +43,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 );
|
||||
@@ -60,8 +58,6 @@ MainWindow::MainWindow()
|
||||
m_pDBusAdaptor = new DBusAppAdaptor( this );
|
||||
#endif
|
||||
|
||||
m_appResourceHandle = std::make_unique<ResourceHandle>();
|
||||
|
||||
m_pcWindowHandle = new SubWindowHandle( this );
|
||||
|
||||
m_appModuleVideo = new VideoHandle( this, m_pcWindowHandle );
|
||||
@@ -80,15 +76,15 @@ MainWindow::MainWindow()
|
||||
setWindowTitle( QApplication::applicationName() );
|
||||
setWindowIcon( QIcon( ":logos/calyp-icon.png" ) );
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
setCentralWidget( m_pcWindowHandle->getWidget() );
|
||||
setCentralWidget( m_pcWindowHandle );
|
||||
setAcceptDrops( true );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::windowActivated, this, &MainWindow::updateMainWindow );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleVideo, &VideoHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleQuality, &QualityHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_appModuleExtensions, &ModulesHandle::changed, this, &MainWindow::updateMainWindow, Qt::QueuedConnection );
|
||||
connect( m_pcWindowHandle, SIGNAL( windowActivated() ), this, SLOT( update() ) );
|
||||
connect( m_pcWindowHandle, SIGNAL( changed() ), this, SLOT( update() ) );
|
||||
connect( m_appModuleVideo, SIGNAL( changed() ), this, SLOT( update() ) );
|
||||
connect( m_appModuleQuality, SIGNAL( changed() ), this, SLOT( update() ) );
|
||||
connect( m_appModuleExtensions, SIGNAL( changed() ), this, SLOT( update() ) );
|
||||
}
|
||||
|
||||
bool MainWindow::parseArgs( int argc, char* argv[] )
|
||||
@@ -96,9 +92,9 @@ bool MainWindow::parseArgs( int argc, char* argv[] )
|
||||
bool bRet = false;
|
||||
CalypOptions pcCmdParser;
|
||||
|
||||
std::vector<std::string> m_apcInputs;
|
||||
std::string strResolution( "" );
|
||||
std::string strPelFmt( "" );
|
||||
std::vector<ClpString> m_apcInputs;
|
||||
ClpString strResolution( "" );
|
||||
ClpString strPelFmt( "" );
|
||||
|
||||
pcCmdParser.addOptions() /**/
|
||||
( "input,i", m_apcInputs, "input file" ) /**/
|
||||
@@ -135,7 +131,8 @@ 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,82 +182,37 @@ void MainWindow::closeAll()
|
||||
m_pcWindowHandle->removeAllSubWindow();
|
||||
}
|
||||
|
||||
void MainWindow::loadFile( const CalypFileInfo& pStreamInfo )
|
||||
void MainWindow::loadFile( QString fileName, CalypFileInfo* pStreamInfo )
|
||||
{
|
||||
loadFile( pStreamInfo.m_cFilename, pStreamInfo );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if( auto* videoSubWindow = MainWindow::findVideoStreamSubWindow( m_pcWindowHandle, fileName ) )
|
||||
VideoSubWindow* videoSubWindow = MainWindow::findVideoStreamSubWindow( m_pcWindowHandle, fileName );
|
||||
if( videoSubWindow )
|
||||
{
|
||||
m_pcWindowHandle->setActiveSubWindow( videoSubWindow );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !streamInfoOpt.has_value() )
|
||||
videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); // createSubWindow();
|
||||
if( !pStreamInfo )
|
||||
{
|
||||
auto idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
|
||||
if( idx >= 0 ) streamInfoOpt = m_aRecentFileStreamInfo.at( idx );
|
||||
int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
|
||||
pStreamInfo = (CalypFileInfo*)( idx >= 0 ? &m_aRecentFileStreamInfo.at( idx ) : NULL );
|
||||
}
|
||||
|
||||
auto streamInfo = streamInfoOpt.has_value() ? *streamInfoOpt : CalypFileInfo{ .m_cFilename = fileName };
|
||||
|
||||
auto videoResource = std::make_unique<VideostreamResource>();
|
||||
|
||||
bool opened = false;
|
||||
try
|
||||
{
|
||||
[[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 );
|
||||
bool opened = false;
|
||||
|
||||
if( !forceDialog )
|
||||
{
|
||||
opened = videoResource->loadFile( streamInfo, false );
|
||||
}
|
||||
|
||||
if( !opened )
|
||||
{
|
||||
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( !pStreamInfo )
|
||||
opened = videoSubWindow->loadFile( fileName );
|
||||
else
|
||||
opened = videoSubWindow->loadFile( pStreamInfo );
|
||||
|
||||
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();
|
||||
@@ -269,17 +221,19 @@ void MainWindow::loadFile( const QString& fileName, std::optional<CalypFileInfo>
|
||||
|
||||
updateZoomFactorSBox();
|
||||
|
||||
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 ) );
|
||||
addStreamInfoToRecentList( videoSubWindow->getStreamInfo() );
|
||||
|
||||
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,12 +256,12 @@ QStringList MainWindow::showFileDialog( bool bRead )
|
||||
|
||||
for( unsigned int i = 0; i < supportedFmts.size(); i++ )
|
||||
{
|
||||
std::vector<std::string> arrayExt = supportedFmts[i].getExts();
|
||||
std::vector<ClpString> arrayExt = supportedFmts[i].getExts();
|
||||
if( arrayExt.size() > 0 )
|
||||
{
|
||||
QString currFmt( QString::fromStdString( supportedFmts[i].formatName ) );
|
||||
currFmt.append( " (" );
|
||||
for( std::vector<std::string>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
for( std::vector<ClpString>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
{
|
||||
supported.append( " *." );
|
||||
currFmt.append( "*." );
|
||||
@@ -327,12 +281,13 @@ QStringList MainWindow::showFileDialog( bool bRead )
|
||||
fileNameList.clear();
|
||||
if( bRead )
|
||||
{
|
||||
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_lastOpenPath, filter.join( ";;" ) );
|
||||
fileNameList = QFileDialog::getOpenFileNames( this, tr( "Open File" ), m_cLastOpenPath, filter.join( ";;" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_lastOpenPath, filter.join( ";;" ) );
|
||||
if( !fileName.isEmpty() ) fileNameList.append( fileName );
|
||||
QString fileName = QFileDialog::getSaveFileName( this, tr( "Save File" ), m_cLastOpenPath, filter.join( ";;" ) );
|
||||
if( !fileName.isEmpty() )
|
||||
fileNameList.append( fileName );
|
||||
}
|
||||
return fileNameList;
|
||||
}
|
||||
@@ -344,7 +299,7 @@ void MainWindow::open()
|
||||
{
|
||||
if( !fileNameList.at( i ).isEmpty() )
|
||||
{
|
||||
loadFile( std::move( fileNameList.at( i ) ) );
|
||||
loadFile( fileNameList.at( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,25 +312,25 @@ void MainWindow::open()
|
||||
void MainWindow::openRecent()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>( sender() );
|
||||
CalypFileInfo recentFile = action->data().value<CalypFileInfo>();
|
||||
if( action )
|
||||
{
|
||||
loadFile( action->data().value<CalypFileInfo>() );
|
||||
}
|
||||
loadFile( recentFile.m_cFilename, &recentFile );
|
||||
}
|
||||
|
||||
void MainWindow::saveFrame()
|
||||
{
|
||||
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
|
||||
if( pcVideoSubWindow != nullptr )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow;
|
||||
|
||||
QStringList fileNameList = showFileDialog( false );
|
||||
if( fileNameList.size() == 1 )
|
||||
{
|
||||
QString fileName = fileNameList[0];
|
||||
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
||||
try
|
||||
{
|
||||
pcVideoSubWindow->save( fileName );
|
||||
saveWindow->save( fileName );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
@@ -392,17 +347,18 @@ void MainWindow::saveFrame()
|
||||
|
||||
void MainWindow::saveStream()
|
||||
{
|
||||
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
|
||||
if( pcVideoSubWindow != nullptr )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
VideoSubWindow* saveWindow = m_pcCurrentVideoSubWindow;
|
||||
|
||||
QStringList fileNameList = showFileDialog( false );
|
||||
if( fileNameList.size() == 1 )
|
||||
{
|
||||
QString fileName = fileNameList[0];
|
||||
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
||||
try
|
||||
{
|
||||
pcVideoSubWindow->save( fileName );
|
||||
saveWindow->save( fileName );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
@@ -419,19 +375,15 @@ void MainWindow::saveStream()
|
||||
|
||||
void MainWindow::format()
|
||||
{
|
||||
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
|
||||
if( pcVideoSubWindow )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow = m_pcCurrentVideoSubWindow;
|
||||
try
|
||||
{
|
||||
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 );
|
||||
if( pcVideoSubWindow->loadFile( pcVideoSubWindow->getCurrentFileName(), true ) )
|
||||
{
|
||||
addStreamInfoToRecentList( pcVideoSubWindow->getStreamInfo() );
|
||||
}
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
@@ -440,18 +392,20 @@ void MainWindow::format()
|
||||
QMessageBox::warning( this, QApplication::applicationName(), warningMsg );
|
||||
printMessage( warningMsg, CLP_LOG_ERROR );
|
||||
qDebug() << warningMsg;
|
||||
m_pcCurrentSubWindow->close();
|
||||
}
|
||||
updateMainWindow();
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::reload()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow<SubWindowAbstract>();
|
||||
if( activeSubWindow != nullptr )
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
activeSubWindow->refreshSubWindow();
|
||||
updateMainWindow();
|
||||
m_pcCurrentSubWindow->refreshSubWindow();
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -471,16 +425,16 @@ void MainWindow::reloadAll()
|
||||
subWindowList.at( i )->refreshSubWindow();
|
||||
}
|
||||
}
|
||||
updateMainWindow();
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
update();
|
||||
}
|
||||
|
||||
void MainWindow::loadAll()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
|
||||
if( activeSubWindow != nullptr )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
printMessage( "Loading file into memory...", CLP_LOG_INFO );
|
||||
activeSubWindow->loadAll();
|
||||
m_pcCurrentVideoSubWindow->loadAll();
|
||||
printMessage( "File loaded", CLP_LOG_INFO );
|
||||
}
|
||||
}
|
||||
@@ -489,45 +443,40 @@ void MainWindow::loadAll()
|
||||
|
||||
void MainWindow::normalSize()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
if( activeSubWindow != nullptr )
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
activeSubWindow->normalSize();
|
||||
m_pcCurrentSubWindow->normalSize();
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::zoomToFit()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
if( activeSubWindow != nullptr )
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
activeSubWindow->zoomToFit();
|
||||
m_pcCurrentSubWindow->zoomToFit();
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::zoomToFitAll()
|
||||
{
|
||||
VideoSubWindow* videoSubWindow;
|
||||
QList<SubWindowAbstract*> subWindowList = m_pcWindowHandle->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
auto* videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
videoSubWindow->zoomToFit();
|
||||
}
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
if( activeSubWindow != nullptr )
|
||||
{
|
||||
if( m_pcCurrentSubWindow )
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::scaleFrame( int ratio )
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
if( activeSubWindow != nullptr )
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
activeSubWindow->scaleView( (double)( ratio ) / 100.0 );
|
||||
m_pcCurrentSubWindow->scaleView( (double)( ratio ) / 100.0 );
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
}
|
||||
@@ -544,10 +493,10 @@ void MainWindow::zoomFromSBox( double zoom )
|
||||
|
||||
void MainWindow::updateZoomFactorSBox()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
if( activeSubWindow != nullptr )
|
||||
double factor;
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
auto factor = activeSubWindow->getScaleFactor();
|
||||
factor = m_pcCurrentSubWindow->getScaleFactor();
|
||||
m_pcZoomFactorSBox->setValue( factor * 100 );
|
||||
}
|
||||
}
|
||||
@@ -568,48 +517,60 @@ void MainWindow::dropEvent( QDropEvent* event )
|
||||
if( urlList.size() == 1 )
|
||||
{
|
||||
QString fileName = urlList.at( 0 ).toLocalFile();
|
||||
m_lastOpenPath = QFileInfo( fileName ).path();
|
||||
m_cLastOpenPath = QFileInfo( fileName ).path();
|
||||
loadFile( fileName );
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------- Sub Window Functions -----------------------
|
||||
|
||||
VideoStreamSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
||||
const QString& fileName )
|
||||
VideoSubWindow* MainWindow::findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
||||
const QString& fileName )
|
||||
{
|
||||
QString canonicalFilePath = QFileInfo( fileName ).canonicalFilePath();
|
||||
VideoSubWindow* pcSubWindow;
|
||||
QList<SubWindowAbstract*> subWindowList = windowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
auto* pcSubWindow = qobject_cast<VideoStreamSubWindow*>( subWindowList.at( i ) );
|
||||
if( pcSubWindow->getCurrentFileName() == canonicalFilePath ) return pcSubWindow;
|
||||
pcSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
if( pcSubWindow->getCurrentFileName() == canonicalFilePath )
|
||||
return qobject_cast<VideoSubWindow*>( pcSubWindow );
|
||||
}
|
||||
return nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------- Update Functions -----------------------
|
||||
|
||||
void MainWindow::updateMainWindow()
|
||||
void MainWindow::update()
|
||||
{
|
||||
auto* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
auto* activeVideoSubWindow = qobject_cast<VideoSubWindow*>( activeSubWindow );
|
||||
SubWindowAbstract* activeSubWindow = m_pcWindowHandle->activeSubWindow();
|
||||
QCoreApplication::processEvents();
|
||||
// if( activeSubWindow() != m_pcCurrentSubWindow )
|
||||
{
|
||||
m_pcCurrentSubWindow = NULL;
|
||||
m_pcCurrentVideoSubWindow = NULL;
|
||||
if( activeSubWindow )
|
||||
{
|
||||
if( activeVideoSubWindow != nullptr &&
|
||||
!m_pcWindowHandle->findSubWindow( activeVideoSubWindow->getRefSubWindow() ) )
|
||||
m_pcCurrentSubWindow = activeSubWindow;
|
||||
|
||||
if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_SUBWINDOW )
|
||||
{
|
||||
activeVideoSubWindow->setRefSubWindow( nullptr );
|
||||
m_pcCurrentVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcCurrentSubWindow );
|
||||
}
|
||||
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
if( !m_pcWindowHandle->findSubWindow( m_pcCurrentVideoSubWindow->getRefSubWindow() ) )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->setRefSubWindow( NULL );
|
||||
}
|
||||
}
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
}
|
||||
//! Check this - these two function should swap order
|
||||
m_appModuleQuality->update( activeVideoSubWindow );
|
||||
m_appModuleVideo->update( activeVideoSubWindow );
|
||||
m_appModuleQuality->update( m_pcCurrentVideoSubWindow );
|
||||
m_appModuleVideo->update( m_pcCurrentVideoSubWindow );
|
||||
updateMenus();
|
||||
}
|
||||
|
||||
@@ -634,14 +595,10 @@ void MainWindow::updateMenus()
|
||||
{
|
||||
bool hasSubWindow = ( m_pcWindowHandle->activeSubWindow() != 0 );
|
||||
|
||||
bool hasVideoStreamSubWindow{ false };
|
||||
bool supportsFormat{ false };
|
||||
auto* pcVideoSubWindow = m_pcWindowHandle->activeSubWindow<VideoStreamSubWindow>();
|
||||
if( pcVideoSubWindow != nullptr && pcVideoSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
{
|
||||
hasVideoStreamSubWindow = true;
|
||||
supportsFormat = pcVideoSubWindow->supportsFormatConfiguration();
|
||||
}
|
||||
bool hasVideoStreamSubWindow = false;
|
||||
if( m_pcCurrentSubWindow )
|
||||
if( m_pcCurrentSubWindow->getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
hasVideoStreamSubWindow = true;
|
||||
|
||||
m_arrayMenu[RECENT_MENU]->setEnabled( m_aRecentFileStreamInfo.size() > 0 ? true : false );
|
||||
|
||||
@@ -651,7 +608,7 @@ void MainWindow::updateMenus()
|
||||
m_arrayActions[RELOAD_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[RELOAD_ALL_ACT]->setEnabled( hasSubWindow );
|
||||
|
||||
m_arrayActions[FORMAT_ACT]->setEnabled( supportsFormat );
|
||||
m_arrayActions[FORMAT_ACT]->setEnabled( hasVideoStreamSubWindow );
|
||||
m_arrayActions[LOAD_ALL_ACT]->setEnabled( hasVideoStreamSubWindow );
|
||||
|
||||
m_arrayActions[ZOOM_IN_ACT]->setEnabled( hasSubWindow );
|
||||
@@ -706,19 +663,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() ) );
|
||||
|
||||
@@ -741,17 +698,22 @@ 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], &QAction::triggered, [this] { scaleFrame( 125 ); } );
|
||||
connect( m_arrayActions[ZOOM_IN_ACT], SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
|
||||
mapperZoom->setMapping( m_arrayActions[ZOOM_IN_ACT], 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], &QAction::triggered, [this] { scaleFrame( 80 ); } );
|
||||
connect( m_arrayActions[ZOOM_OUT_ACT], SIGNAL( triggered() ), mapperZoom, SLOT( map() ) );
|
||||
mapperZoom->setMapping( m_arrayActions[ZOOM_OUT_ACT], 80 );
|
||||
|
||||
m_arrayActions[ZOOM_NORMAL_ACT] = new QAction( tr( "&Normal Size" ), this );
|
||||
m_arrayActions[ZOOM_NORMAL_ACT]->setIcon( QIcon::fromTheme( "zoom-original" ) );
|
||||
@@ -840,9 +802,12 @@ void MainWindow::createMenus()
|
||||
|
||||
menuBar()->addMenu( m_appModuleVideo->createVideoMenu() );
|
||||
menuBar()->addMenu( m_appModuleVideo->createImageMenu() );
|
||||
menuBar()->addMenu( m_appModuleQuality->createMenu() );
|
||||
menuBar()->addMenu( m_appModuleExtensions->createMenu() );
|
||||
menuBar()->addMenu( m_pcWindowHandle->createMenu() );
|
||||
QMenu* QualityMenu = m_appModuleQuality->createMenu();
|
||||
menuBar()->addMenu( QualityMenu );
|
||||
QMenu* ModuleMenu = m_appModuleExtensions->createMenu();
|
||||
menuBar()->addMenu( ModuleMenu );
|
||||
QMenu* windowMenu = m_pcWindowHandle->createMenu();
|
||||
menuBar()->addMenu( windowMenu );
|
||||
|
||||
menuBar()->addSeparator();
|
||||
|
||||
@@ -857,17 +822,19 @@ void MainWindow::createMenus()
|
||||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
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.resize( TOTAL_TOOLBAR );
|
||||
|
||||
auto* viewToolBar = addToolBar( tr( "View" ) );
|
||||
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] );
|
||||
|
||||
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 );
|
||||
@@ -875,15 +842,14 @@ 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] );
|
||||
|
||||
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 );
|
||||
m_arrayToolBars[FILE_TOOLBAR]->setMovable( false );
|
||||
addToolBar( Qt::TopToolBarArea, m_arrayToolBars[VIEW_TOOLBAR] );
|
||||
|
||||
addToolBar( Qt::TopToolBarArea, m_appModuleVideo->createToolBar() );
|
||||
}
|
||||
@@ -906,17 +872,12 @@ 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()
|
||||
@@ -956,7 +917,6 @@ 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 );
|
||||
@@ -976,10 +936,7 @@ void MainWindow::readSettings()
|
||||
move( pos );
|
||||
resize( size );
|
||||
|
||||
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>();
|
||||
m_cLastOpenPath = appSettings.value( "MainWindow/LastOpenPath", QDir::homePath() ).toString();
|
||||
|
||||
QVariant value = appSettings.value( "MainWindow/RecentFileList" );
|
||||
m_aRecentFileStreamInfo = value.value<CalypFileInfoVector>();
|
||||
@@ -998,13 +955,10 @@ void MainWindow::writeSettings()
|
||||
|
||||
appSettings.setValue( "MainWindow/Position", pos() );
|
||||
appSettings.setValue( "MainWindow/Size", size() );
|
||||
appSettings.setValue( "MainWindow/LastOpenPath", m_lastOpenPath );
|
||||
appSettings.setValue( "MainWindow/LastWidth", m_lastOpenWidth );
|
||||
appSettings.setValue( "MainWindow/LastHeight", m_lastOpenHeight );
|
||||
appSettings.setValue( "MainWindow/LastBitsPerPixel", m_lastOpenBitPerPixel );
|
||||
appSettings.setValue( "MainWindow/LastOpenPath", m_cLastOpenPath );
|
||||
|
||||
QVariant var;
|
||||
var.setValue( m_aRecentFileStreamInfo );
|
||||
var.setValue<CalypFileInfoVector>( m_aRecentFileStreamInfo );
|
||||
appSettings.setValue( "MainWindow/RecentFileList", var );
|
||||
|
||||
m_appModuleVideo->writeSettings();
|
||||
|
||||
+25
-22
@@ -36,20 +36,16 @@
|
||||
#ifndef __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <optional>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoStreamSubWindow.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_QTDBUS
|
||||
#include "DBusAppAdaptor.h"
|
||||
#endif
|
||||
#include "ResourceHandle.h"
|
||||
#include "VideostreamResource.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class QCloseEvent;
|
||||
class QDragEnterEvent;
|
||||
@@ -62,7 +58,6 @@ class QSignalMapper;
|
||||
class CalypOptions;
|
||||
class CalypStream;
|
||||
class SubWindowHandle;
|
||||
class VideoStreamSubWindow;
|
||||
class VideoHandle;
|
||||
class QualityHandle;
|
||||
class ModulesHandle;
|
||||
@@ -78,8 +73,7 @@ class MainWindow : public QMainWindow
|
||||
public:
|
||||
MainWindow();
|
||||
bool parseArgs( int argc, char* argv[] );
|
||||
void loadFile( const CalypFileInfo& pStreamInfo );
|
||||
void loadFile( const QString& fileName, std::optional<CalypFileInfo> streamInfoOpt = {}, bool forceDialog = false );
|
||||
void loadFile( QString fileName, CalypFileInfo* pStreamInfo = NULL );
|
||||
|
||||
public Q_SLOTS:
|
||||
void printMessage( const QString& msg );
|
||||
@@ -120,7 +114,7 @@ private Q_SLOTS:
|
||||
void dragEnterEvent( QDragEnterEvent* event );
|
||||
void dropEvent( QDropEvent* event );
|
||||
|
||||
void updateMainWindow();
|
||||
void update();
|
||||
void updateZoomFactorSBox();
|
||||
|
||||
private:
|
||||
@@ -129,17 +123,14 @@ 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_lastOpenPath;
|
||||
unsigned int m_lastOpenWidth;
|
||||
unsigned int m_lastOpenHeight;
|
||||
unsigned int m_lastOpenBitPerPixel;
|
||||
QString m_cLastOpenPath;
|
||||
QStringList showFileDialog( bool bRead );
|
||||
|
||||
static VideoStreamSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
||||
const QString& fileName );
|
||||
static VideoSubWindow* findVideoStreamSubWindow( const SubWindowHandle* windowManager,
|
||||
const QString& fileName );
|
||||
|
||||
void updateMenus();
|
||||
|
||||
@@ -158,6 +149,7 @@ private:
|
||||
|
||||
QDoubleSpinBox* m_pcZoomFactorSBox;
|
||||
|
||||
QSignalMapper* mapperZoom;
|
||||
QSignalMapper* mapperWindow;
|
||||
|
||||
/**
|
||||
@@ -166,7 +158,6 @@ private:
|
||||
* Quality
|
||||
* Modules
|
||||
*/
|
||||
std::unique_ptr<ResourceHandle> m_appResourceHandle;
|
||||
VideoHandle* m_appModuleVideo;
|
||||
QualityHandle* m_appModuleQuality;
|
||||
ModulesHandle* m_appModuleExtensions;
|
||||
@@ -202,6 +193,18 @@ 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
|
||||
*/
|
||||
@@ -234,7 +237,7 @@ private:
|
||||
QVector<QAction*> m_arrayRecentFilesActions;
|
||||
CalypFileInfoVector m_aRecentFileStreamInfo;
|
||||
|
||||
AboutDialog* m_pcAboutDialog{ nullptr };
|
||||
AboutDialog* m_pcAboutDialog;
|
||||
};
|
||||
|
||||
#endif // __MAINWINDOW_H__
|
||||
@@ -32,7 +32,7 @@ MdiSubWindow::MdiSubWindow( QWidget* parent )
|
||||
: QMdiSubWindow( parent )
|
||||
{
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
}
|
||||
|
||||
QSize MdiSubWindow::sizeHint() const
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/* 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 ModuleSubWindow.cpp
|
||||
* \brief Video Sub windows handling
|
||||
*/
|
||||
|
||||
#include "ModuleSubWindow.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QStaticText>
|
||||
#include <cassert>
|
||||
|
||||
#include "ModulesHandle.h"
|
||||
|
||||
ModuleSubWindow::ModuleSubWindow( CalypAppModuleIf* module, QWidget* parent )
|
||||
: VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW, parent )
|
||||
{
|
||||
m_pcDisplayModule = module;
|
||||
}
|
||||
|
||||
ModuleSubWindow::~ModuleSubWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void ModuleSubWindow::resetWindowName()
|
||||
{
|
||||
QString windowName{ "Module" };
|
||||
if( auto module_ptr = m_pcDisplayModule )
|
||||
{
|
||||
windowName.append( " " ).append( module_ptr->getModule()->m_pchModuleLongName );
|
||||
}
|
||||
setWindowName( windowName );
|
||||
}
|
||||
|
||||
void ModuleSubWindow::updateVideoWindowInfo()
|
||||
{
|
||||
m_cStreamInformation = "";
|
||||
|
||||
m_cStreamInformation = "Module";
|
||||
if( auto module_ptr = m_pcDisplayModule )
|
||||
{
|
||||
const auto& arraySubWindows = module_ptr->getSubWindowList();
|
||||
QStringList windowInfoList;
|
||||
if( arraySubWindows.size() > 0 )
|
||||
{
|
||||
for( std::size_t i = 0; i < arraySubWindows.size(); i++ )
|
||||
{
|
||||
if( arraySubWindows[i]->getWindowName() != getWindowName() )
|
||||
{
|
||||
windowInfoList.append( QString( "Input %1 - " + arraySubWindows[i]->getWindowName() ).arg( i + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( module_ptr->hasFeature( ClpModuleFeature::HasInfo ) )
|
||||
{
|
||||
QStringList list = QString::fromStdString( module_ptr->moduleInfo() ).split( '\n' );
|
||||
windowInfoList.append( list );
|
||||
}
|
||||
if( windowInfoList.size() > 0 )
|
||||
{
|
||||
m_pcVideoInfo->setInformationTopLeft( windowInfoList );
|
||||
}
|
||||
}
|
||||
if( m_pcCurrFrameAsset )
|
||||
{
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrameAsset->getPelFmtName() );
|
||||
m_cStreamInformation += " | " + m_cPelFmtName;
|
||||
}
|
||||
if( m_cStreamInformation.isEmpty() )
|
||||
{
|
||||
m_cStreamInformation = " ";
|
||||
}
|
||||
}
|
||||
|
||||
bool ModuleSubWindow::isPlaying()
|
||||
{
|
||||
if( auto module_ptr = m_pcDisplayModule )
|
||||
{
|
||||
for( auto window : module_ptr->getSubWindowList() )
|
||||
{
|
||||
if( window->isPlaying() )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModuleSubWindow::refreshSubWindow()
|
||||
{
|
||||
if( auto module_ptr = m_pcDisplayModule )
|
||||
{
|
||||
setFillWindow( true );
|
||||
updateVideoWindowInfo();
|
||||
module_ptr->apply( isPlaying(), false );
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/* 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 ModuleSubWindow.h
|
||||
* \brief Video Sub windows handling
|
||||
*/
|
||||
|
||||
#ifndef __MODULESUBWINDOW_H__
|
||||
#define __MODULESUBWINDOW_H__
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QFuture>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "CalypAppModuleIf.h"
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class VideoInformation;
|
||||
|
||||
class ModuleSubWindow : public VideoSubWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ModuleSubWindow( CalypAppModuleIf* module, QWidget* parent = 0 );
|
||||
~ModuleSubWindow();
|
||||
|
||||
void resetWindowName();
|
||||
|
||||
void updateVideoWindowInfo();
|
||||
|
||||
bool isPlaying();
|
||||
void stop(){};
|
||||
void advanceOneFrame(){};
|
||||
auto getFrameNum() -> std::uint64_t { return 1; };
|
||||
|
||||
void refreshSubWindow();
|
||||
|
||||
void setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame );
|
||||
};
|
||||
|
||||
#endif // __MODULESUBWINDOW_H__
|
||||
+129
-108
@@ -27,7 +27,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "ModuleSubWindow.h"
|
||||
#include "ModulesHandleOptDialog.h"
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
@@ -36,7 +35,7 @@
|
||||
#include "modules/CalypModulesFactory.h"
|
||||
|
||||
ModulesHandle::ModulesHandle( QWidget* parent, SubWindowHandle* windowManager, VideoHandle* moduleVideo )
|
||||
: m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
|
||||
: QWidget( parent ), m_pcParent( parent ), m_pcMainWindowManager( windowManager ), m_appModuleVideo( moduleVideo )
|
||||
{
|
||||
setParent( m_pcParent );
|
||||
}
|
||||
@@ -51,32 +50,32 @@ void ModulesHandle::createActions()
|
||||
connect( m_pcActionMapper, SIGNAL( mapped( int ) ), this, SLOT( processOpt( int ) ) );
|
||||
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT] = new QAction( "Refresh while
|
||||
// playing", m_pcParent );
|
||||
// playing", parent() );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setStatusTip( "Force module
|
||||
// refreshing while playing" );
|
||||
// m_arrayActions[FORCE_PLAYING_REFRESH_ACT]->setCheckable( true );
|
||||
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT] = new QAction( "Load external module", m_pcParent );
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT] = new QAction( "Load external module", parent() );
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT]->setStatusTip( "Load an externally build module" );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], &QAction::triggered, this, &ModulesHandle::loadExternalModule );
|
||||
connect( m_arrayActions[LOAD_EXTERNAL_ACT], SIGNAL( triggered() ), this, SLOT( loadExternalModule() ) );
|
||||
|
||||
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", m_pcParent );
|
||||
m_arrayActions[APPLY_ALL_ACT] = new QAction( "Apply to All", parent() );
|
||||
m_arrayActions[APPLY_ALL_ACT]->setStatusTip( "Apply module to all frames and save the result" );
|
||||
connect( m_arrayActions[APPLY_ALL_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( m_arrayActions[APPLY_ALL_ACT], APPLY_ALL_ACT );
|
||||
|
||||
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", m_pcParent );
|
||||
m_arrayActions[SWAP_FRAMES_ACT] = new QAction( "Swap frames", parent() );
|
||||
m_arrayActions[SWAP_FRAMES_ACT]->setStatusTip( "Swap Sub Window order" );
|
||||
connect( m_arrayActions[SWAP_FRAMES_ACT], SIGNAL( triggered() ), m_pcActionMapper, SLOT( map() ) );
|
||||
m_pcActionMapper->setMapping( m_arrayActions[SWAP_FRAMES_ACT], SWAP_FRAMES_ACT );
|
||||
|
||||
m_arrayActions[DISABLE_ACT] = new QAction( "Disable Modules", m_pcParent );
|
||||
connect( m_arrayActions[DISABLE_ACT], &QAction::triggered, this, &ModulesHandle::destroyWindowModules );
|
||||
m_arrayActions[DISABLE_ACT] = new QAction( "Disable Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ACT], SIGNAL( triggered() ), this, SLOT( destroyWindowModules() ) );
|
||||
|
||||
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", m_pcParent );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], &QAction::triggered, this, &ModulesHandle::destroyAllModulesIf );
|
||||
m_arrayActions[DISABLE_ALL_ACT] = new QAction( "Disable All Modules", parent() );
|
||||
connect( m_arrayActions[DISABLE_ALL_ACT], SIGNAL( triggered() ), this, SLOT( destroyAllModulesIf() ) );
|
||||
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", m_pcParent );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT] = new QAction( "Use New Window", parent() );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setStatusTip(
|
||||
"Show module result in a new window. Some modules already force this "
|
||||
"feature" );
|
||||
@@ -85,28 +84,34 @@ void ModulesHandle::createActions()
|
||||
|
||||
QMenu* ModulesHandle::createMenu()
|
||||
{
|
||||
m_pcModulesMenu = new QMenu( "&Modules", m_pcParent );
|
||||
m_pcModulesMenu = new QMenu( "&Modules", this );
|
||||
buildMenu();
|
||||
return m_pcModulesMenu;
|
||||
}
|
||||
|
||||
void ModulesHandle::buildMenu()
|
||||
{
|
||||
for( auto& action : m_arrayModulesActions )
|
||||
CalypModuleIf* pcCurrModuleIf;
|
||||
QString ModuleIfinternalName;
|
||||
QAction* currAction;
|
||||
QMenu* currSubMenu;
|
||||
|
||||
for( int i = 0; i < m_arrayModulesActions.size(); i++ )
|
||||
{
|
||||
delete action;
|
||||
delete m_arrayModulesActions.at( i );
|
||||
}
|
||||
m_arrayModulesActions.clear();
|
||||
m_pcModulesMenu->clear();
|
||||
m_pcModulesSubMenuList.clear();
|
||||
|
||||
const auto& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
|
||||
for( auto& [name, create_fct] : moduleFactoryMap )
|
||||
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
|
||||
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
|
||||
for( ; it != moduleFactoryMap.end(); ++it )
|
||||
{
|
||||
auto pcCurrModuleIf = create_fct();
|
||||
QString moduleIfInternalName = QString::fromStdString( name );
|
||||
pcCurrModuleIf = it->second();
|
||||
ModuleIfinternalName = QString::fromLocal8Bit( it->first );
|
||||
|
||||
QMenu* currSubMenu{ nullptr };
|
||||
currSubMenu = NULL;
|
||||
if( pcCurrModuleIf->m_iModuleAPI <= CLP_MODULE_API_2 )
|
||||
{
|
||||
if( pcCurrModuleIf->m_pchModuleCategory )
|
||||
@@ -127,21 +132,23 @@ void ModulesHandle::buildMenu()
|
||||
}
|
||||
}
|
||||
|
||||
QAction* currAction = new QAction( pcCurrModuleIf->getModuleLongName(), m_pcParent );
|
||||
currAction = new QAction( pcCurrModuleIf->getModuleLongName(), parent() );
|
||||
QString moduleTooltip = pcCurrModuleIf->m_pchModuleTooltip;
|
||||
if( pcCurrModuleIf->m_uiNumberOfFrames > 1 )
|
||||
moduleTooltip += QString( " | Requires %1 frames" ).arg( pcCurrModuleIf->m_uiNumberOfFrames );
|
||||
|
||||
currAction->setStatusTip( moduleTooltip );
|
||||
currAction->setData( moduleIfInternalName );
|
||||
currAction->setData( ModuleIfinternalName );
|
||||
currAction->setCheckable( false );
|
||||
connect( currAction, &QAction::triggered, this, &ModulesHandle::activateModule );
|
||||
connect( currAction, SIGNAL( triggered() ), this, SLOT( activateModule() ) );
|
||||
m_arrayModulesActions.append( currAction );
|
||||
|
||||
if( currSubMenu )
|
||||
currSubMenu->addAction( currAction );
|
||||
else
|
||||
m_pcModulesMenu->addAction( currAction );
|
||||
|
||||
pcCurrModuleIf->Delete();
|
||||
}
|
||||
|
||||
m_pcModulesMenu->addAction( m_arrayActions[LOAD_EXTERNAL_ACT] );
|
||||
@@ -155,20 +162,20 @@ void ModulesHandle::buildMenu()
|
||||
|
||||
void ModulesHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
|
||||
bool hasSubWindow = pcSubWindow != nullptr ? true : false;
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
bool hasSubWindow = pcSubWindow ? true : false;
|
||||
QAction* currModuleAction;
|
||||
|
||||
for( int i = 0; i < m_arrayModulesActions.size(); i++ )
|
||||
{
|
||||
auto* currModuleAction = m_arrayModulesActions.at( i );
|
||||
// currModuleAction->setEnabled( hasSubWindow );
|
||||
currModuleAction = m_arrayModulesActions.at( i );
|
||||
//currModuleAction->setEnabled( hasSubWindow );
|
||||
currModuleAction->setChecked( false );
|
||||
}
|
||||
// for( int i = 0; i < m_pcModulesSubMenuList.size(); i++ )
|
||||
//for( int i = 0; i < m_pcModulesSubMenuList.size(); i++ )
|
||||
//{
|
||||
// m_pcModulesSubMenuList.at( i )->setEnabled( hasSubWindow );
|
||||
// }
|
||||
//}
|
||||
|
||||
for( int i = 0; i < m_arrayActions.size(); i++ )
|
||||
{
|
||||
@@ -176,21 +183,22 @@ void ModulesHandle::updateMenus()
|
||||
}
|
||||
m_arrayActions[LOAD_EXTERNAL_ACT]->setEnabled( true );
|
||||
m_arrayActions[FORCE_NEW_WINDOW_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[DISABLE_ALL_ACT]->setEnabled( true );
|
||||
m_arrayActions[DISABLE_ALL_ACT]->setEnabled( m_pcCalypAppModuleIfList.size() > 0 );
|
||||
|
||||
if( pcSubWindow )
|
||||
{
|
||||
m_arrayActions[DISABLE_ACT]->setEnabled( pcSubWindow->hasModules() );
|
||||
QList<CalypAppModuleIf*> apcCurrentModule = pcSubWindow->getModuleArray();
|
||||
m_arrayActions[DISABLE_ACT]->setEnabled( apcCurrentModule.size() > 0 );
|
||||
if( pcSubWindow->getDisplayModule() )
|
||||
{
|
||||
m_arrayActions[APPLY_ALL_ACT]->setEnabled( true );
|
||||
m_arrayActions[SWAP_FRAMES_ACT]->setEnabled( true );
|
||||
}
|
||||
// for( int i = 0; i < apcCurrentModule.size(); i++ )
|
||||
// {
|
||||
// currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction;
|
||||
// currModuleAction->setChecked( true );
|
||||
// }
|
||||
for( int i = 0; i < apcCurrentModule.size(); i++ )
|
||||
{
|
||||
currModuleAction = apcCurrentModule.at( i )->m_pcModuleAction;
|
||||
currModuleAction->setChecked( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,21 +216,22 @@ void ModulesHandle::writeSettings()
|
||||
|
||||
void ModulesHandle::processOpt( int index )
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcSubWindow )
|
||||
{
|
||||
CalypAppModuleIf* pcCurrentModule = pcSubWindow->getDisplayModule();
|
||||
if( pcCurrentModule )
|
||||
{
|
||||
CalypAppModuleIf* pcCurrModule = pcCurrentModule;
|
||||
switch( index )
|
||||
{
|
||||
case INVALID_OPT:
|
||||
break;
|
||||
case SWAP_FRAMES_ACT:
|
||||
swapModulesWindowsIf( pcCurrentModule );
|
||||
swapModulesWindowsIf( pcCurrModule );
|
||||
break;
|
||||
case APPLY_ALL_ACT:
|
||||
applyAllModuleIf( pcCurrentModule );
|
||||
applyAllModuleIf( pcCurrModule );
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT( 0 );
|
||||
@@ -257,7 +266,7 @@ void ModulesHandle::activateModule()
|
||||
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
|
||||
bool bTmpForceNewWindow = false;
|
||||
|
||||
VideoSubWindow* pcVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( !pcVideoSubWindow )
|
||||
{
|
||||
return;
|
||||
@@ -269,12 +278,9 @@ void ModulesHandle::activateModule()
|
||||
}
|
||||
|
||||
QString ModuleIfName = pcAction->data().toString();
|
||||
auto pcCurrModuleIf = CalypModulesFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
|
||||
if( pcCurrModuleIf == nullptr )
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto pcCurrAppModuleIf = std::make_shared<CalypAppModuleIf>( this, pcAction, std::move( pcCurrModuleIf ) );
|
||||
CalypModuleIf* pcCurrModuleIf =
|
||||
CalypModulesFactory::Get()->CreateModule( ModuleIfName.toLocal8Bit().constData() );
|
||||
CalypAppModuleIf* pcCurrAppModuleIf = new CalypAppModuleIf( this, pcAction, pcCurrModuleIf );
|
||||
|
||||
QList<VideoSubWindow*> videoSubWindowList;
|
||||
int numberOfFrames = pcCurrAppModuleIf->m_pcModule->m_uiNumberOfFrames;
|
||||
@@ -282,7 +288,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
int minNumFrames = numberOfFrames;
|
||||
int maxNumFrames = numberOfFrames;
|
||||
if( pcCurrAppModuleIf->m_pcModule->has( ClpModuleFeature::VariableNumOfFrames ) )
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULES_VARIABLE_NUM_FRAMES )
|
||||
{
|
||||
minNumFrames = numberOfFrames;
|
||||
maxNumFrames = 255;
|
||||
@@ -331,7 +337,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
videoSubWindowList.clear();
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Error! Incompatible frames", CLP_LOG_ERROR );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -346,7 +352,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )
|
||||
->printMessage( "Error! There is no windows to apply the module", CLP_LOG_ERROR );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -355,13 +361,13 @@ void ModulesHandle::activateModule()
|
||||
pcCurrAppModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i );
|
||||
}
|
||||
|
||||
if( pcCurrAppModuleIf->m_pcModule->has( ClpModuleFeature::Options ) )
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_OPTIONS )
|
||||
{
|
||||
ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrAppModuleIf.get() );
|
||||
ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrAppModuleIf );
|
||||
if( moduleOptDialog.runConfiguration() == QDialog::Rejected )
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Module canceled by user!", CLP_LOG_WARNINGS );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -370,12 +376,14 @@ void ModulesHandle::activateModule()
|
||||
|
||||
QString windowName;
|
||||
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == ClpModuleType::FrameProcessing )
|
||||
VideoSubWindow* pcModuleSubWindow = NULL;
|
||||
if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
if( bShowModulesNewWindow || pcCurrAppModuleIf->m_pcModule->has( ClpModuleFeature::NewWindow ) )
|
||||
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
|
||||
{
|
||||
auto pcModuleSubWindow = new ModuleSubWindow( pcCurrAppModuleIf.get() );
|
||||
pcModuleSubWindow->resetWindowName();
|
||||
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
|
||||
windowName.append( QStringLiteral( "Module " ) );
|
||||
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleLongName );
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
|
||||
// connect( pcModuleSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo,
|
||||
// SLOT( updateSelectionArea( QRect ) ) );
|
||||
@@ -384,15 +392,11 @@ void ModulesHandle::activateModule()
|
||||
// connect( pcModuleSubWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), m_appModuleVideo,
|
||||
// SLOT( moveAllScrollBars( const QPoint ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
pcCurrAppModuleIf->m_pcSubWindow[0]->setDisplayModule( pcCurrAppModuleIf.get() );
|
||||
}
|
||||
}
|
||||
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == ClpModuleType::FrameMeasurement )
|
||||
else if( pcCurrAppModuleIf->m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow = NULL;
|
||||
pcCurrAppModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrAppModuleIf.get() );
|
||||
pcCurrAppModuleIf->m_pcModuleDock = new ModuleHandleDock( m_pcParent, pcCurrAppModuleIf );
|
||||
QString titleDockWidget;
|
||||
titleDockWidget.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleName );
|
||||
titleDockWidget.append( " Information" );
|
||||
@@ -404,9 +408,19 @@ void ModulesHandle::activateModule()
|
||||
->addDockWidget( Qt::RightDockWidgetArea, pcCurrAppModuleIf->m_pcDockWidget );
|
||||
}
|
||||
|
||||
for( int i = 0; i < videoSubWindowList.size(); i++ )
|
||||
// Associate module with subwindows
|
||||
if( !pcCurrAppModuleIf->m_pcDisplaySubWindow && !pcCurrAppModuleIf->m_pcModuleDock )
|
||||
{
|
||||
pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf );
|
||||
pcCurrAppModuleIf->m_pcSubWindow[0]->enableModule( pcCurrAppModuleIf );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrAppModuleIf );
|
||||
for( int i = 0; i < videoSubWindowList.size(); i++ )
|
||||
{
|
||||
pcCurrAppModuleIf->m_pcSubWindow[i]->associateModule( pcCurrAppModuleIf );
|
||||
}
|
||||
}
|
||||
|
||||
// Create Module
|
||||
@@ -429,19 +443,19 @@ void ModulesHandle::activateModule()
|
||||
if( !moduleCreated )
|
||||
{
|
||||
qobject_cast<MainWindow*>( m_pcParent )->printMessage( "Error! Module cannot be created", CLP_LOG_ERROR );
|
||||
// destroyModuleIf( pcCurrAppModuleIf );
|
||||
destroyModuleIf( pcCurrAppModuleIf );
|
||||
return;
|
||||
}
|
||||
|
||||
pcCurrAppModuleIf->apply( false, true );
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
|
||||
if( pcModuleSubWindow )
|
||||
{
|
||||
m_pcMainWindowManager->addSubWindow( pcCurrAppModuleIf->m_pcDisplaySubWindow );
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow->show();
|
||||
m_appModuleVideo->addSubWindow( pcCurrAppModuleIf->m_pcDisplaySubWindow );
|
||||
pcModuleSubWindow->setWindowName( windowName );
|
||||
m_pcMainWindowManager->addSubWindow( pcModuleSubWindow );
|
||||
pcModuleSubWindow->show();
|
||||
m_appModuleVideo->addSubWindow( pcModuleSubWindow );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -451,39 +465,44 @@ void ModulesHandle::activateModule()
|
||||
videoSubWindowList.at( 0 )->setWindowName( windowName );
|
||||
}
|
||||
|
||||
// Change ownership of the module
|
||||
// if( !pcCurrAppModuleIf->m_pcDisplaySubWindow && !pcCurrAppModuleIf->m_pcModuleDock )
|
||||
// {
|
||||
// pcCurrAppModuleIf->m_pcSubWindow[0]->enableModule( pcCurrAppModuleIf );
|
||||
// }
|
||||
// else if( pcCurrAppModuleIf->m_pcDisplaySubWindow )
|
||||
// {
|
||||
// pcCurrAppModuleIf->m_pcDisplaySubWindow->enableModule( pcCurrAppModuleIf );
|
||||
// }
|
||||
m_pcCalypAppModuleIfList.append( pcCurrAppModuleIf );
|
||||
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ModulesHandle::destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
if( pcCurrModuleIf )
|
||||
{
|
||||
pcCurrModuleIf->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void ModulesHandle::destroyWindowModules()
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcVideoSubWindow )
|
||||
{
|
||||
pcVideoSubWindow->disableAllModules();
|
||||
pcVideoSubWindow->disableModule();
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
void ModulesHandle::destroyAllModulesIf()
|
||||
{
|
||||
bool emit_changed = false;
|
||||
QList<SubWindowAbstract*> windowsList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
for( auto window : windowsList )
|
||||
for( int i = 0; i < m_pcCalypAppModuleIfList.size(); i++ )
|
||||
{
|
||||
emit_changed |= qobject_cast<VideoSubWindow*>( window )->disableAllModules();
|
||||
destroyModuleIf( m_pcCalypAppModuleIfList.at( i ) );
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ModulesHandle::applyModuleIf( QList<CalypAppModuleIf*> pcCurrModuleIfList, bool isPlaying, bool disableThreads )
|
||||
{
|
||||
for( int i = 0; i < pcCurrModuleIfList.size() && !isPlaying; i++ )
|
||||
{
|
||||
pcCurrModuleIfList.at( i )->apply( isPlaying, disableThreads );
|
||||
}
|
||||
if( emit_changed )
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
@@ -492,18 +511,21 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
if( !pcCurrModuleIf->m_pcModuleStream )
|
||||
{
|
||||
unsigned int Width = 0, Height = 0, FrameRate = 30;
|
||||
int BitsPixel, InputFormat = -1;
|
||||
|
||||
QString supported = tr( "Supported Files (" );
|
||||
QStringList formatsList;
|
||||
std::vector<CalypStreamFormat> supportedFmts = CalypStream::supportedWriteFormats();
|
||||
|
||||
for( unsigned int i = 0; i < supportedFmts.size(); i++ )
|
||||
{
|
||||
std::vector<std::string> arrayExt = supportedFmts[i].getExts();
|
||||
std::vector<ClpString> arrayExt = supportedFmts[i].getExts();
|
||||
if( arrayExt.size() > 0 )
|
||||
{
|
||||
QString currFmt( QString::fromStdString( supportedFmts[i].formatName ) );
|
||||
currFmt.append( " (" );
|
||||
for( std::vector<std::string>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
for( std::vector<ClpString>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
{
|
||||
supported.append( " *." );
|
||||
currFmt.append( "*." );
|
||||
@@ -524,17 +546,18 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto Width = pcCurrModuleIf->m_pcProcessedFrame->getWidth();
|
||||
auto Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
auto InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat();
|
||||
auto BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel();
|
||||
auto FrameRate = 30;
|
||||
Width = pcCurrModuleIf->m_pcProcessedFrame->getWidth();
|
||||
Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat();
|
||||
BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel();
|
||||
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
|
||||
|
||||
pcCurrModuleIf->m_pcModuleStream = std::unique_ptr<CalypStream>();
|
||||
pcCurrModuleIf->m_pcModuleStream = new CalypStream;
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel,
|
||||
CLP_LITTLE_ENDIAN, FrameRate, CalypStream::Type::Output ) )
|
||||
CLP_LITTLE_ENDIAN, FrameRate, false ) )
|
||||
{
|
||||
pcCurrModuleIf->m_pcModuleStream = nullptr;
|
||||
delete pcCurrModuleIf->m_pcModuleStream;
|
||||
pcCurrModuleIf->m_pcModuleStream = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -542,11 +565,11 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
if( pcCurrModuleIf->m_pcModuleStream )
|
||||
{
|
||||
unsigned int numberOfWindows = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames;
|
||||
std::uint64_t currFrames = 0;
|
||||
std::uint64_t numberOfFrames = -1;
|
||||
ClpULong currFrames = 0;
|
||||
ClpULong numberOfFrames = -1;
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getFrameNum();
|
||||
currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getInputStream()->getFrameNum();
|
||||
if( currFrames < numberOfFrames )
|
||||
numberOfFrames = currFrames;
|
||||
pcCurrModuleIf->m_pcSubWindow[i]->stop();
|
||||
@@ -556,10 +579,11 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
{
|
||||
pcCurrModuleIf->apply( false, true );
|
||||
QCoreApplication::processEvents();
|
||||
pcCurrModuleIf->m_pcModuleStream->writeFrame( *pcCurrModuleIf->m_pcProcessedFrame );
|
||||
pcCurrModuleIf->m_pcModuleStream->writeFrame( pcCurrModuleIf->m_pcProcessedFrame );
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
pcCurrModuleIf->m_pcSubWindow[i]->advanceOneFrame();
|
||||
pcCurrModuleIf->m_pcSubWindow[i]->play();
|
||||
pcCurrModuleIf->m_pcSubWindow[i]->playEvent();
|
||||
}
|
||||
}
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
@@ -585,15 +609,12 @@ void ModulesHandle::swapModulesWindowsIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
void ModulesHandle::customEvent( QEvent* event )
|
||||
{
|
||||
if( !event )
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
CalypAppModuleIf::EventData* eventData = (CalypAppModuleIf::EventData*)event;
|
||||
if( eventData->m_bSuccess )
|
||||
{
|
||||
event->accept();
|
||||
// The module could be freed by the time the event is processed
|
||||
if( eventData->m_pcModule.isNull() )
|
||||
return;
|
||||
eventData->m_pcModule->show();
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -39,7 +39,7 @@ class SubWindowHandle;
|
||||
class CalypAppModuleIf;
|
||||
class SubWindowHandle;
|
||||
|
||||
class ModulesHandle : public QObject
|
||||
class ModulesHandle : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -55,6 +55,10 @@ public:
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
static void destroyModuleIf( CalypAppModuleIf* pcCurrModuleIf );
|
||||
static void applyModuleIf( QList<CalypAppModuleIf*> pcCurrModuleIfList, bool isPlaying = false,
|
||||
bool disableThreads = false );
|
||||
|
||||
private:
|
||||
QWidget* m_pcParent;
|
||||
SubWindowHandle* m_pcMainWindowManager;
|
||||
|
||||
@@ -24,11 +24,8 @@
|
||||
|
||||
#include "PlotSubWindow.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QScreen>
|
||||
#include <QSize>
|
||||
|
||||
#include "qcustomplot.h"
|
||||
//#include "external/qcustomplot/qcustomplot.h"
|
||||
|
||||
void PlotSubWindow::definePlotColors()
|
||||
{
|
||||
@@ -177,7 +174,7 @@ QSize PlotSubWindow::sizeHint() const
|
||||
}
|
||||
else
|
||||
{
|
||||
maxSize = QGuiApplication::screens()[0]->availableGeometry().size();
|
||||
maxSize = QApplication::desktop()->availableGeometry().size();
|
||||
}
|
||||
return sizeHint( maxSize );
|
||||
}
|
||||
|
||||
+18
-16
@@ -32,9 +32,10 @@
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
QualityHandle::QualityHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParent( parent ), m_pcMainWindowManager( windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ void QualityHandle::createActions()
|
||||
|
||||
QMenu* QualityHandle::createMenu()
|
||||
{
|
||||
m_pcMenuQuality = new QMenu( "Quality", m_pcParent );
|
||||
m_pcMenuQuality = new QMenu( "Quality", this );
|
||||
m_pcSubMenuQualityMetrics = m_pcMenuQuality->addMenu( "Quality Metrics" );
|
||||
m_pcSubMenuQualityMetrics->addActions( m_actionGroupQualityMetric->actions() );
|
||||
m_pcMenuQuality->addAction( m_arrayActions[SELECT_CURR_REF_ACT] );
|
||||
@@ -82,8 +83,8 @@ QMenu* QualityHandle::createMenu()
|
||||
|
||||
QDockWidget* QualityHandle::createDock()
|
||||
{
|
||||
m_pcQualityHandleSideBar = new QualityMeasurementSidebar( m_pcParent, m_pcMainWindowManager );
|
||||
m_pcQualityHandleDock = new QDockWidget( tr( "Quality Measurement" ), m_pcParent );
|
||||
m_pcQualityHandleSideBar = new QualityMeasurementSidebar( m_pcParet, m_pcMainWindowManager );
|
||||
m_pcQualityHandleDock = new QDockWidget( tr( "Quality Measurement" ), this );
|
||||
m_pcQualityHandleDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
m_pcQualityHandleDock->setWidget( m_pcQualityHandleSideBar );
|
||||
|
||||
@@ -98,7 +99,7 @@ QDockWidget* QualityHandle::createDock()
|
||||
|
||||
void QualityHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcCurrentVideoSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcCurrentVideoSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
bool hasSubWindow = pcCurrentVideoSubWindow ? true : false;
|
||||
bool hasReference = false;
|
||||
bool isReference = false;
|
||||
@@ -156,8 +157,8 @@ void QualityHandle::update( VideoSubWindow* currSubWindow )
|
||||
void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
{
|
||||
unsigned numberOfWindows = apcWindowList.size();
|
||||
std::uint64_t currFrames = 0;
|
||||
std::uint64_t numberOfFrames = -1;
|
||||
ClpULong currFrames = 0;
|
||||
ClpULong numberOfFrames = -1;
|
||||
|
||||
//! Check reference window
|
||||
for( unsigned i = 0; i < numberOfWindows; i++ )
|
||||
@@ -169,20 +170,21 @@ void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
}
|
||||
VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow();
|
||||
|
||||
numberOfFrames = pcReferenceWindow->getFrameNum();
|
||||
numberOfFrames = pcReferenceWindow->getInputStream()->getFrameNum();
|
||||
for( unsigned i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
currFrames = apcWindowList.at( i )->getFrameNum();
|
||||
currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum();
|
||||
if( currFrames < numberOfFrames )
|
||||
numberOfFrames = currFrames;
|
||||
apcWindowList.at( i )->stop();
|
||||
}
|
||||
pcReferenceWindow->stop();
|
||||
|
||||
ProgressBar* pcProgressBar = new ProgressBar( m_pcParent, numberOfFrames );
|
||||
ProgressBar* pcProgressBar = new ProgressBar( m_pcParet, numberOfFrames );
|
||||
|
||||
QVector<double>* padQualityValues = new QVector<double>[numberOfWindows + 1];
|
||||
double* padAverageQuality = new double[numberOfWindows + 1];
|
||||
double dCurrentQuality;
|
||||
|
||||
for( unsigned i = 0; i < numberOfWindows + 1; i++ )
|
||||
{
|
||||
@@ -198,12 +200,12 @@ void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
pcCurrFrame = apcWindowList.at( i )->getCurrFrame();
|
||||
double dCurrentQuality = pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, CLP_LUMA );
|
||||
dCurrentQuality = pcCurrFrame->getQuality( m_iQualityMetricIdx, pcReferenceFrame, CLP_LUMA );
|
||||
padAverageQuality[i + 1] = ( padAverageQuality[i + 1] * double( f ) + dCurrentQuality ) / double( f + 1 );
|
||||
padQualityValues[i + 1].append( dCurrentQuality );
|
||||
apcWindowList.at( i )->advanceOneFrame();
|
||||
apcWindowList.at( i )->seekRelativeEvent( true );
|
||||
}
|
||||
pcReferenceWindow->advanceOneFrame();
|
||||
pcReferenceWindow->seekRelativeEvent( true );
|
||||
pcProgressBar->incrementProgress( 1 );
|
||||
}
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
@@ -247,7 +249,7 @@ void QualityHandle::slotQualityMetricChanged( int idx )
|
||||
|
||||
void QualityHandle::slotSelectCurrentAsReference()
|
||||
{
|
||||
VideoSubWindow* pcRefSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcRefSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcRefSubWindow )
|
||||
{
|
||||
VideoSubWindow* pcVideoSubWindow;
|
||||
@@ -267,7 +269,7 @@ void QualityHandle::slotSelectCurrentAsReference()
|
||||
|
||||
void QualityHandle::slotPlotQualitySingle()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcSubWindow )
|
||||
{
|
||||
if( pcSubWindow->getRefSubWindow() )
|
||||
@@ -291,7 +293,7 @@ void QualityHandle::slotPlotQualitySingle()
|
||||
|
||||
void QualityHandle::slotPlotQualitySeveral()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
if( pcSubWindow )
|
||||
{
|
||||
QVector<VideoSubWindow*> apcWindowList;
|
||||
|
||||
+3
-3
@@ -25,18 +25,18 @@
|
||||
#ifndef __QUALITYMEASUREMENT_H__
|
||||
#define __QUALITYMEASUREMENT_H__
|
||||
|
||||
#include <QFuture>
|
||||
#include <QtCore>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "QFuture"
|
||||
#include "QualityMeasurementSidebar.h"
|
||||
#include "config.h"
|
||||
|
||||
class SubWindowHandle;
|
||||
class VideoSubWindow;
|
||||
|
||||
class QualityHandle : public QObject
|
||||
class QualityHandle : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
void update( VideoSubWindow* currSubWindow );
|
||||
|
||||
private:
|
||||
QWidget* m_pcParent;
|
||||
QWidget* m_pcParet;
|
||||
SubWindowHandle* m_pcMainWindowManager;
|
||||
|
||||
enum
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
|
||||
* Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Santos (joaompssantos@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 ResourceHandle.cpp
|
||||
* \brief Handle resources
|
||||
*/
|
||||
|
||||
#include "ResourceHandle.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QEvent>
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
#include <memory>
|
||||
|
||||
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;
|
||||
if( m_bStarted )
|
||||
{
|
||||
wake();
|
||||
wait();
|
||||
}
|
||||
m_bStarted = false;
|
||||
}
|
||||
|
||||
void ResourceWorker::wake()
|
||||
{
|
||||
m_Mutex.lock();
|
||||
m_ResourceIdle.wakeAll();
|
||||
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
|
||||
for( ;; )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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 = 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 );
|
||||
return resource_id;
|
||||
}
|
||||
|
||||
auto ResourceHandle::getResource( CalypStream* ptr ) -> std::size_t
|
||||
{
|
||||
if( ptr != nullptr )
|
||||
{
|
||||
for( std::size_t i = 0; i < m_apcStreamResourcesList.size(); i++ )
|
||||
{
|
||||
if( auto* resource = dynamic_cast<OldStreamResource*>( m_apcStreamResourcesList[i].get() ) )
|
||||
{
|
||||
if( &resource->m_stream == ptr ) return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return addResource();
|
||||
}
|
||||
|
||||
auto ResourceHandle::getResourceAsset( std::size_t id ) -> CalypStream*
|
||||
{
|
||||
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_apcStreamResourcesList.contains( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove worker first
|
||||
m_apcStreamResourcesWorkersList[id]->stop();
|
||||
m_apcStreamResourcesWorkersList[id] = nullptr;
|
||||
|
||||
// Then the underlying stream
|
||||
m_apcStreamResourcesList[id] = nullptr;
|
||||
}
|
||||
|
||||
void ResourceHandle::stopResourceWorker( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.contains( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->stop();
|
||||
}
|
||||
|
||||
void ResourceHandle::startResourceWorker( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.contains( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->setObjectName(
|
||||
"RW-" +
|
||||
QFileInfo( QString::fromStdString( m_apcStreamResourcesList[id]->getResourceName() ) ).completeBaseName() );
|
||||
m_apcStreamResourcesWorkersList[id]->start();
|
||||
}
|
||||
|
||||
void ResourceHandle::wakeResourceWorker( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.contains( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->wake();
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/* 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 ResourceHandle.h
|
||||
* \brief Handle multiple sub-windows
|
||||
*/
|
||||
|
||||
#ifndef __RESOURCEHANDLE_H__
|
||||
#define __RESOURCEHANDLE_H__
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <QWaitCondition>
|
||||
#include <atomic>
|
||||
|
||||
#include "CalypResource.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class ResourceWorker : public QThread
|
||||
{
|
||||
private:
|
||||
QMutex m_Mutex;
|
||||
QWaitCondition m_ResourceIdle;
|
||||
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:
|
||||
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 start();
|
||||
void run() override;
|
||||
auto mutex() -> QMutex* { return &m_Mutex; }
|
||||
};
|
||||
|
||||
class ResourceWorker;
|
||||
|
||||
class ResourceHandle : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ResourceHandle();
|
||||
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: // 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;
|
||||
};
|
||||
|
||||
#endif // __RESOURCEHANDLE_H__
|
||||
@@ -26,26 +26,29 @@
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QGuiApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QIcon>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "MdiSubWindow.h"
|
||||
|
||||
SubWindowAbstract::SubWindowAbstract( QWidget* parent, unsigned int category )
|
||||
: QWidget{ parent }, m_uiCategory{ category }, m_cWindowName{ " " }
|
||||
: QWidget( parent ), m_cSubWindow( NULL )
|
||||
{
|
||||
setParent( parent );
|
||||
setVisible( false );
|
||||
// setFocusPolicy( Qt::WheelFocus );
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
|
||||
setWindowIcon( QIcon( ":/logos/calyp-icon.png" ) );
|
||||
|
||||
// setWidgetResizable( true );
|
||||
m_pcLayout = NULL;
|
||||
m_uiCategory = category;
|
||||
m_cWindowName = QString( " " );
|
||||
|
||||
connect( this, SIGNAL( destroyed() ), this, SLOT( onDestroyed() ) );
|
||||
}
|
||||
|
||||
@@ -84,20 +87,10 @@ bool SubWindowAbstract::mayClose()
|
||||
|
||||
QSize SubWindowAbstract::sizeHint() const
|
||||
{
|
||||
QSize maxSize;
|
||||
QWidget* p = parentWidget();
|
||||
if( p )
|
||||
{
|
||||
maxSize = p->size();
|
||||
}
|
||||
else
|
||||
{
|
||||
maxSize = QGuiApplication::screens()[0]->availableGeometry().size();
|
||||
}
|
||||
return sizeHint( maxSize );
|
||||
return QSize();
|
||||
}
|
||||
|
||||
QSize SubWindowAbstract::sizeHint( const QSize& maxSize ) const
|
||||
QSize SubWindowAbstract::sizeHint( const QSize& ) const
|
||||
{
|
||||
return QSize();
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ class SubWindowAbstract : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_pcLayout{ nullptr };
|
||||
QHBoxLayout* m_pcLayout;
|
||||
unsigned int m_uiCategory;
|
||||
QString m_cWindowName;
|
||||
|
||||
MdiSubWindow* m_cSubWindow{ nullptr };
|
||||
MdiSubWindow* m_cSubWindow;
|
||||
|
||||
public:
|
||||
enum SubWindowCategory
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
*/
|
||||
virtual void zoomToFit() = 0;
|
||||
/**
|
||||
* Scale the image (zoomed in or out) to specified absolute zoom value (1.0 =
|
||||
* Scale the image (zoomed in or out) to speficied absolute zoom value (1.0 =
|
||||
* original size).
|
||||
*/
|
||||
virtual void zoomToFactor( double factor, QPoint center = QPoint() ) = 0;
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
* Size related functions
|
||||
*/
|
||||
virtual QSize sizeHint() const;
|
||||
virtual QSize sizeHint( const QSize& maxSize ) const;
|
||||
virtual QSize sizeHint( const QSize& ) const;
|
||||
|
||||
/**
|
||||
* Window name
|
||||
|
||||
+25
-41
@@ -28,12 +28,11 @@
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMdiArea>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#include <QSignalMapper>
|
||||
#include <QStyle>
|
||||
@@ -48,7 +47,7 @@ public:
|
||||
MdiArea( QWidget* parent = 0 )
|
||||
: QMdiArea( parent ), m_pixmapLogo( ":/logos/calyp-logo.png" )
|
||||
{
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
}
|
||||
|
||||
void appendLogMessage( const QString& msg )
|
||||
@@ -84,7 +83,7 @@ private:
|
||||
};
|
||||
|
||||
SubWindowHandle::SubWindowHandle( QWidget* parent )
|
||||
: m_pcApp( qobject_cast<MainWindow*>( parent ) )
|
||||
: QWidget( parent )
|
||||
{
|
||||
m_iWindowMode = -1;
|
||||
m_pcWindowManagerLayout = NULL;
|
||||
@@ -93,7 +92,7 @@ SubWindowHandle::SubWindowHandle( QWidget* parent )
|
||||
m_apcSubWindowList.clear();
|
||||
m_apcMdiSubWindowList.clear();
|
||||
|
||||
m_pcCentralWidget = new QWidget;
|
||||
m_pcApp = qobject_cast<MainWindow*>( parentWidget() );
|
||||
// setWindowMode( DETACHEDSUBWINDOWMODE );
|
||||
setWindowMode( MDISUBWINDOWMODE );
|
||||
}
|
||||
@@ -151,11 +150,11 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
m_apcSubWindowList.at( i )->resize( m_apcSubWindowList.at( i )->sizeHint() );
|
||||
m_apcSubWindowList.at( i )->show();
|
||||
}
|
||||
m_pcCentralWidget->setVisible( false );
|
||||
m_pcApp->update();
|
||||
setVisible( false );
|
||||
parentWidget()->update();
|
||||
m_pcApp->showNormal();
|
||||
qApp->processEvents();
|
||||
QSize screenSize = QGuiApplication::screens()[0]->availableGeometry().size();
|
||||
QSize screenSize = QApplication::desktop()->availableGeometry().size();
|
||||
m_pcApp->move( 0, 0 );
|
||||
m_pcApp->resize( screenSize.width(), 5 );
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
@@ -163,13 +162,13 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
|
||||
if( iWindowMode == MDISUBWINDOWMODE )
|
||||
{
|
||||
m_pcCentralWidget->setVisible( true );
|
||||
setVisible( true );
|
||||
m_pcMdiArea = new MdiArea;
|
||||
m_pcMdiArea->setActivationOrder( QMdiArea::ActivationHistoryOrder );
|
||||
connect( m_pcMdiArea, SIGNAL( subWindowActivated( QMdiSubWindow* ) ), this, SLOT( updateActiveSubWindow() ) );
|
||||
m_pcWindowManagerLayout = new QHBoxLayout( m_pcCentralWidget );
|
||||
m_pcWindowManagerLayout = new QHBoxLayout( this );
|
||||
m_pcWindowManagerLayout->addWidget( m_pcMdiArea );
|
||||
m_pcCentralWidget->setLayout( m_pcWindowManagerLayout );
|
||||
setLayout( m_pcWindowManagerLayout );
|
||||
for( int i = 0; i < m_apcSubWindowList.size(); i++ )
|
||||
{
|
||||
addMdiSubWindow( m_apcSubWindowList.at( i ) );
|
||||
@@ -181,10 +180,6 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
}
|
||||
}
|
||||
m_iWindowMode = iWindowMode;
|
||||
// tileSubWindows();
|
||||
@@ -221,10 +216,6 @@ void SubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window )
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,14 +230,12 @@ void SubWindowHandle::addMdiSubWindow( SubWindowAbstract* window )
|
||||
SLOT( removeMdiSubWindow( MdiSubWindow* ) ) );
|
||||
}
|
||||
|
||||
void SubWindowHandle::addSubWindow( SubWindowAbstract* window )
|
||||
void SubWindowHandle::addSubWindow( SubWindowAbstract* window, Qt::WindowFlags flags )
|
||||
{
|
||||
if( window )
|
||||
{
|
||||
connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp,
|
||||
SLOT( printMessage( const QString& ) ) );
|
||||
connect( window, SIGNAL( zoomFactorChanged( const double, const QPoint ) ), m_pcApp,
|
||||
SLOT( updateZoomFactorSBox() ) );
|
||||
connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp, SLOT( printMessage( const QString& ) ) );
|
||||
connect( window, SIGNAL( zoomFactorChanged( const double, const QPoint ) ), m_pcApp, SLOT( updateZoomFactorSBox() ) );
|
||||
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
|
||||
{
|
||||
connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this,
|
||||
@@ -285,12 +274,7 @@ void SubWindowHandle::removeSubWindow( int windowIdx )
|
||||
if( !m_apcSubWindowList.isEmpty() )
|
||||
m_apcSubWindowList.front()->setFocus();
|
||||
else
|
||||
m_pcActiveWindow = nullptr;
|
||||
|
||||
if( m_pcActiveWindow == nullptr )
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
}
|
||||
m_pcActiveWindow = NULL;
|
||||
|
||||
emit changed();
|
||||
}
|
||||
@@ -319,6 +303,11 @@ void SubWindowHandle::removeActiveSubWindow()
|
||||
removeSubWindow( m_pcActiveWindow );
|
||||
}
|
||||
|
||||
SubWindowAbstract* SubWindowHandle::activeSubWindow() const
|
||||
{
|
||||
return m_pcActiveWindow;
|
||||
}
|
||||
|
||||
QList<SubWindowAbstract*> SubWindowHandle::findSubWindow( const unsigned int uiCategory ) const
|
||||
{
|
||||
QList<SubWindowAbstract*> apcSubWindowList;
|
||||
@@ -389,7 +378,7 @@ void SubWindowHandle::tileSubWindows()
|
||||
|
||||
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
|
||||
{
|
||||
QSize screenSize = QGuiApplication::screens()[0]->availableGeometry().size();
|
||||
QSize screenSize = QApplication::desktop()->availableGeometry().size();
|
||||
unsigned int minWindowsInRow = 1;
|
||||
while( ( screenSize.width() / minWindowsInRow ) > 500 )
|
||||
{
|
||||
@@ -485,12 +474,12 @@ void SubWindowHandle::createActions()
|
||||
m_actionGroupWindowMode->actions().at( m_iWindowMode )->setChecked( true );
|
||||
|
||||
m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( m_pcApp->style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
|
||||
connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) );
|
||||
|
||||
m_arrayActions[CLOSE_ACT] = new QAction( tr( "&Close" ), this );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( m_pcApp->style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setIcon( style()->standardIcon( QStyle::SP_DialogCloseButton ) );
|
||||
m_arrayActions[CLOSE_ACT]->setStatusTip( tr( "Close the active window" ) );
|
||||
connect( m_arrayActions[CLOSE_ACT], SIGNAL( triggered() ), this, SLOT( removeActiveSubWindow() ) );
|
||||
|
||||
@@ -513,14 +502,14 @@ void SubWindowHandle::createActions()
|
||||
|
||||
m_arrayActions[NEXT_WINDOWS_ACT] = new QAction( tr( "Ne&xt" ), this );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setShortcuts( QKeySequence::NextChild );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( m_pcApp->style()->standardIcon( QStyle::SP_ArrowRight ) ) );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowRight ) ) );
|
||||
m_arrayActions[NEXT_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the next window" ) );
|
||||
// connect( m_arrayActions[NEXT_WINDOWS_ACT], SIGNAL( triggered() ), this,
|
||||
// SLOT( activateNextSubWindow() ) );
|
||||
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT] = new QAction( tr( "Pre&vious" ), this );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setShortcuts( QKeySequence::PreviousChild );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( m_pcApp->style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_ArrowLeft ) ) );
|
||||
m_arrayActions[PREVIOUS_WINDOWS_ACT]->setStatusTip( tr( "Move the focus to the previous window" ) );
|
||||
// connect( m_arrayActions[PREVIOUS_WINDOWS_ACT], SIGNAL( triggered() ),
|
||||
// this, SLOT( activatePreviousSubWindow() ) );
|
||||
@@ -531,17 +520,12 @@ void SubWindowHandle::createActions()
|
||||
|
||||
QMenu* SubWindowHandle::createMenu()
|
||||
{
|
||||
m_pcMenuWindow = new QMenu( "&Window", m_pcApp );
|
||||
m_pcMenuWindow = new QMenu( "&Window", this );
|
||||
updateMenu();
|
||||
connect( m_pcMenuWindow, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
|
||||
return m_pcMenuWindow;
|
||||
}
|
||||
|
||||
auto SubWindowHandle::getWidget() -> QWidget*
|
||||
{
|
||||
return m_pcCentralWidget;
|
||||
}
|
||||
|
||||
void SubWindowHandle::updateMenu()
|
||||
{
|
||||
m_pcMenuWindow->clear();
|
||||
|
||||
+3
-11
@@ -42,7 +42,7 @@ class SubWindowAbstract;
|
||||
class MdiArea;
|
||||
class MdiSubWindow;
|
||||
|
||||
class SubWindowHandle : public QObject
|
||||
class SubWindowHandle : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -51,14 +51,9 @@ public:
|
||||
|
||||
void processLogMsg( const QString& msg );
|
||||
|
||||
void addSubWindow( SubWindowAbstract* widget );
|
||||
void addSubWindow( SubWindowAbstract* widget, Qt::WindowFlags flags = 0 );
|
||||
|
||||
template <class T = SubWindowAbstract>
|
||||
T* activeSubWindow() const
|
||||
{
|
||||
static_assert( std::is_base_of<SubWindowAbstract, T>::value, "T must inherit from SubWindowAbstract" );
|
||||
return qobject_cast<T*>( m_pcActiveWindow );
|
||||
}
|
||||
SubWindowAbstract* activeSubWindow() const;
|
||||
|
||||
QList<SubWindowAbstract*> findSubWindow( const unsigned int uiCategory = 0 ) const;
|
||||
QList<SubWindowAbstract*> findSubWindow( const QString& aName, const unsigned int uiCategory = 0 ) const;
|
||||
@@ -67,8 +62,6 @@ public:
|
||||
void createActions();
|
||||
QMenu* createMenu();
|
||||
|
||||
auto getWidget() -> QWidget*;
|
||||
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
@@ -83,7 +76,6 @@ private:
|
||||
int m_iWindowMode;
|
||||
QList<SubWindowAbstract*> m_apcSubWindowList;
|
||||
|
||||
QWidget* m_pcCentralWidget;
|
||||
QHBoxLayout* m_pcWindowManagerLayout;
|
||||
MdiArea* m_pcMdiArea;
|
||||
QList<MdiSubWindow*> m_apcMdiSubWindowList;
|
||||
|
||||
+148
-291
@@ -29,11 +29,8 @@
|
||||
#include <QLabel>
|
||||
#include <QSignalMapper>
|
||||
#include <QSlider>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
#include <QtGui>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
#include "FrameNumberWidget.h"
|
||||
#include "FramePropertiesDock.h"
|
||||
@@ -41,39 +38,36 @@
|
||||
#include "SeekStreamDialog.h"
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoStreamSubWindow.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
#include <QElapsedTimer>
|
||||
#endif
|
||||
|
||||
VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParent{ parent }
|
||||
, m_pcMainWindowManager{ windowManager }
|
||||
, m_pcPlayingTimer{ new QTimer{ this } }
|
||||
, m_pcFrameRateFeedbackTimer{ std::make_unique<QElapsedTimer>() }
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow = NULL;
|
||||
m_bIsPlaying = false;
|
||||
m_pcPlayingTimer = new QTimer;
|
||||
m_pcPlayingTimer->setTimerType( Qt::PreciseTimer );
|
||||
connect( m_pcPlayingTimer, &QTimer::timeout, this, &VideoHandle::playEvent );
|
||||
connect( m_pcPlayingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
||||
m_acPlayingSubWindows.clear();
|
||||
}
|
||||
|
||||
VideoHandle::~VideoHandle() = default;
|
||||
VideoHandle::~VideoHandle() {}
|
||||
|
||||
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" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPlay ) ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) ) );
|
||||
m_arrayActions[PLAY_ACT]->setShortcut( Qt::Key_Space );
|
||||
connect( m_arrayActions[PLAY_ACT], SIGNAL( triggered() ), this, SLOT( play() ) );
|
||||
|
||||
m_arrayActions[STOP_ACT] = new QAction( "Stop", this );
|
||||
m_arrayActions[STOP_ACT]->setStatusTip( "Stop" );
|
||||
m_arrayActions[STOP_ACT]->setIcon( QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaStop ) ) );
|
||||
m_arrayActions[STOP_ACT]->setIcon( QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaStop ) ) );
|
||||
connect( m_arrayActions[STOP_ACT], SIGNAL( triggered() ), this, SLOT( stop() ) );
|
||||
|
||||
m_mapperVideoSeek = new QSignalMapper( this );
|
||||
@@ -82,7 +76,7 @@ void VideoHandle::createActions()
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon(
|
||||
QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
|
||||
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) );
|
||||
m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left );
|
||||
connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, SLOT( map() ) );
|
||||
m_mapperVideoSeek->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 );
|
||||
@@ -90,7 +84,7 @@ void VideoHandle::createActions()
|
||||
m_arrayActions[VIDEO_FORWARD_ACT] = new QAction( "Video Forward", this );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setStatusTip( "Seek forward" );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setIcon(
|
||||
QIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
|
||||
QIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaSeekForward ) ) );
|
||||
m_arrayActions[VIDEO_FORWARD_ACT]->setShortcut( Qt::Key_Right );
|
||||
connect( m_arrayActions[VIDEO_FORWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, SLOT( map() ) );
|
||||
m_mapperVideoSeek->setMapping( m_arrayActions[VIDEO_FORWARD_ACT], 1 );
|
||||
@@ -127,24 +121,6 @@ void VideoHandle::createActions()
|
||||
connect( m_pcFrameSlider, SIGNAL( valueChanged( int ) ), this, SLOT( seekSliderEvent( int ) ) );
|
||||
|
||||
// ------------ Image ------------
|
||||
m_mapperComponent = new QSignalMapper( this );
|
||||
m_actionGroupComponent = new QActionGroup( this );
|
||||
m_actionGroupComponent->setExclusive( true );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "All" ), -1 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Red" ), 0 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Green" ), 1 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Blue" ), 2 );
|
||||
m_mapperComponent->setMapping( m_actionGroupComponent->addAction( "Alpha" ), 3 );
|
||||
for( int i = 0; i < m_actionGroupComponent->actions().size(); i++ )
|
||||
{
|
||||
m_actionGroupComponent->actions().at( i )->setCheckable( true );
|
||||
m_actionGroupComponent->actions().at( i )->setVisible( false );
|
||||
connect( m_actionGroupComponent->actions().at( i ), SIGNAL( triggered() ), m_mapperComponent, SLOT( map() ) );
|
||||
}
|
||||
m_actionGroupComponent->actions().at( 0 )->setChecked( true );
|
||||
m_actionGroupComponent->actions().at( 0 )->setVisible( true );
|
||||
connect( m_mapperComponent, SIGNAL( mapped( int ) ), this, SLOT( setComponent( int ) ) );
|
||||
|
||||
m_actionGroupTools = new QActionGroup( this );
|
||||
m_actionGroupTools->setExclusive( true );
|
||||
|
||||
@@ -156,7 +132,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 );
|
||||
@@ -164,7 +140,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 );
|
||||
@@ -172,7 +148,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 );
|
||||
@@ -180,11 +156,9 @@ void VideoHandle::createActions()
|
||||
m_mapperGrid = new QSignalMapper( this );
|
||||
m_actionGroupGrid = new QActionGroup( this );
|
||||
m_actionGroupGrid->setExclusive( true );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "4x4" ), 4 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "8x8" ), 8 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "16x16" ), 16 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "64x64" ), 64 );
|
||||
m_mapperGrid->setMapping( m_actionGroupGrid->addAction( "128x128" ), 128 );
|
||||
|
||||
for( int i = 0; i < m_actionGroupGrid->actions().size(); i++ )
|
||||
{
|
||||
@@ -202,11 +176,7 @@ void VideoHandle::createActions()
|
||||
|
||||
QMenu* VideoHandle::createVideoMenu()
|
||||
{
|
||||
if( m_pcParent == nullptr )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
m_pcMenuVideo = new QMenu( "Video", m_pcParent );
|
||||
m_pcMenuVideo = new QMenu( "Video", m_pcParet );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[PLAY_ACT] );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[STOP_ACT] );
|
||||
m_pcMenuVideo->addAction( m_arrayActions[VIDEO_BACKWARD_ACT] );
|
||||
@@ -221,13 +191,7 @@ 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() );
|
||||
m_pcMenuImage = new QMenu( "Image", m_pcParet );
|
||||
m_pcMenuImage->addAction( m_arrayActions[NAVIGATION_TOOL_ACT] );
|
||||
m_pcMenuImage->addAction( m_arrayActions[SELECTION_TOOL_ACT] );
|
||||
m_pcMenuImage->addAction( m_arrayActions[BLOCK_SELECTION_TOOL_ACT] );
|
||||
@@ -238,16 +202,14 @@ QMenu* VideoHandle::createImageMenu()
|
||||
return m_pcMenuImage;
|
||||
}
|
||||
|
||||
auto VideoHandle::createToolBar() -> QPointer<QToolBar>
|
||||
QToolBar* VideoHandle::createToolBar()
|
||||
{
|
||||
if( m_pcParent == nullptr ) return nullptr;
|
||||
|
||||
QPointer m_toolbarVideo = new QToolBar( tr( "Video" ) );
|
||||
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] );
|
||||
|
||||
QPointer pcLockLabel = new QLabel( "PlayingLock" );
|
||||
QLabel* pcLockLabel = new QLabel( "PlayingLock" );
|
||||
pcLockLabel->setAlignment( Qt::AlignCenter );
|
||||
m_arrayActions[VIDEO_LOCK_ACT] = m_toolbarVideo->addWidget( pcLockLabel );
|
||||
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
|
||||
@@ -256,7 +218,6 @@ auto VideoHandle::createToolBar() -> QPointer<QToolBar>
|
||||
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 );
|
||||
|
||||
@@ -265,12 +226,8 @@ auto VideoHandle::createToolBar() -> QPointer<QToolBar>
|
||||
|
||||
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_pcFramePropertiesSideBar = new FramePropertiesDock( m_pcParet, &m_bIsPlaying );
|
||||
m_pcFramePropertiesDock = new QDockWidget( tr( "Frame Information" ), m_pcParet );
|
||||
m_pcFramePropertiesDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
m_pcFramePropertiesDock->setWidget( m_pcFramePropertiesSideBar );
|
||||
connect( m_pcFramePropertiesDock, SIGNAL( visibilityChanged( bool ) ), this, SLOT( update() ) );
|
||||
@@ -280,19 +237,9 @@ QDockWidget* VideoHandle::createDock()
|
||||
|
||||
QWidget* VideoHandle::createStatusBarMessage()
|
||||
{
|
||||
if( m_pcParent == nullptr )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
QWidget* pcStatusBarWidget = new QWidget;
|
||||
QHBoxLayout* mainlayout = new QHBoxLayout;
|
||||
|
||||
m_pcPlayingFPSLabel = new QLabel;
|
||||
m_pcPlayingFPSLabel->setText( " " );
|
||||
m_pcPlayingFPSLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
||||
m_pcPlayingFPSLabel->setMinimumWidth( 150 );
|
||||
m_pcPlayingFPSLabel->setAlignment( Qt::AlignCenter );
|
||||
|
||||
m_pcVideoFormatLabel = new QLabel;
|
||||
m_pcVideoFormatLabel->setText( " " );
|
||||
m_pcVideoFormatLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
|
||||
@@ -305,7 +252,6 @@ QWidget* VideoHandle::createStatusBarMessage()
|
||||
m_pcResolutionLabel->setMinimumWidth( 90 );
|
||||
m_pcResolutionLabel->setAlignment( Qt::AlignCenter );
|
||||
|
||||
mainlayout->addWidget( m_pcPlayingFPSLabel );
|
||||
mainlayout->addWidget( m_pcVideoFormatLabel );
|
||||
mainlayout->addWidget( m_pcResolutionLabel );
|
||||
pcStatusBarWidget->setLayout( mainlayout );
|
||||
@@ -313,65 +259,9 @@ QWidget* VideoHandle::createStatusBarMessage()
|
||||
return pcStatusBarWidget;
|
||||
}
|
||||
|
||||
void VideoHandle::updateComponentMenu()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
if( pcSubWindow == nullptr )
|
||||
{
|
||||
m_menuComponent->setEnabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
const auto* frame = pcSubWindow->getCurrFrame();
|
||||
if( frame == nullptr )
|
||||
{
|
||||
m_menuComponent->setEnabled( false );
|
||||
return;
|
||||
}
|
||||
|
||||
m_menuComponent->setEnabled( true );
|
||||
for( int i = 1; i < m_actionGroupComponent->actions().size(); i++ )
|
||||
{
|
||||
m_actionGroupComponent->actions()[i]->setChecked( false );
|
||||
m_actionGroupComponent->actions()[i]->setVisible( false );
|
||||
}
|
||||
switch( frame->getColorSpace() )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Gray" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
break;
|
||||
case CLP_COLOR_YUV:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Luminance" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 2 )->setText( QStringLiteral( "Chrominance U (Cb)" ) );
|
||||
m_actionGroupComponent->actions().at( 2 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 3 )->setText( QStringLiteral( "Chrominance V (Cr)" ) );
|
||||
m_actionGroupComponent->actions().at( 3 )->setVisible( true );
|
||||
break;
|
||||
case CLP_COLOR_RGBA:
|
||||
m_actionGroupComponent->actions().at( 4 )->setText( QStringLiteral( "Alpha" ) );
|
||||
m_actionGroupComponent->actions().at( 4 )->setVisible( true );
|
||||
[[fallthrough]];
|
||||
case CLP_COLOR_RGB:
|
||||
m_actionGroupComponent->actions().at( 1 )->setText( QStringLiteral( "Red" ) );
|
||||
m_actionGroupComponent->actions().at( 1 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 2 )->setText( QStringLiteral( "Green" ) );
|
||||
m_actionGroupComponent->actions().at( 2 )->setVisible( true );
|
||||
m_actionGroupComponent->actions().at( 3 )->setText( QStringLiteral( "Blue" ) );
|
||||
m_actionGroupComponent->actions().at( 3 )->setVisible( true );
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT( false );
|
||||
}
|
||||
auto component = pcSubWindow->getViewArea()->getFilteredChannel();
|
||||
int idx = component.has_value() ? *component : 0;
|
||||
m_actionGroupComponent->actions().at( idx )->setChecked( true );
|
||||
}
|
||||
|
||||
void VideoHandle::updateMenus()
|
||||
{
|
||||
VideoSubWindow* pcSubWindow = m_pcMainWindowManager->activeSubWindow<VideoSubWindow>();
|
||||
VideoSubWindow* pcSubWindow = qobject_cast<VideoSubWindow*>( m_pcMainWindowManager->activeSubWindow() );
|
||||
bool hasSubWindow = pcSubWindow ? true : false;
|
||||
|
||||
m_arrayActions[PLAY_ACT]->setEnabled( hasSubWindow );
|
||||
@@ -397,8 +287,6 @@ void VideoHandle::updateMenus()
|
||||
m_arrayActions[SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[BLOCK_SELECTION_TOOL_ACT]->setEnabled( hasSubWindow );
|
||||
m_arrayActions[SHOW_GRID_ACT]->setEnabled( hasSubWindow );
|
||||
|
||||
updateComponentMenu();
|
||||
}
|
||||
|
||||
void VideoHandle::readSettings()
|
||||
@@ -406,7 +294,8 @@ 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 );
|
||||
@@ -428,16 +317,13 @@ void VideoHandle::update()
|
||||
{
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
bool isPlaying{ false };
|
||||
const CalypStream* pcStream{ nullptr };
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
pcStream = videoStreamSubWindow->getInputStream();
|
||||
isPlaying = videoStreamSubWindow->isPlaying();
|
||||
}
|
||||
auto pcFrame = m_pcCurrentVideoSubWindow->getCurrFrameAsset();
|
||||
CalypStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream();
|
||||
CalypFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
|
||||
|
||||
m_pcVideoFormatLabel->setText( m_pcCurrentVideoSubWindow->getVideoInformation() );
|
||||
unsigned long frame_num = 0;
|
||||
unsigned long total_frame_num = 1;
|
||||
|
||||
m_pcVideoFormatLabel->setText( m_pcCurrentVideoSubWindow->getStreamInformation() );
|
||||
|
||||
QString resolution;
|
||||
if( pcFrame )
|
||||
@@ -445,8 +331,6 @@ void VideoHandle::update()
|
||||
resolution.append( QString( "%1x%2" ).arg( pcFrame->getWidth() ).arg( pcFrame->getHeight() ) );
|
||||
}
|
||||
|
||||
unsigned long frame_num = 0;
|
||||
unsigned long total_frame_num = 1;
|
||||
if( pcStream )
|
||||
{
|
||||
frame_num = pcStream->getCurrFrameNum();
|
||||
@@ -471,7 +355,8 @@ void VideoHandle::update()
|
||||
}
|
||||
}
|
||||
m_pcResolutionLabel->setText( resolution );
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame, isPlaying );
|
||||
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame );
|
||||
|
||||
m_pcFrameNumInfo->setTotalFrameNum( total_frame_num );
|
||||
m_pcFrameNumInfo->setCurrFrameNum( frame_num );
|
||||
@@ -481,25 +366,19 @@ void VideoHandle::update()
|
||||
m_pcFrameSlider->setValue( frame_num );
|
||||
m_pcFrameSlider->blockSignals( false );
|
||||
|
||||
if( m_uiRealAverageFrameRate > 0 )
|
||||
{
|
||||
m_pcPlayingFPSLabel->setText( QString( "%1 fps" ).arg( m_uiRealAverageFrameRate ) );
|
||||
}
|
||||
|
||||
if( m_pcCurrentVideoSubWindow->isPlaying() )
|
||||
{
|
||||
m_arrayActions[PLAY_ACT]->setText( "Pause" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPause ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPause ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arrayActions[PLAY_ACT]->setText( "Play" );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParent->style()->standardIcon( QStyle::SP_MediaPlay ) );
|
||||
m_arrayActions[PLAY_ACT]->setIcon( m_pcParet->style()->standardIcon( QStyle::SP_MediaPlay ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcPlayingFPSLabel->setText( "" );
|
||||
m_pcVideoFormatLabel->setText( "" );
|
||||
m_pcResolutionLabel->setText( "" );
|
||||
m_pcFramePropertiesSideBar->reset();
|
||||
@@ -528,45 +407,48 @@ 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 ) ) );
|
||||
}
|
||||
|
||||
void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow )
|
||||
{
|
||||
auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( subWindow );
|
||||
VideoSubWindow* videoSubWindow = qobject_cast<VideoSubWindow*>( subWindow );
|
||||
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
if( m_acPlayingSubWindows.contains( videoSubWindow ) )
|
||||
{
|
||||
int pos = m_acPlayingSubWindows.indexOf( videoStreamSubWindow );
|
||||
int pos = m_acPlayingSubWindows.indexOf( videoSubWindow );
|
||||
m_acPlayingSubWindows.at( pos )->stop();
|
||||
m_acPlayingSubWindows.remove( pos );
|
||||
if( m_acPlayingSubWindows.size() < 2 )
|
||||
{
|
||||
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
|
||||
}
|
||||
}
|
||||
if( subWindow == m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
m_pcFramePropertiesSideBar->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::zoomToFactorAll( const double scale, const QPoint center )
|
||||
{
|
||||
double factor;
|
||||
|
||||
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() )
|
||||
{
|
||||
double factor = m_pcCurrentVideoSubWindow->getScaleFactor();
|
||||
factor = m_pcCurrentVideoSubWindow->getScaleFactor();
|
||||
|
||||
SubWindowAbstract* subWindow;
|
||||
QList<SubWindowAbstract*> subWindowList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
SubWindowAbstract* subWindow = subWindowList.at( i );
|
||||
subWindow = subWindowList.at( i );
|
||||
if( m_pcCurrentVideoSubWindow == subWindow )
|
||||
continue;
|
||||
else
|
||||
@@ -620,12 +502,12 @@ void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa
|
||||
{
|
||||
if( m_arrayActions[VIDEO_ZOOM_LOCK_ACT]->isChecked() && m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
QList<SubWindowAbstract*> subWindowList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
VideoSubWindow* videoSubWindow;
|
||||
QList<SubWindowAbstract*> subWindowList = m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_SUBWINDOW );
|
||||
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
VideoSubWindow* videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
if( m_pcCurrentVideoSubWindow == videoSubWindow )
|
||||
continue;
|
||||
else
|
||||
@@ -639,20 +521,22 @@ void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa
|
||||
|
||||
unsigned long VideoHandle::getMaxFrameNumber()
|
||||
{
|
||||
std::uint64_t maxFrames = std::numeric_limits<std::uint64_t>::max();
|
||||
unsigned long currFrames;
|
||||
unsigned long maxFrames = INT_MAX;
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) ) )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
auto currFrames = m_acPlayingSubWindows.at( i )->getFrameNum();
|
||||
if( currFrames < maxFrames ) maxFrames = currFrames;
|
||||
currFrames = m_acPlayingSubWindows.at( i )->getInputStream()->getFrameNum();
|
||||
if( currFrames < maxFrames )
|
||||
maxFrames = currFrames;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
maxFrames = m_pcCurrentVideoSubWindow->getFrameNum();
|
||||
maxFrames = m_pcCurrentVideoSubWindow->getInputStream()->getFrameNum();
|
||||
}
|
||||
}
|
||||
return maxFrames;
|
||||
@@ -665,9 +549,9 @@ void VideoHandle::setTimerStatus()
|
||||
{
|
||||
status |= m_acPlayingSubWindows.at( i )->isPlaying();
|
||||
}
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
status |= videoStreamSubWindow->isPlaying();
|
||||
status |= m_pcCurrentVideoSubWindow->isPlaying();
|
||||
}
|
||||
if( status )
|
||||
{
|
||||
@@ -675,33 +559,42 @@ void VideoHandle::setTimerStatus()
|
||||
{
|
||||
m_pcPlayingTimer->start();
|
||||
m_bIsPlaying = true;
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
m_uiNumberPlayedFrames = 0;
|
||||
m_pcFrameRateFeedbackTimer->start();
|
||||
m_uiRealAverageFrameRate = 0;
|
||||
m_pcPlayControlTimer = new QElapsedTimer;
|
||||
m_pcPlayControlTimer->start();
|
||||
m_dAverageFps = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
if( m_pcPlayControlTimer && m_pcPlayingTimer->interval() > 0 )
|
||||
{
|
||||
qDebug() << "Desired Fps: " << 1000 / m_pcPlayingTimer->interval() << "Real Fps: " << 1000 / m_dAverageFps;
|
||||
|
||||
delete m_pcPlayControlTimer;
|
||||
m_pcPlayControlTimer = NULL;
|
||||
}
|
||||
#endif
|
||||
m_pcPlayingTimer->stop();
|
||||
m_bIsPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::configureFrameRateTimer()
|
||||
{
|
||||
double frame_rate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
|
||||
unsigned int time_ms = (unsigned int)( 1000.0 / frame_rate + 0.5 );
|
||||
m_pcPlayingTimer->setInterval( time_ms );
|
||||
}
|
||||
|
||||
void VideoHandle::play()
|
||||
{
|
||||
auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow );
|
||||
if( !m_pcCurrentVideoSubWindow )
|
||||
return;
|
||||
|
||||
if( videoStreamSubWindow == nullptr ) return;
|
||||
if( !m_pcCurrentVideoSubWindow->getInputStream() )
|
||||
return;
|
||||
|
||||
if( !videoStreamSubWindow->isPlaying() ) // Not playing
|
||||
if( !m_pcCurrentVideoSubWindow->isPlaying() ) // Not playing
|
||||
{
|
||||
double frameRate;
|
||||
unsigned int timeinterval;
|
||||
if( m_acPlayingSubWindows.size() < 2 )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
@@ -709,20 +602,22 @@ void VideoHandle::play()
|
||||
m_acPlayingSubWindows.at( i )->pause();
|
||||
}
|
||||
m_acPlayingSubWindows.clear();
|
||||
m_acPlayingSubWindows.append( videoStreamSubWindow );
|
||||
m_acPlayingSubWindows.append( m_pcCurrentVideoSubWindow );
|
||||
}
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->play();
|
||||
}
|
||||
configureFrameRateTimer();
|
||||
frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
|
||||
timeinterval = (unsigned int)( 1000.0 / frameRate + 0.5 );
|
||||
m_pcPlayingTimer->setInterval( timeinterval );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
@@ -731,20 +626,21 @@ void VideoHandle::play()
|
||||
}
|
||||
else
|
||||
{
|
||||
videoStreamSubWindow->pause();
|
||||
m_pcCurrentVideoSubWindow->pause();
|
||||
}
|
||||
}
|
||||
setTimerStatus();
|
||||
emit changed();
|
||||
// update();
|
||||
}
|
||||
|
||||
void VideoHandle::stop()
|
||||
{
|
||||
if( m_acPlayingSubWindows.size() > 0 )
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
playingSubWindow->stop();
|
||||
m_acPlayingSubWindows.at( i )->stop();
|
||||
}
|
||||
m_acPlayingSubWindows.clear();
|
||||
setTimerStatus();
|
||||
@@ -760,137 +656,109 @@ void VideoHandle::stop()
|
||||
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( false );
|
||||
}
|
||||
|
||||
void VideoHandle::calculateRealFrameRate()
|
||||
{
|
||||
double average_time_between_frames_ms = m_uiNumberPlayedFrames > 0 ? 1000.0 / m_uiRealAverageFrameRate : 0;
|
||||
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();
|
||||
}
|
||||
|
||||
void VideoHandle::playEvent()
|
||||
{
|
||||
// auto start = std::chrono::steady_clock::now();
|
||||
|
||||
// This value should only be true if it is really needed to refresh the UI after this play event
|
||||
// Lets assume the current window is not playing. Nothing changes in the UI expect the playing windows
|
||||
// So no changed is emmited
|
||||
bool bShouldRefreshUI = false;
|
||||
calculateRealFrameRate();
|
||||
bool bEndOfSequence = false;
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
m_dAverageFps = double( m_dAverageFps * m_uiNumberPlayedFrames + m_pcPlayControlTimer->elapsed() ) /
|
||||
double( m_uiNumberPlayedFrames + 1 );
|
||||
m_uiNumberPlayedFrames++;
|
||||
m_pcPlayControlTimer->restart();
|
||||
#endif
|
||||
try
|
||||
{
|
||||
bool bEndOfSequence = false;
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
bEndOfSequence |= playingSubWindow->playEvent();
|
||||
// If the current selected windows is playing then we need to refresh the UI
|
||||
if( playingSubWindow == m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
bShouldRefreshUI = true;
|
||||
}
|
||||
bEndOfSequence |= m_acPlayingSubWindows.at( i )->playEvent();
|
||||
}
|
||||
if( bEndOfSequence )
|
||||
{
|
||||
if( !m_arrayActions[VIDEO_REPEAT_ACT]->isChecked() )
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
playingSubWindow->seekAbsoluteEvent( 0 );
|
||||
}
|
||||
}
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 );
|
||||
}
|
||||
}
|
||||
catch( const char* msg )
|
||||
{
|
||||
QString warningMsg =
|
||||
"Error while playing " + m_pcCurrentVideoSubWindow->getWindowName() + " with the following error: \n" + msg;
|
||||
QMessageBox::warning( m_pcParent, QApplication::applicationName(), warningMsg );
|
||||
QString warningMsg = "Error while playing " +
|
||||
QFileInfo( m_pcCurrentVideoSubWindow->getCurrentFileName() ).fileName() +
|
||||
" with the following error: \n" + msg;
|
||||
QMessageBox::warning( m_pcParet, QApplication::applicationName(), warningMsg );
|
||||
qDebug() << warningMsg;
|
||||
stop();
|
||||
m_pcCurrentVideoSubWindow->close();
|
||||
}
|
||||
if( bShouldRefreshUI ) emit changed();
|
||||
|
||||
// auto end = std::chrono::steady_clock::now();
|
||||
// std::cout << "Elapsed time going to next frame: "
|
||||
// << std::chrono::duration_cast<std::chrono::milliseconds>( end - start ).count()
|
||||
// << " ms" << std::endl;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void VideoHandle::seekEvent( int direction )
|
||||
{
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
if( !( (unsigned int)( videoStreamSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() &&
|
||||
if( !( (unsigned int)( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() &&
|
||||
direction > 0 ) )
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
playingSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
m_acPlayingSubWindows.at( i )->seekRelativeEvent( direction > 0 ? true : false );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
videoStreamSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
m_pcCurrentVideoSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
}
|
||||
emit changed();
|
||||
// update();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::seekVideo()
|
||||
{
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
SeekStreamDialog* dialogSeekVideo = new SeekStreamDialog( videoStreamSubWindow->getInputStream(), m_pcParent );
|
||||
int newFrameNum = dialogSeekVideo->runDialog();
|
||||
if( newFrameNum >= 0 )
|
||||
if( m_pcCurrentVideoSubWindow->getInputStream() )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
SeekStreamDialog* dialogSeekVideo =
|
||||
new SeekStreamDialog( m_pcCurrentVideoSubWindow->getInputStream(), m_pcParet );
|
||||
int newFrameNum = dialogSeekVideo->runDialog();
|
||||
if( newFrameNum >= 0 )
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
playingSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
else
|
||||
{
|
||||
videoStreamSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::seekSliderEvent( int new_frame_num )
|
||||
{
|
||||
// TODO: Fix this slot
|
||||
if( m_bIsPlaying ) return;
|
||||
|
||||
if( auto* videoStreamSubWindow = qobject_cast<VideoStreamSubWindow*>( m_pcCurrentVideoSubWindow ) )
|
||||
if( m_pcCurrentVideoSubWindow && !m_bIsPlaying ) // TODO: Fix this slot
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( videoStreamSubWindow ) )
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
playingSubWindow->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
videoStreamSubWindow->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
m_pcCurrentVideoSubWindow->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
@@ -898,34 +766,36 @@ void VideoHandle::seekSliderEvent( int new_frame_num )
|
||||
|
||||
void VideoHandle::videoSelectionButtonEvent()
|
||||
{
|
||||
VideoSubWindow* videoSubWindow;
|
||||
|
||||
Qt::KeyboardModifiers keyModifiers = QApplication::keyboardModifiers();
|
||||
if( keyModifiers & Qt::ControlModifier )
|
||||
{
|
||||
QList<SubWindowAbstract*> subWindowList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
for( auto subWindow : subWindowList )
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
auto* videoSubWindow = qobject_cast<VideoStreamSubWindow*>( subWindow );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SubWindowSelectorDialog dialogWindowsSelection( m_pcParent, m_pcMainWindowManager,
|
||||
SubWindowSelectorDialog dialogWindowsSelection( m_pcParet, m_pcMainWindowManager,
|
||||
SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
QStringList cWindowListNames;
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
dialogWindowsSelection.selectSubWindow( playingSubWindow );
|
||||
dialogWindowsSelection.selectSubWindow( m_acPlayingSubWindows.at( i ) );
|
||||
}
|
||||
if( dialogWindowsSelection.exec() == QDialog::Accepted )
|
||||
{
|
||||
m_acPlayingSubWindows.clear();
|
||||
|
||||
QList<SubWindowAbstract*> selectedSubWindowList = dialogWindowsSelection.getSelectedWindows();
|
||||
for( auto window : selectedSubWindowList )
|
||||
for( int i = 0; i < selectedSubWindowList.size(); i++ )
|
||||
{
|
||||
auto* videoSubWindow = qobject_cast<VideoStreamSubWindow*>( window );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( selectedSubWindowList.at( i ) );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
@@ -937,7 +807,7 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
|
||||
if( m_acPlayingSubWindows.size() > 0 )
|
||||
{
|
||||
m_acPlayingSubWindows.front()->activateWindow();
|
||||
m_acPlayingSubWindows.at( 0 )->activateWindow();
|
||||
if( m_acPlayingSubWindows.size() > 1 )
|
||||
{
|
||||
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( true );
|
||||
@@ -956,19 +826,6 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::setComponent( int component )
|
||||
{
|
||||
if( m_pcCurrentVideoSubWindow == nullptr ) return;
|
||||
if( component < 0 )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->getViewArea()->clearFilteredChannel();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcCurrentVideoSubWindow->getViewArea()->setFilteredChannel( static_cast<std::size_t>( component ) );
|
||||
}
|
||||
}
|
||||
|
||||
void VideoHandle::setTool( int tool )
|
||||
{
|
||||
m_uiViewTool = tool;
|
||||
|
||||
+15
-25
@@ -25,7 +25,6 @@
|
||||
#ifndef __VIDEOHANDLE_H__
|
||||
#define __VIDEOHANDLE_H__
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QThread>
|
||||
@@ -33,21 +32,22 @@
|
||||
#include <QWidget>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "config.h"
|
||||
|
||||
//#define _CONTROL_PLAYING_TIME_ 1
|
||||
|
||||
class QToolBar;
|
||||
class QDockWidget;
|
||||
class QSignalMapper;
|
||||
class QLabel;
|
||||
class QSlider;
|
||||
class QElapsedTimer;
|
||||
|
||||
class SubWindowHandle;
|
||||
class SubWindowAbstract;
|
||||
class VideoStreamSubWindow;
|
||||
class VideoSubWindow;
|
||||
class FramePropertiesDock;
|
||||
class FrameNumberWidget;
|
||||
class QTimer;
|
||||
|
||||
class VideoHandle : public QObject
|
||||
{
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
void createActions();
|
||||
QMenu* createVideoMenu();
|
||||
QMenu* createImageMenu();
|
||||
QPointer<QToolBar> createToolBar();
|
||||
QToolBar* createToolBar();
|
||||
QDockWidget* createDock();
|
||||
QWidget* createStatusBarMessage();
|
||||
void updateMenus();
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void addSubWindow( VideoSubWindow* subWindow );
|
||||
|
||||
private:
|
||||
QWidget* m_pcParent;
|
||||
QWidget* m_pcParet;
|
||||
SubWindowHandle* m_pcMainWindowManager;
|
||||
enum
|
||||
{
|
||||
@@ -97,11 +97,6 @@ private:
|
||||
QSlider* m_pcFrameSlider;
|
||||
FrameNumberWidget* m_pcFrameNumInfo;
|
||||
|
||||
// Filter component actions
|
||||
QMenu* m_menuComponent;
|
||||
QActionGroup* m_actionGroupComponent;
|
||||
QSignalMapper* m_mapperComponent;
|
||||
|
||||
// Tools Actions
|
||||
QActionGroup* m_actionGroupTools;
|
||||
QSignalMapper* m_mapperTools;
|
||||
@@ -113,30 +108,28 @@ private:
|
||||
|
||||
QMenu* m_pcMenuVideo;
|
||||
QMenu* m_pcMenuImage;
|
||||
// QToolBar* m_toolbarVideo;
|
||||
QToolBar* m_toolbarVideo;
|
||||
|
||||
QDockWidget* m_pcFramePropertiesDock;
|
||||
FramePropertiesDock* m_pcFramePropertiesSideBar;
|
||||
|
||||
QLabel* m_pcPlayingFPSLabel;
|
||||
QLabel* m_pcVideoFormatLabel;
|
||||
QLabel* m_pcResolutionLabel;
|
||||
|
||||
QPointer<VideoSubWindow> m_pcCurrentVideoSubWindow{ nullptr };
|
||||
QVector<VideoStreamSubWindow*> m_acPlayingSubWindows;
|
||||
VideoSubWindow* m_pcCurrentVideoSubWindow;
|
||||
QVector<VideoSubWindow*> m_acPlayingSubWindows;
|
||||
|
||||
QTimer* m_pcPlayingTimer;
|
||||
bool m_bIsPlaying{ false };
|
||||
bool m_bIsPlaying;
|
||||
|
||||
unsigned int m_uiNumberPlayedFrames{ 0 };
|
||||
unsigned int m_uiRealAverageFrameRate{ 0 };
|
||||
std::unique_ptr<QElapsedTimer> m_pcFrameRateFeedbackTimer;
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
unsigned int m_uiNumberPlayedFrames;
|
||||
double m_dAverageFps;
|
||||
QElapsedTimer* m_pcPlayControlTimer;
|
||||
#endif
|
||||
|
||||
void configureFrameRateTimer();
|
||||
void calculateRealFrameRate();
|
||||
unsigned long getMaxFrameNumber();
|
||||
void setTimerStatus();
|
||||
void updateComponentMenu();
|
||||
|
||||
Q_SIGNALS:
|
||||
void changed();
|
||||
@@ -147,16 +140,13 @@ private Q_SLOTS:
|
||||
void closeSubWindow( SubWindowAbstract* subWindow );
|
||||
void zoomToFactorAll( const double factor, const QPoint center = QPoint() );
|
||||
void moveAllScrollBars( const double&, const double& );
|
||||
|
||||
void play();
|
||||
void stop();
|
||||
|
||||
void playEvent();
|
||||
void seekSliderEvent( int new_frame_num );
|
||||
void seekEvent( int direction );
|
||||
void seekVideo();
|
||||
void videoSelectionButtonEvent();
|
||||
void setComponent( int component );
|
||||
void setTool( int tool );
|
||||
void toggleGrid( bool checked );
|
||||
void setGridSize( int size );
|
||||
|
||||
@@ -1,423 +0,0 @@
|
||||
/* 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 VideoStreamSubWindow.cpp
|
||||
* \brief Video Sub windows handling
|
||||
*/
|
||||
|
||||
#include "VideoStreamSubWindow.h"
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QSettings>
|
||||
#include <QStaticText>
|
||||
#include <cassert>
|
||||
|
||||
#include "ConfigureFormatDialog.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "QtConcurrent/qtconcurrentrun.h"
|
||||
#include "ResourceHandle.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
|
||||
#define QT_NO_CONCURRENT
|
||||
|
||||
VideoStreamSubWindow::VideoStreamSubWindow( ResourceHandle* resourceManager, QWidget* parent )
|
||||
: VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW, parent )
|
||||
, m_pcResourceManager{ resourceManager }
|
||||
, m_pCurrStream{ NULL }
|
||||
, m_bIsPlaying{ false }
|
||||
{
|
||||
}
|
||||
|
||||
VideoStreamSubWindow::~VideoStreamSubWindow()
|
||||
{
|
||||
if( m_pcResourceManager ) m_pcResourceManager->removeResource( m_uiResourceId );
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::resetWindowName()
|
||||
{
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::updateVideoWindowInfo()
|
||||
{
|
||||
m_cStreamInformation = "";
|
||||
if( m_pcDisplayModule )
|
||||
{
|
||||
m_cStreamInformation = "Module";
|
||||
const auto& arraySubWindows = m_pcDisplayModule->getSubWindowList();
|
||||
QStringList windowInfoList;
|
||||
if( arraySubWindows.size() > 0 )
|
||||
{
|
||||
for( std::size_t i = 0; i < arraySubWindows.size(); i++ )
|
||||
{
|
||||
if( arraySubWindows[i]->getWindowName() != getWindowName() )
|
||||
{
|
||||
windowInfoList.append( QString( "Input %1 - " + arraySubWindows[i]->getWindowName() ).arg( i + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_pcDisplayModule->hasFeature( ClpModuleFeature::HasInfo ) )
|
||||
{
|
||||
QStringList list = QString::fromStdString( m_pcDisplayModule->moduleInfo() ).split( '\n' );
|
||||
windowInfoList.append( list );
|
||||
}
|
||||
if( windowInfoList.size() > 0 )
|
||||
{
|
||||
m_pcVideoInfo->setInformationTopLeft( windowInfoList );
|
||||
}
|
||||
}
|
||||
else if( m_pCurrStream )
|
||||
{
|
||||
QString m_cFormatName = QString::fromStdString( m_pCurrStream->getFormatName() );
|
||||
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
|
||||
m_cStreamInformation = m_cFormatName + " | " + m_cCodedName;
|
||||
}
|
||||
if( m_pcCurrFrameAsset )
|
||||
{
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrameAsset->getPelFmtName() );
|
||||
if( m_pCurrStream )
|
||||
if( !m_pCurrStream->isNative() ) m_cPelFmtName += "*";
|
||||
m_cStreamInformation += " | " + m_cPelFmtName;
|
||||
}
|
||||
if( m_cStreamInformation.isEmpty() )
|
||||
{
|
||||
m_cStreamInformation = " ";
|
||||
}
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::loadAll()
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
m_pCurrStream->loadAll();
|
||||
refreshFrame();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::setResource( std::size_t id )
|
||||
{
|
||||
m_uiResourceId = id;
|
||||
m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->startResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
refreshFrame();
|
||||
|
||||
m_cFilename = QString::fromStdString( m_pCurrStream->getFileName() );
|
||||
|
||||
updateVideoWindowInfo();
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
}
|
||||
|
||||
// bool VideoStreamSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
// {
|
||||
// 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_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 = 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
|
||||
|
||||
// QApplication::restoreOverrideCursor();
|
||||
|
||||
// refreshFrame();
|
||||
|
||||
// m_cFilename = cFilename;
|
||||
|
||||
// updateVideoWindowInfo();
|
||||
// setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// bool VideoStreamSubWindow::loadFile( CalypFileInfo streamInfo )
|
||||
// {
|
||||
// assert( m_pcResourceManager != nullptr );
|
||||
|
||||
// m_uiResourceId = m_pcResourceManager->getResource( m_pCurrStream );
|
||||
// m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
|
||||
|
||||
// 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;
|
||||
// }
|
||||
|
||||
// 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()
|
||||
{
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->stopResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
if( !m_pCurrStream->reload() )
|
||||
{
|
||||
close();
|
||||
return;
|
||||
}
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->startResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
|
||||
updateVideoWindowInfo();
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::refreshFrame()
|
||||
{
|
||||
bool bSetFrame = true;
|
||||
m_pcCurrFrameAsset = m_pCurrStream->getCurrFrameAsset();
|
||||
|
||||
if( m_pcDisplayModule )
|
||||
{
|
||||
// bool disableThreads = !m_bIsPlaying && hasAssociatedModule();
|
||||
m_pcDisplayModule->apply( m_bIsPlaying, true );
|
||||
bSetFrame = false;
|
||||
}
|
||||
if( bSetFrame ) VideoSubWindow::refreshFrame();
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::refreshFrame( bool bThreaded )
|
||||
{
|
||||
#ifndef QT_NO_CONCURRENT
|
||||
m_cRefreshResult.waitForFinished();
|
||||
if( bThreaded )
|
||||
{
|
||||
m_cRefreshResult = QtConcurrent::run( this, &VideoSubWindow::refreshFrame );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
refreshFrame();
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::goToNextFrame( bool bThreaded )
|
||||
{
|
||||
#ifndef QT_NO_CONCURRENT
|
||||
m_cRefreshResult.waitForFinished();
|
||||
m_cReadResult.waitForFinished();
|
||||
#endif
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
while( !m_pCurrStream->hasNextFrame() && !m_pCurrStream->isEof() )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
bool bEndOfSeq = m_pCurrStream->setNextFrame();
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
bThreaded = false;
|
||||
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
if( !bEndOfSeq )
|
||||
{
|
||||
#ifndef QT_NO_CONCURRENT
|
||||
m_cRefreshResult.waitForFinished();
|
||||
if( bThreaded )
|
||||
{
|
||||
m_cReadResult = QtConcurrent::run( m_pCurrStream, &CalypStream::readNextFrameFillRGBBuffer );
|
||||
refreshFrame( bThreaded );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
refreshFrame( bThreaded );
|
||||
#ifndef CALYP_MANAGED_RESOURCES
|
||||
m_pCurrStream->readNextFrameFillRGBBuffer();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return bEndOfSeq;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::saveStream( const QString& filename )
|
||||
{
|
||||
bool iRet = false;
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
// TODO: implement this
|
||||
QApplication::restoreOverrideCursor();
|
||||
return iRet;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::isPlaying()
|
||||
{
|
||||
return m_bIsPlaying;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::play()
|
||||
{
|
||||
bool isPlaying = false;
|
||||
if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 )
|
||||
{
|
||||
isPlaying = true;
|
||||
}
|
||||
m_bIsPlaying = isPlaying;
|
||||
return m_bIsPlaying;
|
||||
}
|
||||
|
||||
bool VideoStreamSubWindow::playEvent()
|
||||
{
|
||||
bool bEndOfSeq = false;
|
||||
if( m_pCurrStream && m_bIsPlaying )
|
||||
{
|
||||
bEndOfSeq = goToNextFrame( true );
|
||||
}
|
||||
return bEndOfSeq;
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::pause()
|
||||
{
|
||||
m_bIsPlaying = false;
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::seekAbsoluteEvent( unsigned int new_frame_num )
|
||||
{
|
||||
if( m_pCurrStream )
|
||||
{
|
||||
if( m_pCurrStream->seekInput( new_frame_num ) ) refreshFrame();
|
||||
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::seekRelativeEvent( bool bIsForward )
|
||||
{
|
||||
if( m_pCurrStream )
|
||||
{
|
||||
if( bIsForward )
|
||||
{
|
||||
goToNextFrame( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCurrStream->seekInputRelative( bIsForward );
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
refreshFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VideoStreamSubWindow::stop()
|
||||
{
|
||||
#ifndef QT_NO_CONCURRENT
|
||||
m_cRefreshResult.waitForFinished();
|
||||
m_cReadResult.waitForFinished();
|
||||
#endif
|
||||
m_bIsPlaying = false;
|
||||
seekAbsoluteEvent( 0 );
|
||||
return;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/* 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 VideoStreamSubWindow.h
|
||||
* \brief Video Sub windows handling
|
||||
*/
|
||||
|
||||
#ifndef __VIDEOSTREAMSUBWINDOW_H__
|
||||
#define __VIDEOSTREAMSUBWINDOW_H__
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QFuture>
|
||||
#include <QRect>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypStream.h"
|
||||
#include "models/VideostreamResource.h"
|
||||
|
||||
class QScrollArea;
|
||||
|
||||
class VideoInformation;
|
||||
class VideoStreamSubWindow;
|
||||
class ResourceHandle;
|
||||
class CalypAppModuleIf;
|
||||
|
||||
class VideoStreamSubWindow : public VideoSubWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoStreamSubWindow( ResourceHandle* resourceManager, QWidget* parent = 0 );
|
||||
~VideoStreamSubWindow();
|
||||
|
||||
void resetWindowName() override;
|
||||
void updateVideoWindowInfo() override;
|
||||
|
||||
bool isPlaying() override;
|
||||
void stop() override;
|
||||
void advanceOneFrame() override { goToNextFrame( true ); }
|
||||
auto getFrameNum() -> std::uint64_t override { return m_pCurrStream->getFrameNum(); }
|
||||
|
||||
bool supportsFormatConfiguration() const { return m_pCurrStream->supportsFormatConfiguration(); };
|
||||
|
||||
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 );
|
||||
|
||||
bool play();
|
||||
void pause();
|
||||
bool playEvent();
|
||||
void seekAbsoluteEvent( unsigned int new_frame_num );
|
||||
void seekRelativeEvent( bool bIsFoward );
|
||||
|
||||
CalypFileInfo getStreamInfo() { return m_sStreamInfo; }
|
||||
|
||||
const CalypStream* getInputStream() { return m_pCurrStream; }
|
||||
const CalypStream* getCurrStream() { return m_pCurrStream; }
|
||||
|
||||
QString getCurrentFileName() { return m_cFilename; }
|
||||
|
||||
void refreshSubWindow() override;
|
||||
void refreshFrame();
|
||||
void refreshFrame( bool bThreaded );
|
||||
|
||||
private:
|
||||
bool goToNextFrame( bool bThreaded );
|
||||
|
||||
private: // NO_LINT
|
||||
ResourceHandle* m_pcResourceManager;
|
||||
std::size_t m_uiResourceId;
|
||||
|
||||
QString m_cFilename;
|
||||
CalypFileInfo m_sStreamInfo;
|
||||
CalypStream* m_pCurrStream;
|
||||
QString m_cCurrFileName;
|
||||
|
||||
bool m_bIsPlaying;
|
||||
|
||||
/**
|
||||
* Threads variables
|
||||
* QtConcurrent
|
||||
*/
|
||||
QFuture<void> m_cRefreshResult;
|
||||
QFuture<void> m_cReadResult;
|
||||
};
|
||||
|
||||
#endif // __VIDEOSTREAMSUBWINDOW_H__
|
||||
+721
-211
File diff suppressed because it is too large.
Load diff
+113
-76
@@ -28,11 +28,9 @@
|
||||
#include <QDataStream>
|
||||
#include <QFuture>
|
||||
#include <QRect>
|
||||
#include <QStaticText>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "CalypAppModuleIf.h"
|
||||
#include "CommonDefs.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
#include "ViewArea.h"
|
||||
@@ -43,35 +41,67 @@ class QScrollArea;
|
||||
|
||||
class VideoInformation;
|
||||
class VideoSubWindow;
|
||||
class ResourceHandle;
|
||||
class CalypAppModuleIf;
|
||||
|
||||
/**
|
||||
* \class VideoInformation
|
||||
* \brief Shows information about video sub window
|
||||
*/
|
||||
class VideoInformation : public QWidget
|
||||
typedef struct
|
||||
{
|
||||
public:
|
||||
VideoInformation( QWidget* parent );
|
||||
void setInformationTopLeft( const QStringList& textLines );
|
||||
void setBusyWindow( bool bFlag );
|
||||
QString m_cFilename;
|
||||
unsigned int m_uiWidth;
|
||||
unsigned int m_uiHeight;
|
||||
int m_iPelFormat;
|
||||
unsigned int m_uiBitsPelPixel;
|
||||
unsigned int m_iEndianness;
|
||||
unsigned int m_uiFrameRate;
|
||||
unsigned long long int m_uiFileSize;
|
||||
} CalypFileInfo;
|
||||
typedef QVector<CalypFileInfo> CalypFileInfoVector;
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event ) override;
|
||||
|
||||
private:
|
||||
QTimer* m_pcRefreshTimer;
|
||||
QList<QStaticText> m_cTopLeftTextList;
|
||||
QFont m_cTopLeftTextFont;
|
||||
QFont m_cCenterTextFont;
|
||||
bool m_bBusyWindow;
|
||||
};
|
||||
QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& d );
|
||||
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& d );
|
||||
int findCalypStreamInfo( CalypFileInfoVector array, QString filename );
|
||||
|
||||
class VideoSubWindow : public SubWindowAbstract
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
bool m_bWindowBusy;
|
||||
|
||||
QScrollArea* m_pcScrollArea;
|
||||
QPoint m_cCurrScroll;
|
||||
double m_dHorScroll;
|
||||
double m_dVerScroll;
|
||||
|
||||
ViewArea* m_cViewArea;
|
||||
|
||||
VideoInformation* m_pcVideoInfo;
|
||||
|
||||
QString m_cFilename;
|
||||
QString m_cStreamInformation;
|
||||
CalypFileInfo m_sStreamInfo;
|
||||
CalypStream* m_pCurrStream;
|
||||
|
||||
CalypFrame* m_pcCurrFrame;
|
||||
QRect m_cSelectedArea;
|
||||
|
||||
CalypAppModuleIf* m_pcCurrentDisplayModule;
|
||||
QList<CalypAppModuleIf*> m_apcCurrentModule;
|
||||
|
||||
VideoSubWindow* m_pcReferenceSubWindow;
|
||||
|
||||
// QString m_cWindowShortName;
|
||||
QString m_cCurrFileName;
|
||||
|
||||
bool m_bIsPlaying;
|
||||
|
||||
QTimer* m_pcUpdateTimer;
|
||||
/**
|
||||
* Threads variables
|
||||
* QtConcurrent
|
||||
*/
|
||||
QFuture<void> m_cRefreshResult;
|
||||
QFuture<void> m_cReadResult;
|
||||
|
||||
public:
|
||||
enum VideoSubWindowCategories
|
||||
{
|
||||
@@ -81,63 +111,90 @@ public:
|
||||
VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 );
|
||||
~VideoSubWindow();
|
||||
|
||||
virtual void resetWindowName() = 0;
|
||||
virtual void updateVideoWindowInfo() = 0;
|
||||
void updateVideoWindowInfo();
|
||||
|
||||
virtual bool isPlaying() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void advanceOneFrame() = 0;
|
||||
virtual auto getFrameNum() -> std::uint64_t { return 1; };
|
||||
bool loadFile( QString cFilename, bool bForceDialog = false );
|
||||
bool loadFile( CalypFileInfo* streamInfo );
|
||||
void loadAll();
|
||||
bool save( QString filename );
|
||||
bool saveStream( QString filename );
|
||||
|
||||
QString getVideoInformation() { return m_cStreamInformation; }
|
||||
bool save( const QString& filename );
|
||||
void refreshSubWindow();
|
||||
void refreshFrame( bool bThreaded = false );
|
||||
|
||||
void setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame );
|
||||
bool play();
|
||||
void pause();
|
||||
bool playEvent();
|
||||
void stop();
|
||||
|
||||
auto getCurrFrame() -> CalypFrame* { return m_pcCurrFrameAsset.get(); }
|
||||
auto getCurrFrameAsset() -> std::shared_ptr<CalypFrame> { return m_pcCurrFrameAsset; };
|
||||
auto getViewArea() -> ViewArea* { return m_cViewArea; }
|
||||
bool isPlaying() { return m_bIsPlaying; }
|
||||
void seekAbsoluteEvent( unsigned int new_frame_num );
|
||||
void seekRelativeEvent( bool bIsFoward );
|
||||
|
||||
VideoSubWindow* getRefSubWindow() { return m_pcReferenceSubWindow; }
|
||||
void setCurrFrame( CalypFrame* pcCurrFrame );
|
||||
|
||||
CalypFileInfo getStreamInfo() { return m_sStreamInfo; }
|
||||
QString getStreamInformation() { return m_cStreamInformation; }
|
||||
CalypStream* getInputStream() { return m_pCurrStream; }
|
||||
CalypStream* getCurrStream() { return m_pCurrStream; }
|
||||
CalypFrame* getCurrFrame() { return m_pcCurrFrame; }
|
||||
ViewArea* getViewArea() { return m_cViewArea; }
|
||||
void setRefSubWindow( VideoSubWindow* subWindow )
|
||||
{
|
||||
m_pcReferenceSubWindow = NULL;
|
||||
if( subWindow )
|
||||
if( m_pcCurrFrameAsset->haveSameFmt( subWindow->getCurrFrame() ) )
|
||||
if( m_pcCurrFrame->haveSameFmt( subWindow->getCurrFrame() ) )
|
||||
m_pcReferenceSubWindow = subWindow;
|
||||
}
|
||||
|
||||
VideoSubWindow* getRefSubWindow() { return m_pcReferenceSubWindow; }
|
||||
/**
|
||||
* Functions to enable a module in the
|
||||
* current SubWindow
|
||||
*/
|
||||
auto hasModules() -> bool { return m_associatedModules.size() > 0; }
|
||||
bool hasAssociatedModule();
|
||||
void setDisplayModule( CalypAppModuleIf* pcModule );
|
||||
void associateModule( std::shared_ptr<CalypAppModuleIf> pcModule );
|
||||
void disableModule( CalypAppModuleIf* pcModule );
|
||||
bool disableAllModules();
|
||||
CalypAppModuleIf* getDisplayModule() { return m_pcDisplayModule; }
|
||||
void enableModule( CalypAppModuleIf* pcModule );
|
||||
void disableModule( CalypAppModuleIf* pcModule = NULL );
|
||||
void associateModule( CalypAppModuleIf* pcModule );
|
||||
|
||||
CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; }
|
||||
QList<CalypAppModuleIf*> getModuleArray()
|
||||
{
|
||||
QList<CalypAppModuleIf*> apcModulesArray;
|
||||
if( m_pcCurrentDisplayModule )
|
||||
apcModulesArray.append( m_pcCurrentDisplayModule );
|
||||
apcModulesArray.append( m_apcCurrentModule );
|
||||
return apcModulesArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual functions from SubWindowAbstract
|
||||
*/
|
||||
void normalSize() override;
|
||||
void zoomToFit() override;
|
||||
void scaleView( double scale, QPoint center = QPoint() ) override;
|
||||
void zoomToFactor( double factor, QPoint center = QPoint() ) override;
|
||||
void normalSize();
|
||||
void zoomToFit();
|
||||
void scaleView( double scale, QPoint center = QPoint() );
|
||||
void zoomToFactor( double factor, QPoint center = QPoint() );
|
||||
|
||||
double getScaleFactor() override { return m_cViewArea->getZoomFactor(); }
|
||||
double getScaleFactor() { return m_cViewArea->getZoomFactor(); }
|
||||
/**
|
||||
* Size related functions
|
||||
*/
|
||||
QSize sizeHint( const QSize& ) const override;
|
||||
QSize sizeHint() const;
|
||||
QSize sizeHint( const QSize& ) const;
|
||||
|
||||
QString getCurrentFileName() { return m_cFilename; }
|
||||
bool getIsModule() { return getCategory() | SubWindowAbstract::MODULE_SUBWINDOW; }
|
||||
void clearWindowBusy() { m_bWindowBusy = false; }
|
||||
void setFillWindow( bool bFlag );
|
||||
|
||||
void adjustScrollBarToRatio( const double horRatio, const double verRatio );
|
||||
void adjustScrollBarToRatio( const double& horRatio, const double& verRatio );
|
||||
|
||||
private:
|
||||
void refreshFrameOperation();
|
||||
bool goToNextFrame( bool bThreaded = false );
|
||||
|
||||
static bool guessFormat( QString filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPixel,
|
||||
int& rEndianness, unsigned int& rFrameRate );
|
||||
|
||||
bool hasRunningModule();
|
||||
|
||||
/**
|
||||
@@ -149,11 +206,9 @@ private:
|
||||
QSize getScrollSize();
|
||||
|
||||
protected:
|
||||
void refreshFrame();
|
||||
|
||||
void keyPressEvent( QKeyEvent* event ) override;
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
void closeEvent( QCloseEvent* event ) override;
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
void closeEvent( QCloseEvent* event );
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateWindowOnTimeout();
|
||||
@@ -162,27 +217,9 @@ public Q_SLOTS:
|
||||
void updateScrollValues();
|
||||
void updateSelectedArea( QRect area );
|
||||
void updatePixelValueStatusBar( const QPoint& pos );
|
||||
|
||||
protected:
|
||||
VideoInformation* m_pcVideoInfo;
|
||||
QString m_cStreamInformation;
|
||||
std::shared_ptr<CalypFrame> m_pcCurrFrameAsset;
|
||||
// bool m_bWindowBusy;
|
||||
// bool m_bIsPlaying;
|
||||
|
||||
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
|
||||
CalypAppModuleIf* m_pcDisplayModule{ nullptr };
|
||||
// bool m_hasAssociatedModules;
|
||||
|
||||
private:
|
||||
QScrollArea* m_pcScrollArea;
|
||||
QPoint m_cCurrScroll;
|
||||
double m_dHorScroll{ 0 };
|
||||
double m_dVerScroll{ 0 };
|
||||
ViewArea* m_cViewArea;
|
||||
QRect m_cSelectedArea;
|
||||
VideoSubWindow* m_pcReferenceSubWindow;
|
||||
QTimer* m_pcUpdateTimer;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( CalypFileInfo )
|
||||
Q_DECLARE_METATYPE( CalypFileInfoVector )
|
||||
|
||||
#endif // __VIDEOSUBWINDOW_H__
|
||||
+120
-163
@@ -25,9 +25,6 @@
|
||||
|
||||
#include "ViewArea.h"
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <qnamespace.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -43,101 +40,65 @@
|
||||
|
||||
#include "GridManager.h"
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
||||
constexpr auto kSelectionColor = QColorConstants::Cyan;
|
||||
constexpr auto kImageMaskColor = QColorConstants::Green;
|
||||
constexpr auto kEraserColor = QColorConstants::Red;
|
||||
#else
|
||||
static const QColor kSelectionColor = Qt::cyan;
|
||||
static const QColor kImageMaskColor = Qt::green;
|
||||
static const QColor kEraserColor = Qt::red;
|
||||
#endif
|
||||
constexpr double kMaxZoom = 100.0;
|
||||
constexpr double kMinZoom = 0.01;
|
||||
static const QColor selectionColor = Qt::cyan;
|
||||
static const QColor imageMaskColor = Qt::green;
|
||||
static const QColor eraserColor = Qt::red;
|
||||
|
||||
ViewArea::ViewArea( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
setMouseTracking( true );
|
||||
|
||||
m_pcCurrFrame = NULL;
|
||||
m_pixmap = QPixmap();
|
||||
m_grid = GridManager();
|
||||
m_mask = QBitmap();
|
||||
m_selectedArea = QRect();
|
||||
m_dZoomFactor = 1;
|
||||
m_xOffset = 0;
|
||||
m_yOffset = 0;
|
||||
m_mode = NormalMode;
|
||||
m_eTool = NavigationTool;
|
||||
m_bGridVisible = false;
|
||||
m_snapToGrid = false;
|
||||
m_blockTrackEnable = false;
|
||||
m_visibleZoomRect = true;
|
||||
|
||||
m_zoomWinTimer.setSingleShot( true );
|
||||
m_zoomWinTimer.setInterval( 2000 );
|
||||
connect( &m_zoomWinTimer, SIGNAL( timeout() ), this, SLOT( update() ) );
|
||||
}
|
||||
|
||||
void ViewArea::setImage( std::shared_ptr<CalypFrame> frame )
|
||||
void ViewArea::setImage( CalypFrame* pcFrame )
|
||||
{
|
||||
m_nextFrame = frame;
|
||||
m_uiPixelHalfScale = 1 << ( m_nextFrame->getBitsPel() - 1 );
|
||||
if( m_filterSingleChannel.has_value() )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer();
|
||||
}
|
||||
m_pcCurrFrame = pcFrame;
|
||||
m_uiPixelHalfScale = 1 << ( m_pcCurrFrame->getBitsPel() - 1 );
|
||||
m_pcCurrFrame->fillRGBBuffer();
|
||||
QImage qimg = QImage( m_pcCurrFrame->getRGBBuffer(), m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
setImage( QPixmap::fromImage( qimg ) );
|
||||
}
|
||||
|
||||
auto rgb_buffer = *m_nextFrame->getRGBBuffer();
|
||||
m_image = QImage( rgb_buffer.data(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
|
||||
// m_mask = QBitmap( pixmap.width(), pixmap.height() );
|
||||
// m_mask.clear();
|
||||
void ViewArea::setImage( const QPixmap& pixmap )
|
||||
{
|
||||
m_pixmap = pixmap;
|
||||
m_mask = QBitmap( pixmap.width(), pixmap.height() );
|
||||
m_mask.clear();
|
||||
updateSize();
|
||||
update();
|
||||
updateGeometry();
|
||||
|
||||
initZoomWinRect();
|
||||
}
|
||||
|
||||
// void ViewArea::clear()
|
||||
// {
|
||||
// m_image = QImage();
|
||||
// m_mask = QBitmap();
|
||||
// m_mode = NormalMode;
|
||||
// updateSize();
|
||||
// update();
|
||||
// updateGeometry();
|
||||
// }
|
||||
|
||||
auto ViewArea::getFilteredChannel() -> std::optional<std::size_t>
|
||||
void ViewArea::clear()
|
||||
{
|
||||
return m_filterSingleChannel;
|
||||
}
|
||||
|
||||
void ViewArea::setFilteredChannel( std::size_t channel )
|
||||
{
|
||||
m_filterSingleChannel = channel;
|
||||
if( m_nextFrame != nullptr )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
auto rgb_buffer = *m_nextFrame->getRGBBuffer();
|
||||
m_image = QImage( rgb_buffer.data(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void ViewArea::clearFilteredChannel()
|
||||
{
|
||||
m_filterSingleChannel = {};
|
||||
if( m_nextFrame != nullptr )
|
||||
{
|
||||
m_nextFrame->fillRGBBuffer( m_filterSingleChannel );
|
||||
auto rgb_buffer = *m_nextFrame->getRGBBuffer();
|
||||
m_image = QImage( rgb_buffer.data(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
}
|
||||
m_pixmap = QPixmap();
|
||||
m_mask = QBitmap();
|
||||
m_mode = NormalMode;
|
||||
updateSize();
|
||||
update();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void ViewArea::setTool( unsigned int view )
|
||||
@@ -205,14 +166,14 @@ void ViewArea::setZoomFactor( double f )
|
||||
|
||||
double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize )
|
||||
{
|
||||
Q_ASSERT( !m_image.isNull() );
|
||||
|
||||
double maxZoom = 100.0;
|
||||
double minZoom = 0.01; //( 1.0 / m_pixmap.width() );
|
||||
double new_scale = 1.0;
|
||||
|
||||
if( ( m_dZoomFactor == kMinZoom ) && ( scale < 1 ) )
|
||||
if( ( m_dZoomFactor == minZoom ) && ( scale < 1 ) )
|
||||
return new_scale;
|
||||
|
||||
if( ( m_dZoomFactor == kMaxZoom ) && ( scale > 1 ) )
|
||||
if( ( m_dZoomFactor == maxZoom ) && ( scale > 1 ) )
|
||||
return new_scale;
|
||||
|
||||
double newZoomFactor = m_dZoomFactor * scale * 100.0;
|
||||
@@ -222,10 +183,10 @@ double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize
|
||||
|
||||
if( !minimumSize.isNull() )
|
||||
{
|
||||
double cw = m_image.width() * m_dZoomFactor;
|
||||
double ch = m_image.height() * m_dZoomFactor;
|
||||
double fw = m_image.width() * newZoomFactor;
|
||||
double fh = m_image.height() * newZoomFactor;
|
||||
double cw = m_pixmap.width() * m_dZoomFactor;
|
||||
double ch = m_pixmap.height() * m_dZoomFactor;
|
||||
double fw = m_pixmap.width() * newZoomFactor;
|
||||
double fh = m_pixmap.height() * newZoomFactor;
|
||||
double mw = minimumSize.width();
|
||||
double mh = minimumSize.height();
|
||||
|
||||
@@ -253,16 +214,16 @@ double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize
|
||||
|
||||
new_scale = scale;
|
||||
|
||||
if( newZoomFactor < kMinZoom )
|
||||
if( newZoomFactor < minZoom )
|
||||
{
|
||||
newZoomFactor = kMinZoom;
|
||||
newZoomFactor = minZoom;
|
||||
new_scale = newZoomFactor / m_dZoomFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( newZoomFactor > kMaxZoom )
|
||||
if( newZoomFactor > maxZoom )
|
||||
{
|
||||
newZoomFactor = kMaxZoom;
|
||||
newZoomFactor = maxZoom;
|
||||
new_scale = newZoomFactor / m_dZoomFactor;
|
||||
}
|
||||
}
|
||||
@@ -358,45 +319,45 @@ void ViewArea::setSnapToGrid( bool enable )
|
||||
|
||||
void ViewArea::initZoomWinRect()
|
||||
{
|
||||
double iMinX = 80;
|
||||
double iMinY = 80;
|
||||
int iMinX = 80;
|
||||
int iMinY = 80;
|
||||
|
||||
double iMaxX = iMinX * 5;
|
||||
double iMaxY = iMinY * 5;
|
||||
int iMaxX = iMinX * 5;
|
||||
int iMaxY = iMinY * 5;
|
||||
|
||||
double dSizeRatio, dWinZoomRatio;
|
||||
|
||||
bool iHorizontalImg = m_image.width() > m_image.height();
|
||||
int iHorizontalImg = ( m_pixmap.width() > m_pixmap.height() ) ? 1 : 0;
|
||||
|
||||
if( iHorizontalImg )
|
||||
{
|
||||
dSizeRatio = (double)m_image.width() / (double)m_image.height();
|
||||
dSizeRatio = (double)m_pixmap.width() / (double)m_pixmap.height();
|
||||
}
|
||||
else
|
||||
{
|
||||
dSizeRatio = (double)m_image.height() / (double)m_image.width();
|
||||
dSizeRatio = (double)m_pixmap.height() / (double)m_pixmap.width();
|
||||
}
|
||||
|
||||
if( dSizeRatio > 5.0 )
|
||||
{
|
||||
if( iHorizontalImg )
|
||||
{
|
||||
dWinZoomRatio = static_cast<double>( m_image.width() ) * 1024.0 / iMaxX / 1000.0;
|
||||
dWinZoomRatio = (double)( m_pixmap.width() * 1024 / iMaxX ) / 1000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dWinZoomRatio = static_cast<double>( m_image.height() ) * 1024.0 / iMaxY / 1000.0;
|
||||
dWinZoomRatio = (double)( m_pixmap.height() * 1024 / iMaxY ) / 1000.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( iHorizontalImg )
|
||||
{
|
||||
dWinZoomRatio = static_cast<double>( m_image.height() ) * 1024.0 / iMinY / 1000.0;
|
||||
dWinZoomRatio = (double)( m_pixmap.height() * 1024 / iMinY ) / 1000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dWinZoomRatio = static_cast<double>( m_image.width() ) * 1024.0 / iMinX / 1000.0;
|
||||
dWinZoomRatio = (double)( m_pixmap.width() * 1024 / iMinX ) / 1000.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,8 +369,8 @@ void ViewArea::initZoomWinRect()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ViewArea::updateSize()
|
||||
{
|
||||
int w = m_image.width() * m_dZoomFactor;
|
||||
int h = m_image.height() * m_dZoomFactor;
|
||||
int w = m_pixmap.width() * m_dZoomFactor;
|
||||
int h = m_pixmap.height() * m_dZoomFactor;
|
||||
setMinimumSize( w, h );
|
||||
|
||||
QWidget* p = parentWidget();
|
||||
@@ -427,17 +388,17 @@ void ViewArea::updateSize()
|
||||
|
||||
void ViewArea::updateOffset()
|
||||
{
|
||||
if( width() > m_image.width() * m_dZoomFactor )
|
||||
if( width() > m_pixmap.width() * m_dZoomFactor )
|
||||
{
|
||||
m_xOffset = ( width() - m_image.width() * m_dZoomFactor ) / 2;
|
||||
m_xOffset = ( width() - m_pixmap.width() * m_dZoomFactor ) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_xOffset = 0;
|
||||
}
|
||||
if( height() > m_image.height() * m_dZoomFactor )
|
||||
if( height() > m_pixmap.height() * m_dZoomFactor )
|
||||
{
|
||||
m_yOffset = ( height() - m_image.height() * m_dZoomFactor ) / 2;
|
||||
m_yOffset = ( height() - m_pixmap.height() * m_dZoomFactor ) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -450,7 +411,7 @@ void ViewArea::updateOffset()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ViewArea::resizeEvent( QResizeEvent* event )
|
||||
{
|
||||
if( size().isEmpty() || m_image.isNull() )
|
||||
if( size().isEmpty() || m_pixmap.isNull() )
|
||||
return;
|
||||
|
||||
updateOffset();
|
||||
@@ -463,11 +424,12 @@ void ViewArea::resizeEvent( QResizeEvent* event )
|
||||
|
||||
void ViewArea::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
m_currFrame = m_nextFrame;
|
||||
|
||||
QRect winRect = event->rect();
|
||||
|
||||
if( visibleRegion().isEmpty() || size().isEmpty() || m_image.isNull() || m_currFrame == nullptr )
|
||||
if( visibleRegion().isEmpty() )
|
||||
return;
|
||||
|
||||
if( size().isEmpty() || m_pixmap.isNull() )
|
||||
return;
|
||||
|
||||
QSize windowSize = parentWidget()->size();
|
||||
@@ -480,14 +442,15 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
|
||||
// This line is for fast paiting. Only visible area of the image is painted.
|
||||
// We take the exposed rect from the event (that gives us scroll/expose
|
||||
// optimizations for free – no need to draw the whole pixmap if your widget
|
||||
// is only partially exposed), and reverse map it with the painter matrix.
|
||||
// optimizations for free – no need
|
||||
// to draw the whole pixmap if your widget is only partially exposed), and
|
||||
// reverse map it with the painter matrix.
|
||||
// That gives us the part of the pixmap that has actually been exposed.
|
||||
// See: http://blog.qt.digia.com/blog/2006/05/13/fast-transformed-pixmapimage-drawing/
|
||||
QRect exposedRect = painter.worldTransform().inverted().mapRect( winRect ).adjusted( -1, -1, 1, 1 );
|
||||
// See:
|
||||
// http://blog.qt.digia.com/blog/2006/05/13/fast-transformed-pixmapimage-drawing/
|
||||
QRect exposedRect = painter.worldTransform().inverted().mapRect( event->rect() ).adjusted( -1, -1, 1, 1 );
|
||||
// Draw the pixmap.
|
||||
// painter.drawPixmap( exposedRect, m_pixmap, exposedRect );
|
||||
painter.drawImage( exposedRect, m_image, exposedRect );
|
||||
painter.drawPixmap( exposedRect, m_pixmap, exposedRect );
|
||||
|
||||
// Draw the Grid if it's visible.
|
||||
if( m_bGridVisible )
|
||||
@@ -505,33 +468,33 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
// is, is referenced to the not scaled image.
|
||||
// To know what image area we need to update, just intersects the
|
||||
// rectangle area with the image area.
|
||||
vr &= QRect( 0, 0, m_image.width(), m_image.height() );
|
||||
vr &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
|
||||
|
||||
// Set up for the grid drawer.
|
||||
painter.setRenderHint( QPainter::Antialiasing );
|
||||
|
||||
// Draw grid.
|
||||
m_grid.drawGrid( m_image, vr, &painter );
|
||||
m_grid.drawGrid( m_pixmap, vr, &painter );
|
||||
}
|
||||
|
||||
painter.restore();
|
||||
|
||||
// Draw a border around the image.
|
||||
/* if( m_xOffset || m_yOffset )
|
||||
{
|
||||
painter.setPen( Qt::black );
|
||||
painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_image.width() *
|
||||
m_dZoomFactor + 1, m_image.height() *
|
||||
m_dZoomFactor + 1 );
|
||||
}*/
|
||||
{
|
||||
painter.setPen( Qt::black );
|
||||
painter.drawRect( m_xOffset - 1, m_yOffset - 1, m_pixmap.width() *
|
||||
m_dZoomFactor + 1, m_pixmap.height() *
|
||||
m_dZoomFactor + 1 );
|
||||
}*/
|
||||
|
||||
int frFormat = m_currFrame->getColorSpace();
|
||||
int frFormat = m_pcCurrFrame->getColorSpace();
|
||||
|
||||
// Draw pixel values in grid
|
||||
if( m_dZoomFactor >= 60.0 || ( frFormat != CLP_COLOR_RGBA && m_dZoomFactor >= 50.0 ) )
|
||||
{
|
||||
int imageWidth = m_image.width();
|
||||
int imageHeight = m_image.height();
|
||||
int imageWidth = m_pixmap.width();
|
||||
int imageHeight = m_pixmap.height();
|
||||
;
|
||||
|
||||
QFont font( "Helvetica" );
|
||||
@@ -549,7 +512,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
|
||||
QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_dZoomFactor, m_dZoomFactor ) );
|
||||
QString pixelValue;
|
||||
CalypPixel pixel = m_currFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
CalypPixel pixel = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
|
||||
|
||||
if( frFormat == CLP_COLOR_YUV || frFormat == CLP_COLOR_GRAY )
|
||||
{
|
||||
@@ -596,33 +559,33 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
painter.drawLine( viewToWindow( QPoint( 0, y ) ), viewToWindow( QPoint( imageWidth, y ) ) );
|
||||
}
|
||||
}
|
||||
bool showZoomRect = m_image.width() * m_dZoomFactor > windowSize.width() ||
|
||||
m_image.height() * m_dZoomFactor > windowSize.height();
|
||||
bool showZoomRect = m_pixmap.width() * m_dZoomFactor > windowSize.width() ||
|
||||
m_pixmap.height() * m_dZoomFactor > windowSize.height();
|
||||
|
||||
// VISIBLE ZOOM RECT
|
||||
if( m_visibleZoomRect && m_zoomWinTimer.isActive() && showZoomRect )
|
||||
{
|
||||
double dRatio = m_dZoomWinRatio;
|
||||
|
||||
QRect cImg = QRect( 0, 0, m_image.width(), m_image.height() );
|
||||
QRect cImg = QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
|
||||
QPoint cZWinRBpos = QPoint( winRect.bottomRight() ) - QPoint( 15, 15 );
|
||||
QRect cImgWinRect( 0, 0, round( (double)cImg.width() / dRatio ), round( (double)cImg.height() / dRatio ) );
|
||||
cImgWinRect.moveBottomRight( cZWinRBpos );
|
||||
|
||||
QRect vr = windowToView( winRect );
|
||||
QRect cVisibleImg = vr & cImg;
|
||||
// cVisibleImg.moveTopLeft(vr.topLeft());
|
||||
//cVisibleImg.moveTopLeft(vr.topLeft());
|
||||
QRect cVisibleWinRect;
|
||||
cVisibleWinRect.setLeft( floor( (double)cVisibleImg.x() / dRatio ) );
|
||||
cVisibleWinRect.setTop( floor( (double)cVisibleImg.y() / dRatio ) );
|
||||
cVisibleWinRect.setRight( round( (double)cVisibleImg.right() / dRatio ) );
|
||||
cVisibleWinRect.setBottom( round( (double)cVisibleImg.bottom() / dRatio ) );
|
||||
|
||||
// painter.fillRect( cImgWinRect, QBrush( QColor( 128, 128, 128, 128 ) ) );
|
||||
//painter.fillRect( cImgWinRect, QBrush( QColor( 128, 128, 128, 128 ) ) );
|
||||
painter.setPen( QColor( 50, 50, 50, 128 ) );
|
||||
// painter.drawRect( cImgWinRect );
|
||||
//painter.drawRect( cImgWinRect );
|
||||
painter.setOpacity( 0.7 );
|
||||
painter.drawImage( cImgWinRect, m_image );
|
||||
painter.drawPixmap( cImgWinRect, m_pixmap );
|
||||
painter.setOpacity( 1 );
|
||||
|
||||
cVisibleWinRect.moveTopLeft( cImgWinRect.topLeft() + cVisibleWinRect.topLeft() );
|
||||
@@ -643,7 +606,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
painter.setPen( QColor( 255, 255, 255, 128 ) );
|
||||
painter.drawRect( cVisibleWinRect );
|
||||
|
||||
// qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio;
|
||||
//qDebug() << "Debug VisibleZoomRect: " << winRect << vr << cImgWinRect << cVisibleWinRect << cVisibleImg << dRatio;
|
||||
}
|
||||
|
||||
QRect sr = viewToWindow( m_selectedArea );
|
||||
@@ -654,7 +617,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_newShape || m_blockTrackEnable )
|
||||
{
|
||||
// Set the tool color
|
||||
QColor selectColor = kSelectionColor;
|
||||
QColor selectColor = selectionColor;
|
||||
|
||||
selectColor.setAlpha( 120 );
|
||||
|
||||
@@ -679,7 +642,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
painter.setBrush( fill );
|
||||
painter.setPen( Qt::NoPen );
|
||||
QPainterPath myPath;
|
||||
QRect imgr = viewToWindow( QRect( 0, 0, m_image.width(), m_image.height() ) );
|
||||
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
|
||||
|
||||
myPath.addRect( imgr );
|
||||
myPath.addRect( sr ); // m_selectedArea
|
||||
@@ -708,7 +671,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_maskColor.isValid() )
|
||||
color = m_maskColor;
|
||||
else
|
||||
color = kImageMaskColor;
|
||||
color = imageMaskColor;
|
||||
|
||||
color.setAlpha( 120 );
|
||||
painter.setPen( color );
|
||||
@@ -728,16 +691,16 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
if( m_maskColor.isValid() )
|
||||
color = m_maskColor;
|
||||
else
|
||||
color = kImageMaskColor;
|
||||
color = imageMaskColor;
|
||||
|
||||
break;
|
||||
}
|
||||
case EraserTool: {
|
||||
color = kEraserColor;
|
||||
color = eraserColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
color = kSelectionColor; // ?Problems!
|
||||
color = selectionColor; // ?Problems!
|
||||
}
|
||||
|
||||
color.setAlpha( 120 );
|
||||
@@ -767,7 +730,7 @@ void ViewArea::wheelEvent( QWheelEvent* event )
|
||||
|
||||
if( event->modifiers() & Qt::ControlModifier )
|
||||
{
|
||||
scale = 0.001 * event->angleDelta().y();
|
||||
scale = 0.001 * event->delta();
|
||||
if( scale > 0 )
|
||||
scale = 1.25;
|
||||
else
|
||||
@@ -775,16 +738,10 @@ void ViewArea::wheelEvent( QWheelEvent* event )
|
||||
|
||||
QWidget* p = parentWidget();
|
||||
QSize minimumSize = QSize( p->size().width() - 5, p->size().height() - 5 );
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 14, 0 )
|
||||
auto eventPosition = event->pos();
|
||||
#else
|
||||
auto eventPosition = event->position().toPoint();
|
||||
#endif
|
||||
usedScale = scaleZoomFactor( scale, eventPosition, minimumSize );
|
||||
usedScale = scaleZoomFactor( scale, event->pos(), minimumSize );
|
||||
if( usedScale != 1.0 )
|
||||
{
|
||||
emit zoomFactorChanged_byWheel( usedScale, eventPosition );
|
||||
emit zoomFactorChanged_byWheel( usedScale, event->pos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -795,7 +752,7 @@ void ViewArea::mousePressEvent( QMouseEvent* event )
|
||||
|
||||
QPoint vpos = windowToView( event->pos() );
|
||||
|
||||
if( event->button() == Qt::MiddleButton )
|
||||
if( event->button() == Qt::MidButton )
|
||||
{
|
||||
}
|
||||
if( event->button() == Qt::LeftButton )
|
||||
@@ -942,24 +899,24 @@ void ViewArea::mouseMoveEvent( QMouseEvent* event )
|
||||
}
|
||||
}
|
||||
/* else // if tool() == BlockSelectionTool || MaskTool || EraserTool
|
||||
{
|
||||
m_blockTrackEnable = false;
|
||||
// If cursor is inside the selected area, we most redraw
|
||||
// the selection rect because it may be smaller.
|
||||
if( m_selectedArea.contains( actualPos ) )
|
||||
{
|
||||
m_selectedArea = m_grid.rectContains( m_lastPos );
|
||||
}
|
||||
{
|
||||
m_blockTrackEnable = false;
|
||||
// If cursor is inside the selected area, we most redraw
|
||||
// the selection rect because it may be smaller.
|
||||
if( m_selectedArea.contains( actualPos ) )
|
||||
{
|
||||
m_selectedArea = m_grid.rectContains( m_lastPos );
|
||||
}
|
||||
|
||||
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
|
||||
}
|
||||
*/
|
||||
m_selectedArea = m_selectedArea.united( m_grid.rectContains( actualPos ) );
|
||||
}
|
||||
*/
|
||||
if( tool() == SelectionTool )
|
||||
{
|
||||
// intercept the selected area with the image area to limit the
|
||||
// selection only to the image area, preventing it to come outside
|
||||
// the image.
|
||||
m_selectedArea &= QRect( 0, 0, m_image.width(), m_image.height() );
|
||||
m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
|
||||
|
||||
// Update only the united area
|
||||
// updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
|
||||
@@ -1043,7 +1000,7 @@ void ViewArea::mouseReleaseEvent( QMouseEvent* event )
|
||||
|
||||
bool ViewArea::isPosValid( const QPoint& pos ) const
|
||||
{
|
||||
if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_image.width() || pos.y() >= m_image.height() )
|
||||
if( pos.x() < 0 || pos.y() < 0 || pos.x() >= m_pixmap.width() || pos.y() >= m_pixmap.height() )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@@ -1134,6 +1091,6 @@ void ViewArea::updateMask( const QRect& rect )
|
||||
break;
|
||||
}
|
||||
default: /* Do Nothing */
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
+26
-25
@@ -56,15 +56,17 @@ public:
|
||||
|
||||
ViewArea( QWidget* parent = 0 );
|
||||
|
||||
void setImage( std::shared_ptr<CalypFrame> frame );
|
||||
|
||||
auto getFilteredChannel() -> std::optional<std::size_t>;
|
||||
void setFilteredChannel( std::size_t channel );
|
||||
void clearFilteredChannel();
|
||||
void setImage( CalypFrame* pcFrame );
|
||||
void setImage( const QPixmap& pixmap );
|
||||
|
||||
void setMode( int mode );
|
||||
void setMaskColor( const QColor& color = QColor() );
|
||||
|
||||
/**
|
||||
* Clears any contents.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Select tool from the menu
|
||||
*/
|
||||
@@ -81,6 +83,8 @@ public:
|
||||
*/
|
||||
void clearMask();
|
||||
|
||||
QPixmap image() const { return m_pixmap; }
|
||||
QBitmap mask() const { return m_mask; }
|
||||
QRect selectedArea() const { return m_selectedArea; }
|
||||
GridManager gridManager() const { return m_grid; }
|
||||
QColor maskColor() const { return m_maskColor; }
|
||||
@@ -106,12 +110,12 @@ public Q_SLOTS:
|
||||
// void setSelectedArea( QRect &rect );
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event ) override;
|
||||
void resizeEvent( QResizeEvent* event ) override;
|
||||
void mousePressEvent( QMouseEvent* event ) override;
|
||||
void mouseMoveEvent( QMouseEvent* event ) override;
|
||||
void mouseReleaseEvent( QMouseEvent* event ) override;
|
||||
void wheelEvent( QWheelEvent* event ) override;
|
||||
void paintEvent( QPaintEvent* event );
|
||||
void resizeEvent( QResizeEvent* event );
|
||||
void mousePressEvent( QMouseEvent* event );
|
||||
void mouseMoveEvent( QMouseEvent* event );
|
||||
void mouseReleaseEvent( QMouseEvent* event );
|
||||
void wheelEvent( QWheelEvent* event );
|
||||
|
||||
void updateSize();
|
||||
void updateOffset();
|
||||
@@ -146,36 +150,33 @@ private:
|
||||
QPoint viewToWindow( const QPoint& pt ) const;
|
||||
QRect viewToWindow( const QRect& rc ) const;
|
||||
|
||||
std::shared_ptr<CalypFrame> m_currFrame;
|
||||
QImage m_image;
|
||||
std::shared_ptr<CalypFrame> m_nextFrame;
|
||||
CalypFrame* m_pcCurrFrame;
|
||||
|
||||
std::optional<std::size_t> m_filterSingleChannel;
|
||||
ClpPel m_uiPixelHalfScale;
|
||||
|
||||
Tool m_eTool{ NavigationTool };
|
||||
bool m_bGridVisible{ false };
|
||||
Tool m_eTool;
|
||||
bool m_bGridVisible;
|
||||
|
||||
QTimer m_zoomWinTimer;
|
||||
double m_dZoomWinRatio;
|
||||
double m_dZoomFactor{ 1.0 };
|
||||
double m_dZoomFactor;
|
||||
|
||||
// QPixmap m_pixmap;
|
||||
QPixmap m_pixmap;
|
||||
QBitmap m_mask;
|
||||
QRect m_selectedArea;
|
||||
QPoint m_lastPos;
|
||||
QPoint m_lastWindowPos;
|
||||
GridManager m_grid;
|
||||
ViewMode m_mode{ NormalMode };
|
||||
ViewMode m_mode;
|
||||
|
||||
QColor m_maskColor;
|
||||
int m_xOffset{ 0 };
|
||||
int m_yOffset{ 0 };
|
||||
bool m_blockTrackEnable{ false };
|
||||
int m_xOffset;
|
||||
int m_yOffset;
|
||||
bool m_blockTrackEnable;
|
||||
bool m_newShape;
|
||||
bool m_snapToGrid{ false };
|
||||
bool m_snapToGrid;
|
||||
bool m_cursorInGrid;
|
||||
bool m_visibleZoomRect{ true };
|
||||
bool m_visibleZoomRect;
|
||||
};
|
||||
|
||||
#endif // __VIEWAREA_H__
|
||||
@@ -1,21 +0,0 @@
|
||||
#
|
||||
# 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)
|
||||
@@ -1,26 +0,0 @@
|
||||
/* 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>
|
||||
@@ -1,285 +0,0 @@
|
||||
/* 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 );
|
||||
}
|
||||
@@ -49,7 +49,7 @@ AboutDialog::AboutDialog( QWidget* parent )
|
||||
.arg( QApplication::applicationVersion() ) );
|
||||
label->setWordWrap( false );
|
||||
|
||||
QString featuresList = QStringLiteral( "<p><h4><b>Features:</b></h4><ul>" );
|
||||
QString featuresList = QStringLiteral( "<p><h3><b>Features:</b></h3><ul>" );
|
||||
|
||||
#ifdef USE_QTDBUS
|
||||
featuresList.append( QStringLiteral( "<li>Support for Qt DBus messages" ) );
|
||||
@@ -63,21 +63,14 @@ AboutDialog::AboutDialog( QWidget* parent )
|
||||
featuresList.append( QStringLiteral( "</ul></p>" ) );
|
||||
QLabel* labelFeatures = new QLabel( featuresList );
|
||||
|
||||
QString thanksList = QStringLiteral( "<p><h4><b>Thanks to:</b></h4><ul>" );
|
||||
thanksList.append( QStringLiteral( "<li>Joao Santos" ) );
|
||||
thanksList.append( QStringLiteral( "<li>Jose Filipe" ) );
|
||||
thanksList.append( QStringLiteral( "</ul></p>" ) );
|
||||
QLabel* labelContributors = new QLabel( thanksList );
|
||||
|
||||
QLabel* labelCopyright = new QLabel( QStringLiteral( "Copyright 2014–2021 Joao Carreira and Luis Lucas" ) );
|
||||
QLabel* labelCopyright = new QLabel( QStringLiteral( "Copyright © 2014–2018 Joao Carreira and Luis Lucas" ) );
|
||||
|
||||
QWidget* topWidget = new QWidget;
|
||||
QVBoxLayout* topLayout = new QVBoxLayout;
|
||||
topLayout->addWidget( pixmapLabel, 0, Qt::AlignHCenter );
|
||||
topLayout->addWidget( label );
|
||||
topLayout->addWidget( labelCopyright );
|
||||
topLayout->addWidget( labelFeatures );
|
||||
topLayout->addWidget( labelContributors );
|
||||
topLayout->addWidget( labelCopyright );
|
||||
topWidget->setLayout( topLayout );
|
||||
|
||||
// QTextEdit *textEdit = new QTextEdit(tr("<p>This program is free "
|
||||
|
||||
@@ -73,7 +73,8 @@ 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" );
|
||||
@@ -136,7 +137,8 @@ private:
|
||||
QSpinBox* m_spinHeight;
|
||||
};
|
||||
|
||||
ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( parent )
|
||||
ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent )
|
||||
: QDialog( parent )
|
||||
{
|
||||
QString Name;
|
||||
unsigned int uiWidth, uiHeight;
|
||||
@@ -173,18 +175,12 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( paren
|
||||
|
||||
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( fontWeight );
|
||||
titleFont.setWeight( 75 );
|
||||
|
||||
menusFont.setBold( true );
|
||||
titleFont.setWeight( fontWeight );
|
||||
titleFont.setWeight( 75 );
|
||||
|
||||
normalFont.setBold( false );
|
||||
// menusFont.setPointSize( 12 );
|
||||
@@ -386,30 +382,8 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget* parent ) : QDialog( paren
|
||||
setFixedSize( MainLayout->sizeHint() );
|
||||
}
|
||||
|
||||
auto findPelFormatColorSpace( ClpPixelFormats rInputFormat ) -> std::pair<int, std::int64_t>
|
||||
{
|
||||
if( rInputFormat != ClpPixelFormats::Invalid )
|
||||
{
|
||||
auto pelFmtName = CalypFrame::pixelFormatName( rInputFormat );
|
||||
for( unsigned int j = 0; j < CalypFrame::supportedColorSpacesListNames().size(); j++ )
|
||||
{
|
||||
const auto& formats_list = CalypFrame::supportedPixelFormatListNames( j );
|
||||
for( const auto& [key, name] : formats_list )
|
||||
{
|
||||
if( pelFmtName == name )
|
||||
{
|
||||
return std::make_pair( j, static_cast<int>( key ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::make_pair( 0, 0 );
|
||||
}
|
||||
|
||||
auto ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth,
|
||||
unsigned int& rHeight, ClpPixelFormats& rInputFormat,
|
||||
unsigned int& rBits, int& rEndianess,
|
||||
unsigned int& rFrameRate ) -> QDialog::DialogCode
|
||||
int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight,
|
||||
int& rInputFormat, unsigned int& rBits, int& rEndianess, unsigned int& rFrameRate )
|
||||
{
|
||||
// Set default values
|
||||
// setWindowTitle( "Configure resolution for " + Filename );
|
||||
@@ -417,8 +391,24 @@ auto ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, u
|
||||
m_spinBoxWidth->setValue( rWidth );
|
||||
m_spinBoxheight->setValue( rHeight );
|
||||
|
||||
auto [colorSpace, sampling] = findPelFormatColorSpace( rInputFormat );
|
||||
|
||||
int colorSpace = 0;
|
||||
int sampling = 0;
|
||||
if( rInputFormat >= 0 )
|
||||
{
|
||||
ClpString pelFmtName = CalypFrame::supportedPixelFormatListNames()[rInputFormat];
|
||||
for( unsigned int j = 0; j < CalypFrame::supportedColorSpacesListNames().size(); j++ )
|
||||
{
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( j ).size(); i++ )
|
||||
{
|
||||
if( pelFmtName == CalypFrame::supportedPixelFormatListNames( j )[i] )
|
||||
{
|
||||
colorSpace = j;
|
||||
sampling = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_comboBoxColorSpace->setCurrentIndex( colorSpace );
|
||||
m_comboBoxPixelFormat->setCurrentIndex( sampling );
|
||||
m_spinBoxBits->setValue( rBits );
|
||||
@@ -451,8 +441,16 @@ auto ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, u
|
||||
rWidth = m_spinBoxWidth->value();
|
||||
rHeight = m_spinBoxheight->value();
|
||||
colorSpace = m_comboBoxColorSpace->currentIndex();
|
||||
sampling = m_comboBoxPixelFormat->currentData().toInt();
|
||||
rInputFormat = static_cast<ClpPixelFormats>( sampling );
|
||||
sampling = m_comboBoxPixelFormat->currentIndex();
|
||||
ClpString pelFmtName = CalypFrame::supportedPixelFormatListNames( colorSpace )[sampling];
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
if( pelFmtName == CalypFrame::supportedPixelFormatListNames()[i] )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
rBits = m_spinBoxBits->value();
|
||||
rEndianess = m_comboBoxEndianness->currentIndex();
|
||||
rFrameRate = m_spinBoxFrameRate->value();
|
||||
@@ -510,13 +508,13 @@ 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 );
|
||||
for( const auto& [key, name] : formats_list )
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames( idx ).size(); i++ )
|
||||
{
|
||||
m_comboBoxPixelFormat->addItem( QString::fromStdString( std::string( name ) ), static_cast<int>( key ) );
|
||||
m_comboBoxPixelFormat->insertItem( i, CalypFrame::supportedPixelFormatListNames( idx )[i].c_str() );
|
||||
}
|
||||
m_comboBoxPixelFormat->setCurrentIndex( 0 );
|
||||
}
|
||||
@@ -544,6 +542,6 @@ void ConfigureFormatDialog::writeSettings()
|
||||
{
|
||||
QSettings appSettings;
|
||||
QVariant var;
|
||||
var.setValue( aRCustomFileFormats );
|
||||
var.setValue<CalypStandardResolutionVector>( aRCustomFileFormats );
|
||||
appSettings.setValue( "ConfigureFormatDialog/CustomFormats", var );
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class QSpinBox;
|
||||
class QString;
|
||||
class QWidget;
|
||||
|
||||
using CalypStandardResolutionVector = QVector<CalypStandardResolution>;
|
||||
typedef QVector<CalypStandardResolution> CalypStandardResolutionVector;
|
||||
QDataStream& operator<<( QDataStream& out, const CalypStandardResolutionVector& array );
|
||||
QDataStream& operator>>( QDataStream& in, CalypStandardResolutionVector& array );
|
||||
|
||||
@@ -51,9 +51,8 @@ class ConfigureFormatDialog : public QDialog
|
||||
|
||||
public:
|
||||
ConfigureFormatDialog( QWidget* parent = 0 );
|
||||
auto runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight,
|
||||
ClpPixelFormats& rInputFormat, unsigned int& rBits, int& rEndianess,
|
||||
unsigned int& rFrameRate ) -> QDialog::DialogCode;
|
||||
int runConfigureFormatDialog( const QString& Filename, unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBits,
|
||||
int& rEndianess, unsigned int& rFrameRate );
|
||||
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
|
||||
@@ -36,17 +36,18 @@
|
||||
|
||||
class QLineEdit;
|
||||
|
||||
class OptionConfiguration : public QWidget
|
||||
class OpionConfiguration : public QWidget
|
||||
{
|
||||
public:
|
||||
OptionConfiguration( CalypOptions::OptionBase* option )
|
||||
: m_cName{ option->opt_string }
|
||||
OpionConfiguration( OptionBase* option )
|
||||
{
|
||||
auto* pcDescription = new QLabel;
|
||||
m_pcChecked = NULL;
|
||||
m_cName = option->opt_string;
|
||||
m_pcDescription = new QLabel;
|
||||
QString desc = QString::fromStdString( option->opt_desc );
|
||||
pcDescription->setText( desc );
|
||||
m_pcDescription->setText( desc );
|
||||
QHBoxLayout* layout = new QHBoxLayout;
|
||||
layout->addWidget( pcDescription, 0, Qt::AlignLeft );
|
||||
layout->addWidget( m_pcDescription, 0, Qt::AlignLeft );
|
||||
if( !option->isBinary() )
|
||||
{
|
||||
m_pcValue = new QLineEdit;
|
||||
@@ -63,7 +64,7 @@ public:
|
||||
layout->setContentsMargins( 1, 1, 1, 1 );
|
||||
setLayout( layout );
|
||||
}
|
||||
auto getValue() const -> QString
|
||||
const QString getValue() const
|
||||
{
|
||||
if( m_pcChecked )
|
||||
{
|
||||
@@ -71,12 +72,13 @@ public:
|
||||
}
|
||||
return m_pcValue->text();
|
||||
}
|
||||
auto getName() const -> std::string { return m_cName; }
|
||||
const ClpString& getName() { return m_cName; }
|
||||
|
||||
private:
|
||||
QLineEdit* m_pcValue{ nullptr };
|
||||
QCheckBox* m_pcChecked{ nullptr };
|
||||
std::string m_cName;
|
||||
QLineEdit* m_pcValue;
|
||||
QCheckBox* m_pcChecked;
|
||||
QLabel* m_pcDescription;
|
||||
ClpString m_cName;
|
||||
};
|
||||
|
||||
ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, CalypAppModuleIf* pcCurrModuleIf )
|
||||
@@ -85,12 +87,13 @@ ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, CalypAppModuleI
|
||||
resize( 400, 10 );
|
||||
setWindowTitle( "Select module parameters" );
|
||||
|
||||
auto& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList();
|
||||
const CalypOptions::OptionsList& moduleOptions = m_pcCurrModuleIf->m_pcModule->m_cModuleOptions.getOptionList();
|
||||
|
||||
QVBoxLayout* optionsLayout = new QVBoxLayout;
|
||||
for( auto& option : moduleOptions )
|
||||
OpionConfiguration* pcOption;
|
||||
for( CalypOptions::OptionsList::const_iterator it = moduleOptions.begin(); it != moduleOptions.end(); ++it )
|
||||
{
|
||||
auto pcOption = new OptionConfiguration( option->base_opt.get() );
|
||||
pcOption = new OpionConfiguration( ( *it )->opt );
|
||||
m_apcOptionList.append( pcOption );
|
||||
optionsLayout->addWidget( pcOption );
|
||||
}
|
||||
@@ -118,17 +121,17 @@ int ModulesHandleOptDialog::runConfiguration()
|
||||
return QDialog::Rejected;
|
||||
}
|
||||
|
||||
std::vector<std::string> argsArray;
|
||||
std::string optionString;
|
||||
std::vector<ClpString> argsArray;
|
||||
ClpString optionString;
|
||||
QString valueString( "" );
|
||||
|
||||
for( const auto& option : m_apcOptionList )
|
||||
for( int i = 0; i < m_apcOptionList.size(); i++ )
|
||||
{
|
||||
valueString = option->getValue();
|
||||
valueString = m_apcOptionList.at( i )->getValue();
|
||||
if( !valueString.isEmpty() )
|
||||
{
|
||||
optionString.append( "--" );
|
||||
optionString.append( option->getName() );
|
||||
optionString.append( m_apcOptionList.at( i )->getName() );
|
||||
if( !( valueString == "true" ) )
|
||||
{
|
||||
optionString.append( "=" );
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "CommonDefs.h"
|
||||
#include "config.h"
|
||||
|
||||
class OptionConfiguration;
|
||||
class OpionConfiguration;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
private:
|
||||
CalypAppModuleIf* m_pcCurrModuleIf;
|
||||
QVector<OptionConfiguration*> m_apcOptionList;
|
||||
QVector<OpionConfiguration*> m_apcOptionList;
|
||||
};
|
||||
|
||||
#endif // __MODULEHANDLEOPTDIALOG_H__
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "ProgressBar.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
SeekStreamDialog::SeekStreamDialog( const CalypStream* pcCurrStream, QWidget* parent )
|
||||
SeekStreamDialog::SeekStreamDialog( CalypStream* pcCurrStream, QWidget* parent )
|
||||
: QDialog( parent, Qt::Dialog | Qt::WindowTitleHint ), m_iSelectedFrameNum()
|
||||
{
|
||||
m_iSelectedFrameNum = pcCurrStream->getCurrFrameNum();
|
||||
|
||||
@@ -42,7 +42,7 @@ class SeekStreamDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SeekStreamDialog( const CalypStream* pcCurrStream, QWidget* parent = 0 );
|
||||
SeekStreamDialog( CalypStream* pcCurrStream, QWidget* parent = 0 );
|
||||
int runDialog();
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
#include <QtGui>
|
||||
#include <cmath>
|
||||
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch )
|
||||
: QWidget( parent ), m_bIsPlaying( false ), m_bHasFrame( false )
|
||||
: QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch )
|
||||
{
|
||||
// -------------- Variables definition --------------
|
||||
m_pcFrame = NULL;
|
||||
m_pcSelectedFrame = NULL;
|
||||
m_iLastFrameType = -1;
|
||||
|
||||
// Histogram area -----------------------------------------------------
|
||||
@@ -230,8 +230,6 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitc
|
||||
statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( medianLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( percentileLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelPercentileValue, gridRow++, 1 );
|
||||
statisticsLayout->addWidget( entropyLabel, gridRow, 0 );
|
||||
statisticsLayout->addWidget( labelEntropyValue, gridRow++, 1 );
|
||||
|
||||
@@ -280,15 +278,16 @@ QSize FramePropertiesDock::sizeHint() const
|
||||
|
||||
void FramePropertiesDock::reset()
|
||||
{
|
||||
m_pcFrame = nullptr;
|
||||
m_pcSelectedFrame = nullptr;
|
||||
|
||||
m_bHasFrame = false;
|
||||
m_pcFrame = NULL;
|
||||
m_cSelectionArea = QRect();
|
||||
if( m_pcSelectedFrame )
|
||||
{
|
||||
delete m_pcSelectedFrame;
|
||||
m_pcSelectedFrame = NULL;
|
||||
}
|
||||
|
||||
m_iLastFrameType = -1;
|
||||
|
||||
labelRangeValue->clear();
|
||||
labelNEBinsValue->clear();
|
||||
labelMeanValue->clear();
|
||||
labelPixelsValue->clear();
|
||||
@@ -296,7 +295,6 @@ void FramePropertiesDock::reset()
|
||||
labelCountValue->clear();
|
||||
labelMedianValue->clear();
|
||||
labelPercentileValue->clear();
|
||||
labelEntropyValue->clear();
|
||||
|
||||
// Remove the histogram data from memory
|
||||
histogramWidget->reset();
|
||||
@@ -304,7 +302,7 @@ void FramePropertiesDock::reset()
|
||||
setEnabled( false );
|
||||
}
|
||||
|
||||
void FramePropertiesDock::setFrame( std::shared_ptr<CalypFrame> pcFrame, bool isPlaying )
|
||||
void FramePropertiesDock::setFrame( CalypFrame* pcFrame )
|
||||
{
|
||||
int colorSpace = pcFrame->getColorSpace();
|
||||
if( m_iLastFrameType != colorSpace )
|
||||
@@ -366,40 +364,35 @@ void FramePropertiesDock::setFrame( std::shared_ptr<CalypFrame> pcFrame, bool is
|
||||
}
|
||||
}
|
||||
setEnabled( true );
|
||||
m_bIsPlaying = isPlaying;
|
||||
if( !m_bIsPlaying )
|
||||
if( m_pcFrame || !( *m_pbIsPlaying ) )
|
||||
{
|
||||
if( pcFrame )
|
||||
{
|
||||
m_bHasFrame = true;
|
||||
m_pcFrame = pcFrame;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHasFrame = false;
|
||||
}
|
||||
m_pcFrame = pcFrame;
|
||||
updateDataHistogram();
|
||||
}
|
||||
updateDataHistogram();
|
||||
}
|
||||
|
||||
void FramePropertiesDock::setSelection( const QRect& selectionArea )
|
||||
{
|
||||
if( m_bHasFrame )
|
||||
if( m_pcFrame )
|
||||
{
|
||||
bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() );
|
||||
m_cSelectionArea = selectionArea;
|
||||
if( selectionArea.isValid() )
|
||||
{
|
||||
m_cSelectionArea = selectionArea;
|
||||
histogramWidget->stopHistogramComputation();
|
||||
|
||||
/*
|
||||
* Crop selection from frame
|
||||
* Allocate a new image for the selection
|
||||
* or just copy information
|
||||
*/
|
||||
if( bSelectionChanged )
|
||||
{
|
||||
m_pcSelectedFrame = std::make_shared<CalypFrame>( *m_pcFrame, selectionArea.x(),
|
||||
selectionArea.y(),
|
||||
selectionArea.width(),
|
||||
selectionArea.height() );
|
||||
if( m_pcSelectedFrame )
|
||||
{
|
||||
delete m_pcSelectedFrame;
|
||||
}
|
||||
m_pcSelectedFrame = new CalypFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
|
||||
selectionArea.height() );
|
||||
}
|
||||
updateDataHistogram();
|
||||
selectionImageButton->click();
|
||||
@@ -416,21 +409,13 @@ void FramePropertiesDock::setSelection( const QRect& selectionArea )
|
||||
|
||||
void FramePropertiesDock::updateDataHistogram()
|
||||
{
|
||||
if( m_bHasFrame && isVisible() )
|
||||
if( m_pcFrame && isVisible() )
|
||||
{
|
||||
if( m_bIsPlaying )
|
||||
if( !*m_pbIsPlaying )
|
||||
{
|
||||
histogramWidget->setLoadingSkipped();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_cSelectionArea.isValid() )
|
||||
if( m_pcSelectedFrame )
|
||||
{
|
||||
m_pcSelectedFrame = std::make_shared<CalypFrame>( *m_pcFrame,
|
||||
m_cSelectionArea.x(),
|
||||
m_cSelectionArea.y(),
|
||||
m_cSelectionArea.width(),
|
||||
m_cSelectionArea.height() );
|
||||
m_pcSelectedFrame->copyFrom( m_pcFrame, m_cSelectionArea.x(), m_cSelectionArea.y() );
|
||||
fullImageButton->show();
|
||||
selectionImageButton->show();
|
||||
}
|
||||
@@ -439,9 +424,12 @@ void FramePropertiesDock::updateDataHistogram()
|
||||
fullImageButton->hide();
|
||||
selectionImageButton->hide();
|
||||
}
|
||||
histogramWidget->updateData( m_pcFrame, m_cSelectionArea.isValid() ? m_pcSelectedFrame : nullptr );
|
||||
histogramWidget->updateData( m_pcFrame, m_pcSelectedFrame );
|
||||
}
|
||||
else
|
||||
{
|
||||
histogramWidget->setLoadingSkipped();
|
||||
}
|
||||
|
||||
histogramWidget->update();
|
||||
}
|
||||
else
|
||||
@@ -462,7 +450,7 @@ void FramePropertiesDock::updateStatistiques()
|
||||
if( channel == CalypFrame::HIST_ALL_CHANNELS )
|
||||
channel = colorsCB->itemData( colorsCB->currentIndex() ).toInt();
|
||||
|
||||
std::shared_ptr<CalypFrame> frame;
|
||||
CalypFrame* frame;
|
||||
|
||||
if( histogramWidget->m_renderingType == HistogramWidget::FullImageHistogram )
|
||||
frame = histogramWidget->m_fullImage;
|
||||
@@ -535,7 +523,7 @@ void FramePropertiesDock::slotRefreshOptions( int range )
|
||||
|
||||
void FramePropertiesDock::slotHistogramComputationFailed()
|
||||
{
|
||||
m_bHasFrame = false;
|
||||
m_pcFrame = NULL;
|
||||
}
|
||||
|
||||
void FramePropertiesDock::slotChannelChanged( int index )
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
#include "HistogramWidget.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
|
||||
class CalypStream;
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class FramePropertiesDock : public QWidget
|
||||
{
|
||||
@@ -43,17 +42,17 @@ public:
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
void setFrame( std::shared_ptr<CalypFrame> m_pcFrame, bool isPlaying );
|
||||
void setFrame( CalypFrame* m_pcFrame );
|
||||
void setSelection( const QRect& selectionArea );
|
||||
void reset();
|
||||
void stopHistogram();
|
||||
|
||||
private:
|
||||
std::shared_ptr<CalypFrame> m_pcFrame;
|
||||
std::shared_ptr<CalypFrame> m_pcSelectedFrame;
|
||||
CalypFrame* m_pcFrame;
|
||||
CalypFrame* m_pcSelectedFrame;
|
||||
int m_iLastFrameType;
|
||||
bool m_bIsPlaying;
|
||||
bool m_bHasFrame;
|
||||
|
||||
bool* m_pbIsPlaying;
|
||||
|
||||
QComboBox* channelCB;
|
||||
QComboBox* colorsCB;
|
||||
|
||||
@@ -58,9 +58,9 @@ ModuleHandleDock::ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf
|
||||
setEnabled( true );
|
||||
}
|
||||
|
||||
ModuleHandleDock::~ModuleHandleDock() = default;
|
||||
ModuleHandleDock::~ModuleHandleDock() {}
|
||||
|
||||
void ModuleHandleDock::setModuleReturnValue( double value )
|
||||
void ModuleHandleDock::setModulueReturnValue( double value )
|
||||
{
|
||||
labelModulueReturnValue->clear();
|
||||
QString strValue = QString( "%1" ).arg( value );
|
||||
@@ -69,9 +69,11 @@ void ModuleHandleDock::setModuleReturnValue( double value )
|
||||
|
||||
void ModuleHandleDock::visibilityChangedSlot( bool visiblity )
|
||||
{
|
||||
if( !visiblity )
|
||||
if( !visiblity && m_pcCurrModuleIf )
|
||||
{
|
||||
m_pcCurrModuleIf->disable();
|
||||
CalypAppModuleIf* pcCurrentModule = m_pcCurrModuleIf;
|
||||
m_pcCurrModuleIf = NULL;
|
||||
ModulesHandle::destroyModuleIf( pcCurrentModule );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
ModuleHandleDock( QWidget* parent, CalypAppModuleIf* moduleIf );
|
||||
~ModuleHandleDock();
|
||||
|
||||
void setModuleReturnValue( double value );
|
||||
void setModulueReturnValue( double value );
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
|
||||
+3
-16
@@ -2,24 +2,11 @@
|
||||
# CMakeLists for qcustomplot
|
||||
#
|
||||
|
||||
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()
|
||||
|
||||
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Gui Widgets PrintSupport)
|
||||
|
||||
SET(qcustomplot_SRCS qcustomplot.cpp qcustomplot.h)
|
||||
|
||||
SET(CMAKE_AUTOMOC ON)
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-deprecated-enum-enum-conversion")
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(QCustomPlotLib STATIC ${qcustomplot_SRCS})
|
||||
TARGET_LINK_LIBRARIES(QCustomPlotLib Qt::Core Qt::Gui Qt::Widgets Qt::PrintSupport)
|
||||
TARGET_LINK_LIBRARIES(QCustomPlotLib Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(QCustomPlotLib PUBLIC .)
|
||||
Vendored
-674
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
-52
@@ -1,55 +1,3 @@
|
||||
#### 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:
|
||||
- Compatibility up to Qt 6.0
|
||||
- Tech Preview: Radial Plots (see setupPolarPlotDemo in examples project)
|
||||
- QCPAxisTickerDateTime can now be configured with a QTimeZone for adjusting the label display to arbitrary time zones
|
||||
- QCPColorGradient (and thus also QCPColorMap) now has explicit configurable NaN handling (see QCPColorGradient::setNanHandling)
|
||||
- added timing/benchmarking method QCustomPlot::replotTime(bool average) which returns the milliseconds per replot
|
||||
- QCustomPlot::plottableAt has an optional output parameter dataIndex, providing the index of the data point at the probed position
|
||||
- QCustomPlot::plottableAt<T> template method allows limiting the search to the specified QCPAbstractPlottable subclass T
|
||||
- QCustomPlot::itemAt<T> template method allows limiting the search to the specified QCPAbstractItem subclass T
|
||||
- Added Interaction flag QCP::iSelectPlottablesBeyondAxisRect, allows selection of data points very close to (and beyond of) the axes
|
||||
- QCPAxisTickerDateTime::dateTimeToKey(QDate &) now also takes a TimeSpec to specify the interpretation of the start-of-day
|
||||
- QCPAxisTickerLog now switches to linear ticks if zoomed in beyond where logarithmic ticks are reasonable
|
||||
- Added QCustomPlot::afterLayout signal, for user code that crucially depends on layout sizes/positions, right before the draw step during a replot
|
||||
|
||||
Bugfixes:
|
||||
- Fixed bug where QCPLayer::replot wouldn't issue full replot even though invalidated buffers existed
|
||||
- Fixed QCPCurve bug causing rendering artifacts when using keys/values smaller than about 1e-12 in some constellations
|
||||
- Fixed getValueRange when used with explicit keyRange, now doesn't use key range expanded by one point to each side anymore
|
||||
- Fixed bug of QCPAxis tick label font size change only propagating to the layout after second call to replot
|
||||
- Fixed bug of QCPTextElement not respecting the configured text alignment flag (setTextFlags)
|
||||
- Various documentation typos and improvements
|
||||
|
||||
Other:
|
||||
- QCP Now requires C++11. However, Qt4.6 compatibility is maintained in the QCP 2.x release series
|
||||
- QCPColorScale is now initialized with gpCold gradient preset, which prevents color maps turning black when linking them to a default-created color scale without explicitly setting a gradient
|
||||
- QCPLegend::clearItems is now faster in case of many legend items (>1000)
|
||||
- Modernized expressions and thereby avoided some warnings (e.g. nullptr and casts)
|
||||
- Switched to foreach (Qt macro) where possible (in preparation for switch to range-based for (C++11), soonest at next major release)
|
||||
- Work around Qt bug, drawing lines with pen width 1 as slow as with pen widths > 1 (polyfill instead of line algorithm, also on Normal-DPI), by using pen width 0 in such cases.
|
||||
- Added QCP::Interaction flag iNone=0x000 to allow explicitly specifying no interaction (Avoids QFlags::zero, which was deprecated in Qt5.14)
|
||||
- QCP is now compatible with defines QT_USE_QSTRINGBUILDER, QT_USE_FAST_CONCATENATION (Qt<4.8), QT_USE_FAST_OPERATOR_PLUS (Qt<4.8)
|
||||
|
||||
#### Version 2.0.1 released on 25.06.18 ####
|
||||
|
||||
Bugfixes:
|
||||
|
||||
+9775
-14567
File diff suppressed because it is too large.
Load diff
+3270
-4115
File diff suppressed because it is too large.
Load diff
+3
-13
@@ -22,10 +22,6 @@
|
||||
* \brief main file
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMetaType>
|
||||
#include <QStyleFactory>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "ConfigureFormatDialog.h"
|
||||
#include "MainWindow.h"
|
||||
@@ -34,7 +30,7 @@
|
||||
#ifdef USE_QTDBUS
|
||||
#include "DBusAppAdaptor.h"
|
||||
#endif
|
||||
|
||||
#include <QApplication>
|
||||
#ifdef USE_FERVOR
|
||||
#include "fvupdater.h"
|
||||
#endif
|
||||
@@ -46,21 +42,15 @@
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
qRegisterMetaType<CalypFileInfoVector>();
|
||||
qRegisterMetaType<CalypStandardResolutionVector>();
|
||||
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
|
||||
qRegisterMetaTypeStreamOperators<CalypFileInfoVector>();
|
||||
qRegisterMetaType<CalypStandardResolutionVector>();
|
||||
qRegisterMetaTypeStreamOperators<CalypStandardResolutionVector>();
|
||||
#endif
|
||||
QApplication::setStyle( "macOS" );
|
||||
|
||||
QApplication application( argc, argv );
|
||||
QApplication::setApplicationName( QStringLiteral( "Calyp" ) );
|
||||
QApplication::setApplicationVersion( QStringLiteral( CALYP_VERSION_STRING ) );
|
||||
QApplication::setOrganizationName( QStringLiteral( "PixLRA" ) );
|
||||
|
||||
#if _WIN32
|
||||
application.setStyle( QStyleFactory::create( "Fusion" ) );
|
||||
#endif
|
||||
|
||||
#ifdef USE_QTDBUS
|
||||
/**
|
||||
* use dbus, if available
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/* 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__
|
||||
@@ -1,351 +0,0 @@
|
||||
/* 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;
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/* 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__
|
||||
Binary file not shown.
@@ -35,7 +35,7 @@ class QLabel;
|
||||
class FrameNumberWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
explicit FrameNumberWidget( QWidget* parent = 0 );
|
||||
FrameNumberWidget( QWidget* parent = 0 );
|
||||
void setCurrFrameNum( int number );
|
||||
void setTotalFrameNum( int number );
|
||||
void clear();
|
||||
|
||||
@@ -41,42 +41,60 @@ class HistogramWorker : public QThread
|
||||
{
|
||||
private:
|
||||
QObject* m_parent;
|
||||
std::shared_ptr<CalypFrame> m_pcFrame{ nullptr };
|
||||
CalypFrame* m_pcFrame;
|
||||
|
||||
public:
|
||||
HistogramWorker( QObject* parent )
|
||||
: m_parent{ parent } {}
|
||||
|
||||
void reset() { m_pcFrame = nullptr; }
|
||||
|
||||
void setup( std::shared_ptr<CalypFrame> frame )
|
||||
{
|
||||
m_pcFrame = std::move( frame );
|
||||
EventData* eventData = new EventData(); // NOLINT
|
||||
eventData->starting = true;
|
||||
// QCoreApplication::postEvent( m_parent, eventData );
|
||||
m_pcFrame = NULL;
|
||||
m_parent = parent;
|
||||
}
|
||||
|
||||
void setup( CalypFrame* frame )
|
||||
{
|
||||
m_pcFrame = frame;
|
||||
// run();
|
||||
start();
|
||||
}
|
||||
void run() override
|
||||
void run()
|
||||
{
|
||||
EventData* eventData = new EventData(); // NOLINT
|
||||
if( m_pcFrame != nullptr )
|
||||
if( m_pcFrame && m_parent )
|
||||
{
|
||||
EventData* eventData = new EventData();
|
||||
// eventDm_imageHistogramata->starting = true;
|
||||
// eventData->success = false;
|
||||
// eventData->histogram = m_histogram;
|
||||
// QCoreApplication::postEvent( m_parent, eventData );
|
||||
|
||||
eventData->starting = true;
|
||||
|
||||
m_pcFrame->calcHistogram();
|
||||
eventData->frame = m_pcFrame.get();
|
||||
|
||||
eventData->starting = false;
|
||||
// eventData->success = m_pcFrame->getHasHistogram();
|
||||
eventData->success = true;
|
||||
eventData->frame = m_pcFrame;
|
||||
QCoreApplication::postEvent( m_parent, eventData );
|
||||
}
|
||||
eventData->success = true;
|
||||
QCoreApplication::postEvent( m_parent, eventData );
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Event
|
||||
*/
|
||||
class EventData : public QEvent
|
||||
{
|
||||
public:
|
||||
EventData()
|
||||
: QEvent( QEvent::User ), frame{ nullptr } {}
|
||||
CalypFrame* frame{ nullptr };
|
||||
bool starting{ false };
|
||||
bool success{ false };
|
||||
: QEvent( QEvent::User )
|
||||
{
|
||||
starting = false;
|
||||
success = false;
|
||||
frame = NULL;
|
||||
}
|
||||
|
||||
bool starting;
|
||||
bool success;
|
||||
CalypFrame* frame;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -221,10 +239,8 @@ void HistogramWidget::reset()
|
||||
d->guideVisible = false;
|
||||
d->clearFlag = HistogramWidgetPrivate::HistogramNone;
|
||||
// Remove histogram data from memory.
|
||||
m_fullImage = nullptr;
|
||||
m_selectionImage = nullptr;
|
||||
m_imageWorker->setup( nullptr );
|
||||
m_selectionWorker->setup( nullptr );
|
||||
m_fullImage = NULL;
|
||||
m_selectionImage = NULL;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -246,7 +262,7 @@ void HistogramWidget::customEvent( QEvent* event )
|
||||
return;
|
||||
}
|
||||
|
||||
if( ed->frame != m_fullImage.get() && ed->frame != m_selectionImage.get() )
|
||||
if( ed->frame != m_fullImage && ed->frame != m_selectionImage )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -307,6 +323,8 @@ void HistogramWidget::customEvent( QEvent* event )
|
||||
emit signalHistogramComputationFailed();
|
||||
}
|
||||
}
|
||||
|
||||
// delete ed;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Data Loading Functions
|
||||
@@ -361,7 +379,7 @@ void HistogramWidget::stopHistogramComputation()
|
||||
// Update Data Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void HistogramWidget::updateData( std::shared_ptr<CalypFrame> pcFrame, std::shared_ptr<CalypFrame> pcFrameSelection )
|
||||
void HistogramWidget::updateData( CalypFrame* pcFrame, CalypFrame* pcFrameSelection )
|
||||
{
|
||||
d->imageBits = pcFrame->getBitsPel();
|
||||
switch( pcFrame->getColorSpace() )
|
||||
@@ -479,7 +497,7 @@ void HistogramWidget::paintEvent( QPaintEvent* )
|
||||
int wWidth = width() - 1;
|
||||
int wHeight = height() - 1;
|
||||
double max;
|
||||
std::shared_ptr<CalypFrame> frame;
|
||||
CalypFrame* frame;
|
||||
|
||||
if( m_renderingType == ImageSelectionHistogram && m_selectionImage )
|
||||
frame = m_selectionImage;
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
void stopHistogramComputation();
|
||||
|
||||
/** Update full image histogram data. */
|
||||
void updateData( std::shared_ptr<CalypFrame> pcFrame, std::shared_ptr<CalypFrame> pcFrameSelection );
|
||||
void updateData( CalypFrame* pcFrame, CalypFrame* pcFrameSelection );
|
||||
|
||||
/** @see @p HistogramOption */
|
||||
void setOptions( HistogramOptions options = AllOptions );
|
||||
@@ -113,10 +113,12 @@ public:
|
||||
|
||||
/** Full image */
|
||||
HistogramWorker* m_imageWorker;
|
||||
std::shared_ptr<CalypFrame> m_fullImage;
|
||||
// CalypFrameStats* m_imageHistogram;
|
||||
CalypFrame* m_fullImage;
|
||||
/** Histogram area selection */
|
||||
HistogramWorker* m_selectionWorker;
|
||||
std::shared_ptr<CalypFrame> m_selectionImage;
|
||||
// CalypFrameStats* m_selectionHistogram;
|
||||
CalypFrame* m_selectionImage;
|
||||
|
||||
Q_SIGNALS:
|
||||
void signalintervalChanged( int min, int max );
|
||||
|
||||
@@ -86,7 +86,6 @@ IF(NOT FFMPEG_LIBRARIES)
|
||||
FIND_COMPONENT(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
|
||||
FIND_COMPONENT(AVUTIL libavutil avutil libavutil/avutil.h)
|
||||
FIND_COMPONENT(SWSCALE libswscale swscale libswscale/swscale.h)
|
||||
FIND_COMPONENT(SWRESAMPLE libswresample swresample libswresample/swresample.h)
|
||||
FIND_COMPONENT(POSTPROC libpostproc postproc libpostproc/postprocess.h)
|
||||
|
||||
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
|
||||
|
||||
@@ -4,7 +4,7 @@ MACRO(ADD_MODULE name file)
|
||||
OPTION(MODULE_${name} "Use module ${name}" ON)
|
||||
ADD_FEATURE_INFO(${name} MODULE_${name} "Module ${name}")
|
||||
IF(MODULE_${name})
|
||||
LIST(APPEND Calyp_Mod_SRCS ${MODULE_LOCATION}${file}.cpp)
|
||||
LIST(APPEND Calyp_Mod_SRCS ${MODULE_LOCATION}${file})
|
||||
LIST(APPEND MODULES_LIST_NAME ${name})
|
||||
LIST(APPEND MODULES_LIST_FILES ${file})
|
||||
SET(Calyp_Mod_SRCS
|
||||
|
||||
+5
-1
@@ -77,5 +77,9 @@ IF(USE_FFMPEG)
|
||||
"FFmpeg-Dir"
|
||||
CACHE PATH "Where to find FFmpeg Lib on Windows"
|
||||
)
|
||||
INSTALL(DIRECTORY ${FFMPEG_DIR}/bin/ DESTINATION bin)
|
||||
INSTALL(FILES ${FFMPEG_DIR}/bin/avcodec-${AVCODEC_VERSION}.dll DESTINATION bin)
|
||||
INSTALL(FILES ${FFMPEG_DIR}/bin/avformat-${AVFORMAT_VERSION}.dll DESTINATION bin)
|
||||
INSTALL(FILES ${FFMPEG_DIR}/bin/avutil-${AVUTIL_VERSION}.dll DESTINATION bin)
|
||||
INSTALL(FILES ${FFMPEG_DIR}/bin/swscale-${SWSCALE_VERSION}.dll DESTINATION bin)
|
||||
INSTALL(FILES ${FFMPEG_DIR}/bin/swresample-${SWRESAMPLE_VERSION}.dll DESTINATION bin)
|
||||
ENDIF()
|
||||
@@ -55,7 +55,4 @@
|
||||
/* Fervor update lib */
|
||||
#cmakedefine USE_FERVOR
|
||||
|
||||
/* Use a resource manager to manage streams in different threads */
|
||||
#cmakedefine CALYP_MANAGED_RESOURCES
|
||||
|
||||
#endif // __CONFIG_CALYP_H__
|
||||
@@ -3,4 +3,3 @@
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(modules)
|
||||
ADD_SUBDIRECTORY(stream)
|
||||
@@ -33,15 +33,15 @@ AbsoluteFrameDifferenceExample::AbsoluteFrameDifferenceExample()
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2; // Use API version 2 (recommended).
|
||||
// See this example for details on the functions prototype
|
||||
m_iModuleType = ClpModuleType::FrameProcessing; // Apply module to the frames or to the whole sequence.
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE; // Apply module to the frames or to the whole sequence.
|
||||
m_pchModuleCategory = "Measurements"; // Category (sub-menu)
|
||||
m_pchModuleName = "AbsoluteDifferenceExample"; // Name
|
||||
m_pchModuleLongName = "Absolute Difference Example"; // Name
|
||||
m_pchModuleTooltip = "Measure the absolute difference " // Description
|
||||
"between two images (Y plane), e. g., abs( Y1 - Y2 )";
|
||||
m_uiNumberOfFrames = 2; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
m_uiModuleRequirements = ClpModuleFeature::NewWindow; // Module requirements (check CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_uiNumberOfFrames = 2; // Number of Frames required (ONE_FRAME, TWO_FRAMES, THREE_FRAMES)
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW; // Module requirements (check CalypModulesIf.h).
|
||||
// Several requirements should be "or" between each others.
|
||||
m_pcFrameDifference = NULL;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ bool AbsoluteFrameDifferenceExample::create( std::vector<CalypFrame*> apcFrameLi
|
||||
return false;
|
||||
|
||||
m_pcFrameDifference =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), ClpPixelFormats::Gray );
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
#include "CalypModuleIf.h"
|
||||
|
||||
class AbsoluteFrameDifferenceExample : public CalypModuleIf, public CalypModuleInstance<AbsoluteFrameDifferenceExample>
|
||||
class AbsoluteFrameDifferenceExample : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( AbsoluteFrameDifferenceExample )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrameDifference;
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
# CMakeLists for modules_example
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
|
||||
|
||||
PROJECT("modules_example")
|
||||
|
||||
# THIS FIND_PACKAGE( Calyp ) INCLUDE_DIRECTORIES( ${CALYP_INCLUDE_DIRS} ) OR
|
||||
INCLUDE_DIRECTORIES(../../lib)
|
||||
|
||||
ADD_LIBRARY(FrameBinarizationAPIv1 SHARED FrameBinarizationAPIv1.cpp)
|
||||
TARGET_LINK_LIBRARIES(FrameBinarizationAPIv1 ${PROJECT_LIBRARY})
|
||||
ADD_LIBRARY(FrameBinarization SHARED FrameBinarization_APIv1.cpp)
|
||||
TARGET_LINK_LIBRARIES(FrameBinarization ${CALYP_LINKER_LIBS})
|
||||
|
||||
ADD_LIBRARY(AbsoluteFrameDifferenceExample SHARED AbsoluteFrameDifferenceExample.cpp)
|
||||
TARGET_LINK_LIBRARIES(AbsoluteFrameDifferenceExample ${PROJECT_LIBRARY})
|
||||
TARGET_LINK_LIBRARIES(AbsoluteFrameDifferenceExample ${PROJECT_LIBRARY} ${CALYP_LINKER_LIBS})
|
||||
+11
-11
@@ -18,24 +18,24 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FrameBinarizationAPIv1.cpp
|
||||
* \file FrameBinarization_APIv1.cpp
|
||||
* \brief Binarize frame module (example of APIv1)
|
||||
*/
|
||||
|
||||
#include "FrameBinarizationAPIv1.h"
|
||||
#include "FrameBinarization_APIv1.h"
|
||||
|
||||
REGISTER_CLASS_MAKER( FrameBinarizationAPIv1 )
|
||||
REGISTER_CLASS_MAKER( FrameBinarization_APIv1 )
|
||||
|
||||
FrameBinarizationAPIv1::FrameBinarizationAPIv1()
|
||||
FrameBinarization_APIv1::FrameBinarization_APIv1()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleType = ClpModuleType::FrameProcessing;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Utilities";
|
||||
m_pchModuleName = "FrameBinarizationAPIv1";
|
||||
m_pchModuleName = "FrameBinarization_APIv1";
|
||||
m_pchModuleLongName = "Frame Binarization API v1";
|
||||
m_pchModuleTooltip = "Binarize frame";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = ClpModuleFeature::Options;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_OPTIONS;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "threshold", m_uiThreshold, "Threshold level for binarization (0-255) [128]" );
|
||||
@@ -44,13 +44,13 @@ FrameBinarizationAPIv1::FrameBinarizationAPIv1()
|
||||
m_uiThreshold = 128;
|
||||
}
|
||||
|
||||
void FrameBinarizationAPIv1::create( CalypFrame* frame )
|
||||
void FrameBinarization_APIv1::create( CalypFrame* frame )
|
||||
{
|
||||
m_pcBinFrame = NULL;
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), ClpPixelFormats::Gray, 8 );
|
||||
m_pcBinFrame = new CalypFrame( frame->getWidth(), frame->getHeight(), CLP_GRAY, 8 );
|
||||
}
|
||||
|
||||
CalypFrame* FrameBinarizationAPIv1::process( CalypFrame* frame )
|
||||
CalypFrame* FrameBinarization_APIv1::process( CalypFrame* frame )
|
||||
{
|
||||
const ClpPel* pPelInput = frame->getPelBufferYUV()[0][0];
|
||||
ClpPel* pPelBin = m_pcBinFrame->getPelBufferYUV()[0][0];
|
||||
@@ -62,7 +62,7 @@ CalypFrame* FrameBinarizationAPIv1::process( CalypFrame* frame )
|
||||
return m_pcBinFrame;
|
||||
}
|
||||
|
||||
void FrameBinarizationAPIv1::destroy()
|
||||
void FrameBinarization_APIv1::destroy()
|
||||
{
|
||||
if( m_pcBinFrame )
|
||||
delete m_pcBinFrame;
|
||||
+9
-7
@@ -18,27 +18,29 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file FrameBinarizationAPIv1.h
|
||||
* \file FrameBinarization_APIv1.h
|
||||
* \brief Binarize frame module (example of APIv1)
|
||||
*/
|
||||
|
||||
#ifndef __FRAMEBINARIZATIONAPIV1_H__
|
||||
#define __FRAMEBINARIZATIONAPIV1_H__
|
||||
#ifndef __FRAMEBINARIZATION_APIV1_H__
|
||||
#define __FRAMEBINARIZATION_APIV1_H__
|
||||
|
||||
#include "CalypModuleIf.h"
|
||||
|
||||
class FrameBinarizationAPIv1 : public CalypModuleIf, public CalypModuleInstance<FrameBinarizationAPIv1>
|
||||
class FrameBinarization_APIv1 : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FrameBinarization_APIv1 )
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcBinFrame;
|
||||
unsigned int m_uiThreshold;
|
||||
|
||||
public:
|
||||
FrameBinarizationAPIv1();
|
||||
virtual ~FrameBinarizationAPIv1() {}
|
||||
FrameBinarization_APIv1();
|
||||
virtual ~FrameBinarization_APIv1() {}
|
||||
void create( CalypFrame* );
|
||||
CalypFrame* process( CalypFrame* );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __FRAMEBINARIZATIONAPIV1_H__
|
||||
#endif // __FRAMEBINARIZATION_APIV1_H__
|
||||
@@ -1,9 +0,0 @@
|
||||
#
|
||||
# CMakeLists for modules_example
|
||||
#
|
||||
INCLUDE_DIRECTORIES(../../lib)
|
||||
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
ADD_EXECUTABLE(testStreamReading testStreamReading.cpp)
|
||||
TARGET_LINK_LIBRARIES(testStreamReading ${PROJECT_LIBRARY})
|
||||
@@ -1,68 +0,0 @@
|
||||
/* 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 testStreamReading.cpp
|
||||
* \brief Example of open and reading from a stream
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
// Use auto keyword to avoid typing long
|
||||
// type definitions to get the timepoint
|
||||
// at this instant use function now()
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
double n = 0;
|
||||
CalypStream stream;
|
||||
stream.open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/Foreman.yuv" ), 352, 288, 0, 8, CLP_BIG_ENDIAN, 1, true );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
CalypFrame* frame = stream.getCurrFrame();
|
||||
frame->fillRGBBuffer();
|
||||
n++;
|
||||
if( stream.setNextFrame() )
|
||||
break;
|
||||
stream.readNextFrame();
|
||||
}
|
||||
|
||||
// After function call
|
||||
auto stop = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Subtract stop and start timepoints and
|
||||
// cast it to required unit. Predefined units
|
||||
// are nanoseconds, microseconds, milliseconds,
|
||||
// seconds, minutes, hours. Use duration_cast()
|
||||
// function.
|
||||
auto duration = std::chrono::duration_cast<std::chrono::microseconds>( stop - start );
|
||||
|
||||
// To get the value of duration use the count()
|
||||
// member function on the duration object
|
||||
std::cout << duration.count() / 1000.0 / n << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
+22
-43
@@ -3,12 +3,8 @@
|
||||
#
|
||||
|
||||
INCLUDE(GNUInstallDirs)
|
||||
SET(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
|
||||
EXPORT(PACKAGE MyLib)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp)
|
||||
|
||||
@@ -24,10 +20,19 @@ SET(Calyp_Lib_Stream_SRCS
|
||||
|
||||
SET(Calyp_Lib_OptionParser_SRCS CalypOptions.h CalypOptions.cpp)
|
||||
|
||||
SET(Calyp_Lib_Modules_SRCS CalypModuleIf.h CalypModuleIf.cpp)
|
||||
SET(Calyp_Lib_Modules_SRCS CalypOptions.h CalypOptions.cpp)
|
||||
|
||||
SET(Calyp_Lib_SRCS CalypLib.h CalypDefs.h ${Calyp_Lib_Frame_SRCS} ${Calyp_Lib_Stream_SRCS} ${Calyp_Lib_OptionParser_SRCS} ${Calyp_Lib_Modules_SRCS})
|
||||
SET(Calyp_Lib_SRCS
|
||||
LibMemory.h
|
||||
CalypLib.h
|
||||
CalypDefs.h
|
||||
${Calyp_Lib_Frame_SRCS}
|
||||
${Calyp_Lib_Stream_SRCS}
|
||||
${Calyp_Lib_OptionParser_SRCS}
|
||||
${Calyp_Lib_Modules_SRCS}
|
||||
)
|
||||
|
||||
LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${PROJECT_LIBRARY})
|
||||
LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
IF(USE_FFMPEG)
|
||||
@@ -36,40 +41,23 @@ IF(USE_FFMPEG)
|
||||
|
||||
LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${FFMPEG_LIBRARIES})
|
||||
LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS})
|
||||
|
||||
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS})
|
||||
|
||||
LIST(APPEND CALYP_LIB_LINKER_DEPENDENCIES ${FFMPEG_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
IF(USE_OPENCV)
|
||||
LIST(APPEND Calyp_Lib_SRCS StreamHandlerOpenCV.h)
|
||||
LIST(APPEND Calyp_Lib_SRCS StreamHandlerOpenCV.cpp)
|
||||
|
||||
LIST(APPEND Calyp_Lib_SRCS CalypOpenCVModuleIf.cpp)
|
||||
|
||||
LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${OpenCV_LIBRARIES})
|
||||
LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
LIST(APPEND CMAKE_CFG_LINKER_LIBSS ${PROJECT_LIBRARY})
|
||||
LIST(APPEND CMAKE_CFG_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
LIST(APPEND CALYP_LIB_LINKER_DEPENDENCIES ${OpenCV_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
SET(Calyp_Lib_HEADERS CalypFrame.h CalypStream.h CalypOptions.h CalypModuleIf.h)
|
||||
SET(Calyp_Lib_HEADERS CalypDefs.h CalypFrame.h CalypStream.h CalypOptions.h CalypModuleIf.h CalypOpenCVModuleIf.h)
|
||||
|
||||
INCLUDE(CMakePackageConfigHelpers)
|
||||
CONFIGURE_FILE(CalypConfig.cmake.in CalypConfig.cmake @ONLY)
|
||||
|
||||
CONFIGURE_PACKAGE_CONFIG_FILE(CalypConfig.cmake.in CalypConfig.cmake INSTALL_DESTINATION share/calyp)
|
||||
|
||||
WRITE_BASIC_PACKAGE_VERSION_FILE(
|
||||
CalypConfigVersion.cmake
|
||||
VERSION ${CALYP_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
# CONFIGURE_FILE(CalypConfig.cmake.in CalypConfig.cmake @ONLY)
|
||||
INCLUDE_DIRECTORIES(${FFMPEG_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
IF(USE_STATIC)
|
||||
ADD_LIBRARY(${PROJECT_LIBRARY} STATIC ${Calyp_Lib_SRCS})
|
||||
@@ -77,32 +65,23 @@ ELSE()
|
||||
ADD_LIBRARY(${PROJECT_LIBRARY} SHARED ${Calyp_Lib_SRCS})
|
||||
ENDIF()
|
||||
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_LIBRARY} ${CALYP_LIB_LINKER_DEPENDENCIES})
|
||||
# TARGET_INCLUDE_DIRECTORIES(${PROJECT_LIBRARY} PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_LIBRARY} ${FFMPEG_LIBRARIES} ${OpenCV_LIBRARIES})
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(${PROJECT_LIBRARY} PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>)
|
||||
|
||||
SET_TARGET_PROPERTIES(${PROJECT_LIBRARY} PROPERTIES VERSION ${CALYP_VERSION} SOVERSION ${CALYP_VERSION_MAJOR})
|
||||
|
||||
IF(USE_IWYU)
|
||||
SET_PROPERTY(TARGET ${PROJECT_LIBRARY} PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
|
||||
ENDIF()
|
||||
|
||||
EXPORT(TARGETS ${PROJECT_LIBRARY} FILE ${CMAKE_CURRENT_BINARY_DIR}/CalypTargets.cmake)
|
||||
EXPORT(PACKAGE ${PROJECT_LIBRARY})
|
||||
|
||||
IF(NOT USE_STATIC)
|
||||
INSTALL(
|
||||
TARGETS ${PROJECT_LIBRARY}
|
||||
EXPORT "${PROJECT_LIBRARY}Targets"
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
INSTALL(FILES ${Calyp_Lib_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CalypConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CalypConfigVersion.cmake DESTINATION share/calyp)
|
||||
INSTALL(EXPORT CalypTargets DESTINATION share/calyp)
|
||||
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CalypConfig.cmake DESTINATION share/calyp)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ADD_SUBDIRECTORY(catch2)
|
||||
ENDIF()
|
||||
@@ -12,7 +12,7 @@
|
||||
#
|
||||
#
|
||||
# This file will define the following variables:
|
||||
# - CALYP_LIBRARIES : The list of all imported targets for OpenCV modules.
|
||||
# - CALYP_LINKER_LIBS : The list of all imported targets for OpenCV modules.
|
||||
# - CALYP_CXX_FLAGS
|
||||
# - CALYP_INCLUDE_DIRS : The Calyp include directories.
|
||||
# - CALYP_VERSION : The version of this Calyp build: "@CALYP_VERSION@"
|
||||
@@ -22,18 +22,15 @@
|
||||
#
|
||||
# ===================================================================================================================
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
# ======================================================
|
||||
# Variables:
|
||||
# ======================================================
|
||||
SET(CALYP_VERSION @CALYP_VERSION@)
|
||||
SET(CALYP_VERSION_MAJOR @CALYP_VERSION_MAJOR@)
|
||||
SET(CALYP_VERSION_MINOR @CALYP_VERSION_MINOR@)
|
||||
SET(CALYP_VERSION_PATCH @CALYP_VERSION_PATCH@)
|
||||
|
||||
FIND_LIBRARY(CALYP_LIBRARY NAMES Calyp HINTS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ )
|
||||
|
||||
SET( CALYP_CXX_FLAGS "" )
|
||||
SET( CALYP_LIBRARIES "${CALYP_LIBRARY}" )
|
||||
LIST( APPEND CALYP_LIBRARIES "@CALYP_LIB_LINKER_DEPENDENCIES@")
|
||||
set_and_check( CALYP_INCLUDE_DIRS "@CMAKE_CFG_INCLUDE_DIRS@" )
|
||||
|
||||
CHECK_REQUIRED_COMPONENTS(Calyp)
|
||||
SET( CALYP_INCLUDE_DIRS "@CMAKE_CFG_INCLUDE_DIRS@" )
|
||||
SET( CALYP_LINKER_LIBS "@CMAKE_CFG_LINKER_LIBSS@" )
|
||||
+82
-16
@@ -20,17 +20,22 @@
|
||||
/**
|
||||
* \file CalypDefs.h
|
||||
* \ingroup CalypLibGrp
|
||||
* \brief Define basic types, new types and enumerations (private use only)
|
||||
* \brief Define basic types, new types and enumerations
|
||||
*/
|
||||
|
||||
#ifndef __CALYPDEFS_H__
|
||||
#define __CALYPDEFS_H__
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
typedef unsigned short ClpPel; ///< 16-bit pixel type
|
||||
typedef unsigned char ClpByte;
|
||||
typedef unsigned long long ClpULong;
|
||||
|
||||
typedef std::string ClpString;
|
||||
|
||||
enum CLP_LOG_LEVEL
|
||||
{
|
||||
@@ -40,35 +45,96 @@ enum CLP_LOG_LEVEL
|
||||
CLP_LOG_ERROR = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum CalypColorSpace
|
||||
* \brief List of supported color spaces
|
||||
* \ingroup CalypLibGrp
|
||||
*/
|
||||
enum CalypColorSpace
|
||||
{
|
||||
CLP_COLOR_INVALID = -1, //!< Invalid
|
||||
CLP_COLOR_YUV = 0, //!< YUV
|
||||
CLP_COLOR_RGB = 1, //!< RGB
|
||||
CLP_COLOR_GRAY = 2, //!< Grayscale
|
||||
CLP_COLOR_RGBA = 3, //!< RGB + Alpha
|
||||
CLP_COLOR_MAX = 255, //!< Account for future formats
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum CalypPixelFormats
|
||||
* \brief List of supported pixel formats
|
||||
* \ingroup CalypLibGrp
|
||||
*/
|
||||
enum CalypPixelFormats
|
||||
{
|
||||
CLP_INVALID_FMT = -1, //!< Invalid
|
||||
CLP_YUV420P = 0, //!< YUV 420 progressive
|
||||
CLP_YUV422P, //!< YUV 422 progressive
|
||||
CLP_YUV444P, //!< YUV 444 progressive
|
||||
CLP_YUYV422, //!< YUV 422 interleaved
|
||||
CLP_GRAY, //!< Grayscale
|
||||
CLP_RGB24P, //!< RGB 32 bpp progressive
|
||||
CLP_RGB24, //!< RGB 32 bpp
|
||||
CLP_BGR24, //!< BGR 32 bpp
|
||||
CLP_RGBA32, //!< RGBA 32 bpp
|
||||
CLP_BGRA32, //!< BGRA 32 bpp
|
||||
CLP_MAX_FMT = 255, //!< Account for future formats
|
||||
};
|
||||
|
||||
enum CLP_YUV_Components
|
||||
{
|
||||
CLP_LUMA = 0,
|
||||
CLP_CHROMA_U,
|
||||
CLP_CHROMA_V,
|
||||
};
|
||||
|
||||
enum CLP_RGB_Components
|
||||
{
|
||||
CLP_COLOR_R = 0,
|
||||
CLP_COLOR_G,
|
||||
CLP_COLOR_B,
|
||||
CLP_COLOR_A,
|
||||
};
|
||||
|
||||
enum CLP_Endianness
|
||||
{
|
||||
CLP_BIG_ENDIAN = 0,
|
||||
CLP_LITTLE_ENDIAN = 1,
|
||||
};
|
||||
|
||||
static const double S_PI = 3.14159265358979323846;
|
||||
static const double S_PI_2 = 1.57079632679489661923;
|
||||
|
||||
inline std::string clpLowercase( const std::string& in )
|
||||
inline ClpString clpLowercase( const ClpString& in )
|
||||
{
|
||||
std::string out;
|
||||
std::transform( in.begin(), in.end(), std::back_inserter( out ), tolower );
|
||||
ClpString out;
|
||||
transform( in.begin(), in.end(), std::back_inserter( out ), tolower );
|
||||
return out;
|
||||
}
|
||||
|
||||
inline std::string clpUppercase( const std::string& in )
|
||||
inline ClpString clpUppercase( const ClpString& in )
|
||||
{
|
||||
std::string out;
|
||||
std::transform( in.begin(), in.end(), std::back_inserter( out ), toupper );
|
||||
ClpString out;
|
||||
transform( in.begin(), in.end(), std::back_inserter( out ), toupper );
|
||||
return out;
|
||||
}
|
||||
|
||||
struct CalypFailure : public std::exception
|
||||
{
|
||||
CalypFailure( std::string error_msg ) throw() : m_error_msg{ std::move( error_msg ) } {}
|
||||
CalypFailure( std::string class_name, std::string error_msg ) throw()
|
||||
: m_error_msg{ std::format( "[%s] %s", class_name, error_msg ) }
|
||||
ClpString m_class_name;
|
||||
ClpString m_error_msg;
|
||||
CalypFailure( ClpString error_msg ) throw()
|
||||
: m_error_msg( error_msg ) {}
|
||||
CalypFailure( ClpString class_name, ClpString error_msg ) throw()
|
||||
: m_class_name( class_name ), m_error_msg( error_msg )
|
||||
{
|
||||
}
|
||||
~CalypFailure() throw() {}
|
||||
auto what() const throw() -> const char* { return m_error_msg.c_str(); }
|
||||
|
||||
private:
|
||||
std::string m_error_msg;
|
||||
const char* what() const throw()
|
||||
{
|
||||
ClpString* msg = new ClpString( "[" + m_class_name + "] " + m_error_msg );
|
||||
return msg->c_str();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __CALYPDEFS_H__
|
||||
+590
-655
File diff suppressed because it is too large.
Load diff
+219
-372
@@ -26,85 +26,15 @@
|
||||
#ifndef __CALYPFRAME_H__
|
||||
#define __CALYPFRAME_H__
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "CalypDefs.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
class Mat;
|
||||
} // namespace cv
|
||||
|
||||
using ClpPel = std::uint16_t;
|
||||
using ClpByte = std::uint8_t;
|
||||
|
||||
/**
|
||||
* \enum CalypColorSpace
|
||||
* \brief List of supported color spaces
|
||||
* \ingroup CalypLibGrp
|
||||
*/
|
||||
enum CalypColorSpace
|
||||
{
|
||||
CLP_COLOR_INVALID = -1, //!< Invalid
|
||||
CLP_COLOR_YUV = 0, //!< YUV
|
||||
CLP_COLOR_RGB = 1, //!< RGB
|
||||
CLP_COLOR_GRAY = 2, //!< Grayscale
|
||||
CLP_COLOR_RGBA = 3, //!< RGB + Alpha
|
||||
CLP_COLOR_MAX = 255, //!< Account for future formats
|
||||
};
|
||||
|
||||
/**
|
||||
* \enum ClpPixelFormats
|
||||
* \brief List of supported pixel formats
|
||||
* \ingroup CalypLibGrp
|
||||
*/
|
||||
enum class ClpPixelFormats : int
|
||||
{
|
||||
Invalid = -1, //!< Invalid
|
||||
YUV420p = 0, //!< YUV 420 progressive
|
||||
YUV422p, //!< YUV 422 progressive
|
||||
YUV444p, //!< YUV 444 progressive
|
||||
YUYV422, //!< YUV 422 interleaved
|
||||
Gray, //!< Grayscale
|
||||
RGB24p, //!< RGB 32 bpp progressive
|
||||
RGB24, //!< RGB 32 bpp
|
||||
BGR24, //!< BGR 32 bpp
|
||||
RGBA32, //!< RGBA 32 bpp
|
||||
BGRA32, //!< BGRA 32 bpp
|
||||
};
|
||||
|
||||
enum CLP_YUV_Components
|
||||
{
|
||||
CLP_LUMA = 0,
|
||||
CLP_CHROMA_U,
|
||||
CLP_CHROMA_V,
|
||||
};
|
||||
|
||||
enum CLP_RGB_Components
|
||||
{
|
||||
CLP_COLOR_R = 0,
|
||||
CLP_COLOR_G,
|
||||
CLP_COLOR_B,
|
||||
CLP_COLOR_A,
|
||||
};
|
||||
|
||||
enum CLP_Endianness
|
||||
{
|
||||
CLP_INVALID_ENDIANESS = -1,
|
||||
CLP_BIG_ENDIAN = 0,
|
||||
CLP_LITTLE_ENDIAN = 1,
|
||||
};
|
||||
|
||||
constexpr auto CHROMASHIFT( unsigned int size, unsigned int shift ) -> unsigned int
|
||||
{
|
||||
return -( ( -( static_cast<int>( size ) ) ) >> ( shift ) ); // NOLINT
|
||||
}
|
||||
|
||||
#define CHROMASHIFT( SIZE, SHIFT ) (unsigned int)( -( ( -( (int)( SIZE ) ) ) >> ( SHIFT ) ) )
|
||||
|
||||
/**
|
||||
* \class CalypPixel
|
||||
* \ingroup CalypLibGrp CalypFrameGrp
|
||||
@@ -112,95 +42,38 @@ constexpr auto CHROMASHIFT( unsigned int size, unsigned int shift ) -> unsigned
|
||||
*/
|
||||
class CalypPixel
|
||||
{
|
||||
private:
|
||||
static constexpr std::size_t kMaxNumberOfComponents{ 4 };
|
||||
int m_colorSpace{ CLP_COLOR_INVALID };
|
||||
std::array<ClpPel, kMaxNumberOfComponents> m_pelComp{ 0, 0, 0, 0 };
|
||||
|
||||
public:
|
||||
static constexpr std::size_t getMaxNumberOfComponents() { return kMaxNumberOfComponents; }
|
||||
static int getMaxNumberOfComponents();
|
||||
|
||||
CalypPixel() = default;
|
||||
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;
|
||||
auto operator=( CalypPixel&& other ) noexcept -> CalypPixel& = default;
|
||||
~CalypPixel() = default;
|
||||
CalypPixel( const int& CalypColorSpace = CLP_COLOR_INVALID );
|
||||
CalypPixel( const int& CalypColorSpace, const ClpPel& c0 );
|
||||
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 );
|
||||
CalypPixel( const CalypPixel& other );
|
||||
~CalypPixel();
|
||||
|
||||
int colorSpace() const { return m_colorSpace; };
|
||||
int colorSpace() const;
|
||||
|
||||
auto components() const -> const std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
auto components() -> std::array<ClpPel, kMaxNumberOfComponents>& { return m_pelComp; };
|
||||
ClpPel operator[]( const int& channel ) const;
|
||||
ClpPel& operator[]( const int& 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]; }
|
||||
|
||||
auto operator+=( const CalypPixel& ) -> CalypPixel&;
|
||||
auto operator-=( const CalypPixel& ) -> CalypPixel&;
|
||||
auto operator*=( double ) -> CalypPixel&;
|
||||
|
||||
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 auto operator<<( std::ostream& os, const CalypPixel& p ) -> std::ostream&;
|
||||
CalypPixel operator=( const CalypPixel& );
|
||||
CalypPixel operator+( const CalypPixel& );
|
||||
CalypPixel operator+=( const CalypPixel& );
|
||||
CalypPixel operator-( const CalypPixel& );
|
||||
CalypPixel operator-=( const CalypPixel& );
|
||||
CalypPixel operator*( const double& );
|
||||
|
||||
/**
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
auto convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel;
|
||||
};
|
||||
|
||||
auto operator<<( std::ostream& stream, const CalypPixel& pixel ) -> std::ostream&;
|
||||
|
||||
/**
|
||||
* \class CalypPlane
|
||||
* \ingroup CalypLibGrp CalypPlaneGrp
|
||||
* \brief Frame handling class
|
||||
*/
|
||||
template <typename T>
|
||||
class CalypPlane
|
||||
{
|
||||
public:
|
||||
CalypPlane() noexcept = default;
|
||||
CalypPlane( std::size_t width, std::size_t height ) noexcept { resize( width, height ); }
|
||||
|
||||
~CalypPlane() noexcept = default;
|
||||
CalypPlane( const CalypPlane& buffer ) noexcept = default;
|
||||
CalypPlane( CalypPlane&& buffer ) noexcept = default;
|
||||
auto operator=( const CalypPlane& buffer ) -> CalypPlane& = default;
|
||||
auto operator=( CalypPlane&& buffer ) noexcept -> CalypPlane& = default;
|
||||
|
||||
auto operator[]( std::size_t row ) const& noexcept -> const std::span<T>& { return m_rows[row]; }
|
||||
auto operator[]( std::size_t row ) & noexcept -> std::span<T>& { return m_rows[row]; }
|
||||
|
||||
auto operator[]( std::size_t row ) const&& noexcept { return m_rows[row]; }
|
||||
auto operator[]( std::size_t row ) && noexcept { return m_rows[row]; }
|
||||
|
||||
auto data() noexcept { return std::span<T>( m_data ); }
|
||||
auto data() const noexcept { return std::span<const T>( m_data ); }
|
||||
|
||||
void resize( std::size_t width, std::size_t height ) noexcept
|
||||
{
|
||||
m_data.resize( width * height );
|
||||
m_rows.resize( height );
|
||||
for( std::size_t y = 0; y < height; y++ )
|
||||
{
|
||||
m_rows[y] = std::span<T>( m_data ).subspan( y * width, width );
|
||||
}
|
||||
}
|
||||
* Convert a Pixel to a new color space
|
||||
* @param inputPixel input pixel (CalypPixel)
|
||||
* @param eOutputSpace output color space
|
||||
* @return converted pixel
|
||||
*/
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace );
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
std::vector<std::span<T>> m_rows;
|
||||
struct CalypPixelPrivate* d;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -212,24 +85,33 @@ class CalypFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedColorSpacesListNames();
|
||||
* Function that handles the supported color space
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<ClpString> supportedColorSpacesListNames();
|
||||
|
||||
/**
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static constexpr auto numberOfFormats() -> std::size_t;
|
||||
static auto findPixelFormat( const std::string& 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 ) -> std::string_view;
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<ClpString> supportedPixelFormatListNames();
|
||||
static std::vector<ClpString> supportedPixelFormatListNames( int colorSpace );
|
||||
static int numberOfFormats();
|
||||
static int findPixelFormat( const ClpString& name );
|
||||
static int pelformatColorSpace( const int idx );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
@@ -240,66 +122,34 @@ 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 = 8 );
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values );
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
* @param width width of the frame
|
||||
* @param height height of the frame
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
* @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 hasNegativeValues );
|
||||
|
||||
/**
|
||||
* Move contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( CalypFrame&& other ) noexcept = default;
|
||||
|
||||
/**
|
||||
* Move assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
auto operator=( CalypFrame&& other ) noexcept -> CalypFrame& = default;
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other );
|
||||
CalypFrame( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Copy-assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
auto operator=( const CalypFrame& other ) -> CalypFrame&;
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
* its contents. This function only copies a specific region from the existing
|
||||
* frame
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
* @param posX position X to crop from
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
* its contents. This function only copies a specific region from the existing
|
||||
* frame
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
* @param posX position X to crop from
|
||||
* @param posY position Y to crop from
|
||||
* @param areaWidth crop width
|
||||
* @param areaHeight crop height
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
CalypFrame( const CalypFrame* other, unsigned int x, unsigned int y, unsigned int width, unsigned int height );
|
||||
|
||||
~CalypFrame();
|
||||
|
||||
/** Format match opts
|
||||
*/
|
||||
*/
|
||||
enum FormatMatching
|
||||
{
|
||||
MATCH_COLOR_SPACE = 1,
|
||||
@@ -312,198 +162,196 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @param match matching conditions (use enum FormatMatching)
|
||||
* @return true if format matches
|
||||
*/
|
||||
auto haveSameFmt( const CalypFrame& other, unsigned int match = MATCH_ALL ) const -> bool;
|
||||
auto haveSameFmt( const CalypFrame* other, unsigned int match = MATCH_ALL ) const -> bool;
|
||||
* Check if two CalypFrames have the same fmt
|
||||
* @param other frame to compare with
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
auto getPelFormat() const -> ClpPixelFormats;
|
||||
* Get pixel format information
|
||||
* @return pixel format index
|
||||
*/
|
||||
int getPelFormat() const;
|
||||
|
||||
/**
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
auto getPelFmtName() const -> std::string;
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
ClpString getPelFmtName();
|
||||
|
||||
/**
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
auto getColorSpace() const -> int;
|
||||
* Get color space information
|
||||
* @return get color space index
|
||||
*/
|
||||
int getColorSpace() const;
|
||||
|
||||
/**
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
auto getNumberChannels() const -> unsigned;
|
||||
* Get the number of channels
|
||||
* @return number of channels
|
||||
*/
|
||||
unsigned getNumberChannels() const;
|
||||
|
||||
/**
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
auto getWidth( unsigned channel = 0 ) const -> unsigned int;
|
||||
* Get width of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getWidth( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get height of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
auto getHeight( 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;
|
||||
|
||||
/**
|
||||
* Check if frame has negative values
|
||||
* @return Boolean with the flag value
|
||||
*/
|
||||
auto getHasNegativeValues() const -> bool;
|
||||
bool getHasNegativeValues() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
auto getPixels( unsigned channel = 0 ) const -> std::uint64_t;
|
||||
* Get number of pixels of the frame
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
ClpULong getPixels( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get the total number of pixels of the frame
|
||||
* @return number of pixels
|
||||
*/
|
||||
auto getTotalNumberOfPixels() const -> std::uint64_t;
|
||||
ClpULong getTotalNumberOfPixels() const;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
auto getChromaWidthRatio() const -> unsigned;
|
||||
* Get chroma width ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaWidthRatio() const;
|
||||
|
||||
/**
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
auto getChromaHeightRatio() const -> unsigned;
|
||||
* Get chroma height ratio
|
||||
* @return ratio multiple of 2
|
||||
*/
|
||||
unsigned getChromaHeightRatio() const;
|
||||
|
||||
/**
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
auto getChromaLength() const -> std::uint64_t;
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
ClpULong getChromaLength() const;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
auto getBitsPel() const -> unsigned int;
|
||||
* Get number of bits per pixel
|
||||
* @return number of bits
|
||||
*/
|
||||
unsigned int getBitsPel() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
auto getBytesPerFrame() const -> std::uint64_t;
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
ClpULong getBytesPerFrame() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static auto getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, ClpPixelFormats pelFormat,
|
||||
unsigned int bitsPixel ) -> std::uint64_t;
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static ClpULong getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
* Reset frame pixels to zero
|
||||
*/
|
||||
void reset();
|
||||
|
||||
auto getPelBufferYUV() const -> ClpPel***;
|
||||
auto getPelBufferYUV() -> ClpPel***;
|
||||
ClpPel*** getPelBufferYUV() const;
|
||||
ClpPel*** getPelBufferYUV();
|
||||
|
||||
auto getRGBBuffer() const -> std::optional<std::span<const std::uint8_t>>;
|
||||
unsigned char* getRGBBuffer() const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param ch frame channel
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param absolute whether it should return positive/negative values
|
||||
* @return pixel value
|
||||
*/
|
||||
auto operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const -> ClpPel;
|
||||
* @return pixel value
|
||||
*/
|
||||
ClpPel operator()( unsigned int ch, unsigned int xPos, unsigned int yPos, bool absolute = true ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
auto operator()( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel operator()( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
auto getPixel( unsigned int xPos, unsigned int yPos ) const -> CalypPixel;
|
||||
* Get pixel value at coordinates
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos ) const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
auto getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace ) const -> CalypPixel;
|
||||
* Get pixel value at coordinates
|
||||
* in the desired color space
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
* @param eColorSpace desired color space
|
||||
* @return pixel value
|
||||
*/
|
||||
CalypPixel getPixel( unsigned int xPos, unsigned int yPos, CalypColorSpace eColorSpace );
|
||||
|
||||
/**
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
* Set pixel value at coordinates to a given value
|
||||
* @param xPos position in X axis
|
||||
* @param yPos position in Y axis
|
||||
*/
|
||||
void setPixel( unsigned int xPos, unsigned int yPos, CalypPixel pixel );
|
||||
|
||||
/**
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
* Copy a frame into the current buffer
|
||||
* @param other frame to be copied
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other );
|
||||
void copyFrom( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
* Copy a region from a reference corresponding to the size
|
||||
* of the size of the current frame
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the reference frame
|
||||
* @param y y position on the reference frame
|
||||
*/
|
||||
void copyFrom( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyFrom( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
/**
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y ) const;
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y ) const;
|
||||
* Copy a reference frame to a specific location on the current frame
|
||||
* The whole reference frame is copied
|
||||
* @param other frame to be copied
|
||||
* @param x x position on the current frame
|
||||
* @param y y position on the current frame
|
||||
*/
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
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 frameFromBuffer( ClpByte*, int, unsigned long );
|
||||
void frameFromBuffer( ClpByte*, int );
|
||||
void frameToBuffer( ClpByte*, int );
|
||||
|
||||
void fillRGBBuffer( std::optional<std::size_t> channel ) const;
|
||||
void fillRGBBuffer() const;
|
||||
void fillRGBBuffer();
|
||||
|
||||
/**
|
||||
* Histogram
|
||||
*/
|
||||
* Histogram
|
||||
*/
|
||||
enum HistogramChannels
|
||||
{
|
||||
HIST_CHAN_ONE = 0,
|
||||
@@ -522,32 +370,32 @@ public:
|
||||
};
|
||||
void calcHistogram();
|
||||
|
||||
auto getMinimumPelValue( unsigned channel ) const -> unsigned int;
|
||||
auto getMaximumPelValue( unsigned channel ) const -> unsigned int;
|
||||
unsigned int getMinimumPelValue( unsigned channel );
|
||||
unsigned int getMaximumPelValue( unsigned channel );
|
||||
|
||||
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;
|
||||
unsigned int getMaximum( unsigned channel );
|
||||
unsigned int getNumPixelsRange( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getMean( unsigned channel, unsigned int start, unsigned int end );
|
||||
int getMedian( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getStdDev( unsigned channel, unsigned int start, unsigned int end );
|
||||
double getHistogramValue( unsigned channel, unsigned int bin );
|
||||
unsigned int getNEBins( unsigned channel );
|
||||
int getNumHistogramSegment();
|
||||
double getEntropy( unsigned channel, unsigned int start, unsigned int end );
|
||||
|
||||
/**
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
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;
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 );
|
||||
bool fromMat( cv::Mat& cvMat, int iChannel = -1 );
|
||||
|
||||
/**
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
* \ingroup CalypFrameGrp
|
||||
* @defgroup CalypFrameQualityMetricsGrp Calyp Frame Quality Metrics interface
|
||||
* @{
|
||||
* Quality metrics interface
|
||||
*
|
||||
*/
|
||||
|
||||
enum QualityMetrics
|
||||
{
|
||||
@@ -559,18 +407,17 @@ public:
|
||||
NUMBER_METRICS,
|
||||
};
|
||||
|
||||
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;
|
||||
static std::vector<ClpString> supportedQualityMetricsList();
|
||||
static std::vector<ClpString> 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 );
|
||||
/** @} */
|
||||
|
||||
private:
|
||||
struct CalypFramePrivate;
|
||||
std::unique_ptr<CalypFramePrivate> m_d;
|
||||
struct CalypFramePrivate* d;
|
||||
};
|
||||
|
||||
#endif // __CALYPFRAME_H__
|
||||
+54
-93
@@ -34,12 +34,15 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypOptions.h"
|
||||
|
||||
#define REGISTER_CLASS_MAKER( X ) \
|
||||
extern "C" CalypModuleIf* Maker() { return new X; }
|
||||
#define REGISTER_CLASS_FACTORY( X ) \
|
||||
public: \
|
||||
static CalypModuleIf* Create() { return new X(); } \
|
||||
void Delete() { delete this; }
|
||||
#define _BASIC_MODULE_API_2_CHECK_ \
|
||||
if( apcFrameList.size() != m_uiNumberOfFrames ) \
|
||||
return false; \
|
||||
@@ -59,9 +62,8 @@
|
||||
*/
|
||||
enum Module_API_Version
|
||||
{
|
||||
CLP_MODULE_API_INVALID = -1,
|
||||
CLP_MODULE_API_1 = 0,
|
||||
CLP_MODULE_API_2 = 1,
|
||||
CLP_MODULE_API_1,
|
||||
CLP_MODULE_API_2,
|
||||
CLP_MODULE_API_3,
|
||||
};
|
||||
|
||||
@@ -70,11 +72,11 @@ enum Module_API_Version
|
||||
* Type of module
|
||||
* @see m_iModuleType
|
||||
*/
|
||||
enum class ClpModuleType : std::uint8_t
|
||||
enum Module_Type
|
||||
{
|
||||
Invalid,
|
||||
FrameProcessing,
|
||||
FrameMeasurement,
|
||||
CLP_FRAME_PROCESSING_MODULE,
|
||||
CLP_FRAME_MEASUREMENT_MODULE,
|
||||
CLP_MODULE_TYPE_MAX = 255,
|
||||
};
|
||||
|
||||
/** Module_Features Enum
|
||||
@@ -82,19 +84,18 @@ enum class ClpModuleType : std::uint8_t
|
||||
* Features/Requirements of a module
|
||||
* @see m_uiModuleRequirements
|
||||
*/
|
||||
enum class ClpModuleFeature : std::uint64_t
|
||||
enum Module_Features
|
||||
{
|
||||
None = 0,
|
||||
SkipWhilePlaying = 1,
|
||||
Options = 2,
|
||||
NewWindow = 4,
|
||||
KeysShortcuts = 8,
|
||||
VariableNumOfFrames = 16,
|
||||
HasInfo = 32,
|
||||
CLP_MODULE_REQUIRES_NOTHING = 0,
|
||||
CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY = 1,
|
||||
CLP_MODULE_REQUIRES_OPTIONS = 2,
|
||||
CLP_MODULE_REQUIRES_NEW_WINDOW = 4,
|
||||
CLP_MODULE_USES_KEYS = 8,
|
||||
CLP_MODULES_VARIABLE_NUM_FRAMES = 16,
|
||||
CLP_MODULES_HAS_INFO = 32,
|
||||
CLP_MODULE_REQURES_MAX = 1024,
|
||||
};
|
||||
|
||||
auto operator|( ClpModuleFeature lhs, ClpModuleFeature rhs ) -> ClpModuleFeature;
|
||||
|
||||
enum Module_Key_Supported
|
||||
{
|
||||
MODULE_KEY_LEFT,
|
||||
@@ -103,8 +104,6 @@ enum Module_Key_Supported
|
||||
MODULE_KEY_DOWN,
|
||||
};
|
||||
|
||||
class CalypFrame;
|
||||
|
||||
/**
|
||||
* \class CalypModuleIf
|
||||
* \ingroup CalypLib Calyp_Modules
|
||||
@@ -113,17 +112,39 @@ class CalypFrame;
|
||||
class CalypModuleIf
|
||||
{
|
||||
public:
|
||||
CalypModuleIf() = default;
|
||||
CalypModuleIf( const CalypModuleIf& buffer ) noexcept = delete;
|
||||
CalypModuleIf( CalypModuleIf&& buffer ) noexcept = delete;
|
||||
auto operator=( const CalypModuleIf& buffer ) -> CalypModuleIf& = delete;
|
||||
auto operator=( CalypModuleIf&& buffer ) noexcept -> CalypModuleIf& = delete;
|
||||
int m_iModuleAPI;
|
||||
int m_iModuleType;
|
||||
const char* m_pchModuleCategory;
|
||||
const char* m_pchModuleName;
|
||||
const char* m_pchModuleTooltip;
|
||||
const char* m_pchModuleLongName;
|
||||
|
||||
virtual ~CalypModuleIf() = default;
|
||||
virtual void destroy(){};
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames;
|
||||
//! Features/Requirements
|
||||
unsigned int m_uiModuleRequirements;
|
||||
|
||||
auto getModuleLongName() -> const char*;
|
||||
auto has( ClpModuleFeature feature ) -> bool;
|
||||
unsigned int m_iFrameBufferCount;
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
|
||||
CalypModuleIf()
|
||||
{
|
||||
m_iModuleAPI = CLP_MODULE_API_1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_pchModuleLongName = NULL;
|
||||
m_pcOutputFrame = NULL;
|
||||
m_iFrameBufferCount = 0;
|
||||
}
|
||||
virtual ~CalypModuleIf() {}
|
||||
virtual void Delete() = 0;
|
||||
virtual void destroy() = 0;
|
||||
|
||||
const char* getModuleLongName()
|
||||
{
|
||||
return m_pchModuleLongName ? m_pchModuleLongName : m_pchModuleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module API version 1
|
||||
@@ -138,77 +159,17 @@ public:
|
||||
virtual CalypFrame* process( std::vector<CalypFrame*> ) { return NULL; }
|
||||
virtual double measure( std::vector<CalypFrame*> ) { return 0; }
|
||||
virtual bool keyPressed( enum Module_Key_Supported ) { return false; }
|
||||
virtual std::string moduleInfo() { return std::string(); }
|
||||
virtual ClpString moduleInfo() { return ClpString(); }
|
||||
/**
|
||||
* Module API version 3
|
||||
*/
|
||||
virtual CalypFrame* getProcessedFrame() { return nullptr; }
|
||||
virtual CalypFrame* getProcessedFrame() { return m_pcOutputFrame; }
|
||||
virtual bool needFrame() { return m_iFrameBufferCount == 0 ? true : false; };
|
||||
virtual bool flush()
|
||||
{
|
||||
m_iFrameBufferCount = 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
public:
|
||||
int m_iModuleAPI{ CLP_MODULE_API_1 };
|
||||
ClpModuleType m_iModuleType{ ClpModuleType::Invalid };
|
||||
const char* m_pchModuleCategory{ "" };
|
||||
const char* m_pchModuleName{ "" };
|
||||
const char* m_pchModuleTooltip{ "" };
|
||||
const char* m_pchModuleLongName{ nullptr };
|
||||
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames{ 1 };
|
||||
//! Features/Requirements
|
||||
ClpModuleFeature m_uiModuleRequirements{ ClpModuleFeature::None };
|
||||
|
||||
unsigned int m_iFrameBufferCount{ 0 };
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
};
|
||||
|
||||
namespace cv
|
||||
{
|
||||
class Mat;
|
||||
}
|
||||
|
||||
/**
|
||||
* \class CalypOpenCVModuleIf
|
||||
* \ingroup CalypLib Calyp_Modules
|
||||
* \brief Abstract class for modules using OpenCV library
|
||||
*/
|
||||
class CalypOpenCVModuleIf : public CalypModuleIf
|
||||
{
|
||||
using Mat = cv::Mat;
|
||||
|
||||
public:
|
||||
CalypOpenCVModuleIf() = default;
|
||||
virtual ~CalypOpenCVModuleIf() {}
|
||||
|
||||
// Common API
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
|
||||
// API using OpenCV
|
||||
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(){};
|
||||
|
||||
protected:
|
||||
// const char* m_pchPythonFunctionName;
|
||||
std::unique_ptr<CalypFrame> m_pcOutputFrame;
|
||||
bool m_bConvertToGray{ false };
|
||||
};
|
||||
|
||||
using CalypModulePtr = std::unique_ptr<CalypModuleIf>;
|
||||
|
||||
template <typename T>
|
||||
class CalypModuleInstance
|
||||
{
|
||||
public:
|
||||
static CalypModulePtr Create() { return std::make_unique<T>(); }
|
||||
};
|
||||
|
||||
#endif // __CALYPMODULESIF_H__
|
||||
@@ -22,84 +22,62 @@
|
||||
* \brief Calyp modules interface for OpenCV
|
||||
*/
|
||||
|
||||
#include "CalypModuleIf.h"
|
||||
#include "CalypOpenCVModuleIf.h"
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
// OpenCV
|
||||
#include <opencv2/opencv.hpp>
|
||||
#endif
|
||||
|
||||
using cv::Mat;
|
||||
|
||||
bool CalypOpenCVModuleIf::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
#ifdef USE_OPENCV
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
bool bRet = false;
|
||||
std::vector<Mat> acMatList( apcFrameList.size() );
|
||||
std::vector<Mat*> acMatList( apcFrameList.size() );
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
apcFrameList[i]->toMat( acMatList[i], m_bConvertToGray );
|
||||
acMatList[i] = new Mat;
|
||||
apcFrameList[i]->toMat( *acMatList[i], m_bConvertToGray );
|
||||
}
|
||||
Mat* outputMat = create_using_opencv( acMatList );
|
||||
if( outputMat )
|
||||
{
|
||||
auto pelFormat = m_bConvertToGray ? ClpPixelFormats::Gray : apcFrameList[0]->getPelFormat();
|
||||
m_pcOutputFrame = std::make_unique<CalypFrame>( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
unsigned pelFormat = m_bConvertToGray ? CalypFrame::findPixelFormat( "GRAY" ) : apcFrameList[0]->getPelFormat();
|
||||
m_pcOutputFrame = new CalypFrame( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
bRet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
delete acMatList[i];
|
||||
}
|
||||
return bRet;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
CalypFrame* CalypOpenCVModuleIf::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
#ifdef USE_OPENCV
|
||||
m_pcOutputFrame->reset();
|
||||
std::vector<Mat> acMatList( apcFrameList.size() );
|
||||
std::vector<Mat*> acMatList( apcFrameList.size() );
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
apcFrameList[i]->toMat( acMatList[i], m_bConvertToGray );
|
||||
acMatList[i] = new Mat;
|
||||
apcFrameList[i]->toMat( *acMatList[i], m_bConvertToGray );
|
||||
}
|
||||
Mat* cvOutput = process_using_opencv( acMatList );
|
||||
m_pcOutputFrame->fromMat( *cvOutput );
|
||||
return m_pcOutputFrame.get();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
delete acMatList[i];
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void CalypOpenCVModuleIf::destroy()
|
||||
{
|
||||
}
|
||||
|
||||
ClpModuleFeature operator|( ClpModuleFeature lhs, ClpModuleFeature rhs )
|
||||
{
|
||||
return static_cast<ClpModuleFeature>(
|
||||
static_cast<std::underlying_type_t<ClpModuleFeature>>( lhs ) |
|
||||
static_cast<std::underlying_type_t<ClpModuleFeature>>( rhs ) );
|
||||
}
|
||||
|
||||
ClpModuleFeature operator&( ClpModuleFeature lhs, ClpModuleFeature rhs )
|
||||
{
|
||||
return static_cast<ClpModuleFeature>(
|
||||
static_cast<std::underlying_type_t<ClpModuleFeature>>( lhs ) &
|
||||
static_cast<std::underlying_type_t<ClpModuleFeature>>( rhs ) );
|
||||
}
|
||||
|
||||
auto CalypModuleIf::getModuleLongName() -> const char*
|
||||
{
|
||||
return m_pchModuleLongName ? m_pchModuleLongName : m_pchModuleName;
|
||||
}
|
||||
|
||||
auto CalypModuleIf::has( ClpModuleFeature feature ) -> bool
|
||||
{
|
||||
return ( m_uiModuleRequirements & feature ) != ClpModuleFeature::None;
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 by Joao Carreira (jfmcarreira@gmail.com)
|
||||
* 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
|
||||
@@ -18,49 +18,48 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file ThreeSixtyDynamicDownsampling.h
|
||||
* \file CalypOpenCVModuleIf.h
|
||||
* \ingroup CalypLibGroup
|
||||
* \brief Calyp modules interface for OpenCV
|
||||
*/
|
||||
|
||||
#ifndef __ThreeSixtyDynamicDownsampling_H__
|
||||
#define __ThreeSixtyDynamicDownsampling_H__
|
||||
#ifndef __CALYPOPENCVMODULEIF_H__
|
||||
#define __CALYPOPENCVMODULEIF_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
#include "CalypModuleIf.h"
|
||||
|
||||
struct ClpFaceProperty
|
||||
namespace cv
|
||||
{
|
||||
unsigned id;
|
||||
unsigned x;
|
||||
unsigned y;
|
||||
int rot;
|
||||
unsigned ratio;
|
||||
};
|
||||
struct ClpVideoFPStruct
|
||||
{
|
||||
unsigned rows;
|
||||
unsigned cols;
|
||||
int numFaces;
|
||||
ClpFaceProperty faces[60];
|
||||
};
|
||||
class Mat;
|
||||
}
|
||||
|
||||
class ThreeSixtyDynamicDownsampling : public CalypModuleIf, public CalypModuleInstance<ThreeSixtyDynamicDownsampling>
|
||||
/**
|
||||
* \class CalypOpenCVModuleIf
|
||||
* \ingroup CalypLib Calyp_Modules
|
||||
* \brief Abstract class for modules using OpenCV library
|
||||
*/
|
||||
class CalypOpenCVModuleIf : public CalypModuleIf
|
||||
{
|
||||
private:
|
||||
std::string m_arrayInputDefinitionString;
|
||||
std::string m_arrayOutputDefinitionString;
|
||||
ClpVideoFPStruct m_cInputFPSStruct;
|
||||
ClpVideoFPStruct m_cOutputFPSStruct;
|
||||
unsigned m_uiFaceWidth;
|
||||
unsigned m_uiFaceHeight;
|
||||
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
protected:
|
||||
const char* m_pchPythonFunctionName;
|
||||
bool m_bConvertToGray;
|
||||
|
||||
public:
|
||||
ThreeSixtyDynamicDownsampling();
|
||||
virtual ~ThreeSixtyDynamicDownsampling() {}
|
||||
CalypOpenCVModuleIf()
|
||||
{
|
||||
m_bConvertToGray = false;
|
||||
};
|
||||
virtual ~CalypOpenCVModuleIf() {}
|
||||
|
||||
// Common API
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
|
||||
// API using OpenCV
|
||||
virtual cv::Mat* create_using_opencv( std::vector<cv::Mat*> apcFrameList ) { return NULL; };
|
||||
virtual cv::Mat* process_using_opencv( std::vector<cv::Mat*> apcFrameList ) = 0;
|
||||
virtual void destroy_using_opencv(){};
|
||||
};
|
||||
|
||||
#endif // __ThreeSixtyDynamicDownsampling_H__
|
||||
#endif // __CALYPOPENCVMODULEIF_H__
|
||||
+158
-152
@@ -38,54 +38,53 @@
|
||||
|
||||
#include "CalypOptions.h"
|
||||
|
||||
#include <functional>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include "config.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct ParseFailure : public std::exception
|
||||
{
|
||||
std::string arg;
|
||||
std::string val;
|
||||
ParseFailure( std::string arg0, std::string val0 ) throw()
|
||||
: arg{ std::move( arg0 ) }, val{ std::move( val0 ) } {}
|
||||
ParseFailure( ParseFailure&& other ) noexcept = delete;
|
||||
ParseFailure& operator=( ParseFailure&& other ) noexcept = delete;
|
||||
ParseFailure( const ParseFailure& other ) = delete;
|
||||
ParseFailure& operator=( const ParseFailure& other ) = delete;
|
||||
ClpString arg;
|
||||
ClpString val;
|
||||
ParseFailure( ClpString arg0, ClpString val0 ) throw()
|
||||
: arg( arg0 ), val( val0 ) {}
|
||||
~ParseFailure() throw() {}
|
||||
const char* what() const throw() override { return "Option Parse Failure"; }
|
||||
const char* what() const throw() { return "Option Parse Failure"; }
|
||||
};
|
||||
|
||||
/** Type specific option storage */
|
||||
class boolOption : public CalypOptions::OptionBase
|
||||
class boolOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
boolOption( const std::string& name, const std::string& desc )
|
||||
: CalypOptions::OptionBase( name, desc, "(1-0)" ) { is_binary = true; }
|
||||
void parse( const std::string& arg ) override { arg_count++; }
|
||||
boolOption( const ClpString& name, const ClpString& desc )
|
||||
: OptionBase( name, desc, "(1-0)" ) { is_binary = true; }
|
||||
void parse( const ClpString& arg ) { arg_count++; }
|
||||
};
|
||||
|
||||
/** Type specific option storage */
|
||||
template <typename T>
|
||||
class StandardOption : public CalypOptions::OptionBase
|
||||
class StandardOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
StandardOption( const std::string& name, T& storage, const std::string& desc, const std::string& def )
|
||||
: CalypOptions::OptionBase( name, desc, def ), opt_storage( storage ) {}
|
||||
StandardOption( const ClpString& name, T& storage, const ClpString& desc, const ClpString& def )
|
||||
: OptionBase( name, desc, def ), opt_storage( storage )
|
||||
{
|
||||
is_binary = false;
|
||||
}
|
||||
|
||||
void parse( const std::string& arg ) override;
|
||||
void parse( const ClpString& arg );
|
||||
T& opt_storage;
|
||||
std::vector<T> opt_storage_array;
|
||||
};
|
||||
|
||||
/* Generic parsing */
|
||||
template <typename T>
|
||||
inline void StandardOption<T>::parse( const std::string& arg )
|
||||
inline void StandardOption<T>::parse( const ClpString& arg )
|
||||
{
|
||||
if( !is_binary )
|
||||
{
|
||||
@@ -104,9 +103,9 @@ inline void StandardOption<T>::parse( const std::string& arg )
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void StandardOption<std::vector<unsigned int>>::parse( const std::string& arg )
|
||||
inline void StandardOption<std::vector<unsigned int>>::parse( const ClpString& arg )
|
||||
{
|
||||
unsigned int aux_opt_storage{ 0 };
|
||||
unsigned int aux_opt_storage;
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
arg_ss.exceptions( std::ios::failbit );
|
||||
try
|
||||
@@ -122,9 +121,9 @@ inline void StandardOption<std::vector<unsigned int>>::parse( const std::string&
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void StandardOption<std::vector<int>>::parse( const std::string& arg )
|
||||
inline void StandardOption<std::vector<int>>::parse( const ClpString& arg )
|
||||
{
|
||||
int aux_opt_storage{ 0 };
|
||||
int aux_opt_storage;
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
arg_ss.exceptions( std::ios::failbit );
|
||||
try
|
||||
@@ -141,7 +140,7 @@ inline void StandardOption<std::vector<int>>::parse( const std::string& arg )
|
||||
|
||||
/* string parsing is specialized */
|
||||
template <>
|
||||
inline void StandardOption<std::string>::parse( const std::string& arg )
|
||||
inline void StandardOption<ClpString>::parse( const ClpString& arg )
|
||||
{
|
||||
opt_storage = arg;
|
||||
arg_count++;
|
||||
@@ -149,33 +148,33 @@ inline void StandardOption<std::string>::parse( const std::string& arg )
|
||||
|
||||
/* string vector parsing is specialized */
|
||||
template <>
|
||||
inline void StandardOption<std::vector<std::string>>::parse( const std::string& arg )
|
||||
inline void StandardOption<std::vector<ClpString>>::parse( const ClpString& arg )
|
||||
{
|
||||
opt_storage.push_back( arg );
|
||||
arg_count++;
|
||||
}
|
||||
|
||||
/** Option class for argument handling using a user provided function */
|
||||
struct FunctionOption : public CalypOptions::OptionBase
|
||||
struct FunctionOption : public OptionBase
|
||||
{
|
||||
using OptFunc = std::function<void( CalypOptions&, const std::string& )>;
|
||||
|
||||
public:
|
||||
FunctionOption( const std::string& name, CalypOptions& parent, OptFunc func, const std::string& desc, const std::string& def )
|
||||
: CalypOptions::OptionBase( name, desc, def ), m_parent( parent ), m_func( func )
|
||||
typedef void( Func )( CalypOptions&, const ClpString& );
|
||||
|
||||
FunctionOption( const ClpString& name, CalypOptions& parent_, Func* func_, const ClpString& desc, const ClpString& def )
|
||||
: OptionBase( name, desc, def ), parent( parent_ ), func( func_ )
|
||||
{
|
||||
is_binary = false;
|
||||
}
|
||||
|
||||
void parse( const std::string& arg ) override
|
||||
void parse( const ClpString& arg )
|
||||
{
|
||||
m_func( m_parent, arg );
|
||||
func( parent, arg );
|
||||
arg_count++;
|
||||
}
|
||||
|
||||
private:
|
||||
CalypOptions& m_parent;
|
||||
OptFunc m_func;
|
||||
CalypOptions& parent;
|
||||
void ( *func )( CalypOptions&, const ClpString& );
|
||||
};
|
||||
|
||||
/* Helper method to initiate adding options to Options */
|
||||
@@ -186,15 +185,9 @@ private:
|
||||
* with default_val as the default value
|
||||
* with desc as an optional help description
|
||||
*/
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, const std::string& desc )
|
||||
CalypOptions& CalypOptions::operator()( const ClpString& name, const ClpString& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<boolOption>( name, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, const std::string& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<boolOption>( name, desc ) );
|
||||
addOption( new boolOption( name, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -204,99 +197,114 @@ CalypOptions& CalypOptions::addOption( const std::string& name, const std::strin
|
||||
* with desc as an optional help description
|
||||
*/
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, T& storage, const std::string& desc )
|
||||
CalypOptions& CalypOptions::operator()( const ClpString& name, T& storage, const ClpString& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc, std::string( "" ) ) );
|
||||
return *this;
|
||||
}
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, T& storage, const std::string& desc )
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc, std::string( "" ) ) );
|
||||
addOption( new StandardOption<T>( name, storage, desc, ClpString( "" ) ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::operator()( const std::string& name, T& storage, const std::string& desc, const std::string& defaults )
|
||||
CalypOptions& CalypOptions::operator()( const ClpString& name, T& storage, const ClpString& desc, const ClpString& defaults )
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc ) );
|
||||
addOption( new StandardOption<T>( name, storage, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& CalypOptions::addOption( const std::string& name, T& storage, const std::string& desc, const std::string& defaults )
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, bool& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, unsigned int& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, int& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, long& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, long long int& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, ClpString& storage, const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector<unsigned int>& storage,
|
||||
const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector<int>& storage,
|
||||
const ClpString& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const ClpString& name, std::vector<ClpString>& storage,
|
||||
const ClpString& desc );
|
||||
|
||||
CalypOptions::Option::Option()
|
||||
: opt( 0 ) {}
|
||||
|
||||
CalypOptions::Option::~Option()
|
||||
{
|
||||
addOptionInternal( std::make_unique<StandardOption<T>>( name, storage, desc ) );
|
||||
return *this;
|
||||
if( opt )
|
||||
delete opt;
|
||||
}
|
||||
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, bool& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, unsigned int& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, int& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, long& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, long long int& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, std::string& storage, const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, std::vector<unsigned int>& storage,
|
||||
const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, std::vector<int>& storage,
|
||||
const std::string& desc );
|
||||
template CalypOptions& CalypOptions::operator()( const std::string& name, std::vector<std::string>& storage,
|
||||
const std::string& desc );
|
||||
|
||||
CalypOptions::CalypOptions( std::string name )
|
||||
: m_cOptionGroupName{ std::move( name ) }
|
||||
CalypOptions::CalypOptions( const ClpString& name )
|
||||
{
|
||||
m_cOptionGroupName = name;
|
||||
m_bAllowUnkonw = true;
|
||||
}
|
||||
|
||||
CalypOptions::OptionBase* CalypOptions::operator[]( const std::string& optName )
|
||||
CalypOptions::~CalypOptions()
|
||||
{
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
||||
OptionBase* CalypOptions::operator[]( const ClpString& optName )
|
||||
{
|
||||
return getOption( optName );
|
||||
}
|
||||
|
||||
CalypOptions::OptionBase* CalypOptions::getOption( const std::string& optName )
|
||||
OptionBase* CalypOptions::getOption( const ClpString& optName )
|
||||
{
|
||||
std::map<std::string, std::list<Option*>>::iterator opt_it;
|
||||
CalypOptions::OptionMap::iterator opt_it;
|
||||
opt_it = opt_short_map.find( optName );
|
||||
if( opt_it != opt_short_map.end() )
|
||||
{
|
||||
auto opt_list = ( *opt_it ).second;
|
||||
for( auto& option : opt_list )
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
return option->base_opt.get();
|
||||
return ( *it )->opt;
|
||||
}
|
||||
}
|
||||
opt_it = opt_long_map.find( optName );
|
||||
if( opt_it != opt_long_map.end() )
|
||||
{
|
||||
auto opt_list = ( *opt_it ).second;
|
||||
for( auto& option : opt_list )
|
||||
OptionsList opt_list = ( *opt_it ).second;
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
return option->base_opt.get();
|
||||
return ( *it )->opt;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CalypOptions::hasOpt( const std::string& optName )
|
||||
bool CalypOptions::hasOpt( const ClpString& optName )
|
||||
{
|
||||
OptionBase* opt = getOption( optName );
|
||||
return opt ? opt->count() > 0 ? true : false : false;
|
||||
}
|
||||
|
||||
void CalypOptions::addDefaultOptions()
|
||||
{
|
||||
addOptions() /**/
|
||||
( "help", "produce help message" ) /**/
|
||||
( "version", "show version and exit" ) /**/
|
||||
( "pel_fmts", "list pixel formats" ) /**/
|
||||
( "quality_metrics", "list supported quality metrics" ) /**/
|
||||
( "module_list", "list supported modules" ) /**/
|
||||
( "module_list_full", "detailed list supported modules" );
|
||||
}
|
||||
|
||||
CalypOptions& CalypOptions::addOptions()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CalypOptions::addOptionInternal( std::unique_ptr<OptionBase> opt )
|
||||
void CalypOptions::addOption( OptionBase* opt )
|
||||
{
|
||||
auto names = std::make_unique<Option>();
|
||||
names->base_opt = std::move( opt );
|
||||
opt = nullptr;
|
||||
const std::string& opt_string = names->base_opt->opt_string;
|
||||
Option* names = new Option();
|
||||
names->opt = opt;
|
||||
string& opt_string = opt->opt_string;
|
||||
|
||||
size_t opt_start = 0;
|
||||
for( size_t opt_end = 0; opt_end != std::string::npos; )
|
||||
for( size_t opt_end = 0; opt_end != string::npos; )
|
||||
{
|
||||
opt_end = opt_string.find_first_of( ',', opt_start );
|
||||
bool force_short = 0;
|
||||
@@ -305,37 +313,36 @@ void CalypOptions::addOptionInternal( std::unique_ptr<OptionBase> opt )
|
||||
opt_start++;
|
||||
force_short = 1;
|
||||
}
|
||||
std::string opt_name = opt_string.substr( opt_start, opt_end - opt_start );
|
||||
string opt_name = opt_string.substr( opt_start, opt_end - opt_start );
|
||||
if( force_short || opt_name.size() == 1 )
|
||||
{
|
||||
names->opt_short.push_back( opt_name );
|
||||
opt_short_map[opt_name].push_back( names.get() );
|
||||
opt_short_map[opt_name].push_back( names );
|
||||
}
|
||||
else
|
||||
{
|
||||
names->opt_long.push_back( opt_name );
|
||||
opt_long_map[opt_name].push_back( names.get() );
|
||||
opt_long_map[opt_name].push_back( names );
|
||||
}
|
||||
opt_start += opt_end + 1;
|
||||
}
|
||||
opt_list.push_back( std::move( names ) );
|
||||
opt_list.push_back( names );
|
||||
}
|
||||
|
||||
static void setOptions( std::list<CalypOptions::Option*>& opt_list, const std::string& value )
|
||||
static void setOptions( CalypOptions::OptionsList& opt_list, const string& value )
|
||||
{
|
||||
/* multiple options may be registered for the same name:
|
||||
* allow each to parse value
|
||||
*/
|
||||
for( auto& option : opt_list )
|
||||
* allow each to parse value */
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
|
||||
{
|
||||
option->base_opt->parse( value );
|
||||
( *it )->opt->parse( value );
|
||||
}
|
||||
}
|
||||
|
||||
bool CalypOptions::storePair( bool allow_long, bool allow_short, const std::string& name, const std::string& value )
|
||||
bool CalypOptions::storePair( bool allow_long, bool allow_short, const string& name, const string& value )
|
||||
{
|
||||
bool found = false;
|
||||
std::map<std::string, std::list<Option*>>::iterator opt_it;
|
||||
CalypOptions::OptionMap::iterator opt_it;
|
||||
if( allow_long )
|
||||
{
|
||||
opt_it = opt_long_map.find( name );
|
||||
@@ -360,7 +367,7 @@ bool CalypOptions::storePair( bool allow_long, bool allow_short, const std::stri
|
||||
if( !m_bAllowUnkonw )
|
||||
{
|
||||
/* not found */
|
||||
std::cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << std::endl;
|
||||
cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -369,7 +376,7 @@ bool CalypOptions::storePair( bool allow_long, bool allow_short, const std::stri
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalypOptions::storePair( const std::string& name, const std::string& value )
|
||||
bool CalypOptions::storePair( const string& name, const string& value )
|
||||
{
|
||||
return storePair( true, true, name, value );
|
||||
}
|
||||
@@ -377,19 +384,19 @@ bool CalypOptions::storePair( const std::string& name, const std::string& value
|
||||
/**
|
||||
* returns number of extra arguments consumed
|
||||
*/
|
||||
unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] ) // NOLINT
|
||||
unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] )
|
||||
{
|
||||
/* gnu style long options can take the forms:
|
||||
* --option=arg
|
||||
* --option arg
|
||||
*/
|
||||
std::string arg( argv[0] );
|
||||
std::size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
std::size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
std::string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
string arg( argv[0] );
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
|
||||
unsigned int extra_argc_consumed = 0;
|
||||
if( arg_opt_sep == std::string::npos )
|
||||
if( arg_opt_sep == string::npos )
|
||||
{
|
||||
/* no argument found => argument in argv[1] (maybe) */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
@@ -409,7 +416,7 @@ unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] ) // NOLI
|
||||
else
|
||||
{
|
||||
/* argument occurs after option_sep */
|
||||
std::string val = arg.substr( arg_opt_sep + 1 );
|
||||
string val = arg.substr( arg_opt_sep + 1 );
|
||||
storePair( true, false, option, val );
|
||||
}
|
||||
return extra_argc_consumed;
|
||||
@@ -418,7 +425,7 @@ unsigned int CalypOptions::parseLONG( unsigned int argc, char* argv[] ) // NOLI
|
||||
/**
|
||||
* returns number of extra arguments consumed
|
||||
*/
|
||||
unsigned int CalypOptions::parseLONG( const std::string& arg )
|
||||
unsigned int CalypOptions::parseLONG( string arg )
|
||||
{
|
||||
/* gnu style long options can take the forms:
|
||||
* --option=arg
|
||||
@@ -426,10 +433,10 @@ unsigned int CalypOptions::parseLONG( const std::string& arg )
|
||||
*/
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
size_t arg_opt_sep = arg.find_first_of( '=' );
|
||||
std::string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
string option = arg.substr( arg_opt_start, arg_opt_sep - arg_opt_start );
|
||||
|
||||
unsigned int extra_argc_consumed = 0;
|
||||
if( arg_opt_sep == std::string::npos )
|
||||
if( arg_opt_sep == string::npos )
|
||||
{
|
||||
/* no argument found => argument in argv[1] (maybe) */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
@@ -441,36 +448,36 @@ unsigned int CalypOptions::parseLONG( const std::string& arg )
|
||||
else
|
||||
{
|
||||
/* argument occurs after option_sep */
|
||||
std::string val = arg.substr( arg_opt_sep + 1 );
|
||||
string val = arg.substr( arg_opt_sep + 1 );
|
||||
storePair( true, false, option, val );
|
||||
}
|
||||
return extra_argc_consumed;
|
||||
}
|
||||
|
||||
unsigned int CalypOptions::parseSHORT( unsigned int argc, char* argv[] ) // NOLINT
|
||||
unsigned int CalypOptions::parseSHORT( unsigned int argc, char* argv[] )
|
||||
{
|
||||
/* short options can take the forms:
|
||||
* --option arg
|
||||
* -option arg
|
||||
*/
|
||||
std::string arg( argv[0] );
|
||||
std::size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
std::string option = arg.substr( arg_opt_start );
|
||||
string arg( argv[0] );
|
||||
size_t arg_opt_start = arg.find_first_not_of( '-' );
|
||||
string option = arg.substr( arg_opt_start );
|
||||
/* lookup option */
|
||||
|
||||
/* argument in argv[1] */
|
||||
/* xxx, need to handle case where option isn't required */
|
||||
if( argc == 1 )
|
||||
{
|
||||
std::cerr << "Not processing option without argument `" << option << "'" << std::endl;
|
||||
cerr << "Not processing option without argument `" << option << "'" << endl;
|
||||
return 0; /* run out of argv for argument */
|
||||
}
|
||||
storePair( false, true, option, std::string( argv[1] ) );
|
||||
storePair( false, true, option, string( argv[1] ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CalypOptions::parse( unsigned int argc, char* argv[] ) // NOLINT
|
||||
int CalypOptions::parse( unsigned int argc, char* argv[] )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -492,11 +499,10 @@ int CalypOptions::parse( unsigned int argc, char* argv[] ) // NOLINT
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(*-avoid-c-arrays)
|
||||
std::list<const char*> CalypOptions::scanArgv( unsigned int argc, char* argv[] )
|
||||
list<const char*> CalypOptions::scanArgv( unsigned int argc, char* argv[] )
|
||||
{
|
||||
/* a list for anything that didn't get handled as an option */
|
||||
std::list<const char*> non_option_arguments;
|
||||
list<const char*> non_option_arguments;
|
||||
|
||||
for( unsigned int i = 1; i < argc; i++ )
|
||||
{
|
||||
@@ -539,7 +545,7 @@ std::list<const char*> CalypOptions::scanArgv( unsigned int argc, char* argv[] )
|
||||
return non_option_arguments;
|
||||
}
|
||||
|
||||
void CalypOptions::parse( std::vector<std::string> args_array )
|
||||
void CalypOptions::parse( std::vector<ClpString> args_array )
|
||||
{
|
||||
for( unsigned int i = 0; i < args_array.size(); i++ )
|
||||
{
|
||||
@@ -554,13 +560,13 @@ static const char spaces[41] = " ";
|
||||
* using the formatting: "-x, --long",
|
||||
* if a short/long option isn't specified, it is not printed
|
||||
*/
|
||||
static void doHelpOpt( std::ostream& out, const CalypOptions::Option& entry, unsigned int pad_short = 0 )
|
||||
static void doHelpOpt( ostream& out, const CalypOptions::Option& entry, unsigned int pad_short = 0 )
|
||||
{
|
||||
pad_short = std::min( pad_short, 8u );
|
||||
pad_short = min( pad_short, 8u );
|
||||
|
||||
if( !entry.opt_short.empty() )
|
||||
{
|
||||
unsigned int pad = std::max( (int)pad_short - (int)entry.opt_short.front().size(), 0 );
|
||||
unsigned int pad = max( (int)pad_short - (int)entry.opt_short.front().size(), 0 );
|
||||
out << "-" << entry.opt_short.front();
|
||||
if( !entry.opt_long.empty() )
|
||||
{
|
||||
@@ -581,19 +587,19 @@ static void doHelpOpt( std::ostream& out, const CalypOptions::Option& entry, uns
|
||||
}
|
||||
|
||||
/* format the help text */
|
||||
void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
void CalypOptions::doHelp( ostream& out, unsigned int columns )
|
||||
{
|
||||
const unsigned int pad_short = 3;
|
||||
/* first pass: work out the longest option name */
|
||||
unsigned int max_width = 0;
|
||||
for( auto& opt : opt_list )
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
std::ostringstream line( std::ios_base::out );
|
||||
doHelpOpt( line, *opt, pad_short );
|
||||
max_width = std::max( max_width, (unsigned int)line.tellp() );
|
||||
ostringstream line( ios_base::out );
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
max_width = max( max_width, (unsigned int)line.tellp() );
|
||||
}
|
||||
|
||||
unsigned int opt_width = std::min( max_width + 2, 28u + pad_short ) + 2;
|
||||
unsigned int opt_width = min( max_width + 2, 28u + pad_short ) + 2;
|
||||
unsigned int desc_width = columns - opt_width;
|
||||
|
||||
/* second pass: write out formatted option and help text.
|
||||
@@ -601,17 +607,17 @@ void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
* - if the option text is longer than opt_width, place the help
|
||||
* text at opt_width on the next line.
|
||||
*/
|
||||
for( auto& opt : opt_list )
|
||||
for( CalypOptions::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
|
||||
{
|
||||
std::ostringstream line( std::ios_base::out );
|
||||
ostringstream line( ios_base::out );
|
||||
line << " ";
|
||||
doHelpOpt( line, *opt, pad_short );
|
||||
doHelpOpt( line, **it, pad_short );
|
||||
|
||||
const std::string& opt_desc = opt->base_opt->opt_desc;
|
||||
const string& opt_desc = ( *it )->opt->opt_desc;
|
||||
if( opt_desc.empty() )
|
||||
{
|
||||
/* no help text: output option, skip further processing */
|
||||
std::cout << line.str() << std::endl;
|
||||
cout << line.str() << endl;
|
||||
continue;
|
||||
}
|
||||
size_t currlength = size_t( line.tellp() );
|
||||
@@ -619,17 +625,17 @@ void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
{
|
||||
/* if option text is too long (and would collide with the
|
||||
* help text, split onto next line */
|
||||
line << std::endl;
|
||||
line << endl;
|
||||
currlength = 0;
|
||||
}
|
||||
/* split up the help text, taking into account new lines,
|
||||
* (add opt_width of padding to each new line) */
|
||||
for( std::size_t newline_pos = 0, cur_pos = 0; cur_pos != std::string::npos; currlength = 0 )
|
||||
for( size_t newline_pos = 0, cur_pos = 0; cur_pos != string::npos; currlength = 0 )
|
||||
{
|
||||
/* print any required padding space for vertical alignment */
|
||||
line << &( spaces[40 - opt_width + currlength] );
|
||||
newline_pos = opt_desc.find_first_of( '\n', newline_pos );
|
||||
if( newline_pos != std::string::npos )
|
||||
if( newline_pos != string::npos )
|
||||
{
|
||||
/* newline found, print substring (newline needn't be stripped) */
|
||||
newline_pos++;
|
||||
@@ -646,14 +652,14 @@ void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
/* find a suitable point to split text (avoid spliting in middle of word)
|
||||
*/
|
||||
size_t split_pos = opt_desc.find_last_of( ' ', cur_pos + desc_width );
|
||||
if( split_pos != std::string::npos )
|
||||
if( split_pos != string::npos )
|
||||
{
|
||||
/* eat up multiple space characters */
|
||||
split_pos = opt_desc.find_last_not_of( ' ', split_pos ) + 1;
|
||||
}
|
||||
|
||||
/* bad split if no suitable space to split at. fall back to width */
|
||||
bool bad_split = split_pos == std::string::npos || split_pos <= cur_pos;
|
||||
bool bad_split = split_pos == string::npos || split_pos <= cur_pos;
|
||||
if( bad_split )
|
||||
{
|
||||
split_pos = cur_pos + desc_width;
|
||||
@@ -671,9 +677,10 @@ void CalypOptions::doHelp( std::ostream& out, unsigned int columns )
|
||||
{
|
||||
break;
|
||||
}
|
||||
line << std::endl;
|
||||
line << endl;
|
||||
}
|
||||
std::cout << line.str() << std::endl;
|
||||
|
||||
cout << line.str() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,25 +690,24 @@ bool CalypOptions::checkListingOpts()
|
||||
|
||||
if( hasOpt( "version" ) )
|
||||
{
|
||||
std::cout << "Calyp version" << CALYP_VERSION_STRING << std::endl;
|
||||
std::cout << "Calyp version " << CALYP_VERSION_STRING << "\n";
|
||||
bRet |= true;
|
||||
}
|
||||
if( hasOpt( "pel_fmts" ) )
|
||||
{
|
||||
std::cout << "Calyp supported pixel formats:" << std::endl;
|
||||
const auto& fmt_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( const auto& [key, name] : fmt_list )
|
||||
printf( "Calyp supported pixel formats: \n" );
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
std::cout << " " << name << std::endl;
|
||||
printf( " %s\n", CalypFrame::supportedPixelFormatListNames()[i].c_str() );
|
||||
}
|
||||
bRet |= true;
|
||||
}
|
||||
if( hasOpt( "quality_metrics" ) )
|
||||
{
|
||||
std::cout << "Calyp supported quality metrics:" << std::endl;
|
||||
printf( "Calyp supported quality metrics: \n" );
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedQualityMetricsList().size(); i++ )
|
||||
{
|
||||
std::cout << " " << CalypFrame::supportedQualityMetricsList()[i] << std::endl;
|
||||
printf( " %s\n", CalypFrame::supportedQualityMetricsList()[i].c_str() );
|
||||
}
|
||||
bRet |= true;
|
||||
}
|
||||
|
||||
+57
-63
@@ -42,9 +42,32 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
|
||||
/**
|
||||
* \class OptionBase
|
||||
* \ingroup CalypLibGrp
|
||||
* \brief Virtual base class for storing information relating to a
|
||||
* specific option This base class describes common elements.
|
||||
* Type specific information should be stored in a derived class.
|
||||
*/
|
||||
class OptionBase
|
||||
{
|
||||
public:
|
||||
OptionBase( const ClpString& name, const ClpString& desc, const ClpString& def )
|
||||
: arg_count( 0 ), opt_string( name ), opt_desc( desc ), opt_defaults( def ) {}
|
||||
virtual ~OptionBase() {}
|
||||
/* parse argument arg, to obtain a value for the option */
|
||||
virtual void parse( const ClpString& arg ) = 0;
|
||||
int count() { return arg_count; }
|
||||
bool isBinary() { return is_binary; }
|
||||
int arg_count;
|
||||
ClpString opt_string;
|
||||
ClpString opt_desc;
|
||||
ClpString opt_defaults;
|
||||
bool is_binary;
|
||||
};
|
||||
|
||||
/**
|
||||
* \class CalypOptions
|
||||
@@ -54,56 +77,34 @@
|
||||
class CalypOptions
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Virtual base class for storing information relating to a
|
||||
* specific option This base class describes common elements.
|
||||
* Type specific information should be stored in a derived class.
|
||||
*/
|
||||
class OptionBase
|
||||
{
|
||||
public:
|
||||
OptionBase( std::string name, std::string desc, std::string def )
|
||||
: opt_string{ std::move( name ) }, opt_desc{ std::move( desc ) }, opt_defaults{ std::move( def ) } {}
|
||||
OptionBase( OptionBase&& other ) noexcept = delete;
|
||||
OptionBase& operator=( OptionBase&& other ) noexcept = delete;
|
||||
OptionBase( const OptionBase& other ) = delete;
|
||||
OptionBase& operator=( const OptionBase& other ) = delete;
|
||||
virtual ~OptionBase() = default;
|
||||
/* parse argument arg, to obtain a value for the option */
|
||||
virtual void parse( const std::string& arg ) = 0;
|
||||
auto count() const -> std::size_t { return arg_count; }
|
||||
auto isBinary() const -> bool { return is_binary; }
|
||||
std::string opt_string;
|
||||
std::string opt_desc;
|
||||
std::string opt_defaults;
|
||||
|
||||
protected:
|
||||
std::size_t arg_count{ 0 };
|
||||
bool is_binary{ false };
|
||||
};
|
||||
struct Option
|
||||
{
|
||||
std::list<std::string> opt_long;
|
||||
std::list<std::string> opt_short;
|
||||
std::unique_ptr<OptionBase> base_opt{ nullptr };
|
||||
Option();
|
||||
~Option();
|
||||
std::list<ClpString> opt_long;
|
||||
std::list<ClpString> opt_short;
|
||||
OptionBase* opt;
|
||||
};
|
||||
typedef std::list<Option*> OptionsList;
|
||||
|
||||
CalypOptions() = default;
|
||||
CalypOptions( std::string name );
|
||||
CalypOptions( const ClpString& name = "" );
|
||||
~CalypOptions();
|
||||
|
||||
int parse( unsigned int argc, char* argv[] ); // NOLINT
|
||||
void parse( std::vector<std::string> args_array );
|
||||
int parse( unsigned int argc, char* argv[] );
|
||||
void parse( std::vector<ClpString> args_array );
|
||||
|
||||
std::list<const char*>& getUnhandledArgs() { return m_aUnhandledArgs; }
|
||||
void doHelp( std::ostream& out, unsigned columns = 80 );
|
||||
|
||||
CalypOptions::OptionBase* operator[]( const std::string& optName );
|
||||
CalypOptions::OptionBase* getOption( const std::string& optName );
|
||||
OptionBase* operator[]( const ClpString& optName );
|
||||
OptionBase* getOption( const ClpString& optName );
|
||||
|
||||
bool hasOpt( const std::string& optName );
|
||||
bool hasOpt( const ClpString& optName );
|
||||
|
||||
auto getOptionList() -> const std::list<std::unique_ptr<Option>>& { return opt_list; }
|
||||
OptionsList getOptionList() { return opt_list; }
|
||||
void addDefaultOptions();
|
||||
CalypOptions& addOptions();
|
||||
void addOption( OptionBase* opt );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -111,8 +112,7 @@ public:
|
||||
* with default_val as the default value
|
||||
* with desc as an optional help description
|
||||
*/
|
||||
CalypOptions& operator()( const std::string& name, const std::string& desc );
|
||||
CalypOptions& addOption( const std::string& name, const std::string& desc );
|
||||
CalypOptions& operator()( const ClpString& name, const ClpString& desc );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -121,36 +121,30 @@ public:
|
||||
* description and range along with default value
|
||||
*/
|
||||
template <typename T>
|
||||
CalypOptions& operator()( const std::string& name, T& storage, const std::string& desc );
|
||||
template <typename T>
|
||||
CalypOptions& addOption( const std::string& name, T& storage, const std::string& desc );
|
||||
CalypOptions& operator()( const ClpString& name, T& storage, const ClpString& desc );
|
||||
|
||||
template <typename T>
|
||||
CalypOptions& operator()( const std::string& name, T& storage, const std::string& desc, const std::string& defaults );
|
||||
template <typename T>
|
||||
CalypOptions& addOption( const std::string& name, T& storage, const std::string& desc, const std::string& defaults );
|
||||
CalypOptions& operator()( const ClpString& name, T& storage, const ClpString& desc, const ClpString& defaults );
|
||||
|
||||
bool checkListingOpts();
|
||||
|
||||
private:
|
||||
void addOptionInternal( std::unique_ptr<OptionBase> opt );
|
||||
typedef std::map<ClpString, OptionsList> OptionMap;
|
||||
OptionMap opt_long_map;
|
||||
OptionMap opt_short_map;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::list<Option*>> opt_long_map;
|
||||
std::map<std::string, std::list<Option*>> opt_short_map;
|
||||
OptionsList opt_list;
|
||||
|
||||
std::list<std::unique_ptr<Option>> opt_list;
|
||||
|
||||
std::string m_cOptionGroupName{ "" };
|
||||
bool m_bAllowUnkonw{ true };
|
||||
ClpString m_cOptionGroupName;
|
||||
bool m_bAllowUnkonw;
|
||||
std::list<const char*> m_aUnhandledArgs;
|
||||
|
||||
bool storePair( bool allow_long, bool allow_short, const std::string& name, const std::string& value );
|
||||
bool storePair( const std::string& name, const std::string& value );
|
||||
unsigned int parseLONG( unsigned int argc, char* argv[] ); // NOLINT
|
||||
unsigned int parseLONG( const std::string& arg );
|
||||
unsigned int parseSHORT( unsigned int argc, char* argv[] ); // NOLINT
|
||||
std::list<const char*> scanArgv( unsigned int argc, char* argv[] ); // NOLINT
|
||||
bool storePair( bool allow_long, bool allow_short, const ClpString& name, const ClpString& value );
|
||||
bool storePair( const ClpString& name, const ClpString& value );
|
||||
unsigned int parseLONG( unsigned int argc, char* argv[] );
|
||||
unsigned int parseLONG( ClpString arg );
|
||||
unsigned int parseSHORT( unsigned int argc, char* argv[] );
|
||||
std::list<const char*> scanArgv( unsigned int argc, char* argv[] );
|
||||
};
|
||||
|
||||
#endif // __CALYPOPTIONS_H__
|
||||
+146
-103
@@ -22,164 +22,207 @@
|
||||
* \brief Video Frame handling
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto kMinPixelValue{ 0 };
|
||||
constexpr auto kMaxPixelValue{ 255 };
|
||||
#define MAX_NUMBER_COMPONENTS 4
|
||||
|
||||
constexpr void yuvToRgb( int iY, int iU, int iV, int& iR, int& iG, int& iB )
|
||||
struct CalypPixelPrivate
|
||||
{
|
||||
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
|
||||
CalypPixelPrivate( const int& ColorSpace )
|
||||
{
|
||||
iColorSpace = ColorSpace == CLP_COLOR_GRAY ?
|
||||
CLP_COLOR_YUV :
|
||||
ColorSpace;
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
PelComp[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int iColorSpace;
|
||||
ClpPel PelComp[MAX_NUMBER_COMPONENTS];
|
||||
};
|
||||
|
||||
static inline void yuvToRgb( const int& iY, const int& iU, const int& iV, int& iR, int& iG, int& iB )
|
||||
{
|
||||
iR = iY + ( ( 1436 * ( iV - 128 ) ) >> 10 );
|
||||
iG = iY - ( ( 352 * ( iU - 128 ) + 731 * ( iV - 128 ) ) >> 10 );
|
||||
iB = iY + ( ( 1812 * ( iU - 128 ) ) >> 10 );
|
||||
iR = iR < 0 ? 0 : iR > 255 ? 255 :
|
||||
iR;
|
||||
iG = iG < 0 ? 0 : iG > 255 ? 255 :
|
||||
iG;
|
||||
iB = iB < 0 ? 0 : iB > 255 ? 255 :
|
||||
iB;
|
||||
}
|
||||
|
||||
constexpr void rgbToYuv( int iR, int iG, int iB, int& iY, int& iU, int& iV )
|
||||
static inline void rgbToYuv( const int& iR, const int& iG, const 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( int colorSpace, const ClpPel c0 ) : m_colorSpace( colorSpace )
|
||||
{
|
||||
m_pelComp[0] = c0;
|
||||
iY = ( 299 * iR + 587 * iG + 114 * iB + 500 ) / 1000;
|
||||
iU = ( 1000 * ( iB - iY ) + 226816 ) / 1772;
|
||||
iV = ( 1000 * ( iR - iY ) + 179456 ) / 1402;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2 ) : m_colorSpace( colorSpace )
|
||||
int CalypPixel::getMaxNumberOfComponents()
|
||||
{
|
||||
m_pelComp[0] = c0;
|
||||
m_pelComp[1] = c1;
|
||||
m_pelComp[2] = c2;
|
||||
return MAX_NUMBER_COMPONENTS;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( int colorSpace, const ClpPel c0, const ClpPel c1, const ClpPel c2, const ClpPel c3 )
|
||||
: m_colorSpace( colorSpace )
|
||||
CalypPixel::CalypPixel( const int& ColorSpace )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
m_pelComp[0] = c0;
|
||||
m_pelComp[1] = c1;
|
||||
m_pelComp[2] = c2;
|
||||
m_pelComp[3] = c3;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator+=( const CalypPixel& in ) -> CalypPixel&
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0 )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs + rhs; } );
|
||||
d->PelComp[0] = c0;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2 )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
d->PelComp[2] = c2;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2, const ClpPel& c3 )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
d->PelComp[2] = c2;
|
||||
d->PelComp[3] = c3;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const CalypPixel& other )
|
||||
: d( new CalypPixelPrivate( other.colorSpace() ) )
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
d->PelComp[i] = other[i];
|
||||
}
|
||||
}
|
||||
|
||||
CalypPixel::~CalypPixel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
int CalypPixel::colorSpace() const
|
||||
{
|
||||
return d->iColorSpace;
|
||||
}
|
||||
|
||||
ClpPel CalypPixel::operator[]( const int& channel ) const
|
||||
{
|
||||
return d->PelComp[channel];
|
||||
}
|
||||
ClpPel& CalypPixel::operator[]( const int& channel )
|
||||
{
|
||||
return d->PelComp[channel];
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator=( const CalypPixel& other )
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
d->PelComp[i] = other[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator-=( const CalypPixel& in ) -> CalypPixel&
|
||||
CalypPixel CalypPixel::operator+( const CalypPixel& in )
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
std::ranges::transform( other_comp, m_pelComp, m_pelComp.begin(), []( auto& lhs, auto& rhs ) { return lhs - rhs; } );
|
||||
CalypPixel result;
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
result[i] = d->PelComp[i] + in[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator+=( const CalypPixel& in )
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
d->PelComp[i] += in[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator*=( double op ) -> CalypPixel&
|
||||
CalypPixel CalypPixel::operator-( const CalypPixel& in )
|
||||
{
|
||||
std::ranges::transform( m_pelComp, m_pelComp.begin(), [&op]( auto& p1 ) { return p1 * op; } );
|
||||
CalypPixel result;
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
result[i] = d->PelComp[i] - in[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CalypPixel CalypPixel::operator-=( const CalypPixel& in )
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
d->PelComp[i] -= in[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator+( const CalypPixel& in ) const -> CalypPixel
|
||||
CalypPixel CalypPixel::operator*( const double& op )
|
||||
{
|
||||
assert( in.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = in.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
|
||||
[]( auto& lhs, auto& rhs ) { return lhs + rhs; } );
|
||||
CalypPixel result;
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
result[i] = d->PelComp[i] * op;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
auto CalypPixel::operator-( const CalypPixel& input ) const -> CalypPixel
|
||||
CalypPixel CalypPixel::convertPixel( CalypColorSpace eOutputSpace )
|
||||
{
|
||||
assert( input.colorSpace() == m_colorSpace );
|
||||
const auto& other_comp = input.components();
|
||||
CalypPixel result{ m_colorSpace };
|
||||
std::ranges::transform( other_comp, m_pelComp, result.components().begin(),
|
||||
[]( auto& lhs, auto& rhs ) { return lhs - rhs; } );
|
||||
return result;
|
||||
}
|
||||
if( d->iColorSpace == eOutputSpace )
|
||||
return *this;
|
||||
|
||||
auto CalypPixel::operator*( double op ) const -> CalypPixel
|
||||
{
|
||||
CalypPixel result{ m_colorSpace };
|
||||
auto& comp = result.components();
|
||||
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::ranges::equal( m_pelComp, other.components() );
|
||||
}
|
||||
|
||||
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 stream;
|
||||
}
|
||||
|
||||
auto CalypPixel::convertPixel( CalypColorSpace eOutputSpace ) const -> CalypPixel
|
||||
{
|
||||
if( m_colorSpace == eOutputSpace ) return *this;
|
||||
|
||||
int outA{ 0 };
|
||||
int outB{ 0 };
|
||||
int outC{ 0 };
|
||||
int outD{ 0 };
|
||||
if( m_colorSpace == CLP_COLOR_YUV )
|
||||
int outA = 0;
|
||||
int outB = 0;
|
||||
int outC = 0;
|
||||
int outD = 0;
|
||||
if( d->iColorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
switch( eOutputSpace )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
outA = m_pelComp[0];
|
||||
outA = d->PelComp[0];
|
||||
break;
|
||||
case CLP_COLOR_RGBA:
|
||||
outD = kMaxPixelValue;
|
||||
outD = 255;
|
||||
case CLP_COLOR_RGB:
|
||||
yuvToRgb( m_pelComp[0], m_pelComp[1], m_pelComp[2], outA, outB, outC );
|
||||
yuvToRgb( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( m_colorSpace == CLP_COLOR_RGB )
|
||||
if( d->iColorSpace == CLP_COLOR_RGB )
|
||||
{
|
||||
switch( eOutputSpace )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
rgbToYuv( m_pelComp[0], m_pelComp[1], m_pelComp[2], outA, outB, outC );
|
||||
rgbToYuv( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC );
|
||||
case CLP_COLOR_YUV:
|
||||
rgbToYuv( m_pelComp[0], m_pelComp[1], m_pelComp[2], outA, outB, outC );
|
||||
rgbToYuv( d->PelComp[0], d->PelComp[1], d->PelComp[2], outA, outB, outC );
|
||||
break;
|
||||
case CLP_COLOR_RGBA:
|
||||
outD = kMaxPixelValue;
|
||||
outD = 255;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { eOutputSpace, static_cast<ClpPel>( outA ), static_cast<ClpPel>( outB ), static_cast<ClpPel>( outC ),
|
||||
static_cast<ClpPel>( outD ) };
|
||||
return CalypPixel( eOutputSpace, outA, outB, outC, outD );
|
||||
}
|
||||
+329
-406
@@ -25,15 +25,9 @@
|
||||
// Self
|
||||
#include "CalypStream.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStreamHandlerIf.h"
|
||||
#include "LibMemory.h"
|
||||
#include "StreamHandlerPortableMap.h"
|
||||
#include "StreamHandlerRaw.h"
|
||||
#include "config.h"
|
||||
@@ -46,11 +40,6 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
constexpr auto kDefaultBitsPerPixel = 8;
|
||||
constexpr auto kDefaultFrameRate = 30;
|
||||
|
||||
auto find_stream_handler( const std::string& strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn;
|
||||
|
||||
std::vector<CalypStreamFormat> CalypStream::supportedReadFormats()
|
||||
{
|
||||
INI_REGIST_CALYP_SUPPORTED_FMT;
|
||||
@@ -107,263 +96,85 @@ std::vector<CalypStandardResolution> CalypStream::stdResolutionSizes()
|
||||
return stdResList;
|
||||
}
|
||||
|
||||
struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuffer>
|
||||
class CalypStreamBufferPrivate
|
||||
{
|
||||
std::mutex buffer_mutex;
|
||||
std::vector<std::unique_ptr<CalypFrame>> framePool;
|
||||
std::size_t bufferIdx{ 0 };
|
||||
private:
|
||||
std::vector<CalypFrame*> m_apcFrameBuffer;
|
||||
unsigned int m_uiIndex;
|
||||
|
||||
CalypStreamFrameBuffer( std::size_t size, unsigned int width, unsigned int height, ClpPixelFormats pelFormat,
|
||||
unsigned int bitsPixel, bool hasNegative )
|
||||
public:
|
||||
CalypStreamBufferPrivate( unsigned int size, unsigned int width, unsigned int height, int pelFormat, int bitsPixel, bool hasNegative )
|
||||
{
|
||||
framePool.reserve( size );
|
||||
for( std::size_t i = 0; i < size; i++ )
|
||||
for( unsigned int i = 0; i < size; i++ )
|
||||
{
|
||||
framePool.push_back( std::make_unique<CalypFrame>( width, height, pelFormat, bitsPixel, hasNegative ) );
|
||||
CalypFrame* pFrame = new CalypFrame( width, height, pelFormat, bitsPixel, hasNegative );
|
||||
m_apcFrameBuffer.push_back( pFrame );
|
||||
}
|
||||
bufferIdx = framePool.size();
|
||||
m_uiIndex = 0;
|
||||
}
|
||||
|
||||
CalypStreamFrameBuffer( const CalypStreamFrameBuffer& ) = delete;
|
||||
CalypStreamFrameBuffer( CalypStreamFrameBuffer&& ) = delete;
|
||||
CalypStreamFrameBuffer& operator=( const CalypStreamFrameBuffer& ) = delete;
|
||||
CalypStreamFrameBuffer& operator=( CalypStreamFrameBuffer&& ) = delete;
|
||||
|
||||
~CalypStreamFrameBuffer() = default;
|
||||
|
||||
void increase( std::size_t newSize )
|
||||
~CalypStreamBufferPrivate()
|
||||
{
|
||||
framePool.reserve( newSize );
|
||||
auto oldSize = framePool.size();
|
||||
for( std::size_t i = oldSize; i < newSize; i++ )
|
||||
while( m_apcFrameBuffer.size() > 0 )
|
||||
{
|
||||
framePool.push_back( std::make_unique<CalypFrame>( framePool[0]->getWidth(), framePool[0]->getHeight(),
|
||||
framePool[0]->getPelFormat(), framePool[0]->getBitsPel(),
|
||||
framePool[0]->getHasNegativeValues() ) );
|
||||
delete m_apcFrameBuffer.back();
|
||||
m_apcFrameBuffer.pop_back();
|
||||
}
|
||||
bufferIdx += newSize - oldSize;
|
||||
}
|
||||
|
||||
CalypFrame* ref() { return framePool[0].get(); }
|
||||
|
||||
std::shared_ptr<CalypFrame> getFrame()
|
||||
void increase( unsigned int newSize )
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock( buffer_mutex );
|
||||
assert( bufferIdx > 0 );
|
||||
bufferIdx--;
|
||||
auto frame = framePool[bufferIdx].release();
|
||||
auto deleter = [this, lifetime = shared_from_this()]( CalypFrame* p ) {
|
||||
const std::lock_guard<std::mutex> lock( buffer_mutex );
|
||||
framePool[bufferIdx].reset( p );
|
||||
bufferIdx++;
|
||||
};
|
||||
return std::shared_ptr<CalypFrame>{ frame, deleter };
|
||||
for( unsigned int i = m_apcFrameBuffer.size(); i < newSize; i++ )
|
||||
{
|
||||
CalypFrame* pFrame = new CalypFrame( m_apcFrameBuffer.at( 0 ) );
|
||||
m_apcFrameBuffer.push_back( pFrame );
|
||||
}
|
||||
}
|
||||
unsigned int size() { return m_apcFrameBuffer.size(); }
|
||||
void setIndex( unsigned int i ) { m_uiIndex = i; }
|
||||
CalypFrame* frame( int i ) { return m_apcFrameBuffer.at( i ); }
|
||||
|
||||
CalypFrame* current() { return m_apcFrameBuffer.at( m_uiIndex ); }
|
||||
CalypFrame* next() { return m_apcFrameBuffer.at( nextIndex() ); }
|
||||
void setNextFrame() { m_uiIndex = nextIndex(); }
|
||||
|
||||
private:
|
||||
inline int nextIndex() { return m_uiIndex + 1 >= m_apcFrameBuffer.size() ? 0 : m_uiIndex + 1; }
|
||||
inline int prevIndex() { return m_uiIndex - 1 < 0 ? m_apcFrameBuffer.size() - 1 : m_uiIndex - 1; }
|
||||
};
|
||||
|
||||
class CalypStream::CalypStreamPrivate
|
||||
struct CalypStreamPrivate
|
||||
{
|
||||
public:
|
||||
std::recursive_mutex stream_mutex;
|
||||
CalypStream::Type streamType;
|
||||
bool isInit;
|
||||
bool isInput;
|
||||
|
||||
std::unique_ptr<CalypStreamHandlerIf> handler;
|
||||
CalypStreamHandlerIf* handler;
|
||||
CreateStreamHandlerFn pfctCreateHandler;
|
||||
|
||||
std::shared_ptr<CalypStreamFrameBuffer> frameBuffer;
|
||||
std::deque<std::shared_ptr<CalypFrame>> frameFifo;
|
||||
CalypStreamBufferPrivate* frameBuffer;
|
||||
|
||||
std::string cFilename;
|
||||
ClpString cFilename;
|
||||
long long int iCurrFrameNum;
|
||||
bool bLoadAll;
|
||||
|
||||
CalypStreamPrivate( const CalypStreamPrivate& ) = delete;
|
||||
CalypStreamPrivate( CalypStreamPrivate&& ) = delete;
|
||||
CalypStreamPrivate& operator=( const CalypStreamPrivate& ) = delete;
|
||||
CalypStreamPrivate& operator=( CalypStreamPrivate&& ) = delete;
|
||||
CalypStreamPrivate()
|
||||
{
|
||||
handler = nullptr;
|
||||
streamType = CalypStream::Type::Input;
|
||||
handler = NULL;
|
||||
pfctCreateHandler = NULL;
|
||||
isInput = true;
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
iCurrFrameNum = -1;
|
||||
}
|
||||
|
||||
~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 )
|
||||
{
|
||||
if( isInit )
|
||||
{
|
||||
close();
|
||||
}
|
||||
isInit = false;
|
||||
streamType = type;
|
||||
bool isInput = streamType == CalypStream::Type::Input;
|
||||
|
||||
if( forceRaw )
|
||||
{
|
||||
handler = StreamHandlerRaw::Create();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto createHandlerFct = find_stream_handler( filename, isInput );
|
||||
if( !createHandlerFct )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Invalid handler" );
|
||||
}
|
||||
|
||||
handler = createHandlerFct();
|
||||
}
|
||||
|
||||
if( !handler )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot create handler" );
|
||||
}
|
||||
|
||||
cFilename = std::move( filename );
|
||||
|
||||
handler->m_uiWidth = width;
|
||||
handler->m_uiHeight = height;
|
||||
handler->m_iPixelFormat = input_format;
|
||||
handler->m_uiBitsPerPixel = bitsPel;
|
||||
handler->m_iEndianness = bitsPel > 8 ? endianness : CLP_BIG_ENDIAN;
|
||||
handler->m_dFrameRate = frame_rate;
|
||||
|
||||
if( !handler->openHandler( cFilename, isInput ) )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot create the stream handler" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
if( handler->m_uiWidth <= 0 || handler->m_uiHeight <= 0 || handler->m_iPixelFormat == ClpPixelFormats::Invalid )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
frameFifo.clear();
|
||||
|
||||
// Keep past, current and future frames
|
||||
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 );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
const CalypFrame* refFrame = frameBuffer->ref();
|
||||
|
||||
handler->m_uiNBytesPerFrame = refFrame->getBytesPerFrame();
|
||||
|
||||
// Some handlers need to know how long is a frame to get frame number
|
||||
handler->calculateFrameNumber();
|
||||
|
||||
if( isInput && handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
if( !handler->configureBuffer( *refFrame ) )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated buffers" );
|
||||
return isInit;
|
||||
}
|
||||
|
||||
iCurrFrameNum = -1;
|
||||
isInit = true;
|
||||
|
||||
seekInput( 0 );
|
||||
|
||||
isInit = true;
|
||||
return isInit;
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
if( handler )
|
||||
{
|
||||
handler->closeHandler();
|
||||
}
|
||||
|
||||
bLoadAll = false;
|
||||
isInit = false;
|
||||
}
|
||||
|
||||
bool seekInput( unsigned long new_frame_num )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || new_frame_num >= handler->m_uiTotalNumberFrames || long( new_frame_num ) == iCurrFrameNum )
|
||||
return false;
|
||||
|
||||
iCurrFrameNum = new_frame_num;
|
||||
|
||||
if( bLoadAll )
|
||||
return true;
|
||||
|
||||
frameFifo.clear();
|
||||
if( !handler->seek( iCurrFrameNum ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot seek file into desired position" );
|
||||
}
|
||||
|
||||
readNextFrame();
|
||||
if( handler->m_uiTotalNumberFrames > 1 )
|
||||
readNextFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readNextFrame( bool fillRgbBuffer = false )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || streamType != CalypStream::Type::Input ||
|
||||
handler->m_uiCurrFrameFileIdx >= handler->m_uiTotalNumberFrames )
|
||||
return false;
|
||||
|
||||
if( bLoadAll )
|
||||
return true;
|
||||
|
||||
auto frame = frameBuffer->getFrame();
|
||||
|
||||
if( !handler->read( *frame ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot read frame from stream" );
|
||||
return false;
|
||||
}
|
||||
frameFifo.push_back( frame );
|
||||
|
||||
if( fillRgbBuffer )
|
||||
{
|
||||
frame->fillRGBBuffer();
|
||||
}
|
||||
return true;
|
||||
cFilename = "";
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<std::string> CalypStreamFormat::getExts()
|
||||
std::vector<ClpString> CalypStreamFormat::getExts()
|
||||
{
|
||||
std::vector<std::string> arrayExt;
|
||||
std::string::size_type prev_pos = 0, pos = 0;
|
||||
while( ( pos = formatExt.find( ',', pos ) ) != std::string::npos )
|
||||
std::vector<ClpString> arrayExt;
|
||||
ClpString::size_type prev_pos = 0, pos = 0;
|
||||
while( ( pos = formatExt.find( ',', pos ) ) != ClpString::npos )
|
||||
{
|
||||
std::string substring( formatExt.substr( prev_pos, pos - prev_pos ) );
|
||||
ClpString substring( formatExt.substr( prev_pos, pos - prev_pos ) );
|
||||
arrayExt.push_back( substring );
|
||||
prev_pos = ++pos;
|
||||
}
|
||||
@@ -371,25 +182,68 @@ std::vector<std::string> CalypStreamFormat::getExts()
|
||||
return arrayExt;
|
||||
}
|
||||
|
||||
CalypStream::CalypStream() : d{ std::make_unique<CalypStreamPrivate>() } {}
|
||||
CreateStreamHandlerFn CalypStream::findStreamHandler( ClpString strFilename, bool bRead )
|
||||
{
|
||||
ClpString currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
|
||||
currExt = clpLowercase( currExt );
|
||||
|
||||
CalypStream::~CalypStream() = default;
|
||||
std::vector<CalypStreamFormat> supportedFmts;
|
||||
if( bRead )
|
||||
{
|
||||
supportedFmts = CalypStream::supportedReadFormats();
|
||||
}
|
||||
else
|
||||
{
|
||||
supportedFmts = CalypStream::supportedWriteFormats();
|
||||
}
|
||||
for( unsigned int i = 0; i < supportedFmts.size(); i++ )
|
||||
{
|
||||
std::vector<ClpString> arrayExt = supportedFmts[i].getExts();
|
||||
for( std::vector<ClpString>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
{
|
||||
if( currExt != "" && currExt == *e )
|
||||
{
|
||||
return supportedFmts[i].formatFct;
|
||||
}
|
||||
else if( strFilename.find( *e ) != ClpString::npos )
|
||||
{
|
||||
return supportedFmts[i].formatFct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string CalypStream::getFormatName() const
|
||||
#ifdef USE_FFMPEG
|
||||
return &StreamHandlerLibav::Create;
|
||||
#else
|
||||
return &StreamHandlerRaw::Create;
|
||||
#endif
|
||||
}
|
||||
|
||||
CalypStream::CalypStream()
|
||||
: d( new CalypStreamPrivate )
|
||||
{
|
||||
}
|
||||
|
||||
CalypStream::~CalypStream()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
ClpString CalypStream::getFormatName() const
|
||||
{
|
||||
return !d->handler ? "" : d->handler->getFormatName();
|
||||
}
|
||||
std::string CalypStream::getCodecName() const
|
||||
ClpString 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( ClpString filename, ClpString resolution, ClpString input_format_name, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
{
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
int input_format = -1;
|
||||
|
||||
if( resolution.size() > 0 )
|
||||
{
|
||||
@@ -399,63 +253,124 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const auto input_format = CalypFrame::findPixelFormat( input_format_name );
|
||||
if( !input_format.has_value() )
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
return false;
|
||||
if( clpLowercase( CalypFrame::supportedPixelFormatListNames()[i] ) == clpLowercase( input_format_name ) )
|
||||
{
|
||||
input_format = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return d->open( std::move( filename ), width, height, *input_format, bitsPel, endianness, hasNegative, frame_rate,
|
||||
false, type );
|
||||
return open( filename, width, height, input_format, bitsPel, endianness, hasNegative, frame_rate, bInput );
|
||||
}
|
||||
|
||||
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( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
{
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, false, frame_rate, false,
|
||||
type );
|
||||
return open( filename, width, height, input_format, bitsPel, endianness, false, frame_rate, bInput );
|
||||
}
|
||||
|
||||
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( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
unsigned int frame_rate, bool bInput )
|
||||
{
|
||||
return d->open( std::move( filename ), width, height, input_format, bitsPel, endianness, hasNegative, frame_rate,
|
||||
false, type );
|
||||
}
|
||||
if( d->isInit )
|
||||
{
|
||||
close();
|
||||
}
|
||||
d->isInit = false;
|
||||
d->isInput = bInput;
|
||||
|
||||
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 );
|
||||
}
|
||||
d->pfctCreateHandler = CalypStream::findStreamHandler( filename, d->isInput );
|
||||
if( !d->pfctCreateHandler )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Invalid handler" );
|
||||
}
|
||||
|
||||
bool CalypStream::supportsFormatConfiguration()
|
||||
{
|
||||
if( d->handler == nullptr )
|
||||
return false;
|
||||
return d->handler->m_bSupportsFormat;
|
||||
d->handler = d->pfctCreateHandler();
|
||||
|
||||
if( !d->handler )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot create handler" );
|
||||
}
|
||||
|
||||
d->cFilename = filename;
|
||||
|
||||
d->handler->m_cFilename = filename;
|
||||
d->handler->m_uiWidth = width;
|
||||
d->handler->m_uiHeight = height;
|
||||
d->handler->m_iPixelFormat = input_format;
|
||||
d->handler->m_uiBitsPerPixel = bitsPel;
|
||||
d->handler->m_iEndianness = endianness;
|
||||
d->handler->m_dFrameRate = frame_rate;
|
||||
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
{
|
||||
close();
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 )
|
||||
{
|
||||
close();
|
||||
//throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
// Keep past, current and future frames
|
||||
try
|
||||
{
|
||||
d->frameBuffer = new CalypStreamBufferPrivate( d->isInput ? 3 : 1, d->handler->m_uiWidth, d->handler->m_uiHeight,
|
||||
d->handler->m_iPixelFormat, d->handler->m_uiBitsPerPixel, hasNegative );
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
d->handler->m_uiNBytesPerFrame = d->frameBuffer->current()->getBytesPerFrame();
|
||||
|
||||
// Some handlers need to know how long is a frame to get frame number
|
||||
d->handler->calculateFrameNumber();
|
||||
|
||||
if( d->isInput && d->handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( !d->handler->configureBuffer( d->frameBuffer->current() ) )
|
||||
{
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated buffers" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
d->iCurrFrameNum = -1;
|
||||
d->isInit = true;
|
||||
|
||||
seekInput( 0 );
|
||||
|
||||
d->isInit = true;
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
bool CalypStream::reload()
|
||||
{
|
||||
d->frameFifo.clear();
|
||||
d->handler->closeHandler();
|
||||
if( !d->handler->openHandler( d->cFilename, d->streamType == CalypStream::Type::Input ) )
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot open stream " + d->cFilename + " with the " +
|
||||
std::string( d->handler->m_pchHandlerName ) + " handler" );
|
||||
ClpString( d->handler->m_pchHandlerName ) + " handler" );
|
||||
}
|
||||
const CalypFrame* refFrame = d->frameBuffer->ref();
|
||||
d->handler->m_uiNBytesPerFrame = refFrame->getBytesPerFrame();
|
||||
d->handler->m_uiNBytesPerFrame = d->frameBuffer->current()->getBytesPerFrame();
|
||||
d->handler->calculateFrameNumber();
|
||||
d->handler->configureBuffer( *refFrame );
|
||||
d->handler->configureBuffer( d->frameBuffer->current() );
|
||||
|
||||
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 < 0 ||
|
||||
d->handler->m_uiBitsPerPixel == 0 || d->handler->m_uiTotalNumberFrames == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -463,13 +378,27 @@ bool CalypStream::reload()
|
||||
{
|
||||
d->iCurrFrameNum = 0;
|
||||
}
|
||||
auto currFrameNum = d->iCurrFrameNum;
|
||||
int currFrameNum = d->iCurrFrameNum;
|
||||
d->iCurrFrameNum = -1;
|
||||
seekInput( currFrameNum );
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CalypStream::getFileName() const
|
||||
void CalypStream::close()
|
||||
{
|
||||
if( !d->isInit )
|
||||
return;
|
||||
|
||||
d->handler->closeHandler();
|
||||
d->handler->Delete();
|
||||
|
||||
delete d->frameBuffer;
|
||||
|
||||
d->bLoadAll = false;
|
||||
d->isInit = false;
|
||||
}
|
||||
|
||||
ClpString CalypStream::getFileName() const
|
||||
{
|
||||
return d->cFilename;
|
||||
}
|
||||
@@ -479,7 +408,7 @@ bool CalypStream::isNative() const
|
||||
return d->handler->m_bNative;
|
||||
}
|
||||
|
||||
std::uint64_t CalypStream::getFrameNum() const
|
||||
ClpULong CalypStream::getFrameNum() const
|
||||
{
|
||||
return d->handler->m_uiTotalNumberFrames;
|
||||
}
|
||||
@@ -509,8 +438,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, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate ) const
|
||||
{
|
||||
if( d->isInit )
|
||||
{
|
||||
@@ -519,37 +448,22 @@ void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, ClpPix
|
||||
rInputFormat = d->handler->m_iPixelFormat;
|
||||
rBitsPerPel = d->handler->m_uiBitsPerPixel;
|
||||
rEndianness = d->handler->m_iEndianness;
|
||||
rFrameRate = static_cast<unsigned>( std::max( 0.0, d->handler->m_dFrameRate ) );
|
||||
rFrameRate = d->handler->m_dFrameRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
rWidth = 0;
|
||||
rHeight = 0;
|
||||
rInputFormat = ClpPixelFormats::YUV420p;
|
||||
rBitsPerPel = kDefaultBitsPerPixel;
|
||||
rInputFormat = CLP_YUV420P;
|
||||
rBitsPerPel = 8;
|
||||
rEndianness = 0;
|
||||
rFrameRate = kDefaultFrameRate;
|
||||
rFrameRate = 30;
|
||||
}
|
||||
}
|
||||
|
||||
auto CalypStream::hasNextFrame() -> bool
|
||||
{
|
||||
return d->frameFifo.size() > 1;
|
||||
}
|
||||
|
||||
auto CalypStream::hasWritingSlot() -> bool
|
||||
{
|
||||
return !d->bLoadAll && d->frameBuffer->bufferIdx > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read operations
|
||||
*/
|
||||
|
||||
void CalypStream::loadAll()
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( d->stream_mutex );
|
||||
if( d->bLoadAll || d->streamType != CalypStream::Type::Input )
|
||||
if( d->bLoadAll || !d->isInput )
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -558,79 +472,64 @@ void CalypStream::loadAll()
|
||||
}
|
||||
catch( CalypFailure& e )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer for the whole stream" );
|
||||
}
|
||||
|
||||
seekInput( 0 );
|
||||
for( unsigned int i = 2; i < d->handler->m_uiTotalNumberFrames; i++ )
|
||||
for( unsigned int i = 2; i < d->frameBuffer->size(); i++ )
|
||||
{
|
||||
d->readNextFrame( false );
|
||||
readFrame( d->frameBuffer->frame( i ) );
|
||||
}
|
||||
d->bLoadAll = true;
|
||||
d->iCurrFrameNum = 0;
|
||||
}
|
||||
|
||||
auto CalypStream::getCurrFrameAsset() -> std::shared_ptr<CalypFrame>
|
||||
void CalypStream::getDuration( int* duration_array ) const
|
||||
{
|
||||
// int hours, mins, secs = 0;
|
||||
// #ifdef USE_FFMPEG
|
||||
// if( m_iStreamHandler == FFMPEG )
|
||||
// {
|
||||
// secs = m_cLibAvContext->getStreamDuration();
|
||||
// }
|
||||
// else
|
||||
// #endif
|
||||
// if( m_iStreamHandler == YUV_IO )
|
||||
// {
|
||||
// secs = m_uiTotalFrameNum / m_dFrameRate;
|
||||
// }
|
||||
// mins = secs / 60;
|
||||
// secs %= 60;
|
||||
// hours = mins / 60;
|
||||
// mins %= 60;
|
||||
// *duration_array++ = hours;
|
||||
// *duration_array++ = mins;
|
||||
// *duration_array++ = secs;
|
||||
}
|
||||
|
||||
bool CalypStream::readFrame( CalypFrame* frame )
|
||||
{
|
||||
if( !d->isInit || !d->isInput || d->handler->m_uiCurrFrameFileIdx >= d->handler->m_uiTotalNumberFrames )
|
||||
return false;
|
||||
|
||||
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() );
|
||||
else
|
||||
buffer->copyFrom( *d->frameFifo.front() );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
auto CalypStream::getCurrFrame() -> CalypFrame*
|
||||
{
|
||||
if( d->bLoadAll )
|
||||
return d->frameFifo[d->iCurrFrameNum].get();
|
||||
return d->frameFifo.front().get();
|
||||
}
|
||||
|
||||
bool CalypStream::isEof()
|
||||
{
|
||||
if( d->iCurrFrameNum + 1 >= (long)( d->handler->m_uiTotalNumberFrames ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CalypStream::setNextFrame()
|
||||
{
|
||||
if( isEof() )
|
||||
if( !d->handler->read( frame ) )
|
||||
{
|
||||
return true;
|
||||
throw CalypFailure( "CalypStream", "Cannot read frame from stream" );
|
||||
return false;
|
||||
}
|
||||
d->iCurrFrameNum++;
|
||||
if( !d->bLoadAll )
|
||||
{
|
||||
assert( d->frameFifo.size() > 1 );
|
||||
d->frameFifo.pop_front();
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CalypStream::readNextFrame()
|
||||
void CalypStream::writeFrame()
|
||||
{
|
||||
d->readNextFrame();
|
||||
writeFrame( d->frameBuffer->current() );
|
||||
}
|
||||
|
||||
void CalypStream::readNextFrameFillRGBBuffer()
|
||||
{
|
||||
d->readNextFrame( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write operations
|
||||
*/
|
||||
void CalypStream::writeFrame( const CalypFrame& pcFrame )
|
||||
void CalypStream::writeFrame( CalypFrame* pcFrame )
|
||||
{
|
||||
if( !d->handler->write( pcFrame ) )
|
||||
{
|
||||
@@ -639,36 +538,76 @@ void CalypStream::writeFrame( const CalypFrame& pcFrame )
|
||||
return;
|
||||
}
|
||||
|
||||
bool CalypStream::saveFrame( const std::string& filename )
|
||||
bool CalypStream::saveFrame( const ClpString& filename )
|
||||
{
|
||||
return saveFrame( filename, *getCurrFrame() );
|
||||
return saveFrame( filename, d->frameBuffer->current() );
|
||||
}
|
||||
|
||||
bool CalypStream::saveFrame( const std::string& filename, const CalypFrame& saveFrame )
|
||||
bool CalypStream::saveFrame( const ClpString& filename, CalypFrame* saveFrame )
|
||||
{
|
||||
CalypStream auxSaveStream;
|
||||
if( !auxSaveStream.open( filename, saveFrame.getWidth(), saveFrame.getHeight(), saveFrame.getPelFormat(),
|
||||
saveFrame.getBitsPel(), CLP_LITTLE_ENDIAN, 1, Type::Output ) )
|
||||
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(),
|
||||
saveFrame->getBitsPel(), CLP_LITTLE_ENDIAN, 1, false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auxSaveStream.writeFrame( saveFrame );
|
||||
auxSaveStream.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Seek operations
|
||||
*/
|
||||
bool CalypStream::setNextFrame()
|
||||
{
|
||||
bool bEndOfSeq = false;
|
||||
|
||||
if( d->iCurrFrameNum + 1 < (long)( d->handler->m_uiTotalNumberFrames ) )
|
||||
{
|
||||
d->frameBuffer->setNextFrame();
|
||||
d->iCurrFrameNum++;
|
||||
}
|
||||
else
|
||||
{
|
||||
bEndOfSeq = true;
|
||||
}
|
||||
return bEndOfSeq;
|
||||
}
|
||||
|
||||
void CalypStream::readNextFrame()
|
||||
{
|
||||
readFrame( d->frameBuffer->next() );
|
||||
}
|
||||
|
||||
void CalypStream::readNextFrameFillRGBBuffer()
|
||||
{
|
||||
readNextFrame();
|
||||
d->frameBuffer->next()->fillRGBBuffer();
|
||||
return;
|
||||
}
|
||||
|
||||
CalypFrame* CalypStream::getCurrFrame( CalypFrame* pyuv_image ) const
|
||||
{
|
||||
if( pyuv_image == NULL )
|
||||
pyuv_image = new CalypFrame( d->frameBuffer->current() );
|
||||
else
|
||||
pyuv_image->copyFrom( d->frameBuffer->current() );
|
||||
return pyuv_image;
|
||||
}
|
||||
|
||||
CalypFrame* CalypStream::getCurrFrame() const
|
||||
{
|
||||
return d->frameBuffer->current();
|
||||
}
|
||||
|
||||
bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
{
|
||||
if( !d->isInit || d->streamType != Type::Input )
|
||||
if( !d->isInit || !d->isInput )
|
||||
return false;
|
||||
|
||||
bool bRet = false;
|
||||
if( bIsFoward )
|
||||
{
|
||||
bRet = !setNextFrame();
|
||||
d->readNextFrame();
|
||||
readFrame( d->frameBuffer->next() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -680,42 +619,26 @@ bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
|
||||
bool CalypStream::seekInput( unsigned long new_frame_num )
|
||||
{
|
||||
return d->seekInput( new_frame_num );
|
||||
if( !d->isInit || new_frame_num >= d->handler->m_uiTotalNumberFrames || long( new_frame_num ) == d->iCurrFrameNum )
|
||||
return false;
|
||||
|
||||
d->iCurrFrameNum = new_frame_num;
|
||||
|
||||
if( d->bLoadAll )
|
||||
{
|
||||
d->frameBuffer->setIndex( d->iCurrFrameNum );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !d->handler->seek( d->iCurrFrameNum ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot seek file into desired position" );
|
||||
}
|
||||
|
||||
d->frameBuffer->setIndex( 0 );
|
||||
readFrame( d->frameBuffer->current() );
|
||||
if( d->handler->m_uiTotalNumberFrames > 1 )
|
||||
readFrame( d->frameBuffer->next() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto find_stream_handler( const std::string& strFilename, bool bRead ) -> CalypStreamFormat::CreateStreamHandlerFn
|
||||
{
|
||||
std::string currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
|
||||
currExt = clpLowercase( currExt );
|
||||
|
||||
std::vector<CalypStreamFormat> supportedFmts;
|
||||
if( bRead )
|
||||
{
|
||||
supportedFmts = CalypStream::supportedReadFormats();
|
||||
}
|
||||
else
|
||||
{
|
||||
supportedFmts = CalypStream::supportedWriteFormats();
|
||||
}
|
||||
for( unsigned int i = 0; i < supportedFmts.size(); i++ )
|
||||
{
|
||||
std::vector<std::string> arrayExt = supportedFmts[i].getExts();
|
||||
for( std::vector<std::string>::iterator e = arrayExt.begin(); e != arrayExt.end(); ++e )
|
||||
{
|
||||
if( currExt != "" && currExt == *e )
|
||||
{
|
||||
return supportedFmts[i].formatFct;
|
||||
}
|
||||
else if( strFilename.find( *e ) != std::string::npos )
|
||||
{
|
||||
return supportedFmts[i].formatFct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
return &StreamHandlerLibav::Create;
|
||||
#else
|
||||
return &StreamHandlerRaw::Create;
|
||||
#endif
|
||||
}
|
||||
+51
-66
@@ -26,39 +26,28 @@
|
||||
#ifndef __CALYPSTREAM_H__
|
||||
#define __CALYPSTREAM_H__
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypDefs.h"
|
||||
|
||||
class CalypFrame;
|
||||
class CalypStreamHandlerIf;
|
||||
|
||||
struct CalypStandardResolution
|
||||
typedef CalypStreamHandlerIf* ( *CreateStreamHandlerFn )( void );
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string shortName;
|
||||
ClpString formatName;
|
||||
ClpString formatExt;
|
||||
std::vector<ClpString> getExts();
|
||||
ClpString formatPattern;
|
||||
CreateStreamHandlerFn formatFct;
|
||||
} CalypStreamFormat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ClpString shortName;
|
||||
unsigned int uiWidth;
|
||||
unsigned int uiHeight;
|
||||
};
|
||||
|
||||
/**
|
||||
* \class CalypStreamFormat
|
||||
* \ingroup CalypLibGrp CalypStreamGrp
|
||||
* \brief Stream format handling class
|
||||
*/
|
||||
|
||||
class CalypStreamFormat
|
||||
{
|
||||
public:
|
||||
using CreateStreamHandlerFn = auto ( * )( void ) -> std::unique_ptr<CalypStreamHandlerIf>;
|
||||
|
||||
CalypStreamFormat() = default;
|
||||
std::vector<std::string> getExts();
|
||||
|
||||
std::string formatName;
|
||||
std::string formatExt;
|
||||
std::string formatPattern;
|
||||
CreateStreamHandlerFn formatFct;
|
||||
};
|
||||
} CalypStandardResolution;
|
||||
|
||||
/**
|
||||
* \class CalypStream
|
||||
@@ -68,73 +57,69 @@ public:
|
||||
class CalypStream
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Input,
|
||||
Output
|
||||
};
|
||||
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats();
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats();
|
||||
|
||||
static CreateStreamHandlerFn findStreamHandler( ClpString strFilename, bool bRead );
|
||||
|
||||
static std::vector<CalypStandardResolution> stdResolutionSizes();
|
||||
|
||||
CalypStream();
|
||||
CalypStream( CalypStream&& other ) noexcept = delete;
|
||||
CalypStream& operator=( CalypStream&& other ) noexcept = delete;
|
||||
CalypStream( const CalypStream& other ) = delete;
|
||||
CalypStream& operator=( const CalypStream& other ) = delete;
|
||||
~CalypStream();
|
||||
|
||||
std::string getFormatName() const;
|
||||
std::string getCodecName() const;
|
||||
ClpString getFormatName() const;
|
||||
;
|
||||
ClpString 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( ClpString filename, ClpString resolution, ClpString input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( ClpString filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
|
||||
bool supportsFormatConfiguration();
|
||||
bool reload();
|
||||
void close();
|
||||
|
||||
bool isNative() const;
|
||||
std::string getFileName() const;
|
||||
std::uint64_t getFrameNum() const;
|
||||
ClpString getFileName() const;
|
||||
ClpULong getFrameNum() const;
|
||||
unsigned int getWidth() const;
|
||||
unsigned int getHeight() const;
|
||||
unsigned int getBitsPerPixel() const;
|
||||
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;
|
||||
|
||||
auto hasNextFrame() -> bool;
|
||||
auto hasWritingSlot() -> bool;
|
||||
void getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate ) const;
|
||||
|
||||
void loadAll();
|
||||
auto getCurrFrameAsset() -> std::shared_ptr<CalypFrame>;
|
||||
auto getCurrFrame( std::unique_ptr<CalypFrame> buffer ) const -> std::unique_ptr<CalypFrame>;
|
||||
auto getCurrFrame() -> CalypFrame*;
|
||||
bool isEof();
|
||||
|
||||
void writeFrame();
|
||||
void writeFrame( CalypFrame* pcFrame );
|
||||
|
||||
bool saveFrame( const ClpString& filename );
|
||||
static bool saveFrame( const ClpString& filename, CalypFrame* saveFrame );
|
||||
|
||||
CalypFrame* getCurrFrame( CalypFrame* ) const;
|
||||
|
||||
// continuous read control
|
||||
bool setNextFrame();
|
||||
void readNextFrame();
|
||||
void readNextFrameFillRGBBuffer();
|
||||
|
||||
void writeFrame( const CalypFrame& pcFrame );
|
||||
|
||||
bool saveFrame( const std::string& filename );
|
||||
static bool saveFrame( const std::string& filename, const CalypFrame& saveFrame );
|
||||
CalypFrame* getCurrFrame() const;
|
||||
|
||||
bool seekInputRelative( bool bIsFoward );
|
||||
bool seekInput( unsigned long new_frame_num );
|
||||
|
||||
void getDuration( int* duration_array ) const;
|
||||
|
||||
private:
|
||||
class CalypStreamPrivate;
|
||||
std::unique_ptr<CalypStreamPrivate> d;
|
||||
bool readFrame( CalypFrame* frame );
|
||||
|
||||
private:
|
||||
struct CalypStreamPrivate* d;
|
||||
};
|
||||
|
||||
#endif // __CALYPSTREAM_H__
|
||||
+47
-44
@@ -25,9 +25,6 @@
|
||||
#ifndef __CALYPSTREAMHANDLERIF_H__
|
||||
#define __CALYPSTREAMHANDLERIF_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypStream.h"
|
||||
|
||||
#define INI_REGIST_CALYP_SUPPORTED_FMT \
|
||||
@@ -52,11 +49,12 @@
|
||||
formatsList.insert( formatsList.end(), new_fmts.begin(), new_fmts.end() ); \
|
||||
}
|
||||
|
||||
#define REGISTER_CALYP_STREAM_HANDLER( X ) \
|
||||
public: \
|
||||
static std::unique_ptr<CalypStreamHandlerIf> Create() { return std::make_unique<X>(); } \
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats(); \
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats(); \
|
||||
#define REGISTER_CALYP_STREAM_HANDLER( X ) \
|
||||
public: \
|
||||
static CalypStreamHandlerIf* Create() { return new X(); } \
|
||||
void Delete() { delete this; } \
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats(); \
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats(); \
|
||||
// static int checkforSupportedFile( String, bool );
|
||||
|
||||
/**
|
||||
@@ -69,51 +67,56 @@ class CalypStreamHandlerIf
|
||||
friend class CalypStream;
|
||||
|
||||
public:
|
||||
CalypStreamHandlerIf()
|
||||
: m_bIsInput( true )
|
||||
, m_bNative( true )
|
||||
, m_uiWidth( 0 )
|
||||
, m_uiHeight( 0 )
|
||||
, m_iPixelFormat( -1 )
|
||||
, m_uiBitsPerPixel( 8 )
|
||||
, m_iEndianness( -1 )
|
||||
, m_dFrameRate( 30 )
|
||||
, m_uiCurrFrameFileIdx( 0 )
|
||||
, m_uiTotalNumberFrames( 0 )
|
||||
, m_pStreamBuffer( NULL )
|
||||
, m_uiNBytesPerFrame( 0 )
|
||||
, m_isEOF( false )
|
||||
{
|
||||
}
|
||||
virtual ~CalypStreamHandlerIf() {}
|
||||
virtual void Delete() = 0;
|
||||
|
||||
virtual bool openHandler( std::string strFilename, bool bInput ) = 0;
|
||||
virtual bool openHandler( ClpString strFilename, bool bInput ) = 0;
|
||||
virtual void closeHandler() = 0;
|
||||
virtual bool configureBuffer( const CalypFrame& pcFrame ) = 0;
|
||||
virtual bool seek( std::uint64_t iFrameNum ) = 0;
|
||||
virtual bool read( CalypFrame& pcFrame ) = 0;
|
||||
virtual bool write( const CalypFrame& pcFrame ) = 0;
|
||||
virtual bool configureBuffer( CalypFrame* pcFrame ) = 0;
|
||||
virtual bool seek( ClpULong iFrameNum ) = 0;
|
||||
virtual bool read( CalypFrame* pcFrame ) = 0;
|
||||
virtual bool write( CalypFrame* pcFrame ) = 0;
|
||||
|
||||
virtual void calculateFrameNumber(){};
|
||||
|
||||
std::string getFormatName()
|
||||
{
|
||||
return m_strFormatName;
|
||||
}
|
||||
std::string getCodecName()
|
||||
{
|
||||
return m_strCodecName;
|
||||
}
|
||||
ClpString getFormatName() { return m_strFormatName; }
|
||||
ClpString getCodecName() { return m_strCodecName; }
|
||||
|
||||
protected:
|
||||
CalypStreamHandlerIf() = default;
|
||||
CalypStreamHandlerIf( bool supportsFormats )
|
||||
: m_bSupportsFormat{ supportsFormats }
|
||||
{
|
||||
}
|
||||
const char* m_pchHandlerName;
|
||||
|
||||
const char* m_pchHandlerName{ "" };
|
||||
const bool m_bSupportsFormat{ false };
|
||||
|
||||
std::string m_strFormatName;
|
||||
std::string m_strCodecName;
|
||||
bool m_bIsInput{ true };
|
||||
bool m_bNative{ true };
|
||||
unsigned int m_uiWidth{ 0 };
|
||||
unsigned int m_uiHeight{ 0 };
|
||||
ClpPixelFormats m_iPixelFormat{ ClpPixelFormats::Invalid };
|
||||
unsigned int m_uiBitsPerPixel{ 8 };
|
||||
int m_iEndianness{ CLP_INVALID_ENDIANESS };
|
||||
double m_dFrameRate{ 30 };
|
||||
std::uint64_t m_uiCurrFrameFileIdx{ 0 };
|
||||
std::uint64_t m_uiTotalNumberFrames{ 0 };
|
||||
std::vector<ClpByte> m_pStreamBuffer;
|
||||
std::uint64_t m_uiNBytesPerFrame{ 0 };
|
||||
bool m_isEOF{ false };
|
||||
ClpString m_strFormatName;
|
||||
ClpString m_strCodecName;
|
||||
bool m_bIsInput;
|
||||
bool m_bNative;
|
||||
ClpString m_cFilename;
|
||||
unsigned int m_uiWidth;
|
||||
unsigned int m_uiHeight;
|
||||
int m_iPixelFormat;
|
||||
unsigned int m_uiBitsPerPixel;
|
||||
int m_iEndianness;
|
||||
double m_dFrameRate;
|
||||
ClpULong m_uiCurrFrameFileIdx;
|
||||
ClpULong m_uiTotalNumberFrames;
|
||||
ClpByte* m_pStreamBuffer;
|
||||
ClpULong m_uiNBytesPerFrame;
|
||||
bool m_isEOF;
|
||||
};
|
||||
|
||||
#endif // __CALYPSTREAMHANDLERIF_H__
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
/* 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 LibMemory.cpp
|
||||
* \ingroup CalypLib
|
||||
* \brief Memory allocation functions
|
||||
*/
|
||||
|
||||
#ifndef __LIBMEMORY_H__
|
||||
#define __LIBMEMORY_H__
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free
|
||||
#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
|
||||
#define xMalloc( len ) _aligned_malloc( len, 32 )
|
||||
#define xFreeMem( ptr ) _aligned_free( ptr )
|
||||
#else
|
||||
#define xMalloc( len ) malloc( len )
|
||||
#define xFreeMem( ptr ) free( ptr )
|
||||
#endif
|
||||
#define xMemSet( type, len, ptr ) memset( ptr, 0, ( len ) * sizeof( type ) )
|
||||
|
||||
static inline void* xMallocMem( size_t nitems )
|
||||
{
|
||||
void* d;
|
||||
if( ( d = xMalloc( nitems ) ) == NULL )
|
||||
{
|
||||
printf( "malloc failed.\n" );
|
||||
return NULL;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
{
|
||||
size_t padded_size = nitems * size;
|
||||
void* d = xMallocMem( padded_size );
|
||||
if( d )
|
||||
memset( d, 0, (int)padded_size );
|
||||
return d;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem1D( T** array1D, int dim0 )
|
||||
{
|
||||
if( ( *array1D = (T*)xCallocMem( dim0, sizeof( T ) ) ) == NULL )
|
||||
return 0;
|
||||
|
||||
return ( sizeof( T* ) + dim0 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem2D( T*** array2D, int dim0, int dim1 )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( ( *array2D = (T**)xMallocMem( dim0 * sizeof( T* ) ) ) == NULL )
|
||||
printf( "get_mem2Dint: array2D" );
|
||||
if( ( *( *array2D ) = (T*)xCallocMem( dim0 * dim1, sizeof( T ) ) ) == NULL )
|
||||
printf( "get_mem2Dint: array2D" );
|
||||
|
||||
for( i = 1; i < dim0; i++ )
|
||||
( *array2D )[i] = ( *array2D )[i - 1] + dim1;
|
||||
|
||||
return dim0 * ( sizeof( T* ) + dim1 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem3D( T**** array3D, int dim0, int dim1, int dim2 )
|
||||
{
|
||||
int i, mem_size = dim0 * sizeof( T** );
|
||||
|
||||
if( ( ( *array3D ) = (T***)xMallocMem( dim0 * sizeof( T** ) ) ) == NULL )
|
||||
printf( "get_mem3Dint: array3D" );
|
||||
|
||||
mem_size += getMem2D( *array3D, dim0 * dim1, dim2 );
|
||||
|
||||
for( i = 1; i < dim0; i++ )
|
||||
( *array3D )[i] = ( *array3D )[i - 1] + dim1;
|
||||
|
||||
return mem_size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem2D( T**& array2D )
|
||||
{
|
||||
if( *array2D )
|
||||
{
|
||||
if( *array2D )
|
||||
xFreeMem( *array2D );
|
||||
else
|
||||
printf( "free_mem2Dint: trying to free unused memory" );
|
||||
|
||||
xFreeMem( array2D );
|
||||
array2D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem2Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem3D( T***& array3D )
|
||||
{
|
||||
if( array3D )
|
||||
{
|
||||
freeMem2D( *array3D );
|
||||
xFreeMem( array3D );
|
||||
array3D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem3Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __LIBMEMORY_H__
|
||||
+22
-21
@@ -25,6 +25,7 @@
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_FFMPEG
|
||||
#include "StreamHandlerLibav.h"
|
||||
@@ -43,11 +44,11 @@
|
||||
#define ADD_FFMPEG_PEL_FMT( fmt ) 0
|
||||
#endif
|
||||
|
||||
const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap = {
|
||||
{
|
||||
ClpPixelFormats::YUV420p,
|
||||
CLP_YUV420P,
|
||||
{
|
||||
"YUV420p"sv,
|
||||
"YUV420p",
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -62,9 +63,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::YUV422p,
|
||||
CLP_YUV422P,
|
||||
{
|
||||
"YUV422p"sv,
|
||||
"YUV422p",
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -79,9 +80,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::YUV444p,
|
||||
CLP_YUV444P,
|
||||
{
|
||||
"YUV444p"sv,
|
||||
"YUV444p",
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
3,
|
||||
@@ -96,9 +97,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::YUYV422,
|
||||
CLP_YUYV422,
|
||||
{
|
||||
"YUYV422"sv,
|
||||
"YUYV422",
|
||||
CLP_COLOR_YUV,
|
||||
3,
|
||||
1,
|
||||
@@ -113,9 +114,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::Gray,
|
||||
CLP_GRAY,
|
||||
{
|
||||
"GRAY"sv,
|
||||
"GRAY",
|
||||
CLP_COLOR_GRAY,
|
||||
1,
|
||||
1,
|
||||
@@ -126,9 +127,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::RGB24p,
|
||||
CLP_RGB24P,
|
||||
{
|
||||
"RGBp"sv,
|
||||
"RGBp",
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
3,
|
||||
@@ -143,9 +144,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::RGB24,
|
||||
CLP_RGB24,
|
||||
{
|
||||
"RGB"sv,
|
||||
"RGB",
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
@@ -160,9 +161,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::BGR24,
|
||||
CLP_BGR24,
|
||||
{
|
||||
"BGR"sv,
|
||||
"BGR",
|
||||
CLP_COLOR_RGB,
|
||||
3,
|
||||
1,
|
||||
@@ -177,9 +178,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::RGBA32,
|
||||
CLP_RGBA32,
|
||||
{
|
||||
"RGBA"sv,
|
||||
"RGBA",
|
||||
CLP_COLOR_RGBA,
|
||||
4,
|
||||
1,
|
||||
@@ -195,9 +196,9 @@ const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescrip
|
||||
},
|
||||
},
|
||||
{
|
||||
ClpPixelFormats::BGRA32,
|
||||
CLP_BGRA32,
|
||||
{
|
||||
"BGRA"sv,
|
||||
"BGRA",
|
||||
CLP_COLOR_RGBA,
|
||||
4,
|
||||
1,
|
||||
|
||||
+12
-19
@@ -29,21 +29,11 @@
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
using namespace std::string_view_literals;
|
||||
#define CHROMA_RESAMPLING( X ) ( ( ( X + 1 ) >> 1 ) << 1 )
|
||||
|
||||
template <typename T>
|
||||
inline constexpr T CHROMA_RESAMPLING( T in )
|
||||
{
|
||||
return ( ( ( in + 1 ) >> 1 ) << 1 );
|
||||
}
|
||||
#define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE )
|
||||
|
||||
template <typename T, typename R>
|
||||
inline constexpr T CHROMARATIO( T size, R ratio )
|
||||
{
|
||||
return ( ratio > 1 ? ( ( size + 1 ) / ratio ) : size );
|
||||
}
|
||||
|
||||
struct CalypComponentDescriptor
|
||||
typedef struct CalypComponentDescriptor
|
||||
{
|
||||
/**
|
||||
* Which of the 4 planes contains the component.
|
||||
@@ -61,7 +51,8 @@ struct CalypComponentDescriptor
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
unsigned short offset_plus1;
|
||||
};
|
||||
|
||||
} CalypComponentDescriptor;
|
||||
|
||||
/**
|
||||
* Descriptor that unambiguously describes how the bits of a pixel are
|
||||
@@ -72,9 +63,9 @@ struct CalypComponentDescriptor
|
||||
* and all the YUV variants) AVPixFmtDescriptor just stores how values
|
||||
* are stored not what these values represent.
|
||||
*/
|
||||
struct CalypPixelFormatDescriptor
|
||||
typedef struct CalypPixelFormatDescriptor
|
||||
{
|
||||
std::string_view name;
|
||||
const char* name;
|
||||
|
||||
int colorSpace;
|
||||
|
||||
@@ -111,9 +102,11 @@ struct CalypPixelFormatDescriptor
|
||||
* otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
|
||||
*/
|
||||
CalypComponentDescriptor comp[4];
|
||||
};
|
||||
|
||||
static constexpr std::size_t kNumberOfPixelFormats{ 10 };
|
||||
extern const std::map<ClpPixelFormats, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap;
|
||||
} CalypPixelFormatDescriptor;
|
||||
|
||||
#define MAX_NUMBER_PLANES 3
|
||||
|
||||
extern const std::map<int, CalypPixelFormatDescriptor> g_CalypPixFmtDescriptorsMap;
|
||||
|
||||
#endif // __PIXELFORMATS_H__
|
||||
+59
-55
@@ -28,6 +28,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#if( ( LIBAVCODEC_VERSION_MAJOR > 57 ) || ( LIBAVCODEC_VERSION_MAJOR == 57 ) && ( LIBAVCODEC_VERSION_MINOR >= 37 ) )
|
||||
@@ -35,10 +36,6 @@
|
||||
#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;
|
||||
@@ -67,7 +64,7 @@ StreamHandlerLibav::StreamHandlerLibav()
|
||||
m_pchHandlerName = "FFmpeg";
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
bool StreamHandlerLibav::openHandler( ClpString strFilename, bool bInput )
|
||||
{
|
||||
const char* filename = strFilename.c_str();
|
||||
|
||||
@@ -94,7 +91,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
// }
|
||||
|
||||
// Register all components of FFmpeg
|
||||
// av_register_all();
|
||||
av_register_all();
|
||||
|
||||
/* open input file, and allocate format context */
|
||||
if( avformat_open_input( &m_cFmtCtx, filename, NULL, NULL ) < 0 )
|
||||
@@ -127,7 +124,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
#else
|
||||
int codecId = m_cStream->codec->codec_id;
|
||||
#endif
|
||||
auto* dec = avcodec_find_decoder( AVCodecID( codecId ) );
|
||||
AVCodec* dec = avcodec_find_decoder( AVCodecID( codecId ) );
|
||||
if( !dec )
|
||||
{
|
||||
std::cout << "Failed to find video coded" << std::endl;
|
||||
@@ -154,7 +151,7 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
if( avcodec_open2( m_cCodedCtx, dec, NULL ) < 0 )
|
||||
{
|
||||
std::cout << "Failed to open video codec" << std::endl;
|
||||
std::cout << "Failed to open video coded" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,8 +173,8 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
m_uiBitsPerPixel = 8;
|
||||
|
||||
/**
|
||||
* Auxiliar conversation to re-use similar pixfmt
|
||||
*/
|
||||
* Auxiliar conversation to re-use similar pixfmt
|
||||
*/
|
||||
int auxPixFmt = m_ffPixFmt;
|
||||
switch( m_ffPixFmt )
|
||||
{
|
||||
@@ -201,14 +198,20 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
auxPixFmt = AV_PIX_FMT_GRAY8;
|
||||
}
|
||||
|
||||
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; } );
|
||||
if( found_fmt != g_CalypPixFmtDescriptorsMap.end() )
|
||||
m_iPixelFormat = CLP_INVALID_FMT;
|
||||
for( int i = 0; i < CalypFrame::numberOfFormats(); i++ )
|
||||
{
|
||||
m_bNative = true;
|
||||
m_iPixelFormat = found_fmt->first;
|
||||
if( g_CalypPixFmtDescriptorsMap.at( i ).ffmpegPelFormat == auxPixFmt )
|
||||
{
|
||||
m_iPixelFormat = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( m_iPixelFormat == CLP_INVALID_FMT )
|
||||
{
|
||||
m_bNative = false;
|
||||
//throw CalypFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" );
|
||||
//return false;
|
||||
}
|
||||
|
||||
double fr = 30;
|
||||
@@ -247,34 +250,35 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
if( !m_bNative )
|
||||
{
|
||||
ClpPixelFormats newPelFmt{ ClpPixelFormats::Invalid };
|
||||
int newPelFmt = -1;
|
||||
const AVPixFmtDescriptor* ffPelDesc = av_pix_fmt_desc_get( AVPixelFormat( m_ffPixFmt ) );
|
||||
if( ffPelDesc->flags & AV_PIX_FMT_FLAG_PAL )
|
||||
{
|
||||
newPelFmt = ClpPixelFormats::RGB24;
|
||||
newPelFmt = CLP_RGB24;
|
||||
}
|
||||
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_ALPHA )
|
||||
{
|
||||
newPelFmt = ClpPixelFormats::RGBA32;
|
||||
newPelFmt = CLP_RGBA32;
|
||||
}
|
||||
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_RGB )
|
||||
{
|
||||
newPelFmt = ClpPixelFormats::RGB24;
|
||||
newPelFmt = CLP_RGB24;
|
||||
}
|
||||
else if( ffPelDesc->nb_components == 1 )
|
||||
{
|
||||
newPelFmt = ClpPixelFormats::Gray;
|
||||
newPelFmt = CLP_GRAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
newPelFmt = ClpPixelFormats::YUV444p;
|
||||
newPelFmt = CLP_YUV444P;
|
||||
}
|
||||
m_iPixelFormat = newPelFmt;
|
||||
|
||||
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();
|
||||
@@ -284,9 +288,8 @@ bool StreamHandlerLibav::openHandler( std::string strFilename, bool bInput )
|
||||
return false;
|
||||
}
|
||||
|
||||
auto alloc_error =
|
||||
av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize, m_uiWidth, m_uiHeight, newAvFmt, 16 );
|
||||
if( alloc_error < 0 )
|
||||
if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize,
|
||||
m_uiWidth, m_uiHeight, newAvFmt, 16 ) < 0 )
|
||||
{
|
||||
closeHandler();
|
||||
return false;
|
||||
@@ -298,10 +301,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 */
|
||||
m_cPacket = av_packet_alloc();
|
||||
m_cPacket->data = NULL;
|
||||
m_cPacket->size = 0;
|
||||
m_cOrgPacket = *m_cPacket;
|
||||
av_init_packet( &m_cPacket );
|
||||
m_cPacket.data = NULL;
|
||||
m_cPacket.size = 0;
|
||||
m_cOrgPacket = m_cPacket;
|
||||
|
||||
m_bHasStream = true;
|
||||
return true;
|
||||
@@ -318,20 +321,21 @@ void StreamHandlerLibav::closeHandler()
|
||||
avformat_close_input( &m_cFmtCtx );
|
||||
|
||||
av_free( m_cFrame );
|
||||
av_packet_free( &m_cPacket );
|
||||
}
|
||||
m_bHasStream = false;
|
||||
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::configureBuffer( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerLibav::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
m_pStreamBuffer.resize( pcFrame.getBytesPerFrame() );
|
||||
return true;
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
void StreamHandlerLibav::calculateFrameNumber()
|
||||
{
|
||||
std::uint64_t num_frames;
|
||||
ClpULong num_frames;
|
||||
/*if( m_cStream->nb_frames )
|
||||
{
|
||||
num_frames = m_cStream->nb_frames;
|
||||
@@ -352,7 +356,7 @@ void StreamHandlerLibav::calculateFrameNumber()
|
||||
m_uiTotalNumberFrames = num_frames;
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
bool StreamHandlerLibav::read( CalypFrame* pcFrame )
|
||||
{
|
||||
int bGotFrame = 0;
|
||||
bool bErrors = false;
|
||||
@@ -368,21 +372,21 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
bReadPkt = true;
|
||||
else
|
||||
return false;
|
||||
// if( iRet == AVERROR_EOF )
|
||||
// m_isEOF = true;
|
||||
//if( iRet == AVERROR_EOF )
|
||||
// m_isEOF = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 );
|
||||
@@ -395,7 +399,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 )
|
||||
{
|
||||
@@ -404,10 +408,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
|
||||
}
|
||||
@@ -418,27 +422,27 @@ 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, m_uiFrameBufferSize, decFrame->data,
|
||||
decFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
|
||||
|
||||
pcFrame.frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
m_uiCurrFrameFileIdx++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::write( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerLibav::write( CalypFrame* pcFrame )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::seek( std::uint64_t iFrameNum )
|
||||
bool StreamHandlerLibav::seek( ClpULong iFrameNum )
|
||||
{
|
||||
if( m_uiTotalNumberFrames == 1 )
|
||||
return true;
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
@@ -64,13 +63,13 @@ class StreamHandlerLibav : public CalypStreamHandlerIf
|
||||
public:
|
||||
StreamHandlerLibav();
|
||||
~StreamHandlerLibav() {}
|
||||
bool openHandler( std::string strFilename, bool bInput );
|
||||
bool openHandler( ClpString strFilename, bool bInput );
|
||||
void closeHandler();
|
||||
bool configureBuffer( const CalypFrame& pcFrame );
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
void calculateFrameNumber();
|
||||
bool seek( std::uint64_t iFrameNum );
|
||||
bool read( CalypFrame& pcFrame );
|
||||
bool write( const CalypFrame& pcFrame );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
|
||||
unsigned int getStreamDuration() { return m_uiSecs; }
|
||||
unsigned char* m_pchFrameBuffer;
|
||||
@@ -88,7 +87,7 @@ private:
|
||||
int m_ffPixFmt;
|
||||
AVFrame* m_cFrame;
|
||||
AVPacket m_cOrgPacket;
|
||||
AVPacket* m_cPacket;
|
||||
AVPacket m_cPacket;
|
||||
|
||||
bool m_bHasStream;
|
||||
|
||||
|
||||
+25
-26
@@ -28,8 +28,7 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#include "LibMemory.h"
|
||||
#if CV_MAJOR_VERSION >= 3
|
||||
#include <opencv2/videoio.hpp>
|
||||
#endif
|
||||
@@ -62,32 +61,32 @@ std::vector<CalypStreamFormat> StreamHandlerOpenCV::supportedWriteFormats()
|
||||
StreamHandlerOpenCV::StreamHandlerOpenCV()
|
||||
{
|
||||
m_pchHandlerName = "OpenCV";
|
||||
m_pcVideoCapture = NULL;
|
||||
pcVideoCapture = NULL;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
bool StreamHandlerOpenCV::openHandler( ClpString strFilename, bool bInput )
|
||||
{
|
||||
m_cFilename = std::move( strFilename );
|
||||
m_cFilename = strFilename;
|
||||
if( bInput )
|
||||
{
|
||||
#if( CV_VERSION_MAJOR >= 3 )
|
||||
/*
|
||||
* Special filename to handle webcam input
|
||||
*/
|
||||
if( m_cFilename.find( "/dev/video" ) != std::string::npos )
|
||||
if( m_cFilename.find( "/dev/video" ) != ClpString::npos )
|
||||
{
|
||||
int iDeviceId = 0;
|
||||
if( m_cFilename.find( "/dev/video0" ) != std::string::npos )
|
||||
if( m_cFilename.find( "/dev/video0" ) != ClpString::npos )
|
||||
iDeviceId = 0;
|
||||
else if( m_cFilename.find( "/dev/video1" ) != std::string::npos )
|
||||
else if( m_cFilename.find( "/dev/video1" ) != ClpString::npos )
|
||||
iDeviceId = 1;
|
||||
|
||||
m_strFormatName = "DEV";
|
||||
m_strCodecName = "Raw Video";
|
||||
m_pcVideoCapture = new VideoCapture( iDeviceId );
|
||||
pcVideoCapture = new VideoCapture( iDeviceId );
|
||||
#if CV_MAJOR_VERSION >= 4
|
||||
m_uiWidth = m_pcVideoCapture->get( cv::CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = m_pcVideoCapture->get( cv::CAP_PROP_FRAME_HEIGHT );
|
||||
m_uiWidth = pcVideoCapture->get( cv::CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( cv::CAP_PROP_FRAME_HEIGHT );
|
||||
#else
|
||||
m_uiWidth = pcVideoCapture->get( CV_CAP_PROP_FRAME_WIDTH );
|
||||
m_uiHeight = pcVideoCapture->get( CV_CAP_PROP_FRAME_HEIGHT );
|
||||
@@ -105,10 +104,10 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
m_dFrameRate = 1;
|
||||
}
|
||||
m_uiBitsPerPixel = 8;
|
||||
m_iPixelFormat = ClpPixelFormats::BGR24;
|
||||
m_iPixelFormat = CalypFrame::findPixelFormat( "BGR" );
|
||||
|
||||
m_uiTotalNumberFrames = 1;
|
||||
if( m_pcVideoCapture )
|
||||
if( pcVideoCapture )
|
||||
{
|
||||
m_uiTotalNumberFrames = 2;
|
||||
}
|
||||
@@ -119,50 +118,50 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
|
||||
void StreamHandlerOpenCV::closeHandler()
|
||||
{
|
||||
if( m_pcVideoCapture )
|
||||
if( pcVideoCapture )
|
||||
{
|
||||
m_pcVideoCapture->release();
|
||||
delete m_pcVideoCapture;
|
||||
m_pcVideoCapture = NULL;
|
||||
pcVideoCapture->release();
|
||||
delete pcVideoCapture;
|
||||
pcVideoCapture = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::configureBuffer( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerOpenCV::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::seek( std::uint64_t iFrameNum )
|
||||
bool StreamHandlerOpenCV::seek( ClpULong iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::read( CalypFrame& pcFrame )
|
||||
bool StreamHandlerOpenCV::read( CalypFrame* pcFrame )
|
||||
{
|
||||
bool bRet = false;
|
||||
if( m_pcVideoCapture )
|
||||
if( pcVideoCapture )
|
||||
{
|
||||
Mat cvMat;
|
||||
bRet = m_pcVideoCapture->read( cvMat );
|
||||
bRet = pcVideoCapture->read( cvMat );
|
||||
if( bRet )
|
||||
bRet = pcFrame.fromMat( cvMat );
|
||||
bRet = pcFrame->fromMat( cvMat );
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat cvMat = cv::imread( m_cFilename );
|
||||
bRet = pcFrame.fromMat( cvMat );
|
||||
bRet = pcFrame->fromMat( cvMat );
|
||||
}
|
||||
if( bRet )
|
||||
m_uiCurrFrameFileIdx++;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::write( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerOpenCV::write( CalypFrame* pcFrame )
|
||||
{
|
||||
bool bRet = false;
|
||||
Mat cvFrame;
|
||||
bRet = pcFrame.toMat( cvFrame, false, true );
|
||||
bRet = pcFrame->toMat( cvFrame, false, true );
|
||||
if( !bRet )
|
||||
return bRet;
|
||||
bRet = cv::imwrite( m_cFilename, cvFrame );
|
||||
|
||||
@@ -40,16 +40,15 @@ class StreamHandlerOpenCV : public CalypStreamHandlerIf
|
||||
public:
|
||||
StreamHandlerOpenCV();
|
||||
~StreamHandlerOpenCV() {}
|
||||
bool openHandler( std::string strFilename, bool bInput );
|
||||
bool openHandler( ClpString strFilename, bool bInput );
|
||||
void closeHandler();
|
||||
bool configureBuffer( const CalypFrame& pcFrame );
|
||||
bool seek( std::uint64_t iFrameNum );
|
||||
bool read( CalypFrame& pcFrame );
|
||||
bool write( const CalypFrame& pcFrame );
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
|
||||
private:
|
||||
std::string m_cFilename;
|
||||
cv::VideoCapture* m_pcVideoCapture;
|
||||
cv::VideoCapture* pcVideoCapture;
|
||||
};
|
||||
|
||||
#endif // __STREAMHANDLEROPENCV_H__
|
||||
Loaded 100 of 184 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user