Coverage Report

Created: 2026-08-14 09:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/libertiff/libtiff_codecs.h
Line
Count
Source
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
49
#define TIFFInitLZW LIBERTIFF_TIFFInitLZW
19
9
#define TIFFInitPackBits LIBERTIFF_TIFFInitPackBits
20
22
#define TIFFInitLERC LIBERTIFF_TIFFInitLERC
21
127
#define _TIFFmallocExt LIBERTIFF_TIFFmallocExt
22
3
#define _TIFFreallocExt LIBERTIFF_TIFFreallocExt
23
22
#define _TIFFcallocExt LIBERTIFF_TIFFcallocExt
24
237
#define _TIFFfreeExt LIBERTIFF_TIFFfreeExt
25
46
#define _TIFFmemset LIBERTIFF_TIFFmemset
26
3.35k
#define _TIFFmemcpy LIBERTIFF_TIFFmemcpy
27
49
#define TIFFPredictorInit LIBERTIFF_TIFFPredictorInit
28
49
#define TIFFPredictorCleanup LIBERTIFF_TIFFPredictorCleanup
29
71
#define _TIFFSetDefaultCompressionState LIBERTIFF_TIFFSetDefaultCompressionState
30
#define TIFFFlushData1 LIBERTIFF_TIFFFlushData1_dummy
31
37
#define TIFFWarningExtR LIBERTIFF_TIFFWarningExtR
32
223
#define TIFFErrorExtR LIBERTIFF_TIFFErrorExtR
33
#define TIFFTileRowSize LIBERTIFF_TIFFTileRowSize_dummy
34
#define TIFFScanlineSize LIBERTIFF_TIFFScanlineSize_dummy
35
44
#define TIFFSetField LIBERTIFF_TIFFSetField_dummy
36
22
#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
    void *LIBERTIFF_TIFFmallocExt(TIFF *, tmsize_t s)
71
127
    {
72
127
        return malloc(s);
73
127
    }
74
75
    void *LIBERTIFF_TIFFreallocExt(TIFF *, void *p, tmsize_t s)
76
3
    {
77
3
        return realloc(p, s);
78
3
    }
79
80
    void *LIBERTIFF_TIFFcallocExt(TIFF *, tmsize_t nmemb, tmsize_t siz)
81
22
    {
82
22
        return calloc(nmemb, siz);
83
22
    }
84
85
    void LIBERTIFF_TIFFfreeExt(TIFF *, void *ptr)
86
237
    {
87
237
        free(ptr);
88
237
    }
89
90
    void LIBERTIFF_TIFFmemset(void *ptr, int v, tmsize_t s)
91
46
    {
92
46
        memset(ptr, v, s);
93
46
    }
94
95
    void LIBERTIFF_TIFFmemcpy(void *d, const void *s, tmsize_t c)
96
3.35k
    {
97
3.35k
        memcpy(d, s, c);
98
3.35k
    }
99
100
    void LIBERTIFF_TIFFSetDefaultCompressionState(TIFF *)
101
71
    {
102
71
    }
103
104
    int LIBERTIFF_TIFFSetField_dummy(TIFF *, uint32_t, ...)
105
44
    {
106
44
        return 0;
107
44
    }
108
109
    int LIBERTIFF_TIFFMergeFields_dummy(TIFF *, const TIFFField[], uint32_t)
110
22
    {
111
22
        return 1;
112
22
    }
113
114
    int LIBERTIFF_TIFFPredictorInit(TIFF *)
115
49
    {
116
49
        return 0;
117
49
    }
118
119
    int LIBERTIFF_TIFFPredictorCleanup(TIFF *)
120
49
    {
121
49
        return 0;
122
49
    }
123
124
    void LIBERTIFF_TIFFWarningExtR(TIFF *, const char *pszModule,
125
                                   const char *fmt, ...)
126
37
    {
127
37
        char *pszModFmt =
128
37
            gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
129
37
        va_list ap;
130
37
        va_start(ap, fmt);
131
37
        CPLErrorV(CE_Warning, CPLE_AppDefined, pszModFmt, ap);
132
37
        va_end(ap);
133
37
        CPLFree(pszModFmt);
134
37
    }
135
136
    void LIBERTIFF_TIFFErrorExtR(TIFF *, const char *pszModule, const char *fmt,
137
                                 ...)
138
223
    {
139
223
        char *pszModFmt =
140
223
            gdal::tiff_common::PrepareTIFFErrorFormat(pszModule, fmt);
141
223
        va_list ap;
142
223
        va_start(ap, fmt);
143
223
        CPLErrorV(CE_Failure, CPLE_AppDefined, pszModFmt, ap);
144
223
        va_end(ap);
145
223
        CPLFree(pszModFmt);
146
223
    }
147
}
148
#undef isTiled