/src/ghostpdl/base/gxi16bit.c
Line | Count | Source (jump to first uncovered line) |
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 | | /* 16-bit image procedures */ |
18 | | #include "gx.h" |
19 | | #include "memory_.h" |
20 | | #include "gpcheck.h" |
21 | | #include "gserrors.h" |
22 | | #include "gxfixed.h" |
23 | | #include "gxfrac.h" |
24 | | #include "gxarith.h" |
25 | | #include "gxmatrix.h" |
26 | | #include "gsccolor.h" |
27 | | #include "gspaint.h" |
28 | | #include "gxdevice.h" |
29 | | #include "gxcmap.h" |
30 | | #include "gxdcolor.h" |
31 | | #include "gxgstate.h" |
32 | | #include "gxdevmem.h" |
33 | | #include "gxcpath.h" |
34 | | #include "gximage.h" |
35 | | |
36 | | /* ---------------- Unpacking procedures ---------------- */ |
37 | | |
38 | | const byte * |
39 | | sample_unpack_16(byte * bptr, int *pdata_x, const byte * data, |
40 | | int data_x, uint dsize, const sample_map *ignore_smap, int spread, |
41 | | int ignore_num_components_per_plane) |
42 | 0 | { |
43 | | /* Assuming an identity map for all components. */ |
44 | 0 | register frac *bufp = (frac *) bptr; |
45 | 0 | uint dskip = data_x << 1; |
46 | 0 | const byte *psrc = data + dskip; |
47 | 0 | #define inc_bufp(bp, n) bp = (frac *)((byte *)(bp) + (n)) |
48 | 0 | uint sample; |
49 | 0 | int left = dsize - dskip; |
50 | |
|
51 | 0 | while (left >= 2) { |
52 | 0 | sample = ((uint) psrc[0] << 8) + psrc[1]; |
53 | 0 | *bufp = (frac)((frac_1 * (sample + 1)) >> 16); |
54 | 0 | inc_bufp(bufp, spread); |
55 | 0 | psrc += 2; |
56 | 0 | left -= 2; |
57 | 0 | } |
58 | 0 | *pdata_x = 0; |
59 | 0 | return bptr; |
60 | 0 | } |
61 | | |
62 | | const byte * |
63 | | sample_unpackicc_16(byte * bptr, int *pdata_x, const byte * data, |
64 | | int data_x, uint dsize, const sample_map *ignore_smap, int spread, |
65 | | int ignore_num_components_per_plane) |
66 | 0 | { |
67 | | /* Assuming an identity map for all components. */ |
68 | 0 | register unsigned short *bufp = (unsigned short *) bptr; |
69 | 0 | uint dskip = data_x << 1; |
70 | 0 | const byte *psrc = data + dskip; |
71 | 0 | #define inc_bufp16(bp, n) bp = ( unsigned short *)((byte *)(bp) + (n)) |
72 | 0 | uint sample; |
73 | 0 | int left = dsize - dskip; |
74 | |
|
75 | 0 | while (left >= 2) { |
76 | 0 | sample = ((uint) psrc[0] << 8) + psrc[1]; |
77 | 0 | *bufp = (unsigned short)(sample); |
78 | 0 | inc_bufp16(bufp, spread); |
79 | 0 | psrc += 2; |
80 | 0 | left -= 2; |
81 | 0 | } |
82 | 0 | *pdata_x = 0; |
83 | 0 | return bptr; |
84 | 0 | } |
85 | | const sample_unpack_proc_t sample_unpack_16_proc = sample_unpack_16; |
86 | | const sample_unpack_proc_t sample_unpackicc_16_proc = sample_unpackicc_16; |
87 | | |
88 | | /* ---------------- Rendering procedures ---------------- */ |
89 | | |
90 | | /* After unpacking, 16-bit amples have the same format as 12-bit ones */ |
91 | | /* and can be rendered by the procedures from gxi12bit.c */ |