1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
Copyright (C) 2017-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/
/*
WARNING: This file was generated by the dkct program (see
http://dktools.sourceforge.net/ for details).
Changes you make here will be lost if dkct is run again!
You should modify the original source and run dkct on it.
Original source: dk4pxres.ctr
*/
#ifndef DK4PXRES_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4PXRES_H_INCLUDED 1
#line 9 "dk4pxres.ctr"
/** @file dk4pxres.h Pixel resampling.
*/
#ifndef DK4CONF_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif
#ifndef DK4PXBIT_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4pxbit.h"
#else
#include <dktools-4/dk4pxbit.h>
#endif
#endif
/** Structure to resample pixels.
*/
typedef struct {
unsigned long nom; /**< Nominator in scale factor. */
unsigned long denom; /**< Denominator in scale factor. */
unsigned long denom2; /**< Half of the denominator. */
} dk4_px_resample_t;
#ifdef __cplusplus
extern "C" {
#endif
/** Initialize resampler structure.
@param pxrptr Resampler structure to initialize.
*/
void
dk4pxres_init(dk4_px_resample_t *pxrptr);
/** Set up resample structure for conversions.
@param pxrptr Resample structure to set up.
@param ibits Number of input bits.
@param obits Number of output (result) bits.
@return 1 on success, 0 on error.
*/
int
dk4pxres_setup(
dk4_px_resample_t *pxrptr,
size_t ibits,
size_t obits
);
/** Set up resample structure for conversions for unusual maxval values.
Input is from a range with unusual maxval, output is prepared
for a given bit depth.
@param pxrptr Resample structure to set up.
@param imaxval Maximum value for input pixel data.
@param obits Number of output (result) bits.
@return 1 on success, 0 on error.
*/
int
dk4pxres_setup_from_maxval(
dk4_px_resample_t *pxrptr,
dk4_px_t imaxval,
size_t obits
);
/** Set up resample structure for conversions for unusual maxval values.
Input has a given bit depth, output must be in the range up to s
specified maxval.
@param pxrptr Resample structure to set up.
@param ibits Input bit depth.
@param omaxval Maximum value for output pixel data.
@return 1 on success, 0 on error.
*/
int
dk4pxres_setup_to_maxval(
dk4_px_resample_t *pxrptr,
size_t ibits,
dk4_px_t omaxval
);
/** Resample pixel component from old bit width to new bit width.
@param pxrptr Resample structure to use.
@param in Component value in old bit depth.
@return Resampling result (component value in new bit depth).
*/
dk4_px_t
dk4pxres_get(
dk4_px_resample_t const *pxrptr,
dk4_px_t in
);
/** Check whether a component value can be resampled without quality loss.
@param pxrptr Resample structure to use.
@param in Component value in old bit depth.
@return 1 on success (no division remainder), 0 on error
(skipped division remainder results in quality loss).
*/
int
dk4pxres_check(
dk4_px_resample_t const *pxrptr,
dk4_px_t in
);
/** Resample multiple values to new bit depth.
@param dptr Array containing values to resample, results on output.
@param dsz Number of elements in array.
@param pxrptr Resample structure to use.
@return 1 on success, 0 on error.
*/
int
dk4pxres_multiple(
dk4_px_t *dptr,
size_t dsz,
dk4_px_resample_t const *pxrptr
);
#ifdef __cplusplus
}
#endif
/* vim: set ai sw=4 ts=4 : */
#endif
|