Skip to content
This repository was archived by the owner on Jul 22, 2018. It is now read-only.
This repository was archived by the owner on Jul 22, 2018. It is now read-only.

Implement a safer TiffEntry/CiffEntry way of accessing data #142

@pedrocr

Description

@pedrocr

After the work in PR #141 I've come up with a sketch for a further API change to achieve two things at once:

  1. Make the TiffEntry/CiffEntry APIs safer against out of bounds access
  2. Finally remove the TiffIFD/TiffIFDBE split, as discussed in PR Rename 'BE' to "Swap", #27

So here's the basic sketch:

  • Remove getIntArray()/getShortArray() functions and instead make getInt()/getShort()/getData() take an optional integer argument that's the array offset (and in the case of getData() a count as well)
  • Make TiffEntry/CiffEntry no longer have a pointer to data but instead just keep around the reference to the underlying FileMap
  • Move the get4BE() and friends macros into the FileMap API
  • Have TiffEntry/CiffEntry know the host and file endianness (pushing into FileMap is also possible but sometimes there are BE bits inside a LE file and vice-versa)
  • Now when doing getInt()/getShort()/getData() just call into FileMap with getNBE()/getNLE()/getData() insuring proper bounds checks. It is also endian clean so there's no need to keep around the swapped versions of TiffIFD/TiffEntry. It also avoids the memory copying in TiffEntryBE.

Since the TiffEntry API is used for metadata only the performance implications should be minimal if any. How does the plan sound?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions