JP2KAK errors out on JPIP URL ending in *.jp2
|Reported by:||gbriggs||Owned by:||warmerdam|
|Severity:||normal||Keywords:||JPEG2000 JP2KAK JPIPKAK|
The following command fails: C:\gdal170\bin>gdal_translate.exe jpip://188.8.131.52/JP2Server/qb_boulder_pan_20bit.jp2 "C:\gdal_qb_boulder_msi_Byte.img"
The command throws the following error and also generates a memory exception because of an attempt to access a NULL pointer: ERROR 4: JPIP Protocol not supported by GDAL with Kakadu 3.4 or on Unix.
This particular problem originally manifested on a test server internal to ITT VIS. However, the error also manifests when trying to access a JPIP stream that does not actually exist with the ".jp2" extension.
This error message is reported from jp2kakdataset.cpp (line 1159). I believe it is a result of the JP2KAK driver incorrectly deciding it can open the URL above because it ends with the JP2 extension.
If the JP2KAK driver is removed from the GDAL build, the commandline above executes correctly using the JPIPKAK GDAL driver. One possible fix would be to change the order of the GDAL drivers' tests for open (i.e. put JPIPKAK before JP2KAK in the list). However, a better fix would involve a more comprehensive check in the JP2KAK driver to ensure any JPIP URL is not mistaken for a JP2 file. (of course this check would need to be disabled if the preprocessor directive USE_JPIP was defined)