70 ui32 bit_depth,
bool is_signed,
ui32 width) = NULL;
80 ui32 bit_depth,
bool is_signed,
ui32 width) = NULL;
99 (
const float *r,
const float *g,
const float *b,
100 float *y,
float *cb,
float *cr,
ui32 repeat) = NULL;
104 (
const float *y,
const float *cb,
const float *cr,
105 float *r,
float *g,
float *b,
ui32 repeat) = NULL;
116#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
129 #ifndef OJPH_DISABLE_SIMD
131 #if (defined(OJPH_ARCH_X86_64) || defined(OJPH_ARCH_I386))
133 #ifndef OJPH_DISABLE_SSE
141 #ifndef OJPH_DISABLE_SSE2
157 #ifndef OJPH_DISABLE_AVX
165 #ifndef OJPH_DISABLE_AVX2
181 #elif defined(OJPH_ARCH_ARM)
212 float(2.0*
double(ALPHA_BF)*(1.0-
double(ALPHA_BF))/
double(ALPHA_GF));
214 float(2.0*
double(ALPHA_RF)*(1.0-
double(ALPHA_RF))/
double(ALPHA_GF));
220#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
232 const si32 *sp = src_line->
i32 + src_line_offset;
233 si32 *dp = dst_line->
i32 + dst_line_offset;
235 for (
ui32 i = width; i > 0; --i)
240 const si32 *sp = src_line->
i32 + src_line_offset;
241 si64 *dp = dst_line->
i64 + dst_line_offset;
242 for (
ui32 i = width; i > 0; --i)
243 *dp++ = *sp++ + shift;
250 const si64 *sp = src_line->
i64 + src_line_offset;
251 si32 *dp = dst_line->
i32 + dst_line_offset;
252 for (
ui32 i = width; i > 0; --i)
253 *dp++ = (
si32)(*sp++ + shift);
267 const si32 *sp = src_line->
i32 + src_line_offset;
268 si32 *dp = dst_line->
i32 + dst_line_offset;
270 for (
ui32 i = width; i > 0; --i) {
271 const si32 v = *sp++;
272 *dp++ = v >= 0 ? v : (- v - s);
277 const si32 *sp = src_line->
i32 + src_line_offset;
278 si64 *dp = dst_line->
i64 + dst_line_offset;
279 for (
ui32 i = width; i > 0; --i) {
280 const si64 v = *sp++;
281 *dp++ = v >= 0 ? v : (- v - shift);
289 const si64 *sp = src_line->
i64 + src_line_offset;
290 si32 *dp = dst_line->
i32 + dst_line_offset;
291 for (
ui32 i = width; i > 0; --i) {
292 const si64 v = *sp++;
293 *dp++ = (
si32)(v >= 0 ? v : (- v - shift));
300 template<
bool NLT_TYPE3>
304 ui32 bit_depth,
bool is_signed,
ui32 width)
311 assert(bit_depth <= 32);
312 const float* sp = src_line->
f32;
313 si32* dp = dst_line->
i32 + dst_line_offset;
320 si32 neg_limit = (
si32)INT_MIN >> (32 - bit_depth);
321 float mul = (float)(1ull << bit_depth);
322 float fl_up_lim = -(float)neg_limit;
323 float fl_low_lim = (float)neg_limit;
324 si32 s32_up_lim = INT_MAX >> (32 - bit_depth);
325 si32 s32_low_lim = INT_MIN >> (32 - bit_depth);
329 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
330 for (
int i = (
int)width; i > 0; --i) {
331 float t = *sp++ * mul;
333 v = t >= fl_low_lim ? v : s32_low_lim;
334 v = t < fl_up_lim ? v : s32_up_lim;
336 v = (v >= 0) ? v : (- v - bias);
342 const si32 half = (
si32)(1ULL << (bit_depth - 1));
343 for (
int i = (
int)width; i > 0; --i) {
344 float t = *sp++ * mul;
346 v = t >= fl_low_lim ? v : s32_low_lim;
347 v = t < fl_up_lim ? v : s32_up_lim;
356 ui32 bit_depth,
bool is_signed,
ui32 width)
358 local_gen_irv_convert_to_integer<false>(src_line, dst_line,
359 dst_line_offset, bit_depth, is_signed, width);
365 ui32 bit_depth,
bool is_signed,
ui32 width)
367 local_gen_irv_convert_to_integer<true>(src_line, dst_line,
368 dst_line_offset, bit_depth, is_signed, width);
372 template<
bool NLT_TYPE3>
376 ui32 bit_depth,
bool is_signed,
ui32 width)
383 assert(bit_depth <= 32);
384 float mul = (float)(1.0 / (
double)(1ULL << bit_depth));
386 const si32* sp = src_line->
i32 + src_line_offset;
387 float* dp = dst_line->
f32;
390 const si32 bias = (
si32)((1ULL << (bit_depth - 1)) + 1);
391 for (
int i = (
int)width; i > 0; --i) {
394 v = (v >= 0) ? v : (- v - bias);
395 *dp++ = (float)v * mul;
400 const si32 half = (
si32)(1ULL << (bit_depth - 1));
401 for (
int i = (
int)width; i > 0; --i) {
404 *dp++ = (float)v * mul;
412 ui32 bit_depth,
bool is_signed,
ui32 width)
414 local_gen_irv_convert_to_float<false>(src_line, src_line_offset,
415 dst_line, bit_depth, is_signed, width);
421 ui32 bit_depth,
bool is_signed,
ui32 width)
423 local_gen_irv_convert_to_float<true>(src_line, src_line_offset,
424 dst_line, bit_depth, is_signed, width);
449 for (
ui32 i = repeat; i > 0; --i)
451 si32 rr = *rp++, gg = *gp++, bb = *bp++;
452 *yp++ = (rr + (gg << 1) + bb) >> 2;
467 for (
ui32 i = repeat; i > 0; --i)
469 si64 rr = *rp++, gg = *gp++, bb = *bp++;
470 *yp++ = (rr + (gg << 1) + bb) >> 2;
499 for (
ui32 i = repeat; i > 0; --i)
501 si32 yy = *yp++, cbb = *cbp++, crr = *crp++;
502 si32 gg = yy - ((cbb + crr) >> 2);
518 for (
ui32 i = repeat; i > 0; --i)
520 si64 yy = *yp++, cbb = *cbp++, crr = *crp++;
521 si64 gg = yy - ((cbb + crr) >> 2);
522 *rp++ = (
si32)(crr + gg);
524 *bp++ = (
si32)(cbb + gg);
531 float *y,
float *cb,
float *cr,
ui32 repeat)
533 for (
ui32 i = repeat; i > 0; --i)
545 float *r,
float *g,
float *b,
ui32 repeat)
547 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)
static bool colour_transform_functions_initialized
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