Skip to content

Conversation

@lgritz
Copy link
Collaborator

@lgritz lgritz commented Feb 1, 2025

The implementation of IB::pixeltype() was:

  • Make sure at least the spec had been read (lazy read).
  • If there are "local pixels", return the pixel type from the spec, otherwise return the cache pixel type.

But there is a flaw in this logic: If only the metadata has been read but not the pixels, the local pixels might not be allocated yet, but also there is not a cache and no cached pixel type, so pixeltype() will return UNKNOWN even though we do already know what type of pixels will be stored when they are eventually read.

The correct logic is:

  • Make sure at least the spec had been read (lazy read).
  • If it's a cached image, return the cache pixel type, otherwise return the pixel type from the spec (which will be correct because we definitely have read the spec at this point).

Also, for legit cached images, ensure that cachedpixeltype is set upon read_spec() and doesn't have to wait for a full read().

The implementation of IB::pixeltype() was:

- Make sure at least the spec had been read (lazy read).
- If there are "local pixels", return the pixel type from the spec,
  otherwise return the cache pixel type.

But there is a flaw in this logic: If only the metadata has been read
but not the pixels, the local pixels might not be allocated yet, but
also there is not a cache and no cached pixel type, so pixeltype()
will return UNKNOWN even though we do already know what type of pixels
will be stored when they are eventually read.

The correct logic is:

- Make sure at least the spec had been read (lazy read).
- If it's a cached image, return the cache pixel type, otherwise
  return the pixel type from the spec (which will be correct because
  we definitely have read the spec at this point).

Also, for legit cached images, ensure that cachedpixeltype is set upon
read_spec() and doesn't have to wait for a full read().

Signed-off-by: Larry Gritz <[email protected]>
@virtualritz
Copy link

This fixes the issue I reported on Slack. Cheers!

@lgritz lgritz merged commit c4873d5 into AcademySoftwareFoundation:main Feb 2, 2025
27 checks passed
lgritz added a commit to lgritz/OpenImageIO that referenced this pull request Feb 3, 2025
…cademySoftwareFoundation#4614)

The implementation of IB::pixeltype() was:

- Make sure at least the spec had been read (lazy read).
- If there are "local pixels", return the pixel type from the spec,
otherwise return the cache pixel type.

But there is a flaw in this logic: If only the metadata has been read
but not the pixels, the local pixels might not be allocated yet, but
also there is not a cache and no cached pixel type, so pixeltype() will
return UNKNOWN even though we do already know what type of pixels will
be stored when they are eventually read.

The correct logic is:

- Make sure at least the spec had been read (lazy read).
- If it's a cached image, return the cache pixel type, otherwise return
the pixel type from the spec (which will be correct because we
definitely have read the spec at this point).

Also, for legit cached images, ensure that cachedpixeltype is set upon
read_spec() and doesn't have to wait for a full read().

Signed-off-by: Larry Gritz <[email protected]>
@lgritz lgritz deleted the lg-pixeltype branch February 8, 2025 19:51
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 17, 2025
…cademySoftwareFoundation#4614)

The implementation of IB::pixeltype() was:

- Make sure at least the spec had been read (lazy read).
- If there are "local pixels", return the pixel type from the spec,
otherwise return the cache pixel type.

But there is a flaw in this logic: If only the metadata has been read
but not the pixels, the local pixels might not be allocated yet, but
also there is not a cache and no cached pixel type, so pixeltype() will
return UNKNOWN even though we do already know what type of pixels will
be stored when they are eventually read.

The correct logic is:

- Make sure at least the spec had been read (lazy read).
- If it's a cached image, return the cache pixel type, otherwise return
the pixel type from the spec (which will be correct because we
definitely have read the spec at this point).

Also, for legit cached images, ensure that cachedpixeltype is set upon
read_spec() and doesn't have to wait for a full read().

Signed-off-by: Larry Gritz <[email protected]>
Signed-off-by: Scott Wilson <[email protected]>
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 18, 2025
…cademySoftwareFoundation#4614)

The implementation of IB::pixeltype() was:

- Make sure at least the spec had been read (lazy read).
- If there are "local pixels", return the pixel type from the spec,
otherwise return the cache pixel type.

But there is a flaw in this logic: If only the metadata has been read
but not the pixels, the local pixels might not be allocated yet, but
also there is not a cache and no cached pixel type, so pixeltype() will
return UNKNOWN even though we do already know what type of pixels will
be stored when they are eventually read.

The correct logic is:

- Make sure at least the spec had been read (lazy read).
- If it's a cached image, return the cache pixel type, otherwise return
the pixel type from the spec (which will be correct because we
definitely have read the spec at this point).

Also, for legit cached images, ensure that cachedpixeltype is set upon
read_spec() and doesn't have to wait for a full read().

Signed-off-by: Larry Gritz <[email protected]>
Signed-off-by: Scott Wilson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants