Repository navigation
feat: Add big endian fixtures with predictor 2 and predictor 3 - #73
Merged
kylebarron merged 1 commit intoOct 5, 2026
Merged
Conversation
james-willis
marked this pull request as ready for review
October 1, 2026 21:03
james-willis
force-pushed
the
jw/big-endian-fixtures
branch
from
October 1, 2026 21:43
06cdf41 to
788ee9f
Compare
This was referenced Oct 1, 2026
GDAL's COG driver can't write big endian files, so these are rewritten from a little endian COG through the GTiff driver with COPY_SRC_OVERVIEWS, which keeps the COG layout. - uint16_1band_lzw_block128_predictor2_big_endian: readers must swap samples to native order before undoing horizontal differencing. - float32_1band_deflate_block64_predictor3_big_endian: predictor 3 byte planes are most significant byte first in every file, so readers must not swap these samples. A test checks that both files are MM, carry their predictor on every IFD, and match their little endian source at every level.
james-willis
force-pushed
the
jw/big-endian-fixtures
branch
from
October 1, 2026 22:16
788ee9f to
37b239b
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fixtures, generation path, metadata, and regression coverage consistently satisfy the stated endian and predictor requirements.
Review effort: Balanced
Findings: None
What changed in this PR
Adds big-endian predictor fixtures to validate downstream GeoTIFF decoding behavior.
Changes:
- Adds Predictor 2 and Predictor 3 big-endian COG fixtures.
- Adds reusable endian-rewriting logic and fixture validation tests.
- Configures pytest imports for generator modules.
| File | Description |
|---|---|
pyproject.toml |
Adds the repository root to pytest’s Python path. |
rasterio_generated/write_utils.py |
Adds the big-endian COG rewrite helper. |
tests/test_big_endian.py |
Validates byte order, predictors, and pixels. |
rasterio_generated/fixtures/uint16_1band_lzw_block128_predictor2_big_endian.py |
Generates the Predictor 2 fixture. |
rasterio_generated/fixtures/uint16_1band_lzw_block128_predictor2_big_endian.tif |
Provides the generated uint16 fixture. |
rasterio_generated/fixtures/uint16_1band_lzw_block128_predictor2_big_endian_info.md |
Records uint16 fixture metadata. |
rasterio_generated/fixtures/float32_1band_deflate_block64_predictor3_big_endian.py |
Generates the Predictor 3 fixture. |
rasterio_generated/fixtures/float32_1band_deflate_block64_predictor3_big_endian.tif |
Provides the generated float32 fixture. |
rasterio_generated/fixtures/float32_1band_deflate_block64_predictor3_big_endian_info.md |
Records float32 fixture metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
kylebarron
added a commit
that referenced
this pull request
Oct 5, 2026
uint16_1band_lzw_block128_predictor2_big_endian is rewritten from uint16_1band_lzw_block128_predictor2. #73 was branched before #76 changed that source to 256x256 with 128x128 tiles and triangle wave data, and was merged without rebasing. So the committed file still held the old 128x128 source with 64x64 tiles, and the "generated files are up to date" check on main failed. Regenerate the file and its info, and fix the docstring to give the new size and tiling. Co-authored-by: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
to developmentseed/deck.gl-raster
that referenced
this pull request
Oct 13, 2026
) Closes #686. Big endian (`MM`) TIFFs decoded to byte-swapped pixel values: `toTypedArray` views the decoded bytes in the platform's byte order, and `DecoderMetadata` didn't carry the file's. ### Changes - `DecoderMetadata` gains an optional `littleEndian` (default `true`, so existing callers of `decode()` are unaffected). `fetch.ts` sets it from `image.tiff.isLittleEndian` for both data and mask tiles. - `decode()` byte-swaps samples wider than 8 bits from big endian files, **before** `applyPredictor`, since horizontal differencing (predictor 2) has to accumulate native-order integers. - Predictor 3 is excluded: its byte planes are most significant byte first in every file (TIFF Technical Note 3), and `decodeRowFloatingPoint` already reassembles them in platform order. - The swap writes to a new buffer, because the uncompressed decoder returns the caller's bytes, which may be shared with the block cache. - Codecs that return typed pixels (LERC, JPEG, WebP) don't go through this path and are unchanged. ### Tests Three unit tests in `decode.test.ts` build big endian tiles from known values: - float32, no predictor (also asserts the input buffer is untouched) - uint16, predictor 2 - float32, predictor 3, decoded as both `II` and `MM`, which must agree The first two fail on main; the third fails if the swap is applied to predictor 3. `pnpm typecheck` and `biome check` are clean. The second commit bumps `fixtures/geotiff-test-data` to pick up its big endian fixtures (developmentseed/geotiff-test-data#73, #77) and adds both to `integration-rasterio.test.ts`: - `uint16_1band_lzw_block128_predictor2_big_endian`: fails `tile pixel data matches` on main, passes here. - `float32_1band_deflate_block64_predictor3_big_endian`: passes either way, and guards against swapping predictor 3 byte planes. With `pixi run generate-npy` as in CI, the integration suite passes 19/19 here and fails only the uint16 big endian case against main's `decode.ts` / `fetch.ts`. --------- Co-authored-by: Kyle Barron <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Adds two big endian (
MM) fixtures, as requested in developmentseed/deck.gl-raster#687.uint16_1band_lzw_block128_predictor2_big_endianfloat32_1band_deflate_block64_predictor3_big_endianBoth are 128×128 with 64×64 tiles and one overview, and pass
rio cogeo validate.How they're made
GDAL's COG driver has no
ENDIANNESSoption, so a newrewrite_big_endianhelper inwrite_utils.pycopies a little endian COG through the GTiff driver withCOPY_SRC_OVERVIEWS=YESandENDIANNESS=BIG, which keeps the COG layout. The uint16 fixture is rewritten fromuint16_1band_lzw_block128_predictor2; the float32 one from anp.linspaceCOG built the same way asfloat32_1band_lerc_block32.Tiling, compression and predictor are copied from the source, which relies on #74 (
write_cognow writes the predictor into the COG).Tests
tests/test_big_endian.pychecks, for each fixture, that the file starts withMM, that every IFD carries the expected predictor (viatifffile), and that every level matches its little endian source as read by rasterio.pyproject.tomlgainspythonpath = ["."]so the test can import the generators.pixi run checkandpixi run testpass locally, and regenerating is byte-for-byte stable.Downstream check
With deck.gl-raster's fixtures submodule pointed at this branch and both fixtures added to
integration-rasterio.test.ts:tile pixel data matches, and the predictor 3 fixture passes, as expected.