Decode TIFF predictor=3 by file byte order so big-endian floats read exactly#1500
Merged
brendancol merged 4 commits intomainfrom May 6, 2026
Merged
Decode TIFF predictor=3 by file byte order so big-endian floats read exactly#1500brendancol merged 4 commits intomainfrom
brendancol merged 4 commits intomainfrom
Conversation
… floating-point TIFFs read exactly The floating-point predictor (TIFF Tech Note 3) byte-swizzles each row into bytes_per_sample lanes with the most significant byte in lane 0. The decoder un-transposed those lanes assuming the output was always little-endian: it placed the MSB at byte index bps-1 of each output sample. Big-endian predictor=3 files therefore decoded into samples with the bytes in the wrong order; the result still came back as a clean float32/float64 array, just with garbage values. The fix threads the file's byte order into the un-transpose step on both CPU and GPU paths. For big-endian files the MSB now lands at byte index 0 of each output sample. The little-endian path is unchanged. The GPU output also needed a final byteswap when the file was big-endian: the GPU decode keeps bytes in the file's order through predictor decode and tile assembly, but cupy interprets the resulting view as native (little-endian) byte order. New tests (test_predictor3_big_endian.py) decode tifffile/imagecodecs- encoded big-endian predictor=3 float32 and float64 files (strip and tiled layouts, plus a GPU parity check) and confirm the existing little-endian round-trip still works.
Contributor
Author
|
@copilot resolve the merge conflicts in this pull request |
…dian # Conflicts: # xrspatial/geotiff/__init__.py # xrspatial/geotiff/_reader.py Co-authored-by: brendancol <433221+brendancol@users.noreply.github.com>
Contributor
Resolved in 32b7e3c. Two conflicts:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bpslanes, MSB first. The decoder un-transposed those lanes assuming the output was always little-endian: MSB landed at byte indexbps-1of each output sample. Big-endian predictor=3 files therefore decoded into samples with the bytes in the wrong order, which silently produced garbage float values - the array still came back as a clean float32/float64.Repro before the fix
Test plan
test_predictor3_big_endian.py: float32 and float64 BE round-trip