Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTiff driver: CreateCopy doesn't preserve mask on band interleaved COGs #11851

Closed
orglofch opened this issue Feb 14, 2025 · 2 comments · Fixed by #11857
Closed

GTiff driver: CreateCopy doesn't preserve mask on band interleaved COGs #11851

orglofch opened this issue Feb 14, 2025 · 2 comments · Fixed by #11857
Assignees

Comments

@orglofch
Copy link

What is the bug?

After create a COG via CreateCopy() with the GTIFF driver and an explicit mask, the mask read back doesn't preserve the original bytes. When we read back the mask, the mask is expanded from the 1-bit mask to the 8-bit mask through the pathway of gtiffoddbitsband.h which is the correct path. However, the mask is not a 1-bit mask when I add logging in this file; instead, it's the original 8-bit mask (with 255s and 0s). So when it gets expanded to 8-bits, it's no longer the original mask:
E.g.,
The mask 255 0 255 255 is stored verbatim and becomes 255 255 ... 255 255 0 0 ... 0 0 255 255
Instead of being stored as 128 (10000000) 192 (11000000) which becomes 255 0 255 255.

So my guess is that somewhere along the line we either copy the mask without turning it back into a bitmask, or we lose metadata tracking that the mask is encoded a certain way.

The issue does not occur when either COPY_SRC_OVERVIEWS="YES" is removed or INTERLEAVE is set to PIXEL (it only fails on band interleaving). This is using the 'GTiff' driver.

Steps to reproduce the issue

Example gist: https://gist.github.com/orglofch/40cf4d9136978b0384141cc74d1039b6.

The final mask is 0 0 255 255 instead of 0 255 255 255.

Versions and provenance

In current master head. This failure only started occurring after 3bdc81a.

Additional context

No response

@rouault
Copy link
Member

rouault commented Feb 17, 2025

fix in #11857

@schwehr
Copy link
Member

schwehr commented Feb 17, 2025

Thank you! I've confirmed this fixes the original issue @orglofch was having that the unit test was representing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants