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

Patton, Eric epatton at nrcan.gc.ca
Fri Jan 19 15:36:20 EST 2007


Frank,

Running the command you suggested seems to only use the JPEG2000 driver. I get lines and lines of the following:

<snip>
...
JPEG2000: Component 41921: bpp=4, signedness=0
JPEG2000: Component 41922: bpp=4, signedness=0
JPEG2000: Component 41923: bpp=4, signedness=0
JPEG2000: Component 41924: bpp=4, signedness=0
JPEG2000: Component 41925: bpp=4, signedness=0
terminate called after throwing an instance of 'std::bad_alloc'
  what():  St9bad_alloc
Aborted

Only the last few lines of output are shown. Does it matter what order I compiled jasper-1.900.0.uuid vs. libecwj2-3.3? I believe I complied jasper first, if it matters.

Thanks for the suggestion for FWTools. I installed it under Windows, and imported a 9.5MB jp2 file as a test - OpenEV exported this jp2 to an 800MB tiff! I wonder how big the 291MB jp2 file  would expand to.

~ Eric.

-----Original Message-----
From: Frank Warmerdam
To: Patton, Eric
Cc: gdal-dev at lists.maptools.org
Sent: 1/19/2007 12:45 PM
Subject: Re: [Gdal-dev] Error reading jp2: 'terminate called after throwing an instance of 'std::bad_alloc'

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>
> JPEG (rw): JPEG JFIF
> 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
>
Eric,

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.

Try:

   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