71 ui32 bit_depth,
bool is_signed,
ui32 width) = NULL;
81 ui32 bit_depth,
bool is_signed,
ui32 width) = NULL;
100 (
const float *r,
const float *g,
const float *b,
101 float *y,
float *cb,
float *cr,
ui32 repeat) = NULL;
105 (
const float *y,
const float *cb,
const float *cr,
106 float *r,
float *g,
float *b,
ui32 repeat) = NULL;
111 static std::once_flag colour_transform_functions_init_flag;
112 std::call_once(colour_transform_functions_init_flag, []() {
113#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
126 #ifndef OJPH_DISABLE_SIMD
128 #if (defined(OJPH_ARCH_X86_64) || defined(OJPH_ARCH_I386))
130 #ifndef OJPH_DISABLE_SSE
138 #ifndef OJPH_DISABLE_SSE2
154 #ifndef OJPH_DISABLE_AVX
162 #ifndef OJPH_DISABLE_AVX2
178 #elif defined(OJPH_ARCH_ARM)
208 float(2.0*
double(ALPHA_BF)*(1.0-
double(ALPHA_BF))/
double(ALPHA_GF));
210 float(2.0*
double(ALPHA_RF)*(1.0-
double(ALPHA_RF))/
double(ALPHA_GF));
216#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
228 const si32 *sp = src_line->
i32 + src_line_offset;
229 si32 *dp = dst_line->
i32 + dst_line_offset;
231 for (
ui32 i = width; i > 0; --i)
236 const si32 *sp = src_line->
i32 + src_line_offset;
237 si64 *dp = dst_line->
i64 + dst_line_offset;
238 for (
ui32 i = width; i > 0; --i)
239 *dp++ = *sp++ + shift;
246 const si64 *sp = src_line->
i64 + src_line_offset;
247 si32 *dp = dst_line->
i32 + dst_line_offset;
248 for (
ui32 i = width; i > 0; --i)
249 *dp++ = (
si32)(*sp++ + shift);
263 const si32 *sp = src_line->
i32 + src_line_offset;
264 si32 *dp = dst_line->
i32 + dst_line_offset;
266 for (
ui32 i = width; i > 0; --i) {
267 const si32 v = *sp++;
268 *dp++ = v >= 0 ? v : (- v - s);
273 const si32 *sp = src_line->
i32 + src_line_offset;
274 si64 *dp = dst_line->
i64 + dst_line_offset;
275 for (
ui32 i = width; i > 0; --i) {
276 const si64 v = *sp++;
277 *dp++ = v >= 0 ? v : (- v - shift);
285 const si64 *sp = src_line->
i64 + src_line_offset;
286 si32 *dp = dst_line->
i32 + dst_line_offset;
287 for (
ui32 i = width; i > 0; --i) {
288 const si64 v = *sp++;
289 *dp++ = (
si32)(v >= 0 ? v : (- v - shift));
296 template<
bool NLT_TYPE3>
300 ui32 bit_depth,
bool is_signed,
ui32 width)
307 assert(bit_depth <= 32);
308 const float* sp = src_line->
f32;
309 si32* dp = dst_line->
i32 + dst_line_offset;
316 si32 neg_limit = (
si32)INT_MIN >> (32 - bit_depth);
317 float mul = (float)(1ull << bit_depth);
318 float fl_up_lim = -(float)neg_limit;
319 float fl_low_lim = (float)neg_limit;
320 si32 s32_up_lim = INT_MAX >> (32 - bit_depth);
321 si32 s32_low_lim = INT_MIN >> (32 - bit_depth);
325 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
326 for (
int i = (
int)width; i > 0; --i) {
327 float t = *sp++ * mul;
329 v = t >= fl_low_lim ? v : s32_low_lim;
330 v = t < fl_up_lim ? v : s32_up_lim;
332 v = (v >= 0) ? v : (- v - bias);
338 const si32 half = (
si32)(1ULL << (bit_depth - 1));
339 for (
int i = (
int)width; i > 0; --i) {
340 float t = *sp++ * mul;
342 v = t >= fl_low_lim ? v : s32_low_lim;
343 v = t < fl_up_lim ? v : s32_up_lim;
352 ui32 bit_depth,
bool is_signed,
ui32 width)
355 dst_line_offset, bit_depth, is_signed, width);
361 ui32 bit_depth,
bool is_signed,
ui32 width)
364 dst_line_offset, bit_depth, is_signed, width);
368 template<
bool NLT_TYPE3>
372 ui32 bit_depth,
bool is_signed,
ui32 width)
379 assert(bit_depth <= 32);
380 float mul = (float)(1.0 / (
double)(1ULL << bit_depth));
382 const si32* sp = src_line->
i32 + src_line_offset;
383 float* dp = dst_line->
f32;
386 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
387 for (
int i = (
int)width; i > 0; --i) {
390 v = (v >= 0) ? v : (- v - bias);
391 *dp++ = (float)v * mul;
396 const si32 half = (
si32)(1ULL << (bit_depth - 1));
397 for (
int i = (
int)width; i > 0; --i) {
400 *dp++ = (float)v * mul;
408 ui32 bit_depth,
bool is_signed,
ui32 width)
411 dst_line, bit_depth, is_signed, width);
417 ui32 bit_depth,
bool is_signed,
ui32 width)
420 dst_line, bit_depth, is_signed, width);
445 for (
ui32 i = repeat; i > 0; --i)
447 si32 rr = *rp++, gg = *gp++, bb = *bp++;
448 *yp++ = (rr + (gg << 1) + bb) >> 2;
463 for (
ui32 i = repeat; i > 0; --i)
465 si64 rr = *rp++, gg = *gp++, bb = *bp++;
466 *yp++ = (rr + (gg << 1) + bb) >> 2;
495 for (
ui32 i = repeat; i > 0; --i)
497 si32 yy = *yp++, cbb = *cbp++, crr = *crp++;
498 si32 gg = yy - ((cbb + crr) >> 2);
514 for (
ui32 i = repeat; i > 0; --i)
516 si64 yy = *yp++, cbb = *cbp++, crr = *crp++;
517 si64 gg = yy - ((cbb + crr) >> 2);
518 *rp++ = (
si32)(crr + gg);
520 *bp++ = (
si32)(cbb + gg);
527 float *y,
float *cb,
float *cr,
ui32 repeat)
529 for (
ui32 i = repeat; i > 0; --i)
541 float *r,
float *g,
float *b,
ui32 repeat)
543 for (
ui32 i = repeat; i > 0; --i)
void sse2_rct_backward(const line_buf *y, const line_buf *cb, const line_buf *cr, line_buf *r, line_buf *g, line_buf *b, ui32 repeat)
void sse2_irv_convert_to_integer(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void wasm_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
void wasm_irv_convert_to_integer(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void avx2_rct_forward(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void wasm_rev_convert_nlt_type3(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void(* rct_forward)(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void wasm_irv_convert_to_integer_nlt_type3(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void sse2_irv_convert_to_float_nlt_type3(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void sse2_irv_convert_to_integer_nlt_type3(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void(* ict_forward)(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void gen_rct_forward(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void avx_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void gen_rct_backward(const line_buf *y, const line_buf *cb, const line_buf *cr, line_buf *r, line_buf *g, line_buf *b, ui32 repeat)
void sse2_rev_convert(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void(* irv_convert_to_integer_nlt_type3)(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void(* irv_convert_to_float)(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void avx2_rct_backward(const line_buf *y, const line_buf *cb, const line_buf *cr, line_buf *r, line_buf *g, line_buf *b, ui32 repeat)
void gen_irv_convert_to_integer(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void(* ict_backward)(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
void sse2_rev_convert_nlt_type3(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void wasm_rev_convert(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void gen_irv_convert_to_float(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void init_colour_transform_functions()
void gen_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void(* rct_backward)(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void gen_rev_convert_nlt_type3(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void(* irv_convert_to_integer)(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void wasm_irv_convert_to_float_nlt_type3(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void sse_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void avx2_rev_convert(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void avx2_irv_convert_to_float(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void wasm_rct_backward(const line_buf *y, const line_buf *cb, const line_buf *cr, line_buf *r, line_buf *g, line_buf *b, ui32 repeat)
static void local_gen_irv_convert_to_integer(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void wasm_rct_forward(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void wasm_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void avx2_rev_convert_nlt_type3(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void gen_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
void gen_rev_convert(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void avx2_irv_convert_to_integer(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void avx2_irv_convert_to_float_nlt_type3(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void(* irv_convert_to_float_nlt_type3)(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void sse2_rct_forward(const line_buf *r, const line_buf *g, const line_buf *b, line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
void avx_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
void avx2_irv_convert_to_integer_nlt_type3(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void(* rev_convert_nlt_type3)(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void wasm_irv_convert_to_float(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void(* rev_convert)(const line_buf *src_line, const ui32 src_line_offset, line_buf *dst_line, const ui32 dst_line_offset, si64 shift, ui32 width)
void sse_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
void gen_irv_convert_to_integer_nlt_type3(const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset, ui32 bit_depth, bool is_signed, ui32 width)
void gen_irv_convert_to_float_nlt_type3(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
static void local_gen_irv_convert_to_float(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
void sse2_irv_convert_to_float(const line_buf *src_line, ui32 src_line_offset, line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width)
static si32 ojph_round(float val)
OJPH_EXPORT int get_cpu_ext_level()
static const float GAMMA_CR2R
static const float BETA_CbF
static const float GAMMA_CB2B
static const float ALPHA_RF
static const float GAMMA_CB2G
static const float GAMMA_CR2G
static const float ALPHA_BF
static const float BETA_CrF
static const float ALPHA_GF