about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-11-06 22:58:52 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-11-06 22:58:52 +0000
commit1f5d5a03933a0532b20c16826fe8f4e4add0f8e9 (patch)
treed63379436fe5ece404fe41e5d4d83fd416aee6df
parent4714059b1bfcab41f320961075596ed881c65162 (diff)
downloadnetpbm-mirror-1f5d5a03933a0532b20c16826fe8f4e4add0f8e9.tar.gz
netpbm-mirror-1f5d5a03933a0532b20c16826fe8f4e4add0f8e9.tar.xz
netpbm-mirror-1f5d5a03933a0532b20c16826fe8f4e4add0f8e9.zip
Fix assertion failure with numbps for codeblock being greater than numbps for band
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4464 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/jpeg2000/libjasper/jpc/jpc_enc.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
index 8f13207c..debdeec0 100644
--- a/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
+++ b/converter/other/jpeg2000/libjasper/jpc/jpc_enc.c
@@ -1561,8 +1561,17 @@ quantizeBand(jpc_enc_band_t * const bandP,
         }
         bandP->stepsize = jpc_abstorelstepsize(
             bandP->absstepsize, prec + bandP->analgain);
-
-        bandP->numbps = tccp_numgbits + JPC_QCX_GETEXPN(bandP->stepsize) - 1;
+        /* I couldn't figure out what the calculation with tccp_numgbits and
+           stepsize does (or even what a step size is), but there is an
+           assertion elsewhere than the number here is at least at large as
+           the 'numbps' value for every code block, which means
+           'actualnumbps'.  In practice, we saw that not be true, so we added
+           the code to make 'actualnumbps' the floor here in hopes that would
+           fix the problem.  22.11.06
+        */
+        bandP->numbps =
+            MAX(actualnumbps,
+                tccp_numgbits + JPC_QCX_GETEXPN(bandP->stepsize) - 1);
 
         if (!tileP->intmode && bandP->data)
             quantize(bandP->data, bandP->absstepsize);