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

Function WriteBand_Fmt20

AudioEncode/aencode.cpp:288–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288void WriteBand_Fmt20(Encoder &enc, int32_t colIndex, uint32_t formatId) {
289 const float currBlockValue = static_cast<float>(enc.m_currBlockBitValue);
290 const float halfCurrBlockValue = currBlockValue * 0.5f;
291 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockValue);
292 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockValue);
293
294 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
295 int32_t currSampleIndex = enc.m_samples_per_subband;
296 while (currSampleIndex) {
297 --currSampleIndex;
298 int32_t val = (int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue);
299 if (minValue > val) {
300 val = minValue;
301 } else if (maxValue < val) {
302 val = maxValue;
303 }
304
305 pCurrSample += enc.m_numColumns;
306 if (val == 0) {
307 if (currSampleIndex != 0 && !(int32_t)floorf((*pCurrSample + halfCurrBlockValue) / currBlockValue)) {
308 enc.m_bits.WriteBits(0, 1);
309
310 if (currSampleIndex == 0)
311 return;
312 --currSampleIndex;
313 pCurrSample += enc.m_numColumns;
314 continue;
315 }
316 enc.m_bits.WriteBits(1, 2);
317 continue;
318 }
319 enc.m_bits.WriteBits(3, 2);
320 if (val < 0) {
321 val += 2;
322 } else {
323 ++val;
324 }
325
326 enc.m_bits.WriteBits(val, 2);
327 }
328}
329
330void WriteBand_Fmt21(Encoder &enc, int32_t colIndex, uint32_t formatId) {
331 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