From 4a3958f7462a6319519c05ec24c64f6ff460c058 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Fri, 13 Dec 2024 12:32:06 +1100 Subject: [PATCH 1/2] Makes all colour components involved in colour transform employ the same precision. --- src/core/codestream/ojph_params.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/codestream/ojph_params.cpp b/src/core/codestream/ojph_params.cpp index 40934cb..bbc5869 100644 --- a/src/core/codestream/ojph_params.cpp +++ b/src/core/codestream/ojph_params.cpp @@ -780,19 +780,26 @@ namespace ojph { ui32 param_cod::propose_precision(const param_siz* siz, ui32 comp_num) const { - bool employing_color_transform = is_employing_color_transform() ? 1 : 0; - bool reversible = atk->is_reversible(); + if (atk->is_reversible() == false) + return 32; + else + { + ui32 bit_depth = 0; + if (comp_num < 3 && is_employing_color_transform()) + { + for (int c = 0; c < 3; ++c) + bit_depth = ojph_max(bit_depth, siz->get_bit_depth(c)); + ++bit_depth; // colour transform needs one extra bit + } + else + bit_depth = siz->get_bit_depth(comp_num); - ui32 bit_depth = 32; - if (reversible) { - bit_depth = siz->get_bit_depth(comp_num); - bit_depth += comp_num < 3 ? employing_color_transform : 0; // 3 or 4 is how many extra bits are needed for the HH band at the // bottom most level of decomposition. bit_depth += get_num_decompositions() > 5 ? 4 : 3; - } - return bit_depth; + return bit_depth; + } } ////////////////////////////////////////////////////////////////////////// From 23633ba1bd14d2d0fee7d91d927262f7d47b3aa0 Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Fri, 13 Dec 2024 12:36:44 +1100 Subject: [PATCH 2/2] Fixes warning. --- src/core/codestream/ojph_params.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/codestream/ojph_params.cpp b/src/core/codestream/ojph_params.cpp index bbc5869..76d3a22 100644 --- a/src/core/codestream/ojph_params.cpp +++ b/src/core/codestream/ojph_params.cpp @@ -787,7 +787,7 @@ namespace ojph { ui32 bit_depth = 0; if (comp_num < 3 && is_employing_color_transform()) { - for (int c = 0; c < 3; ++c) + for (ui32 c = 0; c < 3; ++c) bit_depth = ojph_max(bit_depth, siz->get_bit_depth(c)); ++bit_depth; // colour transform needs one extra bit }