OpenJPH Open-source implementation of JPEG2000 Part-15

Loading...
Searching...
No Matches
ojph_colour.cpp
Go to the documentation of this file.
1//***************************************************************************/
2// This software is released under the 2-Clause BSD license, included
3// below.
4//
5// Copyright (c) 2019, Aous Naman
6// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
7// Copyright (c) 2019, The University of New South Wales, Australia
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//***************************************************************************/
32// This file is part of the OpenJPH software implementation.
33// File: ojph_colour.cpp
34// Author: Aous Naman
35// Date: 28 August 2019
36//***************************************************************************/
37
38#include <cmath>
39#include <climits>
40#include <mutex>
41
42#include "ojph_defs.h"
43#include "ojph_arch.h"
44#include "ojph_mem.h"
45#include "ojph_colour.h"
46#include "ojph_colour_local.h"
47
48 namespace ojph {
49
50 // defined elsewhere
51 class line_buf;
52
53 namespace local {
54
56 void (*rev_convert)
57 (const line_buf *src_line, const ui32 src_line_offset,
58 line_buf *dst_line, const ui32 dst_line_offset,
59 si64 shift, ui32 width) = NULL;
60
62 void (*rev_convert_nlt_type3)
63 (const line_buf *src_line, const ui32 src_line_offset,
64 line_buf *dst_line, const ui32 dst_line_offset,
65 si64 shift, ui32 width) = NULL;
66
67
69 void (*irv_convert_to_integer) (
70 const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset,
71 ui32 bit_depth, bool is_signed, ui32 width) = NULL;
72
74 void (*irv_convert_to_float) (
75 const line_buf *src_line, ui32 src_line_offset,
76 line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width) = NULL;
77
79 void (*irv_convert_to_integer_nlt_type3) (
80 const line_buf *src_line, line_buf *dst_line, ui32 dst_line_offset,
81 ui32 bit_depth, bool is_signed, ui32 width) = NULL;
82
84 void (*irv_convert_to_float_nlt_type3) (
85 const line_buf *src_line, ui32 src_line_offset,
86 line_buf *dst_line, ui32 bit_depth, bool is_signed, ui32 width) = NULL;
87
89 void (*rct_forward)
90 (const line_buf* r, const line_buf* g, const line_buf* b,
91 line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;
92
94 void (*rct_backward)
95 (const line_buf* r, const line_buf* g, const line_buf* b,
96 line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;
97
99 void (*ict_forward)
100 (const float *r, const float *g, const float *b,
101 float *y, float *cb, float *cr, ui32 repeat) = NULL;
102
104 void (*ict_backward)
105 (const float *y, const float *cb, const float *cr,
106 float *r, float *g, float *b, ui32 repeat) = NULL;
107
109 void init_colour_transform_functions()
110 {
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)
114
115 rev_convert = gen_rev_convert;
116 rev_convert_nlt_type3 = gen_rev_convert_nlt_type3;
117 irv_convert_to_integer = gen_irv_convert_to_integer;
118 irv_convert_to_float = gen_irv_convert_to_float;
119 irv_convert_to_integer_nlt_type3 = gen_irv_convert_to_integer_nlt_type3;
120 irv_convert_to_float_nlt_type3 = gen_irv_convert_to_float_nlt_type3;
121 rct_forward = gen_rct_forward;
122 rct_backward = gen_rct_backward;
123 ict_forward = gen_ict_forward;
124 ict_backward = gen_ict_backward;
125
126 #ifndef OJPH_DISABLE_SIMD
127
128 #if (defined(OJPH_ARCH_X86_64) || defined(OJPH_ARCH_I386))
129
130 #ifndef OJPH_DISABLE_SSE
131 if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_SSE)
132 {
133 ict_forward = sse_ict_forward;
134 ict_backward = sse_ict_backward;
135 }
136 #endif // !OJPH_DISABLE_SSE
137
138 #ifndef OJPH_DISABLE_SSE2
139 if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_SSE2)
140 {
141 rev_convert = sse2_rev_convert;
142 rev_convert_nlt_type3 = sse2_rev_convert_nlt_type3;
143 irv_convert_to_integer = sse2_irv_convert_to_integer;
144 irv_convert_to_float = sse2_irv_convert_to_float;
145 irv_convert_to_integer_nlt_type3 =
146 sse2_irv_convert_to_integer_nlt_type3;
147 irv_convert_to_float_nlt_type3 =
148 sse2_irv_convert_to_float_nlt_type3;
149 rct_forward = sse2_rct_forward;
150 rct_backward = sse2_rct_backward;
151 }
152 #endif // !OJPH_DISABLE_SSE2
153
154 #ifndef OJPH_DISABLE_AVX
155 if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_AVX)
156 {
157 ict_forward = avx_ict_forward;
158 ict_backward = avx_ict_backward;
159 }
160 #endif // !OJPH_DISABLE_AVX
161
162 #ifndef OJPH_DISABLE_AVX2
163 if (get_cpu_ext_level() >= X86_CPU_EXT_LEVEL_AVX2)
164 {
165 rev_convert = avx2_rev_convert;
166 rev_convert_nlt_type3 = avx2_rev_convert_nlt_type3;
167 irv_convert_to_integer = avx2_irv_convert_to_integer;
168 irv_convert_to_float = avx2_irv_convert_to_float;
169 irv_convert_to_integer_nlt_type3 =
170 avx2_irv_convert_to_integer_nlt_type3;
171 irv_convert_to_float_nlt_type3 =
172 avx2_irv_convert_to_float_nlt_type3;
173 rct_forward = avx2_rct_forward;
174 rct_backward = avx2_rct_backward;
175 }
176 #endif // !OJPH_DISABLE_AVX2
177
178 #elif defined(OJPH_ARCH_ARM)
179
180 #elif defined(OJPH_ARCH_PPC64LE)
181
182 if (get_cpu_ext_level() >= PPC_CPU_EXT_LEVEL_ARCH_3_00)
183 {
184 // 128-bit VSX kernels; see ojph_simd_vsx.h
185 rev_convert = vsx_rev_convert;
186 rev_convert_nlt_type3 = vsx_rev_convert_nlt_type3;
187 irv_convert_to_integer = vsx_irv_convert_to_integer;
188 irv_convert_to_float = vsx_irv_convert_to_float;
189 irv_convert_to_integer_nlt_type3 =
190 vsx_irv_convert_to_integer_nlt_type3;
191 irv_convert_to_float_nlt_type3 =
192 vsx_irv_convert_to_float_nlt_type3;
193 rct_forward = vsx_rct_forward;
194 rct_backward = vsx_rct_backward;
195 ict_forward = vsx_ict_forward;
196 ict_backward = vsx_ict_backward;
197 }
198
199 #endif // !(defined(OJPH_ARCH_X86_64) || defined(OJPH_ARCH_I386))
200
201 #endif // !OJPH_DISABLE_SIMD
202
203#else // OJPH_ENABLE_WASM_SIMD
204
205 rev_convert = wasm_rev_convert;
206 rev_convert_nlt_type3 = wasm_rev_convert_nlt_type3;
207 irv_convert_to_integer = wasm_irv_convert_to_integer;
208 irv_convert_to_float = wasm_irv_convert_to_float;
209 irv_convert_to_integer_nlt_type3 = wasm_irv_convert_to_integer_nlt_type3;
210 irv_convert_to_float_nlt_type3 = wasm_irv_convert_to_float_nlt_type3;
211 rct_forward = wasm_rct_forward;
212 rct_backward = wasm_rct_backward;
213 ict_forward = wasm_ict_forward;
214 ict_backward = wasm_ict_backward;
215
216#endif // !OJPH_ENABLE_WASM_SIMD
217 });
218 }
219
221 const float CT_CNST::ALPHA_RF = 0.299f;
222 const float CT_CNST::ALPHA_GF = 0.587f;
223 const float CT_CNST::ALPHA_BF = 0.114f;
224 const float CT_CNST::BETA_CbF = float(0.5/(1-double(CT_CNST::ALPHA_BF)));
225 const float CT_CNST::BETA_CrF = float(0.5/(1-double(CT_CNST::ALPHA_RF)));
226 const float CT_CNST::GAMMA_CB2G =
227 float(2.0*double(ALPHA_BF)*(1.0-double(ALPHA_BF))/double(ALPHA_GF));
228 const float CT_CNST::GAMMA_CR2G =
229 float(2.0*double(ALPHA_RF)*(1.0-double(ALPHA_RF))/double(ALPHA_GF));
230 const float CT_CNST::GAMMA_CB2B = float(2.0 * (1.0 - double(ALPHA_BF)));
231 const float CT_CNST::GAMMA_CR2R = float(2.0 * (1.0 - double(ALPHA_RF)));
232
234
235#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
236
238 void gen_rev_convert(
239 const line_buf *src_line, const ui32 src_line_offset,
240 line_buf *dst_line, const ui32 dst_line_offset,
241 si64 shift, ui32 width)
242 {
243 if (src_line->flags & line_buf::LFT_32BIT)
244 {
245 if (dst_line->flags & line_buf::LFT_32BIT)
246 {
247 const si32 *sp = src_line->i32 + src_line_offset;
248 si32 *dp = dst_line->i32 + dst_line_offset;
249 si32 s = (si32)shift;
250 for (ui32 i = width; i > 0; --i)
251 *dp++ = *sp++ + s;
252 }
253 else
254 {
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;
259 }
260 }
261 else
262 {
263 assert(src_line->flags & line_buf::LFT_64BIT);
264 assert(dst_line->flags & line_buf::LFT_32BIT);
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);
269 }
270 }
271
273 void gen_rev_convert_nlt_type3(
274 const line_buf *src_line, const ui32 src_line_offset,
275 line_buf *dst_line, const ui32 dst_line_offset,
276 si64 shift, ui32 width)
277 {
278 if (src_line->flags & line_buf::LFT_32BIT)
279 {
280 if (dst_line->flags & line_buf::LFT_32BIT)
281 {
282 const si32 *sp = src_line->i32 + src_line_offset;
283 si32 *dp = dst_line->i32 + dst_line_offset;
284 si32 s = (si32)shift;
285 for (ui32 i = width; i > 0; --i) {
286 const si32 v = *sp++;
287 *dp++ = v >= 0 ? v : (- v - s);
288 }
289 }
290 else
291 {
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);
297 }
298 }
299 }
300 else
301 {
302 assert(src_line->flags & line_buf::LFT_64BIT);
303 assert(dst_line->flags & line_buf::LFT_32BIT);
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));
309 }
310 }
311 }
312
313
315 template<bool NLT_TYPE3>
316 static inline
317 void local_gen_irv_convert_to_integer(const line_buf *src_line,
318 line_buf *dst_line, ui32 dst_line_offset,
319 ui32 bit_depth, bool is_signed, ui32 width)
320 {
321 assert((src_line->flags & line_buf::LFT_32BIT) &&
322 (src_line->flags & line_buf::LFT_INTEGER) == 0 &&
323 (dst_line->flags & line_buf::LFT_32BIT) &&
324 (dst_line->flags & line_buf::LFT_INTEGER));
325
326 assert(bit_depth <= 32);
327 const float* sp = src_line->f32;
328 si32* dp = dst_line->i32 + dst_line_offset;
329 // There is the possibility that converting to integer will
330 // exceed the dynamic range of 32bit integer; therefore, care must be
331 // exercised.
332 // We look if the floating point number is outside the half-closed
333 // interval [-0.5f, 0.5f). If so, we limit the resulting integer
334 // to the maximum/minimum that number supports.
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; // val < upper
338 float fl_low_lim = (float)neg_limit; // val >= lower
339 si32 s32_up_lim = INT_MAX >> (32 - bit_depth);
340 si32 s32_low_lim = INT_MIN >> (32 - bit_depth);
341
342 if (is_signed)
343 {
344 const si32 bias = (si32)((1ULL << (bit_depth - 1)) + 1);
345 for (int i = (int)width; i > 0; --i) {
346 float t = *sp++ * mul;
347 si32 v = ojph_round(t);
348 v = t >= fl_low_lim ? v : s32_low_lim;
349 v = t < fl_up_lim ? v : s32_up_lim;
350 if (NLT_TYPE3)
351 v = (v >= 0) ? v : (- v - bias);
352 *dp++ = v;
353 }
354 }
355 else
356 {
357 const si32 half = (si32)(1ULL << (bit_depth - 1));
358 for (int i = (int)width; i > 0; --i) {
359 float t = *sp++ * mul;
360 si32 v = ojph_round(t);
361 v = t >= fl_low_lim ? v : s32_low_lim;
362 v = t < fl_up_lim ? v : s32_up_lim;
363 *dp++ = v + half;
364 }
365 }
366 }
367
369 void gen_irv_convert_to_integer(const line_buf *src_line,
370 line_buf *dst_line, ui32 dst_line_offset,
371 ui32 bit_depth, bool is_signed, ui32 width)
372 {
373 local_gen_irv_convert_to_integer<false>(src_line, dst_line,
374 dst_line_offset, bit_depth, is_signed, width);
375 }
376
378 void gen_irv_convert_to_integer_nlt_type3(const line_buf *src_line,
379 line_buf *dst_line, ui32 dst_line_offset,
380 ui32 bit_depth, bool is_signed, ui32 width)
381 {
382 local_gen_irv_convert_to_integer<true>(src_line, dst_line,
383 dst_line_offset, bit_depth, is_signed, width);
384 }
385
387 template<bool NLT_TYPE3>
388 static inline
389 void local_gen_irv_convert_to_float(const line_buf *src_line,
390 ui32 src_line_offset, line_buf *dst_line,
391 ui32 bit_depth, bool is_signed, ui32 width)
392 {
393 assert((src_line->flags & line_buf::LFT_32BIT) &&
394 (src_line->flags & line_buf::LFT_INTEGER) &&
395 (dst_line->flags & line_buf::LFT_32BIT) &&
396 (dst_line->flags & line_buf::LFT_INTEGER) == 0);
397
398 assert(bit_depth <= 32);
399 float mul = (float)(1.0 / (double)(1ULL << bit_depth));
400
401 const si32* sp = src_line->i32 + src_line_offset;
402 float* dp = dst_line->f32;
403 if (is_signed)
404 {
405 const si32 bias = (si32)((1ULL << (bit_depth - 1)) + 1);
406 for (int i = (int)width; i > 0; --i) {
407 si32 v = *sp++;
408 if (NLT_TYPE3)
409 v = (v >= 0) ? v : (- v - bias);
410 *dp++ = (float)v * mul;
411 }
412 }
413 else
414 {
415 const si32 half = (si32)(1ULL << (bit_depth - 1));
416 for (int i = (int)width; i > 0; --i) {
417 si32 v = *sp++;
418 v -= half;
419 *dp++ = (float)v * mul;
420 }
421 }
422 }
423
425 void gen_irv_convert_to_float(const line_buf *src_line,
426 ui32 src_line_offset, line_buf *dst_line,
427 ui32 bit_depth, bool is_signed, ui32 width)
428 {
429 local_gen_irv_convert_to_float<false>(src_line, src_line_offset,
430 dst_line, bit_depth, is_signed, width);
431 }
432
434 void gen_irv_convert_to_float_nlt_type3(const line_buf *src_line,
435 ui32 src_line_offset, line_buf *dst_line,
436 ui32 bit_depth, bool is_signed, ui32 width)
437 {
438 local_gen_irv_convert_to_float<true>(src_line, src_line_offset,
439 dst_line, bit_depth, is_signed, width);
440 }
441
443 void gen_rct_forward(
444 const line_buf *r, const line_buf *g, const line_buf *b,
445 line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat)
446 {
447 assert((y->flags & line_buf::LFT_INTEGER) &&
448 (cb->flags & line_buf::LFT_INTEGER) &&
449 (cr->flags & line_buf::LFT_INTEGER) &&
450 (r->flags & line_buf::LFT_INTEGER) &&
451 (g->flags & line_buf::LFT_INTEGER) &&
452 (b->flags & line_buf::LFT_INTEGER));
453
454 if (y->flags & line_buf::LFT_32BIT)
455 {
456 assert((y->flags & line_buf::LFT_32BIT) &&
457 (cb->flags & line_buf::LFT_32BIT) &&
458 (cr->flags & line_buf::LFT_32BIT) &&
459 (r->flags & line_buf::LFT_32BIT) &&
460 (g->flags & line_buf::LFT_32BIT) &&
461 (b->flags & line_buf::LFT_32BIT));
462 const si32 *rp = r->i32, * gp = g->i32, * bp = b->i32;
463 si32 *yp = y->i32, * cbp = cb->i32, * crp = cr->i32;
464 for (ui32 i = repeat; i > 0; --i)
465 {
466 si32 rr = *rp++, gg = *gp++, bb = *bp++;
467 *yp++ = (rr + (gg << 1) + bb) >> 2;
468 *cbp++ = (bb - gg);
469 *crp++ = (rr - gg);
470 }
471 }
472 else
473 {
474 assert((y->flags & line_buf::LFT_64BIT) &&
475 (cb->flags & line_buf::LFT_64BIT) &&
476 (cr->flags & line_buf::LFT_64BIT) &&
477 (r->flags & line_buf::LFT_32BIT) &&
478 (g->flags & line_buf::LFT_32BIT) &&
479 (b->flags & line_buf::LFT_32BIT));
480 const si32 *rp = r->i32, *gp = g->i32, *bp = b->i32;
481 si64 *yp = y->i64, *cbp = cb->i64, *crp = cr->i64;
482 for (ui32 i = repeat; i > 0; --i)
483 {
484 si64 rr = *rp++, gg = *gp++, bb = *bp++;
485 *yp++ = (rr + (gg << 1) + bb) >> 2;
486 *cbp++ = (bb - gg);
487 *crp++ = (rr - gg);
488 }
489 }
490 }
491
493 void gen_rct_backward(
494 const line_buf *y, const line_buf *cb, const line_buf *cr,
495 line_buf *r, line_buf *g, line_buf *b, ui32 repeat)
496 {
497 assert((y->flags & line_buf::LFT_INTEGER) &&
498 (cb->flags & line_buf::LFT_INTEGER) &&
499 (cr->flags & line_buf::LFT_INTEGER) &&
500 (r->flags & line_buf::LFT_INTEGER) &&
501 (g->flags & line_buf::LFT_INTEGER) &&
502 (b->flags & line_buf::LFT_INTEGER));
503
504 if (y->flags & line_buf::LFT_32BIT)
505 {
506 assert((y->flags & line_buf::LFT_32BIT) &&
507 (cb->flags & line_buf::LFT_32BIT) &&
508 (cr->flags & line_buf::LFT_32BIT) &&
509 (r->flags & line_buf::LFT_32BIT) &&
510 (g->flags & line_buf::LFT_32BIT) &&
511 (b->flags & line_buf::LFT_32BIT));
512 const si32 *yp = y->i32, *cbp = cb->i32, *crp = cr->i32;
513 si32 *rp = r->i32, *gp = g->i32, *bp = b->i32;
514 for (ui32 i = repeat; i > 0; --i)
515 {
516 si32 yy = *yp++, cbb = *cbp++, crr = *crp++;
517 si32 gg = yy - ((cbb + crr) >> 2);
518 *rp++ = crr + gg;
519 *gp++ = gg;
520 *bp++ = cbb + gg;
521 }
522 }
523 else
524 {
525 assert((y->flags & line_buf::LFT_64BIT) &&
526 (cb->flags & line_buf::LFT_64BIT) &&
527 (cr->flags & line_buf::LFT_64BIT) &&
528 (r->flags & line_buf::LFT_32BIT) &&
529 (g->flags & line_buf::LFT_32BIT) &&
530 (b->flags & line_buf::LFT_32BIT));
531 const si64 *yp = y->i64, *cbp = cb->i64, *crp = cr->i64;
532 si32 *rp = r->i32, *gp = g->i32, *bp = b->i32;
533 for (ui32 i = repeat; i > 0; --i)
534 {
535 si64 yy = *yp++, cbb = *cbp++, crr = *crp++;
536 si64 gg = yy - ((cbb + crr) >> 2);
537 *rp++ = (si32)(crr + gg);
538 *gp++ = (si32)gg;
539 *bp++ = (si32)(cbb + gg);
540 }
541 }
542 }
543
545 void gen_ict_forward(const float *r, const float *g, const float *b,
546 float *y, float *cb, float *cr, ui32 repeat)
547 {
548 for (ui32 i = repeat; i > 0; --i)
549 {
550 *y = CT_CNST::ALPHA_RF * *r
551 + CT_CNST::ALPHA_GF * *g++
552 + CT_CNST::ALPHA_BF * *b;
553 *cb++ = CT_CNST::BETA_CbF * (*b++ - *y);
554 *cr++ = CT_CNST::BETA_CrF * (*r++ - *y++);
555 }
556 }
557
559 void gen_ict_backward(const float *y, const float *cb, const float *cr,
560 float *r, float *g, float *b, ui32 repeat)
561 {
562 for (ui32 i = repeat; i > 0; --i)
563 {
564 *g++ = *y - CT_CNST::GAMMA_CR2G * *cr - CT_CNST::GAMMA_CB2G * *cb;
565 *r++ = *y + CT_CNST::GAMMA_CR2R * *cr++;
566 *b++ = *y++ + CT_CNST::GAMMA_CB2B * *cb++;
567 }
568 }
569
570#endif // !OJPH_ENABLE_WASM_SIMD
571
572 }
573}
ojph::line_buf
Definition ojph_mem.h:161
ojph::line_buf::LFT_INTEGER
@ LFT_INTEGER
Definition ojph_mem.h:170
ojph::line_buf::LFT_32BIT
@ LFT_32BIT
Definition ojph_mem.h:168
ojph::line_buf::LFT_64BIT
@ LFT_64BIT
Definition ojph_mem.h:169
ojph::line_buf::i64
si64 * i64
Definition ojph_mem.h:186
ojph::line_buf::flags
ui32 flags
Definition ojph_mem.h:183
ojph::line_buf::f32
float * f32
Definition ojph_mem.h:187
ojph::line_buf::i32
si32 * i32
Definition ojph_mem.h:185
ojph::local
Definition ojph_bitbuffer_read.h:53
ojph::local::sse2_rct_backward
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)
ojph::local::sse2_irv_convert_to_integer
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)
ojph::local::wasm_ict_backward
void wasm_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
Definition ojph_colour_wasm.cpp:655
ojph::local::wasm_irv_convert_to_integer
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)
Definition ojph_colour_wasm.cpp:366
ojph::local::avx2_rct_forward
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)
ojph::local::wasm_rev_convert_nlt_type3
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)
Definition ojph_colour_wasm.cpp:126
ojph::local::vsx_irv_convert_to_float_nlt_type3
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)
Definition ojph_colour_vsx.cpp:432
ojph::local::rct_forward
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)
Definition ojph_colour.cpp:90
ojph::local::wasm_irv_convert_to_integer_nlt_type3
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)
Definition ojph_colour_wasm.cpp:375
ojph::local::sse2_irv_convert_to_float_nlt_type3
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)
ojph::local::sse2_irv_convert_to_integer_nlt_type3
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)
ojph::local::ict_forward
void(* ict_forward)(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
Definition ojph_colour.cpp:100
ojph::local::gen_rct_forward
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)
Definition ojph_colour.cpp:443
ojph::local::avx_ict_forward
void avx_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
ojph::local::gen_rct_backward
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)
Definition ojph_colour.cpp:493
ojph::local::sse2_rev_convert
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)
ojph::local::vsx_ict_backward
void vsx_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
Definition ojph_colour_vsx.cpp:645
ojph::local::irv_convert_to_integer_nlt_type3
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)
Definition ojph_colour.cpp:79
ojph::local::irv_convert_to_float
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)
Definition ojph_colour.cpp:74
ojph::local::avx2_rct_backward
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)
ojph::local::gen_irv_convert_to_integer
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)
Definition ojph_colour.cpp:369
ojph::local::ict_backward
void(* ict_backward)(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
Definition ojph_colour.cpp:105
ojph::local::sse2_rev_convert_nlt_type3
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)
ojph::local::wasm_rev_convert
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)
Definition ojph_colour_wasm.cpp:65
ojph::local::gen_irv_convert_to_float
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)
Definition ojph_colour.cpp:425
ojph::local::vsx_rev_convert_nlt_type3
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)
Definition ojph_colour_vsx.cpp:125
ojph::local::vsx_ict_forward
void vsx_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
Definition ojph_colour_vsx.cpp:620
ojph::local::init_colour_transform_functions
void init_colour_transform_functions()
Definition ojph_colour.cpp:109
ojph::local::vsx_rct_backward
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)
Definition ojph_colour_vsx.cpp:531
ojph::local::gen_ict_forward
void gen_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
Definition ojph_colour.cpp:545
ojph::local::rct_backward
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)
Definition ojph_colour.cpp:95
ojph::local::vsx_rev_convert
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)
Definition ojph_colour_vsx.cpp:64
ojph::local::gen_rev_convert_nlt_type3
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)
Definition ojph_colour.cpp:273
ojph::local::irv_convert_to_integer
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)
Definition ojph_colour.cpp:69
ojph::local::wasm_irv_convert_to_float_nlt_type3
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)
Definition ojph_colour_wasm.cpp:442
ojph::local::sse_ict_forward
void sse_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
ojph::local::avx2_rev_convert
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)
ojph::local::avx2_irv_convert_to_float
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)
ojph::local::wasm_rct_backward
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)
Definition ojph_colour_wasm.cpp:541
ojph::local::local_gen_irv_convert_to_integer
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)
Definition ojph_colour.cpp:317
ojph::local::wasm_rct_forward
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)
Definition ojph_colour_wasm.cpp:451
ojph::local::wasm_ict_forward
void wasm_ict_forward(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
Definition ojph_colour_wasm.cpp:630
ojph::local::avx2_rev_convert_nlt_type3
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)
ojph::local::gen_ict_backward
void gen_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
Definition ojph_colour.cpp:559
ojph::local::gen_rev_convert
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)
Definition ojph_colour.cpp:238
ojph::local::vsx_rct_forward
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)
Definition ojph_colour_vsx.cpp:441
ojph::local::avx2_irv_convert_to_integer
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)
ojph::local::avx2_irv_convert_to_float_nlt_type3
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)
ojph::local::irv_convert_to_float_nlt_type3
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)
Definition ojph_colour.cpp:84
ojph::local::sse2_rct_forward
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)
ojph::local::avx_ict_backward
void avx_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
ojph::local::avx2_irv_convert_to_integer_nlt_type3
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)
ojph::local::vsx_irv_convert_to_float
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)
Definition ojph_colour_vsx.cpp:423
ojph::local::vsx_irv_convert_to_integer
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)
Definition ojph_colour_vsx.cpp:356
ojph::local::rev_convert_nlt_type3
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)
Definition ojph_colour.cpp:63
ojph::local::wasm_irv_convert_to_float
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)
Definition ojph_colour_wasm.cpp:433
ojph::local::rev_convert
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)
Definition ojph_colour.cpp:57
ojph::local::vsx_irv_convert_to_integer_nlt_type3
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)
Definition ojph_colour_vsx.cpp:365
ojph::local::sse_ict_backward
void sse_ict_backward(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
ojph::local::gen_irv_convert_to_integer_nlt_type3
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)
Definition ojph_colour.cpp:378
ojph::local::gen_irv_convert_to_float_nlt_type3
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)
Definition ojph_colour.cpp:434
ojph::local::local_gen_irv_convert_to_float
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)
Definition ojph_colour.cpp:389
ojph::local::sse2_irv_convert_to_float
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)
ojph
Definition ojph_img_io.h:52
ojph::si64
int64_t si64
Definition ojph_defs.h:57
ojph::ojph_round
static si32 ojph_round(float val)
Definition ojph_arch.h:317
ojph::PPC_CPU_EXT_LEVEL_ARCH_3_00
@ PPC_CPU_EXT_LEVEL_ARCH_3_00
Definition ojph_arch.h:180
ojph::get_cpu_ext_level
OJPH_EXPORT int get_cpu_ext_level()
Definition ojph_arch.cpp:296
ojph::si32
int32_t si32
Definition ojph_defs.h:55
ojph::ui32
uint32_t ui32
Definition ojph_defs.h:54
ojph::X86_CPU_EXT_LEVEL_AVX2
@ X86_CPU_EXT_LEVEL_AVX2
Definition ojph_arch.h:163
ojph::X86_CPU_EXT_LEVEL_AVX
@ X86_CPU_EXT_LEVEL_AVX
Definition ojph_arch.h:162
ojph::X86_CPU_EXT_LEVEL_SSE2
@ X86_CPU_EXT_LEVEL_SSE2
Definition ojph_arch.h:157
ojph::X86_CPU_EXT_LEVEL_SSE
@ X86_CPU_EXT_LEVEL_SSE
Definition ojph_arch.h:156
ojph_arch.h
ojph_colour.h
ojph_colour_local.h
ojph_defs.h
ojph_mem.h
ojph::local::CT_CNST::GAMMA_CR2R
static const float GAMMA_CR2R
Definition ojph_colour_local.h:53
ojph::local::CT_CNST::BETA_CbF
static const float BETA_CbF
Definition ojph_colour_local.h:51
ojph::local::CT_CNST::GAMMA_CB2B
static const float GAMMA_CB2B
Definition ojph_colour_local.h:54
ojph::local::CT_CNST::ALPHA_RF
static const float ALPHA_RF
Definition ojph_colour_local.h:48
ojph::local::CT_CNST::GAMMA_CB2G
static const float GAMMA_CB2G
Definition ojph_colour_local.h:56
ojph::local::CT_CNST::GAMMA_CR2G
static const float GAMMA_CR2G
Definition ojph_colour_local.h:55
ojph::local::CT_CNST::ALPHA_BF
static const float ALPHA_BF
Definition ojph_colour_local.h:50
ojph::local::CT_CNST::BETA_CrF
static const float BETA_CrF
Definition ojph_colour_local.h:52
ojph::local::CT_CNST::ALPHA_GF
static const float ALPHA_GF
Definition ojph_colour_local.h:49