Type Declarations#

nvTIFF Encode API Return Status Codes#

The return codes of the nvTIFF Encode APIs are listed below:

#define NVTIFF_ENCODE_SUCCESS             (0)
#define NVTIFF_ENCODE_INVALID_CTX         (1)
#define NVTIFF_ENCODE_INVALID_STRIP_NUM   (2)
#define NVTIFF_ENCODE_INVALID_IMAGE_NUM   (3)
#define NVTIFF_ENCODE_COMP_OVERFLOW       (4)
#define NVTIFF_ENCODE_COMP_STRIP_TOO_LONG (5)

Description of the Return Codes

Return Code

Description

NVTIFF_ENCODE_SUCCESS (0)

The API call has finished successfully. Note that many of the calls are asynchronous and some of the errors may be seen only after synchronization.

NVTIFF_ENCODE_INVALID_CTX (1)

Invalid CTX.

NVTIFF_ENCODE_INVALID_STRIP_NUM (2)

Invalid strip number

NVTIFF_ENCODE_INVALID_IMAGE_NUM (3)

Invalid image number

NVTIFF_ENCODE_COMP_OVERFLOW (4)

Overflow during compression

NVTIFF_ENCODE_COMP_STRIP_TOO_LONG (5)

Too long strip

nvTIFF Write API Return Status Codes#

The return codes of the nvTIFF Write APIs are listed below:

#define NVTIFF_WRITE_SUCCESS                (0)
#define NVTIFF_WRITE_UNSUPP_PLANAR_CONF     (1)
#define NVTIFF_WRITE_UNSUPP_PHOTOMETRIC_INT (2)
#define NVTIFF_WRITE_UNSUPP_SAMPLE_FORMAT (3)

Description of the Return Codes

Return Code

Description

NVTIFF_WRITE_SUCCESS (0)

The API call has finished successfully. Note that many of the calls are asynchronous and some of the errors may be seen only after synchronization.

NVTIFF_WRITE_UNSUPP_PLANAR_CONF (1)

if the value of planarConf parameter is not equal to 1;.

NVTIFF_WRITE_UNSUPP_PHOTOMETRIC_INT (2)

if the value of photometricInt parameter is neither 1 nor 2;

NVTIFF_WRITE_UNSUPP_SAMPLE_FORMAT (3)

if the value of sampleFormat parameter is not equal to 1, 2, 3, or 4;

Decode API Return Status Codes#

The return codes of the nvTiff Decode APIs are listed below:

typedef enum {
    NVTIFF_STATUS_SUCCESS = 0,
    NVTIFF_STATUS_NOT_INITIALIZED = 1,
    NVTIFF_STATUS_INVALID_PARAMETER = 2,
    NVTIFF_STATUS_BAD_TIFF = 3,
    NVTIFF_STATUS_TIFF_NOT_SUPPORTED = 4,
    NVTIFF_STATUS_ALLOCATOR_FAILURE = 5,
    NVTIFF_STATUS_EXECUTION_FAILED = 6,
    NVTIFF_STATUS_ARCH_MISMATCH = 7,
    NVTIFF_STATUS_INTERNAL_ERROR = 8,
    NVTIFF_STATUS_NVCOMP_NOT_FOUND = 9,
    NVTIFF_STATUS_NVJPEG_NOT_FOUND = 10,
    NVTIFF_STATUS_TAG_NOT_FOUND = 11,
    NVTIFF_STATUS_PARAMETER_OUT_OF_BOUNDS = 12,
    NVTIFF_STATUS_NVJPEG2K_NOT_FOUND = 13
} nvtiffStatus_t;

Description of the Return Codes

Return Code

Description

NVTIFF_STATUS_SUCCESS (0)

The API call has finished successfully. Note that many of the calls are asynchronous and some of the errors may be seen only after synchronization.

NVTIFF_STATUS_NOT_INITIALIZED (1)

The library handle was not initialized.

NVTIFF_STATUS_INVALID_PARAMETER (2)

Wrong parameter was passed. For example, a null pointer as input data, or an invalid enum value

NVTIFF_STATUS_BAD_TIFF (3)

Cannot parse the TIFF stream. Likely due to a corruption that cannot be handled

NVTIFF_STATUS_TIFF_NOT_SUPPORTED (4)

Attempting to decode a TIFF stream that is not supported by the nvTIFF library.

NVTIFF_STATUS_ALLOCATOR_FAILURE (5)

The user-provided allocator functions, for either memory allocation or for releasing the memory, returned a non-zero code.

NVTIFF_STATUS_EXECUTION_FAILED (6)

Error during the execution of the device tasks.

NVTIFF_STATUS_ARCH_MISMATCH (7)

The device capabilities are not enough for the set of input parameters provided.

NVTIFF_STATUS_INTERNAL_ERROR (8)

Unknown error occurred in the library.

NVTIFF_STATUS_NVCOMP_NOT_FOUND (9)

nvTiff is unable to load the nvcomp library.

NVTIFF_STATUS_NVJPEG_NOT_FOUND (10)

nvTiff is unable to load the nvjpeg library.

NVTIFF_STATUS_TAG_NOT_FOUND (11)

nvTiff is unable to find information about the provided tag.

NVTIFF_STATUS_PARAMETER_OUT_OF_BOUNDS (12)

Provided parameter is outside the range of possible values.

NVTIFF_STATUS_NVJPEG2K_NOT_FOUND (13)

nvTiff is unable to load the nvJPEG2000 library.

TIFF Tags#

typedef enum nvtiffTag {
  NVTIFF_TAG_UNKNOWN = -1,
  NVTIFF_TAG_MODEL_PIXEL_SCALE = 33550,
  NVTIFF_TAG_MODEL_TIE_POINT =   33922,
  NVTIFF_TAG_MODEL_TRANSFORMATION = 34264
} nvtiffTag_t;

nvtiffTag_t corresponds to various TIFF tags listed in the TIFF specification. Currently only GeoTIFF relevant tags are supported. User can refer to the TIFF specification for additional details.

TIFF Tag Data Type#

typedef enum nvtiffTagDataType {
    NVTIFF_TAG_TYPE_BYTE      =  1,
    NVTIFF_TAG_TYPE_ASCII     =  2,
    NVTIFF_TAG_TYPE_SHORT     =  3,
    NVTIFF_TAG_TYPE_LONG      =  4,
    NVTIFF_TAG_TYPE_RATIONAL  =  5,
    NVTIFF_TAG_TYPE_SBYTE     =  6,
    NVTIFF_TAG_TYPE_UNDEFINED =  7,
    NVTIFF_TAG_TYPE_SSHORT    =  8,
    NVTIFF_TAG_TYPE_SLONG     =  9,
    NVTIFF_TAG_TYPE_SRATIONAL = 10,
    NVTIFF_TAG_TYPE_FLOAT     = 11,
    NVTIFF_TAG_TYPE_DOUBLE    = 12,
    NVTIFF_TAG_TYPE_LONG8     = 16,
    NVTIFF_TAG_TYPE_SLONG8    = 17,
    NVTIFF_TAG_TYPE_IFD8      = 18,
} nvtiffTagDataType_t;

nvtiffTagDataType_t corresponds to the datatype for a TIFF tag.

GeoTIFF Keys#

typedef enum nvtiffGeoKeys
{
    // GeoTIFF Configuration Keys
    NVTIFF_GEOKEY_GT_MODEL_TYPE                = 1024,
    NVTIFF_GEOKEY_GT_RASTER_TYPE               = 1025,
    NVTIFF_GEOKEY_GT_CITATION                  = 1026,

    // Geodetic CRS Parameter Keys
    NVTIFF_GEOKEY_GEODETIC_CRS                 = 2048,
    NVTIFF_GEOKEY_GEODETIC_CITATION            = 2049,
    NVTIFF_GEOKEY_GEODETIC_DATUM               = 2050,
    NVTIFF_GEOKEY_PRIME_MERIDIAN               = 2051,
    NVTIFF_GEOKEY_GEOG_LINEAR_UNITS            = 2052,
    NVTIFF_GEOKEY_GEOG_LINEAR_UNIT_SIZE        = 2053,
    NVTIFF_GEOKEY_GEOG_ANGULAR_UNITS           = 2054,
    NVTIFF_GEOKEY_GEOG_ANGULAR_UNIT_SIZE       = 2055,
    NVTIFF_GEOKEY_ELLIPSOID                    = 2056,
    NVTIFF_GEOKEY_ELLIPSOID_SEMI_MAJOR_AXIS    = 2057,
    NVTIFF_GEOKEY_ELLIPSOID_SEMI_MINOR_AXIS    = 2058,
    NVTIFF_GEOKEY_ELLIPSOID_INV_FLATTENING     = 2059,
    NVTIFF_GEOKEY_GEOG_AZIMUTH_UNITS           = 2060,
    NVTIFF_GEOKEY_PRIME_MERIDIAN_LONG          = 2061,

    // Projected CRS Parameter Keys
    NVTIFF_GEOKEY_PROJECTED_CRS                = 3072,
    NVTIFF_GEOKEY_PROJECTED_CITATION           = 3073,
    NVTIFF_GEOKEY_PROJECTION                   = 3074,
    NVTIFF_GEOKEY_PROJ_METHOD                  = 3075,
    NVTIFF_GEOKEY_PROJ_LINEAR_UNITS            = 3076,
    NVTIFF_GEOKEY_PROJ_LINEAR_UNIT_SIZE        = 3077,
    NVTIFF_GEOKEY_PROJ_STD_PARALLEL1           = 3078,
    NVTIFF_GEOKEY_PROJ_STD_PARALLEL            = 3078,
    NVTIFF_GEOKEY_PROJ_STD_PARALLEL2           = 3079,
    NVTIFF_GEOKEY_PROJ_NAT_ORIGIN_LONG         = 3080,
    NVTIFF_GEOKEY_PROJ_ORIGIN_LONG             = 3080,
    NVTIFF_GEOKEY_PROJ_NAT_ORIGIN_LAT          = 3081,
    NVTIFF_GEOKEY_PROJ_ORIGIN_LAT              = 3081,
    NVTIFF_GEOKEY_PROJ_FALSE_EASTING           = 3082,
    NVTIFF_GEOKEY_PROJ_FALSE_NORTHING          = 3083,
    NVTIFF_GEOKEY_PROJ_FALSE_ORIGIN_LONG       = 3084,
    NVTIFF_GEOKEY_PROJ_FALSE_ORIGIN_LAT        = 3085,
    NVTIFF_GEOKEY_PROJ_FALSE_ORIGIN_EASTING    = 3086,
    NVTIFF_GEOKEY_PROJ_FALSE_ORIGIN_NORTHING   = 3087,
    NVTIFF_GEOKEY_PROJ_CENTER_LONG             = 3088,
    NVTIFF_GEOKEY_PROJ_CENTER_LAT              = 3089,
    NVTIFF_GEOKEY_PROJ_CENTER_EASTING          = 3090,
    NVTIFF_GEOKEY_PROJ_CENTER_NORTHING         = 3091,
    NVTIFF_GEOKEY_PROJ_SCALE_AT_NAT_ORIGIN     = 3092,
    NVTIFF_GEOKEY_PROJ_SCALE_AT_ORIGIN         = 3092,
    NVTIFF_GEOKEY_PROJ_SCALE_AT_CENTER         = 3093,
    NVTIFF_GEOKEY_PROJ_AZIMUTH_ANGLE           = 3094,
    NVTIFF_GEOKEY_PROJ_STRAIGHT_VERT_POLE_LONG = 3095,

    // Vertical CRS Parameter Keys (4096-5119)
    NVTIFF_GEOKEY_VERTICAL                     = 4096,
    NVTIFF_GEOKEY_VERTICAL_CITATION            = 4097,
    NVTIFF_GEOKEY_VERTICAL_DATUM               = 4098,
    NVTIFF_GEOKEY_VERTICAL_UNITS               = 4099,

    NVTIFF_GEOKEY_BASE                         = 32768,
    NVTIFF_GEOKEY_END                          = 65535
} nvtiffGeoKey_t;

nvtiffGeoKey_t corresponds to various geo keys listed in the GeoTIFF specification. User can refer to the GeoTIFF specification for additional details.

GeoTIFF Key Datatype#

typedef enum nvtiffGeoKeyDataType {
    NVTIFF_GEOKEY_TYPE_SHORT=1,
    NVTIFF_GEOKEY_TYPE_ASCII=2,
    NVTIFF_GEOKEY_TYPE_DOUBLE=3,
    NVTIFF_GEOKEY_TYPE_UNKNOWN=4
} nvtiffGeoKeyDataType_t;

nvtiffGeoKeyDataType_t corresponds to a datatype for a geo key.

Device Allocator Interface#

typedef int (*nvtiffDeviceMallocAsync)(void* ctx, void **ptr, size_t size, cudaStream_t stream);

typedef int (*nvtiffDeviceFreeAsync)(void* ctx, void *ptr, size_t size, cudaStream_t stream);

typedef struct {
    nvtiffDeviceMallocAsync device_malloc;
    nvtiffDeviceFreeAsync device_free;
    void *device_ctx;
} nvtiffDeviceAllocator_t;

Custom device allocator supports stream ordered allocation and user defined context information *device_ctx. When invoking the device allocators, nvTiff will pass *device_ctx as input to the device allocator.

Pinned Allocator Interface#

typedef int (*nvtiffPinnedMallocAsync)(void* ctx, void **ptr, size_t size, cudaStream_t stream);

typedef int (*nvtiffPinnedFreeAsync)(void* ctx, void *ptr, size_t size, cudaStream_t stream);

typedef struct {
    nvtiffPinnedMallocAsync pinned_malloc;
    nvtiffPinnedFreeAsync pinned_free;
    void *pinned_ctx;
} nvtiffPinnedAllocator_t;

Custom pinned allocator supports stream ordered allocation and user defined context information *pinned_ctx. When invoking the pinned allocators, nvTiff will pass *pinned_ctx as input to the pinned allocator.

Image Type#

typedef enum {
    NVTIFF_IMAGETYPE_REDUCED_IMAGE = 0b0001,
    NVTIFF_IMAGETYPE_PAGE          = 0b0010,
    NVTIFF_IMAGETYPE_MASK          = 0b0100,
    NVTIFF_IMAGETYPE_ENUM_FORCE_UINT32 =  0xFFFFFFFF,
} nvtiffImageType;
typedef uint32_t nvtiffImageType_t;

nvtiffImageType enum corresponds to the NewSubfiletype (254) tag defined in the TIFF specification.

Compression Type#

typedef enum nvtiffCompression {
    NVTIFF_COMPRESSION_UNKNOWN = 0,
    NVTIFF_COMPRESSION_NONE = 1,
    NVTIFF_COMPRESSION_LZW = 5,
    NVTIFF_COMPRESSION_JPEG = 7,
    NVTIFF_COMPRESSION_ADOBE_DEFLATE = 8,
    NVTIFF_COMPRESSION_DEFLATE = 32946,
    NVTIFF_COMPRESSION_APERIO_JP2000_YCC = 33003,
    NVTIFF_COMPRESSION_APERIO_JP2000_RGB = 33005,
    NVTIFF_COMPRESSION_JP2000 = 34712
} nvtiffCompression_t;

nvtiffCompression_t enum corresponds to the Compression (259) tag defined in the TIFF specification.

Photometric Interpretation#

typedef enum nvtiffPhotometricInt {
    NVTIFF_PHOTOMETRIC_UNKNOWN    = -1,
    NVTIFF_PHOTOMETRIC_MINISWHITE = 0,
    NVTIFF_PHOTOMETRIC_MINISBLACK = 1,
    NVTIFF_PHOTOMETRIC_RGB        = 2,
    NVTIFF_PHOTOMETRIC_PALETTE    = 3,
    NVTIFF_PHOTOMETRIC_MASK       = 4,
    NVTIFF_PHOTOMETRIC_SEPARATED  = 5,
    NVTIFF_PHOTOMETRIC_YCBCR      = 6,
}nvtiffPhotometricInt_t;

nvtiffPhotometricInt_t enum corresponds to the PhotometricInterpretation (262) tag defined in the TIFF specification.

Planar Configuration#

typedef enum nvtiffPlanarConfig {
  NVTIFF_PHOTOMETRIC_UNKNOWN    = -1,
  NVTIFF_PHOTOMETRIC_MINISWHITE = 0,
  NVTIFF_PHOTOMETRIC_MINISBLACK = 1,
  NVTIFF_PHOTOMETRIC_RGB        = 2,
  NVTIFF_PHOTOMETRIC_PALETTE    = 3,
  NVTIFF_PHOTOMETRIC_MASK       = 4,
  NVTIFF_PHOTOMETRIC_SEPARATED  = 5,
  NVTIFF_PHOTOMETRIC_YCBCR      = 6,
} nvtiffPlanarConfig_t;

nvtiffPlanarConfig_t enum corresponds to the PlanarConfiguration (284) tag defined in the TIFF specification.

Sample Format#

typedef enum nvtiffSampleFormat {
    NVTIFF_SAMPLEFORMAT_UNKNOWN = 0,
    NVTIFF_SAMPLEFORMAT_UINT    = 1,
    NVTIFF_SAMPLEFORMAT_INT        = 2,
    NVTIFF_SAMPLEFORMAT_IEEEFP    = 3,
    NVTIFF_SAMPLEFORMAT_VOID        = 4,
    NVTIFF_SAMPLEFORMAT_COMPLEXINT    = 5,
    NVTIFF_SAMPLEFORMAT_COMPLEXIEEEFP    = 6
} nvtiffSampleFormat_t;

nvtiffSampleFormat_t enum corresponds to the SampleFormat (339) tag defined in the TIFF specification.

TIFF Image Information#

typedef struct nvtiffImageInfo {
    nvtiffImageType_t image_type;
    uint32_t image_width;
    uint32_t image_height;
    nvtiffCompression_t compression;
    nvtiffPhotometricInt_t photometric_int;
    nvtiffPlanarConfig_t planar_config;
    uint16_t samples_per_pixel;
    uint16_t bits_per_pixel; // SUM(bits_per_sample)
    uint16_t bits_per_sample[MAX_NUM_SAMPLES];
    nvtiffSampleFormat_t sample_format[MAX_NUM_SAMPLES];
} nvtiffImageInfo_t;

nvtiffImageInfo_t contains some additional metadata of an image stored in a TIFF file.

TIFF Image Data#

typedef struct {
    void **plane_data;
    size_t *plane_pitch_bytes;
    uint32_t num_planes;
} nvtiffImage_t;

nvtiffImage_t contains output image data buffers used by _nvtiffdecodeimageex-label.

TIFF Geometry Type#

typedef enum nvtiffImageGeometryType {
    NVTIFF_IMAGE_STRIPED = 0,
    NVTIFF_IMAGE_TILED = 1,
} nvtiffImageGeometryType_t;

nvtiffImageGeometryType_t specifies whether a tiff file uses strips or tiles

TIFF Geometry Information#

typedef struct nvtiffImageGeometry {
    nvtiffImageGeometryType_t type;
    uint32_t image_depth;
    uint32_t strile_width;            // strile_width = image_width for strips
    uint32_t strile_height;
    uint32_t strile_depth;            // strile_depth = image_depth for strips
    uint32_t num_striles_per_plane;
    uint32_t num_striles;
} nvtiffImageGeometry_t;

Stores image geometry along with strip/tile dimensions. When the geometry type is NVTIFF_IMAGE_STRIPED, strile_width is to image width.

Decode Output Format#

typedef enum nvtiffOutputFormat {
    NVTIFF_OUTPUT_UNCHANGED_I    = 0,   // Interleaved channels
    NVTIFF_OUTPUT_RGB_I_UINT8    = 1,   // Interleaved RGB with 8 bits per channel
    NVTIFF_OUTPUT_RGB_I_UINT16   = 2,   // Interleaved RGB with 16 bits per channel
} nvtiffOutputFormat_t;

nvtiffOutputFormat_t is used to specify the decode output format.

Decoder Handle#

struct nvtiffDecoder;
typedef struct nvtiffDecoder* nvtiffDecoder_t;

nvtiffDecoder_t stores intermediate decode buffers used in decoding.

Bitstream/File Handle#

struct nvtiffStream;
typedef struct nvtiffStream* nvtiffStream_t;

nvtiffStream_t is used for parsing a tiff file. Tiff metadata can be extracted using APIs defined in Parser API Reference.

Decode Parameters Handle#

struct nvtiffDecodeParams;
typedef struct nvtiffDecodeParams* nvtiffDecodeParams_t;

nvtiffDecodeParams_t is used to specify decode output parameters such as region of interest to decode, output format.

Encoder Handle#

struct nvtiffEncoder;
typedef struct nvtiffEncoder* nvtiffEncoder_t;

nvtiffEncoder_t stores intermediate buffers used in encoding.

Encode Parameters Handle#

struct nvtiffEncodeParams;
typedef struct nvtiffEncodeParams* nvtiffEncodeParams_t;

nvtiffEncodeParams_t is used to specify encode input parameters such as image and pixel information, compression method, and GeoTIFF tags and keys.