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

◆ IntensityProcMPEG2()

void fl::third_party::IntensityProcMPEG2 ( int32_t x[MAX_NCHAN][MAX_NSAMP],
int32_t nSamps,
FrameHeader * fh,
ScaleFactorInfoSub * sfis,
CriticalBandInfo * cbi,
ScaleFactorJS * sfjs,
int32_t midSideFlag,
int32_t mixFlag,
int32_t mOut[2] )

Definition at line 220 of file stproc.hpp.

222{
223 (void)mixFlag; // Unused parameter - reserved for future use
224 int32_t i, j, k, n, r, cb, w;
225 int32_t fl, fr, mOutL, mOutR, xl, xr;
226 int32_t sampsLeft;
227 int32_t isf, sfIdx, tmp, il[23];
228 int32_t *isfTab;
229 int32_t cbStartL, cbStartS, cbEndL, cbEndS;
230
231 isfTab = (int32_t *)ISFMpeg2[sfjs->intensityScale][midSideFlag];
232 mOutL = mOutR = 0;
233
234 /* fill buffer with illegal intensity positions (depending on slen) */
235 for (k = r = 0; r < 4; r++) {
236 tmp = (1 << sfjs->slen[r]) - 1;
237 for (j = 0; j < sfjs->nr[r]; j++, k++)
238 il[k] = tmp;
239 }
240
241 if (cbi[1].cbType == 0) {
242 /* long blocks */
243 il[21] = il[22] = 1;
244 cbStartL = cbi[1].cbEndL + 1; /* start at end of right */
245 cbEndL = cbi[0].cbEndL + 1; /* process to end of left */
246 i = fh->sfBand->l[cbStartL];
247 sampsLeft = nSamps - i;
248
249 for(cb = cbStartL; cb < cbEndL; cb++) {
250 sfIdx = sfis->l[cb];
251 if (sfIdx == il[cb]) {
252 fl = ISFIIP[midSideFlag][0];
253 fr = ISFIIP[midSideFlag][1];
254 } else {
255 isf = (sfis->l[cb] + 1) >> 1;
256 fl = isfTab[(sfIdx & 0x01 ? isf : 0)];
257 fr = isfTab[(sfIdx & 0x01 ? 0 : isf)];
258 }
259 n = MIN(fh->sfBand->l[cb + 1] - fh->sfBand->l[cb], sampsLeft);
260
261 for(j = 0; j < n; j++, i++) {
262 xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr);
263 xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl);
264 }
265
266 /* early exit once we've used all the non-zero samples */
267 sampsLeft -= n;
268 if (sampsLeft == 0)
269 break;
270 }
271 } else {
272 /* short or mixed blocks */
273 il[12] = 1;
274
275 for(w = 0; w < 3; w++) {
276 cbStartS = cbi[1].cbEndS[w] + 1; /* start at end of right */
277 cbEndS = cbi[0].cbEndS[w] + 1; /* process to end of left */
278 i = 3 * fh->sfBand->s[cbStartS] + w;
279
280 /* skip through sample array by 3, so early-exit logic would be more tricky */
281 for(cb = cbStartS; cb < cbEndS; cb++) {
282 sfIdx = sfis->s[cb][w];
283 if (sfIdx == il[cb]) {
284 fl = ISFIIP[midSideFlag][0];
285 fr = ISFIIP[midSideFlag][1];
286 } else {
287 isf = (sfis->s[cb][w] + 1) >> 1;
288 fl = isfTab[(sfIdx & 0x01 ? isf : 0)];
289 fr = isfTab[(sfIdx & 0x01 ? 0 : isf)];
290 }
291 n = fh->sfBand->s[cb + 1] - fh->sfBand->s[cb];
292
293 for(j = 0; j < n; j++, i+=3) {
294 xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr);
295 xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl);
296 }
297 }
298 }
299 }
300 mOut[0] = mOutL;
301 mOut[1] = mOutR;
302
303 return;
304}
#define MIN(a, b)
Definition coder.h:64
const int32_t ISFIIP[2][2]
Definition trigtabs.hpp:218
__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
__inline int32_t FASTABS(int32_t x) FL_NOEXCEPT
Absolute value of x.
Definition assembly.h:513
const int32_t ISFMpeg2[2][2][16]
Definition trigtabs.hpp:186
fl::i32 int32_t
Definition coder.h:220
const SFBandTable * sfBand
Definition coder.h:175
Base definition for an LED controller.
Definition crgb.hpp:179

References FASTABS(), FL_NOEXCEPT, ISFIIP, ISFMpeg2, MAX_NCHAN, MAX_NSAMP, MIN, MULSHIFT32(), and fl::x.

Referenced by Dequantize().

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