libosmocore 0.9.6-23.20170220git32ee5af8.fc42
Osmocom core library
Loading...
Searching...
No Matches
conv.h
Go to the documentation of this file.
1/*
2 * conv.h
3 *
4 * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
31#pragma once
32
33#include <stdint.h>
34
35#include <osmocom/core/bits.h>
36
49
57 int N;
58 int K;
59 int len;
63 const uint8_t (*next_output)[2];
64 const uint8_t (*next_state)[2];
66 const uint8_t *next_term_output;
67 const uint8_t *next_term_state;
69 const int *puncture;
70};
71
72
73/* Common */
74
75int osmo_conv_get_input_length(const struct osmo_conv_code *code, int len);
76int osmo_conv_get_output_length(const struct osmo_conv_code *code, int len);
77
78
79/* Encoding */
80
81 /* Low level API */
82
85 const struct osmo_conv_code *code;
86 int i_idx;
87 int p_idx;
88 uint8_t state;
89};
90
91void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
92 const struct osmo_conv_code *code);
93void osmo_conv_encode_load_state(struct osmo_conv_encoder *encoder,
94 const ubit_t *input);
95int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
96 const ubit_t *input, ubit_t *output, int n);
97int osmo_conv_encode_flush(struct osmo_conv_encoder *encoder, ubit_t *output);
98
99 /* All-in-one */
100int osmo_conv_encode(const struct osmo_conv_code *code,
101 const ubit_t *input, ubit_t *output);
102
103
104/* Decoding */
105
106 /* Low level API */
107
110 const struct osmo_conv_code *code;
114 int len;
116 int o_idx;
117 int p_idx;
119 unsigned int *ae;
120 unsigned int *ae_next;
121 uint8_t *state_history;
122};
123
124void osmo_conv_decode_init(struct osmo_conv_decoder *decoder,
125 const struct osmo_conv_code *code,
126 int len, int start_state);
127void osmo_conv_decode_reset(struct osmo_conv_decoder *decoder, int start_state);
128void osmo_conv_decode_rewind(struct osmo_conv_decoder *decoder);
129void osmo_conv_decode_deinit(struct osmo_conv_decoder *decoder);
130
131int osmo_conv_decode_scan(struct osmo_conv_decoder *decoder,
132 const sbit_t *input, int n);
133int osmo_conv_decode_flush(struct osmo_conv_decoder *decoder,
134 const sbit_t *input);
135int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder,
136 ubit_t *output, int has_flush, int end_state);
137
138 /* All-in-one */
139int osmo_conv_decode(const struct osmo_conv_code *code,
140 const sbit_t *input, ubit_t *output);
141
142
Osmocom bit level support code.
uint8_t ubit_t
unpacked bit (0 or 1)
Definition bits.h:23
int8_t sbit_t
soft bit (-127...127)
Definition bits.h:22
void osmo_conv_encode_init(struct osmo_conv_encoder *encoder, const struct osmo_conv_code *code)
Initialize a convolutional encoder.
Definition conv.c:87
int osmo_conv_decode(const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output)
All-in-one convolutional decoding function.
Definition conv.c:603
int osmo_conv_encode(const struct osmo_conv_code *code, const ubit_t *input, ubit_t *output)
All-in-one convolutional encoding function.
Definition conv.c:213
osmo_conv_term
possibe termination types
Definition conv.h:44
@ CONV_TERM_FLUSH
Flush encoder state.
Definition conv.h:45
@ CONV_TERM_TAIL_BITING
Tail biting.
Definition conv.h:47
@ CONV_TERM_TRUNCATION
Direct truncation.
Definition conv.h:46
structure describing a given convolutional code
Definition conv.h:56
int len
# of data bits
Definition conv.h:59
const uint8_t(* next_output)[2]
Next output array.
Definition conv.h:63
const uint8_t * next_term_state
Flush termination state
Definition conv.h:67
int N
Inverse of code rate.
Definition conv.h:57
enum osmo_conv_term term
Termination type.
Definition conv.h:61
const int * puncture
Punctured bits indexes.
Definition conv.h:69
int K
Constraint length.
Definition conv.h:58
const uint8_t * next_term_output
Flush termination output.
Definition conv.h:66
const uint8_t(* next_state)[2]
Next state array
Definition conv.h:64
convolutional decoder state
Definition conv.h:109
const struct osmo_conv_code * code
for which code?
Definition conv.h:110
uint8_t * state_history
state history [len][n_states]
Definition conv.h:121
unsigned int * ae
accumulated error
Definition conv.h:119
int len
Max o_idx (excl. termination)
Definition conv.h:114
unsigned int * ae_next
next accumulated error (tmp in scan)
Definition conv.h:120
int o_idx
output index
Definition conv.h:116
int n_states
number of states
Definition conv.h:112
int p_idx
puncture index
Definition conv.h:117
convolutional encoder state
Definition conv.h:84
const struct osmo_conv_code * code
for which code?
Definition conv.h:85
uint8_t state
Current state.
Definition conv.h:88
int p_idx
Current puncture index.
Definition conv.h:87
int i_idx
Next input bit index.
Definition conv.h:86