viterbi decoder: add viterbi decoder base class

Add a viterbi decoder base class that viterbi decoder
implementations can inherit from.
This commit is contained in:
Stephen Wolfe
2016-11-07 15:00:30 -05:00
parent 9cf628359b
commit 528536e3f2
7 changed files with 185 additions and 240 deletions
+1 -87
View File
@@ -27,7 +27,7 @@
* Some modifications from original Karn code by Matt Ettus
* Major modifications by adding SSE2 code by Bogdan Diaconescu
*/
#include "viterbi_decoder.h"
#include "viterbi_decoder_generic.h"
#include <cstring>
#include <iostream>
@@ -83,13 +83,6 @@
using namespace gr::ieee802_11;
viterbi_decoder::viterbi_decoder() :
d_store_pos(0) {
}
viterbi_decoder::~viterbi_decoder() {
}
void
viterbi_decoder::viterbi_butterfly2_generic(unsigned char *symbols,
unsigned char *mm0, unsigned char *mm1, unsigned char *pp0,
@@ -292,9 +285,7 @@ viterbi_decoder::viterbi_get_output_generic(unsigned char *mm0,
int bestmetric, minmetric;
int beststate = 0;
int pos = 0;
#ifndef IEEE80211_MSSE2
int j;
#endif
// circular buffer with the last ntraceback paths
d_store_pos = (d_store_pos + 1) % ntraceback;
@@ -342,42 +333,6 @@ viterbi_decoder::viterbi_get_output_generic(unsigned char *mm0,
return bestmetric;
}
uint8_t*
viterbi_decoder::depuncture(uint8_t *in) {
int count;
int n_cbps = d_ofdm->n_cbps;
uint8_t *depunctured;
if (d_ntraceback == 5) {
count = d_frame->n_sym * n_cbps;
depunctured = in;
} else {
depunctured = d_depunctured;
count = 0;
for(int i = 0; i < d_frame->n_sym; i++) {
for(int k = 0; k < n_cbps; k++) {
while (d_depuncture_pattern[count % (2 * d_k)] == 0) {
depunctured[count] = 2;
count++;
}
// Insert received bits
depunctured[count] = in[i * n_cbps + k];
count++;
while (d_depuncture_pattern[count % (2 * d_k)] == 0) {
depunctured[count] = 2;
count++;
}
}
}
}
return depunctured;
}
uint8_t*
viterbi_decoder::decode(ofdm_param *ofdm, frame_param *frame, uint8_t *in) {
@@ -469,44 +424,3 @@ viterbi_decoder::viterbi_chunks_init_generic() {
}
}
}
/* Parity lookup table */
const unsigned char viterbi_decoder::PARTAB[256] = {
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0,
};
const unsigned char viterbi_decoder::PUNCTURE_1_2[2] = {1, 1};
const unsigned char viterbi_decoder::PUNCTURE_2_3[4] = {1, 1, 1, 0};
const unsigned char viterbi_decoder::PUNCTURE_3_4[6] = {1, 1, 1, 0, 0, 1};