Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eaa9987314 | ||
|
|
2a1b0abb2f | ||
|
|
cad1f6d7a6 | ||
|
|
d330ecfd0d | ||
|
|
7b5e5d5694 | ||
|
|
f2a636baa1 | ||
|
|
9e3fb9c0a0 | ||
|
|
420aeb89a6 | ||
|
|
a1b44895b8 | ||
|
|
e1e5c4eb3c | ||
|
|
206613d08a | ||
|
|
b7e8087163 | ||
|
|
f4cf81b63c | ||
|
|
47504ff46f | ||
|
|
bdc5317ccc | ||
|
|
1dfddcf7fb | ||
|
|
cea720f8e9 | ||
|
|
48907ef614 | ||
|
|
cdff468904 | ||
|
|
dea3dd93d5 | ||
|
|
3745a687cb | ||
|
|
a1ebf62e21 | ||
|
|
3c85c96769 | ||
|
|
e7e1a8534b | ||
|
|
8807c14b59 | ||
|
|
039887f2e6 | ||
|
|
4c6a4aba65 | ||
|
|
910ab8024e | ||
|
|
6b0f7f6de3 | ||
|
|
6b8b4cbb6a | ||
|
|
0a70267ab7 | ||
|
|
4a4f985ac1 | ||
|
|
58424b8f4e | ||
|
|
3bbbf81ca2 | ||
|
|
7ea1db3202 | ||
|
|
0e26fd8964 | ||
|
|
27ecd818e8 | ||
|
|
d5d21a458f | ||
|
|
1066aaa73c | ||
|
|
ddd5eeb6b9 | ||
|
|
876e1ba9e3 | ||
|
|
47dd2ad3f9 | ||
|
|
e77e0a82fa | ||
|
|
2181fd6add | ||
|
|
eda28d1380 | ||
|
|
1599a80d46 | ||
|
|
42c4e3b388 | ||
|
|
d86ed3508b | ||
|
|
cd18227b8b | ||
|
|
fc913fdc08 | ||
|
|
f90c681788 | ||
|
|
44f7a9b02e | ||
|
|
624612d49b | ||
|
|
70db70a7cf | ||
|
|
33bf02ba0f | ||
|
|
7ff939c33a |
No files matched your search
+12
-10
@@ -1,6 +1,18 @@
|
||||
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
|
||||
@@ -14,14 +26,4 @@ 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]
|
||||
+40
-14
@@ -2,7 +2,7 @@
|
||||
# CMakeLists for calyp
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.2.0)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Project Definition
|
||||
@@ -19,7 +19,7 @@ SET(PROJECT_LIBRARY
|
||||
|
||||
SET(CALYP_VERSION_MAJOR "1")
|
||||
SET(CALYP_VERSION_MINOR "2")
|
||||
SET(CALYP_VERSION_PATCH "0")
|
||||
SET(CALYP_VERSION_PATCH "1")
|
||||
SET(CALYP_VERSION
|
||||
"${CALYP_VERSION_MAJOR}.${CALYP_VERSION_MINOR}.${CALYP_VERSION_PATCH}"
|
||||
CACHE INTERNAL "" FORCE
|
||||
@@ -48,6 +48,7 @@ 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_TESTS_CATCH2 "Build Catch2 Tests" OFF)
|
||||
|
||||
OPTION(USE_FERVOR "Add Fervor support" OFF)
|
||||
|
||||
@@ -111,19 +112,47 @@ SET_PACKAGE_PROPERTIES(
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
|
||||
INCLUDE(FetchContent)
|
||||
|
||||
IF(BUILD_TESTS)
|
||||
FIND_PACKAGE(GTest)
|
||||
SET(BUILD_DOC ${GTEST_FOUND})
|
||||
IF(GTEST_FOUND)
|
||||
ENABLE_TESTING()
|
||||
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
|
||||
ENDIF()
|
||||
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
|
||||
)
|
||||
SET(CALYP_TEST_DATA_DIR
|
||||
"CALYP_TEST_DATA_DIR"
|
||||
CACHE PATH "Location of video information for testing"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
|
||||
FETCHCONTENT_DECLARE(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.13.1
|
||||
)
|
||||
FETCHCONTENT_MAKEAVAILABLE(Catch2)
|
||||
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)
|
||||
ENABLE_TESTING()
|
||||
ENDIF()
|
||||
|
||||
OPTION(USE_OPENCV "Add OpenCV support" ON)
|
||||
IF(USE_OPENCV)
|
||||
|
||||
@@ -189,17 +218,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
# Compiler options
|
||||
# ####################################################################################################################################################
|
||||
|
||||
SET(CMAKE_CXX_STANDARD 14)
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS(-std=gnu++0x)
|
||||
ENDIF()
|
||||
SET(CMAKE_CXX_STANDARD 20)
|
||||
ADD_DEFINITIONS(-std=gnu++20)
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
MESSAGE(STATUS "No build type selected, default to Release")
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -funroll-loops -ftree-vectorizer-verbose")
|
||||
|
||||
ADD_DEFINITIONS(
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
@@ -223,7 +250,6 @@ IF(USE_WERROR)
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
|
||||
# ####################################################################################################################################################
|
||||
# Configure targets
|
||||
|
||||
+11
-2
@@ -142,9 +142,18 @@ 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} )
|
||||
|
||||
@@ -48,7 +48,7 @@ CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModul
|
||||
}
|
||||
}
|
||||
|
||||
void CalypAppModuleIf::update()
|
||||
void CalypAppModuleIf::update( bool isPlaying )
|
||||
{
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
@@ -56,7 +56,7 @@ void CalypAppModuleIf::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
apply();
|
||||
apply( isPlaying );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,14 +167,12 @@ void CalypAppModuleIf::show()
|
||||
if( m_pcDisplaySubWindow )
|
||||
{
|
||||
m_pcDisplaySubWindow->setCurrFrame( m_pcProcessedFrame );
|
||||
m_pcDisplaySubWindow->setFillWindow( false );
|
||||
m_pcDisplaySubWindow->clearWindowBusy();
|
||||
m_pcDisplaySubWindow->setFillWindow( isRunning() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcSubWindow[0]->setCurrFrame( m_pcProcessedFrame );
|
||||
m_pcSubWindow[0]->setFillWindow( false );
|
||||
m_pcSubWindow[0]->clearWindowBusy();
|
||||
m_pcSubWindow[0]->setFillWindow( isRunning() );
|
||||
}
|
||||
break;
|
||||
case CLP_FRAME_MEASUREMENT_MODULE:
|
||||
|
||||
@@ -30,9 +30,14 @@
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef CALYP_THREADED_MODULES
|
||||
#include <QThread>
|
||||
#endif
|
||||
|
||||
#include "CommonDefs.h"
|
||||
#include "ModuleHandleDock.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#include "lib/CalypModuleIf.h"
|
||||
#include "lib/CalypStream.h"
|
||||
@@ -101,7 +106,7 @@ public:
|
||||
CalypModuleIf* getModule() { return m_pcModule; }
|
||||
unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
|
||||
ClpString moduleInfo() { return m_pcModule->moduleInfo(); }
|
||||
void update();
|
||||
void update( bool isPlaying );
|
||||
bool apply( bool isPlaying = false, bool disableThreads = false );
|
||||
bool isRunning();
|
||||
void show();
|
||||
|
||||
+80
-55
@@ -39,9 +39,6 @@
|
||||
#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 )
|
||||
@@ -49,12 +46,17 @@ VideoHandle::VideoHandle( QWidget* parent, SubWindowHandle* windowManager )
|
||||
m_pcCurrentVideoSubWindow = NULL;
|
||||
m_bIsPlaying = false;
|
||||
m_pcPlayingTimer = new QTimer;
|
||||
m_pcFrameRateFeedbackTimer = new QElapsedTimer;
|
||||
m_pcPlayingTimer->setTimerType( Qt::PreciseTimer );
|
||||
connect( m_pcPlayingTimer, SIGNAL( timeout() ), this, SLOT( playEvent() ) );
|
||||
m_acPlayingSubWindows.clear();
|
||||
}
|
||||
|
||||
VideoHandle::~VideoHandle() {}
|
||||
VideoHandle::~VideoHandle()
|
||||
{
|
||||
delete m_pcPlayingTimer;
|
||||
delete m_pcFrameRateFeedbackTimer;
|
||||
}
|
||||
|
||||
void VideoHandle::createActions()
|
||||
{
|
||||
@@ -240,6 +242,12 @@ 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 ) );
|
||||
@@ -252,6 +260,7 @@ 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 );
|
||||
@@ -320,9 +329,6 @@ void VideoHandle::update()
|
||||
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() );
|
||||
|
||||
QString resolution;
|
||||
@@ -331,6 +337,8 @@ 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();
|
||||
@@ -356,7 +364,7 @@ void VideoHandle::update()
|
||||
}
|
||||
m_pcResolutionLabel->setText( resolution );
|
||||
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame );
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame, m_pcCurrentVideoSubWindow->isPlaying() );
|
||||
|
||||
m_pcFrameNumInfo->setTotalFrameNum( total_frame_num );
|
||||
m_pcFrameNumInfo->setCurrFrameNum( frame_num );
|
||||
@@ -366,6 +374,11 @@ 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" );
|
||||
@@ -379,6 +392,7 @@ void VideoHandle::update()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcPlayingFPSLabel->setText( "" );
|
||||
m_pcVideoFormatLabel->setText( "" );
|
||||
m_pcResolutionLabel->setText( "" );
|
||||
m_pcFramePropertiesSideBar->reset();
|
||||
@@ -559,30 +573,25 @@ void VideoHandle::setTimerStatus()
|
||||
{
|
||||
m_pcPlayingTimer->start();
|
||||
m_bIsPlaying = true;
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
m_uiNumberPlayedFrames = 0;
|
||||
m_pcPlayControlTimer = new QElapsedTimer;
|
||||
m_pcPlayControlTimer->start();
|
||||
m_dAverageFps = 0;
|
||||
#endif
|
||||
m_pcFrameRateFeedbackTimer->start();
|
||||
m_uiRealAverageFrameRate = 0;
|
||||
}
|
||||
}
|
||||
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 )
|
||||
@@ -593,8 +602,6 @@ 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++ )
|
||||
@@ -610,9 +617,7 @@ void VideoHandle::play()
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->play();
|
||||
}
|
||||
frameRate = m_acPlayingSubWindows.at( 0 )->getInputStream()->getFrameRate();
|
||||
timeinterval = (unsigned int)( 1000.0 / frameRate + 0.5 );
|
||||
m_pcPlayingTimer->setInterval( timeinterval );
|
||||
configureFrameRateTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -638,9 +643,9 @@ void VideoHandle::stop()
|
||||
{
|
||||
if( m_acPlayingSubWindows.size() > 0 )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->stop();
|
||||
playingSubWindow->stop();
|
||||
}
|
||||
m_acPlayingSubWindows.clear();
|
||||
setTimerStatus();
|
||||
@@ -656,28 +661,48 @@ 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()
|
||||
{
|
||||
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
|
||||
// This value should only be true if it is really needed to refresh the UI after this play event
|
||||
// Lets assum the current window is not playing. Nothing changes in the UI expect the playing windows
|
||||
// So no changed is emmited
|
||||
bool bShouldRefreshUI = false;
|
||||
calculateRealFrameRate();
|
||||
try
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
bool bEndOfSequence = false;
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
bEndOfSequence |= m_acPlayingSubWindows.at( i )->playEvent();
|
||||
bEndOfSequence |= playingSubWindow->playEvent();
|
||||
// If the current selected windows is playing then we need to refresh the UI
|
||||
if( playingSubWindow == m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
bShouldRefreshUI = true;
|
||||
}
|
||||
}
|
||||
if( bEndOfSequence )
|
||||
{
|
||||
if( !m_arrayActions[VIDEO_REPEAT_ACT]->isChecked() )
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( 0 );
|
||||
{
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
playingSubWindow->seekAbsoluteEvent( 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( const char* msg )
|
||||
@@ -690,7 +715,8 @@ void VideoHandle::playEvent()
|
||||
stop();
|
||||
m_pcCurrentVideoSubWindow->close();
|
||||
}
|
||||
emit changed();
|
||||
if( bShouldRefreshUI )
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void VideoHandle::seekEvent( int direction )
|
||||
@@ -702,9 +728,9 @@ void VideoHandle::seekEvent( int direction )
|
||||
if( !( (unsigned int)( m_pcCurrentVideoSubWindow->getInputStream()->getCurrFrameNum() + 1 ) >= getMaxFrameNumber() &&
|
||||
direction > 0 ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->seekRelativeEvent( direction > 0 ? true : false );
|
||||
playingSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -713,7 +739,6 @@ void VideoHandle::seekEvent( int direction )
|
||||
m_pcCurrentVideoSubWindow->seekRelativeEvent( direction > 0 ? true : false );
|
||||
}
|
||||
emit changed();
|
||||
// update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,9 +755,9 @@ void VideoHandle::seekVideo()
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
playingSubWindow->seekAbsoluteEvent( (unsigned int)newFrameNum );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -751,9 +776,9 @@ void VideoHandle::seekSliderEvent( int new_frame_num )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
{
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
m_acPlayingSubWindows.at( i )->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
playingSubWindow->seekAbsoluteEvent( (unsigned int)new_frame_num );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -773,9 +798,9 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
{
|
||||
QList<SubWindowAbstract*> subWindowList =
|
||||
m_pcMainWindowManager->findSubWindow( SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
for( int i = 0; i < subWindowList.size(); i++ )
|
||||
for( auto subWindow : subWindowList )
|
||||
{
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindowList.at( i ) );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( subWindow );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
@@ -784,18 +809,18 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
SubWindowSelectorDialog dialogWindowsSelection( m_pcParet, m_pcMainWindowManager,
|
||||
SubWindowAbstract::VIDEO_STREAM_SUBWINDOW );
|
||||
QStringList cWindowListNames;
|
||||
for( int i = 0; i < m_acPlayingSubWindows.size(); i++ )
|
||||
for( auto playingSubWindow : m_acPlayingSubWindows )
|
||||
{
|
||||
dialogWindowsSelection.selectSubWindow( m_acPlayingSubWindows.at( i ) );
|
||||
dialogWindowsSelection.selectSubWindow( playingSubWindow );
|
||||
}
|
||||
if( dialogWindowsSelection.exec() == QDialog::Accepted )
|
||||
{
|
||||
m_acPlayingSubWindows.clear();
|
||||
|
||||
QList<SubWindowAbstract*> selectedSubWindowList = dialogWindowsSelection.getSelectedWindows();
|
||||
for( int i = 0; i < selectedSubWindowList.size(); i++ )
|
||||
for( auto window : selectedSubWindowList )
|
||||
{
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( selectedSubWindowList.at( i ) );
|
||||
videoSubWindow = qobject_cast<VideoSubWindow*>( window );
|
||||
m_acPlayingSubWindows.append( videoSubWindow );
|
||||
}
|
||||
}
|
||||
@@ -807,7 +832,7 @@ void VideoHandle::videoSelectionButtonEvent()
|
||||
|
||||
if( m_acPlayingSubWindows.size() > 0 )
|
||||
{
|
||||
m_acPlayingSubWindows.at( 0 )->activateWindow();
|
||||
m_acPlayingSubWindows.front()->activateWindow();
|
||||
if( m_acPlayingSubWindows.size() > 1 )
|
||||
{
|
||||
m_arrayActions[VIDEO_LOCK_ACT]->setVisible( true );
|
||||
|
||||
+7
-6
@@ -34,8 +34,6 @@
|
||||
#include "CommonDefs.h"
|
||||
#include "config.h"
|
||||
|
||||
//#define _CONTROL_PLAYING_TIME_ 1
|
||||
|
||||
class QToolBar;
|
||||
class QDockWidget;
|
||||
class QSignalMapper;
|
||||
@@ -113,6 +111,7 @@ private:
|
||||
QDockWidget* m_pcFramePropertiesDock;
|
||||
FramePropertiesDock* m_pcFramePropertiesSideBar;
|
||||
|
||||
QLabel* m_pcPlayingFPSLabel;
|
||||
QLabel* m_pcVideoFormatLabel;
|
||||
QLabel* m_pcResolutionLabel;
|
||||
|
||||
@@ -122,12 +121,12 @@ private:
|
||||
QTimer* m_pcPlayingTimer;
|
||||
bool m_bIsPlaying;
|
||||
|
||||
#if( _CONTROL_PLAYING_TIME_ == 1 )
|
||||
unsigned int m_uiNumberPlayedFrames;
|
||||
double m_dAverageFps;
|
||||
QElapsedTimer* m_pcPlayControlTimer;
|
||||
#endif
|
||||
unsigned int m_uiRealAverageFrameRate;
|
||||
QElapsedTimer* m_pcFrameRateFeedbackTimer;
|
||||
|
||||
void configureFrameRateTimer();
|
||||
void calculateRealFrameRate();
|
||||
unsigned long getMaxFrameNumber();
|
||||
void setTimerStatus();
|
||||
|
||||
@@ -140,8 +139,10 @@ 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 );
|
||||
|
||||
+27
-4
@@ -34,7 +34,7 @@
|
||||
#include "QtConcurrent/qtconcurrentrun.h"
|
||||
#include "SubWindowAbstract.h"
|
||||
|
||||
#define QT_NO_CONCURRENT
|
||||
//#define QT_NO_CONCURRENT
|
||||
|
||||
/**
|
||||
* \brief Functions to control data stream from stream information
|
||||
@@ -89,6 +89,7 @@ int findCalypStreamInfo( CalypFileInfoVector array, QString filename )
|
||||
class VideoInformation : public QWidget
|
||||
{
|
||||
private:
|
||||
QTimer* m_pcRefreshTimer;
|
||||
QList<QStaticText> m_cTopLeftTextList;
|
||||
QFont m_cTopLeftTextFont;
|
||||
QFont m_cCenterTextFont;
|
||||
@@ -102,6 +103,9 @@ public:
|
||||
setAttribute( Qt::WA_TransparentForMouseEvents );
|
||||
m_cTopLeftTextFont.setPointSize( 8 );
|
||||
m_cCenterTextFont.setPointSize( 12 );
|
||||
m_pcRefreshTimer = new QTimer;
|
||||
m_pcRefreshTimer->setSingleShot( true );
|
||||
connect( m_pcRefreshTimer, SIGNAL( timeout() ), this, SLOT( update() ) );
|
||||
}
|
||||
void setInformationTopLeft( const QStringList& textLines )
|
||||
{
|
||||
@@ -111,7 +115,11 @@ public:
|
||||
m_cTopLeftTextList.append( QStaticText( textLines.at( i ) ) );
|
||||
}
|
||||
}
|
||||
void setBusyWindow( bool bFlag ) { m_bBusyWindow = bFlag; }
|
||||
void setBusyWindow( bool bFlag )
|
||||
{
|
||||
m_bBusyWindow = bFlag;
|
||||
m_pcRefreshTimer->start( 500 );
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent* event )
|
||||
@@ -383,6 +391,7 @@ bool VideoSubWindow::loadFile( QString cFilename, bool bForceDialog )
|
||||
|
||||
updateVideoWindowInfo();
|
||||
setWindowName( QFileInfo( m_cFilename ).fileName() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -731,7 +740,7 @@ void VideoSubWindow::refreshFrameOperation()
|
||||
}
|
||||
for( int i = 0; i < m_apcCurrentModule.size(); i++ )
|
||||
{
|
||||
m_apcCurrentModule.at( i )->update();
|
||||
m_apcCurrentModule.at( i )->update( m_bIsPlaying );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,8 +772,8 @@ bool VideoSubWindow::goToNextFrame( bool bThreaded )
|
||||
m_cRefreshResult.waitForFinished();
|
||||
if( bThreaded )
|
||||
{
|
||||
refreshFrame();
|
||||
m_cReadResult = QtConcurrent::run( m_pCurrStream, &CalypStream::readNextFrameFillRGBBuffer );
|
||||
refreshFrame();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -806,6 +815,20 @@ bool VideoSubWindow::saveStream( QString filename )
|
||||
return iRet;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
if( m_pCurrStream && m_pCurrStream->getFrameNum() > 1 )
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
bool playEvent();
|
||||
void stop();
|
||||
|
||||
bool isPlaying() { return m_bIsPlaying; }
|
||||
bool isPlaying();
|
||||
void seekAbsoluteEvent( unsigned int new_frame_num );
|
||||
void seekRelativeEvent( bool bIsFoward );
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
#include <QtGui>
|
||||
#include <cmath>
|
||||
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch )
|
||||
: QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch )
|
||||
: QWidget( parent ), m_bIsPlaying( false ), m_bHasFrame( false )
|
||||
{
|
||||
// -------------- Variables definition --------------
|
||||
m_pcFrame = NULL;
|
||||
m_pcSelectedFrame = NULL;
|
||||
m_iLastFrameType = -1;
|
||||
|
||||
// Histogram area -----------------------------------------------------
|
||||
@@ -278,13 +278,8 @@ QSize FramePropertiesDock::sizeHint() const
|
||||
|
||||
void FramePropertiesDock::reset()
|
||||
{
|
||||
m_pcFrame = NULL;
|
||||
m_bHasFrame = false;
|
||||
m_cSelectionArea = QRect();
|
||||
if( m_pcSelectedFrame )
|
||||
{
|
||||
delete m_pcSelectedFrame;
|
||||
m_pcSelectedFrame = NULL;
|
||||
}
|
||||
|
||||
m_iLastFrameType = -1;
|
||||
|
||||
@@ -302,7 +297,7 @@ void FramePropertiesDock::reset()
|
||||
setEnabled( false );
|
||||
}
|
||||
|
||||
void FramePropertiesDock::setFrame( CalypFrame* pcFrame )
|
||||
void FramePropertiesDock::setFrame( CalypFrame* pcFrame, bool isPlaying )
|
||||
{
|
||||
int colorSpace = pcFrame->getColorSpace();
|
||||
if( m_iLastFrameType != colorSpace )
|
||||
@@ -364,35 +359,38 @@ void FramePropertiesDock::setFrame( CalypFrame* pcFrame )
|
||||
}
|
||||
}
|
||||
setEnabled( true );
|
||||
if( m_pcFrame || !( *m_pbIsPlaying ) )
|
||||
m_bIsPlaying = isPlaying;
|
||||
if( !m_bIsPlaying )
|
||||
{
|
||||
m_pcFrame = pcFrame;
|
||||
updateDataHistogram();
|
||||
if( pcFrame )
|
||||
{
|
||||
m_bHasFrame = true;
|
||||
m_cFrame = CalypFrame( pcFrame );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bHasFrame = false;
|
||||
}
|
||||
}
|
||||
updateDataHistogram();
|
||||
}
|
||||
|
||||
void FramePropertiesDock::setSelection( const QRect& selectionArea )
|
||||
{
|
||||
if( m_pcFrame )
|
||||
if( m_bHasFrame )
|
||||
{
|
||||
bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() );
|
||||
m_cSelectionArea = selectionArea;
|
||||
if( selectionArea.isValid() )
|
||||
{
|
||||
m_cSelectionArea = selectionArea;
|
||||
histogramWidget->stopHistogramComputation();
|
||||
|
||||
/*
|
||||
* Allocate a new image for the selection
|
||||
* or just copy information
|
||||
* Crop selection from frame
|
||||
*/
|
||||
if( bSelectionChanged )
|
||||
{
|
||||
if( m_pcSelectedFrame )
|
||||
{
|
||||
delete m_pcSelectedFrame;
|
||||
}
|
||||
m_pcSelectedFrame = new CalypFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
|
||||
selectionArea.height() );
|
||||
m_cSelectedFrame = CalypFrame( m_cFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
|
||||
selectionArea.height() );
|
||||
}
|
||||
updateDataHistogram();
|
||||
selectionImageButton->click();
|
||||
@@ -409,13 +407,13 @@ void FramePropertiesDock::setSelection( const QRect& selectionArea )
|
||||
|
||||
void FramePropertiesDock::updateDataHistogram()
|
||||
{
|
||||
if( m_pcFrame && isVisible() )
|
||||
if( m_bHasFrame && isVisible() )
|
||||
{
|
||||
if( !*m_pbIsPlaying )
|
||||
if( !m_bIsPlaying )
|
||||
{
|
||||
if( m_pcSelectedFrame )
|
||||
if( m_cSelectionArea.isValid() )
|
||||
{
|
||||
m_pcSelectedFrame->copyFrom( m_pcFrame, m_cSelectionArea.x(), m_cSelectionArea.y() );
|
||||
m_cSelectedFrame = CalypFrame( m_cFrame, m_cSelectionArea.x(), m_cSelectionArea.y(), m_cSelectionArea.width(), m_cSelectionArea.height() );
|
||||
fullImageButton->show();
|
||||
selectionImageButton->show();
|
||||
}
|
||||
@@ -424,7 +422,7 @@ void FramePropertiesDock::updateDataHistogram()
|
||||
fullImageButton->hide();
|
||||
selectionImageButton->hide();
|
||||
}
|
||||
histogramWidget->updateData( m_pcFrame, m_pcSelectedFrame );
|
||||
histogramWidget->updateData( &m_cFrame, m_cSelectionArea.isValid() ? &m_cSelectedFrame : nullptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -523,7 +521,7 @@ void FramePropertiesDock::slotRefreshOptions( int range )
|
||||
|
||||
void FramePropertiesDock::slotHistogramComputationFailed()
|
||||
{
|
||||
m_pcFrame = NULL;
|
||||
m_bHasFrame = false;
|
||||
}
|
||||
|
||||
void FramePropertiesDock::slotChannelChanged( int index )
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
#include "HistogramWidget.h"
|
||||
#include "config.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
#include "lib/CalypStream.h"
|
||||
|
||||
class CalypStream;
|
||||
|
||||
class FramePropertiesDock : public QWidget
|
||||
{
|
||||
@@ -42,17 +43,17 @@ public:
|
||||
|
||||
QSize sizeHint() const;
|
||||
|
||||
void setFrame( CalypFrame* m_pcFrame );
|
||||
void setFrame( CalypFrame* m_pcFrame, bool isPlaying );
|
||||
void setSelection( const QRect& selectionArea );
|
||||
void reset();
|
||||
void stopHistogram();
|
||||
|
||||
private:
|
||||
CalypFrame* m_pcFrame;
|
||||
CalypFrame* m_pcSelectedFrame;
|
||||
CalypFrame m_cFrame;
|
||||
CalypFrame m_cSelectedFrame;
|
||||
int m_iLastFrameType;
|
||||
|
||||
bool* m_pbIsPlaying;
|
||||
bool m_bIsPlaying;
|
||||
bool m_bHasFrame;
|
||||
|
||||
QComboBox* channelCB;
|
||||
QComboBox* colorsCB;
|
||||
|
||||
+674
@@ -0,0 +1,674 @@
|
||||
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,3 +1,37 @@
|
||||
#### 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:
|
||||
|
||||
+6438
-1057
File diff suppressed because it is too large.
Load diff
+1300
-202
File diff suppressed because it is too large.
Load diff
@@ -31,6 +31,7 @@
|
||||
#include "DBusAppAdaptor.h"
|
||||
#endif
|
||||
#include <QApplication>
|
||||
#include <QStyleFactory>
|
||||
#ifdef USE_FERVOR
|
||||
#include "fvupdater.h"
|
||||
#endif
|
||||
|
||||
Binary file not shown.
@@ -53,7 +53,7 @@ public:
|
||||
void setup( CalypFrame* frame )
|
||||
{
|
||||
m_pcFrame = frame;
|
||||
// run();
|
||||
//run();
|
||||
start();
|
||||
}
|
||||
void run()
|
||||
@@ -61,17 +61,9 @@ public:
|
||||
if( m_pcFrame && m_parent )
|
||||
{
|
||||
EventData* eventData = new EventData();
|
||||
// eventDm_imageHistogramata->starting = true;
|
||||
// eventData->success = false;
|
||||
// eventData->histogram = m_histogram;
|
||||
// QCoreApplication::postEvent( m_parent, eventData );
|
||||
|
||||
eventData->starting = true;
|
||||
|
||||
m_pcFrame->calcHistogram();
|
||||
|
||||
eventData->starting = false;
|
||||
// eventData->success = m_pcFrame->getHasHistogram();
|
||||
eventData->success = true;
|
||||
eventData->frame = m_pcFrame;
|
||||
QCoreApplication::postEvent( m_parent, eventData );
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(modules)
|
||||
ADD_SUBDIRECTORY(stream)
|
||||
@@ -2,7 +2,7 @@
|
||||
# CMakeLists for modules_example
|
||||
#
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
|
||||
|
||||
PROJECT("modules_example")
|
||||
|
||||
@@ -10,7 +10,7 @@ PROJECT("modules_example")
|
||||
INCLUDE_DIRECTORIES(../../lib)
|
||||
|
||||
ADD_LIBRARY(FrameBinarization SHARED FrameBinarization_APIv1.cpp)
|
||||
TARGET_LINK_LIBRARIES(FrameBinarization ${CALYP_LINKER_LIBS})
|
||||
TARGET_LINK_LIBRARIES(FrameBinarization ${PROJECT_LIBRARY})
|
||||
|
||||
ADD_LIBRARY(AbsoluteFrameDifferenceExample SHARED AbsoluteFrameDifferenceExample.cpp)
|
||||
TARGET_LINK_LIBRARIES(AbsoluteFrameDifferenceExample ${PROJECT_LIBRARY} ${CALYP_LINKER_LIBS})
|
||||
TARGET_LINK_LIBRARIES(AbsoluteFrameDifferenceExample ${PROJECT_LIBRARY})
|
||||
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# 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})
|
||||
@@ -0,0 +1,69 @@
|
||||
/* 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( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/Kendo_c4_1024x768_yuv420p.yuv" ), 1024, 768, 0, 8, CLP_BIG_ENDIAN, 1, true );
|
||||
stream.open( ClpString( CALYP_TEST_DATA_DIR ) + ClpString( "/SteamLocomotiveTrain_2560x1600_60_10bit_crop.yuv" ), 2560, 1600, 0, 10, CLP_LITTLE_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;
|
||||
}
|
||||
@@ -85,3 +85,7 @@ ENDIF()
|
||||
IF(BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_TESTS_CATCH2)
|
||||
ADD_SUBDIRECTORY(catch2)
|
||||
ENDIF()
|
||||
+5
-7
@@ -26,16 +26,14 @@
|
||||
#ifndef __CALYPDEFS_H__
|
||||
#define __CALYPDEFS_H__
|
||||
|
||||
#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;
|
||||
using ClpByte = std::uint8_t;
|
||||
using ClpPel = std::uint16_t;
|
||||
using ClpULong = std::uint64_t;
|
||||
using ClpString = std::string;
|
||||
|
||||
enum CLP_LOG_LEVEL
|
||||
{
|
||||
|
||||
+130
-65
@@ -26,6 +26,10 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <vector>
|
||||
|
||||
#include "LibMemory.h"
|
||||
#include "PixelFormats.h"
|
||||
@@ -88,7 +92,7 @@ int CalypFrame::pelformatColorSpace( const int idx )
|
||||
return g_CalypPixFmtDescriptorsMap.at( idx ).colorSpace;
|
||||
}
|
||||
|
||||
struct CalypFramePrivate
|
||||
class CalypFrame::CalypFramePrivate
|
||||
{
|
||||
public:
|
||||
bool m_bInit;
|
||||
@@ -106,19 +110,26 @@ public:
|
||||
|
||||
ClpPel*** m_pppcInputPel;
|
||||
|
||||
bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
unsigned char* m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
std::vector<std::uint8_t> m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
|
||||
/** Histogram control variables **/
|
||||
bool m_bHasHistogram;
|
||||
bool m_bHistogramRunning;
|
||||
/** The histogram data.*/
|
||||
unsigned int* m_puiHistogram;
|
||||
std::vector<unsigned int> m_puiHistogram;
|
||||
/** If the image is RGB and calcLuma is true, we have 1 more channel */
|
||||
unsigned int m_uiHistoChannels;
|
||||
/** Numbers of histogram segments depending of image bytes depth*/
|
||||
unsigned int m_uiHistoSegments;
|
||||
|
||||
CalypFramePrivate()
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bHasRGBPel = false;
|
||||
m_pppcInputPel = nullptr;
|
||||
}
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel )
|
||||
{
|
||||
init( width, height, pel_format, bitsPixel, false );
|
||||
@@ -126,10 +137,6 @@ 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;
|
||||
@@ -139,7 +146,7 @@ public:
|
||||
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
|
||||
{
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a PlYUVerFrame of this type" );
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a CalypFrame of this type" );
|
||||
}
|
||||
|
||||
m_pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( pel_format ) );
|
||||
@@ -176,9 +183,8 @@ public:
|
||||
}
|
||||
|
||||
/* Alloc ARGB memory */
|
||||
getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 );
|
||||
m_pcARGB32.resize( m_uiHeight * m_uiWidth * 4 );
|
||||
|
||||
m_puiHistogram = NULL;
|
||||
m_bHasHistogram = false;
|
||||
m_bHistogramRunning = false;
|
||||
|
||||
@@ -190,7 +196,7 @@ public:
|
||||
else
|
||||
m_uiHistoChannels = m_pcPelFormat->numberChannels;
|
||||
|
||||
getMem1D<unsigned int>( &( m_puiHistogram ), m_uiHistoSegments * m_uiHistoChannels );
|
||||
m_puiHistogram.resize( m_uiHistoSegments * m_uiHistoChannels );
|
||||
|
||||
m_cPelFmtName = CalypFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str();
|
||||
|
||||
@@ -242,15 +248,10 @@ 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 );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -258,27 +259,49 @@ public:
|
||||
* \brief Constructors
|
||||
*/
|
||||
|
||||
CalypFrame::CalypFrame()
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel )
|
||||
: d( new CalypFramePrivate )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel );
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel, bool has_negative_values )
|
||||
: d( new CalypFramePrivate )
|
||||
: d{ std::make_unique<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( new CalypFramePrivate )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel(), other.getHasNegativeValues() );
|
||||
copyFrom( &other );
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( const CalypFrame* other )
|
||||
: d( new CalypFramePrivate )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
if( other )
|
||||
{
|
||||
@@ -287,8 +310,22 @@ CalypFrame::CalypFrame( const CalypFrame* other )
|
||||
}
|
||||
}
|
||||
|
||||
CalypFrame& CalypFrame::operator=( const CalypFrame& other )
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
CalypFrame::CalypFrame( const CalypFrame& other, unsigned int x, unsigned int y, unsigned int width, unsigned int height )
|
||||
: d( new CalypFramePrivate )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( other.getPelFormat() ) );
|
||||
if( pcPelFormat->log2ChromaWidth )
|
||||
@@ -313,7 +350,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( new CalypFramePrivate )
|
||||
: d{ std::make_unique<CalypFramePrivate>() }
|
||||
{
|
||||
if( !other )
|
||||
return;
|
||||
@@ -340,10 +377,7 @@ CalypFrame::CalypFrame( const CalypFrame* other, unsigned int posX, unsigned int
|
||||
copyFrom( other, posX, posY );
|
||||
}
|
||||
|
||||
CalypFrame::~CalypFrame()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
CalypFrame::~CalypFrame() = default;
|
||||
|
||||
bool CalypFrame::haveSameFmt( const CalypFrame& other, unsigned int match ) const
|
||||
{
|
||||
@@ -495,7 +529,7 @@ unsigned char* CalypFrame::getRGBBuffer() const
|
||||
{
|
||||
if( d->m_bHasRGBPel )
|
||||
{
|
||||
return d->m_pcARGB32;
|
||||
return d->m_pcARGB32.data();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -614,7 +648,7 @@ void CalypFrame::copyTo( const CalypFrame* other, unsigned x, unsigned y )
|
||||
copyTo( *other, x, y );
|
||||
}
|
||||
|
||||
void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness, unsigned long uiBuffSize )
|
||||
void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndianness, unsigned long uiBuffSize )
|
||||
{
|
||||
if( uiBuffSize != getBytesPerFrame() )
|
||||
return;
|
||||
@@ -622,19 +656,14 @@ void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness, unsigned long
|
||||
frameFromBuffer( Buff, iEndianness );
|
||||
}
|
||||
|
||||
void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness )
|
||||
void CalypFrame::frameFromBuffer( const std::vector<ClpByte>& Buff, int iEndianness )
|
||||
{
|
||||
ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
ClpByte* pTmpBuff;
|
||||
ClpPel* pPel;
|
||||
const ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
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 b;
|
||||
int maxval = pow( 2, d->m_uiBitsPel ) - 1;
|
||||
int maxval = ( 1 << d->m_uiBitsPel ) - 1;
|
||||
|
||||
if( iEndianness == CLP_BIG_ENDIAN )
|
||||
{
|
||||
@@ -643,37 +672,36 @@ void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness )
|
||||
incByte = -1;
|
||||
}
|
||||
|
||||
ppBuff[0] = Buff;
|
||||
for( i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
ppBuff[0] = Buff.data();
|
||||
for( unsigned i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
{
|
||||
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
int ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioH = i > 1 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
ppBuff[i] = ppBuff[i - 1] + CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ) * bytesPixel;
|
||||
}
|
||||
|
||||
for( ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
xMemSet( ClpPel, getTotalNumberOfPixels(), d->m_pppcInputPel[0][0] );
|
||||
|
||||
for( unsigned ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
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;
|
||||
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;
|
||||
|
||||
pPel = d->m_pppcInputPel[ch][0];
|
||||
pTmpBuff = ppBuff[d->m_pcPelFormat->comp[ch].plane] + ( d->m_pcPelFormat->comp[ch].offset_plus1 - 1 ) * 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;
|
||||
|
||||
for( i = 0; i < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); i++ )
|
||||
for( unsigned p = 0; p < CHROMASHIFT( d->m_uiHeight, ratioH ) * CHROMASHIFT( d->m_uiWidth, ratioW ); p++ )
|
||||
{
|
||||
*pPel = 0;
|
||||
for( b = startByte; b != endByte; b += incByte )
|
||||
for( int b = startByte; b != endByte; b += incByte )
|
||||
{
|
||||
*pPel += *pTmpBuff << ( b * 8 );
|
||||
pPel[p] += *pTmpBuff << ( b * 8 );
|
||||
pTmpBuff++;
|
||||
// Check max value and bound it to "maxval" to prevent segfault when
|
||||
// calculating histogram
|
||||
if( *pPel > maxval )
|
||||
*pPel = 0;
|
||||
// -----
|
||||
}
|
||||
pPel++;
|
||||
// Check max value and bound it to "maxval" to prevent segfault when
|
||||
// calculating histogram
|
||||
if( pPel[p] > maxval )
|
||||
pPel[p] = 0;
|
||||
pTmpBuff += step;
|
||||
}
|
||||
}
|
||||
@@ -681,7 +709,7 @@ void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness )
|
||||
d->m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
void CalypFrame::frameToBuffer( ClpByte* output_buffer, int iEndianness )
|
||||
void CalypFrame::frameToBuffer( std::vector<ClpByte>& output_buffer, int iEndianness )
|
||||
{
|
||||
unsigned int bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
ClpByte* ppBuff[MAX_NUMBER_PLANES];
|
||||
@@ -701,7 +729,7 @@ void CalypFrame::frameToBuffer( ClpByte* output_buffer, int iEndianness )
|
||||
incByte = -1;
|
||||
}
|
||||
|
||||
ppBuff[0] = output_buffer;
|
||||
ppBuff[0] = output_buffer.data();
|
||||
for( int i = 1; i < MAX_NUMBER_PLANES; i++ )
|
||||
{
|
||||
ratioW = i > 1 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
@@ -731,8 +759,6 @@ void CalypFrame::frameToBuffer( ClpByte* output_buffer, int iEndianness )
|
||||
}
|
||||
}
|
||||
|
||||
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 : \
|
||||
@@ -745,12 +771,47 @@ void CalypFrame::fillRGBBuffer()
|
||||
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()
|
||||
{
|
||||
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;
|
||||
uint32_t* pARGB = (uint32_t*)d->m_pcARGB32.data();
|
||||
if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
{
|
||||
ClpPel* pY = d->m_pppcInputPel[CLP_LUMA][0];
|
||||
@@ -780,6 +841,11 @@ void CalypFrame::fillRGBBuffer()
|
||||
}
|
||||
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];
|
||||
@@ -822,7 +888,6 @@ void CalypFrame::fillRGBBuffer()
|
||||
pLineV += uiChromaStride;
|
||||
}
|
||||
}
|
||||
d->m_bHasRGBPel = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -831,12 +896,12 @@ void CalypFrame::fillRGBBuffer()
|
||||
|
||||
void CalypFrame::calcHistogram()
|
||||
{
|
||||
if( d->m_bHasHistogram || !d->m_puiHistogram )
|
||||
if( d->m_bHasHistogram || d->m_puiHistogram.empty() )
|
||||
return;
|
||||
|
||||
d->m_bHistogramRunning = true;
|
||||
|
||||
xMemSet( unsigned int, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram );
|
||||
std::fill( d->m_puiHistogram.begin(), d->m_puiHistogram.end(), 0 );
|
||||
|
||||
unsigned int numberChannels = d->m_pcPelFormat->numberChannels;
|
||||
for( unsigned int ch = 0; ch < numberChannels; ch++ )
|
||||
|
||||
+35
-5
@@ -26,6 +26,8 @@
|
||||
#ifndef __CALYPFRAME_H__
|
||||
#define __CALYPFRAME_H__
|
||||
|
||||
#include <span>
|
||||
|
||||
#include "CalypDefs.h"
|
||||
|
||||
namespace cv
|
||||
@@ -73,7 +75,8 @@ public:
|
||||
CalypPixel convertPixel( CalypColorSpace eOutputSpace );
|
||||
|
||||
private:
|
||||
struct CalypPixelPrivate* d;
|
||||
class CalypPixelPrivate;
|
||||
std::unique_ptr<CalypPixelPrivate> d;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -102,6 +105,11 @@ public:
|
||||
static int findPixelFormat( const ClpString& name );
|
||||
static int pelformatColorSpace( const int idx );
|
||||
|
||||
/**
|
||||
* Default constructor. Frame is not valid
|
||||
*/
|
||||
CalypFrame();
|
||||
|
||||
/**
|
||||
* Creates a new frame using the following configuration
|
||||
*
|
||||
@@ -124,6 +132,20 @@ 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
|
||||
*
|
||||
@@ -132,6 +154,13 @@ public:
|
||||
CalypFrame( const CalypFrame& other );
|
||||
CalypFrame( const CalypFrame* other );
|
||||
|
||||
/**
|
||||
* Copy-assignement contructor
|
||||
*
|
||||
* @param other existing frame to copy from
|
||||
*/
|
||||
CalypFrame& operator=( const CalypFrame& other );
|
||||
|
||||
/**
|
||||
* Creates and new frame with the configuration of an existing one and copy
|
||||
* its contents. This function only copies a specific region from the existing
|
||||
@@ -343,9 +372,9 @@ public:
|
||||
void copyTo( const CalypFrame& other, unsigned x, unsigned y );
|
||||
void copyTo( const CalypFrame* other, unsigned x, unsigned y );
|
||||
|
||||
void frameFromBuffer( ClpByte*, int, unsigned long );
|
||||
void frameFromBuffer( ClpByte*, int );
|
||||
void frameToBuffer( ClpByte*, int );
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int, unsigned long );
|
||||
void frameFromBuffer( const std::vector<ClpByte>&, int );
|
||||
void frameToBuffer( std::vector<ClpByte>&, int );
|
||||
|
||||
void fillRGBBuffer();
|
||||
|
||||
@@ -417,7 +446,8 @@ public:
|
||||
/** @} */
|
||||
|
||||
private:
|
||||
struct CalypFramePrivate* d;
|
||||
class CalypFramePrivate;
|
||||
std::unique_ptr<CalypFramePrivate> d;
|
||||
};
|
||||
|
||||
#endif // __CALYPFRAME_H__
|
||||
@@ -34,6 +34,8 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "CalypOptions.h"
|
||||
|
||||
|
||||
+11
-10
@@ -22,14 +22,17 @@
|
||||
* \brief Video Frame handling
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
#include "PixelFormats.h"
|
||||
#include "config.h"
|
||||
|
||||
#define MAX_NUMBER_COMPONENTS 4
|
||||
|
||||
struct CalypPixelPrivate
|
||||
class CalypPixel::CalypPixelPrivate
|
||||
{
|
||||
public:
|
||||
CalypPixelPrivate( const int& ColorSpace )
|
||||
{
|
||||
iColorSpace = ColorSpace == CLP_COLOR_GRAY ?
|
||||
@@ -71,18 +74,18 @@ int CalypPixel::getMaxNumberOfComponents()
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
{
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0 )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c1, const ClpPel& c2 )
|
||||
: d( new CalypPixelPrivate( ColorSpace ) )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
@@ -90,7 +93,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( new CalypPixelPrivate( ColorSpace ) )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( ColorSpace ) }
|
||||
{
|
||||
d->PelComp[0] = c0;
|
||||
d->PelComp[1] = c1;
|
||||
@@ -99,7 +102,8 @@ CalypPixel::CalypPixel( const int& ColorSpace, const ClpPel& c0, const ClpPel& c
|
||||
}
|
||||
|
||||
CalypPixel::CalypPixel( const CalypPixel& other )
|
||||
: d( new CalypPixelPrivate( other.colorSpace() ) )
|
||||
: d{ std::make_unique<CalypPixelPrivate>( other.colorSpace() ) }
|
||||
|
||||
{
|
||||
for( int i = 0; i < MAX_NUMBER_COMPONENTS; i++ )
|
||||
{
|
||||
@@ -107,10 +111,7 @@ CalypPixel::CalypPixel( const CalypPixel& other )
|
||||
}
|
||||
}
|
||||
|
||||
CalypPixel::~CalypPixel()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
CalypPixel::~CalypPixel() = default;
|
||||
|
||||
int CalypPixel::colorSpace() const
|
||||
{
|
||||
|
||||
+14
-34
@@ -107,15 +107,14 @@ public:
|
||||
{
|
||||
for( unsigned int i = 0; i < size; i++ )
|
||||
{
|
||||
CalypFrame* pFrame = new CalypFrame( width, height, pelFormat, bitsPixel, hasNegative );
|
||||
m_apcFrameBuffer.push_back( pFrame );
|
||||
m_apcFrameBuffer.push_back( new CalypFrame( width, height, pelFormat, bitsPixel, hasNegative ) );
|
||||
}
|
||||
m_uiIndex = 0;
|
||||
}
|
||||
|
||||
~CalypStreamBufferPrivate()
|
||||
{
|
||||
while( m_apcFrameBuffer.size() > 0 )
|
||||
while( !m_apcFrameBuffer.empty() )
|
||||
{
|
||||
delete m_apcFrameBuffer.back();
|
||||
m_apcFrameBuffer.pop_back();
|
||||
@@ -125,8 +124,7 @@ public:
|
||||
{
|
||||
for( unsigned int i = m_apcFrameBuffer.size(); i < newSize; i++ )
|
||||
{
|
||||
CalypFrame* pFrame = new CalypFrame( m_apcFrameBuffer.at( 0 ) );
|
||||
m_apcFrameBuffer.push_back( pFrame );
|
||||
m_apcFrameBuffer.push_back( new CalypFrame( m_apcFrameBuffer.at( 0 ) ) );
|
||||
}
|
||||
}
|
||||
unsigned int size() { return m_apcFrameBuffer.size(); }
|
||||
@@ -158,8 +156,9 @@ struct CalypStreamPrivate
|
||||
|
||||
CalypStreamPrivate()
|
||||
{
|
||||
handler = NULL;
|
||||
pfctCreateHandler = NULL;
|
||||
handler = nullptr;
|
||||
pfctCreateHandler = nullptr;
|
||||
frameBuffer = nullptr;
|
||||
isInput = true;
|
||||
isInit = false;
|
||||
bLoadAll = false;
|
||||
@@ -227,6 +226,7 @@ CalypStream::CalypStream()
|
||||
CalypStream::~CalypStream()
|
||||
{
|
||||
close();
|
||||
delete d;
|
||||
}
|
||||
|
||||
ClpString CalypStream::getFormatName() const
|
||||
@@ -389,10 +389,13 @@ void CalypStream::close()
|
||||
if( !d->isInit )
|
||||
return;
|
||||
|
||||
d->handler->closeHandler();
|
||||
d->handler->Delete();
|
||||
|
||||
delete d->frameBuffer;
|
||||
if( d->handler )
|
||||
{
|
||||
d->handler->closeHandler();
|
||||
d->handler->Delete();
|
||||
}
|
||||
if( d->frameBuffer )
|
||||
delete d->frameBuffer;
|
||||
|
||||
d->bLoadAll = false;
|
||||
d->isInit = false;
|
||||
@@ -485,29 +488,6 @@ void CalypStream::loadAll()
|
||||
d->iCurrFrameNum = 0;
|
||||
}
|
||||
|
||||
void CalypStream::getDuration( int* duration_array ) const
|
||||
{
|
||||
// int hours, mins, secs = 0;
|
||||
// #ifdef USE_FFMPEG
|
||||
// if( m_iStreamHandler == FFMPEG )
|
||||
// {
|
||||
// secs = m_cLibAvContext->getStreamDuration();
|
||||
// }
|
||||
// else
|
||||
// #endif
|
||||
// if( m_iStreamHandler == YUV_IO )
|
||||
// {
|
||||
// secs = m_uiTotalFrameNum / m_dFrameRate;
|
||||
// }
|
||||
// mins = secs / 60;
|
||||
// secs %= 60;
|
||||
// hours = mins / 60;
|
||||
// mins %= 60;
|
||||
// *duration_array++ = hours;
|
||||
// *duration_array++ = mins;
|
||||
// *duration_array++ = secs;
|
||||
}
|
||||
|
||||
bool CalypStream::readFrame( CalypFrame* frame )
|
||||
{
|
||||
if( !d->isInit || !d->isInput || d->handler->m_uiCurrFrameFileIdx >= d->handler->m_uiTotalNumberFrames )
|
||||
|
||||
@@ -113,8 +113,6 @@ public:
|
||||
bool seekInputRelative( bool bIsFoward );
|
||||
bool seekInput( unsigned long new_frame_num );
|
||||
|
||||
void getDuration( int* duration_array ) const;
|
||||
|
||||
private:
|
||||
bool readFrame( CalypFrame* frame );
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __CALYPSTREAMHANDLERIF_H__
|
||||
#define __CALYPSTREAMHANDLERIF_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypStream.h"
|
||||
|
||||
#define INI_REGIST_CALYP_SUPPORTED_FMT \
|
||||
@@ -78,7 +80,6 @@ public:
|
||||
, m_dFrameRate( 30 )
|
||||
, m_uiCurrFrameFileIdx( 0 )
|
||||
, m_uiTotalNumberFrames( 0 )
|
||||
, m_pStreamBuffer( NULL )
|
||||
, m_uiNBytesPerFrame( 0 )
|
||||
, m_isEOF( false )
|
||||
{
|
||||
@@ -114,7 +115,7 @@ protected:
|
||||
double m_dFrameRate;
|
||||
ClpULong m_uiCurrFrameFileIdx;
|
||||
ClpULong m_uiTotalNumberFrames;
|
||||
ClpByte* m_pStreamBuffer;
|
||||
std::vector<ClpByte> m_pStreamBuffer;
|
||||
ClpULong m_uiNBytesPerFrame;
|
||||
bool m_isEOF;
|
||||
};
|
||||
|
||||
+13
-44
@@ -40,7 +40,7 @@
|
||||
#endif
|
||||
#define xMemSet( type, len, ptr ) memset( ptr, 0, ( len ) * sizeof( type ) )
|
||||
|
||||
static inline void* xMallocMem( size_t nitems )
|
||||
[[deprecated]] static inline void* xMallocMem( size_t nitems )
|
||||
{
|
||||
void* d;
|
||||
if( ( d = xMalloc( nitems ) ) == NULL )
|
||||
@@ -51,7 +51,7 @@ static inline void* xMallocMem( size_t nitems )
|
||||
return d;
|
||||
}
|
||||
|
||||
static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
[[deprecated]] static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
{
|
||||
size_t padded_size = nitems * size;
|
||||
void* d = xMallocMem( padded_size );
|
||||
@@ -61,7 +61,7 @@ static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem1D( T** array1D, int dim0 )
|
||||
[[deprecated]] int getMem1D( T** array1D, int dim0 )
|
||||
{
|
||||
if( ( *array1D = (T*)xCallocMem( dim0, sizeof( T ) ) ) == NULL )
|
||||
return 0;
|
||||
@@ -69,6 +69,16 @@ int getMem1D( T** array1D, int dim0 )
|
||||
return ( sizeof( T* ) + dim0 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[deprecated]] void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem2D( T*** array2D, int dim0, int dim1 )
|
||||
{
|
||||
@@ -85,32 +95,6 @@ int getMem2D( T*** array2D, int dim0, int 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 )
|
||||
{
|
||||
@@ -130,19 +114,4 @@ void freeMem2D( T**& array2D )
|
||||
}
|
||||
}
|
||||
|
||||
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__
|
||||
@@ -323,14 +323,12 @@ void StreamHandlerLibav::closeHandler()
|
||||
av_free( m_cFrame );
|
||||
}
|
||||
m_bHasStream = false;
|
||||
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
m_pStreamBuffer.resize( pcFrame->getBytesPerFrame() );
|
||||
return true;
|
||||
}
|
||||
|
||||
void StreamHandlerLibav::calculateFrameNumber()
|
||||
@@ -427,7 +425,7 @@ bool StreamHandlerLibav::read( CalypFrame* pcFrame )
|
||||
|
||||
decFrame = m_cConvertedFrame;
|
||||
}
|
||||
av_image_copy_to_buffer( m_pStreamBuffer, m_uiFrameBufferSize, decFrame->data,
|
||||
av_image_copy_to_buffer( m_pStreamBuffer.data(), m_uiFrameBufferSize, decFrame->data,
|
||||
decFrame->linesize, AVPixelFormat( m_ffPixFmt ), m_uiWidth, m_uiHeight, 1 );
|
||||
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
|
||||
@@ -124,14 +124,12 @@ void StreamHandlerPortableMap::closeHandler()
|
||||
{
|
||||
if( m_pFile )
|
||||
fclose( m_pFile );
|
||||
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
m_pStreamBuffer.resize( pcFrame->getBytesPerFrame() );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::seek( ClpULong iFrameNum )
|
||||
@@ -142,7 +140,7 @@ bool StreamHandlerPortableMap::seek( ClpULong iFrameNum )
|
||||
|
||||
bool StreamHandlerPortableMap::read( CalypFrame* pcFrame )
|
||||
{
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, CLP_BIG_ENDIAN );
|
||||
@@ -162,7 +160,7 @@ bool StreamHandlerPortableMap::write( CalypFrame* pcFrame )
|
||||
fprintf( m_pFile, "%d\n", m_iMaxValue );
|
||||
}
|
||||
pcRGBFrame.frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -57,7 +57,6 @@ bool StreamHandlerRaw::openHandler( ClpString strFilename, bool bInput )
|
||||
calculateFrameNumber();
|
||||
m_strFormatName = "YUV";
|
||||
m_strCodecName = "Raw Video";
|
||||
m_dFrameRate = 30;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,13 +64,12 @@ void StreamHandlerRaw::closeHandler()
|
||||
{
|
||||
if( m_pFile )
|
||||
fclose( m_pFile );
|
||||
if( m_pStreamBuffer )
|
||||
freeMem1D( m_pStreamBuffer );
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::configureBuffer( CalypFrame* pcFrame )
|
||||
{
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
m_pStreamBuffer.resize( pcFrame->getBytesPerFrame() );
|
||||
return true;
|
||||
}
|
||||
|
||||
void StreamHandlerRaw::calculateFrameNumber()
|
||||
@@ -98,9 +96,9 @@ bool StreamHandlerRaw::seek( ClpULong iFrameNum )
|
||||
|
||||
bool StreamHandlerRaw::read( CalypFrame* pcFrame )
|
||||
{
|
||||
if( !m_pFile || !m_pStreamBuffer || m_uiNBytesPerFrame == 0 )
|
||||
if( !m_pFile || m_pStreamBuffer.empty() || m_uiNBytesPerFrame == 0 )
|
||||
return false;
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fread( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
m_uiCurrFrameFileIdx++;
|
||||
@@ -111,7 +109,7 @@ bool StreamHandlerRaw::read( CalypFrame* pcFrame )
|
||||
bool StreamHandlerRaw::write( CalypFrame* pcFrame )
|
||||
{
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer, sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
unsigned long long int processed_bytes = fwrite( m_pStreamBuffer.data(), sizeof( ClpByte ), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# CMakeLists for Calyp lis tests using catch2
|
||||
#
|
||||
|
||||
# ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")
|
||||
|
||||
SET(Calyp_Lib_Catch2_Tests_SRCS CalypFrameTests.cpp)
|
||||
|
||||
ADD_EXECUTABLE(CalypLibCatch2Tests ${Calyp_Lib_Catch2_Tests_SRCS})
|
||||
TARGET_LINK_LIBRARIES(CalypLibCatch2Tests ${PROJECT_LIBRARY} Catch2::Catch2)
|
||||
|
||||
INCLUDE(CTest)
|
||||
CATCH_DISCOVER_TESTS(CalypLibCatch2Tests)
|
||||
@@ -0,0 +1,61 @@
|
||||
/* This file is a part of plaYUVer project
|
||||
* Copyright (C) 2014-2021 by Joao Carreira (jfmcarreira@gmail.com)
|
||||
* Luis Lucas (luisfrlucas@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file CalypFrameTests.cpp
|
||||
* \brief CalypFrame general tests
|
||||
*/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "CalypFrame.h"
|
||||
|
||||
TEST_CASE( "create a 256x128 frame with 8 bits in YUV420 format", "CalypFrame" )
|
||||
{
|
||||
// Constructor: CalypFrame( unsigned int width, unsigned int height, int pelFormat, unsigned bitsPixel = 8 );
|
||||
CalypFrame testFrame( 256, 128, CLP_YUV420P, 8 );
|
||||
|
||||
REQUIRE( testFrame.getWidth() == 256 );
|
||||
REQUIRE( testFrame.getHeight() == 128 );
|
||||
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,6 +5,9 @@
|
||||
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 gtest_main)
|
||||
ADD_TEST(PlaYUVerFrameQualityTests PlaYUVerFrameQualityTests)
|
||||
TARGET_LINK_LIBRARIES(PlaYUVerFrameQualityTests ${PROJECT_LIBRARY} gtest_main)
|
||||
|
||||
INCLUDE(GoogleTest)
|
||||
GTEST_DISCOVER_TESTS(PlaYUVerFrameQualityTests)
|
||||
+30
-1
@@ -2,7 +2,7 @@
|
||||
# CMakeLists for calyp modules component
|
||||
#
|
||||
|
||||
OPTION(CALYP_THREADED_MODULES "Use threads for modules" OFF)
|
||||
OPTION(CALYP_THREADED_MODULES "Use threads for modules" ON)
|
||||
SET(CALYP_EXTRA_MODULES_DIR
|
||||
"CALYP_EXTRA_MODULES_DIR"
|
||||
CACHE PATH "Location of extra Calyp modules"
|
||||
@@ -76,6 +76,35 @@ ADD_MODULE_USE_OPENCV(FrameResampling "FrameResampling" VERSION 3.3.0 MODULES co
|
||||
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})
|
||||
|
||||
@@ -52,7 +52,6 @@ HEVCIntraPrediction::HEVCIntraPrediction()
|
||||
;
|
||||
|
||||
m_pcPredBlock = NULL;
|
||||
m_referenceMem = NULL;
|
||||
|
||||
m_uiMode = 26;
|
||||
m_iBlockSize = 4;
|
||||
@@ -66,7 +65,8 @@ 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() );
|
||||
|
||||
getMem1D( &m_referenceMem, m_iBlockSize * 4 );
|
||||
m_referenceMem.resize( m_iBlockSize * 4 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,5 @@ 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;
|
||||
ClpPel* m_referenceMem;
|
||||
std::vector<ClpPel> m_referenceMem;
|
||||
|
||||
public:
|
||||
HEVCIntraPrediction();
|
||||
|
||||
@@ -32,6 +32,7 @@ using cv::Mat_;
|
||||
using cv::Point;
|
||||
using cv::Point2f;
|
||||
using cv::Ptr;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
|
||||
OpticalFlowModule::OpticalFlowModule()
|
||||
@@ -106,6 +107,8 @@ 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];
|
||||
@@ -117,7 +120,8 @@ void OpticalFlowModule::compensateFlow()
|
||||
{
|
||||
Point2f u = m_cvFlow( y, x );
|
||||
Point p( x + u.x, y + u.y );
|
||||
*pPelOut = pPelPrev[p.y][p.x];
|
||||
if( p.inside( frameShape ) )
|
||||
*pPelOut = pPelPrev[p.y][p.x];
|
||||
pPelOut++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,11 +62,10 @@ bool OptimiseDisplay::create( std::vector<CalypFrame*> apcFrameList )
|
||||
CalypFrame* OptimiseDisplay::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
unsigned numValues = 1u << apcFrameList[0]->getBitsPel();
|
||||
ClpPel* lookUpTable;
|
||||
std::vector<ClpPel> lookUpTable( numValues, 0 );
|
||||
const ClpPel* pInput1PelYUV = apcFrameList[0]->getPelBufferYUV()[0][0];
|
||||
ClpPel* pOutputPelYUV = m_pcOptimisedFrame->getPelBufferYUV()[0][0];
|
||||
|
||||
getMem1D( &lookUpTable, numValues );
|
||||
apcFrameList[0]->calcHistogram();
|
||||
m_pcOptimisedFrame->reset();
|
||||
|
||||
@@ -92,8 +91,6 @@ CalypFrame* OptimiseDisplay::process( std::vector<CalypFrame*> apcFrameList )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
freeMem1D( lookUpTable );
|
||||
return m_pcOptimisedFrame;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/* 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 = MODULE_API_2;
|
||||
m_iModuleType = FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "Quality";
|
||||
m_pchModuleName = "SaliencyBasedFiltering";
|
||||
m_pchModuleTooltip = "Image filter based on a map";
|
||||
m_uiModuleRequirements = MODULE_REQUIRES_NOTHING;
|
||||
m_uiNumberOfFrames = MODULE_REQUIRES_TWO_FRAMES;
|
||||
|
||||
m_pcProcessedFrame = NULL;
|
||||
}
|
||||
|
||||
Bool SaliencyBasedFiltering::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
for( UInt i = 0; i < apcFrameList.size(); i++ )
|
||||
{
|
||||
if( !apcFrameList[i]->haveSameFmt( apcFrameList[0], PlaYUVerFrame::MATCH_RESOLUTION ) )
|
||||
return false;
|
||||
}
|
||||
if( apcFrameList[1]->getNumberChannels() != 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_pcProcessedFrame = new PlaYUVerFrame( apcFrameList[0] );
|
||||
return true;
|
||||
}
|
||||
|
||||
static cv::Mat* getCvFrame( Pel* pInputPel, UInt uiWidth, UInt uiHeight )
|
||||
{
|
||||
cv::Mat* cvInput = new cv::Mat( uiHeight, uiWidth, CV_MAKETYPE( CV_8U, 1 ) );
|
||||
UChar* pCvPel = cvInput->data;
|
||||
for( UInt i = 0; i < uiWidth * uiHeight; i++ )
|
||||
{
|
||||
*pCvPel++ = *pInputPel++;
|
||||
}
|
||||
return cvInput;
|
||||
}
|
||||
|
||||
static cv::Mat* filterframe( cv::Mat* cvFrame, UInt 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 ) / (Double)( kernelSize * kernelSize );
|
||||
|
||||
/// Apply filter
|
||||
cv::filter2D( *cvFrame, *cvFiltered, ddepth, kernel, anchor, delta, cv::BORDER_DEFAULT );
|
||||
|
||||
return cvFiltered;
|
||||
}
|
||||
|
||||
static void filterComponent( PlaYUVerFrame* pInput, PlaYUVerFrame* pOutput, PlaYUVerFrame* Map, UInt uiComp )
|
||||
{
|
||||
Pel* pMapPel = Map->getPelBufferYUV()[0][0];
|
||||
Int iMapStep = 1;
|
||||
Pel* pInputPel = pInput->getPelBufferYUV()[uiComp][0];
|
||||
Pel* pOutputPel = pOutput->getPelBufferYUV()[uiComp][0];
|
||||
Int iHeight = pInput->getHeight();
|
||||
Int iWidth = pInput->getWidth();
|
||||
|
||||
if( uiComp > 0 )
|
||||
{
|
||||
iHeight = pInput->getChromaHeight();
|
||||
iWidth = pInput->getChromaWidth();
|
||||
iMapStep = 2;
|
||||
}
|
||||
|
||||
cv::Mat* cvInput = getCvFrame( pInputPel, iWidth, iHeight );
|
||||
|
||||
UInt numberFilters = 1;
|
||||
UChar* pCvPel[3];
|
||||
cv::Mat* cvOutput[3];
|
||||
for( UInt i = 0; i < numberFilters; i++ )
|
||||
{
|
||||
cvOutput[i] = filterframe( cvInput, ( 1 << ( 2 * i + 7 ) ) + 1 );
|
||||
pCvPel[i] = cvOutput[i]->data;
|
||||
}
|
||||
|
||||
Int iCheckNeighbour = 8;
|
||||
UInt uiRelevance = 0;
|
||||
for( Int y = 0; y < iHeight; y++ )
|
||||
{
|
||||
for( Int x = 0; x < iWidth; x++ )
|
||||
{
|
||||
uiRelevance = 0;
|
||||
// uiRelevance = *pMapPel;
|
||||
for( Int j = CLAMP_RANGE( y - iCheckNeighbour, 0, iHeight ); j < CLAMP_RANGE( y + iCheckNeighbour + 1, 0, iHeight ); j++ )
|
||||
{
|
||||
for( Int 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( UInt i = 0; i < numberFilters; i++ )
|
||||
pCvPel[i]++;
|
||||
pInputPel++;
|
||||
pOutputPel++;
|
||||
pMapPel += iMapStep;
|
||||
}
|
||||
pMapPel += ( iMapStep - 1 ) * iWidth;
|
||||
}
|
||||
}
|
||||
|
||||
PlaYUVerFrame* SaliencyBasedFiltering::process( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
PlaYUVerFrame* pcInputFrame = apcFrameList[0];
|
||||
|
||||
for( UInt c = 0; c < pcInputFrame->getNumberChannels(); c++ )
|
||||
filterComponent( pcInputFrame, m_pcProcessedFrame, apcFrameList[1], c );
|
||||
|
||||
return m_pcProcessedFrame;
|
||||
}
|
||||
|
||||
Void SaliencyBasedFiltering::destroy()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/* 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 <cassert>
|
||||
|
||||
#include "lib/PlaYUVerModuleIf.h"
|
||||
|
||||
class SaliencyBasedFiltering : public PlaYUVerModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( SaliencyBasedFiltering )
|
||||
|
||||
private:
|
||||
PlaYUVerFrame* m_pcProcessedFrame;
|
||||
|
||||
public:
|
||||
SaliencyBasedFiltering();
|
||||
virtual ~SaliencyBasedFiltering()
|
||||
{
|
||||
}
|
||||
Bool create( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
PlaYUVerFrame* process( std::vector<PlaYUVerFrame*> apcFrameList );
|
||||
Void destroy();
|
||||
};
|
||||
|
||||
#endif // __SALIENCYBASEDFILTERING_H__
|
||||
@@ -0,0 +1,764 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyDownsampling.cpp
|
||||
* \brief Adaptive Latitude Downsampling
|
||||
*/
|
||||
|
||||
#include "ThreeSixtyDownsampling.h"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
//#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/photo.hpp>
|
||||
|
||||
//using cv::InputArray;
|
||||
//using cv::OutputArray;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
using cv::Size;
|
||||
|
||||
ThreeSixtyDownsampling::ThreeSixtyDownsampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleName = "ThreeSixtyDownsampling";
|
||||
m_pchModuleLongName = "Adaptive Latitude Downsampling";
|
||||
m_pchModuleTooltip = "Adaptive Latitude Downsampling";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
|
||||
CLP_MODULE_REQUIRES_OPTIONS |
|
||||
CLP_MODULES_HAS_INFO |
|
||||
CLP_MODULE_USES_KEYS;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Downsampling", m_uiDownsampling, "ERP to NxN (0 for up, 1 for down and 2 for recon) [1]" ) /**/
|
||||
( "y0", m_uiY0, "Vertical anchor point ratio (0-100) [0]" ) /**/
|
||||
( "x0", m_uiX0, "Horizontal anchor point ratio (0-100) [25%]" ) /**/
|
||||
// INTER_NEAREST - a nearest-neighbor interpolation
|
||||
// INTER_LINEAR - a bilinear interpolation (used by default)
|
||||
// INTER_AREA - resampling using pixel area relation. It may be a preferred
|
||||
// method for image decimation, as it gives moire’-free results. But when
|
||||
// the image is zoomed, it is similar to the INTER_NEAREST method.
|
||||
// INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
|
||||
// INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood
|
||||
( "Interpolation", m_iInterpolation, "Interpolation method (1-4) [2]" ) /**/
|
||||
( "IntegerSlope", m_bForceIntSlope, "Force the downsampling slope to be integer (binary) [0]" ) /**/
|
||||
( "Packing", m_iRearrange, "Rearrange image into a rectangle (0-3) [0]" ) /**/
|
||||
( "Inpainting", m_iInpaintMethod, "Use inpainting to fill empty pixels (0-2) [0]" ) /**/
|
||||
( "UpsampWidth", m_iWidth, "Image width after upsampling [-1]" );
|
||||
|
||||
m_uiDownsampling = 1;
|
||||
m_uiY0 = 0;
|
||||
m_uiX0 = 0;
|
||||
m_iInterpolation = 2;
|
||||
m_iInpaintMethod = 0;
|
||||
m_bForceIntSlope = 0;
|
||||
m_iRearrange = 0;
|
||||
m_iWidth = -1;
|
||||
m_pcOutputFrame = NULL;
|
||||
m_pcDownsampled = NULL;
|
||||
m_dPixelRatio = 0;
|
||||
|
||||
//#ifdef DEBUG
|
||||
// m_uiY0 = 25;
|
||||
// m_uiX0 = 0;
|
||||
// m_iInterpolation = 4;
|
||||
// m_bForceIntSlope = 1;
|
||||
// m_iRearrange = 1;
|
||||
//#endif
|
||||
}
|
||||
|
||||
ClpString ThreeSixtyDownsampling::moduleInfo()
|
||||
{
|
||||
ClpString info( "" );
|
||||
info += "Interpolation: ";
|
||||
switch( m_iInterpolation )
|
||||
{
|
||||
case cv::INTER_NEAREST:
|
||||
info += "Nearest";
|
||||
break;
|
||||
case cv::INTER_LINEAR:
|
||||
info += "Linear";
|
||||
break;
|
||||
case cv::INTER_AREA:
|
||||
info += "Area";
|
||||
break;
|
||||
case cv::INTER_CUBIC:
|
||||
info += "Cubic";
|
||||
break;
|
||||
case cv::INTER_LANCZOS4:
|
||||
info += "Lanczos4";
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
}
|
||||
info += "\ny0 = " + std::to_string( m_uiY0 ) + "\nx0 = " + std::to_string( m_uiX0 );
|
||||
if( m_bForceIntSlope == 0 )
|
||||
info += "\nNo integer slope";
|
||||
else
|
||||
info += "\nUisng integer slope";
|
||||
info += "\nPixel ratio = " + std::to_string( m_dPixelRatio );
|
||||
return info;
|
||||
}
|
||||
|
||||
bool ThreeSixtyDownsampling::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
m_uiDownsampling = m_uiDownsampling > 2 ? 1 : m_uiDownsampling;
|
||||
|
||||
if( !createDownsamplingMask( apcFrameList[0] ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch( m_iInterpolation )
|
||||
{
|
||||
case 2:
|
||||
m_iInterpolation = cv::INTER_LINEAR;
|
||||
break;
|
||||
case 3:
|
||||
m_iInterpolation = cv::INTER_CUBIC;
|
||||
break;
|
||||
case 4:
|
||||
m_iInterpolation = cv::INTER_LANCZOS4;
|
||||
break;
|
||||
default:
|
||||
m_iInterpolation = cv::INTER_NEAREST;
|
||||
}
|
||||
|
||||
switch( m_iInpaintMethod )
|
||||
{
|
||||
case 1:
|
||||
m_iInterpolation = cv::INPAINT_NS;
|
||||
break;
|
||||
case 2:
|
||||
m_iInpaintMethod = cv::INPAINT_TELEA;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define WIDTH_TRIM_START_POINT 0.0
|
||||
#define WIDTH_FINAL 1.0
|
||||
|
||||
bool ThreeSixtyDownsampling::createDownsamplingMask( CalypFrame* pcInputFrame )
|
||||
{
|
||||
if( m_iRearrange == 3 )
|
||||
{
|
||||
m_uiX0 = 0;
|
||||
m_uiY0 = std::ceil( 100.0 / 3.0 );
|
||||
}
|
||||
|
||||
if( m_iRearrange == 4 )
|
||||
{
|
||||
m_uiX0 = 0;
|
||||
m_uiY0 = m_uiY0 > 37 ? 40 : 34;
|
||||
}
|
||||
|
||||
m_iHeight = -1;
|
||||
if( m_uiDownsampling == 0 )
|
||||
{
|
||||
if( m_iWidth == -1 )
|
||||
{
|
||||
// Guess the output dimensions when upsampling
|
||||
switch( m_iRearrange )
|
||||
{
|
||||
case 1: // Cannot get this - user input needed
|
||||
break;
|
||||
case 2:
|
||||
m_iWidth = pcInputFrame->getWidth();
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_iHeight = m_iWidth / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iWidth = pcInputFrame->getWidth();
|
||||
m_iHeight = pcInputFrame->getHeight();
|
||||
}
|
||||
if( m_iWidth == -1 || m_iHeight == -1 ) // output dimensions are needed
|
||||
return false;
|
||||
|
||||
//m_pcDownsampled = new CalypFrame( m_iWidth, m_uiHeight, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
m_pcDownsampled = new CalypFrame( m_iWidth, m_iHeight, CalypFrame::findPixelFormat( "GRAY" ), pcInputFrame->getBitsPel() );
|
||||
|
||||
m_isOdd = !( m_iHeight % 2 );
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat* downsamplingMaskPtr = new Mat( m_pcDownsampled->getHeight( ch ), m_pcDownsampled->getWidth( ch ), CV_8UC1, Scalar( 0 ) );
|
||||
Mat downsamplingMask = *downsamplingMaskPtr;
|
||||
Mat_<Point> initialReshapePoints( m_pcDownsampled->getHeight( ch ), m_pcDownsampled->getWidth( ch ), Point( -1, -1 ) );
|
||||
|
||||
int imH = m_pcDownsampled->getHeight( ch );
|
||||
int imN = imH / 2;
|
||||
|
||||
// Find lines
|
||||
double theta = atan2( imN, imH - WIDTH_TRIM_START_POINT - WIDTH_FINAL );
|
||||
double y0 = std::ceil( float( int( m_uiY0 ) * imH ) / 200.0 );
|
||||
double x0 = std::round( float( int( m_uiX0 ) * imH ) / 100.0 );
|
||||
double xl = 0;
|
||||
double slope2 = 0;
|
||||
|
||||
if( m_iRearrange == 3 || m_iRearrange == 4 )
|
||||
{
|
||||
y0 = std::ceil( y0 / 64.0 ) * 64;
|
||||
}
|
||||
|
||||
Point p0;
|
||||
Point p1;
|
||||
Point p2;
|
||||
|
||||
if( m_uiY0 > 0 )
|
||||
{
|
||||
double x0min = ( 1 + y0 / tan( theta ) - imH + WIDTH_TRIM_START_POINT ) * double( imN - y0 ) / y0 + y0 / tan( theta );
|
||||
|
||||
x0 = std::max( x0, x0min );
|
||||
xl = double( imH - WIDTH_TRIM_START_POINT ) - y0 / tan( theta ) - y0 * y0 / double( imN - y0 ) * ( 1.0 / tan( theta ) - x0 / y0 );
|
||||
xl = std::floor( xl );
|
||||
if( m_iRearrange == 3 )
|
||||
xl = imH / 2;
|
||||
else if( m_iRearrange == 4 && m_uiY0 == 34 )
|
||||
xl = imH / 2;
|
||||
else if( m_iRearrange == 4 && m_uiY0 == 40 )
|
||||
xl = imH / 3;
|
||||
|
||||
slope2 = xl / ( double( imN ) - y0 );
|
||||
if( m_bForceIntSlope )
|
||||
slope2 = std::round( slope2 );
|
||||
|
||||
// calculate the final coordinates of point corresponding to y0
|
||||
// p0 corresponds to a coordinate system with reference ate left-most equator
|
||||
p0 = Point( int( ( double( y0 + 1 ) - double( imH ) / 2.0 ) * slope2 + double( imH - WIDTH_FINAL ) ), y0 );
|
||||
// give the y value of the triangle which can be used to fill the gap
|
||||
if( m_iRearrange == 2 )
|
||||
{
|
||||
int y1 = double( -p0.x + WIDTH_FINAL ) / slope2 + imN;
|
||||
p1 = Point( int( ( double( y1 + 1 ) - double( imH ) / 2.0 ) * slope2 + double( imH - WIDTH_FINAL ) ), y1 );
|
||||
p2 = Point( -1, ( imH - p1.y ) / 2 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
slope2 = 2;
|
||||
p0 = Point( 0, 0 );
|
||||
p1 = Point( -1, imN );
|
||||
}
|
||||
|
||||
// Reset mask
|
||||
downsamplingMask = Scalar( 0 );
|
||||
|
||||
for( int line = 0; line < imN; line++ )
|
||||
{
|
||||
for( int hemisfer = -1; hemisfer < 2; hemisfer += 2 )
|
||||
{
|
||||
// calculate destination sizes
|
||||
int ypos = ( ( imH + ( m_isOdd ? hemisfer : 0 ) ) >> 1 ) + line * hemisfer;
|
||||
int lineWidth = 0;
|
||||
|
||||
if( m_uiY0 == 0 )
|
||||
{
|
||||
lineWidth = ( 2 * imH - 2 ) - 4 * line;
|
||||
}
|
||||
else
|
||||
{
|
||||
double lp = 0;
|
||||
if( line < y0 )
|
||||
lp = line * x0 / y0;
|
||||
else
|
||||
lp = ( line + 1 - imN ) * slope2 + double( imH - WIDTH_FINAL );
|
||||
lp = std::round( lp );
|
||||
assert( imH >= lp );
|
||||
lineWidth = 2 * imH - 2 * lp;
|
||||
}
|
||||
assert( lineWidth > 0 );
|
||||
int xpos = imH - lineWidth / 2; // N - WIDTH/2
|
||||
|
||||
// create mask and init reshape matrix
|
||||
Mat downsamplingMaskRow = downsamplingMask.row( ypos );
|
||||
Mat_<Point> reshapePointsRow = initialReshapePoints.row( ypos );
|
||||
for( int x = xpos; x < xpos + lineWidth; x++ )
|
||||
{
|
||||
*( downsamplingMaskRow.data + x ) = ch == 0 ? 255 : 128;
|
||||
reshapePointsRow( x ) = Point( x, ypos );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( m_iRearrange > 0 )
|
||||
{
|
||||
// initialReshapePoints -> Original coordinates without re-arrange
|
||||
// intermediateReshapePoints -> Coordinates with re-arrange <- Set this
|
||||
|
||||
Mat_<Point> intermediateReshapePoints;
|
||||
|
||||
int imH = int( m_pcDownsampled->getHeight( ch ) );
|
||||
int imN = imH / 2;
|
||||
|
||||
// Strecth into wide rectangle
|
||||
if( m_iRearrange == 1 )
|
||||
{
|
||||
intermediateReshapePoints = Mat_<Point>( initialReshapePoints.rows, initialReshapePoints.cols, Point( -1, -1 ) );
|
||||
Size maskSize( imH - p0.x, imN - p0.y );
|
||||
for( int hemisfer = -1; hemisfer < 2; hemisfer += 2 )
|
||||
{
|
||||
// copy center
|
||||
Point r0_pt( 0, imN );
|
||||
Point r0_size( 2 * imH, hemisfer * p0.y );
|
||||
initialReshapePoints( Rect( r0_pt, r0_pt + r0_size ) ).copyTo( intermediateReshapePoints( Rect( r0_pt, r0_pt + r0_size ) ) );
|
||||
|
||||
// main triangle
|
||||
Mat currMask;
|
||||
downsamplingMask( Rect( Point( p0.x, 0 ), maskSize ) ).copyTo( currMask );
|
||||
if( hemisfer == 1 )
|
||||
cv::flip( currMask, currMask, 0 ); // Filp vertically
|
||||
|
||||
initialReshapePoints( Rect( Point( p0.x, hemisfer == -1 ? 0 : imN + p0.y ), maskSize ) )
|
||||
.copyTo( intermediateReshapePoints( Rect( Point( 1, hemisfer == -1 ? 0 : imN + p0.y ), maskSize ) ), currMask );
|
||||
|
||||
// rotated triangle
|
||||
Mat tmpTriangle;
|
||||
initialReshapePoints( Rect( Point( imH, hemisfer == -1 ? 0 : imN + p0.y ), maskSize ) ).copyTo( tmpTriangle );
|
||||
cv::flip( tmpTriangle, tmpTriangle, 0 );
|
||||
|
||||
cv::flip( currMask, currMask, 1 ); // Filp horizontaly
|
||||
cv::flip( currMask, currMask, 0 );
|
||||
tmpTriangle.copyTo( intermediateReshapePoints( Rect( Point( 0, hemisfer == -1 ? 0 : imN + p0.y ), maskSize ) ), currMask );
|
||||
tmpTriangle.release();
|
||||
}
|
||||
// At this point the two triangle were merged into a rectangle
|
||||
if( ( ( imN - p0.y ) % p0.y ) == 0 ) // check if we can divide the rectangles into equally heighted slices
|
||||
{
|
||||
int numberRectSlices = ( imN - p0.y ) / p0.y;
|
||||
int rectSlicesWidth = 2 * imN - p0.x + 1;
|
||||
// create extended reshapePoints
|
||||
Mat_<Point> extendedReshapePoints( 2 * p0.y, intermediateReshapePoints.cols + rectSlicesWidth * numberRectSlices, Point( -1, -1 ) );
|
||||
intermediateReshapePoints( Rect( Point( 0, imN - p0.y ), Size( intermediateReshapePoints.cols, 2 * p0.y ) ) )
|
||||
.copyTo( extendedReshapePoints( Rect( Point( 0, 0 ), Size( intermediateReshapePoints.cols, 2 * p0.y ) ) ) );
|
||||
for( int hemisfer = -1; hemisfer < 2; hemisfer += 2 )
|
||||
{
|
||||
Point initSize( rectSlicesWidth, hemisfer * p0.y );
|
||||
Point finalPoint = Point( 0, p0.y ) + Point( 2 * imH, 0 );
|
||||
for( int i = 0; i < numberRectSlices; i++ )
|
||||
{
|
||||
Point initPoint = Point( 0, imN + hemisfer * ( p0.y + i * p0.y ) );
|
||||
intermediateReshapePoints( Rect( initPoint, initPoint + initSize ) ).copyTo( extendedReshapePoints( Rect( finalPoint, finalPoint + initSize ) ) );
|
||||
finalPoint += Point( rectSlicesWidth, 0 );
|
||||
}
|
||||
}
|
||||
intermediateReshapePoints.release();
|
||||
extendedReshapePoints.copyTo( intermediateReshapePoints );
|
||||
extendedReshapePoints.release();
|
||||
}
|
||||
}
|
||||
// Rotate triangles into a rectangle and spread the top small triangles
|
||||
else if( m_iRearrange == 2 )
|
||||
{
|
||||
intermediateReshapePoints = Mat_<Point>( initialReshapePoints.rows, initialReshapePoints.cols, Point( -1, -1 ) );
|
||||
for( int hemisfer = -1; hemisfer < 2; hemisfer += 2 )
|
||||
{
|
||||
if( p0.x < imN )
|
||||
{
|
||||
for( int side = -1; side < 2; side += 2 )
|
||||
{
|
||||
// center
|
||||
Point r0_pt( imH, imN );
|
||||
Point r0_size( side * imH, hemisfer * p0.y );
|
||||
initialReshapePoints( Rect( r0_pt, r0_pt + r0_size ) ).copyTo( intermediateReshapePoints( Rect( r0_pt, r0_pt + r0_size ) ) );
|
||||
|
||||
// copy center unmodified
|
||||
Point r1_pt = r0_pt + Point( 0, hemisfer * p0.y );
|
||||
Point r1_size( side * imH, hemisfer * ( p1.y - p0.y ) / 2 );
|
||||
Rect mainRoi( r1_pt, r1_pt + r1_size );
|
||||
initialReshapePoints( mainRoi ).copyTo( intermediateReshapePoints( mainRoi ), downsamplingMask( mainRoi ) );
|
||||
|
||||
// rotated polygon
|
||||
Point r2_pt = r1_pt + Point( 0, hemisfer * ( p1.y - p0.y ) / 2 );
|
||||
Mat_<Point> auxPointMap;
|
||||
Mat auxMask;
|
||||
initialReshapePoints( Rect( r2_pt, r2_pt + r1_size ) ).copyTo( auxPointMap );
|
||||
downsamplingMask( Rect( r2_pt, r2_pt + r1_size ) ).copyTo( auxMask );
|
||||
cv::flip( auxPointMap, auxPointMap, -1 );
|
||||
cv::flip( auxMask, auxMask, -1 );
|
||||
auxPointMap.copyTo( intermediateReshapePoints( mainRoi ), auxMask );
|
||||
auxPointMap.release();
|
||||
auxMask.release();
|
||||
|
||||
// top triangle
|
||||
// the top triangle is converted to a rectangle and then reshape into and new rectangle with a larger width
|
||||
Point r34_size( side * ( imH - p1.x + 1 ), hemisfer * ( imN - p1.y ) / 2 );
|
||||
Point r3_pt( imH, imN + hemisfer * p1.y );
|
||||
Point r4_pt = r3_pt + Point( 0, r34_size.y );
|
||||
|
||||
Point r3l_pt( r3_pt.x, r2_pt.y );
|
||||
|
||||
Mat_<Point> topTriangleReshape;
|
||||
initialReshapePoints( Rect( r3_pt, r3_pt + r34_size ) ).copyTo( topTriangleReshape );
|
||||
|
||||
// rotate the top of the top triangle to form a rectangle
|
||||
initialReshapePoints( Rect( r4_pt, r4_pt + r34_size ) ).copyTo( auxPointMap );
|
||||
downsamplingMask( Rect( r4_pt, r4_pt + r34_size ) ).copyTo( auxMask );
|
||||
|
||||
cv::flip( auxPointMap, auxPointMap, -1 );
|
||||
cv::flip( auxMask, auxMask, -1 );
|
||||
|
||||
//cv::imwrite( "auxMask.png", auxMask );
|
||||
auxPointMap.copyTo( topTriangleReshape, auxMask );
|
||||
|
||||
long shape_area = std::abs( r34_size.x ) * std::abs( r34_size.y );
|
||||
int reshapedWidth = imH;
|
||||
while( 1 )
|
||||
{
|
||||
if( !( shape_area % reshapedWidth ) )
|
||||
break;
|
||||
reshapedWidth--;
|
||||
}
|
||||
int reshaped_height = shape_area / reshapedWidth;
|
||||
if( shape_area % reshapedWidth )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
topTriangleReshape = topTriangleReshape.reshape( 1, reshaped_height );
|
||||
topTriangleReshape.copyTo( intermediateReshapePoints( Rect( r3l_pt, r3l_pt + Point( side * topTriangleReshape.cols, hemisfer * topTriangleReshape.rows ) ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( m_iRearrange == 3 )
|
||||
{
|
||||
intermediateReshapePoints = Mat_<Point>( 8 * p0.y, initialReshapePoints.cols, Point( -1, -1 ) );
|
||||
for( int hemisfer = -1; hemisfer < 2; hemisfer += 2 )
|
||||
{
|
||||
Point r_pt;
|
||||
Point r_size;
|
||||
Point r_pt_final;
|
||||
Mat currMask;
|
||||
|
||||
// copy half of rectangle 6 and 5
|
||||
r_pt = Point( p0.x, imN );
|
||||
r_size = Point( 2 * ( imH - p0.x ), hemisfer * p0.y );
|
||||
r_pt_final = Point( p0.x, 3 * p0.y );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
|
||||
// copy triangle 2 or 4
|
||||
r_pt = Point( imH, imN + hemisfer * p0.y );
|
||||
r_size = Point( -( imH - p0.x ), hemisfer * ( imN - p0.y ) );
|
||||
r_pt_final = Point( imH, 3 * p0.y + hemisfer * p0.y );
|
||||
downsamplingMask( Rect( r_pt, r_pt + r_size ) ).copyTo( currMask );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ), currMask );
|
||||
currMask.release();
|
||||
|
||||
// copy triangle 3 or 1
|
||||
r_pt = Point( imH, imN - hemisfer * p0.y );
|
||||
r_size = Point( imH - p0.x, -1 * hemisfer * ( imN - p0.y ) );
|
||||
r_pt_final = Point( p0.x, hemisfer == -1 ? 0 : 6 * p0.y );
|
||||
|
||||
downsamplingMask( Rect( r_pt, r_pt + r_size ) ).copyTo( currMask );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ), currMask );
|
||||
|
||||
// copy rectangle 7 and 8
|
||||
r_pt = Point( imH - hemisfer * ( imH - p0.x ), imN - p0.y );
|
||||
r_size = Point( -hemisfer * p0.x, p0.y * 2 );
|
||||
if( hemisfer == -1 )
|
||||
r_pt_final = Point( imH, 0 );
|
||||
else
|
||||
r_pt_final = Point( 2 * imH - p0.x, 4 * p0.y );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
}
|
||||
}
|
||||
else if( m_iRearrange == 4 )
|
||||
{
|
||||
intermediateReshapePoints = Mat_<Point>( 10 * p0.y, initialReshapePoints.cols, Point( -1, -1 ) );
|
||||
//unsigned hor_pad = 0;
|
||||
unsigned ver_pad = 0;
|
||||
if( m_uiY0 == 40 )
|
||||
{
|
||||
if( unsigned( 4 * p0.y + ( imH - p0.y ) ) % 2 )
|
||||
{
|
||||
ver_pad = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( unsigned( 6 * p0.y + ( imH - p0.y ) ) % 2 )
|
||||
{
|
||||
ver_pad = 1;
|
||||
}
|
||||
}
|
||||
for( int side = -1; side < 2; side += 2 )
|
||||
{
|
||||
Point r_pt;
|
||||
Point r_size;
|
||||
Point r_pt_final;
|
||||
Mat currMask;
|
||||
|
||||
// copy half of rectangle 6 and 5
|
||||
r_pt = Point( p0.x, imN - p0.y );
|
||||
r_size = Point( 2 * ( imH - p0.x ), 2 * p0.y );
|
||||
r_pt_final = Point( p0.x, imN - p0.y );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
|
||||
// copy triangle 2 or 1
|
||||
r_pt = Point( imH, imN - p0.y );
|
||||
r_size = Point( side * ( imH - p0.x ), -( imN - p0.y ) );
|
||||
r_pt_final = Point( imH, imN - p0.y );
|
||||
downsamplingMask( Rect( r_pt, r_pt + r_size ) ).copyTo( currMask );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ), currMask );
|
||||
currMask.release();
|
||||
|
||||
// copy triangle 4 or 3
|
||||
r_pt = Point( imH, imN + p0.y );
|
||||
r_size = Point( side * ( imH - p0.x ), imN - p0.y );
|
||||
r_pt_final = Point( imH - side * ( imH - p0.x ), 0 );
|
||||
downsamplingMask( Rect( r_pt, r_pt + r_size ) ).copyTo( currMask );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ), currMask );
|
||||
|
||||
// copy rectangle 7 and 8
|
||||
if( m_uiY0 == 40 )
|
||||
{
|
||||
r_pt = Point( imH + side * ( imH - p0.x ), imN - p0.y );
|
||||
r_size = Point( side * p0.x, p0.y * 2 );
|
||||
r_pt_final = Point( imH - side * ( imH - p0.x ), ver_pad + imN + ( side == -1 ? p0.y : 3 * p0.y ) );
|
||||
if( side == -1 )
|
||||
{
|
||||
Mat flipRect;
|
||||
cv::flip( initialReshapePoints( Rect( r_pt, r_pt + r_size ) ), flipRect, -1 );
|
||||
flipRect.copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r_pt = Point( imH + side * ( imH - p0.x ), imN - p0.y );
|
||||
r_size = Point( side * p0.x, p0.y * 2 );
|
||||
r_pt_final = Point( imH - side * p0.x, imN + p0.y + ver_pad );
|
||||
initialReshapePoints( Rect( r_pt, r_pt + r_size ) ).copyTo( intermediateReshapePoints( Rect( r_pt_final, r_pt_final + r_size ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
initialReshapePoints.release();
|
||||
intermediateReshapePoints.copyTo( initialReshapePoints ); // copy back to the initial Mat
|
||||
}
|
||||
|
||||
// Create a mask with valid reshape points in order to create the final rectangular frame
|
||||
Mat reshapePointsMask( initialReshapePoints.rows, initialReshapePoints.cols, CV_8UC1, Scalar( 0 ) );
|
||||
m_dPixelRatio = 0;
|
||||
for( int y = 0; y < initialReshapePoints.rows; y++ )
|
||||
for( int x = 0; x < initialReshapePoints.cols; x++ )
|
||||
if( initialReshapePoints.at<Point>( y, x ).x != -1 )
|
||||
{
|
||||
reshapePointsMask.at<uchar>( y, x ) = 1;
|
||||
m_dPixelRatio++;
|
||||
}
|
||||
m_dPixelRatio = m_dPixelRatio / double( pcInputFrame->getWidth() * pcInputFrame->getHeight() );
|
||||
|
||||
Rect reshapeArea = boundingRect( reshapePointsMask );
|
||||
Mat_<Point>* finalReshapePointsPtr = new Mat_<Point>( reshapeArea.height, reshapeArea.width );
|
||||
initialReshapePoints( reshapeArea ).copyTo( *finalReshapePointsPtr );
|
||||
|
||||
m_cvDownsamplingMask.push_back( downsamplingMaskPtr ); // Save Mat's for each channel
|
||||
m_cvReshapePoints.push_back( finalReshapePointsPtr );
|
||||
}
|
||||
switch( m_uiDownsampling )
|
||||
{
|
||||
case 0:
|
||||
m_pcOutputFrame = new CalypFrame( m_pcDownsampled->getWidth(), m_pcDownsampled->getHeight(), pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
break;
|
||||
case 1:
|
||||
m_pcOutputFrame = new CalypFrame( m_cvReshapePoints[0]->cols, m_cvReshapePoints[0]->rows, pcInputFrame->getPelFormat(), pcInputFrame->getBitsPel() );
|
||||
break;
|
||||
case 2:
|
||||
m_pcOutputFrame = new CalypFrame( pcInputFrame );
|
||||
m_pcOutputFrame->reset();
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreeSixtyDownsampling::downsamplingOperation( CalypFrame* pcInputFrame )
|
||||
{
|
||||
unsigned numBytes = m_pcDownsampled->getBitsPel() > 8 ? 2 : 1;
|
||||
m_pcDownsampled->reset();
|
||||
m_pcOutputFrame->reset();
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
{
|
||||
int imH = int( m_pcDownsampled->getHeight( ch ) );
|
||||
|
||||
Mat cvInputFrame;
|
||||
pcInputFrame->toMat( cvInputFrame, true, false, ch );
|
||||
for( int y = 0; y < imH; y++ )
|
||||
{
|
||||
// calculate destination sizes
|
||||
int lineWidth = cv::countNonZero( m_cvDownsamplingMask[ch]->row( y ) );
|
||||
int xpos = imH - lineWidth / 2; // (2*HEIGHT - WIDTH)/2
|
||||
|
||||
Mat cvDownsample( 1, lineWidth, numBytes > 2 ? CV_16UC1 : CV_8UC1 );
|
||||
cv::resize( cvInputFrame.row( y ), cvDownsample, cvDownsample.size(), 0, 0, m_iInterpolation );
|
||||
|
||||
// copy to output
|
||||
ClpPel* outpel = &m_pcDownsampled->getPelBufferYUV()[ch][y][xpos];
|
||||
unsigned char* cv_data = cvDownsample.data;
|
||||
for( int i = 0; i < lineWidth; i++ )
|
||||
{
|
||||
*outpel = 0;
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
{
|
||||
*outpel = ClpPel( *outpel + ( *cv_data++ << ( 8 * b ) ) );
|
||||
}
|
||||
outpel++;
|
||||
}
|
||||
}
|
||||
Mat_<Point> reshapePoints = *( m_cvReshapePoints[ch] );
|
||||
ClpPel** downSampPelBuff = m_pcDownsampled->getPelBufferYUV()[ch];
|
||||
ClpPel* pelOutputPtr = m_pcOutputFrame->getPelBufferYUV()[ch][0];
|
||||
|
||||
Mat outputMask( m_pcOutputFrame->getHeight( ch ), m_pcOutputFrame->getWidth( ch ), CV_8UC1, Scalar( 1 ) );
|
||||
for( unsigned y = 0; y < m_pcOutputFrame->getHeight( ch ); y++ )
|
||||
{
|
||||
for( unsigned x = 0; x < m_pcOutputFrame->getWidth( ch ); x++ )
|
||||
{
|
||||
Point pt = reshapePoints.at<Point>( y, x );
|
||||
if( pt.x > -1 )
|
||||
{
|
||||
*pelOutputPtr = downSampPelBuff[pt.y][pt.x];
|
||||
outputMask.at<unsigned char>( y, x ) = 0;
|
||||
}
|
||||
pelOutputPtr++;
|
||||
}
|
||||
}
|
||||
if( m_iInpaintMethod )
|
||||
{
|
||||
Mat outputFrameUnfilled, outputFrame;
|
||||
m_pcOutputFrame->toMat( outputFrameUnfilled, true, false, ch );
|
||||
cv::inpaint( outputFrameUnfilled, outputMask, outputFrame, 16, m_iInpaintMethod );
|
||||
m_pcOutputFrame->fromMat( outputFrame, ch );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ThreeSixtyDownsampling::upsamplingOperation( CalypFrame* pcInputFrame )
|
||||
{
|
||||
unsigned numBytes = m_pcDownsampled->getBitsPel() > 8 ? 2 : 1;
|
||||
m_pcDownsampled->reset();
|
||||
m_pcOutputFrame->reset();
|
||||
for( unsigned ch = 0; ch < m_pcDownsampled->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat_<Point> reshapePoints = *( m_cvReshapePoints[ch] );
|
||||
ClpPel** downSampPelBuff = m_pcDownsampled->getPelBufferYUV()[ch];
|
||||
ClpPel* pelInputPtr = pcInputFrame->getPelBufferYUV()[ch][0];
|
||||
for( unsigned y = 0; y < pcInputFrame->getHeight( ch ); y++ )
|
||||
{
|
||||
for( unsigned x = 0; x < pcInputFrame->getWidth( ch ); x++ )
|
||||
{
|
||||
Point pt = reshapePoints.at<Point>( y, x );
|
||||
if( pt.x > -1 )
|
||||
downSampPelBuff[pt.y][pt.x] = *( pelInputPtr );
|
||||
pelInputPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
Mat cvDownsampled;
|
||||
m_pcDownsampled->toMat( cvDownsampled, true, false, ch );
|
||||
int imH = m_pcOutputFrame->getHeight( ch );
|
||||
Mat cvUpsample( 1, 2 * imH, numBytes > 2 ? CV_16UC1 : CV_8UC1 );
|
||||
for( int y = 0; y < imH; y++ )
|
||||
{
|
||||
unsigned lineWidth = cv::countNonZero( m_cvDownsamplingMask[ch]->row( y ) );
|
||||
unsigned int xpos = imH - lineWidth / 2; // N - WIDTH/2
|
||||
|
||||
// resize
|
||||
cv::resize( cvDownsampled.row( y ).colRange( xpos, xpos + lineWidth ), cvUpsample, cvUpsample.size(), 0, 0, m_iInterpolation );
|
||||
|
||||
// copy to output
|
||||
ClpPel* outpel = &m_pcOutputFrame->getPelBufferYUV()[ch][y][0];
|
||||
unsigned char* cv_data = cvUpsample.data;
|
||||
for( int i = 0; i < 2 * imH; i++ )
|
||||
{
|
||||
*outpel = 0;
|
||||
for( unsigned b = 0; b < numBytes; b++ )
|
||||
{
|
||||
*outpel = ClpPel( *outpel + ( *cv_data++ << ( 8 * b ) ) );
|
||||
}
|
||||
outpel++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//m_pcOutputFrame->copyFrom( m_pcDownsampled );
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyDownsampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcDownsampled->reset();
|
||||
if( m_uiDownsampling == 1 || m_uiDownsampling == 2 )
|
||||
{
|
||||
downsamplingOperation( apcFrameList[0] );
|
||||
}
|
||||
if( m_uiDownsampling == 0 || m_uiDownsampling == 2 )
|
||||
{
|
||||
upsamplingOperation( m_uiDownsampling == 2 ? m_pcOutputFrame : apcFrameList[0] );
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
bool ThreeSixtyDownsampling::keyPressed( enum Module_Key_Supported value )
|
||||
{
|
||||
bool bRet = false;
|
||||
if( value == MODULE_KEY_LEFT )
|
||||
{
|
||||
m_uiX0 = m_uiX0 == 0 ? 0 : m_uiX0 - 1;
|
||||
}
|
||||
else if( value == MODULE_KEY_RIGHT )
|
||||
{
|
||||
m_uiX0 = m_uiX0 == 60 ? 60 : m_uiX0 + 1;
|
||||
}
|
||||
else if( value == MODULE_KEY_DOWN )
|
||||
{
|
||||
m_uiY0 = m_uiY0 == 0 ? 0 : m_uiY0 - 1;
|
||||
}
|
||||
else if( value == MODULE_KEY_UP )
|
||||
{
|
||||
m_uiY0 = m_uiY0 == 60 ? 60 : m_uiY0 + 1;
|
||||
}
|
||||
if( bRet )
|
||||
{
|
||||
bRet = createDownsamplingMask( m_pcDownsampled );
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void ThreeSixtyDownsampling::destroy()
|
||||
{
|
||||
if( m_pcDownsampled )
|
||||
delete m_pcDownsampled;
|
||||
m_pcDownsampled = NULL;
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyDownsampling.h
|
||||
* \brief Adaptive Latitude Downsampling
|
||||
*/
|
||||
|
||||
#ifndef __THREESIXTYDOWNSAMPLING_H__
|
||||
#define __THREESIXTYDOWNSAMPLING_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
#include "opencv2/core/mat.hpp"
|
||||
#include "opencv2/core/types.hpp"
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Mat_;
|
||||
using cv::Point;
|
||||
|
||||
class ThreeSixtyDownsampling : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyDownsampling )
|
||||
private:
|
||||
unsigned m_uiDownsampling;
|
||||
unsigned m_uiX0;
|
||||
unsigned m_uiY0;
|
||||
int m_iInterpolation;
|
||||
int m_iInpaintMethod;
|
||||
unsigned m_bForceIntSlope;
|
||||
unsigned m_iRearrange;
|
||||
|
||||
bool m_isOdd;
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
|
||||
double m_dPixelRatio;
|
||||
|
||||
CalypFrame* m_pcDownsampled;
|
||||
|
||||
// Values one per channel
|
||||
std::vector<Mat*> m_cvDownsamplingMask;
|
||||
std::vector<Mat_<Point>*> m_cvReshapePoints;
|
||||
bool createDownsamplingMask( CalypFrame* pcFrame );
|
||||
|
||||
void downsamplingOperation( CalypFrame* pcInputFrame );
|
||||
void upsamplingOperation( CalypFrame* pcInputFrame );
|
||||
|
||||
public:
|
||||
ThreeSixtyDownsampling();
|
||||
virtual ~ThreeSixtyDownsampling() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
ClpString moduleInfo();
|
||||
bool keyPressed( enum Module_Key_Supported value );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __THREESIXTYDOWNSAMPLING_H__
|
||||
@@ -0,0 +1,155 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyDynamicDownsampling.cpp
|
||||
*/
|
||||
|
||||
#include "ThreeSixtyDynamicDownsampling.h"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
using cv::InputArray;
|
||||
using cv::Mat;
|
||||
using cv::OutputArray;
|
||||
using cv::Point;
|
||||
using cv::Rect;
|
||||
using cv::Size;
|
||||
|
||||
ThreeSixtyDynamicDownsampling::ThreeSixtyDynamicDownsampling()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleLongName = "Dynamic Downsampling";
|
||||
m_pchModuleName = "ThreeSixtyDynamicDownsampling";
|
||||
m_pchModuleTooltip = "Dynamic downsampling of 360 videos";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY | CLP_MODULE_REQUIRES_OPTIONS;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "CodingFaceWidth", m_uiFaceWidth, "Coding Face Width [same as input]" ) /**/
|
||||
( "CodingFaceHeight", m_uiFaceHeight, "Coding Face Height [same as input]" ) /**/
|
||||
( "SourceFPStructure", m_arrayInputDefinitionString, "Input frame packing" ) /**/
|
||||
( "CodingFPStructure", m_arrayOutputDefinitionString, "Coding frame packing" ); /**/
|
||||
|
||||
m_arrayInputDefinitionString = "6 2 3 0 0 0 0 100 1 0 1 0 100 2 0 2 0 100 0 1 3 0 100 1 1 4 0 100 2 1 5 0 100";
|
||||
|
||||
m_arrayOutputDefinitionString = "6 3 3 0 0 0 0 100 1 0 1 0 200 0 1 2 0 100 0 2 3 0 100 1 2 4 0 100 2 2 5 0 100 ";
|
||||
|
||||
m_uiFaceWidth = 0;
|
||||
m_uiFaceHeight = 0;
|
||||
}
|
||||
|
||||
void processFPSString( const ClpString& fps, ClpVideoFPStruct* pcFPSStruct )
|
||||
{
|
||||
std::istringstream ss( fps );
|
||||
ss >> pcFPSStruct->numFaces;
|
||||
ss >> pcFPSStruct->rows;
|
||||
ss >> pcFPSStruct->cols;
|
||||
for( int i = 0; i < pcFPSStruct->numFaces; i++ )
|
||||
{
|
||||
ss >> pcFPSStruct->faces[i].x;
|
||||
ss >> pcFPSStruct->faces[i].y;
|
||||
ss >> pcFPSStruct->faces[i].id;
|
||||
ss >> pcFPSStruct->faces[i].rot;
|
||||
ss >> pcFPSStruct->faces[i].ratio;
|
||||
}
|
||||
}
|
||||
|
||||
bool ThreeSixtyDynamicDownsampling::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
|
||||
processFPSString( m_arrayInputDefinitionString, &m_cInputFPSStruct );
|
||||
processFPSString( m_arrayOutputDefinitionString, &m_cOutputFPSStruct );
|
||||
|
||||
if( !m_uiFaceWidth && !m_uiFaceHeight )
|
||||
{
|
||||
m_uiFaceWidth = apcFrameList[0]->getWidth() / m_cInputFPSStruct.cols;
|
||||
m_uiFaceHeight = apcFrameList[0]->getHeight() / m_cInputFPSStruct.rows;
|
||||
}
|
||||
else if( !m_uiFaceHeight )
|
||||
{
|
||||
m_uiFaceHeight = m_uiFaceWidth;
|
||||
}
|
||||
|
||||
m_pcOutputFrame = new CalypFrame( m_uiFaceWidth * m_cOutputFPSStruct.cols,
|
||||
m_uiFaceHeight * m_cOutputFPSStruct.rows,
|
||||
apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyDynamicDownsampling::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
|
||||
for( unsigned ch = 0; ch < apcFrameList[0]->getNumberChannels(); ch++ )
|
||||
{
|
||||
Mat inputFrame;
|
||||
apcFrameList[0]->toMat( inputFrame, true, false, ch );
|
||||
|
||||
unsigned inGridW = apcFrameList[0]->getWidth( ch ) / m_cInputFPSStruct.cols;
|
||||
unsigned inGridH = apcFrameList[0]->getHeight( ch ) / m_cInputFPSStruct.rows;
|
||||
|
||||
unsigned outGridW = CHROMASHIFT( m_uiFaceWidth, ch > 0 ? m_pcOutputFrame->getChromaWidthRatio() : 0 );
|
||||
unsigned outGridH = CHROMASHIFT( m_uiFaceHeight, ch > 0 ? m_pcOutputFrame->getChromaHeightRatio() : 0 );
|
||||
|
||||
Mat outputFrame;
|
||||
m_pcOutputFrame->toMat( outputFrame, true, false, ch );
|
||||
|
||||
for( int face = 0; face < m_cOutputFPSStruct.numFaces; face++ )
|
||||
{
|
||||
ClpFaceProperty outFp = m_cOutputFPSStruct.faces[face];
|
||||
Mat outputFace( outGridW * outFp.ratio / 100, outGridH * outFp.ratio / 100, CV_8UC1 );
|
||||
Rect outRect( Point( outFp.x * outGridW, outFp.y * outGridH ), outputFace.size() );
|
||||
|
||||
int inFace = face;
|
||||
for( int i = 0; i < m_cInputFPSStruct.numFaces; i++ )
|
||||
{
|
||||
if( m_cInputFPSStruct.faces[i].id == outFp.id )
|
||||
{
|
||||
inFace = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ClpFaceProperty inFp = m_cInputFPSStruct.faces[inFace];
|
||||
Mat inputFace( inGridW * inFp.ratio / 100, inGridH * inFp.ratio / 100, CV_8UC1 );
|
||||
Rect inRect( Point( inFp.x * inGridW, inFp.y * inGridH ), inputFace.size() );
|
||||
inputFrame( inRect ).copyTo( inputFace );
|
||||
|
||||
cv::resize( inputFace, outputFace, outputFace.size(), 0, 0, cv::INTER_LANCZOS4 );
|
||||
|
||||
outputFace.copyTo( outputFrame( outRect ) );
|
||||
}
|
||||
m_pcOutputFrame->fromMat( outputFrame, ch );
|
||||
}
|
||||
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void ThreeSixtyDynamicDownsampling::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyDynamicDownsampling.h
|
||||
*/
|
||||
|
||||
#ifndef __ThreeSixtyDynamicDownsampling_H__
|
||||
#define __ThreeSixtyDynamicDownsampling_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
|
||||
struct ClpFaceProperty
|
||||
{
|
||||
unsigned id;
|
||||
unsigned x;
|
||||
unsigned y;
|
||||
int rot;
|
||||
unsigned ratio;
|
||||
};
|
||||
struct ClpVideoFPStruct
|
||||
{
|
||||
unsigned rows;
|
||||
unsigned cols;
|
||||
int numFaces;
|
||||
ClpFaceProperty faces[60];
|
||||
};
|
||||
|
||||
class ThreeSixtyDynamicDownsampling : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyDynamicDownsampling )
|
||||
|
||||
private:
|
||||
ClpString m_arrayInputDefinitionString;
|
||||
ClpString m_arrayOutputDefinitionString;
|
||||
ClpVideoFPStruct m_cInputFPSStruct;
|
||||
ClpVideoFPStruct m_cOutputFPSStruct;
|
||||
unsigned m_uiFaceWidth;
|
||||
unsigned m_uiFaceHeight;
|
||||
|
||||
public:
|
||||
ThreeSixtyDynamicDownsampling();
|
||||
virtual ~ThreeSixtyDynamicDownsampling() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __ThreeSixtyDynamicDownsampling_H__
|
||||
@@ -0,0 +1,257 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyNxN.cpp
|
||||
* \brief Downsampling ERP to NxN
|
||||
*/
|
||||
|
||||
#include "ThreeSixtyNxN.h"
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include "lib/LibMemory.h"
|
||||
//#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/photo.hpp>
|
||||
|
||||
//using cv::InputArray;
|
||||
//using cv::OutputArray;
|
||||
using cv::Rect;
|
||||
using cv::Scalar;
|
||||
using cv::Size;
|
||||
|
||||
ThreeSixtyNxN::ThreeSixtyNxN()
|
||||
{
|
||||
/* Module Definition */
|
||||
m_iModuleAPI = CLP_MODULE_API_2;
|
||||
m_iModuleType = CLP_FRAME_PROCESSING_MODULE;
|
||||
m_pchModuleCategory = "360Video";
|
||||
m_pchModuleName = "ThreeSixtyNxN";
|
||||
m_pchModuleLongName = "ERP to NxN";
|
||||
m_pchModuleTooltip = "Downsampling ERP to NxN";
|
||||
m_uiNumberOfFrames = 1;
|
||||
m_uiModuleRequirements = CLP_MODULE_REQUIRES_SKIP_WHILE_PLAY |
|
||||
CLP_MODULE_REQUIRES_OPTIONS;
|
||||
|
||||
m_cModuleOptions.addOptions() /**/
|
||||
( "Downsampling", m_uiDownsampling, "ERP to NxN (0 for up, 1 for down and 2 for recon) [1]" ) /**/
|
||||
;
|
||||
|
||||
m_uiDownsampling = 1;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
|
||||
bool ThreeSixtyNxN::create( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
_BASIC_MODULE_API_2_CHECK_
|
||||
m_uiDownsampling = m_uiDownsampling > 2 ? 1 : m_uiDownsampling;
|
||||
if( m_uiDownsampling == 0 )
|
||||
{
|
||||
m_pcOutputFrame = new CalypFrame( 2 * apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcOutputFrame = new CalypFrame( apcFrameList[0]->getHeight(), apcFrameList[0]->getHeight(), apcFrameList[0]->getPelFormat(), apcFrameList[0]->getBitsPel() );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define WIDTH_TRIM_START_POINT 0.0
|
||||
#define WIDTH_FINAL 1.0
|
||||
|
||||
//#define CLAMP8BITS( in ) ( uint8_t )( ( in > 255 ? 255 : in < 0 ? 0 : in ) + 0.5 )
|
||||
#define CLAMP_RANGE( X, MIN, MAX ) ( ( X ) < MIN ? MIN : ( ( X ) > MAX ? MAX : X ) )
|
||||
#define CIRCULAR( a, b ) ( ( ( a < 0 ? b : 0 ) + ( a % b ) ) % b )
|
||||
#define PI 3.14159265358979323846264338327950288419716939937510
|
||||
#define s60 0.8660254037844386467637231707529361834714026269051
|
||||
#define s45 0.7071067811865475244008443621048490392848359376884
|
||||
|
||||
//interpolação Lanczos3 360
|
||||
static inline ClpPel interpol_lanczos3( ClpPel* image, double x, int N, int max_value )
|
||||
{
|
||||
static const double cs[][2] = {
|
||||
{ 1, 0 },
|
||||
{ -0.5, -s60 },
|
||||
{ -0.5, s60 },
|
||||
{ 1, 0 },
|
||||
{ -0.5, -s60 },
|
||||
{ -0.5, s60 },
|
||||
};
|
||||
|
||||
double sum_coeffs = 0, sum = 0, coeffs[6];
|
||||
int x_int = floor( x );
|
||||
ClpPel xx[6];
|
||||
x -= x_int;
|
||||
bool n0 = x > 0;
|
||||
xx[2] = *( image + CIRCULAR( x_int, N ) );
|
||||
if( !n0 )
|
||||
return xx[2];
|
||||
xx[3] = *( image + CIRCULAR( x_int + n0, N ) );
|
||||
xx[1] = *( image + CIRCULAR( x_int - 1, N ) );
|
||||
xx[4] = *( image + CIRCULAR( x_int + n0 + 1, N ) );
|
||||
xx[0] = *( image + CIRCULAR( x_int - 2, N ) );
|
||||
xx[5] = *( image + CIRCULAR( x_int + n0 + 2, N ) );
|
||||
|
||||
double aux = -2 - x, s_aux = sin( aux * PI / 3 ), c_aux = cos( aux * PI / 3 );
|
||||
|
||||
for( int i = 0; i < 6; i++ )
|
||||
sum_coeffs += coeffs[i] = ( cs[i][0] * s_aux + cs[i][1] * c_aux ) / ( i - 2 - x ) / ( i - 2 - x );
|
||||
|
||||
for( int i = 0; i < 6; i++ )
|
||||
sum += xx[i] * coeffs[i] / sum_coeffs;
|
||||
|
||||
return CLAMP_RANGE( sum, 0, max_value );
|
||||
}
|
||||
|
||||
//interpolação cúbica 360
|
||||
static inline ClpPel interpol_cub( ClpPel* image, double x, int N, int max_value )
|
||||
{
|
||||
int x_int = floor( x );
|
||||
x -= x_int;
|
||||
bool n0 = x > 0;
|
||||
ClpPel x1 = *( image + CIRCULAR( x_int, N ) );
|
||||
if( !n0 )
|
||||
return x1;
|
||||
ClpPel x2 = *( image + CIRCULAR( x_int + n0, N ) );
|
||||
ClpPel x0 = *( image + CIRCULAR( x_int - 1, N ) );
|
||||
ClpPel x3 = *( image + CIRCULAR( x_int + n0 + 1, N ) );
|
||||
|
||||
ClpPel out = CLAMP_RANGE( x1 - x * ( x0 - x2 + x * ( 2 * x1 - 2 * x0 - x2 + x3 + x * ( x0 - x1 + x2 - x3 ) ) ), 0, max_value ); //cubic
|
||||
return out;
|
||||
}
|
||||
|
||||
void ThreeSixtyNxN::downsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
{
|
||||
for( unsigned ch = 0; ch < m_pcOutputFrame->getNumberChannels(); ch++ )
|
||||
{
|
||||
int max_value = ( 1 << m_pcOutputFrame->getBitsPel() ) - 1;
|
||||
int N = pcInputFrame->getHeight( ch );
|
||||
ClpPel* in = &pcInputFrame->getPelBufferYUV()[ch][0][0];
|
||||
ClpPel* out = &m_pcOutputFrame->getPelBufferYUV()[ch][0][0];
|
||||
|
||||
unsigned long nn = N * N;
|
||||
int n_2 = N / 2;
|
||||
int n1 = N - 1;
|
||||
double dist_y;
|
||||
double dist_x;
|
||||
double novo_x;
|
||||
double novo_y;
|
||||
double tx_x;
|
||||
ClpPel* tx_y;
|
||||
ClpPel* rx;
|
||||
bool valida;
|
||||
|
||||
for( int y = 0; y < N; y++ )
|
||||
{
|
||||
for( int x = 0; x < N; x++ )
|
||||
{
|
||||
dist_y = ( abs( y * 2 - n1 ) - 1 ) / 2;
|
||||
dist_x = ( abs( x * 2 - n1 ) - 1 ) / 2;
|
||||
valida = ( n_2 - dist_x - dist_y - 1 ) >= 0;
|
||||
|
||||
novo_y = ( valida ? y : ( y < n_2 ? dist_x : n1 - dist_x ) ) * 2;
|
||||
novo_x = ( valida ? x : ( x < n_2 ? -dist_y + x * 2 : n1 + dist_y - ( n1 - x ) * 2 ) ) - n_2 + 1;
|
||||
|
||||
tx_x = ( N / ( N - fabs( novo_y - n1 ) ) ) * novo_x + n1;
|
||||
tx_y = (int)novo_y * N + in;
|
||||
rx = x + y * N + out;
|
||||
|
||||
*( rx ) = interpol_lanczos3( tx_y, tx_x, N * 2, max_value );
|
||||
//*( rx ) = interpol_cub( tx_y, tx_x, N * 2, max_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ThreeSixtyNxN::upsamplingOperation( const CalypFrame* pcInputFrame )
|
||||
{
|
||||
for( unsigned ch = 0; ch < m_pcOutputFrame->getNumberChannels(); ch++ )
|
||||
{
|
||||
int max_value = ( 1 << m_pcOutputFrame->getBitsPel() ) - 1;
|
||||
int N = pcInputFrame->getHeight( ch );
|
||||
ClpPel* in = &pcInputFrame->getPelBufferYUV()[ch][0][0];
|
||||
ClpPel* out = &m_pcOutputFrame->getPelBufferYUV()[ch][0][0];
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int n2 = 2 * N;
|
||||
double dist_y;
|
||||
double dist_x;
|
||||
double dist_Lj;
|
||||
double novo_x;
|
||||
double novo_y;
|
||||
double Lj;
|
||||
double Dj;
|
||||
double tx;
|
||||
ClpPel* rx;
|
||||
ClpPel* linhaY;
|
||||
|
||||
getMem1D( &linhaY, n2 );
|
||||
|
||||
for( y = 0; y < N; y++ )
|
||||
{
|
||||
Lj = ( N - abs( 2 * y - N + 1 ) ) * 2;
|
||||
Dj = n2 / Lj;
|
||||
|
||||
for( x = 0; x < Lj; x++ )
|
||||
{
|
||||
dist_x = x - Lj / 2;
|
||||
dist_y = ( N - abs( 2 * y - N + 1 ) - 1 ) / 2;
|
||||
dist_Lj = ( Lj - abs( 2 * x - Lj + 1 ) - 1 ) / 2;
|
||||
|
||||
novo_x = ( dist_x > dist_y ? dist_y : ( dist_x + 1 < -dist_y ? -dist_y - 1 : dist_x ) ) + N / 2;
|
||||
novo_y = abs( dist_x ) > dist_y ? ( y < N / 2 ? dist_Lj : N - dist_Lj - 1 ) : y;
|
||||
|
||||
*( linhaY + x ) = *( in + (int)novo_x + (int)novo_y * N );
|
||||
}
|
||||
|
||||
for( x = 0; x < n2; x++ )
|
||||
{
|
||||
tx = ( x + 1 ) / Dj - 1;
|
||||
rx = x + y * n2 + out;
|
||||
|
||||
*( rx ) = interpol_lanczos3( linhaY, tx, Lj, max_value );
|
||||
}
|
||||
}
|
||||
freeMem1D( linhaY );
|
||||
}
|
||||
}
|
||||
|
||||
CalypFrame* ThreeSixtyNxN::process( std::vector<CalypFrame*> apcFrameList )
|
||||
{
|
||||
m_pcOutputFrame->reset();
|
||||
if( m_uiDownsampling == 1 || m_uiDownsampling == 2 )
|
||||
{
|
||||
downsamplingOperation( apcFrameList[0] );
|
||||
}
|
||||
if( m_uiDownsampling == 0 || m_uiDownsampling == 2 )
|
||||
{
|
||||
upsamplingOperation( m_uiDownsampling == 2 ? m_pcOutputFrame : apcFrameList[0] );
|
||||
}
|
||||
return m_pcOutputFrame;
|
||||
}
|
||||
|
||||
void ThreeSixtyNxN::destroy()
|
||||
{
|
||||
if( m_pcOutputFrame )
|
||||
delete m_pcOutputFrame;
|
||||
m_pcOutputFrame = NULL;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* This file is a part of Calyp project
|
||||
* Copyright (C) 2014-2019 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 ThreeSixtyNxN.h
|
||||
* \brief Downsampling ERP to NxN
|
||||
*/
|
||||
|
||||
#ifndef __THREESIXTYNXN_H__
|
||||
#define __THREESIXTYNXN_H__
|
||||
|
||||
// CalypLib
|
||||
#include "lib/CalypModuleIf.h"
|
||||
#include "opencv2/core/mat.hpp"
|
||||
#include "opencv2/core/types.hpp"
|
||||
|
||||
using cv::Mat;
|
||||
using cv::Mat_;
|
||||
using cv::Point;
|
||||
|
||||
class ThreeSixtyNxN : public CalypModuleIf
|
||||
{
|
||||
REGISTER_CLASS_FACTORY( ThreeSixtyNxN )
|
||||
private:
|
||||
unsigned m_uiDownsampling;
|
||||
void downsamplingOperation( const CalypFrame* pcInputFrame );
|
||||
void upsamplingOperation( const CalypFrame* pcInputFrame );
|
||||
|
||||
public:
|
||||
ThreeSixtyNxN();
|
||||
virtual ~ThreeSixtyNxN() {}
|
||||
bool create( std::vector<CalypFrame*> apcFrameList );
|
||||
CalypFrame* process( std::vector<CalypFrame*> apcFrameList );
|
||||
void destroy();
|
||||
};
|
||||
|
||||
#endif // __THREESIXTYNXN_H__
|
||||
@@ -44,6 +44,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "CalypToolsCmdParser.h"
|
||||
#include "lib/CalypFrame.h"
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __CALYPTOOLSCMDPARSER_H__
|
||||
#define __CALYPTOOLSCMDPARSER_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "config.h"
|
||||
#include "lib/CalypOptions.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user