1 /******************************************************************************
2  * $Id: gdalwarper.h 98488570e6fb1676653ada4ed498c46a6115eaf1 2020-12-28 23:45:10 +0100 Even Rouault $
3  *
4  * Project:  GDAL High Performance Warper
5  * Purpose:  Prototypes, and definitions for warping related work.
6  * Author:   Frank Warmerdam, warmerdam@pobox.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2003, Frank Warmerdam
10  * Copyright (c) 2009-2012, Even Rouault <even dot rouault at spatialys.com>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef GDALWARPER_H_INCLUDED
32 #define GDALWARPER_H_INCLUDED
33 
34 /**
35  * \file gdalwarper.h
36  *
37  * GDAL warper related entry points and definitions.  Eventually it is
38  * expected that this file will be mostly private to the implementation,
39  * and the public C entry points will be available in gdal_alg.h.
40  */
41 
42 #include "gdal_alg.h"
43 #include "cpl_minixml.h"
44 #include "cpl_multiproc.h"
45 
46 CPL_C_START
47 
48 /* Note: values are selected to be consistent with GDALRIOResampleAlg of gcore/gdal.h */
49 /*! Warp Resampling Algorithm */
50 typedef enum {
51   /*! Nearest neighbour (select on one input pixel) */ GRA_NearestNeighbour=0,
52   /*! Bilinear (2x2 kernel) */                         GRA_Bilinear=1,
53   /*! Cubic Convolution Approximation (4x4 kernel) */  GRA_Cubic=2,
54   /*! Cubic B-Spline Approximation (4x4 kernel) */     GRA_CubicSpline=3,
55   /*! Lanczos windowed sinc interpolation (6x6 kernel) */ GRA_Lanczos=4,
56   /*! Average (computes the weighted average of all non-NODATA contributing pixels) */ GRA_Average=5,
57   /*! Mode (selects the value which appears most often of all the sampled points) */ GRA_Mode=6,
58   /*  GRA_Gauss=7 reserved. */
59   /*! Max (selects maximum of all non-NODATA contributing pixels) */ GRA_Max=8,
60   /*! Min (selects minimum of all non-NODATA contributing pixels) */ GRA_Min=9,
61   /*! Med (selects median of all non-NODATA contributing pixels) */ GRA_Med=10,
62   /*! Q1 (selects first quartile of all non-NODATA contributing pixels) */ GRA_Q1=11,
63   /*! Q3 (selects third quartile of all non-NODATA contributing pixels) */ GRA_Q3=12,
64   /*! Sum (weighed sum of all non-NODATA contributing pixels). Added in GDAL 3.1 */ GRA_Sum=13,
65   /*! RMS (weighted root mean square (quadratic mean) of all non-NODATA contributing pixels) */ GRA_RMS=14,
66 /*! @cond Doxygen_Suppress */
67   GRA_LAST_VALUE=GRA_RMS
68 /*! @endcond */
69 } GDALResampleAlg;
70 
71 /*! GWKAverageOrMode Algorithm */
72 typedef enum {
73     /*! Average */ GWKAOM_Average=1,
74     /*! Mode */ GWKAOM_Fmode=2,
75     /*! Mode of GDT_Byte, GDT_UInt16, or GDT_Int16 */ GWKAOM_Imode=3,
76     /*! Maximum */ GWKAOM_Max=4,
77     /*! Minimum */ GWKAOM_Min=5,
78     /*! Quantile */ GWKAOM_Quant=6,
79     /*! Sum */ GWKAOM_Sum=7,
80     /*! RMS */ GWKAOM_RMS=8
81 } GWKAverageOrModeAlg;
82 
83 /*! @cond Doxygen_Suppress */
84 typedef int
85 (*GDALMaskFunc)( void *pMaskFuncArg,
86                  int nBandCount, GDALDataType eType,
87                  int nXOff, int nYOff,
88                  int nXSize, int nYSize,
89                  GByte **papabyImageData,
90                  int bMaskIsFloat, void *pMask );
91 
92 CPLErr CPL_DLL
93 GDALWarpNoDataMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
94                       int nXOff, int nYOff, int nXSize, int nYSize,
95                       GByte **papabyImageData, int bMaskIsFloat,
96                       void *pValidityMask, int* pbOutAllValid );
97 
98 CPLErr CPL_DLL
99 GDALWarpDstAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
100                         int nXOff, int nYOff, int nXSize, int nYSize,
101                         GByte ** /*ppImageData */,
102                         int bMaskIsFloat, void *pValidityMask );
103 CPLErr CPL_DLL
104 GDALWarpSrcAlphaMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
105                         int nXOff, int nYOff, int nXSize, int nYSize,
106                         GByte ** /*ppImageData */,
107                         int bMaskIsFloat, void *pValidityMask, int* pbOutAllOpaque );
108 
109 CPLErr CPL_DLL
110 GDALWarpSrcMaskMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
111                        int nXOff, int nYOff, int nXSize, int nYSize,
112                        GByte ** /*ppImageData */,
113                        int bMaskIsFloat, void *pValidityMask );
114 
115 CPLErr CPL_DLL
116 GDALWarpCutlineMasker( void *pMaskFuncArg, int nBandCount, GDALDataType eType,
117                        int nXOff, int nYOff, int nXSize, int nYSize,
118                        GByte ** /* ppImageData */,
119                        int bMaskIsFloat, void *pValidityMask );
120 /*! @endcond */
121 
122 /************************************************************************/
123 /*                           GDALWarpOptions                            */
124 /************************************************************************/
125 
126 /** Warp control options for use with GDALWarpOperation::Initialize()  */
127 typedef struct {
128 
129     char              **papszWarpOptions;
130 
131     /*! In bytes, 0.0 for internal default */
132     double              dfWarpMemoryLimit;
133 
134     /*! Resampling algorithm to use */
135     GDALResampleAlg     eResampleAlg;
136 
137     /*! data type to use during warp operation, GDT_Unknown lets the algorithm
138         select the type */
139     GDALDataType        eWorkingDataType;
140 
141     /*! Source image dataset. */
142     GDALDatasetH        hSrcDS;
143 
144     /*! Destination image dataset - may be NULL if only using GDALWarpOperation::WarpRegionToBuffer(). */
145     GDALDatasetH        hDstDS;
146 
147     /*! Number of bands to process, may be 0 to select all bands. */
148     int                 nBandCount;
149 
150     /*! The band numbers for the source bands to process (1 based) */
151     int                *panSrcBands;
152 
153     /*! The band numbers for the destination bands to process (1 based) */
154     int                *panDstBands;
155 
156     /*! The source band so use as an alpha (transparency) value, 0=disabled */
157     int                nSrcAlphaBand;
158 
159     /*! The dest. band so use as an alpha (transparency) value, 0=disabled */
160     int                nDstAlphaBand;
161 
162     /*! The "nodata" value real component for each input band, if NULL there isn't one */
163     double             *padfSrcNoDataReal;
164     /*! The "nodata" value imaginary component - may be NULL even if real
165       component is provided. This value is not used to flag invalid values.
166       Only the real component is used. */
167     double             *padfSrcNoDataImag;
168 
169     /*! The "nodata" value real component for each output band, if NULL there isn't one */
170     double             *padfDstNoDataReal;
171     /*! The "nodata" value imaginary component - may be NULL even if real
172       component is provided. Note that warp operations only use real component
173       for flagging invalid data.*/
174     double             *padfDstNoDataImag;
175 
176     /*! GDALProgressFunc() compatible progress reporting function, or NULL
177       if there isn't one. */
178     GDALProgressFunc    pfnProgress;
179 
180     /*! Callback argument to be passed to pfnProgress. */
181     void               *pProgressArg;
182 
183     /*! Type of spatial point transformer function */
184     GDALTransformerFunc pfnTransformer;
185 
186     /*! Handle to image transformer setup structure */
187     void                *pTransformerArg;
188 
189     /** Unused. Must be NULL */
190     GDALMaskFunc       *papfnSrcPerBandValidityMaskFunc;
191     /** Unused. Must be NULL */
192     void              **papSrcPerBandValidityMaskFuncArg;
193 
194     /** Unused. Must be NULL */
195     GDALMaskFunc        pfnSrcValidityMaskFunc;
196     /** Unused. Must be NULL */
197     void               *pSrcValidityMaskFuncArg;
198 
199     /** Unused. Must be NULL */
200     GDALMaskFunc        pfnSrcDensityMaskFunc;
201     /** Unused. Must be NULL */
202     void               *pSrcDensityMaskFuncArg;
203 
204     /** Unused. Must be NULL */
205     GDALMaskFunc        pfnDstDensityMaskFunc;
206     /** Unused. Must be NULL */
207     void               *pDstDensityMaskFuncArg;
208 
209     /** Unused. Must be NULL */
210     GDALMaskFunc        pfnDstValidityMaskFunc;
211     /** Unused. Must be NULL */
212     void               *pDstValidityMaskFuncArg;
213 
214     /** Unused. Must be NULL */
215     CPLErr              (*pfnPreWarpChunkProcessor)( void *pKern, void *pArg );
216     /** Unused. Must be NULL */
217     void               *pPreWarpProcessorArg;
218 
219     /** Unused. Must be NULL */
220     CPLErr              (*pfnPostWarpChunkProcessor)( void *pKern, void *pArg);
221     /** Unused. Must be NULL */
222     void               *pPostWarpProcessorArg;
223 
224     /*! Optional OGRPolygonH for a masking cutline. */
225     void               *hCutline;
226 
227     /*! Optional blending distance to apply across cutline in pixels, default is zero. */
228     double              dfCutlineBlendDist;
229 
230 } GDALWarpOptions;
231 
232 GDALWarpOptions CPL_DLL * CPL_STDCALL GDALCreateWarpOptions(void);
233 void CPL_DLL CPL_STDCALL GDALDestroyWarpOptions( GDALWarpOptions * );
234 GDALWarpOptions CPL_DLL * CPL_STDCALL
235 GDALCloneWarpOptions( const GDALWarpOptions * );
236 
237 void CPL_DLL CPL_STDCALL
238 GDALWarpInitDstNoDataReal( GDALWarpOptions *, double dNoDataReal );
239 
240 void CPL_DLL CPL_STDCALL
241 GDALWarpInitSrcNoDataReal( GDALWarpOptions *, double dNoDataReal );
242 
243 void CPL_DLL CPL_STDCALL
244 GDALWarpInitNoDataReal( GDALWarpOptions *, double dNoDataReal );
245 
246 void CPL_DLL CPL_STDCALL
247 GDALWarpInitDstNoDataImag( GDALWarpOptions *, double dNoDataImag );
248 
249 void CPL_DLL CPL_STDCALL
250 GDALWarpInitSrcNoDataImag( GDALWarpOptions *, double dNoDataImag );
251 
252 void CPL_DLL CPL_STDCALL
253 GDALWarpResolveWorkingDataType( GDALWarpOptions * );
254 
255 void CPL_DLL CPL_STDCALL
256 GDALWarpInitDefaultBandMapping( GDALWarpOptions *, int nBandCount );
257 
258 /*! @cond Doxygen_Suppress */
259 CPLXMLNode CPL_DLL * CPL_STDCALL
260       GDALSerializeWarpOptions( const GDALWarpOptions * );
261 GDALWarpOptions CPL_DLL * CPL_STDCALL
262       GDALDeserializeWarpOptions( CPLXMLNode * );
263 /*! @endcond */
264 
265 /************************************************************************/
266 /*                         GDALReprojectImage()                         */
267 /************************************************************************/
268 
269 CPLErr CPL_DLL CPL_STDCALL
270 GDALReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
271                     GDALDatasetH hDstDS, const char *pszDstWKT,
272                     GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
273                     double dfMaxError,
274                     GDALProgressFunc pfnProgress, void *pProgressArg,
275                     GDALWarpOptions *psOptions );
276 
277 CPLErr CPL_DLL CPL_STDCALL
278 GDALCreateAndReprojectImage( GDALDatasetH hSrcDS, const char *pszSrcWKT,
279                     const char *pszDstFilename, const char *pszDstWKT,
280                     GDALDriverH hDstDriver, char **papszCreateOptions,
281                     GDALResampleAlg eResampleAlg, double dfWarpMemoryLimit,
282                     double dfMaxError,
283                     GDALProgressFunc pfnProgress, void *pProgressArg,
284                     GDALWarpOptions *psOptions );
285 
286 /************************************************************************/
287 /*                           VRTWarpedDataset                           */
288 /************************************************************************/
289 
290 GDALDatasetH CPL_DLL CPL_STDCALL
291 GDALAutoCreateWarpedVRT( GDALDatasetH hSrcDS,
292                          const char *pszSrcWKT, const char *pszDstWKT,
293                          GDALResampleAlg eResampleAlg,
294                          double dfMaxError, const GDALWarpOptions *psOptions );
295 
296 GDALDatasetH CPL_DLL CPL_STDCALL
297 GDALAutoCreateWarpedVRTEx( GDALDatasetH hSrcDS,
298                            const char *pszSrcWKT, const char *pszDstWKT,
299                            GDALResampleAlg eResampleAlg,
300                            double dfMaxError, const GDALWarpOptions *psOptions,
301                            CSLConstList papszTransformerOptions );
302 
303 GDALDatasetH CPL_DLL CPL_STDCALL
304 GDALCreateWarpedVRT( GDALDatasetH hSrcDS,
305                      int nPixels, int nLines, double *padfGeoTransform,
306                      GDALWarpOptions *psOptions );
307 
308 CPLErr CPL_DLL CPL_STDCALL
309 GDALInitializeWarpedVRT( GDALDatasetH hDS,
310                          GDALWarpOptions *psWO );
311 
312 CPL_C_END
313 
314 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
315 
316 /************************************************************************/
317 /*                            GDALWarpKernel                            */
318 /*                                                                      */
319 
320 /** This is the number of dummy pixels that must be reserved in source arrays
321  * in order to satisfy assumptions made in GWKResample(), and more specifically
322  * by GWKGetPixelRow() that always read a even number of pixels. So if we are
323  * in the situation to read the last pixel of the source array, we need 1 extra
324  * dummy pixel to avoid reading out of bounds. */
325 #define WARP_EXTRA_ELTS    1
326 
327 /** This class represents the lowest level of abstraction of warping.
328  *
329  * It holds the imagery for one "chunk" of a warp, and the
330  * pre-prepared masks.  All IO is done before and after its
331  * operation.  This class is not normally used by the
332  * application.
333  */
334 class CPL_DLL GDALWarpKernel
335 {
336     CPL_DISALLOW_COPY_ASSIGN(GDALWarpKernel)
337 
338 public:
339     /** Warp options */
340     char              **papszWarpOptions;
341 
342     /** Resample algorithm */
343     GDALResampleAlg     eResample;
344     /** Working data type */
345     GDALDataType        eWorkingDataType;
346     /** Number of input and output bands (excluding alpha bands) */
347     int                 nBands;
348 
349     /** Width of the source image */
350     int                 nSrcXSize;
351     /** Height of the source image */
352     int                 nSrcYSize;
353     /** Extra pixels (included in nSrcXSize) reserved for filter window. Should be ignored in scale computation */
354     double              dfSrcXExtraSize;
355     /** Extra pixels (included in nSrcYSize) reserved for filter window. Should be ignored in scale computation */
356     double              dfSrcYExtraSize;
357     /** Array of nBands source images of size nSrcXSize * nSrcYSize. Each subarray must have WARP_EXTRA_ELTS at the end */
358     GByte               **papabySrcImage;
359 
360     /** Array of nBands validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8 */
361     GUInt32           **papanBandSrcValid;
362     /** Unified validity mask of size (nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS) / 8 */
363     GUInt32            *panUnifiedSrcValid;
364     /** Unified source density of size nSrcXSize * nSrcYSize + WARP_EXTRA_ELTS */
365     float              *pafUnifiedSrcDensity;
366 
367     /** Width of the destination image */
368     int                 nDstXSize;
369     /** Height of the destination image */
370     int                 nDstYSize;
371     /** Array of nBands destination images of size nDstXSize * nDstYSize */
372     GByte             **papabyDstImage;
373     /** Validify mask of size (nDstXSize * nDstYSize) / 8 */
374     GUInt32            *panDstValid;
375     /** Destination density of size nDstXSize * nDstYSize */
376     float              *pafDstDensity;
377 
378     /** X resampling scale, i.e. nDstXSize / nSrcXSize */
379     double              dfXScale;
380     /** Y resampling scale, i.e. nDstYSize / nSrcYSize */
381     double              dfYScale;
382     /** X size of filter kernel */
383     double              dfXFilter;
384     /** Y size of filter kernel */
385     double              dfYFilter;
386     /** X size of window to filter */
387     int                 nXRadius;
388     /** Y size of window to filter */
389     int                 nYRadius;
390     /** X filtering offset */
391     int                 nFiltInitX;
392     /** Y filtering offset */
393     int                 nFiltInitY;
394 
395     /** X offset of the source buffer regarding the top-left corner of the image */
396     int                 nSrcXOff;
397     /** Y offset of the source buffer regarding the top-left corner of the image */
398     int                 nSrcYOff;
399 
400     /** X offset of the destination buffer regarding the top-left corner of the image */
401     int                 nDstXOff;
402     /** Y offset of the destination buffer regarding the top-left corner of the image */
403     int                 nDstYOff;
404 
405     /** Pixel transformation function */
406     GDALTransformerFunc pfnTransformer;
407     /** User data provided to pfnTransformer */
408     void                *pTransformerArg;
409 
410     /** Progress function */
411     GDALProgressFunc    pfnProgress;
412     /** User data provided to pfnProgress */
413     void                *pProgress;
414 
415     /** Base/offset value for progress computation */
416     double              dfProgressBase;
417     /** Scale value for progress computation */
418     double              dfProgressScale;
419 
420     /** Array of nBands value for destination nodata */
421     double              *padfDstNoDataReal;
422 
423 /*! @cond Doxygen_Suppress */
424     /** Per-thread data. Internally set */
425     void                *psThreadData;
426 /*! @endcond */
427 
428                        GDALWarpKernel();
429     virtual           ~GDALWarpKernel();
430 
431     CPLErr              Validate();
432     CPLErr              PerformWarp();
433 };
434 
435 /*! @cond Doxygen_Suppress */
436 void* GWKThreadsCreate(char** papszWarpOptions,
437                        GDALTransformerFunc pfnTransformer,
438                        void* pTransformerArg);
439 void GWKThreadsEnd(void* psThreadDataIn);
440 /*! @endcond */
441 
442 /************************************************************************/
443 /*                         GDALWarpOperation()                          */
444 /*                                                                      */
445 /*      This object is application created, or created by a higher      */
446 /*      level convenience function.  It is responsible for              */
447 /*      subdividing the operation into chunks, loading and saving       */
448 /*      imagery, and establishing the varios validity and density       */
449 /*      masks.  Actual resampling is done by the GDALWarpKernel.        */
450 /************************************************************************/
451 
452 /*! @cond Doxygen_Suppress */
453 typedef struct _GDALWarpChunk GDALWarpChunk;
454 /*! @endcond */
455 
456 class CPL_DLL GDALWarpOperation {
457 
458     CPL_DISALLOW_COPY_ASSIGN(GDALWarpOperation)
459 
460 private:
461     GDALWarpOptions *psOptions;
462 
463     void            WipeOptions();
464     int             ValidateOptions();
465 
466     CPLErr          ComputeSourceWindow( int nDstXOff, int nDstYOff,
467                                          int nDstXSize, int nDstYSize,
468                                          int *pnSrcXOff, int *pnSrcYOff,
469                                          int *pnSrcXSize, int *pnSrcYSize,
470                                          double *pdfSrcXExtraSize, double *pdfSrcYExtraSize,
471                                          double* pdfSrcFillRatio );
472 
473     void            ComputeSourceWindowStartingFromSource(
474                                     int nDstXOff, int nDstYOff,
475                                     int nDstXSize, int nDstYSize,
476                                     double* padfSrcMinX, double* padfSrcMinY,
477                                     double* padfSrcMaxX, double* padfSrcMaxY);
478 
479     static CPLErr          CreateKernelMask( GDALWarpKernel *, int iBand,
480                                       const char *pszType );
481 
482     CPLMutex        *hIOMutex;
483     CPLMutex        *hWarpMutex;
484 
485     int             nChunkListCount;
486     int             nChunkListMax;
487     GDALWarpChunk  *pasChunkList;
488 
489     int             bReportTimings;
490     unsigned long   nLastTimeReported;
491 
492     void           *psThreadData;
493 
494     void            WipeChunkList();
495     CPLErr          CollectChunkListInternal( int nDstXOff, int nDstYOff,
496                                       int nDstXSize, int nDstYSize );
497     void            CollectChunkList( int nDstXOff, int nDstYOff,
498                                       int nDstXSize, int nDstYSize );
499     void            ReportTiming( const char * );
500 
501 public:
502                     GDALWarpOperation();
503     virtual        ~GDALWarpOperation();
504 
505     CPLErr          Initialize( const GDALWarpOptions *psNewOptions );
506     void*           CreateDestinationBuffer( int nDstXSize, int nDstYSize,
507                                              int *pbWasInitialized = nullptr );
508     static void     DestroyDestinationBuffer(void* pDstBuffer);
509 
510     const GDALWarpOptions         *GetOptions();
511 
512     CPLErr          ChunkAndWarpImage( int nDstXOff, int nDstYOff,
513                                        int nDstXSize, int nDstYSize );
514     CPLErr          ChunkAndWarpMulti( int nDstXOff, int nDstYOff,
515                                        int nDstXSize, int nDstYSize );
516     CPLErr          WarpRegion( int nDstXOff, int nDstYOff,
517                                 int nDstXSize, int nDstYSize,
518                                 int nSrcXOff=0, int nSrcYOff=0,
519                                 int nSrcXSize=0, int nSrcYSize=0,
520                                 double dfProgressBase=0.0, double dfProgressScale=1.0);
521     CPLErr          WarpRegion( int nDstXOff, int nDstYOff,
522                                 int nDstXSize, int nDstYSize,
523                                 int nSrcXOff, int nSrcYOff,
524                                 int nSrcXSize, int nSrcYSize,
525                                 double dfSrcXExtraSize, double dfSrcYExtraSize,
526                                 double dfProgressBase, double dfProgressScale);
527     CPLErr          WarpRegionToBuffer( int nDstXOff, int nDstYOff,
528                                         int nDstXSize, int nDstYSize,
529                                         void *pDataBuf,
530                                         GDALDataType eBufDataType,
531                                         int nSrcXOff=0, int nSrcYOff=0,
532                                         int nSrcXSize=0, int nSrcYSize=0,
533                                         double dfProgressBase=0.0, double dfProgressScale=1.0);
534     CPLErr          WarpRegionToBuffer( int nDstXOff, int nDstYOff,
535                                         int nDstXSize, int nDstYSize,
536                                         void *pDataBuf,
537                                         GDALDataType eBufDataType,
538                                         int nSrcXOff, int nSrcYOff,
539                                         int nSrcXSize, int nSrcYSize,
540                                         double dfSrcXExtraSize, double dfSrcYExtraSize,
541                                         double dfProgressBase, double dfProgressScale);
542 };
543 
544 #endif /* def __cplusplus */
545 
546 CPL_C_START
547 
548 /** Opaque type representing a GDALWarpOperation object */
549 typedef void * GDALWarpOperationH;
550 
551 GDALWarpOperationH CPL_DLL GDALCreateWarpOperation(const GDALWarpOptions* );
552 void CPL_DLL GDALDestroyWarpOperation( GDALWarpOperationH );
553 CPLErr CPL_DLL GDALChunkAndWarpImage( GDALWarpOperationH, int, int, int, int );
554 CPLErr CPL_DLL GDALChunkAndWarpMulti( GDALWarpOperationH, int, int, int, int );
555 CPLErr CPL_DLL GDALWarpRegion( GDALWarpOperationH,
556                                int, int, int, int, int, int, int, int );
557 CPLErr CPL_DLL GDALWarpRegionToBuffer( GDALWarpOperationH, int, int, int, int,
558                                        void *, GDALDataType,
559                                        int, int, int, int );
560 
561 /************************************************************************/
562 /*      Warping kernel functions                                        */
563 /************************************************************************/
564 
565 /*! @cond Doxygen_Suppress */
566 int GWKGetFilterRadius(GDALResampleAlg eResampleAlg);
567 
568 typedef double (*FilterFuncType)(double dfX);
569 FilterFuncType GWKGetFilterFunc(GDALResampleAlg eResampleAlg);
570 
571 // TODO(schwehr): Can padfVals be a const pointer?
572 typedef double (*FilterFunc4ValuesType)(double* padfVals);
573 FilterFunc4ValuesType GWKGetFilterFunc4Values(GDALResampleAlg eResampleAlg);
574 /*! @endcond */
575 
576 CPL_C_END
577 
578 #endif /* ndef GDAL_ALG_H_INCLUDED */
579