MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / III_reorder

Function III_reorder

modules/data/mp3/libmad/layer3.c:1323–1379  ·  view source on GitHub ↗

NAME: III_reorder() DESCRIPTION: reorder frequency lines of a short block into subband order */

Source from the content-addressed store, hash-verified

1321 DESCRIPTION: reorder frequency lines of a short block into subband order
1322*/
1323static
1324enum mad_error III_reorder(mad_fixed_t xr[576], struct channel const *channel,
1325 unsigned int const sfbwidth[39], mad_fixed_t tmp[576])
1326{
1327 unsigned int sb, l, f, w, sbw[3], sw[3];
1328// mad_fixed_t *tmp; // [32][3][6]
1329 // See if we can allocate this buffer on the stack and save heap
1330// char onstack = 0;
1331// if (stackfree() > (int)(100 + sizeof(mad_fixed_t)*32*3*6)) {
1332// onstack = 1;
1333// tmp = alloca(sizeof(mad_fixed_t)*32*3*6);
1334// } else {
1335// tmp = (mad_fixed_t*)malloc(sizeof(mad_fixed_t)*32*3*6);
1336// if (!tmp) return MAD_ERROR_NOMEM;
1337// }
1338
1339 stack(__FUNCTION__, __FILE__, __LINE__);
1340
1341 /* this is probably wrong for 8000 Hz mixed blocks */
1342
1343 sb = 0;
1344 if (channel->flags & mixed_block_flag) {
1345 sb = 2;
1346
1347 l = 0;
1348 while (l < 36)
1349 l += *sfbwidth++;
1350 }
1351
1352 for (w = 0; w < 3; ++w) {
1353 sbw[w] = sb;
1354 sw[w] = 0;
1355 }
1356
1357 f = *sfbwidth++;
1358 w = 0;
1359
1360 for (l = 18 * sb; l < 576; ++l) {
1361 if (f-- == 0) {
1362 f = *sfbwidth++ - 1;
1363 w = (w + 1) % 3;
1364 }
1365
1366 tmp[ (sbw[w]*3*6) + (w*6) + (sw[w]++) ] = xr[l];
1367
1368 if (sw[w] == 6) {
1369 sw[w] = 0;
1370 ++sbw[w];
1371 }
1372 }
1373
1374 memcpy(&xr[18 * sb], &tmp[sb * 3 * 6], (576 - 18 * sb) * sizeof(mad_fixed_t));
1375
1376// if (!onstack) free(tmp);
1377// // If it's on the stack, it'll go away on the return
1378 return MAD_ERROR_NONE;
1379}
1380

Callers 1

III_decodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected