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

◆ IntensityProcMPEG1()

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

Definition at line 113 of file stproc.hpp.

115{
116 (void)mixFlag; // Unused parameter - reserved for future use
117 int32_t i=0, j=0, n=0, cb=0, w=0;
118 int32_t sampsLeft, isf, mOutL, mOutR, xl, xr;
119 int32_t fl, fr, fls[3], frs[3];
120 int32_t cbStartL=0, cbStartS=0, cbEndL=0, cbEndS=0;
121 int32_t *isfTab;
122
123 /* NOTE - this works fine for mixed blocks, as long as the switch point starts in the
124 * short block section (i.e. on or after sample 36 = sfBand->l[8] = 3*sfBand->s[3]
125 * is this a safe assumption?
126 * TODO - intensity + mixed not quite right (diff = 11 on he_mode)
127 * figure out correct implementation (spec ambiguous about when to do short block reorder)
128 */
129 if (cbi[1].cbType == 0) {
130 /* long block */
131 cbStartL = cbi[1].cbEndL + 1;
132 cbEndL = cbi[0].cbEndL + 1;
133 cbStartS = cbEndS = 0;
134 i = fh->sfBand->l[cbStartL];
135 } else if (cbi[1].cbType == 1 || cbi[1].cbType == 2) {
136 /* short or mixed block */
137 cbStartS = cbi[1].cbEndSMax + 1;
138 cbEndS = cbi[0].cbEndSMax + 1;
139 cbStartL = cbEndL = 0;
140 i = 3 * fh->sfBand->s[cbStartS];
141 }
142
143 sampsLeft = nSamps - i; /* process to length of left */
144 isfTab = (int32_t *)ISFMpeg1[midSideFlag];
145 mOutL = mOutR = 0;
146
147 /* long blocks */
148 for (cb = cbStartL; cb < cbEndL && sampsLeft > 0; cb++) {
149 isf = sfis->l[cb];
150 if (isf == 7) {
151 fl = ISFIIP[midSideFlag][0];
152 fr = ISFIIP[midSideFlag][1];
153 } else {
154 fl = isfTab[isf];
155 fr = isfTab[6] - isfTab[isf];
156 }
157
158 n = fh->sfBand->l[cb + 1] - fh->sfBand->l[cb];
159 for (j = 0; j < n && sampsLeft > 0; j++, i++) {
160 xr = MULSHIFT32(fr, x[0][i]) << 2; x[1][i] = xr; mOutR |= FASTABS(xr);
161 xl = MULSHIFT32(fl, x[0][i]) << 2; x[0][i] = xl; mOutL |= FASTABS(xl);
162 sampsLeft--;
163 }
164 }
165
166 /* short blocks */
167 for (cb = cbStartS; cb < cbEndS && sampsLeft >= 3; cb++) {
168 for (w = 0; w < 3; w++) {
169 isf = sfis->s[cb][w];
170 if (isf == 7) {
171 fls[w] = ISFIIP[midSideFlag][0];
172 frs[w] = ISFIIP[midSideFlag][1];
173 } else {
174 fls[w] = isfTab[isf];
175 frs[w] = isfTab[6] - isfTab[isf];
176 }
177 }
178
179 n = fh->sfBand->s[cb + 1] - fh->sfBand->s[cb];
180 for (j = 0; j < n && sampsLeft >= 3; j++, i+=3) {
181 xr = MULSHIFT32(frs[0], x[0][i+0]) << 2; x[1][i+0] = xr; mOutR |= FASTABS(xr);
182 xl = MULSHIFT32(fls[0], x[0][i+0]) << 2; x[0][i+0] = xl; mOutL |= FASTABS(xl);
183 xr = MULSHIFT32(frs[1], x[0][i+1]) << 2; x[1][i+1] = xr; mOutR |= FASTABS(xr);
184 xl = MULSHIFT32(fls[1], x[0][i+1]) << 2; x[0][i+1] = xl; mOutL |= FASTABS(xl);
185 xr = MULSHIFT32(frs[2], x[0][i+2]) << 2; x[1][i+2] = xr; mOutR |= FASTABS(xr);
186 xl = MULSHIFT32(fls[2], x[0][i+2]) << 2; x[0][i+2] = xl; mOutL |= FASTABS(xl);
187 sampsLeft -= 3;
188 }
189 }
190 mOut[0] = mOutL;
191 mOut[1] = mOutR;
192
193 return;
194}
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 ISFMpeg1[2][7]
Definition trigtabs.hpp:164
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, ISFMpeg1, MAX_NCHAN, MAX_NSAMP, MULSHIFT32(), and fl::x.

Referenced by Dequantize().

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