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)
180 #elif defined(OJPH_ARCH_PPC64LE)
227 float(2.0*
double(ALPHA_BF)*(1.0-
double(ALPHA_BF))/
double(ALPHA_GF));
229 float(2.0*
double(ALPHA_RF)*(1.0-
double(ALPHA_RF))/
double(ALPHA_GF));
235#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
247 const si32 *sp = src_line->
i32 + src_line_offset;
248 si32 *dp = dst_line->
i32 + dst_line_offset;
250 for (
ui32 i = width; i > 0; --i)
255 const si32 *sp = src_line->
i32 + src_line_offset;
256 si64 *dp = dst_line->
i64 + dst_line_offset;
257 for (
ui32 i = width; i > 0; --i)
258 *dp++ = *sp++ + shift;
265 const si64 *sp = src_line->
i64 + src_line_offset;
266 si32 *dp = dst_line->
i32 + dst_line_offset;
267 for (
ui32 i = width; i > 0; --i)
268 *dp++ = (
si32)(*sp++ + shift);
282 const si32 *sp = src_line->
i32 + src_line_offset;
283 si32 *dp = dst_line->
i32 + dst_line_offset;
285 for (
ui32 i = width; i > 0; --i) {
286 const si32 v = *sp++;
287 *dp++ = v >= 0 ? v : (- v - s);
292 const si32 *sp = src_line->
i32 + src_line_offset;
293 si64 *dp = dst_line->
i64 + dst_line_offset;
294 for (
ui32 i = width; i > 0; --i) {
295 const si64 v = *sp++;
296 *dp++ = v >= 0 ? v : (- v - shift);
304 const si64 *sp = src_line->
i64 + src_line_offset;
305 si32 *dp = dst_line->
i32 + dst_line_offset;
306 for (
ui32 i = width; i > 0; --i) {
307 const si64 v = *sp++;
308 *dp++ = (
si32)(v >= 0 ? v : (- v - shift));
315 template<
bool NLT_TYPE3>
319 ui32 bit_depth,
bool is_signed,
ui32 width)
326 assert(bit_depth <= 32);
327 const float* sp = src_line->
f32;
328 si32* dp = dst_line->
i32 + dst_line_offset;
335 si32 neg_limit = (
si32)INT_MIN >> (32 - bit_depth);
336 float mul = (float)(1ull << bit_depth);
337 float fl_up_lim = -(float)neg_limit;
338 float fl_low_lim = (float)neg_limit;
339 si32 s32_up_lim = INT_MAX >> (32 - bit_depth);
340 si32 s32_low_lim = INT_MIN >> (32 - bit_depth);
344 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
345 for (
int i = (
int)width; i > 0; --i) {
346 float t = *sp++ * mul;
348 v = t >= fl_low_lim ? v : s32_low_lim;
349 v = t < fl_up_lim ? v : s32_up_lim;
351 v = (v >= 0) ? v : (- v - bias);
357 const si32 half = (
si32)(1ULL << (bit_depth - 1));
358 for (
int i = (
int)width; i > 0; --i) {
359 float t = *sp++ * mul;
361 v = t >= fl_low_lim ? v : s32_low_lim;
362 v = t < fl_up_lim ? v : s32_up_lim;
371 ui32 bit_depth,
bool is_signed,
ui32 width)
374 dst_line_offset, bit_depth, is_signed, width);
380 ui32 bit_depth,
bool is_signed,
ui32 width)
383 dst_line_offset, bit_depth, is_signed, width);
387 template<
bool NLT_TYPE3>
391 ui32 bit_depth,
bool is_signed,
ui32 width)
398 assert(bit_depth <= 32);
399 float mul = (float)(1.0 / (
double)(1ULL << bit_depth));
401 const si32* sp = src_line->
i32 + src_line_offset;
402 float* dp = dst_line->
f32;
405 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
406 for (
int i = (
int)width; i > 0; --i) {
409 v = (v >= 0) ? v : (- v - bias);
410 *dp++ = (float)v * mul;
415 const si32 half = (
si32)(1ULL << (bit_depth - 1));
416 for (
int i = (
int)width; i > 0; --i) {
419 *dp++ = (float)v * mul;
427 ui32 bit_depth,
bool is_signed,
ui32 width)
430 dst_line, bit_depth, is_signed, width);
436 ui32 bit_depth,
bool is_signed,
ui32 width)
439 dst_line, bit_depth, is_signed, width);
464 for (
ui32 i = repeat; i > 0; --i)
466 si32 rr = *rp++, gg = *gp++, bb = *bp++;
467 *yp++ = (rr + (gg << 1) + bb) >> 2;
482 for (
ui32 i = repeat; i > 0; --i)
484 si64 rr = *rp++, gg = *gp++, bb = *bp++;
485 *yp++ = (rr + (gg << 1) + bb) >> 2;
514 for (
ui32 i = repeat; i > 0; --i)
516 si32 yy = *yp++, cbb = *cbp++, crr = *crp++;
517 si32 gg = yy - ((cbb + crr) >> 2);
533 for (
ui32 i = repeat; i > 0; --i)
535 si64 yy = *yp++, cbb = *cbp++, crr = *crp++;
536 si64 gg = yy - ((cbb + crr) >> 2);
537 *rp++ = (
si32)(crr + gg);
539 *bp++ = (
si32)(cbb + gg);
546 float *y,
float *cb,
float *cr,
ui32 repeat)
548 for (
ui32 i = repeat; i > 0; --i)
560 float *r,
float *g,
float *b,
ui32 repeat)
562 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 vsx_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(* 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 vsx_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
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 vsx_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 vsx_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void init_colour_transform_functions()
void vsx_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_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 vsx_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_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 vsx_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 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 vsx_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 vsx_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(* 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 vsx_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 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)
@ PPC_CPU_EXT_LEVEL_ARCH_3_00
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