Skip to content

Commit

Permalink
Merge branch 'master' of github.com:OSGeo/gdal
Browse files Browse the repository at this point in the history
* 'master' of github.com:OSGeo/gdal:
  use per band mask in overviews with nodatavalue and average (fix OSGeo#3913)  when computing the overviews and nodatavalue is used  the mask must be computed per band
  • Loading branch information
a0x8o committed Jun 10, 2022
1 parent 68bb5c6 commit 3e786b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions autotest/gcore/tiff_ovr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,11 @@ def test_tiff_ovr_color_table_bug_3336_bis():
def test_tiff_ovr_nodata_multiband():

numpy = pytest.importorskip('numpy')
<<<<<<< HEAD

=======

>>>>>>> 7355095be4 (Merge branch 'master' of github.com:OSGeo/gdal)
temp_path = '/vsimem/test.tif'
ds = gdal.GetDriverByName('GTiff').Create(temp_path, 4, 4, 2, gdal.GDT_Float32)
ds.GetRasterBand(1).SetNoDataValue(-10000)
Expand All @@ -2067,14 +2071,22 @@ def test_tiff_ovr_nodata_multiband():
assert ds.GetRasterBand(1).GetOverviewCount() == 1, \
'Overview could not be generated'

<<<<<<< HEAD
pix = ds.GetRasterBand(1).GetOverview(0).ReadAsArray(win_xsize=1, win_ysize=1)
assert pix[0,0] == 2.0

pix = ds.GetRasterBand(2).GetOverview(0).ReadAsArray(win_xsize=1, win_ysize=1)
=======
pix = ds.GetRasterBand(1).GetOverview(0).ReadAsArray(win_xsize=1, win_ysize=1)
assert pix[0,0] == 2.0

pix = ds.GetRasterBand(2).GetOverview(0).ReadAsArray(win_xsize=1, win_ysize=1)
>>>>>>> 7355095be4 (Merge branch 'master' of github.com:OSGeo/gdal)
assert pix[0,0] == 3.0

ds = None

<<<<<<< HEAD
###############################################################################

@pytest.mark.parametrize("external_ovr", [False,True])
Expand Down Expand Up @@ -2224,6 +2236,8 @@ def test_tiff_ovr_uint64():
del ds
gdal.GetDriverByName('GTiff').Delete(temp_path)

=======
>>>>>>> 7355095be4 (Merge branch 'master' of github.com:OSGeo/gdal)

###############################################################################
# Cleanup
Expand Down
9 changes: 9 additions & 0 deletions gcore/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5285,7 +5285,12 @@ GDALRegenerateOverviewsMultiBand( int nBands, GDALRasterBand** papoSrcBands,

if( bUseNoDataMask && eErr == CE_None )
{
<<<<<<< HEAD:gcore/overview.cpp
auto poMaskBand = poSrcBand->IsMaskBand() ? poSrcBand : poSrcBand->GetMaskBand();
=======
const bool bUseSrcAsMaskBand = bIsMask || papoSrcBands[iBand]->GetColorInterpretation() == GCI_AlphaBand;
auto poMaskBand = bUseSrcAsMaskBand ? poSrcBand : poSrcBand->GetMaskBand();
>>>>>>> 7355095be4 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/gcore/overview.cpp
eErr = poMaskBand->RasterIO(
GF_Read,
nChunkXOffQueried, nChunkYOffQueried,
Expand Down Expand Up @@ -5361,7 +5366,11 @@ GDALRegenerateOverviewsMultiBand( int nBands, GDALRasterBand** papoSrcBands,
for( int iBand = 0; iBand < nBands; ++iBand )
{
CPLFree(apaChunk[iBand]);
<<<<<<< HEAD:gcore/overview.cpp
papapoOverviewBands[iBand][iOverview]->FlushCache(false);
=======
papapoOverviewBands[iBand][iOverview]->FlushCache();
>>>>>>> 7355095be4 (Merge branch 'master' of github.com:OSGeo/gdal):gdal/gcore/overview.cpp

CPLFree(apabyChunkNoDataMask[iBand]);
}
Expand Down

0 comments on commit 3e786b1

Please sign in to comment.