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

Function WriteBand_Fmt23

AudioEncode/aencode.cpp:415–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415void WriteBand_Fmt23(Encoder &enc, int32_t colIndex, uint32_t formatId) {
416 const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue);
417 const float halfCurrBlockValue = currBlockValue * 0.5f;
418 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue);
419 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue);
420
421 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
422 int32_t currSampleIndex = enc.m_samples_per_subband;
423 while (currSampleIndex) {
424 --currSampleIndex;
425
426 int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue);
427 if (minValue > val) {
428 val = minValue;
429 } else if (maxValue < val) {
430 val = maxValue;
431 }
432
433 pCurrSample += enc.m_numColumns;
434 if (!val) {
435 if (currSampleIndex != 0) {
436 if (!(int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) {
437 enc.m_bits.WriteBits(0, 1);
438
439 if (currSampleIndex == 0)
440 return;
441 --currSampleIndex;
442
443 pCurrSample += enc.m_numColumns;
444 continue;
445 }
446 }
447
448 enc.m_bits.WriteBits(1, 2);
449 continue;
450 }
451
452 enc.m_bits.WriteBits(3, 2);
453
454 if (val != -1 && val != 1) {
455 enc.m_bits.WriteBits(1, 1);
456
457 if (val < 0) {
458 val += 3;
459 }
460
461 enc.m_bits.WriteBits(val, 2);
462 continue;
463 }
464
465 enc.m_bits.WriteBits(0, 1);
466 enc.m_bits.WriteBits((val == 1) ? 1 : 0, 1);
467 }
468}
469
470void WriteBand_Fmt24(Encoder &enc, int32_t colIndex, uint32_t formatId) {
471 const float currBlockBitValue = static_cast<float>(enc.m_currBlockBitValue);

Callers

nothing calls this directly

Calls 1

WriteBitsMethod · 0.80

Tested by

no test coverage detected