Open hhoffstaette opened 1 month ago
@hhoffstaette As best I can tell from looking at the source code, the "2 < 20" is referring to the fact that the value of 2 guard bits specified on the command line is too small for the data to be encoded, and the encoder believes that the number of guard bits should be at least 20. Although I cannot say definitively that this is bug in musl, I am very suspicious that this might be the case, given that none of the code in JasPer that calculates the number of necessary guard bits has been changed in a long time as far as I can recall. One thing that would be potentially helpful to know: If you move the print statement that outputs the "too few guard bits" message prior to the "if" body in which it is located for the case where things work (i.e., no using musl), what values does it print? In other words, in a situation where things work, what does it think that the two printed integers (related to numbers of guard bits) are equal to?
I enabled this line by removing the guard.
on glibc (success):
TESTID=sgn_1 ENC=jasper DEC=jasper
FMT=pgx WIDTH=8 HEIGHT=8 PREC=12 NUMCMPTS=1 RAWSIZE=96
test information:
image signed_12.pgx
id sgn_1
pae 0
bug oj_dec
fmt jpc
mode int
software=jasper input=/tmp/portage/media-libs/jasper-4.2.2/work/jasper-version-4.2.2/data/images/signed_12.pgx output=/tmp/jasper-@localhost/jpcod-168/test.jpc fmt=jpc m>
Running JasPer encoder
/tmp/portage/media-libs/jasper-4.2.2/work/jasper-version-4.2.2_build/src/app/jasper -T jpc -O cblkwidth=64 -O cblkheight=64 -O mode=int -O numrlvls=6 -O numgbits=2 -O p>
numgbits 2 mingbits 0
Running JasPer decoder
/tmp/portage/media-libs/jasper-4.2.2/work/jasper-version-4.2.2_build/src/app/jasper -T pgx < /tmp/jasper-@localhost/jpcod-168/test.jpc > /tmp/jasper-@localhost/jpcod-16>
STATUS: LOSSLESS (ENCFILESIZE=196)
on musl (failure):
TESTID=sgn_1 ENC=jasper DEC=jasper
FMT=pgx WIDTH=8 HEIGHT=8 PREC=12 NUMCMPTS=1 RAWSIZE=96
test information:
image signed_12.pgx
id sgn_1
pae 0
bug oj_dec
fmt jpc
mode int
software=jasper input=/var/tmp/portage/media-libs/jasper-4.2.2/work/jasper-version-4.2.2/data/images/signed_12.pgx output=/tmp/jasper-@localhost/jpcod-2234/test.jpc fmt=>
Running JasPer encoder
/var/tmp/portage/media-libs/jasper-4.2.2/work/jasper-version-4.2.2_build/src/app/jasper -T jpc -O cblkwidth=64 -O cblkheight=64 -O mode=int -O numrlvls=6 -O numgbits=2 >
numgbits 2 mingbits 20
error: too few guard bits (2 < 20)
cannot encode main body
jpc_encode failed
error: cannot encode image
ERROR: ENCODER FAILURE
ERROR: ENCODER FAILURE
So the difference is the "numgbits 2 mingbits 0" vs. "numgbits 2 mingbits 20", and the problem is inconsistent detection/configuration of mingbits.
@hhoffstaette Thanks for checking this. So, it would appear that the use of musl somehow results in the number of necessary guard bits being computed incorrectly. Unfortunately, I don't recall how the number of guard bits is computed, since I wrote the code for that about 20 years ago :frowning_face:. I guess that I'll have to trace through the computation and try to figure out how musl is causing an incorrect calculation. Of course, in the unlikely event that you have some spare time on your hands, you are certainly welcome to try this yourself and let me know what you find. :wink:
~Just looking at the possible origins of the value - if I had to make a guess where things go wrong:~ https://github.com/jasper-software/jasper/blob/8766848706a727f61c1c76a5a7cf1078433fad02/src/libjasper/jpc/jpc_enc.c#L554 ~looks like a good candidate.~
Update: that's not it, sorry. Somehow the expected value of 2 gets turned into a 20 somewhere else.
Gentoo CI noticed a test suite failure on musl
Out of curiosity I tried to reproduce it and indeed can do so (with 4.2.2 and also the latest 4.2.4), which is odd and probably a musl problem since the test suite of 4.2.2 passes on glibc :tada:
The test output summary says:
and the specific test is:
Looking at the test arguments, it does pass
numgbits=2
and then complains about that, so it's not clear what is going here or why it succeeds on glibc.Any idea what the problem might be? I can provide the full log if necessary.