[Gdal-dev] Error reading jp2: 'terminate called after throwing an instance of 'std::bad_alloc'

Frank Warmerdam warmerdam at pobox.com
Fri Jan 19 12:45:37 EST 2007

Patton, Eric wrote:
> Hi,
> I've just installed gdal-1.4.0. I gettgin errors trying to read and translate jp2 files. I have compiled the ER Mapper ECW SDK, and JPEG2000 support shows  up in my configure output:
> ...
> <snip>
> JASPER support:            yes (GeoJP2=no)
> ECW support:               yes
> <snip>
> gdalinfo --formats confirms that the support is enabled:
> ...
> <snip>
> JPEG2000 (rw): JPEG-2000 part 1 (ISO/IEC 15444-1)
> ECW (rw): ERMapper Compressed Wavelets
> JP2ECW (rw+): ERMapper JPEG2000
> <snip>
> No errors occurred during make or make install. I'm trying to open a 291MB jp2 file that represents 1m LIDAR dataset. Here's the output when I try to read it with gdalinfo/translate:
> $ gdalinfo csr.jp2
> terminate called after throwing an instance of 'std::bad_alloc'
>   what():  St9bad_alloc
> Aborted

One important question is which driver is actually getting used.
The JasPer based JPEG2000 driver or the ECW SDK based JP2ECW
driver.  The JasPer driver uses huge amounts of memory for large
images, which might explain the allocation failure.


   gdalinfo --debug on --config GDAL_SKIP JPEG2000 csr.jp2

That should use the JP2ECW driver, and perhaps report some
information as it goes.   If the JP2ECW driver doesn't work then it
is possible the file is corrupt in some fashion.  You might want to try
it with FWTools which uses Kakadu for jpeg2000.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the Gdal-dev mailing list