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-07-11 10:11:13 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             : #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
      49             : #endif
      50             : 
      51             : #define LZW_READ_ONLY
      52             : #include "tif_lzw.c"
      53             : 
      54             : #define PACKBITS_READ_ONLY
      55             : #include "tif_packbits.c"
      56             : 
      57             : #ifdef LERC_SUPPORT
      58             : #define LERC_READ_ONLY
      59             : #include "tif_lerc.c"
      60             : #endif
      61             : 
      62             : #ifdef __clang__
      63             : #pragma clang diagnostic pop
      64             : #endif
      65             : 
      66             : #if defined(__GNUC__)
      67             : #pragma GCC diagnostic pop
      68             : #endif
      69             : 
      70         260 :     void *LIBERTIFF_TIFFmallocExt(TIFF *, tmsize_t s)
      71             :     {
      72         260 :         return malloc(s);
      73             :     }
      74             : 
      75           0 :     void *LIBERTIFF_TIFFreallocExt(TIFF *, void *p, tmsize_t s)
      76             :     {
      77           0 :         return realloc(p, s);
      78             :     }
      79             : 
      80          66 :     void *LIBERTIFF_TIFFcallocExt(TIFF *, tmsize_t nmemb, tmsize_t siz)
      81             :     {
      82          66 :         return calloc(nmemb, siz);
      83             :     }
      84             : 
      85         594 :     void LIBERTIFF_TIFFfreeExt(TIFF *, void *ptr)
      86             :     {
      87         594 :         free(ptr);
      88         594 :     }
      89             : 
      90           1 :     void LIBERTIFF_TIFFmemset(void *ptr, int v, tmsize_t s)
      91             :     {
      92           1 :         memset(ptr, v, s);
      93           1 :     }
      94             : 
      95         482 :     void LIBERTIFF_TIFFmemcpy(void *d, const void *s, tmsize_t c)
      96             :     {
      97         482 :         memcpy(d, s, c);
      98         482 :     }
      99             : 
     100         142 :     void LIBERTIFF_TIFFSetDefaultCompressionState(TIFF *)
     101             :     {
     102         142 :     }
     103             : 
     104         132 :     int LIBERTIFF_TIFFSetField_dummy(TIFF *, uint32_t, ...)
     105             :     {
     106         132 :         return 0;
     107             :     }
     108             : 
     109          67 :     int LIBERTIFF_TIFFMergeFields_dummy(TIFF *, const TIFFField[], uint32_t)
     110             :     {
     111          67 :         return 1;
     112             :     }
     113             : 
     114          74 :     int LIBERTIFF_TIFFPredictorInit(TIFF *)
     115             :     {
     116          74 :         return 0;
     117             :     }
     118             : 
     119          75 :     int LIBERTIFF_TIFFPredictorCleanup(TIFF *)
     120             :     {
     121          75 :         return 0;
     122             :     }
     123             : 
     124           2 :     void LIBERTIFF_TIFFWarningExtR(TIFF *, const char *pszModule,
     125             :                                    const char *fmt, ...)
     126             :     {
     127             :         char *pszModFmt =
     128           2 :             gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
     129             :         va_list ap;
     130           2 :         va_start(ap, fmt);
     131           2 :         CPLErrorV(CE_Warning, CPLE_AppDefined, pszModFmt, ap);
     132           2 :         va_end(ap);
     133           2 :         CPLFree(pszModFmt);
     134           2 :     }
     135             : 
     136          14 :     void LIBERTIFF_TIFFErrorExtR(TIFF *, const char *pszModule, const char *fmt,
     137             :                                  ...)
     138             :     {
     139             :         char *pszModFmt =
     140          14 :             gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
     141             :         va_list ap;
     142          14 :         va_start(ap, fmt);
     143          14 :         CPLErrorV(CE_Failure, CPLE_AppDefined, pszModFmt, ap);
     144          14 :         va_end(ap);
     145          14 :         CPLFree(pszModFmt);
     146          14 :     }
     147             : }
     148             : #undef isTiled

Generated by: LCOV version 1.14