Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#1722 closed defect (fixed)

[PATCH] Fix GeoTIFF detection of already computed overview levels

Reported by: Even Rouault Owned by: warmerdam
Priority: normal Milestone: 1.4.3
Component: GDAL_Raster Version: 1.4.2
Severity: normal Keywords: geotiff overviews
Cc:

Description

Use case : 0) I have a GTiff 121x121 Int16. 1) gdaladdo -r average test.tiff 2 4 8 16 2) gdaladdo -r average test.tiff 2 4 8 16. Yeah, this is stupid... 3) gdaladdo -r average test.tiff 2 4 8 16. Segfault

Currently, the 1/16 overview is wrongly detected as 1/15 when doing 2). This lead to segfault when doing 3).

The following patch simulates the new X size of the requested overview and compares it with the X size of the existing overviews, instead of comparing the reduction ratios.

Attachments (1)

gdal-1.4.2-fix-gtiff-redundant-overview-level-detection.patch (640 bytes ) - added by Even Rouault 17 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by warmerdam, 17 years ago

Resolution: fixed
Status: newclosed

I see your point! I've used a slightly different patch which I think amounts to the same thing but for clarity and similarity to other similar code:

Index: geotiff.cpp
===================================================================
--- geotiff.cpp	(revision 11816)
+++ geotiff.cpp	(working copy)
@@ -2090,7 +2090,9 @@
             nOvFactor = (int) 
                 (0.5 + GetRasterXSize() / (double) poODS->GetRasterXSize());
 
-            if( nOvFactor == panOverviewList[i] )
+            if( nOvFactor == panOverviewList[i] 
+                || nOvFactor == TIFF_OvLevelAdjust( panOverviewList[i],
+                                                    GetRasterXSize() ) )
                 panOverviewList[i] *= -1;
         }

The patch is applied in trunk, 1.4 and 1.4-esri branches.

comment:2 by warmerdam, 17 years ago

Component: defaultGDAL_Raster
Keywords: overviews added
Milestone: 1.4.3

comment:3 by Even Rouault, 17 years ago

Yes, your patch fixes the problem too on my use case.

Note: See TracTickets for help on using tickets.