Ticket #1722 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Fix GeoTIFF detection of already computed overview levels

Reported by: rouault Assigned to: 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

gdal-1.4.2-fix-gtiff-redundant-overview-level-detection.patch (0.6 kB) - added by rouault on 07/29/07 10:49:56.

Change History

07/29/07 10:49:56 changed by rouault

  • attachment gdal-1.4.2-fix-gtiff-redundant-overview-level-detection.patch added.

07/31/07 12:27:55 changed by warmerdam

  • status changed from new to closed.
  • resolution set to fixed.

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.

07/31/07 12:28:22 changed by warmerdam

  • keywords changed from geotiff to geotiff overviews.
  • component changed from default to GDAL_Raster.
  • milestone set to 1.4.3.

07/31/07 14:22:46 changed by rouault

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