MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / WriteBand_Fmt29

Function WriteBand_Fmt29

AudioEncode/aencode.cpp:595–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593}
594
595void WriteBand_Fmt29(Encoder &enc, int32_t colIndex, uint32_t formatId) {
596 const float currBitValue = (float)enc.m_currBlockBitValue;
597 const float halfCurrBitValue = currBitValue * 0.5f;
598 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBitValue);
599 const int32_t maxValue = (int32_t)floorf(32767.0f / currBitValue);
600
601 const float *pColumnData = &enc.m_levelSlots[enc.m_levels][colIndex];
602 int32_t currSampleIndex = enc.m_samples_per_subband;
603 while (currSampleIndex) {
604 --currSampleIndex;
605
606 int32_t val = (int32_t)floorf((*pColumnData + halfCurrBitValue) / currBitValue);
607 if (minValue > val) {
608 val = minValue;
609 } else if (maxValue < val) {
610 val = maxValue;
611 }
612
613 int32_t baseValue = val + 5;
614 pColumnData += enc.m_numColumns;
615 if (currSampleIndex != 0) {
616 --currSampleIndex;
617
618 val = (int32_t)floorf((*pColumnData + halfCurrBitValue) / currBitValue);
619 if (minValue > val) {
620 val = minValue;
621 } else if (maxValue < val) {
622 val = maxValue;
623 }
624
625 pColumnData += enc.m_numColumns;
626 } else {
627 val = 0;
628 }
629
630 enc.m_bits.WriteBits(11 * val + 55 + baseValue, 7);
631 }
632}
633
634int ReadSample_init(Encoder &enc, ReadSampleFunction *read, void *data) {
635 enc.m_reader = read;

Callers

nothing calls this directly

Calls 1

WriteBitsMethod · 0.80

Tested by

no test coverage detected