From 792330777d7c21df02ce1ecb6f876b076a14b519 Mon Sep 17 00:00:00 2001 From: Piotr Krysik Date: Tue, 27 Feb 2018 08:34:03 +0100 Subject: Portability fix: replacing tables of variable size with memory allocations --- lib/decoding/openbts/AmrCoder.cpp | 75 +++++++++++++++++++++++------------- lib/decoding/openbts/ViterbiR204.cpp | 13 +++++-- 2 files changed, 58 insertions(+), 30 deletions(-) (limited to 'lib/decoding/openbts') diff --git a/lib/decoding/openbts/AmrCoder.cpp b/lib/decoding/openbts/AmrCoder.cpp index 718baf0..db5b2d8 100644 --- a/lib/decoding/openbts/AmrCoder.cpp +++ b/lib/decoding/openbts/AmrCoder.cpp @@ -24,11 +24,10 @@ #include #include #include +#include using namespace std; - - ViterbiTCH_AFS12_2::ViterbiTCH_AFS12_2() { assert(mDeferral < 32); @@ -378,7 +377,7 @@ void ViterbiTCH_AFS12_2::decode(const SoftVector &in, BitVector& target) assert(sz == decoder.iRate()*target.size()); // Build a "history" array where each element contains the full history. - uint32_t history[ctsz]; + uint32_t * history = (uint32_t *)malloc(sizeof(uint32_t)*ctsz); { BitVector bits = in.sliced(); uint32_t accum = 0; @@ -394,8 +393,8 @@ void ViterbiTCH_AFS12_2::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 #include #include +#include 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; ibitErrorCnt : 0; } + free(history); + free(matchCostTable); + free(mismatchCostTable); } // vim: ts=4 sw=4 -- cgit v1.2.3