| 558 | } |
| 559 | |
| 560 | void WriteBand_Fmt27(Encoder &enc, int32_t colIndex, uint32_t formatId) { |
| 561 | const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue); |
| 562 | const float halfCurrBlockValue = currBlockValue * 0.5f; |
| 563 | const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue); |
| 564 | const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue); |
| 565 | |
| 566 | const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex]; |
| 567 | int32_t currSampleIndex = enc.m_samples_per_subband; |
| 568 | while (currSampleIndex) { |
| 569 | --currSampleIndex; |
| 570 | int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue); |
| 571 | if (val < minValue) { |
| 572 | val = minValue; |
| 573 | } else if (maxValue < val) { |
| 574 | val = maxValue; |
| 575 | } |
| 576 | |
| 577 | pCurrSample += enc.m_numColumns; |
| 578 | if (!val) { |
| 579 | enc.m_bits.WriteBits(0, 1); |
| 580 | continue; |
| 581 | } |
| 582 | |
| 583 | enc.m_bits.WriteBits(1, 1); |
| 584 | |
| 585 | if (val < 0) { |
| 586 | val += 4; |
| 587 | } else { |
| 588 | val += 3; |
| 589 | } |
| 590 | |
| 591 | enc.m_bits.WriteBits(val, 3); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | void WriteBand_Fmt29(Encoder &enc, int32_t colIndex, uint32_t formatId) { |
| 596 | const float currBitValue = (float)enc.m_currBlockBitValue; |