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

Function WriteBand_Fmt19

AudioEncode/aencode.cpp:239–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void WriteBand_Fmt19(Encoder &enc, int32_t colIndex, uint32_t formatId) {
240 const float currBlockBitValue = static_cast<float>(enc.m_currBlockBitValue);
241 const float halfCurrBlockBitValue = currBlockBitValue * 0.5f;
242 const int32_t minValue = (int32_t)ceilf(-32767.0f / currBlockBitValue);
243 const int32_t maxValue = (int32_t)floorf(32767.0f / currBlockBitValue);
244
245 const float *pCurrSample = &enc.m_levelSlots[enc.m_levels][colIndex];
246 int32_t currSampleIndex = enc.m_samples_per_subband;
247 while (currSampleIndex) {
248 --currSampleIndex;
249 int32_t workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue);
250 if (minValue > workingVal) {
251 workingVal = minValue;
252 } else if (maxValue < workingVal) {
253 workingVal = maxValue;
254 }
255 pCurrSample += enc.m_numColumns;
256 int32_t baseValue = workingVal + 1;
257 if (currSampleIndex) {
258 --currSampleIndex;
259 workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue);
260 if (minValue > workingVal) {
261 workingVal = minValue;
262 } else if (maxValue < workingVal) {
263 workingVal = maxValue;
264 }
265 pCurrSample += enc.m_numColumns;
266 } else {
267 workingVal = 0;
268 }
269
270 baseValue += workingVal * 3 + 3;
271 if (currSampleIndex) {
272 --currSampleIndex;
273 workingVal = (int32_t)floorf((*pCurrSample + halfCurrBlockBitValue) / currBlockBitValue);
274 if (minValue > workingVal) {
275 workingVal = minValue;
276 } else if (maxValue < workingVal) {
277 workingVal = maxValue;
278 }
279 pCurrSample += enc.m_numColumns;
280 } else {
281 workingVal = 0;
282 }
283
284 enc.m_bits.WriteBits(workingVal * 9 + 9 + baseValue, 5);
285 }
286}
287
288void WriteBand_Fmt20(Encoder &enc, int32_t colIndex, uint32_t formatId) {
289 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