aboutsummaryrefslogtreecommitdiffstats
path: root/lib/decoding/openbts/ViterbiR204.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/decoding/openbts/ViterbiR204.cpp')
-rw-r--r--lib/decoding/openbts/ViterbiR204.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/decoding/openbts/ViterbiR204.cpp b/lib/decoding/openbts/ViterbiR204.cpp
index 296e292..fe31aad 100644
--- a/lib/decoding/openbts/ViterbiR204.cpp
+++ b/lib/decoding/openbts/ViterbiR204.cpp
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <sstream>
#include <string.h>
+#include <cstdlib>
using namespace std;
@@ -70,7 +71,7 @@ void ViterbiR2O4::encode(const BitVector& in, BitVector& target) const
assert(sz*coder.iRate() == target.size());
// Build a "history" array where each element contains the full history.
- uint32_t history[sz];
+ uint32_t * history = (uint32_t *) malloc(sizeof(uint32_t)*sz);
uint32_t accum = 0;
for (size_t i=0; i<sz; i++) {
accum = (accum<<1) | in.bit(i);
@@ -85,6 +86,7 @@ void ViterbiR2O4::encode(const BitVector& in, BitVector& target) const
*op++ = coder.stateTable(g,index);
}
}
+ free(history);
}
@@ -224,7 +226,7 @@ void ViterbiR2O4::decode(const SoftVector &in, BitVector& target)
// Build a "history" array where each element contains the full history.
// (pat) We only use every other history element, so why are we setting them?
- uint32_t history[ctsz];
+ uint32_t * history = (uint32_t *)malloc(sizeof(uint32_t)*ctsz);
{
BitVector bits = in.sliced();
uint32_t accum = 0;
@@ -241,8 +243,8 @@ void ViterbiR2O4::decode(const SoftVector &in, BitVector& target)
}
// Precompute metric tables.
- float matchCostTable[ctsz];
- float mismatchCostTable[ctsz];
+ float * matchCostTable = (float *)malloc(sizeof(float)*ctsz);
+ float * mismatchCostTable = (float *)malloc(sizeof(float)*ctsz);
{
const float *dp = in.begin();
for (size_t i=0; i<sz; i++) {
@@ -296,6 +298,9 @@ void ViterbiR2O4::decode(const SoftVector &in, BitVector& target)
// Dont think minCost == NULL can happen.
mBitErrorCnt = minCost ? minCost->bitErrorCnt : 0;
}
+ free(history);
+ free(matchCostTable);
+ free(mismatchCostTable);
}
// vim: ts=4 sw=4