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

Function WriteBand_Fmt22

AudioEncode/aencode.cpp:364–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void WriteBand_Fmt22(Encoder &enc, int32_t colIndex, uint32_t formatId) {
365 const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue);
366 const float halfCurrBlockValue = currBlockValue * 0.5f;
367 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue);
368 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue);
369
370 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
371
372 int32_t currSampleIndex = enc.m_samples_per_subband;
373 while (currSampleIndex) {
374 --currSampleIndex;
375 int32_t workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue);
376 if (minValue > workingVal) {
377 workingVal = minValue;
378 } else if (maxValue < workingVal) {
379 workingVal = maxValue;
380 }
381
382 int32_t baseValue = workingVal + 2;
383 pCurrSample += enc.m_numColumns;
384 if (currSampleIndex) {
385 --currSampleIndex;
386 workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue);
387 if (minValue > workingVal) {
388 workingVal = minValue;
389 } else if (maxValue < workingVal) {
390 workingVal = maxValue;
391 }
392 pCurrSample += enc.m_numColumns;
393 } else {
394 workingVal = 0;
395 }
396
397 baseValue += workingVal * 5 + 10;
398 if (currSampleIndex) {
399 --currSampleIndex;
400 workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue);
401 if (minValue > workingVal) {
402 workingVal = minValue;
403 } else if (maxValue < workingVal) {
404 workingVal = maxValue;
405 }
406 pCurrSample += enc.m_numColumns;
407 } else {
408 workingVal = 0;
409 }
410
411 enc.m_bits.WriteBits(workingVal * 25 + 50 + baseValue, 7);
412 }
413}
414
415void WriteBand_Fmt23(Encoder &enc, int32_t colIndex, uint32_t formatId) {
416 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