From b1cd2b44a136c1c00776dd088d49187d976b4914 Mon Sep 17 00:00:00 2001 From: Samuel Li Date: Sun, 14 Jan 2024 22:49:14 -0700 Subject: [PATCH] Add experimental SPECK1D_FLT (#229) * add SPECK1D_FLT class, also apply a simple patch to cli11 * minor --- CMakeLists.txt | 1 + cli11.patch | 4 ++++ include/SPECK1D_FLT.h | 19 +++++++++++++++ src/CMakeLists.txt | 18 +++++++------- src/SPECK1D_FLT.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 cli11.patch create mode 100644 include/SPECK1D_FLT.h create mode 100644 src/SPECK1D_FLT.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index efb1caa6..a1357b62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,7 @@ if( BUILD_CLI_UTILITIES ) FetchContent_Declare( cli11 GIT_REPOSITORY https://github.com/CLIUtils/CLI11 GIT_TAG 291c58789c031208f08f4f261a858b5b7083e8e2 # v2.3.2 + PATCH_COMMAND patch -N CMakeLists.txt < ${CMAKE_SOURCE_DIR}/cli11.patch || true ) FetchContent_MakeAvailable(cli11) diff --git a/cli11.patch b/cli11.patch new file mode 100644 index 00000000..3edf079b --- /dev/null +++ b/cli11.patch @@ -0,0 +1,4 @@ +1c1 +< cmake_minimum_required(VERSION 3.4) +--- +> cmake_minimum_required(VERSION 3.14) diff --git a/include/SPECK1D_FLT.h b/include/SPECK1D_FLT.h new file mode 100644 index 00000000..dd1d92d6 --- /dev/null +++ b/include/SPECK1D_FLT.h @@ -0,0 +1,19 @@ +#ifndef SPECK1D_FLT_H +#define SPECK1D_FLT_H + +#include "SPECK_FLT.h" + +namespace sperr { + +class SPECK1D_FLT : public SPECK_FLT { + protected: + void m_instantiate_encoder() override; + void m_instantiate_decoder() override; + + void m_wavelet_xform() override; + void m_inverse_wavelet_xform(bool) override; +}; + +}; // namespace sperr + +#endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e1f271e..9b9e380f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,17 +6,18 @@ add_library( SPERR CDF97.cpp SPECK_INT.cpp SPECK3D_INT.cpp - SPECK2D_INT.cpp - SPECK1D_INT.cpp SPECK3D_INT_ENC.cpp - SPECK2D_INT_ENC.cpp - SPECK1D_INT_ENC.cpp SPECK3D_INT_DEC.cpp + SPECK2D_INT.cpp + SPECK2D_INT_ENC.cpp SPECK2D_INT_DEC.cpp + SPECK1D_INT.cpp + SPECK1D_INT_ENC.cpp SPECK1D_INT_DEC.cpp SPECK_FLT.cpp SPECK3D_FLT.cpp SPECK2D_FLT.cpp + SPECK1D_FLT.cpp SPERR3D_OMP_C.cpp SPERR3D_OMP_D.cpp SPERR3D_Stream_Tools.cpp @@ -56,17 +57,18 @@ include/Conditioner.h;\ include/CDF97.h;\ include/SPECK_INT.h;\ include/SPECK3D_INT.h;\ -include/SPECK2D_INT.h;\ -include/SPECK1D_INT.h;\ include/SPECK3D_INT_ENC.h;\ -include/SPECK2D_INT_ENC.h;\ -include/SPECK1D_INT_ENC.h;\ include/SPECK3D_INT_DEC.h;\ +include/SPECK2D_INT.h;\ +include/SPECK2D_INT_ENC.h;\ include/SPECK2D_INT_DEC.h;\ +include/SPECK1D_INT.h;\ +include/SPECK1D_INT_ENC.h;\ include/SPECK1D_INT_DEC.h;\ include/SPECK_FLT.h;\ include/SPECK3D_FLT.h;\ include/SPECK2D_FLT.h;\ +include/SPECK1D_FLT.h;\ include/SPERR3D_OMP_C.h;\ include/SPERR3D_Stream_Tools.h;\ include/SPERR3D_OMP_D.h;\ diff --git a/src/SPECK1D_FLT.cpp b/src/SPECK1D_FLT.cpp new file mode 100644 index 00000000..155dbc84 --- /dev/null +++ b/src/SPECK1D_FLT.cpp @@ -0,0 +1,56 @@ +#include "SPECK1D_FLT.h" +#include "SPECK1D_INT_DEC.h" +#include "SPECK1D_INT_ENC.h" + +void sperr::SPECK1D_FLT::m_instantiate_encoder() +{ + switch (m_uint_flag) { + case UINTType::UINT8: + if (m_encoder.index() != 0 || std::get<0>(m_encoder) == nullptr) + m_encoder = std::make_unique>(); + break; + case UINTType::UINT16: + if (m_encoder.index() != 1 || std::get<1>(m_encoder) == nullptr) + m_encoder = std::make_unique>(); + break; + case UINTType::UINT32: + if (m_encoder.index() != 2 || std::get<2>(m_encoder) == nullptr) + m_encoder = std::make_unique>(); + break; + default: + if (m_encoder.index() != 3 || std::get<3>(m_encoder) == nullptr) + m_encoder = std::make_unique>(); + } +} + +void sperr::SPECK1D_FLT::m_instantiate_decoder() +{ + switch (m_uint_flag) { + case UINTType::UINT8: + if (m_decoder.index() != 0 || std::get<0>(m_decoder) == nullptr) + m_decoder = std::make_unique>(); + break; + case UINTType::UINT16: + if (m_decoder.index() != 1 || std::get<1>(m_decoder) == nullptr) + m_decoder = std::make_unique>(); + break; + case UINTType::UINT32: + if (m_decoder.index() != 2 || std::get<2>(m_decoder) == nullptr) + m_decoder = std::make_unique>(); + break; + default: + if (m_decoder.index() != 3 || std::get<3>(m_decoder) == nullptr) + m_decoder = std::make_unique>(); + } +} + +void sperr::SPECK1D_FLT::m_wavelet_xform() +{ + m_cdf.dwt1d(); +} + +void sperr::SPECK1D_FLT::m_inverse_wavelet_xform(bool multi_res) +{ + // Unfortunately, there's no multi-resolution support for 1D arrays... + m_cdf.idwt1d(); +}