Skip to content

Commit

Permalink
Add experimental SPECK1D_FLT (#229)
Browse files Browse the repository at this point in the history
* add SPECK1D_FLT class, also apply a simple patch to cli11

* minor
  • Loading branch information
shaomeng authored Jan 15, 2024
1 parent a981a5d commit b1cd2b4
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 8 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions cli11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1c1
< cmake_minimum_required(VERSION 3.4)
---
> cmake_minimum_required(VERSION 3.14)
19 changes: 19 additions & 0 deletions include/SPECK1D_FLT.h
Original file line number Diff line number Diff line change
@@ -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
18 changes: 10 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;\
Expand Down
56 changes: 56 additions & 0 deletions src/SPECK1D_FLT.cpp
Original file line number Diff line number Diff line change
@@ -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<SPECK1D_INT_ENC<uint8_t>>();
break;
case UINTType::UINT16:
if (m_encoder.index() != 1 || std::get<1>(m_encoder) == nullptr)
m_encoder = std::make_unique<SPECK1D_INT_ENC<uint16_t>>();
break;
case UINTType::UINT32:
if (m_encoder.index() != 2 || std::get<2>(m_encoder) == nullptr)
m_encoder = std::make_unique<SPECK1D_INT_ENC<uint32_t>>();
break;
default:
if (m_encoder.index() != 3 || std::get<3>(m_encoder) == nullptr)
m_encoder = std::make_unique<SPECK1D_INT_ENC<uint64_t>>();
}
}

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<SPECK1D_INT_DEC<uint8_t>>();
break;
case UINTType::UINT16:
if (m_decoder.index() != 1 || std::get<1>(m_decoder) == nullptr)
m_decoder = std::make_unique<SPECK1D_INT_DEC<uint16_t>>();
break;
case UINTType::UINT32:
if (m_decoder.index() != 2 || std::get<2>(m_decoder) == nullptr)
m_decoder = std::make_unique<SPECK1D_INT_DEC<uint32_t>>();
break;
default:
if (m_decoder.index() != 3 || std::get<3>(m_decoder) == nullptr)
m_decoder = std::make_unique<SPECK1D_INT_DEC<uint64_t>>();
}
}

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();
}

0 comments on commit b1cd2b4

Please sign in to comment.