#######################################################################################################################* *-----------------------------------------------------Vorbis frame--------------------------------------------------------* *#########################################################################################################################*/ Vorbis spec 4.3. Audio packe
| 1444 | *#########################################################################################################################*/ |
| 1445 | /* Vorbis spec 4.3. Audio packet decode and synthesis */ |
| 1446 | cc_result Vorbis_DecodeFrame(struct VorbisState* ctx) { |
| 1447 | /* frame header */ |
| 1448 | cc_uint32 packetType; |
| 1449 | struct Mapping* mapping; |
| 1450 | struct Mode* mode; |
| 1451 | int modeIdx; |
| 1452 | |
| 1453 | /* floor/residue */ |
| 1454 | cc_bool hasFloor[VORBIS_MAX_CHANS]; |
| 1455 | cc_bool hasResidue[VORBIS_MAX_CHANS]; |
| 1456 | cc_bool doNotDecode[VORBIS_MAX_CHANS]; |
| 1457 | float* data[VORBIS_MAX_CHANS]; |
| 1458 | int submap, floorIdx; |
| 1459 | int ch, residueIdx; |
| 1460 | |
| 1461 | /* inverse coupling */ |
| 1462 | int magChannel, angChannel; |
| 1463 | float* magValues, m; |
| 1464 | float* angValues, a; |
| 1465 | |
| 1466 | /* misc variables */ |
| 1467 | float* tmp; |
| 1468 | cc_uint32 alignSkip; |
| 1469 | int i, j; |
| 1470 | cc_result res; |
| 1471 | |
| 1472 | res = Vorbis_TryReadBits(ctx, 1, &packetType); |
| 1473 | if (res) return res; |
| 1474 | if (packetType) return VORBIS_ERR_FRAME_TYPE; |
| 1475 | |
| 1476 | modeIdx = Vorbis_ReadBits(ctx, ctx->modeNumBits); |
| 1477 | mode = &ctx->modes[modeIdx]; |
| 1478 | mapping = &ctx->mappings[mode->mappingIdx]; |
| 1479 | |
| 1480 | /* decode window shape */ |
| 1481 | ctx->curBlockSize = ctx->blockSizes[mode->blockSizeFlag]; |
| 1482 | ctx->dataSize = ctx->curBlockSize / 2; |
| 1483 | /* long window lapping flags - we don't care about them though */ |
| 1484 | if (mode->blockSizeFlag) { Vorbis_ReadBits(ctx, 2); } /* TODO: do we just SkipBits here */ |
| 1485 | |
| 1486 | /* swap prev and cur outputs around */ |
| 1487 | tmp = ctx->values[1]; ctx->values[1] = ctx->values[0]; ctx->values[0] = tmp; |
| 1488 | Mem_Set(ctx->values[0], 0, ctx->channels * ctx->curBlockSize); |
| 1489 | |
| 1490 | for (i = 0; i < ctx->channels; i++) |
| 1491 | { |
| 1492 | ctx->curOutput[i] = ctx->values[0] + i * ctx->curBlockSize; |
| 1493 | ctx->prevOutput[i] = ctx->values[1] + i * ctx->prevBlockSize; |
| 1494 | } |
| 1495 | |
| 1496 | /* decode floor */ |
| 1497 | for (i = 0; i < ctx->channels; i++) |
| 1498 | { |
| 1499 | submap = mapping->mux[i]; |
| 1500 | floorIdx = mapping->floorIdx[submap]; |
| 1501 | hasFloor[i] = Floor_DecodeFrame(ctx, &ctx->floors[floorIdx], i); |
| 1502 | hasResidue[i] = hasFloor[i]; |
| 1503 | } |
no test coverage detected