Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e8dfc2e3d | ||
|
|
0280200a82 | ||
|
|
d29f8ea215 | ||
|
|
2d8476e875 | ||
|
|
32f803ada9 | ||
|
|
63eb742f64 | ||
|
|
72ef7deda6 |
No files matched your search
+6
-6
@@ -1,4 +1,4 @@
|
||||
image: Visual Studio 2019
|
||||
image: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform:
|
||||
- x64
|
||||
@@ -16,7 +16,7 @@ init:
|
||||
- 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'
|
||||
@@ -32,10 +32,10 @@ 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 -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 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)
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
---
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-pointer-arithmetic'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
FormatStyle: none
|
||||
CheckOptions:
|
||||
- key: llvm-else-after-return.WarnOnConditionVariables
|
||||
value: '0'
|
||||
- key: modernize-loop-convert.MinConfidence
|
||||
value: reasonable
|
||||
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||
value: llvm
|
||||
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
|
||||
value: '0'
|
||||
- key: google-readability-namespace-comments.ShortNamespaceLines
|
||||
value: '10'
|
||||
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
|
||||
value: '0'
|
||||
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||
value: '1'
|
||||
- key: cert-dcl16-c.NewSuffixes
|
||||
value: 'L;LL;LU;LLU'
|
||||
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||
value: '1'
|
||||
- key: modernize-pass-by-value.IncludeStyle
|
||||
value: llvm
|
||||
- key: google-readability-namespace-comments.SpacesBeforeComments
|
||||
value: '2'
|
||||
- key: modernize-loop-convert.MaxCopySize
|
||||
value: '16'
|
||||
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
|
||||
value: '1'
|
||||
- key: modernize-use-nullptr.NullMacros
|
||||
value: 'NULL'
|
||||
- key: llvm-qualified-auto.AddConstToQualified
|
||||
value: '0'
|
||||
- key: modernize-loop-convert.NamingStyle
|
||||
value: CamelCase
|
||||
- key: llvm-else-after-return.WarnOnUnfixable
|
||||
value: '0'
|
||||
- key: google-readability-function-size.StatementThreshold
|
||||
value: '800'
|
||||
@@ -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,37 +0,0 @@
|
||||
name: Build on Linux
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- devel
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# The CMake configure and build commands are platform agnostic and should work equally
|
||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||
# cross-platform coverage.
|
||||
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install gcc-10 g++-10 cmake qtbase5-dev libavcodec-dev libavformat-dev libavutil-dev libopencv-dev libopencv-video-dev libopencv-contrib-dev
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Configure CMake
|
||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||
run: cmake -B ${{github.workspace}}/build -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_WERROR=ON
|
||||
|
||||
- name: Build
|
||||
# Build your program with the given configuration
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
|
||||
@@ -144,6 +144,3 @@ doc/
|
||||
|
||||
# CLang
|
||||
compile_commands.json
|
||||
|
||||
# Build dirs
|
||||
build*
|
||||
+10
-12
@@ -1,18 +1,6 @@
|
||||
fail_fast: false
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||
rev: v0.6.10
|
||||
hooks:
|
||||
- id: cmake-format
|
||||
- id: cmake-lint
|
||||
|
||||
- repo: https://github.com/pocc/pre-commit-hooks
|
||||
rev: v1.1.1
|
||||
hooks:
|
||||
- id: clang-format
|
||||
args: [--style=file, -i]
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: cmake-configure
|
||||
@@ -26,4 +14,14 @@ repos:
|
||||
pass_filenames: false
|
||||
language: system
|
||||
|
||||
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
||||
rev: v0.6.10
|
||||
hooks:
|
||||
- id: cmake-format
|
||||
- id: cmake-lint
|
||||
|
||||
- repo: https://github.com/pocc/pre-commit-hooks
|
||||
rev: v1.1.1
|
||||
hooks:
|
||||
- id: clang-format
|
||||
args: [--style=file, -i]
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
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
|
||||
|
||||
+39
-60
@@ -17,9 +17,9 @@ SET(PROJECT_LIBRARY
|
||||
CACHE INTERNAL "" FORCE
|
||||
)
|
||||
|
||||
SET(CALYP_VERSION_MAJOR "2")
|
||||
SET(CALYP_VERSION_MINOR "0")
|
||||
SET(CALYP_VERSION_PATCH "1")
|
||||
SET(CALYP_VERSION_MAJOR "1")
|
||||
SET(CALYP_VERSION_MINOR "2")
|
||||
SET(CALYP_VERSION_PATCH "0")
|
||||
SET(CALYP_VERSION
|
||||
"${CALYP_VERSION_MAJOR}.${CALYP_VERSION_MINOR}.${CALYP_VERSION_PATCH}"
|
||||
CACHE INTERNAL "" FORCE
|
||||
@@ -48,16 +48,14 @@ OPTION(BUILD_TOOLS "Build Command Line Application" ON)
|
||||
OPTION(BUILD_EXAMPLES "Build Examples" OFF)
|
||||
OPTION(BUILD_DOC "Build Documentation" OFF)
|
||||
OPTION(BUILD_TESTS "Build Google Tests" OFF)
|
||||
OPTION(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
|
||||
OPTION(BUILD_WITH_THREAD_SANITIZER "Build with thread sanitizer" OFF)
|
||||
OPTION(BUILD_TESTS_CATCH2 "Build Catch2 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
|
||||
@@ -115,41 +113,27 @@ SET_PACKAGE_PROPERTIES(
|
||||
)
|
||||
|
||||
IF(BUILD_TESTS)
|
||||
INCLUDE(FetchContent)
|
||||
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_MAKEAVAILABLE(googletest)
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
googletest PROPERTIES
|
||||
URL "https://github.com/google/googletest"
|
||||
DESCRIPTION "Google unit tests"
|
||||
TYPE OPTIONAL
|
||||
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()
|
||||
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.1
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(Catch2)
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
FIND_PACKAGE(Catch2 REQUIRED)
|
||||
ENABLE_TESTING()
|
||||
SET_PACKAGE_PROPERTIES(
|
||||
Catch2 PROPERTIES
|
||||
URL "https://github.com/catchorg/Catch2"
|
||||
DESCRIPTION "Catch2 unit tests"
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake)
|
||||
INCLUDE(CTest)
|
||||
ENABLE_TESTING()
|
||||
|
||||
SET(CALYP_TEST_DATA_DIR
|
||||
"CALYP_TEST_DATA_DIR"
|
||||
CACHE PATH "Location of video information for testing"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
OPTION(USE_OPENCV "Add OpenCV support" ON)
|
||||
@@ -217,16 +201,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)
|
||||
@@ -234,26 +211,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")
|
||||
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_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Configure targets
|
||||
@@ -266,10 +248,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
|
||||
```
|
||||
+5
-28
@@ -3,14 +3,12 @@
|
||||
#
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/dialog
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/docks ${CMAKE_CURRENT_SOURCE_DIR}/widgets
|
||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/dialog ${CMAKE_CURRENT_SOURCE_DIR}/docks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/widgets
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
ADD_SUBDIRECTORY(external)
|
||||
|
||||
@@ -36,14 +34,6 @@ IF(USE_QTDBUS)
|
||||
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_SRCS
|
||||
# Main
|
||||
main.cpp
|
||||
@@ -53,7 +43,6 @@ SET(Calyp_App_SRCS
|
||||
MdiSubWindow.cpp
|
||||
SubWindowAbstract.cpp
|
||||
# Module Video
|
||||
ResourceHandle.cpp
|
||||
VideoHandle.cpp
|
||||
VideoSubWindow.cpp
|
||||
ViewArea.cpp
|
||||
@@ -61,6 +50,7 @@ SET(Calyp_App_SRCS
|
||||
# Module Quality
|
||||
QualityHandle.cpp
|
||||
PlotSubWindow.cpp
|
||||
external/qcustomplot/qcustomplot.cpp
|
||||
# Module Plugins
|
||||
ModulesHandle.cpp
|
||||
CalypAppModuleIf.cpp
|
||||
@@ -134,10 +124,6 @@ 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)
|
||||
@@ -156,18 +142,9 @@ IF(WIN32)
|
||||
COMMENT "Add icon on windows platform"
|
||||
)
|
||||
ENDIF()
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${WINDOWS_RES_FILE})
|
||||
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_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC} ${APP_ICON_MACOSX})
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(${PROJECT_NAME} ${Calyp_App_SRCS} ${HEADERS_MOC_FILES} ${Calyp_App_UI_Wrap} ${Calyp_App_RCC})
|
||||
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} )
|
||||
|
||||
+97
-122
@@ -28,52 +28,27 @@
|
||||
#include <QApplication>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "ModuleHandleDock.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();
|
||||
}
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
auto* ptr = m_pcDisplaySubWindow;
|
||||
m_pcDisplaySubWindow = NULL;
|
||||
ptr->closeSubWindow();
|
||||
}
|
||||
if( m_pcDockWidget )
|
||||
{
|
||||
m_pcDockWidget->close();
|
||||
}
|
||||
if( m_pcModule )
|
||||
{
|
||||
m_pcModule->destroy();
|
||||
m_pcModule = nullptr;
|
||||
m_pcSubWindow[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::update( bool isPlaying )
|
||||
void CalypAppModuleIf::update()
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
@@ -81,15 +56,7 @@ void CalypAppModuleIf::update( bool isPlaying )
|
||||
}
|
||||
else
|
||||
{
|
||||
apply( isPlaying );
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::setPlaying( bool isPlaying )
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
m_pcDisplaySubWindow->setPlaying( isPlaying );
|
||||
apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,19 +69,11 @@ bool CalypAppModuleIf::isRunning()
|
||||
#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;
|
||||
bool bRet = false;
|
||||
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
if( m_pcModule->m_iModuleType == CLP_FRAME_PROCESSING_MODULE )
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
@@ -128,17 +87,6 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
}
|
||||
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 )
|
||||
{
|
||||
@@ -148,52 +96,49 @@ bool CalypAppModuleIf::apply( bool isPlaying, bool disableThreads )
|
||||
else
|
||||
#endif
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
process();
|
||||
QApplication::restoreOverrideCursor();
|
||||
run();
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
return moduleExecuted;
|
||||
if( m_pcDisplaySubWindow || m_pcModule->m_iModuleType == CLP_FRAME_MEASUREMENT_MODULE )
|
||||
{
|
||||
bRet = true;
|
||||
}
|
||||
}
|
||||
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 == 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 == 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
|
||||
{
|
||||
@@ -202,54 +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()
|
||||
{
|
||||
switch( m_pcModule->m_iModuleType )
|
||||
{
|
||||
case CLP_FRAME_PROCESSING_MODULE: {
|
||||
auto displayWindow = 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 )
|
||||
{
|
||||
m_pcDisplaySubWindow->setFillWindow( false );
|
||||
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
m_Mutex.unlock();
|
||||
m_pcDisplaySubWindow->setFillWindow( false );
|
||||
m_pcDisplaySubWindow->clearWindowBusy();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
|
||||
m_pcSubWindow[0]->setFillWindow( false );
|
||||
m_pcSubWindow[0]->clearWindowBusy();
|
||||
}
|
||||
#endif
|
||||
m_pcDisplaySubWindow->setFillWindow( false );
|
||||
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
break;
|
||||
}
|
||||
case CLP_FRAME_MEASUREMENT_MODULE:
|
||||
m_pcModuleDock->setModuleReturnValue( m_dMeasurementResult );
|
||||
m_pcModuleDock->setModulueReturnValue( m_dMeasurementResult );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::disable()
|
||||
void CalypAppModuleIf::destroy()
|
||||
{
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
QMutexLocker locker( &m_Mutex );
|
||||
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();
|
||||
}
|
||||
+42
-53
@@ -26,100 +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 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 std::vector<VideoSubWindow*>& { return m_pcSubWindow; }
|
||||
|
||||
CalypModuleIf* getModule() { return m_pcModule.get(); }
|
||||
CalypModuleIf* getModule() { return m_pcModule; }
|
||||
unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
|
||||
std::string moduleInfo() { return m_pcModule->moduleInfo(); }
|
||||
void update( bool isPlaying );
|
||||
ClpString moduleInfo() { return m_pcModule->moduleInfo(); }
|
||||
void update();
|
||||
bool apply( bool isPlaying = false, bool disableThreads = false );
|
||||
bool process();
|
||||
void setPlaying( bool isPlaying );
|
||||
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
|
||||
VideoSubWindow* 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;
|
||||
#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).
|
||||
|
||||
+11
-16
@@ -33,7 +33,6 @@
|
||||
#include <QDropEvent>
|
||||
#include <QSignalMapper>
|
||||
#include <QtDebug>
|
||||
#include <memory>
|
||||
|
||||
#include "AboutDialog.h"
|
||||
#include "ModulesHandle.h"
|
||||
@@ -59,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 );
|
||||
@@ -81,13 +78,13 @@ MainWindow::MainWindow()
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
setCentralWidget( m_pcWindowHandle );
|
||||
setAcceptDrops( true );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::windowActivated, this, &MainWindow::update );
|
||||
connect( m_pcWindowHandle, &SubWindowHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleVideo, &VideoHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleQuality, &QualityHandle::changed, this, &MainWindow::update, Qt::QueuedConnection );
|
||||
connect( m_appModuleExtensions, &ModulesHandle::changed, this, &MainWindow::update, 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[] )
|
||||
@@ -95,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" ) /**/
|
||||
@@ -199,8 +196,6 @@ void MainWindow::loadFile( QString fileName, CalypFileInfo* pStreamInfo )
|
||||
return;
|
||||
}
|
||||
videoSubWindow = new VideoSubWindow( VideoSubWindow::VIDEO_STREAM_SUBWINDOW ); // createSubWindow();
|
||||
videoSubWindow->setResourceManaget( m_appResourceHandle.get() );
|
||||
|
||||
if( !pStreamInfo )
|
||||
{
|
||||
int idx = findCalypStreamInfo( m_aRecentFileStreamInfo, fileName );
|
||||
@@ -261,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( "*." );
|
||||
|
||||
+4
-6
@@ -36,17 +36,16 @@
|
||||
#ifndef __MAINWINDOW_H__
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_QTDBUS
|
||||
#include "DBusAppAdaptor.h"
|
||||
#endif
|
||||
#include "ResourceHandle.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class QCloseEvent;
|
||||
class QDragEnterEvent;
|
||||
@@ -159,7 +158,6 @@ private:
|
||||
* Quality
|
||||
* Modules
|
||||
*/
|
||||
std::unique_ptr<ResourceHandle> m_appResourceHandle;
|
||||
VideoHandle* m_appModuleVideo;
|
||||
QualityHandle* m_appModuleQuality;
|
||||
ModulesHandle* m_appModuleExtensions;
|
||||
|
||||
@@ -32,7 +32,7 @@ MdiSubWindow::MdiSubWindow( QWidget* parent )
|
||||
: QMdiSubWindow( parent )
|
||||
{
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
}
|
||||
|
||||
QSize MdiSubWindow::sizeHint() const
|
||||
|
||||
+59
-51
@@ -91,6 +91,7 @@ QMenu* ModulesHandle::createMenu()
|
||||
|
||||
void ModulesHandle::buildMenu()
|
||||
{
|
||||
CalypModuleIf* pcCurrModuleIf;
|
||||
QString ModuleIfinternalName;
|
||||
QAction* currAction;
|
||||
QMenu* currSubMenu;
|
||||
@@ -107,7 +108,7 @@ void ModulesHandle::buildMenu()
|
||||
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
|
||||
for( ; it != moduleFactoryMap.end(); ++it )
|
||||
{
|
||||
auto pcCurrModuleIf = it->second();
|
||||
pcCurrModuleIf = it->second();
|
||||
ModuleIfinternalName = QString::fromLocal8Bit( it->first );
|
||||
|
||||
currSubMenu = NULL;
|
||||
@@ -146,6 +147,8 @@ void ModulesHandle::buildMenu()
|
||||
currSubMenu->addAction( currAction );
|
||||
else
|
||||
m_pcModulesMenu->addAction( currAction );
|
||||
|
||||
pcCurrModuleIf->Delete();
|
||||
}
|
||||
|
||||
m_pcModulesMenu->addAction( m_arrayActions[LOAD_EXTERNAL_ACT] );
|
||||
@@ -180,11 +183,11 @@ 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 )
|
||||
{
|
||||
auto apcCurrentModule = pcSubWindow->getModuleArray();
|
||||
QList<CalypAppModuleIf*> apcCurrentModule = pcSubWindow->getModuleArray();
|
||||
m_arrayActions[DISABLE_ACT]->setEnabled( apcCurrentModule.size() > 0 );
|
||||
if( pcSubWindow->getDisplayModule() )
|
||||
{
|
||||
@@ -275,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;
|
||||
@@ -337,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;
|
||||
}
|
||||
}
|
||||
@@ -352,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;
|
||||
}
|
||||
|
||||
@@ -363,11 +363,11 @@ void ModulesHandle::activateModule()
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -381,7 +381,7 @@ void ModulesHandle::activateModule()
|
||||
{
|
||||
if( ( pcCurrAppModuleIf->m_pcModule->m_uiModuleRequirements & CLP_MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
|
||||
{
|
||||
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW, pcCurrAppModuleIf.get() );
|
||||
pcModuleSubWindow = new VideoSubWindow( VideoSubWindow::MODULE_SUBWINDOW );
|
||||
windowName.append( QStringLiteral( "Module " ) );
|
||||
windowName.append( pcCurrAppModuleIf->m_pcModule->m_pchModuleLongName );
|
||||
pcCurrAppModuleIf->m_pcDisplaySubWindow = pcModuleSubWindow;
|
||||
@@ -392,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 == 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" );
|
||||
@@ -412,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
|
||||
@@ -437,12 +443,11 @@ 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( pcModuleSubWindow )
|
||||
@@ -460,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 = 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 )
|
||||
@@ -510,12 +520,12 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
|
||||
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( "*." );
|
||||
@@ -542,11 +552,12 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
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, false ) )
|
||||
{
|
||||
pcCurrModuleIf->m_pcModuleStream = nullptr;
|
||||
delete pcCurrModuleIf->m_pcModuleStream;
|
||||
pcCurrModuleIf->m_pcModuleStream = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -554,8 +565,8 @@ 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]->getInputStream()->getFrameNum();
|
||||
@@ -568,7 +579,7 @@ 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]->play();
|
||||
@@ -598,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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QSize>
|
||||
|
||||
#include "qcustomplot.h"
|
||||
//#include "external/qcustomplot/qcustomplot.h"
|
||||
|
||||
void PlotSubWindow::definePlotColors()
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
QualityHandle::QualityHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
@@ -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++ )
|
||||
|
||||
+1
-1
@@ -25,11 +25,11 @@
|
||||
#ifndef __QUALITYMEASUREMENT_H__
|
||||
#define __QUALITYMEASUREMENT_H__
|
||||
|
||||
#include <QFuture>
|
||||
#include <QtCore>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "QFuture"
|
||||
#include "QualityMeasurementSidebar.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
@@ -1,167 +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 <chrono>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
ResourceWorker::ResourceWorker( std::shared_ptr<CalypStream> stream )
|
||||
{
|
||||
m_pcStream = stream;
|
||||
}
|
||||
|
||||
void ResourceWorker::stop()
|
||||
{
|
||||
m_bStop = true;
|
||||
wake();
|
||||
wait();
|
||||
}
|
||||
|
||||
void ResourceWorker::wake()
|
||||
{
|
||||
m_Mutex.lock();
|
||||
m_ResourceIdle.wakeAll();
|
||||
m_Mutex.unlock();
|
||||
}
|
||||
|
||||
void ResourceWorker::run()
|
||||
{
|
||||
m_bStop = false;
|
||||
// Loop forever
|
||||
while( !m_bStop )
|
||||
{
|
||||
//auto start = std::chrono::steady_clock::now();
|
||||
m_pcStream->readNextFrameFillRGBBuffer();
|
||||
// auto end = std::chrono::steady_clock::now();
|
||||
// std::cout << "Elapsed time reading and processing a frame: "
|
||||
// << std::chrono::duration_cast<std::chrono::milliseconds>( end - start ).count()
|
||||
// << " ms" << std::endl;
|
||||
|
||||
// if( !m_pcStream->hasWritingSlot() )
|
||||
// {
|
||||
// m_Mutex.lock();
|
||||
// m_ResourceIdle.wait( &m_Mutex );
|
||||
// m_Mutex.unlock();
|
||||
// }
|
||||
while( !m_bStop && !m_pcStream->hasWritingSlot() )
|
||||
{
|
||||
// Wait here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResourceHandle::ResourceHandle()
|
||||
{
|
||||
}
|
||||
|
||||
auto ResourceHandle::addResource() -> std::size_t
|
||||
{
|
||||
auto resource_id = unique_id;
|
||||
unique_id++;
|
||||
auto newStreamResource = std::make_shared<CalypStream>();
|
||||
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( m_apcStreamResourcesList[i].get() == ptr )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return addResource();
|
||||
}
|
||||
|
||||
auto ResourceHandle::getResourceAsset( std::size_t id ) -> CalypStream*
|
||||
{
|
||||
if( m_apcStreamResourcesWorkersList.count( id ) )
|
||||
{
|
||||
return m_apcStreamResourcesList[id].get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ResourceHandle::removeResource( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.count( 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.count( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->stop();
|
||||
}
|
||||
|
||||
void ResourceHandle::startResourceWorker( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.count( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->setObjectName(
|
||||
"RW-" +
|
||||
QFileInfo( QString::fromStdString( m_apcStreamResourcesList[id]->getFileName() ) ).completeBaseName() );
|
||||
m_apcStreamResourcesWorkersList[id]->start();
|
||||
}
|
||||
|
||||
void ResourceHandle::wakeResourceWorker( std::size_t id )
|
||||
{
|
||||
if( !m_apcStreamResourcesWorkersList.count( id ) )
|
||||
{
|
||||
assert( false );
|
||||
return;
|
||||
}
|
||||
m_apcStreamResourcesWorkersList[id]->wake();
|
||||
}
|
||||
@@ -1,73 +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 <QThread>
|
||||
#include <QVector>
|
||||
#include <QWaitCondition>
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class ResourceWorker : public QThread
|
||||
{
|
||||
private:
|
||||
QMutex m_Mutex;
|
||||
QWaitCondition m_ResourceIdle;
|
||||
std::shared_ptr<CalypStream> m_pcStream;
|
||||
bool m_bStop{ false };
|
||||
|
||||
public:
|
||||
ResourceWorker( std::shared_ptr<CalypStream> stream );
|
||||
void stop();
|
||||
void wake();
|
||||
void run();
|
||||
};
|
||||
|
||||
class ResourceHandle
|
||||
{
|
||||
public:
|
||||
ResourceHandle();
|
||||
~ResourceHandle() = default;
|
||||
|
||||
auto getResource( CalypStream* ptr ) -> std::size_t;
|
||||
auto getResourceAsset( std::size_t id ) -> CalypStream*;
|
||||
void removeResource( std::size_t id );
|
||||
void stopResourceWorker( std::size_t id );
|
||||
void startResourceWorker( std::size_t id );
|
||||
void wakeResourceWorker( std::size_t id );
|
||||
|
||||
private:
|
||||
auto addResource() -> std::size_t;
|
||||
|
||||
private:
|
||||
std::size_t unique_id{ 0 };
|
||||
std::map<std::size_t, std::shared_ptr<CalypStream>> m_apcStreamResourcesList;
|
||||
std::map<std::size_t, std::unique_ptr<ResourceWorker>> m_apcStreamResourcesWorkersList;
|
||||
};
|
||||
|
||||
#endif // __RESOURCEHANDLE_H__
|
||||
@@ -40,7 +40,7 @@ SubWindowAbstract::SubWindowAbstract( QWidget* parent, unsigned int category )
|
||||
// setFocusPolicy( Qt::WheelFocus );
|
||||
setFocusPolicy( Qt::StrongFocus );
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
setBackgroundRole( QPalette::Window );
|
||||
setBackgroundRole( QPalette::Background );
|
||||
|
||||
setWindowIcon( QIcon( ":/logos/calyp-icon.png" ) );
|
||||
|
||||
|
||||
+4
-17
@@ -49,7 +49,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 )
|
||||
@@ -182,10 +182,6 @@ void SubWindowHandle::setWindowMode( int iWindowMode )
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
}
|
||||
}
|
||||
m_iWindowMode = iWindowMode;
|
||||
// tileSubWindows();
|
||||
@@ -222,10 +218,6 @@ void SubWindowHandle::updateActiveSubWindow( SubWindowAbstract* window )
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() + " :: " + m_pcActiveWindow->getWindowName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcApp->setWindowTitle( QApplication::applicationName() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,9 +237,9 @@ void SubWindowHandle::addSubWindow( SubWindowAbstract* window )
|
||||
if( window )
|
||||
{
|
||||
connect( window, SIGNAL( updateStatusBar( const QString& ) ), m_pcApp,
|
||||
SLOT( printMessage( const QString& ) ) );
|
||||
SLOT( printMessage( const QString& ) ) );
|
||||
connect( window, SIGNAL( zoomFactorChanged( const double, const QPoint ) ), m_pcApp,
|
||||
SLOT( updateZoomFactorSBox() ) );
|
||||
SLOT( updateZoomFactorSBox() ) );
|
||||
if( m_iWindowMode == DETACHEDSUBWINDOWMODE )
|
||||
{
|
||||
connect( window, SIGNAL( aboutToActivate( SubWindowAbstract* ) ), this,
|
||||
@@ -286,12 +278,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();
|
||||
}
|
||||
|
||||
+61
-95
@@ -29,10 +29,8 @@
|
||||
#include <QLabel>
|
||||
#include <QSignalMapper>
|
||||
#include <QSlider>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
#include <QtGui>
|
||||
#include <memory>
|
||||
|
||||
#include "FrameNumberWidget.h"
|
||||
#include "FramePropertiesDock.h"
|
||||
@@ -41,21 +39,22 @@
|
||||
#include "SubWindowHandle.h"
|
||||
#include "SubWindowSelectorDialog.h"
|
||||
#include "VideoSubWindow.h"
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
#include <QElapsedTimer>
|
||||
#endif
|
||||
|
||||
VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
: m_pcParet( parent ), m_pcMainWindowManager( windowManager )
|
||||
{
|
||||
m_pcCurrentVideoSubWindow = NULL;
|
||||
m_bIsPlaying = false;
|
||||
m_pcPlayingTimer = new QTimer( this );
|
||||
m_pcFrameRateFeedbackTimer = std::make_unique<QElapsedTimer>();
|
||||
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()
|
||||
{
|
||||
@@ -241,12 +240,6 @@ QWidget* VideoHandle::createStatusBarMessage()
|
||||
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 ) );
|
||||
@@ -259,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 );
|
||||
@@ -325,8 +317,11 @@ void VideoHandle::update()
|
||||
{
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
const CalypStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream();
|
||||
const CalypFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
|
||||
CalypStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream();
|
||||
CalypFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
|
||||
|
||||
unsigned long frame_num = 0;
|
||||
unsigned long total_frame_num = 1;
|
||||
|
||||
m_pcVideoFormatLabel->setText( m_pcCurrentVideoSubWindow->getStreamInformation() );
|
||||
|
||||
@@ -336,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();
|
||||
@@ -362,7 +355,8 @@ void VideoHandle::update()
|
||||
}
|
||||
}
|
||||
m_pcResolutionLabel->setText( resolution );
|
||||
m_pcFramePropertiesSideBar->setFrame( m_pcCurrentVideoSubWindow->getCurrFrameAsset(), m_pcCurrentVideoSubWindow->isPlaying() );
|
||||
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame );
|
||||
|
||||
m_pcFrameNumInfo->setTotalFrameNum( total_frame_num );
|
||||
m_pcFrameNumInfo->setCurrFrameNum( frame_num );
|
||||
@@ -372,11 +366,6 @@ 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" );
|
||||
@@ -390,7 +379,6 @@ void VideoHandle::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcPlayingFPSLabel->setText( "" );
|
||||
m_pcVideoFormatLabel->setText( "" );
|
||||
m_pcResolutionLabel->setText( "" );
|
||||
m_pcFramePropertiesSideBar->reset();
|
||||
@@ -438,17 +426,13 @@ void VideoHandle::closeSubWindow( SubWindowAbstract* subWindow )
|
||||
if( m_acPlayingSubWindows.contains( videoSubWindow ) )
|
||||
{
|
||||
int pos = m_acPlayingSubWindows.indexOf( videoSubWindow );
|
||||
// m_acPlayingSubWindows.at( pos )->stop();
|
||||
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 )
|
||||
@@ -575,25 +559,30 @@ 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()
|
||||
{
|
||||
if( !m_pcCurrentVideoSubWindow )
|
||||
@@ -604,6 +593,8 @@ void VideoHandle::play()
|
||||
|
||||
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++ )
|
||||
@@ -619,7 +610,9 @@ void VideoHandle::play()
|
||||
{
|
||||
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
|
||||
@@ -645,9 +638,9 @@ 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();
|
||||
@@ -663,50 +656,28 @@ 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;
|
||||
double time_elapsed_since_last_frame_ms = m_pcFrameRateFeedbackTimer->elapsed();
|
||||
average_time_between_frames_ms = double( average_time_between_frames_ms * m_uiNumberPlayedFrames + time_elapsed_since_last_frame_ms ) / double( m_uiNumberPlayedFrames + 1 );
|
||||
m_uiRealAverageFrameRate = 1000.0 / average_time_between_frames_ms;
|
||||
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 )
|
||||
@@ -719,13 +690,7 @@ void VideoHandle::playEvent()
|
||||
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 )
|
||||
@@ -737,9 +702,9 @@ void VideoHandle::seekEvent( int direction )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -748,6 +713,7 @@ void VideoHandle::seekEvent( int direction )
|
||||
m_pcCurrentVideoSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
}
|
||||
emit changed();
|
||||
// update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -764,9 +730,9 @@ void VideoHandle::seekVideo()
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
{
|
||||
playingSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -785,9 +751,9 @@ void VideoHandle::seekSliderEvent( int new_frame_num )
|
||||
{
|
||||
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
|
||||
@@ -807,9 +773,9 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
{
|
||||
QList<SubWindowAbstract*> subWindowList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
for( auto subWindow : subWindowList )
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
{
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindow );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
@@ -818,18 +784,18 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
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++ )
|
||||
{
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( window );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( selectedSubWindowList.at( i ) );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
@@ -841,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 );
|
||||
|
||||
+8
-10
@@ -25,7 +25,6 @@
|
||||
#ifndef __VIDEOHANDLE_H__
|
||||
#define __VIDEOHANDLE_H__
|
||||
|
||||
#include <QElapsedTimer>
|
||||
#include <QMenu>
|
||||
#include <QPoint>
|
||||
#include <QThread>
|
||||
@@ -35,18 +34,20 @@
|
||||
#include "CommonDefs.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 VideoSubWindow;
|
||||
class FramePropertiesDock;
|
||||
class FrameNumberWidget;
|
||||
class QTimer;
|
||||
|
||||
class VideoHandle : public QObject
|
||||
{
|
||||
@@ -112,7 +113,6 @@ private:
|
||||
QDockWidget* m_pcFramePropertiesDock;
|
||||
FramePropertiesDock* m_pcFramePropertiesSideBar;
|
||||
|
||||
QLabel* m_pcPlayingFPSLabel;
|
||||
QLabel* m_pcVideoFormatLabel;
|
||||
QLabel* m_pcResolutionLabel;
|
||||
|
||||
@@ -122,12 +122,12 @@ private:
|
||||
QTimer* m_pcPlayingTimer;
|
||||
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();
|
||||
|
||||
@@ -140,10 +140,8 @@ 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 );
|
||||
|
||||
+115
-254
@@ -32,7 +32,6 @@
|
||||
#include "ConfigureFormatDialog.h"
|
||||
#include "ModulesHandle.h"
|
||||
#include "QtConcurrent/qtconcurrentrun.h"
|
||||
#include "ResourceHandle.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
|
||||
#define QT_NO_CONCURRENT
|
||||
@@ -57,7 +56,7 @@ QDataStream& operator<<( QDataStream& out, const CalypFileInfoVector& array )
|
||||
QDataStream& operator>>( QDataStream& in, CalypFileInfoVector& array )
|
||||
{
|
||||
CalypFileInfo d;
|
||||
int array_size{ 0 };
|
||||
int array_size;
|
||||
in >> array_size;
|
||||
for( int i = 0; i < array_size; i++ )
|
||||
{
|
||||
@@ -90,7 +89,6 @@ int findCalypStreamInfo( CalypFileInfoVector array, QString filename )
|
||||
class VideoInformation : public QWidget
|
||||
{
|
||||
private:
|
||||
QTimer* m_pcRefreshTimer;
|
||||
QList<QStaticText> m_cTopLeftTextList;
|
||||
QFont m_cTopLeftTextFont;
|
||||
QFont m_cCenterTextFont;
|
||||
@@ -104,8 +102,6 @@ public:
|
||||
setAttribute( Qt::WA_TransparentForMouseEvents );
|
||||
m_cTopLeftTextFont.setPointSize( 8 );
|
||||
m_cCenterTextFont.setPointSize( 12 );
|
||||
m_pcRefreshTimer = new QTimer;
|
||||
m_pcRefreshTimer->setSingleShot( true );
|
||||
}
|
||||
void setInformationTopLeft( const QStringList& textLines )
|
||||
{
|
||||
@@ -115,12 +111,7 @@ public:
|
||||
m_cTopLeftTextList.append( QStaticText( textLines.at( i ) ) );
|
||||
}
|
||||
}
|
||||
void setBusyWindow( bool bFlag )
|
||||
{
|
||||
m_bBusyWindow = bFlag;
|
||||
// Do not show the refresh screen if it takes less than 500 ms
|
||||
m_pcRefreshTimer->start( 500 );
|
||||
}
|
||||
void setBusyWindow( bool bFlag ) { m_bBusyWindow = bFlag; }
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event )
|
||||
@@ -136,7 +127,7 @@ protected:
|
||||
topLeftCorner += QPoint( 0, 15 );
|
||||
}
|
||||
}
|
||||
if( m_bBusyWindow && !m_pcRefreshTimer->isActive() )
|
||||
if( m_bBusyWindow )
|
||||
{
|
||||
painter.setFont( m_cCenterTextFont );
|
||||
painter.drawText( rect(), Qt::AlignHCenter | Qt::AlignVCenter, QStringLiteral( "Refreshing..." ) );
|
||||
@@ -147,9 +138,10 @@ protected:
|
||||
|
||||
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent )
|
||||
: SubWindowAbstract( parent, SubWindowAbstract::VIDEO_SUBWINDOW | category )
|
||||
, m_pcResourceManager( nullptr )
|
||||
, m_bWindowBusy( false )
|
||||
, m_pCurrStream( NULL )
|
||||
, m_pcCurrFrame( NULL )
|
||||
, m_pcCurrentDisplayModule( NULL )
|
||||
, m_pcReferenceSubWindow( NULL )
|
||||
, m_bIsPlaying( false )
|
||||
, m_pcUpdateTimer( NULL )
|
||||
@@ -184,7 +176,7 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
m_pcScrollArea->setWidgetResizable( true );
|
||||
setWidget( m_pcScrollArea );
|
||||
|
||||
m_associatedModules.clear();
|
||||
m_apcCurrentModule.clear();
|
||||
|
||||
m_pcUpdateTimer = new QTimer();
|
||||
m_pcUpdateTimer->setInterval( 800 );
|
||||
@@ -194,18 +186,14 @@ VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, QWidget*
|
||||
m_pcVideoInfo = new VideoInformation( this );
|
||||
}
|
||||
|
||||
VideoSubWindow::VideoSubWindow( enum VideoSubWindowCategories category, CalypAppModuleIf* displayModule, QWidget* parent )
|
||||
: VideoSubWindow( category, parent )
|
||||
{
|
||||
m_pcCurrentDisplayModule = displayModule;
|
||||
}
|
||||
|
||||
VideoSubWindow::~VideoSubWindow()
|
||||
{
|
||||
m_pcCurrFrameAsset = nullptr;
|
||||
if( m_pcResourceManager )
|
||||
m_pcResourceManager->removeResource( m_uiResourceId );
|
||||
m_pcCurrFrame = NULL;
|
||||
disableModule();
|
||||
delete m_cViewArea;
|
||||
delete m_pcUpdateTimer;
|
||||
if( m_pCurrStream )
|
||||
delete m_pCurrStream;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,19 +202,7 @@ VideoSubWindow::~VideoSubWindow()
|
||||
|
||||
void VideoSubWindow::closeEvent( QCloseEvent* event )
|
||||
{
|
||||
//stop();
|
||||
auto tmpModules = m_associatedModules;
|
||||
m_associatedModules.clear();
|
||||
for( auto module : tmpModules )
|
||||
{
|
||||
module->disable();
|
||||
}
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
m_pcCurrentDisplayModule->disable();
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
stop();
|
||||
SubWindowAbstract::closeEvent( event );
|
||||
}
|
||||
|
||||
@@ -291,8 +267,8 @@ QSize VideoSubWindow::sizeHint() const
|
||||
QSize VideoSubWindow::sizeHint( const QSize& maxSize ) const
|
||||
{
|
||||
QSize isize;
|
||||
if( m_pcCurrFrameAsset )
|
||||
isize = QSize( m_pcCurrFrameAsset->getWidth() + 50, m_pcCurrFrameAsset->getHeight() + 50 );
|
||||
if( m_pcCurrFrame )
|
||||
isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 );
|
||||
else if( m_pCurrStream )
|
||||
isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 );
|
||||
|
||||
@@ -322,17 +298,12 @@ void VideoSubWindow::refreshSubWindow()
|
||||
{
|
||||
if( getCategory() & SubWindowAbstract::VIDEO_STREAM_SUBWINDOW )
|
||||
{
|
||||
#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
|
||||
// seekAbsoluteEvent( currFrameNum );
|
||||
}
|
||||
updateVideoWindowInfo();
|
||||
refreshFrame();
|
||||
@@ -340,8 +311,6 @@ void VideoSubWindow::refreshSubWindow()
|
||||
|
||||
bool VideoSubWindow::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;
|
||||
@@ -350,11 +319,11 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
|
||||
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 );
|
||||
|
||||
if( !m_pCurrStream )
|
||||
{
|
||||
m_pCurrStream = new CalypStream;
|
||||
}
|
||||
bool bConfig = true;
|
||||
if( !bForceDialog )
|
||||
{
|
||||
@@ -406,10 +375,6 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
var.setValue<unsigned int>( BitsPel );
|
||||
appSettings.setValue( "VideoSubWindow/LastBitsPerPixel", var );
|
||||
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->startResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
refreshFrame();
|
||||
@@ -418,16 +383,15 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
|
||||
updateVideoWindowInfo();
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoSubWindow::loadFile( CalypFileInfo* streamInfo )
|
||||
{
|
||||
assert( m_pcResourceManager != nullptr );
|
||||
|
||||
m_uiResourceId = m_pcResourceManager->getResource( m_pCurrStream );
|
||||
m_pCurrStream = m_pcResourceManager->getResourceAsset( m_uiResourceId );
|
||||
if( !m_pCurrStream )
|
||||
{
|
||||
m_pCurrStream = new CalypStream;
|
||||
}
|
||||
|
||||
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight,
|
||||
streamInfo->m_iPelFormat, streamInfo->m_uiBitsPelPixel, streamInfo->m_iEndianness,
|
||||
@@ -438,10 +402,6 @@ bool VideoSubWindow::loadFile( CalypFileInfo* streamInfo )
|
||||
|
||||
m_sStreamInfo = *streamInfo;
|
||||
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->startResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
refreshFrame();
|
||||
@@ -458,15 +418,15 @@ void VideoSubWindow::updateVideoWindowInfo()
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
m_cStreamInformation = "Module";
|
||||
const auto& arraySubWindows = m_pcCurrentDisplayModule->getSubWindowList();
|
||||
QList<VideoSubWindow*> arraySubWindows = m_pcCurrentDisplayModule->getSubWindowList();
|
||||
QStringList windowInfoList;
|
||||
if( arraySubWindows.size() > 0 )
|
||||
{
|
||||
for( std::size_t i = 0; i < arraySubWindows.size(); i++ )
|
||||
for( int i = 0; i < arraySubWindows.size(); i++ )
|
||||
{
|
||||
if( arraySubWindows[i]->getWindowName() != getWindowName() )
|
||||
if( arraySubWindows.at( i )->getWindowName() != getWindowName() )
|
||||
{
|
||||
windowInfoList.append( QString( "Input %1 - " + arraySubWindows[i]->getWindowName() ).arg( i + 1 ) );
|
||||
windowInfoList.append( QString( "Input %1 - " + arraySubWindows.at( i )->getWindowName() ).arg( i + 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,6 +435,7 @@ void VideoSubWindow::updateVideoWindowInfo()
|
||||
QStringList list = QString::fromStdString( m_pcCurrentDisplayModule->moduleInfo() ).split( '\n' );
|
||||
windowInfoList.append( list );
|
||||
}
|
||||
// qDebug( ) << sourceWindowList;
|
||||
if( windowInfoList.size() > 0 )
|
||||
{
|
||||
m_pcVideoInfo->setInformationTopLeft( windowInfoList );
|
||||
@@ -486,14 +447,16 @@ void VideoSubWindow::updateVideoWindowInfo()
|
||||
QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() );
|
||||
m_cStreamInformation = m_cFormatName + " | " + m_cCodedName;
|
||||
}
|
||||
if( m_pcCurrFrameAsset )
|
||||
//#if 0
|
||||
if( m_pcCurrFrame )
|
||||
{
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrameAsset->getPelFmtName() );
|
||||
QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() );
|
||||
if( m_pCurrStream )
|
||||
if( !m_pCurrStream->isNative() )
|
||||
m_cPelFmtName += "*";
|
||||
m_cStreamInformation += " | " + m_cPelFmtName;
|
||||
}
|
||||
//#endif
|
||||
if( m_cStreamInformation.isEmpty() )
|
||||
{
|
||||
m_cStreamInformation = " ";
|
||||
@@ -518,10 +481,10 @@ bool VideoSubWindow::guessFormat( QString filename, unsigned int& rWidth, unsign
|
||||
{
|
||||
bGuessed = false;
|
||||
// Guess pixel format
|
||||
auto formats_list = CalypFrame::supportedPixelFormatListNames();
|
||||
for( std::size_t i = 0; i < formats_list.size(); i++ )
|
||||
QVector<ClpString> formats_list = QVector<ClpString>::fromStdVector( CalypFrame::supportedPixelFormatListNames() );
|
||||
for( int i = 0; i < formats_list.size(); i++ )
|
||||
{
|
||||
if( FilenameShort.contains( formats_list[i].c_str(), Qt::CaseInsensitive ) )
|
||||
if( FilenameShort.contains( formats_list.at( i ).c_str(), Qt::CaseInsensitive ) )
|
||||
{
|
||||
rInputFormat = i;
|
||||
break;
|
||||
@@ -661,127 +624,78 @@ void VideoSubWindow::updateSelectedArea( QRect area )
|
||||
* Functions to enable a module in the
|
||||
* current SubWindow
|
||||
*/
|
||||
// void VideoSubWindow::enableModule( std::shared_ptr<CalypAppModuleIf> pcModule )
|
||||
// {
|
||||
// auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
|
||||
// [&]( const auto& module ) { return module.get() == pcModule.get(); } );
|
||||
// if( it != m_associatedModules.end() )
|
||||
// {
|
||||
// m_associatedModules.erase( it );
|
||||
// }
|
||||
// m_pcCurrentDisplayModule = std::move( pcModule );
|
||||
// updateVideoWindowInfo();
|
||||
// }
|
||||
|
||||
bool VideoSubWindow::hasAssociatedModule()
|
||||
void VideoSubWindow::enableModule( CalypAppModuleIf* pcModule )
|
||||
{
|
||||
if( m_pcCurrentDisplayModule == nullptr )
|
||||
return !m_associatedModules.empty();
|
||||
return m_associatedModules.size() > 1;
|
||||
}
|
||||
|
||||
void VideoSubWindow::setDisplayModule( CalypAppModuleIf* pcModule )
|
||||
{
|
||||
if( m_pcCurrentDisplayModule != nullptr )
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
m_pcCurrentDisplayModule->disable();
|
||||
disableModule( m_pcCurrentDisplayModule );
|
||||
}
|
||||
m_pcCurrentDisplayModule = pcModule;
|
||||
updateVideoWindowInfo();
|
||||
}
|
||||
|
||||
void VideoSubWindow::associateModule( std::shared_ptr<CalypAppModuleIf> pcModule )
|
||||
{
|
||||
auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
|
||||
[&]( const auto& module ) { return module.get() == pcModule.get(); } );
|
||||
if( it == m_associatedModules.end() )
|
||||
{
|
||||
m_associatedModules.push_back( std::move( pcModule ) );
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSubWindow::disableModule( CalypAppModuleIf* pcModule )
|
||||
{
|
||||
if( pcModule == nullptr )
|
||||
return;
|
||||
bool bRefresh = false;
|
||||
|
||||
auto it = std::find_if( m_associatedModules.begin(), m_associatedModules.end(),
|
||||
[&]( const auto& module ) { return module.get() == pcModule; } );
|
||||
if( it != m_associatedModules.end() )
|
||||
if( pcModule )
|
||||
{
|
||||
m_associatedModules.erase( it );
|
||||
int modIdx = m_apcCurrentModule.indexOf( pcModule );
|
||||
if( modIdx != -1 )
|
||||
{
|
||||
m_apcCurrentModule.removeAt( modIdx );
|
||||
ModulesHandle::destroyModuleIf( pcModule );
|
||||
bRefresh |= true;
|
||||
}
|
||||
if( pcModule == m_pcCurrentDisplayModule )
|
||||
{
|
||||
pcModule = m_pcCurrentDisplayModule;
|
||||
m_pcCurrentDisplayModule = 0;
|
||||
ModulesHandle::destroyModuleIf( pcModule );
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
bRefresh |= true;
|
||||
}
|
||||
}
|
||||
if( pcModule == m_pcCurrentDisplayModule )
|
||||
else
|
||||
{
|
||||
bRefresh |= true;
|
||||
m_pcCurrentDisplayModule = nullptr;
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
QList<CalypAppModuleIf*> apcCurrentModule = m_apcCurrentModule;
|
||||
for( int i = 0; i < apcCurrentModule.size(); i++ )
|
||||
{
|
||||
m_apcCurrentModule.removeOne( apcCurrentModule.at( i ) );
|
||||
ModulesHandle::destroyModuleIf( apcCurrentModule.at( i ) );
|
||||
bRefresh |= true;
|
||||
}
|
||||
assert( m_apcCurrentModule.size() == 0 );
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
pcModule = m_pcCurrentDisplayModule;
|
||||
m_pcCurrentDisplayModule = NULL;
|
||||
ModulesHandle::destroyModuleIf( pcModule );
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
bRefresh |= true;
|
||||
}
|
||||
}
|
||||
if( bRefresh )
|
||||
{
|
||||
refreshFrame();
|
||||
updateVideoWindowInfo();
|
||||
}
|
||||
// if( pcModule )
|
||||
// {
|
||||
// int modIdx = m_apcCurrentModule.indexOf( pcModule );
|
||||
// if( modIdx != -1 )
|
||||
// {
|
||||
// m_apcCurrentModule.removeAt( modIdx );
|
||||
// ModulesHandle::destroyModuleIf( pcModule );
|
||||
// bRefresh |= true;
|
||||
// }
|
||||
// if( pcModule == m_pcCurrentDisplayModule )
|
||||
// {
|
||||
// pcModule = m_pcCurrentDisplayModule;
|
||||
// m_pcCurrentDisplayModule = 0;
|
||||
// ModulesHandle::destroyModuleIf( pcModule );
|
||||
// setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
// bRefresh |= true;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// QList<CalypAppModuleIf*> apcCurrentModule = m_apcCurrentModule;
|
||||
// for( int i = 0; i < apcCurrentModule.size(); i++ )
|
||||
// {
|
||||
// m_apcCurrentModule.removeOne( apcCurrentModule.at( i ) );
|
||||
// ModulesHandle::destroyModuleIf( apcCurrentModule.at( i ) );
|
||||
// bRefresh |= true;
|
||||
// }
|
||||
// assert( m_apcCurrentModule.size() == 0 );
|
||||
// if( m_pcCurrentDisplayModule )
|
||||
// {
|
||||
// pcModule = m_pcCurrentDisplayModule;
|
||||
// m_pcCurrentDisplayModule = NULL;
|
||||
// ModulesHandle::destroyModuleIf( pcModule );
|
||||
// setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
// bRefresh |= true;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
bool VideoSubWindow::disableAllModules()
|
||||
void VideoSubWindow::associateModule( CalypAppModuleIf* pcModule )
|
||||
{
|
||||
if( m_associatedModules.empty() )
|
||||
return false;
|
||||
// For loop is required as we will invalidate the iterator
|
||||
while( m_associatedModules.size() > 0 )
|
||||
{
|
||||
auto module = m_associatedModules.back();
|
||||
m_associatedModules.pop_back();
|
||||
module->disable();
|
||||
}
|
||||
return true;
|
||||
m_apcCurrentModule.append( pcModule );
|
||||
}
|
||||
|
||||
bool VideoSubWindow::hasRunningModule()
|
||||
{
|
||||
bool bRet = false;
|
||||
for( std::size_t i = 0; i < m_associatedModules.size() && !bRet; i++ )
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
bRet |= m_associatedModules.at( i )->isRunning();
|
||||
bRet |= m_pcCurrentDisplayModule->isRunning();
|
||||
}
|
||||
for( int i = 0; i < m_apcCurrentModule.size() && !bRet; i++ )
|
||||
{
|
||||
bRet |= m_apcCurrentModule.at( i )->isRunning();
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
@@ -791,24 +705,10 @@ void VideoSubWindow::setFillWindow( bool bFlag )
|
||||
m_pcVideoInfo->setBusyWindow( bFlag );
|
||||
}
|
||||
|
||||
std::shared_ptr<CalypFrame> VideoSubWindow::getCurrFrameAsset()
|
||||
void VideoSubWindow::setCurrFrame( CalypFrame* pcCurrFrame )
|
||||
{
|
||||
if( m_pcCurrFrameAsset == nullptr && m_pCurrStream != nullptr )
|
||||
{
|
||||
m_pcCurrFrameAsset = m_pCurrStream->getCurrFrameAsset();
|
||||
}
|
||||
return m_pcCurrFrameAsset;
|
||||
};
|
||||
|
||||
void VideoSubWindow::setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame )
|
||||
{
|
||||
m_pcCurrFrameAsset = std::move( pcCurrFrame );
|
||||
m_cViewArea->setImage( m_pcCurrFrameAsset );
|
||||
for( auto& module : m_associatedModules )
|
||||
{
|
||||
if( module.get() != m_pcCurrentDisplayModule )
|
||||
module->update( m_bIsPlaying );
|
||||
}
|
||||
m_pcCurrFrame = pcCurrFrame;
|
||||
m_cViewArea->setImage( m_pcCurrFrame );
|
||||
}
|
||||
|
||||
void VideoSubWindow::refreshFrameOperation()
|
||||
@@ -816,25 +716,22 @@ void VideoSubWindow::refreshFrameOperation()
|
||||
bool bSetFrame = false;
|
||||
if( m_pCurrStream )
|
||||
{
|
||||
m_pcCurrFrameAsset = m_pCurrStream->getCurrFrameAsset();
|
||||
bSetFrame |= true;
|
||||
m_pcCurrFrame = m_pCurrStream->getCurrFrame();
|
||||
bSetFrame = m_pcCurrFrame ? true : false;
|
||||
}
|
||||
|
||||
if( m_pcCurrentDisplayModule )
|
||||
{
|
||||
m_bWindowBusy = true;
|
||||
bool disableThreads = !m_bIsPlaying && hasAssociatedModule();
|
||||
m_pcCurrentDisplayModule->apply( m_bIsPlaying, disableThreads );
|
||||
m_pcCurrentDisplayModule->apply( m_bIsPlaying, !m_bIsPlaying && m_apcCurrentModule.size() );
|
||||
bSetFrame = false;
|
||||
}
|
||||
if( bSetFrame )
|
||||
{
|
||||
m_cViewArea->setImage( m_pcCurrFrameAsset );
|
||||
for( auto& module : m_associatedModules )
|
||||
{
|
||||
if( module.get() != m_pcCurrentDisplayModule )
|
||||
module->update( m_bIsPlaying );
|
||||
}
|
||||
m_cViewArea->setImage( m_pcCurrFrame );
|
||||
}
|
||||
for( int i = 0; i < m_apcCurrentModule.size(); i++ )
|
||||
{
|
||||
m_apcCurrentModule.at( i )->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,32 +755,22 @@ bool VideoSubWindow::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 )
|
||||
{
|
||||
refreshFrame();
|
||||
m_cReadResult = QtConcurrent::run( m_pCurrStream, &CalypStream::readNextFrameFillRGBBuffer );
|
||||
refreshFrame( bThreaded );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
refreshFrame( bThreaded );
|
||||
#ifndef CALYP_MANAGED_RESOURCES
|
||||
refreshFrame();
|
||||
m_pCurrStream->readNextFrameFillRGBBuffer();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return bEndOfSeq;
|
||||
@@ -894,17 +781,17 @@ bool VideoSubWindow::save( QString filename )
|
||||
bool iRet = false;
|
||||
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
||||
CalypFrame* saveFrame = m_pcCurrFrameAsset.get();
|
||||
CalypFrame* saveFrame = m_pcCurrFrame;
|
||||
if( m_cSelectedArea.isValid() )
|
||||
{
|
||||
saveFrame = new CalypFrame( m_pcCurrFrameAsset.get(), m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(),
|
||||
saveFrame = new CalypFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(), m_cSelectedArea.width(),
|
||||
m_cSelectedArea.height() );
|
||||
}
|
||||
if( !saveFrame )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
iRet = CalypStream::saveFrame( filename.toStdString(), *saveFrame );
|
||||
iRet = CalypStream::saveFrame( filename.toStdString(), saveFrame );
|
||||
QApplication::restoreOverrideCursor();
|
||||
return iRet;
|
||||
}
|
||||
@@ -919,37 +806,16 @@ bool VideoSubWindow::saveStream( QString filename )
|
||||
return iRet;
|
||||
}
|
||||
|
||||
void VideoSubWindow::setPlaying( bool isPlaying )
|
||||
{
|
||||
m_bIsPlaying = isPlaying;
|
||||
for( auto module : m_associatedModules )
|
||||
{
|
||||
module->setPlaying( isPlaying );
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoSubWindow::isPlaying()
|
||||
{
|
||||
if( getCategory() & SubWindowCategory::MODULE_SUBWINDOW )
|
||||
{
|
||||
for( auto window : m_pcCurrentDisplayModule->getSubWindowList() )
|
||||
{
|
||||
if( window->isPlaying() )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return m_bIsPlaying;
|
||||
}
|
||||
|
||||
bool VideoSubWindow::play()
|
||||
{
|
||||
bool isPlaying = false;
|
||||
if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 )
|
||||
{
|
||||
isPlaying = true;
|
||||
m_bIsPlaying = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIsPlaying = false;
|
||||
}
|
||||
setPlaying( isPlaying );
|
||||
return m_bIsPlaying;
|
||||
}
|
||||
|
||||
@@ -965,25 +831,20 @@ bool VideoSubWindow::playEvent()
|
||||
|
||||
void VideoSubWindow::pause()
|
||||
{
|
||||
setPlaying( false );
|
||||
m_bIsPlaying = false;
|
||||
refreshFrame();
|
||||
}
|
||||
|
||||
void VideoSubWindow::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 VideoSubWindow::seekRelativeEvent( bool bIsFoward )
|
||||
{
|
||||
bool bRefresh = false;
|
||||
if( m_pCurrStream )
|
||||
{
|
||||
if( bIsFoward )
|
||||
@@ -992,13 +853,13 @@ void VideoSubWindow::seekRelativeEvent( bool bIsFoward )
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCurrStream->seekInputRelative( bIsFoward );
|
||||
#ifdef CALYP_MANAGED_RESOURCES
|
||||
m_pcResourceManager->wakeResourceWorker( m_uiResourceId );
|
||||
#endif
|
||||
refreshFrame();
|
||||
bRefresh = m_pCurrStream->seekInputRelative( bIsFoward );
|
||||
}
|
||||
}
|
||||
if( bRefresh )
|
||||
{
|
||||
refreshFrame();
|
||||
}
|
||||
}
|
||||
|
||||
void VideoSubWindow::stop()
|
||||
@@ -1007,7 +868,7 @@ void VideoSubWindow::stop()
|
||||
m_cRefreshResult.waitForFinished();
|
||||
m_cReadResult.waitForFinished();
|
||||
#endif
|
||||
setPlaying( false );
|
||||
m_bIsPlaying = false;
|
||||
seekAbsoluteEvent( 0 );
|
||||
return;
|
||||
}
|
||||
@@ -1147,8 +1008,8 @@ void VideoSubWindow::scaleView( double scale, QPoint center )
|
||||
void VideoSubWindow::scaleView( const QSize& size, QPoint center )
|
||||
{
|
||||
QSize imgViewSize;
|
||||
if( m_pcCurrFrameAsset )
|
||||
imgViewSize = QSize( m_pcCurrFrameAsset->getWidth(), m_pcCurrFrameAsset->getHeight() );
|
||||
if( m_pcCurrFrame )
|
||||
imgViewSize = QSize( m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight() );
|
||||
else
|
||||
imgViewSize = QSize( m_pCurrStream->getWidth(), m_pCurrStream->getHeight() );
|
||||
QSize newSize = imgViewSize;
|
||||
@@ -1178,22 +1039,22 @@ void VideoSubWindow::scaleView( const QSize& size, QPoint center )
|
||||
|
||||
void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
|
||||
{
|
||||
if( m_pcCurrFrameAsset )
|
||||
if( m_pcCurrFrame )
|
||||
{
|
||||
int iWidth, iHeight;
|
||||
int posX = pos.x();
|
||||
int posY = pos.y();
|
||||
QString strStatus;
|
||||
|
||||
iWidth = m_pcCurrFrameAsset->getWidth();
|
||||
iHeight = m_pcCurrFrameAsset->getHeight();
|
||||
iWidth = m_pcCurrFrame->getWidth();
|
||||
iHeight = m_pcCurrFrame->getHeight();
|
||||
|
||||
if( ( posX < iWidth ) && ( posX >= 0 ) && ( posY < iHeight ) && ( posY >= 0 ) )
|
||||
{
|
||||
strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
|
||||
|
||||
int colorSpace = m_pcCurrFrameAsset->getColorSpace();
|
||||
CalypPixel pixelValue = m_pcCurrFrameAsset->getPixel( pos.x(), pos.y() );
|
||||
int colorSpace = m_pcCurrFrame->getColorSpace();
|
||||
CalypPixel pixelValue = m_pcCurrFrame->getPixel( pos.x(), pos.y() );
|
||||
switch( colorSpace )
|
||||
{
|
||||
case CLP_COLOR_GRAY:
|
||||
|
||||
+21
-38
@@ -31,7 +31,6 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "CalypAppModuleIf.h"
|
||||
#include "CommonDefs.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
#include "ViewArea.h"
|
||||
@@ -42,7 +41,6 @@ class QScrollArea;
|
||||
|
||||
class VideoInformation;
|
||||
class VideoSubWindow;
|
||||
class ResourceHandle;
|
||||
class CalypAppModuleIf;
|
||||
|
||||
typedef struct
|
||||
@@ -67,8 +65,6 @@ class VideoSubWindow : public SubWindowAbstract
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
ResourceHandle* m_pcResourceManager;
|
||||
|
||||
bool m_bWindowBusy;
|
||||
|
||||
QScrollArea* m_pcScrollArea;
|
||||
@@ -83,15 +79,13 @@ private:
|
||||
QString m_cFilename;
|
||||
QString m_cStreamInformation;
|
||||
CalypFileInfo m_sStreamInfo;
|
||||
std::size_t m_uiResourceId;
|
||||
CalypStream* m_pCurrStream;
|
||||
std::shared_ptr<CalypFrame> m_pcCurrFrameAsset;
|
||||
//CalypFrame* m_pcCurrFrame;
|
||||
|
||||
CalypFrame* m_pcCurrFrame;
|
||||
QRect m_cSelectedArea;
|
||||
|
||||
CalypAppModuleIf* m_pcCurrentDisplayModule{ nullptr };
|
||||
std::vector<std::shared_ptr<CalypAppModuleIf>> m_associatedModules;
|
||||
bool m_hasAssociatedModules;
|
||||
CalypAppModuleIf* m_pcCurrentDisplayModule;
|
||||
QList<CalypAppModuleIf*> m_apcCurrentModule;
|
||||
|
||||
VideoSubWindow* m_pcReferenceSubWindow;
|
||||
|
||||
@@ -115,11 +109,8 @@ public:
|
||||
MODULE_SUBWINDOW = SubWindowAbstract::MODULE_SUBWINDOW,
|
||||
};
|
||||
VideoSubWindow( enum VideoSubWindowCategories category, QWidget* parent = 0 );
|
||||
VideoSubWindow( enum VideoSubWindowCategories category, CalypAppModuleIf* displayModule, QWidget* parent = 0 );
|
||||
~VideoSubWindow();
|
||||
|
||||
void setResourceManaget( ResourceHandle* resourceManager ) { m_pcResourceManager = resourceManager; }
|
||||
|
||||
void updateVideoWindowInfo();
|
||||
|
||||
bool loadFile( QString cFilename, bool bForceDialog = false );
|
||||
@@ -136,25 +127,23 @@ public:
|
||||
bool playEvent();
|
||||
void stop();
|
||||
|
||||
void setPlaying( bool isPlaying );
|
||||
bool isPlaying();
|
||||
bool isPlaying() { return m_bIsPlaying; }
|
||||
void seekAbsoluteEvent( unsigned int new_frame_num );
|
||||
void seekRelativeEvent( bool bIsFoward );
|
||||
|
||||
void setCurrFrame( std::shared_ptr<CalypFrame> pcCurrFrame );
|
||||
void setCurrFrame( CalypFrame* pcCurrFrame );
|
||||
|
||||
CalypFileInfo getStreamInfo() { return m_sStreamInfo; }
|
||||
QString getStreamInformation() { return m_cStreamInformation; }
|
||||
const CalypStream* getInputStream() { return m_pCurrStream; }
|
||||
const CalypStream* getCurrStream() { return m_pCurrStream; }
|
||||
CalypFrame* getCurrFrame() { return m_pcCurrFrameAsset.get(); }
|
||||
std::shared_ptr<CalypFrame> getCurrFrameAsset();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -163,23 +152,17 @@ public:
|
||||
* Functions to enable a module in the
|
||||
* current SubWindow
|
||||
*/
|
||||
//void enableModule( std::shared_ptr<CalypAppModuleIf> pcModule );
|
||||
bool hasAssociatedModule();
|
||||
void setDisplayModule( CalypAppModuleIf* pcModule );
|
||||
void associateModule( std::shared_ptr<CalypAppModuleIf> pcModule );
|
||||
void disableModule( CalypAppModuleIf* pcModule );
|
||||
bool disableAllModules();
|
||||
void enableModule( CalypAppModuleIf* pcModule );
|
||||
void disableModule( CalypAppModuleIf* pcModule = NULL );
|
||||
void associateModule( CalypAppModuleIf* pcModule );
|
||||
|
||||
CalypAppModuleIf* getDisplayModule() { return m_pcCurrentDisplayModule; }
|
||||
QVector<CalypAppModuleIf*> getModuleArray()
|
||||
QList<CalypAppModuleIf*> getModuleArray()
|
||||
{
|
||||
QVector<CalypAppModuleIf*> apcModulesArray;
|
||||
QList<CalypAppModuleIf*> apcModulesArray;
|
||||
if( m_pcCurrentDisplayModule )
|
||||
apcModulesArray.append( m_pcCurrentDisplayModule );
|
||||
for( const auto& module : m_associatedModules )
|
||||
{
|
||||
apcModulesArray.append( module.get() );
|
||||
}
|
||||
apcModulesArray.append( m_apcCurrentModule );
|
||||
return apcModulesArray;
|
||||
}
|
||||
|
||||
@@ -222,9 +205,9 @@ private:
|
||||
QSize getScrollSize();
|
||||
|
||||
protected:
|
||||
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();
|
||||
@@ -235,7 +218,7 @@ public Q_SLOTS:
|
||||
void updatePixelValueStatusBar( const QPoint& pos );
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( CalypFileInfo ) // NOLINT
|
||||
Q_DECLARE_METATYPE( CalypFileInfoVector ) // NOLINT
|
||||
Q_DECLARE_METATYPE( CalypFileInfo )
|
||||
Q_DECLARE_METATYPE( CalypFileInfoVector )
|
||||
|
||||
#endif // __VIDEOSUBWINDOW_H__
|
||||
+71
-70
@@ -25,8 +25,6 @@
|
||||
|
||||
#include "ViewArea.h"
|
||||
|
||||
#include <qnamespace.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -50,6 +48,9 @@ ViewArea::ViewArea( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
{
|
||||
setMouseTracking( true );
|
||||
|
||||
m_pcCurrFrame = NULL;
|
||||
m_pixmap = QPixmap();
|
||||
m_grid = GridManager();
|
||||
m_mask = QBitmap();
|
||||
m_selectedArea = QRect();
|
||||
@@ -68,27 +69,31 @@ ViewArea::ViewArea( QWidget* parent )
|
||||
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 );
|
||||
m_nextFrame->fillRGBBuffer();
|
||||
m_image = QImage( m_nextFrame->getRGBBuffer(),
|
||||
m_nextFrame->getWidth(),
|
||||
m_nextFrame->getHeight(),
|
||||
QImage::Format_ARGB32 );
|
||||
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 ) );
|
||||
}
|
||||
|
||||
// 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_pixmap = QPixmap();
|
||||
m_mask = QBitmap();
|
||||
m_mode = NormalMode;
|
||||
updateSize();
|
||||
@@ -162,7 +167,7 @@ void ViewArea::setZoomFactor( double f )
|
||||
double ViewArea::scaleZoomFactor( double scale, QPoint center, QSize minimumSize )
|
||||
{
|
||||
double maxZoom = 100.0;
|
||||
double minZoom = 0.01; //( 1.0 / m_image.width() );
|
||||
double minZoom = 0.01; //( 1.0 / m_pixmap.width() );
|
||||
double new_scale = 1.0;
|
||||
|
||||
if( ( m_dZoomFactor == minZoom ) && ( scale < 1 ) )
|
||||
@@ -178,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();
|
||||
|
||||
@@ -314,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,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();
|
||||
@@ -383,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
|
||||
{
|
||||
@@ -406,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();
|
||||
@@ -419,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();
|
||||
@@ -436,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 )
|
||||
@@ -461,13 +468,13 @@ 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();
|
||||
@@ -476,18 +483,18 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
/* 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() *
|
||||
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" );
|
||||
@@ -505,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 )
|
||||
{
|
||||
@@ -552,15 +559,15 @@ 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 );
|
||||
@@ -578,7 +585,7 @@ void ViewArea::paintEvent( QPaintEvent* event )
|
||||
painter.setPen( QColor( 50, 50, 50, 128 ) );
|
||||
//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() );
|
||||
@@ -635,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
|
||||
@@ -731,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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -751,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 )
|
||||
@@ -915,7 +916,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent* event )
|
||||
// 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 ) );
|
||||
@@ -999,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;
|
||||
@@ -1090,6 +1091,6 @@ void ViewArea::updateMask( const QRect& rect )
|
||||
break;
|
||||
}
|
||||
default: /* Do Nothing */
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -56,8 +56,8 @@ public:
|
||||
|
||||
ViewArea( QWidget* parent = 0 );
|
||||
|
||||
QImage& image() { return m_image; };
|
||||
void setImage( std::shared_ptr<CalypFrame> frame );
|
||||
void setImage( CalypFrame* pcFrame );
|
||||
void setImage( const QPixmap& pixmap );
|
||||
|
||||
void setMode( int mode );
|
||||
void setMaskColor( const QColor& color = QColor() );
|
||||
@@ -83,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; }
|
||||
@@ -148,8 +150,7 @@ private:
|
||||
QPoint viewToWindow( const QPoint& pt ) const;
|
||||
QRect viewToWindow( const QRect& rc ) const;
|
||||
|
||||
std::shared_ptr<CalypFrame> m_currFrame;
|
||||
std::shared_ptr<CalypFrame> m_nextFrame;
|
||||
CalypFrame* m_pcCurrFrame;
|
||||
|
||||
ClpPel m_uiPixelHalfScale;
|
||||
|
||||
@@ -160,8 +161,7 @@ private:
|
||||
double m_dZoomWinRatio;
|
||||
double m_dZoomFactor;
|
||||
|
||||
QImage m_image;
|
||||
//QPixmap m_pixmap;
|
||||
QPixmap m_pixmap;
|
||||
QBitmap m_mask;
|
||||
QRect m_selectedArea;
|
||||
QPoint m_lastPos;
|
||||
|
||||
@@ -395,7 +395,7 @@ int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, un
|
||||
int sampling = 0;
|
||||
if( rInputFormat >= 0 )
|
||||
{
|
||||
std::string pelFmtName = CalypFrame::supportedPixelFormatListNames()[rInputFormat];
|
||||
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++ )
|
||||
@@ -442,7 +442,7 @@ int ConfigureFormatDialog::runConfigureFormatDialog( const QString& Filename, un
|
||||
rHeight = m_spinBoxheight->value();
|
||||
colorSpace = m_comboBoxColorSpace->currentIndex();
|
||||
sampling = m_comboBoxPixelFormat->currentIndex();
|
||||
std::string pelFmtName = CalypFrame::supportedPixelFormatListNames( colorSpace )[sampling];
|
||||
ClpString pelFmtName = CalypFrame::supportedPixelFormatListNames( colorSpace )[sampling];
|
||||
for( unsigned int i = 0; i < CalypFrame::supportedPixelFormatListNames().size(); i++ )
|
||||
{
|
||||
if( pelFmtName == CalypFrame::supportedPixelFormatListNames()[i] )
|
||||
|
||||
@@ -72,13 +72,13 @@ public:
|
||||
}
|
||||
return m_pcValue->text();
|
||||
}
|
||||
const std::string& getName() { return m_cName; }
|
||||
const ClpString& getName() { return m_cName; }
|
||||
|
||||
private:
|
||||
QLineEdit* m_pcValue;
|
||||
QCheckBox* m_pcChecked;
|
||||
QLabel* m_pcDescription;
|
||||
std::string m_cName;
|
||||
ClpString m_cName;
|
||||
};
|
||||
|
||||
ModulesHandleOptDialog::ModulesHandleOptDialog( QWidget* parent, CalypAppModuleIf* pcCurrModuleIf )
|
||||
@@ -121,8 +121,8 @@ int ModulesHandleOptDialog::runConfiguration()
|
||||
return QDialog::Rejected;
|
||||
}
|
||||
|
||||
std::vector<std::string> argsArray;
|
||||
std::string optionString;
|
||||
std::vector<ClpString> argsArray;
|
||||
ClpString optionString;
|
||||
QString valueString( "" );
|
||||
|
||||
for( int i = 0; i < m_apcOptionList.size(); i++ )
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+1
-6
@@ -6,12 +6,7 @@ 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 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>.
|
||||
-34
@@ -1,37 +1,3 @@
|
||||
#### 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:
|
||||
|
||||
+1057
-6438
File diff suppressed because it is too large.
Load diff
+202
-1300
File diff suppressed because it is too large.
Load diff
@@ -31,7 +31,6 @@
|
||||
#include "DBusAppAdaptor.h"
|
||||
#endif
|
||||
#include <QApplication>
|
||||
#include <QStyleFactory>
|
||||
#ifdef USE_FERVOR
|
||||
#include "fvupdater.h"
|
||||
#endif
|
||||
|
||||
Binary file not shown.
@@ -41,41 +41,60 @@ class HistogramWorker : public QThread
|
||||
{
|
||||
private:
|
||||
QObject* m_parent;
|
||||
std::shared_ptr<CalypFrame> m_pcFrame;
|
||||
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( m_pcFrame.get() ); // NOLINT
|
||||
eventData->starting = true;
|
||||
start();
|
||||
QCoreApplication::postEvent( m_parent, eventData );
|
||||
m_pcFrame = NULL;
|
||||
m_parent = parent;
|
||||
}
|
||||
void run() override
|
||||
|
||||
void setup( CalypFrame* frame )
|
||||
{
|
||||
if( m_pcFrame != nullptr && m_parent != nullptr )
|
||||
m_pcFrame = frame;
|
||||
// run();
|
||||
start();
|
||||
}
|
||||
void run()
|
||||
{
|
||||
if( m_pcFrame && m_parent )
|
||||
{
|
||||
EventData* eventData = new EventData( m_pcFrame.get() ); // NOLINT
|
||||
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->starting = false;
|
||||
// eventData->success = m_pcFrame->getHasHistogram();
|
||||
eventData->success = true;
|
||||
eventData->frame = m_pcFrame;
|
||||
QCoreApplication::postEvent( m_parent, eventData );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Event
|
||||
*/
|
||||
class EventData : public QEvent
|
||||
{
|
||||
public:
|
||||
EventData( CalypFrame* f )
|
||||
: QEvent( QEvent::User ), frame{ f } {}
|
||||
CalypFrame* frame{ nullptr };
|
||||
bool starting{ false };
|
||||
bool success{ false };
|
||||
EventData()
|
||||
: QEvent( QEvent::User )
|
||||
{
|
||||
starting = false;
|
||||
success = false;
|
||||
frame = NULL;
|
||||
}
|
||||
|
||||
bool starting;
|
||||
bool success;
|
||||
CalypFrame* frame;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -220,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();
|
||||
}
|
||||
|
||||
@@ -245,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;
|
||||
}
|
||||
@@ -306,6 +323,8 @@ void HistogramWidget::customEvent( QEvent* event )
|
||||
emit signalHistogramComputationFailed();
|
||||
}
|
||||
}
|
||||
|
||||
// delete ed;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Data Loading Functions
|
||||
@@ -360,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() )
|
||||
@@ -478,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 );
|
||||
|
||||
@@ -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)
|
||||
@@ -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})
|
||||
+8
-8
@@ -18,20 +18,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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 = 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;
|
||||
@@ -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(), 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;
|
||||
+8
-8
@@ -18,29 +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
|
||||
class FrameBinarization_APIv1 : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( FrameBinarizationAPIv1 )
|
||||
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;
|
||||
}
|
||||
+23
-40
@@ -3,10 +3,8 @@
|
||||
#
|
||||
|
||||
INCLUDE(GNUInstallDirs)
|
||||
SET(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
|
||||
EXPORT(PACKAGE MyLib)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SET(Calyp_Lib_Frame_SRCS CalypPixel.cpp PixelFormats.h PixelFormats.cpp CalypFrame.h CalypFrame.cpp)
|
||||
|
||||
@@ -24,8 +22,17 @@ SET(Calyp_Lib_OptionParser_SRCS CalypOptions.h CalypOptions.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)
|
||||
@@ -34,10 +41,6 @@ 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)
|
||||
@@ -48,28 +51,13 @@ IF(USE_OPENCV)
|
||||
|
||||
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,27 @@ 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()
|
||||
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
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@" )
|
||||
+75
-12
@@ -28,8 +28,14 @@
|
||||
|
||||
#include <algorithm>
|
||||
#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
|
||||
{
|
||||
@@ -39,37 +45,94 @@ 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
|
||||
{
|
||||
std::string m_class_name;
|
||||
std::string m_error_msg;
|
||||
CalypFailure( std::string error_msg ) throw()
|
||||
ClpString m_class_name;
|
||||
ClpString m_error_msg;
|
||||
CalypFailure( ClpString error_msg ) throw()
|
||||
: m_error_msg( error_msg ) {}
|
||||
CalypFailure( std::string class_name, std::string error_msg ) throw()
|
||||
CalypFailure( ClpString class_name, ClpString error_msg ) throw()
|
||||
: m_class_name( class_name ), m_error_msg( error_msg )
|
||||
{
|
||||
}
|
||||
~CalypFailure() throw() {}
|
||||
const char* what() const throw()
|
||||
{
|
||||
std::string* msg = new std::string( "[" + m_class_name + "] " + m_error_msg );
|
||||
ClpString* msg = new ClpString( "[" + m_class_name + "] " + m_error_msg );
|
||||
return msg->c_str();
|
||||
}
|
||||
};
|
||||
|
||||
+136
-203
@@ -26,11 +26,9 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "LibMemory.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_OPENCV
|
||||
@@ -39,24 +37,9 @@
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#endif
|
||||
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#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
|
||||
|
||||
constexpr auto kMinBitsPerPixel = 8;
|
||||
constexpr auto kMaxBitsPerPixel = 16;
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedColorSpacesListNames()
|
||||
std::vector<ClpString> CalypFrame::supportedColorSpacesListNames()
|
||||
{
|
||||
return std::vector<std::string>{
|
||||
return std::vector<ClpString>{
|
||||
"YUV",
|
||||
"RGB",
|
||||
"GRAY",
|
||||
@@ -64,9 +47,9 @@ std::vector<std::string> CalypFrame::supportedColorSpacesListNames()
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedPixelFormatListNames()
|
||||
std::vector<ClpString> CalypFrame::supportedPixelFormatListNames()
|
||||
{
|
||||
std::vector<std::string> formatsList;
|
||||
std::vector<ClpString> formatsList;
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
{
|
||||
formatsList.push_back( g_CalypPixFmtDescriptorsMap.at( i ).name );
|
||||
@@ -74,9 +57,9 @@ std::vector<std::string> CalypFrame::supportedPixelFormatListNames()
|
||||
return formatsList;
|
||||
}
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedPixelFormatListNames( int colorSpace )
|
||||
std::vector<ClpString> CalypFrame::supportedPixelFormatListNames( int colorSpace )
|
||||
{
|
||||
std::vector<std::string> formatsList;
|
||||
std::vector<ClpString> formatsList;
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
{
|
||||
if( g_CalypPixFmtDescriptorsMap.at( i ).colorSpace == colorSpace )
|
||||
@@ -87,10 +70,10 @@ std::vector<std::string> CalypFrame::supportedPixelFormatListNames( int colorSpa
|
||||
|
||||
int CalypFrame::numberOfFormats()
|
||||
{
|
||||
return static_cast<int>( g_CalypPixFmtDescriptorsMap.size() );
|
||||
return g_CalypPixFmtDescriptorsMap.size();
|
||||
}
|
||||
|
||||
int CalypFrame::findPixelFormat( const std::string& name )
|
||||
int CalypFrame::findPixelFormat( const ClpString& name )
|
||||
{
|
||||
for( int i = 0; i < numberOfFormats(); i++ )
|
||||
{
|
||||
@@ -105,42 +88,36 @@ int CalypFrame::pelformatColorSpace( const int idx )
|
||||
return g_CalypPixFmtDescriptorsMap.at( idx ).colorSpace;
|
||||
}
|
||||
|
||||
class CalypFrame::CalypFramePrivate
|
||||
struct CalypFramePrivate
|
||||
{
|
||||
public:
|
||||
bool m_bInit{ false };
|
||||
bool m_bInit;
|
||||
|
||||
//! Struct with the pixel format description.
|
||||
const CalypPixelFormatDescriptor* m_pcPelFormat{ nullptr };
|
||||
std::string m_cPelFmtName;
|
||||
const CalypPixelFormatDescriptor* m_pcPelFormat;
|
||||
ClpString m_cPelFmtName;
|
||||
|
||||
unsigned int m_uiWidth{ 0 }; //!< Width of the frame
|
||||
unsigned int m_uiHeight{ 0 }; //!< Height of the frame
|
||||
int m_iPixelFormat{ 0 }; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel{ 0 }; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue{ 0 }; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues{ false }; //!< Half of the scale correspond to negative values
|
||||
unsigned int m_uiWidth; //!< Width of the frame
|
||||
unsigned int m_uiHeight; //!< Height of the frame
|
||||
int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues; //!< Half of the scale correspond to negative values
|
||||
|
||||
ClpPel*** m_pppcInputPel{ nullptr };
|
||||
ClpPel*** m_pppcInputPel;
|
||||
|
||||
bool m_bHasRGBPel{ false }; //!< Flag indicating that the ARGB buffer was computed
|
||||
std::vector<std::uint8_t> m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
unsigned char* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
|
||||
/** Histogram control variables **/
|
||||
bool m_bHasHistogram{ false };
|
||||
bool m_bHistogramRunning{ false };
|
||||
bool m_bHasHistogram;
|
||||
bool m_bHistogramRunning;
|
||||
/** The histogram data.*/
|
||||
std::vector<unsigned int> m_puiHistogram;
|
||||
unsigned int* m_puiHistogram;
|
||||
/** If the image is RGB and calcLuma is true, we have 1 more channel */
|
||||
unsigned int m_uiHistoChannels{ 0 };
|
||||
unsigned int m_uiHistoChannels;
|
||||
/** Numbers of histogram segments depending of image bytes depth*/
|
||||
unsigned int m_uiHistoSegments{ 0 };
|
||||
|
||||
CalypFramePrivate() = default;
|
||||
CalypFramePrivate( const CalypFramePrivate& ) = delete;
|
||||
CalypFramePrivate( CalypFramePrivate&& ) = delete;
|
||||
CalypFramePrivate& operator=( const CalypFramePrivate& ) = delete;
|
||||
CalypFramePrivate& operator=( CalypFramePrivate&& ) = delete;
|
||||
unsigned int m_uiHistoSegments;
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel )
|
||||
{
|
||||
@@ -149,16 +126,20 @@ public:
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel, bool has_negative_values )
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bHasRGBPel = false;
|
||||
m_pppcInputPel = NULL;
|
||||
m_pcARGB32 = NULL;
|
||||
m_uiWidth = width;
|
||||
m_uiHeight = height;
|
||||
m_iPixelFormat = pel_format;
|
||||
m_uiBitsPel = bitsPixel < kMinBitsPerPixel ? kMinBitsPerPixel : bitsPixel;
|
||||
m_uiBitsPel = bitsPixel < 8 ? 8 : bitsPixel;
|
||||
m_uiHalfPelValue = 1 << ( m_uiBitsPel - 1 );
|
||||
m_bHasNegativeValues = has_negative_values;
|
||||
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > kMaxBitsPerPixel )
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
|
||||
{
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a CalypFrame of this type" );
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a PlYUVerFrame of this type" );
|
||||
}
|
||||
|
||||
m_pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( pel_format ) );
|
||||
@@ -177,7 +158,7 @@ public:
|
||||
}
|
||||
mem_size += num_of_ptrs * sizeof( ClpPel* ) + sizeof( ClpPel** ) * iNumberChannels;
|
||||
|
||||
m_pppcInputPel = (ClpPel***)xMalloc( mem_size );
|
||||
m_pppcInputPel = (ClpPel***)xMallocMem( mem_size );
|
||||
|
||||
ClpPel** pelPtrMem = (ClpPel**)( m_pppcInputPel + iNumberChannels );
|
||||
ClpPel* pelMem = (ClpPel*)( pelPtrMem + num_of_ptrs );
|
||||
@@ -195,8 +176,9 @@ public:
|
||||
}
|
||||
|
||||
/* Alloc ARGB memory */
|
||||
m_pcARGB32.resize( m_uiHeight * m_uiWidth * 4 );
|
||||
getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 );
|
||||
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
m_bHistogramRunning = false;
|
||||
|
||||
@@ -208,7 +190,7 @@ public:
|
||||
else
|
||||
m_uiHistoChannels = m_pcPelFormat->numberChannels;
|
||||
|
||||
m_puiHistogram.resize( m_uiHistoSegments * m_uiHistoChannels );
|
||||
getMem1D<unsigned int>( &( m_puiHistogram ), m_uiHistoSegments * m_uiHistoChannels );
|
||||
|
||||
m_cPelFmtName = CalypFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str();
|
||||
|
||||
@@ -260,78 +242,53 @@ public:
|
||||
{
|
||||
while( m_bHistogramRunning )
|
||||
;
|
||||
if( m_puiHistogram )
|
||||
freeMem1D( m_puiHistogram );
|
||||
m_bHasHistogram = false;
|
||||
|
||||
if( m_pppcInputPel )
|
||||
xFreeMem( m_pppcInputPel );
|
||||
|
||||
if( m_pcARGB32 )
|
||||
freeMem1D( m_pcARGB32 );
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Constructors
|
||||
*/
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel );
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel, has_negative_values );
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( CalypFrame&& other ) noexcept
|
||||
: d{ std::move( other.d ) }
|
||||
{
|
||||
}
|
||||
|
||||
CalypFrame& CalypFrame::operator=( CalypFrame&& other ) noexcept
|
||||
{
|
||||
// Self-assignment detection
|
||||
if( &other == this )
|
||||
return *this;
|
||||
|
||||
// Transfer ownership of a.m_ptr to m_ptr
|
||||
d = std::move( other.d );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( const CalypFrame& other )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel(), other.getHasNegativeValues() );
|
||||
copyFrom( &other );
|
||||
}
|
||||
|
||||
// CalypFrame::CalypFrame( const CalypFrame* other )
|
||||
// : d{ std::make_unique<CalypFramePrivate>() }
|
||||
// {
|
||||
// if( other )
|
||||
// {
|
||||
// d->init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel(), other->getHasNegativeValues() );
|
||||
// copyFrom( other );
|
||||
// }
|
||||
// }
|
||||
|
||||
CalypFrame& CalypFrame::operator=( const CalypFrame& other )
|
||||
CalypFrame::CalypFrame( const CalypFrame* other )
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
// Self-assignment detection
|
||||
if( &other == this )
|
||||
return *this;
|
||||
|
||||
// Copy the resource
|
||||
d = std::make_unique<CalypFramePrivate>();
|
||||
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel(), other.getHasNegativeValues() );
|
||||
copyFrom( &other );
|
||||
|
||||
return *this;
|
||||
if( other )
|
||||
{
|
||||
d->init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel(), other->getHasNegativeValues() );
|
||||
copyFrom( other );
|
||||
}
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( other.getPelFormat() ) );
|
||||
if( pcPelFormat->log2ChromaWidth )
|
||||
@@ -356,7 +313,7 @@ CalypFrame::CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y,
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( const CalypFrame* other, unsigned int posX, unsigned int posY, unsigned int areaWidth, unsigned int areaHeight )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
: d( new CalypFramePrivate )
|
||||
{
|
||||
if( !other )
|
||||
return;
|
||||
@@ -383,7 +340,10 @@ CalypFrame::CalypFrame( const CalypFrame* other, unsigned int posX, unsigned int
|
||||
copyFrom( other, posX, posY );
|
||||
}
|
||||
|
||||
CalypFrame::~CalypFrame() = default;
|
||||
CalypFrame::~CalypFrame()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool CalypFrame::haveSameFmt( const CalypFrame& other, unsigned int match ) const
|
||||
{
|
||||
@@ -418,7 +378,7 @@ int CalypFrame::getPelFormat() const
|
||||
return d->m_iPixelFormat;
|
||||
}
|
||||
|
||||
std::string CalypFrame::getPelFmtName()
|
||||
ClpString CalypFrame::getPelFmtName()
|
||||
{
|
||||
return d->m_pcPelFormat->name;
|
||||
}
|
||||
@@ -447,14 +407,14 @@ bool CalypFrame::getHasNegativeValues() const
|
||||
return d->m_bHasNegativeValues;
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getPixels( unsigned channel ) const
|
||||
ClpULong CalypFrame::getPixels( unsigned channel ) const
|
||||
{
|
||||
return getWidth( channel ) * getHeight( channel );
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getTotalNumberOfPixels() const
|
||||
ClpULong CalypFrame::getTotalNumberOfPixels() const
|
||||
{
|
||||
std::uint64_t numberPixels = 0;
|
||||
ClpULong numberPixels = 0;
|
||||
for( unsigned i = 0; i < getNumberChannels(); i++ )
|
||||
{
|
||||
numberPixels += getPixels( i );
|
||||
@@ -472,7 +432,7 @@ unsigned CalypFrame::getChromaHeightRatio() const
|
||||
return d->m_pcPelFormat->log2ChromaHeight;
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getChromaLength() const
|
||||
ClpULong CalypFrame::getChromaLength() const
|
||||
{
|
||||
return getWidth( 1 ) * getHeight( 1 );
|
||||
}
|
||||
@@ -482,19 +442,19 @@ unsigned int CalypFrame::getBitsPel() const
|
||||
return d->m_uiBitsPel;
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getBytesPerFrame() const
|
||||
ClpULong CalypFrame::getBytesPerFrame() const
|
||||
{
|
||||
return getBytesPerFrame( d->m_uiWidth, d->m_uiHeight, d->m_iPixelFormat, d->m_uiBitsPel );
|
||||
}
|
||||
|
||||
std::uint64_t CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel )
|
||||
ClpULong CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel )
|
||||
{
|
||||
const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( iPixelFormat ) );
|
||||
unsigned int bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
|
||||
std::uint64_t numberBytes = uiWidth * uiHeight;
|
||||
ClpULong numberBytes = uiWidth * uiHeight;
|
||||
if( pcPelFormat->numberChannels > 1 )
|
||||
{
|
||||
std::uint64_t numberBytesChroma =
|
||||
ClpULong numberBytesChroma =
|
||||
CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
|
||||
numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma;
|
||||
}
|
||||
@@ -531,11 +491,11 @@ ClpPel*** CalypFrame::getPelBufferYUV()
|
||||
return d->m_pppcInputPel;
|
||||
}
|
||||
|
||||
auto CalypFrame::getRGBBuffer() const -> const unsigned char*
|
||||
unsigned char* CalypFrame::getRGBBuffer() const
|
||||
{
|
||||
if( d->m_bHasRGBPel )
|
||||
{
|
||||
return d->m_pcARGB32.data();
|
||||
return d->m_pcARGB32;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -627,7 +587,7 @@ void CalypFrame::copyFrom( const CalypFrame* other, unsigned x, unsigned y )
|
||||
copyFrom( *other, x, y );
|
||||
}
|
||||
|
||||
void CalypFrame::copyTo( const CalypFrame& other, unsigned x, unsigned y ) const
|
||||
void CalypFrame::copyTo( const CalypFrame& other, unsigned x, unsigned y )
|
||||
{
|
||||
if( !haveSameFmt( other, MATCH_COLOR_SPACE | MATCH_PEL_FMT | MATCH_BITS ) )
|
||||
return;
|
||||
@@ -648,13 +608,13 @@ void CalypFrame::copyTo( const CalypFrame& other, unsigned x, unsigned y ) const
|
||||
d->m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
void CalypFrame::copyTo( const CalypFrame* other, unsigned x, unsigned y ) const
|
||||
void CalypFrame::copyTo( const CalypFrame* other, unsigned x, unsigned y )
|
||||
{
|
||||
if( other )
|
||||
copyTo( *other, x, y );
|
||||
}
|
||||
|
||||
void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndianness, unsigned long uiBuffSize )
|
||||
void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness, unsigned long uiBuffSize )
|
||||
{
|
||||
if( uiBuffSize != getBytesPerFrame() )
|
||||
return;
|
||||
@@ -662,14 +622,19 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
frameFromBuffer( Buff, iEndianness );
|
||||
}
|
||||
|
||||
void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndianness )
|
||||
void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness )
|
||||
{
|
||||
const ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
ClpByte* pTmpBuff;
|
||||
ClpPel* pPel;
|
||||
unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
int ratioH, ratioW, step;
|
||||
unsigned int i, ch;
|
||||
int startByte = 0;
|
||||
int endByte = bytesPixel;
|
||||
int incByte = 1;
|
||||
int maxval = ( 1 << d->m_uiBitsPel ) - 1;
|
||||
int b;
|
||||
int maxval = pow( 2, d->m_uiBitsPel ) - 1;
|
||||
|
||||
if( iEndianness == CLP_BIG_ENDIAN )
|
||||
{
|
||||
@@ -678,36 +643,37 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
incByte = -1;
|
||||
}
|
||||
|
||||
ppBuff[0] = Buff.data();
|
||||
for( unsigned i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
ppBuff[0] = Buff;
|
||||
for( i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
{
|
||||
int ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
|
||||
}
|
||||
|
||||
memset( d->m_pppcInputPel[0][0], 0, getTotalNumberOfPixels() * sizeof( ClpPel ) );
|
||||
|
||||
for( unsigned ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
int step = ( d->m_pcPelFormat->comp[ch].step_minus1 ) * bytesPixel;
|
||||
ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
step = ( d->m_pcPelFormat->comp[ch].step_minus1 ) * bytesPixel;
|
||||
|
||||
ClpPel* pPel = d->m_pppcInputPel[ch][0];
|
||||
const ClpByte* pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * bytesPixel;
|
||||
pPel = d->m_pppcInputPel[ch][0];
|
||||
pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * bytesPixel;
|
||||
|
||||
for( unsigned p = 0; p < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); p++ )
|
||||
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
{
|
||||
for( int b = startByte; b != endByte; b += incByte )
|
||||
*pPel = 0;
|
||||
for( b = startByte; b != endByte; b += incByte )
|
||||
{
|
||||
pPel[p] += *pTmpBuff << ( b * 8 );
|
||||
*pPel += *pTmpBuff << ( b * 8 );
|
||||
pTmpBuff++;
|
||||
// Check max value and bound it to "maxval" to prevent segfault when
|
||||
// calculating histogram
|
||||
if( *pPel > maxval )
|
||||
*pPel = 0;
|
||||
// -----
|
||||
}
|
||||
// Check max value and bound it to "maxval" to prevent segfault when
|
||||
// calculating histogram
|
||||
if( pPel[p] > maxval )
|
||||
pPel[p] = 0;
|
||||
pPel++;
|
||||
pTmpBuff += step;
|
||||
}
|
||||
}
|
||||
@@ -715,7 +681,7 @@ void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndiann
|
||||
d->m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndianness ) const
|
||||
void CalypFrame::frameToBuffer( ClpByte* output_buffer, int iEndianness )
|
||||
{
|
||||
unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
@@ -735,7 +701,7 @@ void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndian
|
||||
incByte = -1;
|
||||
}
|
||||
|
||||
ppBuff[0] = output_buffer.data();
|
||||
ppBuff[0] = output_buffer;
|
||||
for( int i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
{
|
||||
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
@@ -765,6 +731,8 @@ void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndian
|
||||
}
|
||||
}
|
||||
|
||||
void CalypFrame::fillRGBBuffer()
|
||||
{
|
||||
#define PEL_ARGB( a, r, g, b ) ( ( a & 0xff ) << 24 ) | ( ( r & 0xff ) << 16 ) | ( ( g & 0xff ) << 8 ) | ( b & 0xff )
|
||||
#define PEL_RGB( r, g, b ) PEL_ARGB( 0xffu, r, g, b )
|
||||
#define CLAMP_YUV2RGB( X ) X = X < 0 ? 0 : X > 255 ? 255 : \
|
||||
@@ -777,51 +745,16 @@ void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndian
|
||||
CLAMP_YUV2RGB( iG ) \
|
||||
CLAMP_YUV2RGB( iB )
|
||||
|
||||
void fillRGBBufferYUV420p( ClpPel*** pppInputPel, uint32_t* pARGB, unsigned uiWidth, unsigned uiHeight, int shiftBits )
|
||||
{
|
||||
ClpPel* pY = pppInputPel[CLP_LUMA][0];
|
||||
ClpPel* pU = pppInputPel[CLP_CHROMA_U][0];
|
||||
ClpPel* pV = pppInputPel[CLP_CHROMA_V][0];
|
||||
|
||||
for( unsigned y = 0; y < uiHeight; y += 2 )
|
||||
{
|
||||
for( unsigned x = 0; x < uiWidth; x += 2 )
|
||||
{
|
||||
int iY, iU, iV, iR, iG, iB;
|
||||
iY = pY[y * uiWidth + x] >> shiftBits;
|
||||
iU = pU[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
iV = pV[y * uiWidth / 4 + x / 2] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x] = PEL_RGB( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + x + 1] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + x + 1] = PEL_RGB( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + uiWidth + x] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x] = PEL_RGB( iR, iG, iB );
|
||||
|
||||
iY = pY[y * uiWidth + uiWidth + x + 1] >> shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
pARGB[y * uiWidth + uiWidth + x + 1] = PEL_RGB( iR, iG, iB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CalypFrame::fillRGBBuffer() const
|
||||
{
|
||||
if( d->m_bHasRGBPel )
|
||||
return;
|
||||
int shiftBits = d->m_uiBitsPel - 8;
|
||||
|
||||
d->m_bHasRGBPel = true;
|
||||
// 4 bytes for A, R, G and B
|
||||
uint32_t* pARGB = (uint32_t*)d->m_pcARGB32.data();
|
||||
uint32_t* pARGB = (uint32_t*)d->m_pcARGB32;
|
||||
if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
{
|
||||
ClpPel* pY = d->m_pppcInputPel[CLP_LUMA][0];
|
||||
unsigned char finalPel{ 0 };
|
||||
unsigned char finalPel;
|
||||
for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
|
||||
{
|
||||
finalPel = ( *pY++ ) >> shiftBits;
|
||||
@@ -847,37 +780,36 @@ void CalypFrame::fillRGBBuffer() const
|
||||
}
|
||||
else if( d->m_pcPelFormat->colorSpace == CLP_COLOR_YUV )
|
||||
{
|
||||
if( d->m_iPixelFormat == CLP_YUV420P )
|
||||
{
|
||||
fillRGBBufferYUV420p( d->m_pppcInputPel, pARGB, d->m_uiWidth, d->m_uiHeight, shiftBits );
|
||||
return;
|
||||
}
|
||||
ClpPel* pLineY = d->m_pppcInputPel[CLP_LUMA][0];
|
||||
ClpPel* pLineU = d->m_pppcInputPel[CLP_CHROMA_U][0];
|
||||
ClpPel* pLineV = d->m_pppcInputPel[CLP_CHROMA_V][0];
|
||||
unsigned int uiChromaStride = CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth );
|
||||
|
||||
int iR, iG, iB;
|
||||
ClpPel* pY;
|
||||
ClpPel* pU;
|
||||
ClpPel* pV;
|
||||
int iY, iU, iV, iR, iG, iB;
|
||||
uint32_t* pARGBLine = pARGB;
|
||||
uint32_t* pARGBAux;
|
||||
|
||||
for( unsigned y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
unsigned int y, x;
|
||||
int i, j;
|
||||
for( y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
{
|
||||
for( int i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
|
||||
for( i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
|
||||
{
|
||||
ClpPel* pY = pLineY;
|
||||
ClpPel* pU = pLineU;
|
||||
ClpPel* pV = pLineV;
|
||||
pY = pLineY;
|
||||
pU = pLineU;
|
||||
pV = pLineV;
|
||||
pARGBAux = pARGBLine;
|
||||
for( unsigned x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
for( x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
{
|
||||
int iU = *pU++;
|
||||
iU = *pU++;
|
||||
iU >>= shiftBits;
|
||||
int iV = *pV++;
|
||||
iV = *pV++;
|
||||
iV >>= shiftBits;
|
||||
for( int j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
|
||||
for( j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
|
||||
{
|
||||
int iY = *pY++;
|
||||
iY = *pY++;
|
||||
iY >>= shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
*pARGBAux++ = PEL_RGB( iR, iG, iB );
|
||||
@@ -890,6 +822,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
pLineV += uiChromaStride;
|
||||
}
|
||||
}
|
||||
d->m_bHasRGBPel = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,12 +831,12 @@ void CalypFrame::fillRGBBuffer() const
|
||||
|
||||
void CalypFrame::calcHistogram()
|
||||
{
|
||||
if( d->m_bHasHistogram || d->m_puiHistogram.empty() )
|
||||
if( d->m_bHasHistogram || !d->m_puiHistogram )
|
||||
return;
|
||||
|
||||
d->m_bHistogramRunning = true;
|
||||
|
||||
std::fill( d->m_puiHistogram.begin(), d->m_puiHistogram.end(), 0 );
|
||||
xMemSet( unsigned int, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram );
|
||||
|
||||
unsigned int numberChannels = d->m_pcPelFormat->numberChannels;
|
||||
for( unsigned int ch = 0; ch < numberChannels; ch++ )
|
||||
@@ -1232,7 +1165,7 @@ double CalypFrame::getEntropy( unsigned channel, unsigned int start, unsigned in
|
||||
**************************************************************
|
||||
*/
|
||||
|
||||
bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned channel ) const
|
||||
bool CalypFrame::toMat( cv::Mat& cvMat, bool convertToGray, bool scale, unsigned channel )
|
||||
{
|
||||
bool bRet = false;
|
||||
#ifdef USE_OPENCV
|
||||
@@ -1400,9 +1333,9 @@ bool CalypFrame::fromMat( cv::Mat& cvMat, int channel )
|
||||
**************************************************************
|
||||
*/
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedQualityMetricsList()
|
||||
std::vector<ClpString> CalypFrame::supportedQualityMetricsList()
|
||||
{
|
||||
return std::vector<std::string>{
|
||||
return std::vector<ClpString>{
|
||||
"PSNR",
|
||||
"MSE",
|
||||
"SSIM",
|
||||
@@ -1410,9 +1343,9 @@ std::vector<std::string> CalypFrame::supportedQualityMetricsList()
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> CalypFrame::supportedQualityMetricsUnitsList()
|
||||
std::vector<ClpString> CalypFrame::supportedQualityMetricsUnitsList()
|
||||
{
|
||||
return std::vector<std::string>{
|
||||
return std::vector<ClpString>{
|
||||
"dB",
|
||||
"",
|
||||
"",
|
||||
@@ -1450,8 +1383,8 @@ double CalypFrame::getMSE( CalypFrame* Org, unsigned int component )
|
||||
{
|
||||
ClpPel* pPelYUV = getPelBufferYUV()[component][0];
|
||||
ClpPel* pOrgPelYUV = Org->getPelBufferYUV()[component][0];
|
||||
std::uint64_t numberOfPixels = Org->getHeight( component ) * Org->getWidth( component );
|
||||
std::uint64_t ssd = 0;
|
||||
ClpULong numberOfPixels = Org->getHeight( component ) * Org->getWidth( component );
|
||||
ClpULong ssd = 0;
|
||||
for( unsigned int i = 0; i < numberOfPixels; i++ )
|
||||
{
|
||||
int diff = int( *pPelYUV++ ) - int( *pOrgPelYUV++ );
|
||||
@@ -1466,7 +1399,7 @@ double CalypFrame::getMSE( CalypFrame* Org, unsigned int component )
|
||||
|
||||
double CalypFrame::getPSNR( CalypFrame* Org, unsigned int component )
|
||||
{
|
||||
std::uint64_t uiMaxValue = ( 1 << Org->getBitsPel() ) - 1;
|
||||
ClpULong uiMaxValue = ( 1 << Org->getBitsPel() ) - 1;
|
||||
double dPSNR = 100;
|
||||
double dMSE = getMSE( Org, component );
|
||||
if( dMSE != 0 )
|
||||
|
||||
+24
-152
@@ -26,77 +26,13 @@
|
||||
#ifndef __CALYPFRAME_H__
|
||||
#define __CALYPFRAME_H__
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "CalypDefs.h"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
class Mat;
|
||||
}
|
||||
|
||||
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 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,
|
||||
};
|
||||
|
||||
#define CHROMASHIFT( SIZE, SHIFT ) (unsigned int)( -( ( -( (int)( SIZE ) ) ) >> ( SHIFT ) ) )
|
||||
|
||||
/**
|
||||
@@ -137,50 +73,7 @@ public:
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace );
|
||||
|
||||
private:
|
||||
class CalypPixelPrivate;
|
||||
std::unique_ptr<CalypPixelPrivate> d;
|
||||
};
|
||||
|
||||
/**
|
||||
* \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 );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T> m_data;
|
||||
std::vector<std::span<T>> m_rows;
|
||||
struct CalypPixelPrivate* d;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -196,17 +89,17 @@ public:
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedColorSpacesListNames();
|
||||
static std::vector<ClpString> supportedColorSpacesListNames();
|
||||
|
||||
/**
|
||||
* Function that handles the supported pixel formats
|
||||
* of CalypFrame
|
||||
* @return vector of strings with pixel formats names
|
||||
*/
|
||||
static std::vector<std::string> supportedPixelFormatListNames();
|
||||
static std::vector<std::string> supportedPixelFormatListNames( int colorSpace );
|
||||
static std::vector<ClpString> supportedPixelFormatListNames();
|
||||
static std::vector<ClpString> supportedPixelFormatListNames( int colorSpace );
|
||||
static int numberOfFormats();
|
||||
static int findPixelFormat( const std::string& name );
|
||||
static int findPixelFormat( const ClpString& name );
|
||||
static int pelformatColorSpace( const int idx );
|
||||
|
||||
/**
|
||||
@@ -231,33 +124,13 @@ public:
|
||||
*/
|
||||
CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values );
|
||||
|
||||
/**
|
||||
* Move contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( CalypFrame&& other ) noexcept;
|
||||
|
||||
/**
|
||||
* Move assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame& operator=( CalypFrame&& other ) noexcept;
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame( const CalypFrame& other );
|
||||
|
||||
/**
|
||||
* Copy-assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame& operator=( const CalypFrame& other );
|
||||
CalypFrame( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
@@ -307,7 +180,7 @@ public:
|
||||
* Get pixel format information
|
||||
* @return pixel format name
|
||||
*/
|
||||
std::string getPelFmtName();
|
||||
ClpString getPelFmtName();
|
||||
|
||||
/**
|
||||
* Get color space information
|
||||
@@ -346,13 +219,13 @@ public:
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getPixels( unsigned channel = 0 ) const;
|
||||
ClpULong getPixels( unsigned channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get the total number of pixels of the frame
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getTotalNumberOfPixels() const;
|
||||
ClpULong getTotalNumberOfPixels() const;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
@@ -370,7 +243,7 @@ public:
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
std::uint64_t getChromaLength() const;
|
||||
ClpULong getChromaLength() const;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
@@ -382,13 +255,13 @@ public:
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
std::uint64_t getBytesPerFrame() const;
|
||||
ClpULong getBytesPerFrame() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static std::uint64_t getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
static ClpULong getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
@@ -398,7 +271,7 @@ public:
|
||||
ClpPel*** getPelBufferYUV() const;
|
||||
ClpPel*** getPelBufferYUV();
|
||||
|
||||
auto getRGBBuffer() const -> const unsigned char*;
|
||||
unsigned char* getRGBBuffer() const;
|
||||
|
||||
/**
|
||||
* Get pixel value at coordinates
|
||||
@@ -467,14 +340,14 @@ public:
|
||||
* @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;
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int, unsigned long );
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int );
|
||||
void frameToBuffer( std::vector<ClpByte>&, int ) const;
|
||||
void frameFromBuffer( ClpByte*, int, unsigned long );
|
||||
void frameFromBuffer( ClpByte*, int );
|
||||
void frameToBuffer( ClpByte*, int );
|
||||
|
||||
void fillRGBBuffer() const;
|
||||
void fillRGBBuffer();
|
||||
|
||||
/**
|
||||
* Histogram
|
||||
@@ -513,7 +386,7 @@ public:
|
||||
/**
|
||||
* interface with OpenCV lib
|
||||
*/
|
||||
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 ) const;
|
||||
bool toMat( cv::Mat& cvMat, bool convertToGray = false, bool scale = true, unsigned channel = 0 );
|
||||
bool fromMat( cv::Mat& cvMat, int iChannel = -1 );
|
||||
|
||||
/**
|
||||
@@ -534,8 +407,8 @@ public:
|
||||
NUMBER_METRICS,
|
||||
};
|
||||
|
||||
static std::vector<std::string> supportedQualityMetricsList();
|
||||
static std::vector<std::string> supportedQualityMetricsUnitsList();
|
||||
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 );
|
||||
@@ -544,8 +417,7 @@ public:
|
||||
/** @} */
|
||||
|
||||
private:
|
||||
class CalypFramePrivate;
|
||||
std::unique_ptr<CalypFramePrivate> d;
|
||||
struct CalypFramePrivate* d;
|
||||
};
|
||||
|
||||
#endif // __CALYPFRAME_H__
|
||||
+28
-69
@@ -34,24 +34,15 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypOptions.h"
|
||||
|
||||
#define REGISTER_CLASS_MAKER( X ) \
|
||||
extern "C" CalypModulePtr Maker() { return std::make_unique<X>(); }
|
||||
#define REGISTER_CLASS_FACTORY( X ) \
|
||||
public: \
|
||||
X( const X& buffer ) \
|
||||
noexcept = delete; \
|
||||
X( X&& buffer ) \
|
||||
noexcept = delete; \
|
||||
auto operator=( const X& buffer )->X& = delete; \
|
||||
auto operator=( X&& buffer ) noexcept->X& = delete; \
|
||||
static CalypModulePtr Create() { return std::make_unique<X>(); }
|
||||
|
||||
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; \
|
||||
@@ -83,9 +74,8 @@ enum Module_API_Version
|
||||
*/
|
||||
enum Module_Type
|
||||
{
|
||||
CLP_INVALID_MODULE = -1,
|
||||
CLP_FRAME_PROCESSING_MODULE = 0,
|
||||
CLP_FRAME_MEASUREMENT_MODULE = 1,
|
||||
CLP_FRAME_PROCESSING_MODULE,
|
||||
CLP_FRAME_MEASUREMENT_MODULE,
|
||||
CLP_MODULE_TYPE_MAX = 255,
|
||||
};
|
||||
|
||||
@@ -122,25 +112,33 @@ enum Module_Key_Supported
|
||||
class CalypModuleIf
|
||||
{
|
||||
public:
|
||||
int m_iModuleAPI{ CLP_MODULE_API_1 };
|
||||
int m_iModuleType{ CLP_INVALID_MODULE };
|
||||
const char* m_pchModuleCategory{ "" };
|
||||
const char* m_pchModuleName{ "" };
|
||||
const char* m_pchModuleTooltip{ "" };
|
||||
const char* m_pchModuleLongName{ "" };
|
||||
int m_iModuleAPI;
|
||||
int m_iModuleType;
|
||||
const char* m_pchModuleCategory;
|
||||
const char* m_pchModuleName;
|
||||
const char* m_pchModuleTooltip;
|
||||
const char* m_pchModuleLongName;
|
||||
|
||||
//! Number of frames
|
||||
unsigned int m_uiNumberOfFrames{ 1 };
|
||||
unsigned int m_uiNumberOfFrames;
|
||||
//! Features/Requirements
|
||||
unsigned int m_uiModuleRequirements{ CLP_MODULE_REQUIRES_NOTHING };
|
||||
unsigned int m_uiModuleRequirements;
|
||||
|
||||
unsigned int m_iFrameBufferCount{ 0 };
|
||||
//CalypFrame* m_pcOutputFrame;
|
||||
unsigned int m_iFrameBufferCount;
|
||||
CalypFrame* m_pcOutputFrame;
|
||||
|
||||
CalypOptions m_cModuleOptions;
|
||||
|
||||
CalypModuleIf() = default;
|
||||
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()
|
||||
@@ -161,11 +159,11 @@ 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()
|
||||
{
|
||||
@@ -174,43 +172,4 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
protected:
|
||||
//const char* m_pchPythonFunctionName;
|
||||
std::unique_ptr<CalypFrame> m_pcOutputFrame;
|
||||
bool m_bConvertToGray;
|
||||
|
||||
public:
|
||||
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( const std::vector<Mat>& apcFrameList ) { return nullptr; };
|
||||
virtual Mat* process_using_opencv( const std::vector<Mat>& apcFrameList ) = 0;
|
||||
virtual void destroy_using_opencv(){};
|
||||
};
|
||||
|
||||
using CalypModulePtr = std::unique_ptr<CalypModuleIf>;
|
||||
|
||||
#endif // __CALYPMODULESIF_H__
|
||||
@@ -22,47 +22,62 @@
|
||||
* \brief Calyp modules interface for OpenCV
|
||||
*/
|
||||
|
||||
#include "CalypModuleIf.h"
|
||||
#include "CalypOpenCVModuleIf.h"
|
||||
|
||||
// OpenCV
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using cv::Mat;
|
||||
|
||||
bool CalypOpenCVModuleIf::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_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 )
|
||||
{
|
||||
unsigned pelFormat = m_bConvertToGray ? CalypFrame::findPixelFormat( "GRAY" ) : apcFrameList[0]->getPelFormat();
|
||||
m_pcOutputFrame = std::make_unique<CalypFrame>( outputMat->cols, outputMat->rows, pelFormat, apcFrameList[0]->getBitsPel() );
|
||||
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;
|
||||
}
|
||||
|
||||
CalypFrame* CalypOpenCVModuleIf::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
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();
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
delete acMatList[i];
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void CalypOpenCVModuleIf::destroy()
|
||||
{
|
||||
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,51 +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
|
||||
class Mat;
|
||||
}
|
||||
|
||||
/**
|
||||
* \class CalypOpenCVModuleIf
|
||||
* \ingroup CalypLib Calyp_Modules
|
||||
* \brief Abstract class for modules using OpenCV library
|
||||
*/
|
||||
class CalypOpenCVModuleIf : public CalypModuleIf
|
||||
{
|
||||
unsigned rows;
|
||||
unsigned cols;
|
||||
int numFaces;
|
||||
ClpFaceProperty faces[60];
|
||||
};
|
||||
|
||||
class ThreeSixtyDynamicDownsampling : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyDynamicDownsampling )
|
||||
|
||||
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__
|
||||
+37
-37
@@ -49,9 +49,9 @@ using namespace std;
|
||||
|
||||
struct ParseFailure : public std::exception
|
||||
{
|
||||
std::string arg;
|
||||
std::string val;
|
||||
ParseFailure( std::string arg0, std::string val0 ) throw()
|
||||
ClpString arg;
|
||||
ClpString val;
|
||||
ParseFailure( ClpString arg0, ClpString val0 ) throw()
|
||||
: arg( arg0 ), val( val0 ) {}
|
||||
~ParseFailure() throw() {}
|
||||
const char* what() const throw() { return "Option Parse Failure"; }
|
||||
@@ -61,9 +61,9 @@ struct ParseFailure : public std::exception
|
||||
class boolOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
boolOption( const std::string& name, const std::string& desc )
|
||||
boolOption( const ClpString& name, const ClpString& desc )
|
||||
: OptionBase( name, desc, "(1-0)" ) { is_binary = true; }
|
||||
void parse( const std::string& arg ) { arg_count++; }
|
||||
void parse( const ClpString& arg ) { arg_count++; }
|
||||
};
|
||||
|
||||
/** Type specific option storage */
|
||||
@@ -71,20 +71,20 @@ template <typename T>
|
||||
class StandardOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
StandardOption( const std::string& name, T& storage, const std::string& desc, const std::string& def )
|
||||
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 );
|
||||
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 )
|
||||
{
|
||||
@@ -103,7 +103,7 @@ 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;
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
@@ -121,7 +121,7 @@ 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;
|
||||
std::istringstream arg_ss( arg, std::istringstream::in );
|
||||
@@ -140,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++;
|
||||
@@ -148,7 +148,7 @@ 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++;
|
||||
@@ -158,15 +158,15 @@ inline void StandardOption<std::vector<std::string>>::parse( const std::string&
|
||||
struct FunctionOption : public OptionBase
|
||||
{
|
||||
public:
|
||||
typedef void( Func )( CalypOptions&, const std::string& );
|
||||
typedef void( Func )( CalypOptions&, const ClpString& );
|
||||
|
||||
FunctionOption( const std::string& name, CalypOptions& parent_, Func* func_, const std::string& desc, const std::string& def )
|
||||
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 )
|
||||
void parse( const ClpString& arg )
|
||||
{
|
||||
func( parent, arg );
|
||||
arg_count++;
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
|
||||
private:
|
||||
CalypOptions& parent;
|
||||
void ( *func )( CalypOptions&, const std::string& );
|
||||
void ( *func )( CalypOptions&, const ClpString& );
|
||||
};
|
||||
|
||||
/* Helper method to initiate adding options to Options */
|
||||
@@ -185,7 +185,7 @@ 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 )
|
||||
{
|
||||
addOption( new boolOption( name, desc ) );
|
||||
return *this;
|
||||
@@ -197,31 +197,31 @@ CalypOptions& CalypOptions::operator()( const std::string& name, const std::stri
|
||||
* 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 )
|
||||
{
|
||||
addOption( new 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 )
|
||||
{
|
||||
addOption( new StandardOption<T>( name, storage, desc ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
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 );
|
||||
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 ) {}
|
||||
@@ -232,7 +232,7 @@ CalypOptions::Option::~Option()
|
||||
delete opt;
|
||||
}
|
||||
|
||||
CalypOptions::CalypOptions( const std::string& name )
|
||||
CalypOptions::CalypOptions( const ClpString& name )
|
||||
{
|
||||
m_cOptionGroupName = name;
|
||||
m_bAllowUnkonw = true;
|
||||
@@ -246,12 +246,12 @@ CalypOptions::~CalypOptions()
|
||||
}
|
||||
}
|
||||
|
||||
OptionBase* CalypOptions::operator[]( const std::string& optName )
|
||||
OptionBase* CalypOptions::operator[]( const ClpString& optName )
|
||||
{
|
||||
return getOption( optName );
|
||||
}
|
||||
|
||||
OptionBase* CalypOptions::getOption( const std::string& optName )
|
||||
OptionBase* CalypOptions::getOption( const ClpString& optName )
|
||||
{
|
||||
CalypOptions::OptionMap::iterator opt_it;
|
||||
opt_it = opt_short_map.find( optName );
|
||||
@@ -275,7 +275,7 @@ OptionBase* CalypOptions::getOption( const std::string& optName )
|
||||
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;
|
||||
@@ -545,7 +545,7 @@ 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++ )
|
||||
{
|
||||
|
||||
+20
-21
@@ -42,7 +42,6 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
|
||||
@@ -56,17 +55,17 @@
|
||||
class OptionBase
|
||||
{
|
||||
public:
|
||||
OptionBase( const std::string& name, const std::string& desc, const std::string& def )
|
||||
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 std::string& arg ) = 0;
|
||||
virtual void parse( const ClpString& arg ) = 0;
|
||||
int count() { return arg_count; }
|
||||
bool isBinary() { return is_binary; }
|
||||
int arg_count;
|
||||
std::string opt_string;
|
||||
std::string opt_desc;
|
||||
std::string opt_defaults;
|
||||
ClpString opt_string;
|
||||
ClpString opt_desc;
|
||||
ClpString opt_defaults;
|
||||
bool is_binary;
|
||||
};
|
||||
|
||||
@@ -82,25 +81,25 @@ public:
|
||||
{
|
||||
Option();
|
||||
~Option();
|
||||
std::list<std::string> opt_long;
|
||||
std::list<std::string> opt_short;
|
||||
std::list<ClpString> opt_long;
|
||||
std::list<ClpString> opt_short;
|
||||
OptionBase* opt;
|
||||
};
|
||||
typedef std::list<Option*> OptionsList;
|
||||
|
||||
CalypOptions( const std::string& name = "" );
|
||||
CalypOptions( const ClpString& name = "" );
|
||||
~CalypOptions();
|
||||
|
||||
int parse( unsigned int argc, char* argv[] );
|
||||
void parse( std::vector<std::string> args_array );
|
||||
void parse( std::vector<ClpString> args_array );
|
||||
|
||||
std::list<const char*>& getUnhandledArgs() { return m_aUnhandledArgs; }
|
||||
void doHelp( std::ostream& out, unsigned columns = 80 );
|
||||
|
||||
OptionBase* operator[]( const std::string& optName );
|
||||
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 );
|
||||
|
||||
OptionsList getOptionList() { return opt_list; }
|
||||
void addDefaultOptions();
|
||||
@@ -113,7 +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& operator()( const ClpString& name, const ClpString& desc );
|
||||
|
||||
/**
|
||||
* Add option described by name to the parent Options list,
|
||||
@@ -122,28 +121,28 @@ public:
|
||||
* description and range along with default value
|
||||
*/
|
||||
template <typename T>
|
||||
CalypOptions& operator()( 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 );
|
||||
CalypOptions& operator()( const ClpString& name, T& storage, const ClpString& desc, const ClpString& defaults );
|
||||
|
||||
bool checkListingOpts();
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, OptionsList> OptionMap;
|
||||
typedef std::map<ClpString, OptionsList> OptionMap;
|
||||
OptionMap opt_long_map;
|
||||
OptionMap opt_short_map;
|
||||
|
||||
OptionsList opt_list;
|
||||
|
||||
std::string m_cOptionGroupName;
|
||||
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 );
|
||||
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( std::string arg );
|
||||
unsigned int parseLONG( ClpString arg );
|
||||
unsigned int parseSHORT( unsigned int argc, char* argv[] );
|
||||
std::list<const char*> scanArgv( unsigned int argc, char* argv[] );
|
||||
};
|
||||
|
||||
+10
-11
@@ -22,17 +22,14 @@
|
||||
* \brief Video Frame handling
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#define MAX_NUMBER_COMPONENTS 4
|
||||
|
||||
class CalypPixel::CalypPixelPrivate
|
||||
struct CalypPixelPrivate
|
||||
{
|
||||
public:
|
||||
CalypPixelPrivate( const int& ColorSpace )
|
||||
{
|
||||
iColorSpace = ColorSpace == CLP_COLOR_GRAY ?
|
||||
@@ -74,18 +71,18 @@ int CalypPixel::getMaxNumberOfComponents()
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0 )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2 )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
@@ -93,7 +90,7 @@ CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2, const ClpPel& c3 )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
@@ -102,8 +99,7 @@ CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const CalypPixel& other )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( other.colorSpace() ) }
|
||||
|
||||
: d( new CalypPixelPrivate( other.colorSpace() ) )
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
@@ -111,7 +107,10 @@ CalypPixel::CalypPixel( const CalypPixel& other )
|
||||
}
|
||||
}
|
||||
|
||||
CalypPixel::~CalypPixel() = default;
|
||||
CalypPixel::~CalypPixel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
int CalypPixel::colorSpace() const
|
||||
{
|
||||
|
||||
+181
-234
@@ -25,14 +25,9 @@
|
||||
// Self
|
||||
#include "CalypStream.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <deque>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypStreamHandlerIf.h"
|
||||
#include "LibMemory.h"
|
||||
#include "StreamHandlerPortableMap.h"
|
||||
#include "StreamHandlerRaw.h"
|
||||
#include "config.h"
|
||||
@@ -45,9 +40,6 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
constexpr auto kDefaultBitsPerPixel = 8;
|
||||
constexpr auto kDefaultFrameRate = 30;
|
||||
|
||||
std::vector<CalypStreamFormat> CalypStream::supportedReadFormats()
|
||||
{
|
||||
INI_REGIST_CALYP_SUPPORTED_FMT;
|
||||
@@ -104,148 +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, int 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;
|
||||
bool isInit;
|
||||
bool isInput;
|
||||
|
||||
CalypStreamHandlerIf* handler;
|
||||
CreateStreamHandlerFn pfctCreateHandler;
|
||||
|
||||
std::shared_ptr<CalypStreamFrameBuffer> frameBuffer;
|
||||
std::deque<std::shared_ptr<CalypFrame>> frameFifo;
|
||||
CalypStreamBufferPrivate* frameBuffer;
|
||||
|
||||
// std::vector<std::unique_ptr<CalypFrame>> framePool;
|
||||
// std::deque<std::shared_ptr<CalypFrame>> frameFifo;
|
||||
// std::size_t bufferIdx{ 0 };
|
||||
|
||||
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;
|
||||
pfctCreateHandler = nullptr;
|
||||
handler = NULL;
|
||||
pfctCreateHandler = NULL;
|
||||
isInput = true;
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
iCurrFrameNum = -1;
|
||||
cFilename = "";
|
||||
}
|
||||
|
||||
~CalypStreamPrivate()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void close()
|
||||
{
|
||||
if( handler )
|
||||
{
|
||||
handler->closeHandler();
|
||||
handler->Delete();
|
||||
}
|
||||
|
||||
bLoadAll = false;
|
||||
isInit = false;
|
||||
}
|
||||
|
||||
bool readNextFrame( bool fillRgbBuffer = false )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( stream_mutex );
|
||||
|
||||
if( !isInit || !isInput || 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;
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -253,9 +182,9 @@ std::vector<std::string> CalypStreamFormat::getExts()
|
||||
return arrayExt;
|
||||
}
|
||||
|
||||
CreateStreamHandlerFn CalypStream::findStreamHandler( std::string strFilename, bool bRead )
|
||||
CreateStreamHandlerFn CalypStream::findStreamHandler( ClpString strFilename, bool bRead )
|
||||
{
|
||||
std::string currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
|
||||
ClpString currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
|
||||
currExt = clpLowercase( currExt );
|
||||
|
||||
std::vector<CalypStreamFormat> supportedFmts;
|
||||
@@ -269,14 +198,14 @@ CreateStreamHandlerFn CalypStream::findStreamHandler( std::string strFilename, b
|
||||
}
|
||||
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 )
|
||||
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 ) != std::string::npos )
|
||||
else if( strFilename.find( *e ) != ClpString::npos )
|
||||
{
|
||||
return supportedFmts[i].formatFct;
|
||||
}
|
||||
@@ -291,22 +220,25 @@ CreateStreamHandlerFn CalypStream::findStreamHandler( std::string strFilename, b
|
||||
}
|
||||
|
||||
CalypStream::CalypStream()
|
||||
: d{ std::make_unique<CalypStreamPrivate>() }
|
||||
: d( new CalypStreamPrivate )
|
||||
{
|
||||
}
|
||||
|
||||
CalypStream::~CalypStream() = default;
|
||||
CalypStream::~CalypStream()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
std::string CalypStream::getFormatName() const
|
||||
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,
|
||||
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;
|
||||
@@ -332,18 +264,18 @@ bool CalypStream::open( std::string filename, std::string resolution, std::strin
|
||||
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, int input_format, unsigned int bitsPel, int endianness,
|
||||
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 open( filename, width, height, input_format, bitsPel, endianness, false, frame_rate, bInput );
|
||||
}
|
||||
|
||||
bool CalypStream::open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative,
|
||||
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 )
|
||||
{
|
||||
if( d->isInit )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
}
|
||||
d->isInit = false;
|
||||
d->isInput = bInput;
|
||||
@@ -373,54 +305,45 @@ bool CalypStream::open( std::string filename, unsigned int width, unsigned int h
|
||||
|
||||
if( !d->handler->openHandler( d->cFilename, d->isInput ) )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
//throw CalypFailure( "CalypStream", "Incorrect configuration: width, height or pixel format" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
d->frameFifo.clear();
|
||||
|
||||
// Keep past, current and future frames
|
||||
std::size_t bufferSize = d->isInput ? 6 : 1;
|
||||
try
|
||||
{
|
||||
d->frameBuffer = std::make_shared<CalypStreamFrameBuffer>( bufferSize,
|
||||
d->handler->m_uiWidth,
|
||||
d->handler->m_uiHeight,
|
||||
d->handler->m_iPixelFormat,
|
||||
d->handler->m_uiBitsPerPixel,
|
||||
hasNegative );
|
||||
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 )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated frame buffer" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
const CalypFrame* refFrame = d->frameBuffer->ref();
|
||||
|
||||
d->handler->m_uiNBytesPerFrame = refFrame->getBytesPerFrame();
|
||||
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 )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Incorrect configuration: less than one frame" );
|
||||
return d->isInit;
|
||||
}
|
||||
|
||||
if( !d->handler->configureBuffer( *refFrame ) )
|
||||
if( !d->handler->configureBuffer( d->frameBuffer->current() ) )
|
||||
{
|
||||
d->close();
|
||||
close();
|
||||
throw CalypFailure( "CalypStream", "Cannot allocated buffers" );
|
||||
return d->isInit;
|
||||
}
|
||||
@@ -436,17 +359,15 @@ bool CalypStream::open( std::string filename, unsigned int width, unsigned int h
|
||||
|
||||
bool CalypStream::reload()
|
||||
{
|
||||
d->frameFifo.clear();
|
||||
d->handler->closeHandler();
|
||||
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 < 0 ||
|
||||
d->handler->m_uiBitsPerPixel == 0 || d->handler->m_uiTotalNumberFrames == 0 )
|
||||
@@ -457,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;
|
||||
}
|
||||
@@ -473,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;
|
||||
}
|
||||
@@ -513,36 +448,21 @@ void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, int& r
|
||||
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 = CLP_YUV420P;
|
||||
rBitsPerPel = kDefaultBitsPerPixel;
|
||||
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->isInput )
|
||||
return;
|
||||
|
||||
@@ -552,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;
|
||||
}
|
||||
|
||||
std::unique_ptr<CalypFrame> CalypStream::getCurrFrame( std::unique_ptr<CalypFrame> buffer )
|
||||
void CalypStream::getDuration( int* duration_array ) const
|
||||
{
|
||||
if( buffer == nullptr )
|
||||
buffer = std::make_unique<CalypFrame>( *d->frameFifo.front() );
|
||||
else
|
||||
buffer->copyFrom( *d->frameFifo.front() );
|
||||
return buffer;
|
||||
// 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;
|
||||
}
|
||||
|
||||
auto CalypStream::getCurrFrameAsset() -> std::shared_ptr<CalypFrame>
|
||||
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() -> 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 ) )
|
||||
{
|
||||
@@ -633,26 +538,66 @@ 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, false ) )
|
||||
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->isInput )
|
||||
@@ -662,7 +607,7 @@ bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
if( bIsFoward )
|
||||
{
|
||||
bRet = !setNextFrame();
|
||||
d->readNextFrame();
|
||||
readFrame( d->frameBuffer->next() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -674,24 +619,26 @@ bool CalypStream::seekInputRelative( bool bIsFoward )
|
||||
|
||||
bool CalypStream::seekInput( unsigned long new_frame_num )
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lock( d->stream_mutex );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
d->frameFifo.clear();
|
||||
if( !d->handler->seek( d->iCurrFrameNum ) )
|
||||
{
|
||||
throw CalypFailure( "CalypStream", "Cannot seek file into desired position" );
|
||||
}
|
||||
|
||||
d->readNextFrame();
|
||||
d->frameBuffer->setIndex( 0 );
|
||||
readFrame( d->frameBuffer->current() );
|
||||
if( d->handler->m_uiTotalNumberFrames > 1 )
|
||||
d->readNextFrame();
|
||||
readFrame( d->frameBuffer->next() );
|
||||
|
||||
return true;
|
||||
}
|
||||
+38
-39
@@ -26,31 +26,28 @@
|
||||
#ifndef __CALYPSTREAM_H__
|
||||
#define __CALYPSTREAM_H__
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
#include "CalypFrame.h"
|
||||
|
||||
class CalypFrame;
|
||||
class CalypStreamHandlerIf;
|
||||
|
||||
typedef CalypStreamHandlerIf* ( *CreateStreamHandlerFn )( void );
|
||||
|
||||
struct CalypStreamFormat
|
||||
typedef struct
|
||||
{
|
||||
std::string formatName;
|
||||
std::string formatExt;
|
||||
std::vector<std::string> getExts();
|
||||
std::string formatPattern;
|
||||
ClpString formatName;
|
||||
ClpString formatExt;
|
||||
std::vector<ClpString> getExts();
|
||||
ClpString formatPattern;
|
||||
CreateStreamHandlerFn formatFct;
|
||||
};
|
||||
} CalypStreamFormat;
|
||||
|
||||
struct CalypStandardResolution
|
||||
typedef struct
|
||||
{
|
||||
std::string shortName;
|
||||
ClpString shortName;
|
||||
unsigned int uiWidth;
|
||||
unsigned int uiHeight;
|
||||
};
|
||||
} CalypStandardResolution;
|
||||
|
||||
/**
|
||||
* \class CalypStream
|
||||
@@ -63,32 +60,31 @@ public:
|
||||
static std::vector<CalypStreamFormat> supportedReadFormats();
|
||||
static std::vector<CalypStreamFormat> supportedWriteFormats();
|
||||
|
||||
static CreateStreamHandlerFn findStreamHandler( std::string strFilename, bool bRead );
|
||||
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,
|
||||
bool open( ClpString filename, ClpString resolution, ClpString input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
bool bInput );
|
||||
bool open( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, unsigned int frame_rate,
|
||||
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( std::string filename, unsigned int width, unsigned int height, int input_format, unsigned int bitsPel, int endianness, bool hasNegative, unsigned int frame_rate,
|
||||
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 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;
|
||||
@@ -98,29 +94,32 @@ public:
|
||||
void getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate ) const;
|
||||
|
||||
auto hasNextFrame() -> bool;
|
||||
auto hasWritingSlot() -> bool;
|
||||
|
||||
void loadAll();
|
||||
std::unique_ptr<CalypFrame> getCurrFrame( std::unique_ptr<CalypFrame> buffer );
|
||||
auto getCurrFrameAsset() -> std::shared_ptr<CalypFrame>;
|
||||
auto getCurrFrame() -> 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__
|
||||
+15
-16
@@ -25,8 +25,6 @@
|
||||
#ifndef __CALYPSTREAMHANDLERIF_H__
|
||||
#define __CALYPSTREAMHANDLERIF_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypStream.h"
|
||||
|
||||
#define INI_REGIST_CALYP_SUPPORTED_FMT \
|
||||
@@ -80,6 +78,7 @@ public:
|
||||
, m_dFrameRate( 30 )
|
||||
, m_uiCurrFrameFileIdx( 0 )
|
||||
, m_uiTotalNumberFrames( 0 )
|
||||
, m_pStreamBuffer( NULL )
|
||||
, m_uiNBytesPerFrame( 0 )
|
||||
, m_isEOF( false )
|
||||
{
|
||||
@@ -87,36 +86,36 @@ public:
|
||||
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:
|
||||
const char* m_pchHandlerName;
|
||||
|
||||
std::string m_strFormatName;
|
||||
std::string m_strCodecName;
|
||||
ClpString m_strFormatName;
|
||||
ClpString m_strCodecName;
|
||||
bool m_bIsInput;
|
||||
bool m_bNative;
|
||||
std::string m_cFilename;
|
||||
ClpString m_cFilename;
|
||||
unsigned int m_uiWidth;
|
||||
unsigned int m_uiHeight;
|
||||
int m_iPixelFormat;
|
||||
unsigned int m_uiBitsPerPixel;
|
||||
int m_iEndianness;
|
||||
double m_dFrameRate;
|
||||
std::uint64_t m_uiCurrFrameFileIdx;
|
||||
std::uint64_t m_uiTotalNumberFrames;
|
||||
std::vector<ClpByte> m_pStreamBuffer;
|
||||
std::uint64_t m_uiNBytesPerFrame;
|
||||
ClpULong m_uiCurrFrameFileIdx;
|
||||
ClpULong m_uiTotalNumberFrames;
|
||||
ClpByte* m_pStreamBuffer;
|
||||
ClpULong m_uiNBytesPerFrame;
|
||||
bool m_isEOF;
|
||||
};
|
||||
|
||||
|
||||
+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__
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "PixelFormats.h"
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#include "config.h"
|
||||
#ifdef USE_FFMPEG
|
||||
#include "StreamHandlerLibav.h"
|
||||
|
||||
+13
-10
@@ -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 ) )
|
||||
@@ -63,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();
|
||||
|
||||
@@ -322,17 +323,19 @@ void StreamHandlerLibav::closeHandler()
|
||||
av_free( m_cFrame );
|
||||
}
|
||||
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;
|
||||
@@ -353,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;
|
||||
@@ -424,22 +427,22 @@ bool StreamHandlerLibav::read( CalypFrame& pcFrame )
|
||||
|
||||
decFrame = m_cConvertedFrame;
|
||||
}
|
||||
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data,
|
||||
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;
|
||||
|
||||
@@ -63,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;
|
||||
|
||||
+12
-11
@@ -28,6 +28,7 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
#if CV_MAJOR_VERSION >= 3
|
||||
#include <opencv2/videoio.hpp>
|
||||
#endif
|
||||
@@ -63,7 +64,7 @@ StreamHandlerOpenCV::StreamHandlerOpenCV()
|
||||
pcVideoCapture = NULL;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
bool StreamHandlerOpenCV::openHandler( ClpString strFilename, bool bInput )
|
||||
{
|
||||
m_cFilename = strFilename;
|
||||
if( bInput )
|
||||
@@ -72,12 +73,12 @@ bool StreamHandlerOpenCV::openHandler( std::string strFilename, bool bInput )
|
||||
/*
|
||||
* 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";
|
||||
@@ -125,18 +126,18 @@ void StreamHandlerOpenCV::closeHandler()
|
||||
}
|
||||
}
|
||||
|
||||
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( pcVideoCapture )
|
||||
@@ -144,23 +145,23 @@ bool StreamHandlerOpenCV::read( CalypFrame& pcFrame )
|
||||
Mat 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,12 +40,12 @@ 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:
|
||||
cv::VideoCapture* pcVideoCapture;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerPortableMap::supportedReadFormats()
|
||||
{
|
||||
@@ -47,7 +48,7 @@ std::vector<CalypStreamFormat> StreamHandlerPortableMap::supportedWriteFormats()
|
||||
END_REGIST_CALYP_SUPPORTED_FMT;
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::openHandler( std::string strFilename, bool bInput )
|
||||
bool StreamHandlerPortableMap::openHandler( ClpString strFilename, bool bInput )
|
||||
{
|
||||
m_bIsInput = bInput;
|
||||
m_pFile = NULL;
|
||||
@@ -123,34 +124,36 @@ void StreamHandlerPortableMap::closeHandler()
|
||||
{
|
||||
if( m_pFile )
|
||||
fclose( m_pFile );
|
||||
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::configureBuffer( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerPortableMap::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
m_pStreamBuffer.resize( pcFrame.getBytesPerFrame() );
|
||||
return true;
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::seek( std::uint64_t iFrameNum )
|
||||
bool StreamHandlerPortableMap::seek( ClpULong iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::read( CalypFrame& pcFrame )
|
||||
bool StreamHandlerPortableMap::read( CalypFrame* pcFrame )
|
||||
{
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
pcFrame.frameFromBuffer( m_pStreamBuffer, CLP_BIG_ENDIAN );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, CLP_BIG_ENDIAN );
|
||||
m_uiCurrFrameFileIdx++;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::write( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerPortableMap::write( CalypFrame* pcFrame )
|
||||
{
|
||||
CalypFrame pcRGBFrame( pcFrame.getWidth(), pcFrame.getHeight(),
|
||||
m_iPixelFormat, pcFrame.getBitsPel() );
|
||||
CalypFrame pcRGBFrame( pcFrame->getWidth(), pcFrame->getHeight(),
|
||||
m_iPixelFormat, pcFrame->getBitsPel() );
|
||||
pcRGBFrame.copyFrom( pcFrame );
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
fprintf( m_pFile, "P%d\n%d %d\n", m_iMagicNumber, m_uiWidth, m_uiHeight );
|
||||
@@ -159,7 +162,7 @@ bool StreamHandlerPortableMap::write( const CalypFrame& pcFrame )
|
||||
fprintf( m_pFile, "%d\n", m_iMaxValue );
|
||||
}
|
||||
pcRGBFrame.frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -35,12 +35,12 @@ class StreamHandlerPortableMap : public CalypStreamHandlerIf
|
||||
public:
|
||||
StreamHandlerPortableMap() { m_pchHandlerName = "PortableMaps"; }
|
||||
~StreamHandlerPortableMap() {}
|
||||
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:
|
||||
FILE* m_pFile; /**< The input file pointer >*/
|
||||
|
||||
+15
-12
@@ -27,6 +27,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "LibMemory.h"
|
||||
|
||||
std::vector<CalypStreamFormat> StreamHandlerRaw::supportedReadFormats()
|
||||
{
|
||||
@@ -44,7 +45,7 @@ std::vector<CalypStreamFormat> StreamHandlerRaw::supportedWriteFormats()
|
||||
END_REGIST_CALYP_SUPPORTED_FMT;
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::openHandler( std::string strFilename, bool bInput )
|
||||
bool StreamHandlerRaw::openHandler( ClpString strFilename, bool bInput )
|
||||
{
|
||||
m_bIsInput = bInput;
|
||||
m_pFile = NULL;
|
||||
@@ -56,6 +57,7 @@ bool StreamHandlerRaw::openHandler( std::string strFilename, bool bInput )
|
||||
calculateFrameNumber();
|
||||
m_strFormatName = "YUV";
|
||||
m_strCodecName = "Raw Video";
|
||||
m_dFrameRate = 30;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,12 +65,13 @@ void StreamHandlerRaw::closeHandler()
|
||||
{
|
||||
if( m_pFile )
|
||||
fclose( m_pFile );
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::configureBuffer( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerRaw::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
m_pStreamBuffer.resize( pcFrame.getBytesPerFrame() );
|
||||
return true;
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
void StreamHandlerRaw::calculateFrameNumber()
|
||||
@@ -82,7 +85,7 @@ void StreamHandlerRaw::calculateFrameNumber()
|
||||
}
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::seek( std::uint64_t iFrameNum )
|
||||
bool StreamHandlerRaw::seek( ClpULong iFrameNum )
|
||||
{
|
||||
if( m_bIsInput && m_pFile )
|
||||
{
|
||||
@@ -93,22 +96,22 @@ bool StreamHandlerRaw::seek( std::uint64_t iFrameNum )
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::read( CalypFrame& pcFrame )
|
||||
bool StreamHandlerRaw::read( CalypFrame* pcFrame )
|
||||
{
|
||||
if( !m_pFile || m_pStreamBuffer.empty() || m_uiNBytesPerFrame == 0 )
|
||||
if( !m_pFile || !m_pStreamBuffer || m_uiNBytesPerFrame == 0 )
|
||||
return false;
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
m_uiCurrFrameFileIdx++;
|
||||
pcFrame.frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::write( const CalypFrame& pcFrame )
|
||||
bool StreamHandlerRaw::write( CalypFrame* pcFrame )
|
||||
{
|
||||
pcFrame.frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -42,13 +42,13 @@ private:
|
||||
public:
|
||||
StreamHandlerRaw() { m_pchHandlerName = "RawVideo"; }
|
||||
~StreamHandlerRaw() {}
|
||||
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 );
|
||||
};
|
||||
|
||||
#endif // __STREAMHANDLERRAW_H__
|
||||
@@ -8,4 +8,5 @@ SET(Calyp_Lib_Catch2_Tests_SRCS CalypFrameTests.cpp)
|
||||
|
||||
ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS})
|
||||
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2)
|
||||
CATCH_DISCOVER_TESTS(CalypLibCatch2Tests)
|
||||
|
||||
INCLUDE(CTest)
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 8 bits in YUV420 format", "CalypFrame" )
|
||||
TEST_CASE( "create a 256x128 frame in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 8 );
|
||||
@@ -37,25 +37,3 @@ TEST_CASE( "create a 256x128 frame with 8 bits in YUV420 format", "CalypFrame" )
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 8 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 10 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 10 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 10 );
|
||||
}
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 16 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 16 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
REQUIRE( testFrame.getPelFormat() == CLP_YUV420P );
|
||||
REQUIRE( testFrame.getBitsPel() == 16 );
|
||||
}
|
||||
@@ -5,9 +5,6 @@
|
||||
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
|
||||
|
||||
ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
ADD_EXECUTABLE(PlaYUVerFrameQualityTests PlaYUVerFrameQualityTests.cpp)
|
||||
TARGET_LINK_LIBRARIES(PlaYUVerFrameQualityTests ${PROJECT_LIBRARY} gtest_main)
|
||||
|
||||
INCLUDE(GoogleTest)
|
||||
GTEST_DISCOVER_TESTS(PlaYUVerFrameQualityTests)
|
||||
TARGET_LINK_LIBRARIES(PlaYUVerFrameQualityTests ${PROJECT_LIBRARY} gtest gtest_main)
|
||||
ADD_TEST(PlaYUVerFrameQualityTests PlaYUVerFrameQualityTests)
|
||||
@@ -34,13 +34,13 @@ protected:
|
||||
// Can be omitted if not needed.
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
pcStreamPast = std::make_unique<CalypStream>();
|
||||
pcStreamPast->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
pcStreamPast = new CalypStream;
|
||||
pcStreamPast->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F10_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcFramePast = pcStreamPast->getCurrFrame();
|
||||
|
||||
pcStreamFuture = std::make_unique<CalypStream>();
|
||||
pcStreamFuture->open( std::string( CALYP_TEST_DATA_DIR ) + std::string( "/BasketballDrill_F15_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
pcStreamFuture = new CalypStream;
|
||||
pcStreamFuture->open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/BasketballDrill_F15_832x480_yuv420p.yuv" ), 832, 480, 0, 8,
|
||||
CLP_BIG_ENDIAN, 1, true );
|
||||
pcFrameFuture = pcStreamFuture->getCurrFrame();
|
||||
}
|
||||
@@ -50,22 +50,27 @@ protected:
|
||||
// Can be omitted if not needed.
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
pcStreamPast = nullptr;
|
||||
pcStreamFuture = nullptr;
|
||||
pcStreamPast->close();
|
||||
delete pcStreamPast;
|
||||
pcStreamPast = NULL;
|
||||
|
||||
pcStreamFuture->close();
|
||||
delete pcStreamFuture;
|
||||
pcStreamFuture = NULL;
|
||||
}
|
||||
|
||||
// Some expensive resource shared by all tests.
|
||||
static std::unique_ptr<CalypStream> pcStreamPast;
|
||||
static CalypStream* pcStreamPast;
|
||||
static CalypFrame* pcFramePast;
|
||||
|
||||
static std::unique_ptr<CalypStream> pcStreamFuture;
|
||||
static CalypStream* pcStreamFuture;
|
||||
static CalypFrame* pcFrameFuture;
|
||||
};
|
||||
|
||||
std::unique_ptr<CalypStream> CalypFrameQualityTest::pcStreamPast{ nullptr };
|
||||
std::unique_ptr<CalypStream> CalypFrameQualityTest::pcStreamFuture{ nullptr };
|
||||
CalypFrame* CalypFrameQualityTest::pcFramePast{ nullptr };
|
||||
CalypFrame* CalypFrameQualityTest::pcFrameFuture{ nullptr };
|
||||
CalypStream* CalypFrameQualityTest::pcStreamPast = NULL;
|
||||
CalypStream* CalypFrameQualityTest::pcStreamFuture = NULL;
|
||||
CalypFrame* CalypFrameQualityTest::pcFramePast = NULL;
|
||||
CalypFrame* CalypFrameQualityTest::pcFrameFuture = NULL;
|
||||
|
||||
TEST_F( CalypFrameQualityTest, MSE )
|
||||
{
|
||||
|
||||
+3
-31
@@ -1,12 +1,14 @@
|
||||
#
|
||||
# CMakeLists for calyp modules component
|
||||
#
|
||||
|
||||
OPTION(CALYP_THREADED_MODULES "Use threads for modules" OFF)
|
||||
SET(CALYP_EXTRA_MODULES_DIR
|
||||
"CALYP_EXTRA_MODULES_DIR"
|
||||
CACHE PATH "Location of extra Calyp modules"
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
SET(Calyp_Mod_SRCS CalypModulesFactory.cpp)
|
||||
|
||||
@@ -70,40 +72,10 @@ ADD_MODULE_USE_OPENCV(SaliencyDetectionFineGrained "SaliencyDetection" VERSION 3
|
||||
ADD_MODULE_USE_OPENCV(SaliencyDetectionBinWangApr2014 "SaliencyDetection" VERSION 3.3.0 MODULES saliency)
|
||||
|
||||
ADD_MODULE_USE_OPENCV(FrameResampling "FrameResampling" VERSION 3.3.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(SaliencyBasedFiltering "SaliencyBasedFiltering" VERSION 3.1.0 MODULES core)
|
||||
|
||||
ADD_MODULE_USE_OPENCV(ThreeSixtySpatialtoTemporal "ThreeSixtySpatialtoTemporal" VERSION 3.1.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(ThreeSixtyFaceExtraction "ThreeSixtyFaceExtraction" VERSION 3.1.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(ThreeSixtyFaceConcatenation "ThreeSixtyFaceConcatenation" VERSION 3.1.0 MODULES core)
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
ThreeSixtyDownsampling
|
||||
"ThreeSixtyDownsampling"
|
||||
VERSION
|
||||
3.1.0
|
||||
MODULES
|
||||
core
|
||||
imgproc
|
||||
photo
|
||||
)
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
ThreeSixtyDynamicDownsampling
|
||||
"ThreeSixtyDynamicDownsampling"
|
||||
VERSION
|
||||
3.1.0
|
||||
MODULES
|
||||
core
|
||||
imgproc
|
||||
)
|
||||
ADD_MODULE_USE_OPENCV(
|
||||
ThreeSixtyNxN
|
||||
"ThreeSixtyNxN"
|
||||
VERSION
|
||||
3.1.0
|
||||
MODULES
|
||||
core
|
||||
imgproc
|
||||
photo
|
||||
)
|
||||
|
||||
IF(EXISTS ${CALYP_EXTRA_MODULES_DIR})
|
||||
ADD_EXTRA_MODULES(${CALYP_EXTRA_MODULES_DIR})
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
|
||||
CalypModulesFactory::CalypModulesFactory(){ REGISTER_ALL_MODULES }
|
||||
|
||||
CalypModulesFactory::~CalypModulesFactory()
|
||||
{
|
||||
m_FactoryMap.clear();
|
||||
}
|
||||
|
||||
void CalypModulesFactory::Register( const char* moduleName, CreateModuleFn pfnCreate )
|
||||
{
|
||||
@@ -66,7 +70,7 @@ bool CalypModulesFactory::RegisterDl( const char* dlName )
|
||||
#endif
|
||||
}
|
||||
|
||||
CalypModulePtr CalypModulesFactory::CreateModule( const char* moduleName )
|
||||
CalypModuleIf* CalypModulesFactory::CreateModule( const char* moduleName )
|
||||
{
|
||||
CalypModulesFactoryMap& moduleFactoryMap = CalypModulesFactory::Get()->getMap();
|
||||
CalypModulesFactoryMap::iterator it = moduleFactoryMap.begin();
|
||||
@@ -77,5 +81,5 @@ CalypModulePtr CalypModulesFactory::CreateModule( const char* moduleName )
|
||||
return it->second();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return NULL;
|
||||
}
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#define REGISTER_MODULE( X ) Register( "X", &( X::Create ) );
|
||||
|
||||
typedef CalypModulePtr ( *CreateModuleFn )( void );
|
||||
typedef CalypModuleIf* ( *CreateModuleFn )( void );
|
||||
typedef std::map<const char*, CreateModuleFn> CalypModulesFactoryMap;
|
||||
|
||||
// Factory for creating instances of CalypModuleIf
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
CalypModulesFactoryMap m_FactoryMap;
|
||||
|
||||
public:
|
||||
~CalypModulesFactory() = default;
|
||||
~CalypModulesFactory();
|
||||
|
||||
static CalypModulesFactory* Get()
|
||||
{
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void Register( const char* moduleName, CreateModuleFn pfnCreate );
|
||||
bool RegisterDl( const char* dlName );
|
||||
|
||||
CalypModulePtr CreateModule( const char* moduleName );
|
||||
CalypModuleIf* CreateModule( const char* moduleName );
|
||||
CalypModulesFactoryMap& getMap() { return m_FactoryMap; }
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ FrameDifference::FrameDifference()
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Measurements";
|
||||
m_pchModuleName = "FrameDifference";
|
||||
m_pchModuleLongName = "Difference";
|
||||
m_pchModuleName = "Difference";
|
||||
m_pchModuleTooltip = "Measure the difference between two images (Y plane), "
|
||||
"Y1 - Y2, with max absolute diff of 128";
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NEW_WINDOW | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
@@ -82,8 +82,8 @@ bool FrameDifference::create( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
CalypFrame* FrameDifference::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
const CalypFrame& frame1 = *apcFrameList[0];
|
||||
const CalypFrame& frame2 = *apcFrameList[1];
|
||||
const CalypFrame& frame1 = apcFrameList[0];
|
||||
const CalypFrame& frame2 = apcFrameList[1];
|
||||
ClpPel* pOutputPelYUV = m_pcFrameDifference->getPelBufferYUV()[0][0];
|
||||
short aux_pel_1, aux_pel_2;
|
||||
short diff = 0;
|
||||
|
||||
@@ -80,24 +80,26 @@ bool FrameResampling::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_iHeight = apcFrameList[0]->getHeight() * double( m_iWidth ) / double( apcFrameList[0]->getWidth() );
|
||||
}
|
||||
m_resamplingFrame = std::make_unique<CalypFrame>( m_iWidth, m_iHeight, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
return true;
|
||||
m_pcOutputFrame = new CalypFrame( m_iWidth, m_iHeight, apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
CalypFrame* FrameResampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_resamplingFrame->reset();
|
||||
m_pcOutputFrame->reset();
|
||||
for( unsigned ch = 0; ch < apcFrameList[0]->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat inputFrame, outputFrame;
|
||||
cv::Size outSize( m_resamplingFrame->getWidth( ch ), m_resamplingFrame->getHeight( ch ) );
|
||||
cv::Size outSize( m_pcOutputFrame->getWidth( ch ), m_pcOutputFrame->getHeight( ch ) );
|
||||
apcFrameList[0]->toMat( inputFrame, true, false, ch );
|
||||
cv::resize( inputFrame, outputFrame, outSize, 0, 0, m_iInterpolation );
|
||||
m_resamplingFrame->fromMat( outputFrame, ch );
|
||||
m_pcOutputFrame->fromMat( outputFrame, ch );
|
||||
}
|
||||
return m_resamplingFrame.get();
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void FrameResampling::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
}
|
||||
@@ -43,7 +43,6 @@ private:
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iInterpolation;
|
||||
std::unique_ptr<CalypFrame> m_resamplingFrame;
|
||||
|
||||
public:
|
||||
FrameResampling();
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "FrameShift.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
FrameShift::FrameShift()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -50,11 +48,7 @@ FrameShift::FrameShift()
|
||||
bool FrameShift::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
m_pcProcessedFrame = new CalypFrame{ apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() };
|
||||
m_pcProcessedFrame = new CalypFrame( apcFrameList[0] );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
HEVCIntraPrediction::HEVCIntraPrediction()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -50,6 +52,7 @@ HEVCIntraPrediction::HEVCIntraPrediction()
|
||||
;
|
||||
|
||||
m_pcPredBlock = NULL;
|
||||
m_referenceMem = NULL;
|
||||
|
||||
m_uiMode = 26;
|
||||
m_iBlockSize = 4;
|
||||
@@ -63,8 +66,7 @@ bool HEVCIntraPrediction::create( std::vector<CalypFrame*> apcFrameList )
|
||||
m_pcPredBlock = NULL;
|
||||
m_pcPredBlock = new CalypFrame( m_iBlockSize * 2 + 1, m_iBlockSize * 2 + 1, CLP_GRAY, apcFrameList[0]->getBitsPel() );
|
||||
|
||||
m_referenceMem.resize( m_iBlockSize * 4 );
|
||||
|
||||
getMem1D( &m_referenceMem, m_iBlockSize * 4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -199,14 +201,16 @@ bool HEVCIntraPrediction::keyPressed( enum Module_Key_Supported value )
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string HEVCIntraPrediction::moduleInfo()
|
||||
ClpString HEVCIntraPrediction::moduleInfo()
|
||||
{
|
||||
return std::string( "Intra mode: " ) + std::to_string( m_uiMode );
|
||||
return ClpString( "Intra mode: " ) + std::to_string( m_uiMode );
|
||||
}
|
||||
|
||||
void HEVCIntraPrediction::destroy()
|
||||
{
|
||||
if( m_pcPredBlock )
|
||||
delete m_pcPredBlock;
|
||||
if( m_referenceMem )
|
||||
freeMem1D( m_referenceMem );
|
||||
m_pcPredBlock = NULL;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ private:
|
||||
unsigned int m_uiYpel;
|
||||
bool m_bShowResidue;
|
||||
int m_iBlockSize;
|
||||
std::vector<ClpPel> m_referenceMem;
|
||||
ClpPel* m_referenceMem;
|
||||
|
||||
public:
|
||||
HEVCIntraPrediction();
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
bool keyPressed( enum Module_Key_Supported value );
|
||||
std::string moduleInfo();
|
||||
ClpString moduleInfo();
|
||||
void destroy();
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "InterFrameVariance.h"
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
InterFrameVariance::InterFrameVariance()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -54,8 +56,7 @@ bool InterFrameVariance::create( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
m_pcFrameVariance =
|
||||
new CalypFrame( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), CLP_GRAY, 8 );
|
||||
|
||||
m_pVariance = CalypPlane<double>{ apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight() };
|
||||
getMem2D( &m_pVariance, apcFrameList[0]->getHeight(), apcFrameList[0]->getWidth() );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -104,6 +105,9 @@ CalypFrame* InterFrameVariance::process( std::vector<CalypFrame*> apcFrameList )
|
||||
|
||||
void InterFrameVariance::destroy()
|
||||
{
|
||||
if( m_pVariance )
|
||||
freeMem2D( m_pVariance );
|
||||
m_pVariance = NULL;
|
||||
if( m_pcFrameVariance )
|
||||
delete m_pcFrameVariance;
|
||||
m_pcFrameVariance = NULL;
|
||||
|
||||
@@ -34,7 +34,7 @@ class InterFrameVariance : public CalypModuleIf
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrameVariance;
|
||||
CalypPlane<double> m_pVariance;
|
||||
double** m_pVariance;
|
||||
|
||||
public:
|
||||
InterFrameVariance();
|
||||
|
||||
@@ -32,7 +32,6 @@ using cv::Mat_;
|
||||
using cv::Point;
|
||||
using cv::Point2f;
|
||||
using cv::Ptr;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
|
||||
OpticalFlowModule::OpticalFlowModule()
|
||||
@@ -107,8 +106,6 @@ void OpticalFlowModule::drawFlow()
|
||||
|
||||
void OpticalFlowModule::compensateFlow()
|
||||
{
|
||||
Rect frameShape( 0, 0, m_pcOutputFrame->getWidth(), m_pcOutputFrame->getHeight() );
|
||||
m_pcOutputFrame->reset();
|
||||
for( unsigned int c = 0; c < m_pcOutputFrame->getNumberChannels(); c++ )
|
||||
{
|
||||
ClpPel** pPelPrev = m_pcFramePrev->getPelBufferYUV()[c];
|
||||
@@ -120,8 +117,7 @@ void OpticalFlowModule::compensateFlow()
|
||||
{
|
||||
Point2f u = m_cvFlow( y, x );
|
||||
Point p( x + u.x, y + u.y );
|
||||
if( p.inside( frameShape ) )
|
||||
*pPelOut = pPelPrev[p.y][p.x];
|
||||
*pPelOut = pPelPrev[p.y][p.x];
|
||||
pPelOut++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
|
||||
OptimiseDisplay::OptimiseDisplay()
|
||||
{
|
||||
/* Module Definition */
|
||||
@@ -51,11 +53,7 @@ bool OptimiseDisplay::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
m_pcOptimisedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() );
|
||||
m_pcOptimisedFrame = new CalypFrame( apcFrameList[0] );
|
||||
m_pcOptimisedFrame->reset();
|
||||
|
||||
return true;
|
||||
@@ -64,10 +62,11 @@ bool OptimiseDisplay::create( std::vector<CalypFrame*> apcFrameList )
|
||||
CalypFrame* OptimiseDisplay::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
unsigned numValues = 1u << apcFrameList[0]->getBitsPel();
|
||||
std::vector<ClpPel> lookUpTable( numValues, 0 );
|
||||
ClpPel* lookUpTable;
|
||||
const ClpPel* pInput1PelYUV = apcFrameList[0]->getPelBufferYUV()[0][0];
|
||||
ClpPel* pOutputPelYUV = m_pcOptimisedFrame->getPelBufferYUV()[0][0];
|
||||
|
||||
getMem1D( &lookUpTable, numValues );
|
||||
apcFrameList[0]->calcHistogram();
|
||||
m_pcOptimisedFrame->reset();
|
||||
|
||||
@@ -93,9 +92,13 @@ CalypFrame* OptimiseDisplay::process( std::vector<CalypFrame*> apcFrameList )
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_pcOptimisedFrame.get();
|
||||
|
||||
freeMem1D( lookUpTable );
|
||||
return m_pcOptimisedFrame;
|
||||
}
|
||||
|
||||
void OptimiseDisplay::destroy()
|
||||
{
|
||||
delete m_pcOptimisedFrame;
|
||||
m_pcOptimisedFrame = nullptr;
|
||||
}
|
||||
@@ -34,14 +34,14 @@ class OptimiseDisplay : public CalypModuleIf
|
||||
REGISTER_CLASS_FACTORY( OptimiseDisplay )
|
||||
|
||||
private:
|
||||
std::unique_ptr<CalypFrame> m_pcOptimisedFrame;
|
||||
CalypFrame* m_pcOptimisedFrame;
|
||||
|
||||
public:
|
||||
OptimiseDisplay();
|
||||
virtual ~OptimiseDisplay() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList ) final;
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList ) final;
|
||||
void destroy() final;
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __OPTIMISEDISPLAY_H__
|
||||
@@ -1,170 +0,0 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SaliencyBasedFiltering.cpp
|
||||
*/
|
||||
|
||||
#include "SaliencyBasedFiltering.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
#define CLAMP_RANGE( X, MIN, MAX ) ( ( X ) < MIN ? MIN : ( ( X ) > MAX ? MAX : X ) )
|
||||
|
||||
SaliencyBasedFiltering::SaliencyBasedFiltering()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "SaliencyBasedFiltering";
|
||||
m_pchModuleTooltip = "Image filter based on a map";
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = 2;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
}
|
||||
|
||||
bool SaliencyBasedFiltering::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
for( unsigned i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], CalypFrame::MATCH_RESOLUTION ) )
|
||||
return false;
|
||||
}
|
||||
if( apcFrameList[1]->getNumberChannels() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pcProcessedFrame = std::make_unique<CalypFrame>( apcFrameList[0]->getWidth(),
|
||||
apcFrameList[0]->getHeight(),
|
||||
apcFrameList[0]->getPelFormat(),
|
||||
apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getHasNegativeValues() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static cv::Mat* getCvFrame( ClpPel* pInputPel, unsigned uiWidth, unsigned uiHeight )
|
||||
{
|
||||
cv::Mat* cvInput = new cv::Mat( uiHeight, uiWidth, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
unsigned char* pCvPel = cvInput->data;
|
||||
for( unsigned i = 0; i < uiWidth * uiHeight; i++ )
|
||||
{
|
||||
*pCvPel++ = *pInputPel++;
|
||||
}
|
||||
return cvInput;
|
||||
}
|
||||
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, unsigned kernelSize )
|
||||
{
|
||||
cv::Mat* cvFiltered = new cv::Mat( cvFrame->rows, cvFrame->cols, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
/// Initialize arguments for the filter
|
||||
cv::Point anchor = cv::Point( -1, -1 );
|
||||
double delta = 0;
|
||||
int ddepth = -1;
|
||||
|
||||
/// Update kernel size for a normalized box filter
|
||||
cv::Mat kernel = cv::Mat::ones( kernelSize, kernelSize, CV_32F ) / static_cast<double>( kernelSize * kernelSize );
|
||||
|
||||
/// Apply filter
|
||||
cv::filter2D( *cvFrame, *cvFiltered, ddepth, kernel, anchor, delta, cv::BORDER_DEFAULT );
|
||||
|
||||
return cvFiltered;
|
||||
}
|
||||
|
||||
static void filterComponent( CalypFrame* pInput, CalypFrame* pOutput, CalypFrame* Map, unsigned uiComp )
|
||||
{
|
||||
ClpPel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
int iMapStep = 1;
|
||||
ClpPel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
ClpPel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
std::int64_t iHeight = pInput->getHeight( uiComp );
|
||||
std::int64_t iWidth = pInput->getWidth( uiComp );
|
||||
|
||||
if( uiComp > 0 )
|
||||
{
|
||||
iMapStep = 2;
|
||||
}
|
||||
|
||||
cv::Mat* cvInput = getCvFrame( pInputPel, iWidth, iHeight );
|
||||
|
||||
unsigned numberFilters = 1;
|
||||
unsigned char* pCvPel[3];
|
||||
cv::Mat* cvOutput[3];
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
{
|
||||
cvOutput[i] = filterframe( cvInput, ( 1 << ( 2 * i + 7 ) ) + 1 );
|
||||
pCvPel[i] = cvOutput[i]->data;
|
||||
}
|
||||
|
||||
int iCheckNeighbour = 8;
|
||||
unsigned uiRelevance = 0;
|
||||
for( int y = 0; y < iHeight; y++ )
|
||||
{
|
||||
for( int x = 0; x < iWidth; x++ )
|
||||
{
|
||||
uiRelevance = 0;
|
||||
// uiRelevance = *pMapPel;
|
||||
for( std::int64_t j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
{
|
||||
for( std::int64_t i = CLAMP_RANGE( x - iCheckNeighbour, 0, iWidth ); i < CLAMP_RANGE( x + iCheckNeighbour + 1, 0, iWidth ); i++ )
|
||||
{
|
||||
uiRelevance += *( pMapPel + ( ( j - y ) * iWidth ) + ( i - x ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( uiRelevance > 0 )
|
||||
{
|
||||
*pOutputPel = *pInputPel;
|
||||
}
|
||||
else
|
||||
{
|
||||
*pOutputPel = *pCvPel[0];
|
||||
//*pOutputPel = 0;
|
||||
}
|
||||
|
||||
for( unsigned i = 0; i < numberFilters; i++ )
|
||||
pCvPel[i]++;
|
||||
pInputPel++;
|
||||
pOutputPel++;
|
||||
pMapPel += iMapStep;
|
||||
}
|
||||
pMapPel += ( iMapStep - 1 ) * iWidth;
|
||||
}
|
||||
}
|
||||
|
||||
CalypFrame* SaliencyBasedFiltering::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
CalypFrame* pcInputFrame = apcFrameList[0];
|
||||
|
||||
for( unsigned c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame.get(), apcFrameList[1], c );
|
||||
|
||||
return m_pcProcessedFrame.get();
|
||||
}
|
||||
|
||||
void SaliencyBasedFiltering::destroy()
|
||||
{
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com)
|
||||
* Joao Carreira (jfmcarreira@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SaliencyBasedFiltering.h
|
||||
*/
|
||||
|
||||
#ifndef __SALIENCYBASEDFILTERING_H__
|
||||
#define __SALIENCYBASEDFILTERING_H__
|
||||
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
class SaliencyBasedFiltering : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( SaliencyBasedFiltering )
|
||||
|
||||
private:
|
||||
std::unique_ptr<CalypFrame> m_pcProcessedFrame;
|
||||
|
||||
public:
|
||||
SaliencyBasedFiltering();
|
||||
virtual ~SaliencyBasedFiltering() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __SALIENCYBASEDFILTERING_H__
|
||||
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user