Opened 7 years ago

Closed 7 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://hijpip.lpl.arizona.edu:8064/PDS/EXTRAS/RDR/ESP/ORB_016400_016499/ESP_016474_2555/ESP_016474_2555_RED.QLOOK.JP2  -of PNG /tmp/cache/jpip:hijpip.lpl.arizona.edu:8064PDSEXTRASRDRESPORB_016400_016499ESP_016474_2555ESP_016474_2555_RED.QLOOK.JP2:58520:29264:7315:21948:6.95111405975906.png
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 Changed 7 years ago by whagee

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 Changed 7 years ago by warmerdam

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

Crash confirmed ... investigating.

comment:3 Changed 7 years ago by warmerdam

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 Changed 7 years ago by warmerdam

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://216.150.195.220/JP2Server/qb_boulder_pan_byte 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 Changed 7 years ago by warmerdam

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 Changed 7 years ago by warmerdam

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