Hello,

While investigating why one of the unit tests of rasterio fails on i386
[1], I think that the actual cause is a different result from gdal when
using GDALDatasetRasterIO.

When opening the test file [2] I get different results when using i386.
I could reproduce this behaviour when using only C code (attached).
i386:
0 8 5 7 0 0 0 0
0 6 61 15 27 15 24 128
0 20 152 23 15 19 28 0
0 18 255 21 129 24 32 0
9 7 14 16 19 18 36 0
6 27 43 207 38 31 73 0
0 0 0 0 74 23 0 0

AMD64 and other architectures:
0 8 5 7 0 0 0 0
0 6 61 15 27 15 24 128
0 20 152 23 15 19 28 0
**0 17 255 25 255 22 32 0 **
9 7 14 16 19 18 36 0
6 27 43 207 38 31 73 0
0 0 0 0 74 23 0 0


Note that the difference only occurs on i386: on other debian
architectures[3,] (including 32 bit like mips, arm) the same result was
found.

Kind Regards,
Johan

[1] https://github.com/mapbox/rasterio/issues/229
[2] https://github.com/mapbox/rasterio/blob/master/tests/data/RGB.byte.tif
[3] https://buildd.debian.org/status/package.php?p=rasterio&suite=unstable
#include "gdal.h"
#include "cpl_conv.h" /* for CPLMalloc() */
#include <stdio.h>

int main()
{
    GDALDatasetH  hDataset;

    GDALAllRegister();

    hDataset = GDALOpen( "rasterio/tests/data/RGB.byte.tif", GA_ReadOnly );
    if( hDataset != NULL )
    {
	int nXOff = 0;
	int nYOff = 0;
	int nXSize = 791;
	int nYSize = 718;
	int nBufXSize=8;
	int nBufYSize =7;
	unsigned char * pData;
	pData = (unsigned char *) CPLMalloc(sizeof(char)*nBufXSize*nBufYSize);
	GDALDatasetRasterIO(hDataset,GF_Read,nXOff,nYOff, nXSize,nYSize,pData, nBufXSize, nBufYSize, GDT_Byte,1,NULL,0,0,0);
	int x,y;
	for (y=0; y<nBufYSize; y++){
		for (x=0; x<nBufXSize; x++){
			printf("%d ",(int)pData[y*nBufXSize +x]);
		}
		printf("\n");
	}
	return 1;
    }
}

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to