Opened 11 years ago

Closed 11 years ago

#3967 closed defect (fixed)

JPIP region error in gdal_translate

Reported by: whagee Owned by: warmerdam
Priority: normal Milestone: 1.8.1
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: jpipkak
Cc: gaopeng

Description (last modified by warmerdam)

I am not sure this even a GDAL error. It may be an error in Kakadu, a user error, or perhaps something else. The error only occurs when trying to fetch a scaled down image. The image is returned without error if not scaled down. This occurs on both CentOS and MAC OS builds of GDAL. The initial assumption is that it is a GDAL error.

$ ./gdal_translate -srcwin 58520 29264 7315 21948 -outsize 6.95111405975906% 6.95111405975906% jpip://  -of PNG /tmp/cache/
Warning 1: Parsed metadata boxes from jpip stream, geographic metadata not found - is the server using placeholders for this data?
Input file size is 75984, 70717
ERROR 1: Error in Kakadu Region Decompressor:
The `region' passed into `kdu_region_decompressor::start' does not lie fully within the region occupied by the full image on the rendering canvas.  The error is probably connected with a misunderstanding of the way in which codestream dimensions are mapped to rendering coordinates through the rational upsampling process offered by the `kdu_region_decompressor' object.  It is best to use `kdu_region_decompressor::get_rendered_image_dims' to find the full image dimensions on the rendering canvas.
terminate called after throwing an instance of 'kdu_cpl_error_message::JP2KAKException*'
Abort trap

Change History (6)

comment:1 by whagee, 11 years ago

This suspected error was reproduced with both GDAL 1.7.3 and 1.8.0 using both Kakadu 6.4.0 and 6.4.1.

comment:2 by warmerdam, 11 years ago

Component: defaultGDAL_Raster
Description: modified (diff)
Keywords: jpipkak added
Status: newassigned

Crash confirmed ... investigating.

comment:3 by warmerdam, 11 years ago

This looks like a serious issue with how the region calculations are done in the JPIPKAK driver when reading at a different resolution than the underlying image. I will need to spend some more time on it. In the meantime, I have committed code in trunk (r21765) that captures the exception and reports it properly as a GDAL error instead of crashing.

comment:4 by warmerdam, 11 years ago

Things seem to be going wrong any time there are non-zero offsets for a window at other than full resolution. The command:

dumpoverviews jpip:// 1

will also trigger a similar failure as the overviews is pulled into two passes. I am very suspicious of:

        region.pos.x = (int) ceil(nXOff * x_ratio);
        region.pos.y = (int) ceil(nYOff * y_ratio);
        region.size.x = (int) ceil(nXSize * x_ratio);
        region.size.y = (int) ceil(nYSize * y_ratio);

though I'm not clear what the right replacement is.

comment:5 by warmerdam, 11 years ago

Cc: gaopeng added
Milestone: 1.8.1

It turns out that both the fsiz computation and the region computation were pretty screwed up resulting in errors when fetching overviews with an origin other than 0,0. It did not show up in the smaller overviews which are usually fetched "whole".

I have fixed the computations as well as improving error trapping (ensure mutex is released if held). The fix is in trunk (r21769).

I have rolled all the fixes into 1.8 branch (r21770).

comment:6 by warmerdam, 11 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.