LCOV - code coverage report
Current view: top level - frmts/libertiff - libtiff_codecs.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 37 39 94.9 %
Date: 2025-05-31 00:00:17 Functions: 12 13 92.3 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL Core
       4             :  * Purpose:  GeoTIFF thread safe reader using libertiff library.
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include <cinttypes>
      14             : 
      15             : #include "tiff_common.h"
      16             : 
      17             : // Use code from internal libtiff for LZW, PackBits and LERC codecs
      18             : #define TIFFInitLZW LIBERTIFF_TIFFInitLZW
      19             : #define TIFFInitPackBits LIBERTIFF_TIFFInitPackBits
      20             : #define TIFFInitLERC LIBERTIFF_TIFFInitLERC
      21             : #define _TIFFmallocExt LIBERTIFF_TIFFmallocExt
      22             : #define _TIFFreallocExt LIBERTIFF_TIFFreallocExt
      23             : #define _TIFFcallocExt LIBERTIFF_TIFFcallocExt
      24             : #define _TIFFfreeExt LIBERTIFF_TIFFfreeExt
      25             : #define _TIFFmemset LIBERTIFF_TIFFmemset
      26             : #define _TIFFmemcpy LIBERTIFF_TIFFmemcpy
      27             : #define TIFFPredictorInit LIBERTIFF_TIFFPredictorInit
      28             : #define TIFFPredictorCleanup LIBERTIFF_TIFFPredictorCleanup
      29             : #define _TIFFSetDefaultCompressionState LIBERTIFF_TIFFSetDefaultCompressionState
      30             : #define TIFFFlushData1 LIBERTIFF_TIFFFlushData1_dummy
      31             : #define TIFFWarningExtR LIBERTIFF_TIFFWarningExtR
      32             : #define TIFFErrorExtR LIBERTIFF_TIFFErrorExtR
      33             : #define TIFFTileRowSize LIBERTIFF_TIFFTileRowSize_dummy
      34             : #define TIFFScanlineSize LIBERTIFF_TIFFScanlineSize_dummy
      35             : #define TIFFSetField LIBERTIFF_TIFFSetField_dummy
      36             : #define _TIFFMergeFields LIBERTIFF_TIFFMergeFields_dummy
      37             : #define register
      38             : extern "C"
      39             : {
      40             : #if defined(__GNUC__)
      41             : #pragma GCC diagnostic push
      42             : #pragma GCC diagnostic ignored "-Wold-style-cast"
      43             : #endif
      44             : 
      45             : #ifdef __clang__
      46             : #pragma clang diagnostic push
      47             : #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
      48             : #endif
      49             : 
      50             : #define LZW_READ_ONLY
      51             : #include "tif_lzw.c"
      52             : 
      53             : #define PACKBITS_READ_ONLY
      54             : #include "tif_packbits.c"
      55             : 
      56             : #ifdef LERC_SUPPORT
      57             : #define LERC_READ_ONLY
      58             : #include "tif_lerc.c"
      59             : #endif
      60             : 
      61             : #ifdef __clang__
      62             : #pragma clang diagnostic pop
      63             : #endif
      64             : 
      65             : #if defined(__GNUC__)
      66             : #pragma GCC diagnostic pop
      67             : #endif
      68             : 
      69         261 :     void *LIBERTIFF_TIFFmallocExt(TIFF *, tmsize_t s)
      70             :     {
      71         261 :         return malloc(s);
      72             :     }
      73             : 
      74           0 :     void *LIBERTIFF_TIFFreallocExt(TIFF *, void *p, tmsize_t s)
      75             :     {
      76           0 :         return realloc(p, s);
      77             :     }
      78             : 
      79          67 :     void *LIBERTIFF_TIFFcallocExt(TIFF *, tmsize_t nmemb, tmsize_t siz)
      80             :     {
      81          67 :         return calloc(nmemb, siz);
      82             :     }
      83             : 
      84         596 :     void LIBERTIFF_TIFFfreeExt(TIFF *, void *ptr)
      85             :     {
      86         596 :         free(ptr);
      87         596 :     }
      88             : 
      89           1 :     void LIBERTIFF_TIFFmemset(void *ptr, int v, tmsize_t s)
      90             :     {
      91           1 :         memset(ptr, v, s);
      92           1 :     }
      93             : 
      94         482 :     void LIBERTIFF_TIFFmemcpy(void *d, const void *s, tmsize_t c)
      95             :     {
      96         482 :         memcpy(d, s, c);
      97         482 :     }
      98             : 
      99         142 :     void LIBERTIFF_TIFFSetDefaultCompressionState(TIFF *)
     100             :     {
     101         142 :     }
     102             : 
     103         134 :     int LIBERTIFF_TIFFSetField_dummy(TIFF *, uint32_t, ...)
     104             :     {
     105         134 :         return 0;
     106             :     }
     107             : 
     108          67 :     int LIBERTIFF_TIFFMergeFields_dummy(TIFF *, const TIFFField[], uint32_t)
     109             :     {
     110          67 :         return 1;
     111             :     }
     112             : 
     113          75 :     int LIBERTIFF_TIFFPredictorInit(TIFF *)
     114             :     {
     115          75 :         return 0;
     116             :     }
     117             : 
     118          75 :     int LIBERTIFF_TIFFPredictorCleanup(TIFF *)
     119             :     {
     120          75 :         return 0;
     121             :     }
     122             : 
     123           2 :     void LIBERTIFF_TIFFWarningExtR(TIFF *, const char *pszModule,
     124             :                                    const char *fmt, ...)
     125             :     {
     126             :         char *pszModFmt =
     127           2 :             gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
     128             :         va_list ap;
     129           2 :         va_start(ap, fmt);
     130           2 :         CPLErrorV(CE_Warning, CPLE_AppDefined, pszModFmt, ap);
     131           2 :         va_end(ap);
     132           2 :         CPLFree(pszModFmt);
     133           2 :     }
     134             : 
     135          14 :     void LIBERTIFF_TIFFErrorExtR(TIFF *, const char *pszModule, const char *fmt,
     136             :                                  ...)
     137             :     {
     138             :         char *pszModFmt =
     139          14 :             gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
     140             :         va_list ap;
     141          14 :         va_start(ap, fmt);
     142          14 :         CPLErrorV(CE_Failure, CPLE_AppDefined, pszModFmt, ap);
     143          14 :         va_end(ap);
     144          14 :         CPLFree(pszModFmt);
     145          14 :     }
     146             : }
     147             : #undef isTiled

Generated by: LCOV version 1.14