From 86b139d62f6246ca686801a7da43d198b82e02db Mon Sep 17 00:00:00 2001 From: Aous Naman Date: Sat, 6 Apr 2024 09:13:39 +1100 Subject: [PATCH] This is a very important bug fix -- Empty subbands/precincts. --- src/core/codestream/ojph_precinct.cpp | 24 ++++++++++++++++++++++++ src/core/codestream/ojph_precinct.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/core/codestream/ojph_precinct.cpp b/src/core/codestream/ojph_precinct.cpp index 71b61de8..f8d69fbe 100644 --- a/src/core/codestream/ojph_precinct.cpp +++ b/src/core/codestream/ojph_precinct.cpp @@ -332,6 +332,30 @@ namespace ojph { if (may_use_sop) bb_skip_sop(&bb); + if (num_bands == 3) + { + if (bands[1].empty && bands[2].empty && bands[3].empty) + { + ui32 bit = 0; + bb_read_bit(&bb, bit); + bb_terminate(&bb, uses_eph); + assert(bit == 0); + return; + } + } + else + { + if (bands[0].empty) + { + ui32 bit = 0; + bb_read_bit(&bb, bit); + bb_terminate(&bb, uses_eph); + assert(bit == 0); + return; + } + } + + int sst = num_bands == 3 ? 1 : 0; int send = num_bands == 3 ? 4 : 1; bool empty_packet = true; diff --git a/src/core/codestream/ojph_precinct.h b/src/core/codestream/ojph_precinct.h index 4641ed68..d8e880a9 100644 --- a/src/core/codestream/ojph_precinct.h +++ b/src/core/codestream/ojph_precinct.h @@ -69,7 +69,7 @@ namespace ojph { ui32& data_left, infile_base *file, bool skipped); ui8 *scratch; - point img_point; //the precinct projected to full resolution + point img_point; //the precinct projected to full resolution rect cb_idxs[4]; //indices of codeblocks subband *bands; //the subbands coded_lists* coded;