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

Function WriteBand_Fmt24

AudioEncode/aencode.cpp:470–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470void WriteBand_Fmt24(Encoder &enc, int32_t colIndex, uint32_t formatId) {
471 const float currBlockBitValue = static_cast<float>(enc.m_currBlockBitValue);
472 const float halfCurrBlockBitValue = currBlockBitValue * 0.5f;
473 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue);
474 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue);
475
476 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
477 int32_t currSampleIndex = enc.m_samples_per_subband;
478 while (currSampleIndex) {
479 --currSampleIndex;
480 int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue);
481 if (minValue > val) {
482 val = minValue;
483 } else if (maxValue < val) {
484 val = maxValue;
485 }
486
487 pCurrSample += enc.m_numColumns;
488 if (!val) {
489 enc.m_bits.WriteBits(0, 1);
490 continue;
491 }
492
493 enc.m_bits.WriteBits(1, 1);
494
495 if (val != -1 && val != 1) {
496 enc.m_bits.WriteBits(1, 1);
497
498 if (val < 0) {
499 val += 3;
500 }
501 enc.m_bits.WriteBits(val, 2);
502 continue;
503 }
504
505 enc.m_bits.WriteBits(0, 1);
506 enc.m_bits.WriteBits((val == 1) ? 1 : 0, 1);
507 }
508}
509
510void WriteBand_Fmt26(Encoder &enc, int32_t colIndex, uint32_t formatId) {
511 const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue);

Callers

nothing calls this directly

Calls 1

WriteBitsMethod · 0.80

Tested by

no test coverage detected