[gdal-dev] gdalinfo fails on jpeg2000 compressed nitf

Even Rouault even.rouault at mines-paris.org
Fri Jul 1 14:08:48 EDT 2011


Le vendredi 01 juillet 2011 16:29:29, Cole, Derek a écrit :
> Hello,
> 
> I have been trying to use the v2 OpenJPEG2000 driver with GDAL to read NITF
> files that have been compressed with jpeg2000.
> 
> When I am trying to actually load these files and display them, my software
> sometimes succeeds, sometimes fails, sometimes gives bogus results. I also
> occaisionally get a dump like this:
> 
> ERROR 1: Marker is not compliant with its position

This error comes from the OpenJPEG library. It seems it doesn't like something 
in the jpeg2000 data stream. Perhaps it is a deficiency in the openjpeg lib, 
perhaps in the datastream (some jpeg2000 readers might work around 
deficiencies/oddities in datastreams in a more robust way). Anyway, it should 
be best reported on openjpeg issue tracker / mailing list, with some data that 
illustrates the defect.

Clearly, it seems there's little activity in openjpeg v2 branch for now. 
However, I've read a message on their mailing list that seemed to indicate it 
could be revived (see the end of 
https://groups.google.com/group/openjpeg/browse_thread/thread/97cebb74d07ce475?hl=fr 
) .Let's hope it will be indeed merged into their trunk some day.

> 
> ERROR 1: opj_read_header() failed
> ERROR 1: IReadBlock failed at X offset 0, Y offset 0
> ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 0
> 
> I have tried to use gdalinfo on the image in question, and get the
> following:
> 
> ERROR 4: `P003.ntf' not recognised as a supported file format.
> 
> ERROR 1: Unable to open JPEG2000 image within NITF file.
> Is the JP2KAK driver available?
> gdalinfo failed - unable to open 'P003.ntf'.
> 
> 
> Any ideas why it seems to be looking for JP2KAK there?

I suspect that originally the only jpeg2000 driver usable by the NITF driver 
was JP2KAK. But the NITF driver will actually try with any JPEG2000 driver 
that supports the vsi virtual file API, in practice any of the 5 possible 
drivers (JP2KAK, JP2ECW, JP2MRSID, JP2OPENJPEG or JPEG2000).

I've just changed the error message to make it more generic. In case of 
failure, depending on the situation, it will now be :
* "No JPEG2000 capable driver (JP2KAK, JP2ECW, JP2MRSID, JP2OPENJPEG, etc...) 
is available."
* or "One or several JPEG2000 capable drivers are available but the datastream 
could not be opened successfully."

> I was trying to not
> use the kakadu driver, because it is not free. Also seems weird to me that
> the image does load sometimes, and not others. Very buggy feeling.


More information about the gdal-dev mailing list