conv_acc.c File Reference
`#include <stdlib.h>`
`#include <string.h>`
`#include <errno.h>`
`#include "config.h"`
`#include <osmocom/core/conv.h>`

## Data Structures

struct | vtrellis
struct | vdecoder

## Macros

#define | BIT2NRZ(REG, N) (((REG >> N) & 0x01) * 2 - 1) * -1
#define | NUM_STATES(K) (K == 7 ? 64 : 16)
#define | INIT_POINTERS(simd)

## Functions

| __attribute__ ((visibility("hidden")))
static int | conv_code_recursive (const struct osmo_conv_code *code)
static unsigned | vstate_lshift (unsigned reg, int k, int val)
static unsigned | bitswap2 (unsigned v)
static unsigned | bitswap3 (unsigned v)
static unsigned | bitswap4 (unsigned v)
static unsigned | bitswap5 (unsigned v)
static unsigned | bitswap6 (unsigned v)
static unsigned | bitswap (unsigned v, unsigned n)
static unsigned | gen_output (struct vstate *state, int val, const struct osmo_conv_code *code)
static int | gen_state_info (uint8_t *val, unsigned reg, int16_t *output, const struct osmo_conv_code *code)
static unsigned | gen_recursive_output (struct vstate *state, uint8_t *val, unsigned reg, const struct osmo_conv_code *code, int pos)
static int | gen_recursive_state_info (uint8_t *val, unsigned reg, int16_t *output, const struct osmo_conv_code *code)
static void | free_trellis (struct vtrellis *trellis)
static int | generate_trellis (struct vdecoder *dec, const struct osmo_conv_code *code)
static void | _traceback (struct vdecoder *dec, unsigned state, uint8_t *out, int len)
static void | _traceback_rec (struct vdecoder *dec, unsigned state, uint8_t *out, int len)
static int | traceback (struct vdecoder *dec, uint8_t *out, int term, int len)
static void | vdec_deinit (struct vdecoder *dec)
static int | vdec_init (struct vdecoder *dec, const struct osmo_conv_code *code)
static int | depuncture (const int8_t *in, const int *punc, int8_t *out, int len)
static void | forward_traverse (struct vdecoder *dec, const int8_t *seq)
static int | conv_decode (struct vdecoder *dec, const int8_t *seq, const int *punc, uint8_t *out, int len, int term)
static void | osmo_conv_init (void)
int | osmo_conv_decode_acc (const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output)

## Variables

static int | init_complete = 0

## Detailed Description

Accelerated Viterbi decoder implementation.

## Macro Definition Documentation

## BIT2NRZ

#define BIT2NRZ | ( |  | REG,
|  |  | N
| ) |  | (((REG >> N) & 0x01) * 2 - 1) * -1

## INIT_POINTERS

#define INIT_POINTERS | ( |  | simd | ) |

Value:
{ \
osmo_conv_metrics_k5_n2 = osmo_conv_##simd##_metrics_k5_n2; \
osmo_conv_metrics_k5_n3 = osmo_conv_##simd##_metrics_k5_n3; \
osmo_conv_metrics_k5_n4 = osmo_conv_##simd##_metrics_k5_n4; \
osmo_conv_metrics_k7_n2 = osmo_conv_##simd##_metrics_k7_n2; \
osmo_conv_metrics_k7_n3 = osmo_conv_##simd##_metrics_k7_n3; \
osmo_conv_metrics_k7_n4 = osmo_conv_##simd##_metrics_k7_n4; \
vdec_malloc = &osmo_conv_##simd##_vdec_malloc; \
vdec_free = &osmo_conv_##simd##_vdec_free; \
}

## NUM_STATES

#define NUM_STATES | ( |  | K | ) | (K == 7 ? 64 : 16)

## Function Documentation

## __attribute__()

__attribute__ | ( | (visibility("hidden")) |  | ) |

## _traceback()

static void _traceback | ( | struct vdecoder * | dec,
|  | unsigned | state,
|  | uint8_t * | out,
|  | int | len
| ) |  |

static

References vdecoder::k, vdecoder::paths, vdecoder::trellis, vtrellis::vals, and vstate_lshift().

Referenced by traceback().

## _traceback_rec()

static void _traceback_rec | ( | struct vdecoder * | dec,
|  | unsigned | state,
|  | uint8_t * | out,
|  | int | len
| ) |  |

static

References vdecoder::k, vdecoder::paths, vdecoder::trellis, vtrellis::vals, and vstate_lshift().

Referenced by traceback().

## bitswap()

static unsigned bitswap | ( | unsigned | v,
|  | unsigned | n
| ) |  |

static

References bitswap2(), bitswap3(), bitswap4(), bitswap5(), and bitswap6().

Referenced by gen_output(), and gen_recursive_output().

## bitswap2()

static unsigned bitswap2 | ( | unsigned | v | ) |

inline static

Referenced by bitswap().

## bitswap3()

static unsigned bitswap3 | ( | unsigned | v | ) |

inline static

Referenced by bitswap().

## bitswap4()

static unsigned bitswap4 | ( | unsigned | v | ) |

inline static

Referenced by bitswap().

## bitswap5()

static unsigned bitswap5 | ( | unsigned | v | ) |

inline static

Referenced by bitswap().

## bitswap6()

static unsigned bitswap6 | ( | unsigned | v | ) |

inline static

Referenced by bitswap().

## conv_code_recursive()

static int conv_code_recursive | ( | const struct osmo_conv_code * | code | ) |

inline static

