Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/core/coding/ojph_block_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <cstring>
#include <cstdint>
#include <climits>
#include <mutex>

#include "ojph_mem.h"
#include "ojph_arch.h"
Expand Down Expand Up @@ -253,17 +254,16 @@ namespace ojph {
return true;
}

/////////////////////////////////////////////////////////////////////////
static bool tables_initialized = false;

/////////////////////////////////////////////////////////////////////////
bool initialize_block_encoder_tables() {
if (!tables_initialized) {
static bool tables_initialized = false;
static std::once_flag tables_initialized_flag;
std::call_once(tables_initialized_flag, []() {
memset(vlc_tbl0, 0, 2048 * sizeof(ui16));
memset(vlc_tbl1, 0, 2048 * sizeof(ui16));
tables_initialized = vlc_init_tables();
tables_initialized = tables_initialized && uvlc_init_tables();
}
});
return tables_initialized;
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/coding/ojph_block_encoder_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <cstdint>
#include <climits>
#include <immintrin.h>
#include <mutex>

#include "ojph_mem.h"
#include "ojph_arch.h"
Expand Down Expand Up @@ -220,17 +221,16 @@ namespace ojph {
return true;
}

/////////////////////////////////////////////////////////////////////////
static bool tables_initialized = false;

/////////////////////////////////////////////////////////////////////////
bool initialize_block_encoder_tables_avx2() {
if (!tables_initialized) {
static bool tables_initialized = false;
static std::once_flag tables_initialized_flag;
std::call_once(tables_initialized_flag, []() {
memset(vlc_tbl0, 0, 2048 * sizeof(ui32));
memset(vlc_tbl1, 0, 2048 * sizeof(ui32));
tables_initialized = vlc_init_tables();
tables_initialized = tables_initialized && uvlc_init_tables();
}
});
return tables_initialized;
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/coding/ojph_block_encoder_avx512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <cstdint>
#include <climits>
#include <immintrin.h>
#include <mutex>

#include "ojph_mem.h"
#include "ojph_block_encoder.h"
Expand Down Expand Up @@ -219,17 +220,16 @@ namespace ojph {
return true;
}

/////////////////////////////////////////////////////////////////////////
static bool tables_initialized = false;

/////////////////////////////////////////////////////////////////////////
bool initialize_block_encoder_tables_avx512() {
if (!tables_initialized) {
static bool tables_initialized = false;
static std::once_flag tables_initialized_flag;
std::call_once(tables_initialized_flag, []() {
memset(vlc_tbl0, 0, 2048 * sizeof(ui32));
memset(vlc_tbl1, 0, 2048 * sizeof(ui32));
tables_initialized = vlc_init_tables();
tables_initialized = tables_initialized && uvlc_init_tables();
}
});
return tables_initialized;
}

Expand Down
52 changes: 24 additions & 28 deletions src/core/transform/ojph_colour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <cmath>
#include <climits>
#include <mutex>

#include "ojph_defs.h"
#include "ojph_arch.h"
Expand Down Expand Up @@ -104,27 +105,23 @@ namespace ojph {
(const float *y, const float *cb, const float *cr,
float *r, float *g, float *b, ui32 repeat) = NULL;

//////////////////////////////////////////////////////////////////////////
static bool colour_transform_functions_initialized = false;

//////////////////////////////////////////////////////////////////////////
void init_colour_transform_functions()
{
if (colour_transform_functions_initialized)
return;

static std::once_flag colour_transform_functions_init_flag;
std::call_once(colour_transform_functions_init_flag, []() {
#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)

rev_convert = gen_rev_convert;
rev_convert_nlt_type3 = gen_rev_convert_nlt_type3;
irv_convert_to_integer = gen_irv_convert_to_integer;
irv_convert_to_float = gen_irv_convert_to_float;
irv_convert_to_integer_nlt_type3 = gen_irv_convert_to_integer_nlt_type3;
irv_convert_to_float_nlt_type3 = gen_irv_convert_to_float_nlt_type3;
rct_forward = gen_rct_forward;
rct_backward = gen_rct_backward;
ict_forward = gen_ict_forward;
ict_backward = gen_ict_backward;
rev_convert = gen_rev_convert;
rev_convert_nlt_type3 = gen_rev_convert_nlt_type3;
irv_convert_to_integer = gen_irv_convert_to_integer;
irv_convert_to_float = gen_irv_convert_to_float;
irv_convert_to_integer_nlt_type3 = gen_irv_convert_to_integer_nlt_type3;
irv_convert_to_float_nlt_type3 = gen_irv_convert_to_float_nlt_type3;
rct_forward = gen_rct_forward;
rct_backward = gen_rct_backward;
ict_forward = gen_ict_forward;
ict_backward = gen_ict_backward;

#ifndef OJPH_DISABLE_SIMD

Expand Down Expand Up @@ -186,20 +183,19 @@ namespace ojph {

#else // OJPH_ENABLE_WASM_SIMD

rev_convert = wasm_rev_convert;
rev_convert_nlt_type3 = wasm_rev_convert_nlt_type3;
irv_convert_to_integer = wasm_irv_convert_to_integer;
irv_convert_to_float = wasm_irv_convert_to_float;
irv_convert_to_integer_nlt_type3 = wasm_irv_convert_to_integer_nlt_type3;
irv_convert_to_float_nlt_type3 = wasm_irv_convert_to_float_nlt_type3;
rct_forward = wasm_rct_forward;
rct_backward = wasm_rct_backward;
ict_forward = wasm_ict_forward;
ict_backward = wasm_ict_backward;
rev_convert = wasm_rev_convert;
rev_convert_nlt_type3 = wasm_rev_convert_nlt_type3;
irv_convert_to_integer = wasm_irv_convert_to_integer;
irv_convert_to_float = wasm_irv_convert_to_float;
irv_convert_to_integer_nlt_type3 = wasm_irv_convert_to_integer_nlt_type3;
irv_convert_to_float_nlt_type3 = wasm_irv_convert_to_float_nlt_type3;
rct_forward = wasm_rct_forward;
rct_backward = wasm_rct_backward;
ict_forward = wasm_ict_forward;
ict_backward = wasm_ict_backward;

#endif // !OJPH_ENABLE_WASM_SIMD

colour_transform_functions_initialized = true;
});
}

//////////////////////////////////////////////////////////////////////////
Expand Down
26 changes: 11 additions & 15 deletions src/core/transform/ojph_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
//***************************************************************************/

#include <cstdio>
#include <mutex>

#include "ojph_arch.h"
#include "ojph_mem.h"
Expand Down Expand Up @@ -93,25 +94,21 @@ namespace ojph {
(const param_atk* atk, const line_buf* dst, const line_buf* lsrc,
const line_buf* hsrc, ui32 width, bool even) = NULL;

////////////////////////////////////////////////////////////////////////////
static bool wavelet_transform_functions_initialized = false;

//////////////////////////////////////////////////////////////////////////
void init_wavelet_transform_functions()
{
if (wavelet_transform_functions_initialized)
return;

static std::once_flag wavelet_transform_functions_init_flag;
std::call_once(wavelet_transform_functions_init_flag, [](){
#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)

rev_vert_step = gen_rev_vert_step;
rev_horz_ana = gen_rev_horz_ana;
rev_horz_syn = gen_rev_horz_syn;
rev_vert_step = gen_rev_vert_step;
rev_horz_ana = gen_rev_horz_ana;
rev_horz_syn = gen_rev_horz_syn;

irv_vert_step = gen_irv_vert_step;
irv_vert_times_K = gen_irv_vert_times_K;
irv_horz_ana = gen_irv_horz_ana;
irv_horz_syn = gen_irv_horz_syn;
irv_vert_step = gen_irv_vert_step;
irv_vert_times_K = gen_irv_vert_times_K;
irv_horz_ana = gen_irv_horz_ana;
irv_horz_syn = gen_irv_horz_syn;

#ifndef OJPH_DISABLE_SIMD

Expand Down Expand Up @@ -185,8 +182,7 @@ namespace ojph {
irv_horz_ana = wasm_irv_horz_ana;
irv_horz_syn = wasm_irv_horz_syn;
#endif // !OJPH_ENABLE_WASM_SIMD

wavelet_transform_functions_initialized = true;
});
}

//////////////////////////////////////////////////////////////////////////
Expand Down
Loading