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

Function WriteBand_Fmt26

AudioEncode/aencode.cpp:510–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510void WriteBand_Fmt26(Encoder &enc, int32_t colIndex, uint32_t formatId) {
511 const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue);
512 const float halfCurrBlockValue = currBlockValue * 0.5f;
513 const int32_t minValue = static_cast<int32_t>(ceilf(-32767.0f / currBlockValue));
514 const int32_t maxValue = static_cast<int32_t>(floorf(32767.0f / currBlockValue));
515 const float *pColumnData = &enc.m_levelSlots[enc.m_levels][colIndex];
516
517 int32_t currSampleIdx = enc.m_samples_per_subband;
518 while (currSampleIdx) {
519 --currSampleIdx;
520
521 int32_t val = (int32_t)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue);
522 if (minValue > val) {
523 val = minValue;
524 } else if (maxValue < val) {
525 val = maxValue;
526 }
527
528 pColumnData += enc.m_numColumns;
529 if (!val) {
530 if (currSampleIdx) {
531 int32_t testVal = (int32_t)floorf((*pColumnData + halfCurrBlockValue) / currBlockValue);
532 if (!testVal) {
533 enc.m_bits.WriteBits(0, 1);
534
535 if (currSampleIdx == 0)
536 return;
537
538 --currSampleIdx;
539 pColumnData += enc.m_numColumns;
540 continue;
541 }
542 }
543
544 enc.m_bits.WriteBits(1, 2);
545 continue;
546 }
547
548 enc.m_bits.WriteBits(3, 2);
549
550 if (val >= 0) {
551 val += 3;
552 } else {
553 val += 4;
554 }
555
556 enc.m_bits.WriteBits(val, 3);
557 }
558}
559
560void WriteBand_Fmt27(Encoder &enc, int32_t colIndex, uint32_t formatId) {
561 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