References osmo_conv_code::next_term_output.

Referenced by vdec_init().

## conv_decode()

static int conv_decode | ( | struct vdecoder * | dec,
|  | const int8_t * | seq,
|  | const int * | punc,
|  | uint8_t * | out,
|  | int | len,
|  | int | term
| ) |  |

static

References CONV_TERM_TAIL_BITING, depuncture(), forward_traverse(), vdecoder::len, vdecoder::n, and traceback().

Referenced by osmo_conv_decode_acc().

## depuncture()

static int depuncture | ( | const int8_t * | in,
|  | const int * | punc,
|  | int8_t * | out,
|  | int | len
| ) |  |

static

Referenced by conv_decode().

## forward_traverse()

static void forward_traverse | ( | struct vdecoder * | dec,
|  | const int8_t * | seq
| ) |  |

static

References vdecoder::intrvl, vdecoder::len, vdecoder::metric_func, vdecoder::n, vtrellis::outputs, vdecoder::paths, vtrellis::sums, and vdecoder::trellis.

Referenced by conv_decode().

## free_trellis()

static void free_trellis | ( | struct vtrellis * | trellis | ) |

static

References vtrellis::outputs, vtrellis::sums, and vtrellis::vals.

Referenced by generate_trellis(), and vdec_deinit().

## gen_output()

static unsigned gen_output | ( | struct vstate * | state,
|  | int | val,
|  | const struct osmo_conv_code * | code
| ) |  |

static

References bitswap(), osmo_conv_code::K, osmo_conv_code::N, and osmo_conv_code::next_output.

Referenced by gen_state_info().

## gen_recursive_output()

static unsigned gen_recursive_output | ( | struct vstate * | state,
|  | uint8_t * | val,
|  | unsigned | reg,
|  | const struct osmo_conv_code * | code,
|  | int | pos
| ) |  |

static

References bitswap(), osmo_conv_code::K, osmo_conv_code::N, osmo_conv_code::next_output, osmo_conv_code::next_term_output, and vstate_lshift().

Referenced by gen_recursive_state_info().

## gen_recursive_state_info()

static int gen_recursive_state_info | ( | uint8_t * | val,
|  | unsigned | reg,
|  | int16_t * | output,
|  | const struct osmo_conv_code * | code
| ) |  |

static

References BIT2NRZ, gen_recursive_output(), osmo_conv_code::K, osmo_conv_code::N, osmo_conv_code::next_output, NUM_STATES, and vstate_lshift().

Referenced by generate_trellis().

## gen_state_info()

static int gen_state_info | ( | uint8_t * | val,
|  | unsigned | reg,
|  | int16_t * | output,
|  | const struct osmo_conv_code * | code
| ) |  |

static

References BIT2NRZ, gen_output(), osmo_conv_code::K, osmo_conv_code::N, and vstate_lshift().

Referenced by generate_trellis().

## generate_trellis()

static int generate_trellis | ( | struct vdecoder * | dec,
|  | const struct osmo_conv_code * | code
| ) |  |

static

For termination other than tail-biting, initialize the zero state as the encoder starting state. Initialize with the maximum accumulated sum at length equal to the constraint length.

References CONV_TERM_TAIL_BITING, free_trellis(), gen_recursive_state_info(), gen_state_info(), osmo_conv_code::K, osmo_conv_code::N, NUM_STATES, vtrellis::num_states, vtrellis::outputs, vdecoder::recursive, vtrellis::sums, osmo_conv_code::term, vdecoder::trellis, and vtrellis::vals.

Referenced by vdec_init().

## osmo_conv_init()

static void osmo_conv_init | ( | void |  | ) |

static

Usage of curly braces is mandatory, because we use multi-line define.

References init_complete, INIT_POINTERS, and sse41_supported.

Referenced by osmo_conv_decode_acc().

## traceback()

static int traceback | ( | struct vdecoder * | dec,
|  | uint8_t * | out,
|  | int | term,
|  | int | len
| ) |  |

static

References _traceback(), _traceback_rec(), CONV_TERM_FLUSH, vdecoder::k, vdecoder::len, vtrellis::num_states, vdecoder::paths, vdecoder::recursive, vtrellis::sums, vdecoder::trellis, and vstate_lshift().

Referenced by conv_decode().

## vdec_deinit()

static void vdec_deinit | ( | struct vdecoder * | dec | ) |

static

References free_trellis(), vdecoder::paths, and vdecoder::trellis.

Referenced by osmo_conv_decode_acc(), and vdec_init().

## vdec_init()

static int vdec_init | ( | struct vdecoder * | dec,
|  | const struct osmo_conv_code * | code
| ) |  |

static

References conv_code_recursive(), CONV_TERM_FLUSH, generate_trellis(), vdecoder::intrvl, osmo_conv_code::K, vdecoder::k, osmo_conv_code::len, vdecoder::len, vdecoder::metric_func, osmo_conv_code::N, vdecoder::n, NUM_STATES, vdecoder::paths, vdecoder::recursive, osmo_conv_code::term, and vdec_deinit().

Referenced by osmo_conv_decode_acc().

## vstate_lshift()

static unsigned vstate_lshift | ( | unsigned | reg,
|  | int | k,
|  | int | val
| ) |  |

static

Referenced by _traceback(), _traceback_rec(), gen_recursive_output(), gen_recursive_state_info(), gen_state_info(), and traceback().

## Variable Documentation

## init_complete

int init_complete = 0

static

Referenced by osmo_conv_decode_acc(), and osmo_conv_init().