When trying the GDAL OpenJPEG driver against openjpeg current master HEAD,
I get failures when trying to create .jp2 files. The driver uses
opj_write_tile() and in some tests numresolutions = 1.
In openjp2/dwt.c:410, l_data_size = opj_dwt_max_resolution( tilec->resolutions,tilec->numresolutions) * (OPJ_UINT32)sizeof(OPJ_INT32);
is called and returns l_data_size = 0. Now in git opj_malloc() has a special case
for 0 to return a NULL pointer whereas previously it relied on system malloc(),
which in my case didn't return NULL.
So only test the pointer value if l_data_size != 0. This makes the GDAL
autotest suite to pass again.
By default, OpenJPEG uses the function memalign to allocate aligned
memory on Linux systems. That function needs malloc.h which was
missing. This results in a compiler warning:
openjpeg/src/lib/openjp2/opj_malloc.c:63:3: warning:
implicit declaration of function ‘memalign’
[-Wimplicit-function-declaration]
On hosts where sizeof(int) < sizeof(void *) the return value of memalign
will be truncated which results in an invalid pointer.
That caused "make test" to produce lots of segmentation faults when
running on a 64 bit Linux host.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
posix_memalign is only declared conditionally in stdlib.h,
so add one of the possible definitions to get the declaration.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
The png format is also supported, so add it to the message.
Remove also the unneeded blank character before \n.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Fix this and other similar compiler warnings:
src/bin/jp2/convert.c: In function ‘tga_readheader’:
src/bin/jp2/convert.c:595:5: warning:
dereferencing type-punned pointer will break strict-aliasing rules
[-Wstrict-aliasing]
cmap_len = get_ushort(*(unsigned short*)(&tga[5]));
Signed-off-by: Stefan Weil <sw@weilnetz.de>
HP compiler warns:
cc: "dwt.c", line 798: warning 562: Redeclaration of "opj_v4dwt_decode"
with a different storage class specifier: "opj_v4dwt_decode" will have
internal linkage.
cc: "t2.c", line 1341: warning 562: Redeclaration of "opj_t2_init_seg"
with a different storage class specifier: "opj_t2_init_seg" will have
internal linkage.