Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/base/gxsample.c
Line
Count
Source
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* Sample unpacking procedures */
18
#include "gx.h"
19
#include "gxsample.h"
20
#include "gxfixed.h"
21
#include "gximage.h"
22
/* #include "gxsamplp.h" Do not remove - this file is included below. */
23
24
/* ---------------- Lookup tables ---------------- */
25
26
/*
27
 * Define standard tables for spreading 1-bit input data.
28
 * Note that these depend on the end-orientation of the CPU.
29
 * We can't simply define them as byte arrays, because
30
 * they might not wind up properly long- or short-aligned.
31
 */
32
#define map4tox(z,a,b,c,d)\
33
    z, z^a, z^b, z^(a+b),\
34
    z^c, z^(a+c), z^(b+c), z^(a+b+c),\
35
    z^d, z^(a+d), z^(b+d), z^(a+b+d),\
36
    z^(c+d), z^(a+c+d), z^(b+c+d), z^(a+b+c+d)
37
/* Work around warnings from really picky compilers. */
38
#ifdef __STDC__
39
#  define n0L 0xffffffffU
40
#  define ffL8 0x0000ff00U
41
#  define ffL16 0x00ff0000U
42
#  define ffL24 0xff000000U
43
#else
44
#if ARCH_SIZEOF_LONG == 4
45
/*
46
 * The compiler evaluates long expressions mod 2^32.  Even very picky
47
 * compilers allow assigning signed longs to unsigned longs, so we use
48
 * signed constants.
49
 */
50
#  define n0L (-1)
51
#  define ffL8 0x0000ff00
52
#  define ffL16 0x00ff0000
53
#  define ffL24 (-0x01000000)
54
#else
55
/*
56
 * The compiler evaluates long expressions mod 2^64.
57
 */
58
#  define n0L 0xffffffffL
59
#  define ffL8 0x0000ff00L
60
#  define ffL16 0x00ff0000L
61
#  define ffL24 0xff000000L
62
#endif
63
#endif
64
#if ARCH_IS_BIG_ENDIAN
65
const bits32 lookup4x1to32_identity[16] = {
66
    map4tox(0, 0xff, ffL8, ffL16, ffL24)
67
};
68
const bits32 lookup4x1to32_inverted[16] = {
69
    map4tox(n0L, 0xff, ffL8, ffL16, ffL24)
70
};
71
#else /* !ARCH_IS_BIG_ENDIAN */
72
const bits32 lookup4x1to32_identity[16] = {
73
    map4tox(0, ffL24, ffL16, ffL8, 0xff)
74
};
75
const bits32 lookup4x1to32_inverted[16] = {
76
    map4tox(n0L, ffL24, ffL16, ffL8, 0xff)
77
};
78
#endif
79
#undef n0L
80
#undef ffL8
81
#undef ffL16
82
#undef ffL24
83
84
/* ---------------- Unpacking procedures ---------------- */
85
86
const byte *
87
sample_unpack_copy(byte * bptr, int *pdata_x, const byte * data, int data_x,
88
                uint dsize, const sample_map *ignore_smap, int spread,
89
                int ignore_num_components_per_plane)
90
16.9M
{       /* We're going to use the data right away, so no copying is needed. */
91
16.9M
    *pdata_x = data_x;
92
16.9M
    return data;
93
16.9M
}
94
95
42.2M
#define MULTIPLE_MAPS 0
96
#define TEMPLATE_sample_unpack_1 sample_unpack_1
97
#define TEMPLATE_sample_unpack_2 sample_unpack_2
98
#define TEMPLATE_sample_unpack_4 sample_unpack_4
99
#define TEMPLATE_sample_unpack_8 sample_unpack_8
100
101
#include "gxsamplp.h"
102
103
#undef MULTIPLE_MAPS
104
#undef TEMPLATE_sample_unpack_1
105
#undef TEMPLATE_sample_unpack_2
106
#undef TEMPLATE_sample_unpack_4
107
#undef TEMPLATE_sample_unpack_8
108
109
190
#define MULTIPLE_MAPS 1
110
#define TEMPLATE_sample_unpack_1 sample_unpack_1_interleaved
111
#define TEMPLATE_sample_unpack_2 sample_unpack_2_interleaved
112
#define TEMPLATE_sample_unpack_4 sample_unpack_4_interleaved
113
#define TEMPLATE_sample_unpack_8 sample_unpack_8_interleaved
114
115
#include "gxsamplp.h"
116
117
#undef TEMPLATE_sample_unpack_1
118
#undef TEMPLATE_sample_unpack_2
119
#undef TEMPLATE_sample_unpack_4
120
#undef TEMPLATE_sample_unpack_8
121
#undef MULTIPLE_MAPS