Opened 11 years ago

Closed 11 years ago

#5086 closed defect (fixed)

read big raw image error

Reported by: liminlu0314 Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.10.0
Severity: normal Keywords: VRT RAW
Cc:

Description

Define content of VRT file below, GDAL read image is wrong. I found in the VRT ImageOffset error during conversion. the atoi function cannot convert over 2147483647 numbers.

<VRTDataset rasterXSize="1536" rasterYSize="10000">
    <SourceFilename relativeToVRT="0">E:/SJ9A_SEPAMODE_CCD_20130204125820_000000000_0_aa.raw</SourceFilename>
    <ImageOffset>2150400000</ImageOffset>
    <PixelOffset>2</PixelOffset>
    <LineOffset>3072</LineOffset>
    <ByteOrder>MSB</ByteOrder>
  </VRTRasterBand>
</VRTDataset>

so can use this code convert this number

#if defined(WIN32) && defined(_MSC_VER)

GIntBig atoi64(const char * str) { return _atoi64(str); }
GUIntBig atoi64u(const char * str) { return _strtoui64(str, NULL, 10); }

#elif HAVE_LONG_LONG

GIntBig atoi64(const char * str) { return strtoll(str, NULL, 10); }
GUIntBig atoi64u(const char * str) { return strtoull(str, NULL, 10); }

#else

GIntBig atoi64(const char * str) { return _atoi64(str); }
GUIntBig atoi64u(const char * str) { return _strtoui64(str, NULL, 10); }

#endif

Thank you for your work

Change History (4)

comment:1 by liminlu0314, 11 years ago

you can modify the file as below to solve this bug: 1: gdal-1.10.0\frmts\vrt\vrtdataset.cpp line 926:

/* -------------------------------------------------------------------- */
/*      Collect required information.                                   */
/* -------------------------------------------------------------------- */
        if( CSLFetchNameValue(papszOptions, "ImageOffset") != NULL )
            nImageOffset = atoi64u(CSLFetchNameValue(papszOptions, "ImageOffset"));

2:gdal-1.10.0\frmts\vrt\vrtrawrasterband.cpp line 403:

    nImageOffset = atoi64u(CPLGetXMLValue( psTree, "ImageOffset", "0") );

3: gdal-1.10.0\frmts\vrt\vrtrawrasterband.cpp line 334

/* -------------------------------------------------------------------- */
/*      Set other layout information.                                   */
/* -------------------------------------------------------------------- */
    CPLCreateXMLElementAndValue( 
        psTree, "ImageOffset", 
        CPLSPrintf("%llu", poRawRaster->GetImgOffset()) );

comment:2 by liminlu0314, 11 years ago

Milestone: 1.10.1
Version: unspecified1.10.0

comment:3 by warmerdam, 11 years ago

Status: newassigned

comment:4 by warmerdam, 11 years ago

Resolution: fixed
Status: assignedclosed

I have implemented this using the cpl wrappers for 64bit decoding and encoding in trunk (r26023). Could you test it out? If it works well for you, I'll back port it to 1.10.x.

Note: See TracTickets for help on using tickets.