From 169661333fc86fce62944e449efac0bc631d119a Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 12 Jul 2016 08:44:23 +0000 Subject: [PATCH 1/2] ROI_PAC: fix computation of line offset for multi-band BIP files, and warn if detecting a wrong file produced by GDAL >= 2.0.0 (patch by mahze, fixes #6591) git-svn-id: https://svn.osgeo.org/gdal/trunk@34638 f0d54148-0727-0410-94bb-9a71ac55c965 --- gdal/frmts/raw/roipacdataset.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gdal/frmts/raw/roipacdataset.cpp b/gdal/frmts/raw/roipacdataset.cpp index 4a6b28fcf720..7cca5300ef34 100644 --- a/gdal/frmts/raw/roipacdataset.cpp +++ b/gdal/frmts/raw/roipacdataset.cpp @@ -354,8 +354,25 @@ GDALDataset *ROIPACDataset::Open( GDALOpenInfo *poOpenInfo ) } else { /* PIXEL */ nPixelOffset = GDALGetDataTypeSizeBytes(eDataType) * nBands; - nLineOffset = nPixelOffset * nWidth * nBands; + nLineOffset = nPixelOffset * nWidth; nBandOffset = GDALGetDataTypeSizeBytes(eDataType); + + if( nBands > 1 ) + { + // GDAL 2.0.[0-3] and 2.1.0 had a value of nLineOffset that was + // equal to the theoretical nLineOffset multiplied by nBands... + VSIFSeekL( poDS->fpImage, 0, SEEK_END ); + const GUIntBig nWrongFileSize = GDALGetDataTypeSizeBytes(eDataType) * + nWidth * (static_cast(nFileLength - 1) * nBands * nBands + nBands); + if( VSIFTellL( poDS->fpImage ) == nWrongFileSize ) + { + CPLError(CE_Warning, CPLE_AppDefined, + "This file has been incorrectly generated by an older " + "GDAL version whose line offset computation was erroneous. " + "Taking that into account, but the file should be re-encoded ideally"); + nLineOffset = nLineOffset * nBands; + } + } } poDS->nBands = nBands; for( int b = 0; b < nBands; b++ ) From d9ba836c38c1c71a918e9fa7278f1334bc2396d1 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 12 Jul 2016 10:54:28 +0000 Subject: [PATCH 2/2] Rename libqhull into internal_libqhull to avoid confusing in includes when there's a /usr/include/libqhull (fixes #6590) git-svn-id: https://svn.osgeo.org/gdal/trunk@34641 f0d54148-0727-0410-94bb-9a71ac55c965 --- .../COPYING.txt | 0 .../README.txt | 0 .../{libqhull => internal_libqhull}/geom.c | 0 .../{libqhull => internal_libqhull}/geom.h | 0 .../{libqhull => internal_libqhull}/geom2.c | 0 .../{libqhull => internal_libqhull}/global.c | 0 gdal/alg/{libqhull => internal_libqhull}/io.c | 0 gdal/alg/{libqhull => internal_libqhull}/io.h | 0 .../libqhull.c | 0 .../libqhull.h | 0 .../alg/{libqhull => internal_libqhull}/mem.c | 0 .../alg/{libqhull => internal_libqhull}/mem.h | 0 .../{libqhull => internal_libqhull}/merge.c | 0 .../{libqhull => internal_libqhull}/merge.h | 0 .../{libqhull => internal_libqhull}/poly.c | 0 .../{libqhull => internal_libqhull}/poly.h | 0 .../{libqhull => internal_libqhull}/poly2.c | 0 .../{libqhull => internal_libqhull}/qhull_a.h | 0 .../{libqhull => internal_libqhull}/qset.c | 0 .../{libqhull => internal_libqhull}/qset.h | 0 .../{libqhull => internal_libqhull}/random.c | 0 .../{libqhull => internal_libqhull}/random.h | 0 .../{libqhull => internal_libqhull}/rboxlib.c | 0 .../{libqhull => internal_libqhull}/stat.c | 0 .../{libqhull => internal_libqhull}/stat.h | 0 .../{libqhull => internal_libqhull}/user.c | 0 .../{libqhull => internal_libqhull}/user.h | 0 .../{libqhull => internal_libqhull}/usermem.c | 0 .../userprintf.c | 0 .../userprintf_rbox.c | 0 gdal/alg/internal_qhull_headers.h | 30 +++++++++---------- 31 files changed, 15 insertions(+), 15 deletions(-) rename gdal/alg/{libqhull => internal_libqhull}/COPYING.txt (100%) rename gdal/alg/{libqhull => internal_libqhull}/README.txt (100%) rename gdal/alg/{libqhull => internal_libqhull}/geom.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/geom.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/geom2.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/global.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/io.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/io.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/libqhull.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/libqhull.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/mem.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/mem.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/merge.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/merge.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/poly.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/poly.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/poly2.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/qhull_a.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/qset.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/qset.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/random.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/random.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/rboxlib.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/stat.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/stat.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/user.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/user.h (100%) rename gdal/alg/{libqhull => internal_libqhull}/usermem.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/userprintf.c (100%) rename gdal/alg/{libqhull => internal_libqhull}/userprintf_rbox.c (100%) diff --git a/gdal/alg/libqhull/COPYING.txt b/gdal/alg/internal_libqhull/COPYING.txt similarity index 100% rename from gdal/alg/libqhull/COPYING.txt rename to gdal/alg/internal_libqhull/COPYING.txt diff --git a/gdal/alg/libqhull/README.txt b/gdal/alg/internal_libqhull/README.txt similarity index 100% rename from gdal/alg/libqhull/README.txt rename to gdal/alg/internal_libqhull/README.txt diff --git a/gdal/alg/libqhull/geom.c b/gdal/alg/internal_libqhull/geom.c similarity index 100% rename from gdal/alg/libqhull/geom.c rename to gdal/alg/internal_libqhull/geom.c diff --git a/gdal/alg/libqhull/geom.h b/gdal/alg/internal_libqhull/geom.h similarity index 100% rename from gdal/alg/libqhull/geom.h rename to gdal/alg/internal_libqhull/geom.h diff --git a/gdal/alg/libqhull/geom2.c b/gdal/alg/internal_libqhull/geom2.c similarity index 100% rename from gdal/alg/libqhull/geom2.c rename to gdal/alg/internal_libqhull/geom2.c diff --git a/gdal/alg/libqhull/global.c b/gdal/alg/internal_libqhull/global.c similarity index 100% rename from gdal/alg/libqhull/global.c rename to gdal/alg/internal_libqhull/global.c diff --git a/gdal/alg/libqhull/io.c b/gdal/alg/internal_libqhull/io.c similarity index 100% rename from gdal/alg/libqhull/io.c rename to gdal/alg/internal_libqhull/io.c diff --git a/gdal/alg/libqhull/io.h b/gdal/alg/internal_libqhull/io.h similarity index 100% rename from gdal/alg/libqhull/io.h rename to gdal/alg/internal_libqhull/io.h diff --git a/gdal/alg/libqhull/libqhull.c b/gdal/alg/internal_libqhull/libqhull.c similarity index 100% rename from gdal/alg/libqhull/libqhull.c rename to gdal/alg/internal_libqhull/libqhull.c diff --git a/gdal/alg/libqhull/libqhull.h b/gdal/alg/internal_libqhull/libqhull.h similarity index 100% rename from gdal/alg/libqhull/libqhull.h rename to gdal/alg/internal_libqhull/libqhull.h diff --git a/gdal/alg/libqhull/mem.c b/gdal/alg/internal_libqhull/mem.c similarity index 100% rename from gdal/alg/libqhull/mem.c rename to gdal/alg/internal_libqhull/mem.c diff --git a/gdal/alg/libqhull/mem.h b/gdal/alg/internal_libqhull/mem.h similarity index 100% rename from gdal/alg/libqhull/mem.h rename to gdal/alg/internal_libqhull/mem.h diff --git a/gdal/alg/libqhull/merge.c b/gdal/alg/internal_libqhull/merge.c similarity index 100% rename from gdal/alg/libqhull/merge.c rename to gdal/alg/internal_libqhull/merge.c diff --git a/gdal/alg/libqhull/merge.h b/gdal/alg/internal_libqhull/merge.h similarity index 100% rename from gdal/alg/libqhull/merge.h rename to gdal/alg/internal_libqhull/merge.h diff --git a/gdal/alg/libqhull/poly.c b/gdal/alg/internal_libqhull/poly.c similarity index 100% rename from gdal/alg/libqhull/poly.c rename to gdal/alg/internal_libqhull/poly.c diff --git a/gdal/alg/libqhull/poly.h b/gdal/alg/internal_libqhull/poly.h similarity index 100% rename from gdal/alg/libqhull/poly.h rename to gdal/alg/internal_libqhull/poly.h diff --git a/gdal/alg/libqhull/poly2.c b/gdal/alg/internal_libqhull/poly2.c similarity index 100% rename from gdal/alg/libqhull/poly2.c rename to gdal/alg/internal_libqhull/poly2.c diff --git a/gdal/alg/libqhull/qhull_a.h b/gdal/alg/internal_libqhull/qhull_a.h similarity index 100% rename from gdal/alg/libqhull/qhull_a.h rename to gdal/alg/internal_libqhull/qhull_a.h diff --git a/gdal/alg/libqhull/qset.c b/gdal/alg/internal_libqhull/qset.c similarity index 100% rename from gdal/alg/libqhull/qset.c rename to gdal/alg/internal_libqhull/qset.c diff --git a/gdal/alg/libqhull/qset.h b/gdal/alg/internal_libqhull/qset.h similarity index 100% rename from gdal/alg/libqhull/qset.h rename to gdal/alg/internal_libqhull/qset.h diff --git a/gdal/alg/libqhull/random.c b/gdal/alg/internal_libqhull/random.c similarity index 100% rename from gdal/alg/libqhull/random.c rename to gdal/alg/internal_libqhull/random.c diff --git a/gdal/alg/libqhull/random.h b/gdal/alg/internal_libqhull/random.h similarity index 100% rename from gdal/alg/libqhull/random.h rename to gdal/alg/internal_libqhull/random.h diff --git a/gdal/alg/libqhull/rboxlib.c b/gdal/alg/internal_libqhull/rboxlib.c similarity index 100% rename from gdal/alg/libqhull/rboxlib.c rename to gdal/alg/internal_libqhull/rboxlib.c diff --git a/gdal/alg/libqhull/stat.c b/gdal/alg/internal_libqhull/stat.c similarity index 100% rename from gdal/alg/libqhull/stat.c rename to gdal/alg/internal_libqhull/stat.c diff --git a/gdal/alg/libqhull/stat.h b/gdal/alg/internal_libqhull/stat.h similarity index 100% rename from gdal/alg/libqhull/stat.h rename to gdal/alg/internal_libqhull/stat.h diff --git a/gdal/alg/libqhull/user.c b/gdal/alg/internal_libqhull/user.c similarity index 100% rename from gdal/alg/libqhull/user.c rename to gdal/alg/internal_libqhull/user.c diff --git a/gdal/alg/libqhull/user.h b/gdal/alg/internal_libqhull/user.h similarity index 100% rename from gdal/alg/libqhull/user.h rename to gdal/alg/internal_libqhull/user.h diff --git a/gdal/alg/libqhull/usermem.c b/gdal/alg/internal_libqhull/usermem.c similarity index 100% rename from gdal/alg/libqhull/usermem.c rename to gdal/alg/internal_libqhull/usermem.c diff --git a/gdal/alg/libqhull/userprintf.c b/gdal/alg/internal_libqhull/userprintf.c similarity index 100% rename from gdal/alg/libqhull/userprintf.c rename to gdal/alg/internal_libqhull/userprintf.c diff --git a/gdal/alg/libqhull/userprintf_rbox.c b/gdal/alg/internal_libqhull/userprintf_rbox.c similarity index 100% rename from gdal/alg/libqhull/userprintf_rbox.c rename to gdal/alg/internal_libqhull/userprintf_rbox.c diff --git a/gdal/alg/internal_qhull_headers.h b/gdal/alg/internal_qhull_headers.h index f3df3a474026..ce8c53011d83 100644 --- a/gdal/alg/internal_qhull_headers.h +++ b/gdal/alg/internal_qhull_headers.h @@ -974,22 +974,22 @@ static gdal_realT qh_stddev(); #pragma warning( disable : 4306 ) /* e.g 'type cast' : conversion from 'long' to 'facetT *' of greater size */ #endif -#include "libqhull/libqhull.h" -#include "libqhull/libqhull.c" -#include "libqhull/poly.c" -#include "libqhull/poly2.c" -#include "libqhull/mem.c" -#include "libqhull/user.c" -#include "libqhull/global.c" +#include "internal_libqhull/libqhull.h" +#include "internal_libqhull/libqhull.c" +#include "internal_libqhull/poly.c" +#include "internal_libqhull/poly2.c" +#include "internal_libqhull/mem.c" +#include "internal_libqhull/user.c" +#include "internal_libqhull/global.c" /*#include "userprintf.c"*/ -#include "libqhull/random.c" -#include "libqhull/qset.c" -#include "libqhull/io.c" -#include "libqhull/usermem.c" -#include "libqhull/geom.c" -#include "libqhull/geom2.c" -#include "libqhull/stat.c" -#include "libqhull/merge.c" +#include "internal_libqhull/random.c" +#include "internal_libqhull/qset.c" +#include "internal_libqhull/io.c" +#include "internal_libqhull/usermem.c" +#include "internal_libqhull/geom.c" +#include "internal_libqhull/geom2.c" +#include "internal_libqhull/stat.c" +#include "internal_libqhull/merge.c" #ifdef _MSC_VER #pragma warning( pop )