Removed unused viterbi39 decoder

master
ismagom 9 years ago
parent 591f583edb
commit 13d6926737

@ -35,7 +35,6 @@
#include "srslte/fec/viterbi.h"
#include "parity.h"
#include "viterbi37.h"
#include "viterbi39.h"
#define DEB 0
@ -74,28 +73,6 @@ int decode37(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) {
return q->framebits;
}
int decode39(void *o, uint8_t *symbols, uint8_t *data, uint32_t frame_length) {
srslte_viterbi_t *q = o;
if (frame_length > q->framebits) {
fprintf(stderr, "Initialized decoder for max frame length %d bits\n",
q->framebits);
return -1;
}
/* Initialize Viterbi decoder */
init_viterbi39_port(q->ptr, 0);
/* Decode block */
update_viterbi39_blk_port(q->ptr, symbols, frame_length + q->K - 1);
/* Do Viterbi chainback */
chainback_viterbi39_port(q->ptr, data, frame_length, 0);
return q->framebits;
}
void free37(void *o) {
srslte_viterbi_t *q = o;
if (q->symbols_uc) {
@ -107,14 +84,6 @@ void free37(void *o) {
delete_viterbi37_port(q->ptr);
}
void free39(void *o) {
srslte_viterbi_t *q = o;
if (q->symbols_uc) {
free(q->symbols_uc);
}
delete_viterbi39_port(q->ptr);
}
int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) {
q->K = 7;
q->R = 3;
@ -124,13 +93,13 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_
q->decode = decode37;
q->free = free37;
q->decode_f = NULL;
q->symbols_uc = malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->symbols_uc = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->symbols_uc) {
perror("malloc");
return -1;
}
if (q->tail_biting) {
q->tmp = malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
q->tmp = srslte_vec_malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->tmp) {
perror("malloc");
free37(q);
@ -149,36 +118,6 @@ int init37(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_
}
}
int init39(srslte_viterbi_t *q, uint32_t poly[3], uint32_t framebits, bool tail_biting) {
q->K = 9;
q->R = 3;
q->framebits = framebits;
q->tail_biting = tail_biting;
q->gain_quant = 32;
q->decode = decode39;
q->free = free39;
q->decode_f = NULL;
if (q->tail_biting) {
fprintf(stderr,
"Error: Tailbitting not supported in 1/3 K=9 decoder\n");
return -1;
}
q->symbols_uc = malloc(3 * (q->framebits + q->K - 1) * sizeof(uint8_t));
if (!q->symbols_uc) {
perror("malloc");
return -1;
}
if ((q->ptr = create_viterbi39_port(poly, framebits)) == NULL) {
fprintf(stderr, "create_viterbi37 failed\n");
free39(q);
return -1;
} else {
return 0;
}
}
void srslte_viterbi_set_gain_quant(srslte_viterbi_t *q, float gain_quant) {
q->gain_quant = gain_quant;
}
@ -188,8 +127,6 @@ int srslte_viterbi_init(srslte_viterbi_t *q, srslte_viterbi_type_t type, uint32_
switch (type) {
case SRSLTE_VITERBI_37:
return init37(q, poly, max_frame_length, tail_bitting);
case SRSLTE_VITERBI_39:
return init39(q, poly, max_frame_length, tail_bitting);
default:
fprintf(stderr, "Decoder not implemented\n");
return -1;

@ -1,4 +1,6 @@
/* K=9 r=1/3 Viterbi decoder in portable C
/* Adapted Viterbi Phil Karn's r=1/3 k=9 viterbi decoder to r=1/3 k=7
*
* K=9 r=1/3 Viterbi decoder in portable C
* Copyright Aug 2006, Phil Karn, KA9Q
* May be used under the terms of the GNU Affero General Public License (LGPL)
*/

@ -1,44 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 Software Radio Systems Limited
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include <stdbool.h>
void *create_viterbi39_port(uint32_t polys[3],
uint32_t len);
int init_viterbi39_port(void *p,
uint32_t starting_state);
int chainback_viterbi39_port(void *p,
uint8_t *data, /* Decoded output data */
uint32_t nbits, /* Number of data bits */
uint32_t endstate);
void delete_viterbi39_port(void *p);
int update_viterbi39_blk_port(void *p,
uint8_t *syms,
uint32_t nbits);

@ -1,173 +0,0 @@
/* K=9 r=1/3 Viterbi decoder in portable C
* Copyright Aug 2006, Phil Karn, KA9Q
* May be used under the terms of the GNU Affero General Public License (LGPL)
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <memory.h>
#include "viterbi39.h"
#include "parity.h"
typedef union {
uint32_t w[256];
} metric_t;
typedef union {
unsigned long w[8];
} decision_t;
static union {
uint8_t c[128];
} Branchtab39[3];
/* State info for instance of Viterbi decoder */
struct v39 {
metric_t metrics1; /* path metric buffer 1 */
metric_t metrics2; /* path metric buffer 2 */
decision_t *dp; /* Pointer to current decision */
metric_t *old_metrics, *new_metrics; /* Pointers to path metrics, swapped on every bit */
decision_t *decisions; /* Beginning of decisions for block */
};
/* Initialize Viterbi decoder for start of new frame */
int init_viterbi39_port(void *p, uint32_t starting_state) {
struct v39 *vp = p;
uint32_t i;
if (p == NULL)
return -1;
for (i = 0; i < 256; i++)
vp->metrics1.w[i] = 63;
vp->old_metrics = &vp->metrics1;
vp->new_metrics = &vp->metrics2;
vp->dp = vp->decisions;
vp->old_metrics->w[starting_state & 255] = 0; /* Bias known start state */
return 0;
}
void set_viterbi39_polynomial_port(uint32_t polys[3]) {
uint32_t state;
for (state = 0; state < 128; state++) {
Branchtab39[0].c[state] =
(polys[0] < 0) ^ parity((2 * state) & abs(polys[0])) ? 255 : 0;
Branchtab39[1].c[state] =
(polys[1] < 0) ^ parity((2 * state) & abs(polys[1])) ? 255 : 0;
Branchtab39[2].c[state] =
(polys[2] < 0) ^ parity((2 * state) & abs(polys[2])) ? 255 : 0;
}
}
/* Create a new instance of a Viterbi decoder */
void *create_viterbi39_port(uint32_t polys[3], uint32_t len) {
struct v39 *vp;
set_viterbi39_polynomial_port(polys);
if ((vp = (struct v39 *) malloc(sizeof(struct v39))) == NULL)
return NULL ;
if ((vp->decisions = (decision_t *) malloc((len + 8) * sizeof(decision_t)))
== NULL) {
free(vp);
return NULL ;
}
init_viterbi39_port(vp, 0);
return vp;
}
/* Viterbi chainback */
int chainback_viterbi39_port(void *p, uint8_t *data, /* Decoded output data */
uint32_t nbits, /* Number of data bits */
uint32_t endstate) { /* Terminal encoder state */
struct v39 *vp = p;
decision_t *d;
if (p == NULL)
return -1;
d = vp->decisions;
/* Make room beyond the end of the encoder register so we can
* accumulate a full byte of decoded data
*/
endstate %= 256;
/* The store into data[] only needs to be done every 8 bits.
* But this avoids a conditional branch, and the writes will
* combine in the cache anyway
*/
d += 8; /* Look past tail */
while (nbits-- != 0) {
int k;
k = (d[nbits].w[(endstate) / 32] >> (endstate % 32)) & 1;
endstate = (endstate >> 1) | (k << 7);
data[nbits] = k;
}
return 0;
}
/* Delete instance of a Viterbi decoder */
void delete_viterbi39_port(void *p) {
struct v39 *vp = p;
if (vp != NULL) {
free(vp->decisions);
free(vp);
}
}
/* C-language butterfly */
#define BFLY(i) {\
uint32_t metric,m0,m1,decision;\
metric = (Branchtab39[0].c[i] ^ sym0) + (Branchtab39[1].c[i] ^ sym1) + \
(Branchtab39[2].c[i] ^ sym2);\
m0 = vp->old_metrics->w[i] + metric;\
m1 = vp->old_metrics->w[i+128] + (765 - metric);\
decision = (signed int)(m0-m1) > 0;\
vp->new_metrics->w[2*i] = decision ? m1 : m0;\
d->w[i/16] |= decision << ((2*i)&31);\
m0 -= (metric+metric-765);\
m1 += (metric+metric-765);\
decision = (signed int)(m0-m1) > 0;\
vp->new_metrics->w[2*i+1] = decision ? m1 : m0;\
d->w[i/16] |= decision << ((2*i+1)&31);\
}
/* Update decoder with a block of demodulated symbols
* Note that nbits is the number of decoded data bits, not the number
* of symbols!
*/
int update_viterbi39_blk_port(void *p, uint8_t *syms, uint32_t nbits) {
struct v39 *vp = p;
decision_t *d;
if (p == NULL)
return -1;
d = (decision_t *) vp->dp;
while (nbits--) {
void *tmp;
uint8_t sym0, sym1, sym2;
uint32_t i;
for (i = 0; i < 8; i++)
d->w[i] = 0;
sym0 = *syms++;
sym1 = *syms++;
sym2 = *syms++;
for (i = 0; i < 128; i++)
BFLY(i);
d++;
tmp = vp->old_metrics;
vp->old_metrics = vp->new_metrics;
vp->new_metrics = tmp;
}
vp->dp = d;
return 0;
}
Loading…
Cancel
Save