Opened 16 years ago

Closed 9 years ago

#2417 closed defect (fixed)

HDF4 endian problems on read in OSX 64bits

Reported by: kyngchaos Owned by: warmerdam
Priority: normal Milestone: 1.8.1
Component: GDAL_Raster Version: 1.5.2
Severity: normal Keywords: HDF4
Cc:

Description

I think this is coming from GDAL, but I'm not sure: the HDF4 read tests fail in OSX 64bits. The write tests succeed. Both read and write tests succed in OSX 32bits.

If I run gdal_translate to convert the GDAL autotest HDF4 files to tiff, in 64bit mode I noticed that the endianess of the values is reversed. So it seems like an endian problem when run in 64bit mode. This all on OSX Intel. I dont have OSX PPC handy to test (and no PPC 64bit at all).

I poked around in the HDF4 source to see if there were any OSX assumptions I missed, but fixing a few minor issues didn't help GDAL. While some of the HDF4 make check tests fail with errors about incorrect, running hdfunpack (from the HDF source) on the GDAL autotest HDF4 samples gave me the same output when run in 32bit and 64bit modes, so it looks like the HDF4 library may be OK.

I found this in hdf4dataset.cpp, HDF4Dataset::AnyTypeToDouble():

            return (double)*(long *)pData;
        case DFNT_UINT32:
            return (double)*(unsigned long *)pData;
        case DFNT_INT64:
            return (double)*(char *)pData;
        case DFNT_UINT64:
            return (double)*(GIntBig *)pData;

I changed it to (mirroring the GIntBig there):

            return (double)*(GInt32 *)pData;
        case DFNT_UINT32:
            return (double)*(GUInt32 *)pData;
        case DFNT_INT64:
            return (double)*(GUIntBig *)pData;
        case DFNT_UINT64:
            return (double)*(GIntBig *)pData;

to make sure that the 32bit and 64bit integers were correct (the long size matches the processor size on OSX). This didn't help. But I wonder if there is something similar going on somewhere else (I didn't see any other longs being used, or any endian switches)? Or is it really in the HDF4 library, but just a problem exposed by GDAL?

I can test on PPC 32bit OSX later, but I have no way to test PPC 64bit.

Change History (5)

comment:1 by warmerdam, 16 years ago

Keywords: HDF4 added
Milestone: 1.4.5
Status: newassigned

comment:2 by warmerdam, 16 years ago

Milestone: 1.4.51.5.3

comment:3 by Jukka Rahkonen, 9 years ago

Anybody out there to make a new test with OSX 64bits and HDF4 files from GDAL autotest suite? William?

comment:4 by kyngchaos, 9 years ago

HDF4 read tests now succeed on OS X 64bit.

comment:5 by Jukka Rahkonen, 9 years ago

Resolution: fixed
Status: assignedclosed

Closing as fixed.

Note: See TracTickets for help on using tickets.