On bigendian, converting some image to j2k and decompressing it again results in failure, i.e.:
$ wget http://people.sc.fsu.edu/~jburkardt/data/ppma/star_field.ascii.ppm
$ opj2_compress -i star_field.ascii.ppm -o test.j2k -q 30,40,50
[INFO] tile number 1 / 1
Generated outfile test.j2k
$ opj2_decompress -i test.j2k -o test.ppm
[INFO] Start to read j2k main header (0).
[ERROR] Prevent buffer overflow (x1: 671090818, y1: 671090818)
[ERROR] Marker handler function failed to read the marker segment
ERROR -> opj_decompress: failed to read the header
A quick scan through the codebase reveals for instance in convert.c portions of code such as
union { signed short val; signed char vals[2]; } uc16;
mask = (1 << image->comps[compno].prec) - 1;
ptr = image->comps[compno].data;
for (line = 0; line < h; line++) {
for(row = 0; row < w; row++) {
curr = *ptr;
if(curr > 32767 ) curr = 32767; else if( curr < -32768) curr = -32768;
uc16.val = (signed short)(curr & mask);
res = fwrite(uc16.vals, 1, 2, rawFile);
if( res < 2 ) {
fprintf(stderr, "failed to write 2 byte for %s\n", outfile);
goto fin;
}
ptr++;
}
}
which likely produce wrong results on bigendian.
On bigendian, converting some image to j2k and decompressing it again results in failure, i.e.:
A quick scan through the codebase reveals for instance in
convert.cportions of code such aswhich likely produce wrong results on bigendian.