MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / testEncodeDecode

Function testEncodeDecode

GSMShare/AMRTest.cpp:36–74  ·  view source on GitHub ↗

Pat modified to use the Viterbi base class.

Source from the content-addressed store, hash-verified

34#else
35// Pat modified to use the Viterbi base class.
36void testEncodeDecode(const char *label, ViterbiBase *coder, unsigned frameSize, unsigned iRate, unsigned order, bool debug)
37#endif
38{
39 const unsigned trials = 10;
40 cout << endl;
41 if (debug) cout << label << endl;
42 BitVector v1 = randomBitVector(frameSize);
43 if (debug) cout << "v1 " << v1 << endl;
44 BitVector v2(iRate*frameSize+iRate*order);
45#if OLD_TEST
46 (*encoder)(v1, v2);
47#else
48 coder->encode(v1,v2);
49#endif
50 if (debug) cout << "v2 " << v2 << endl;
51 for (int perr = 0; perr <= 50; perr += 10) {
52 int errs = 0;
53 // multiple trials smooths out the weirdnesses due to unfortunate positioning of noisy bits
54 for (unsigned trial = 0; trial < trials; trial++) {
55 SoftVector sv2(v2);
56 for (unsigned j = 0; j < sv2.size(); j++) {
57 if (random() % 100 < perr) sv2[j] = 0.5;
58 }
59 if (debug) cout << "n2 " << sv2 << endl;
60 BitVector v3(frameSize);
61#if OLD_TEST
62 decoder(sv2, v3);
63#else
64 coder->decode(sv2,v3);
65#endif
66 if (debug) cout << "v3 " << v3 << endl;
67 for (unsigned j = 0; j < frameSize; j++) {
68 if (v1.bit(j) != v3.bit(j)) errs++;
69 }
70 }
71 int pbbo = 100 * errs / (frameSize * trials);
72 cout << label << ", " << "% ambiguous bits in : % bad bits out = " << perr << " : " << pbbo << endl;
73 }
74}
75
76#if OLD_TEST
77//void encoder12_2(BitVector &v1, BitVector &v2) { ViterbiTCH_AFS12_2 vCoder; v1.encode(vCoder,v2); }

Callers 1

testAMRFunction · 0.70

Calls 4

randomBitVectorFunction · 0.70
encodeMethod · 0.45
sizeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected