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

Function WriteBand_Fmt18

AudioEncode/aencode.cpp:210–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

208}
209
210void WriteBand_Fmt18(Encoder &enc, int32_t colIndex, uint32_t formatId) {
211 const float currBlockBitValue = static_cast<float>(enc.m_currBlockBitValue);
212 const float halfCurrBlockBitValue = enc.m_currBlockBitValue * 0.5f;
213 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue);
214 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue);
215
216 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
217 int32_t currSampleIndex = enc.m_samples_per_subband;
218 while (currSampleIndex) {
219 --currSampleIndex;
220 int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue);
221 if (minValue > val) {
222 val = minValue;
223 } else if (val > maxValue) {
224 val = maxValue;
225 }
226
227 pCurrSample += enc.m_numColumns;
228
229 if (!val) {
230 enc.m_bits.WriteBits(0, 1);
231 continue;
232 }
233
234 enc.m_bits.WriteBits(1, 1);
235 enc.m_bits.WriteBits((val == 1) ? 1 : 0, 1);
236 }
237}
238
239void WriteBand_Fmt19(Encoder &enc, int32_t colIndex, uint32_t formatId) {
240 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