FastLED 3.9.15
Loading...
Searching...
No Matches

◆ DequantBlock()

static int fl::third_party::DequantBlock ( int32_t * inbuf,
int32_t * outbuf,
int num,
int scale )
static

Definition at line 140 of file dqchan.hpp.

141{
142 int tab4[4];
143 int32_t scalef, scalei, shift;
144 int32_t sx, x, y;
145 int32_t mask = 0;
146 const int32_t *tab16, *coef;
147
148 tab16 = pow43_14[scale & 0x3];
149 scalef = pow14[scale & 0x3];
150 scalei = MIN(scale >> 2, 31); /* smallest input scale = -47, so smallest scalei = -12 */
151
152 /* cache first 4 values */
153 shift = MIN(scalei + 3, 31);
154 shift = MAX(shift, 0);
155 tab4[0] = 0;
156 tab4[1] = tab16[1] >> shift;
157 tab4[2] = tab16[2] >> shift;
158 tab4[3] = tab16[3] >> shift;
159
160 do {
161
162 sx = *inbuf++;
163 x = sx & 0x7fffffff; /* sx = sign|mag */
164
165 if (x < 4) {
166
167 y = tab4[x];
168
169 } else if (x < 16) {
170
171 y = tab16[x];
172 y = (scalei < 0) ? y << -scalei : y >> scalei;
173
174 } else {
175
176 if (x < 64) {
177
178 y = pow43[x-16];
179
180 /* fractional scale */
181 y = MULSHIFT32(y, scalef);
182 shift = scalei - 3;
183
184 } else {
185
186 /* normalize to [0x40000000, 0x7fffffff] */
187 x <<= 17;
188 shift = 0;
189 if (x < 0x08000000)
190 x <<= 4, shift += 4;
191 if (x < 0x20000000)
192 x <<= 2, shift += 2;
193 if (x < 0x40000000)
194 x <<= 1, shift += 1;
195
196 coef = (x < SQRTHALF) ? poly43lo : poly43hi;
197
198 /* polynomial */
199 y = coef[0];
200 y = MULSHIFT32(y, x) + coef[1];
201 y = MULSHIFT32(y, x) + coef[2];
202 y = MULSHIFT32(y, x) + coef[3];
203 y = MULSHIFT32(y, x) + coef[4];
204 y = MULSHIFT32(y, pow2frac[shift]) << 3;
205
206 /* fractional scale */
207 y = MULSHIFT32(y, scalef);
208 shift = scalei - pow2exp[shift];
209 }
210
211 /* integer scale */
212 if (shift < 0) {
213 shift = -shift;
214 if (y > ((int32_t)0x7fffffff >> shift))
215 y = (int32_t)0x7fffffff; /* clip */
216 else
217 y <<= shift;
218 } else {
219 y >>= shift;
220 }
221 }
222
223 /* sign and store */
224 mask |= y;
225 *outbuf++ = (sx < 0) ? -y : y;
226
227 } while (--num);
228
229 return mask;
230}
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::UISlider scale("Scale", 4,.1, 4,.1)
#define MIN(a, b)
Definition coder.h:64
#define MAX(a, b)
Definition coder.h:60
#define SQRTHALF
Definition dqchan.hpp:105
int32_t pow43_14[4][16]
Definition dqchan.hpp:66
__inline int32_t MULSHIFT32(int32_t x, int32_t y) FL_NOEXCEPT
Multiply together two 32-bit numbers and return the top 32-bits of the result.
Definition assembly.h:503
int32_t poly43lo[5]
Definition dqchan.hpp:115
int32_t pow14[4]
Definition dqchan.hpp:61
int32_t poly43hi[5]
Definition dqchan.hpp:116
fl::i32 int32_t
Definition coder.h:220
int32_t pow2frac[8]
Definition dqchan.hpp:121
int32_t pow43[]
Definition dqchan.hpp:89

References FL_NOEXCEPT, MAX, MIN, MULSHIFT32(), poly43hi, poly43lo, pow14, pow2exp, pow2frac, pow43, pow43_14, scale, SQRTHALF, fl::x, and fl::y.

Referenced by DequantChannel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: