[gdal-dev] OpenJPEG2000 issues when reading blocks at a time

Cole, Derek dcole at integrity-apps.com
Mon Jun 13 18:52:20 EDT 2011


Hello,

I have the following code:

    qDebug("tilePosX: %i ", this->tilePosX);
    qDebug("tilePosY: %i ", this->tilePosY);


    float * floatData = (float *) CPLMalloc(sizeof(float)*nXSize*nYSize);
    poBand->RasterIO( GF_Read, this->tilePosX*nXSize, this->tilePosY*nYSize, nXSize, nYSize, floatData, nXSize, nYSize,GDT_Float32, 0, 0 );

I am using this to read in "tiles" from a larger image, to avoid having to do massive read operations.

This seems to work great for an uncompressed nitf, however, when trying it on a JPEG2000 image, it seems to be highly unstable. Sometimes my software crashes, and sometimes I get no data back, and usually it gives a splurge of info like below, whee tilePosX and tilePosY is the "block" in the file I am trying to read. nX/nY Size variables are obtained from the GetBlockSize() function on the band., which is this case is 1024x1024.

Is there a problem with OpenJPEG2000? I have tried to use jasper already, and it was painfully slow. Starting to run out of options here.

Also, as a side note, I am doing this operation in a separate thread from my GUI, and it should be waiting for the data to be returned before returning to my main..which like i said is working fine when it is uncompressed - but does this driver perhaps return a simple allocated array or something it is populated asynchronously? Some of the blocks come back looking right, some are scrambled, and some are all black in my viewer.


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

Loading Pixmap

tilePosX: 1

tilePosY: 0

ERROR 1: Stream too short, expected SOT

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 1, Y offset 0

ERROR 1: GetBlockRef failed at X block offset 1, Y block offset 0

Loading Pixmap

tilePosX: 0

tilePosY: 1

Loading Pixmap

tilePosX: 1

tilePosY: 1

Loading Pixmap

tilePosX: 0

tilePosY: 1

Loading Pixmap

tilePosX: 1

tilePosY: 1

ERROR 1: Stream too short

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 1, Y offset 1

ERROR 1: GetBlockRef failed at X block offset 1, Y block offset 1

Loading Pixmap

tilePosX: 1

tilePosY: 1

Loading Pixmap

tilePosX: 1

tilePosY: 1

Loading Pixmap

tilePosX: 2

tilePosY: 0

Loading Pixmap

tilePosX: 2

tilePosY: 1

ERROR 1: Expected a SOC marker

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 0

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 0

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 1

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 1

Loading Pixmap

Loading Pixmap

tilePosX: 2

tilePosY: 0

tilePosX: 2

tilePosY: 1

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 1

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 1

ERROR 1: Stream too short, expected SOT

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 0

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 0

Loading Pixmap

tilePosX: 2

tilePosY: 0

Loading Pixmap

tilePosX: 2

tilePosY: 0

Loading Pixmap

tilePosX: 0

tilePosY: 2

Loading Pixmap

tilePosX: 1

tilePosY: 2

Loading Pixmap

tilePosX: 2

tilePosY: 2

ERROR 1: Stream too short

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 2

Loading Pixmap

tilePosX: 1

tilePosY: 2

Loading Pixmap

tilePosX: 2

Loading Pixmap

tilePosY: 2

tilePosX: 3

tilePosY: 0

Loading Pixmap

tilePosX: 3

tilePosY: 1

Loading Pixmap

tilePosX: 3

tilePosY: 2

ERROR 1: Expected a SOC marker

ERROR 1: Expected a SOC marker

ERROR 1: opj_read_header() failed

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 3, Y offset 1

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 1

ERROR 1: IReadBlock failed at X offset 2, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 2

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 3, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 2

ERROR 1: Stream too short, expected SOT

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 3, Y offset 0

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 0

Loading Pixmap

Loading Pixmap

tilePosX: 2

tilePosX: 3

Loading Pixmap

Loading Pixmap

tilePosY: 0

tilePosX: 3

tilePosX: 3

tilePosY: 2

tilePosY: 1

tilePosY: 2

ERROR 1: Expected a SOC marker

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 2, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 2, Y block offset 2

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 3, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 2

ERROR 1: IReadBlock failed at X offset 3, Y offset 1

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 1

Loading Pixmap

Loading Pixmap

tilePosX: 2

tilePosY: 2

tilePosX: 3

tilePosY: 0

Loading Pixmap

tilePosX: 3

tilePosY: 2

ERROR 1: Stream too short

ERROR 1: opj_decode_tile_data() failed

ERROR 1: IReadBlock failed at X offset 3, Y offset 2

ERROR 1: GetBlockRef failed at X block offset 3, Y block offset 2

Loading Pixmap

tilePosX: 0

tilePosY: 3

Loading Pixmap

tilePosX: 1

tilePosY: 3

ERROR 1: Stream too short, expected SOT

ERROR 1: opj_decode_tile_data() failed

ERROR 1: Marker is not compliant with its position

ERROR 1: opj_read_header() failed

ERROR 1: IReadBlock failed at X offset 1, Y offset 3

ERROR 1: GetBlockRef failed at X block offset 1, Y block offset 3

ERROR 1: IReadBlock failed at X offset 0, Y offset 3

ERROR 1: GetBlockRef failed at X block offset 0, Y block offset 3

Loading Pixmap

tilePosX: 2

tilePosY: 3

Loading Pixmap

tilePosX: 3

tilePosY: 3

Loading Pixmap

tilePosX: 3

tilePosY: 3


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110613/cead42e7/attachment-0001.html


More information about the gdal-dev mailing list