Skip to content

Commit c3b4b65

Browse files
authored
Merge pull request OSGeo#11562 from rouault/fix_11555
GTiff mask overview: fix vertical shift in internal mask overview computation
2 parents f889151 + 616c60f commit c3b4b65

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

autotest/gcore/data/test_11555.tif

33.2 KB
Binary file not shown.

autotest/gcore/tiff_ovr.py

+35
Original file line numberDiff line numberDiff line change
@@ -2995,3 +2995,38 @@ def test_tiff_ovr_JXL_ALPHA_DISTANCE_OVERVIEW(tmp_vsimem):
29952995
assert ds.GetRasterBand(4).Checksum() != cs4
29962996
del ds
29972997
gdal.Unlink(tmpfilename + ".ovr")
2998+
2999+
3000+
###############################################################################
3001+
# Test fix for https://github.com/OSGeo/gdal/issues/11555
3002+
3003+
3004+
def test_tiff_ovr_internal_mask_issue_11555(tmp_vsimem):
3005+
3006+
if "debug build" in gdal.VersionInfo("--version") and "CI" in os.environ:
3007+
pytest.skip("test skipped on CI for debug builds (to keep things fast)")
3008+
3009+
tmpfilename = str(tmp_vsimem / "test.tif")
3010+
gdal.FileFromMemBuffer(tmpfilename, open("data/test_11555.tif", "rb").read())
3011+
3012+
ds = gdal.Open(tmpfilename, gdal.GA_Update)
3013+
ds.BuildOverviews("bilinear", [2])
3014+
del ds
3015+
3016+
ds = gdal.Open(tmpfilename)
3017+
3018+
# Check that we have non-zero data when mask = 255
3019+
assert ds.GetRasterBand(1).GetOverview(0).ReadRaster(0, 5270, 1, 1) == b"\x7F"
3020+
assert ds.GetRasterBand(2).GetOverview(0).ReadRaster(0, 5270, 1, 1) == b"\x7F"
3021+
assert (
3022+
ds.GetRasterBand(1).GetMaskBand().GetOverview(0).ReadRaster(0, 5270, 1, 1)
3023+
== b"\xFF"
3024+
)
3025+
3026+
# Check that we have zero data when mask = 0
3027+
assert ds.GetRasterBand(1).GetOverview(0).ReadRaster(0, 5271, 1, 1) == b"\x00"
3028+
assert ds.GetRasterBand(2).GetOverview(0).ReadRaster(0, 5271, 1, 1) == b"\x00"
3029+
assert (
3030+
ds.GetRasterBand(1).GetMaskBand().GetOverview(0).ReadRaster(0, 5271, 1, 1)
3031+
== b"\x00"
3032+
)

gcore/overview.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4964,7 +4964,7 @@ CPLErr GDALRegenerateOverviewsEx(GDALRasterBandH hSrcBand, int nOverviewCount,
49644964
poJob->nSrcHeight = nHeight;
49654965
poJob->args.nChunkXOff = 0;
49664966
poJob->args.nChunkXSize = nWidth;
4967-
poJob->args.nChunkYOff = nChunkYOff;
4967+
poJob->args.nChunkYOff = nChunkYOffQueried;
49684968
poJob->args.nChunkYSize = nChunkYSizeQueried;
49694969
poJob->nDstWidth = nDstWidth;
49704970
poJob->args.nDstXOff = 0;

0 commit comments

Comments
 (0)