libosmocore  0.9.0
Osmocom core library
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 
48 };
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 
75 int osmo_conv_get_input_length(const struct osmo_conv_code *code, int len);
76 int 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 
91 void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
92  const struct osmo_conv_code *code);
93 void osmo_conv_encode_load_state(struct osmo_conv_encoder *encoder,
94  const ubit_t *input);
95 int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
96  const ubit_t *input, ubit_t *output, int n);
97 int osmo_conv_encode_flush(struct osmo_conv_encoder *encoder, ubit_t *output);
98 
99  /* All-in-one */
100 int 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;
112  int n_states;
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 
124 void osmo_conv_decode_init(struct osmo_conv_decoder *decoder,
125  const struct osmo_conv_code *code,
126  int len, int start_state);
127 void osmo_conv_decode_reset(struct osmo_conv_decoder *decoder, int start_state);
128 void osmo_conv_decode_rewind(struct osmo_conv_decoder *decoder);
129 void osmo_conv_decode_deinit(struct osmo_conv_decoder *decoder);
130 
131 int osmo_conv_decode_scan(struct osmo_conv_decoder *decoder,
132  const sbit_t *input, int n);
133 int osmo_conv_decode_flush(struct osmo_conv_decoder *decoder,
134  const sbit_t *input);
135 int 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 */
139 int osmo_conv_decode(const struct osmo_conv_code *code,
140  const sbit_t *input, ubit_t *output);
141 
142 
const struct osmo_conv_code * code
for which code?
Definition: conv.h:85
int8_t sbit_t
soft bit (-127...127)
Definition: bits.h:18
int p_idx
Current puncture index.
Definition: conv.h:87
enum osmo_conv_term term
Termination type.
Definition: conv.h:61
unsigned int * ae
accumulated error
Definition: conv.h:119
convolutional encoder state
Definition: conv.h:84
const uint8_t * next_term_state
Flush termination state.
Definition: conv.h:67
void osmo_conv_encode_init(struct osmo_conv_encoder *encoder, const struct osmo_conv_code *code)
Initialize a convolutional encoder.
Definition: conv.c:87
const struct osmo_conv_code * code
for which code?
Definition: conv.h:110
convolutional decoder state
Definition: conv.h:109
const uint8_t(* next_output)[2]
Next output array.
Definition: conv.h:63
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
structure describing a given convolutional code
Definition: conv.h:56
uint8_t state
Current state.
Definition: conv.h:88
Direct truncation.
Definition: conv.h:46
Tail biting.
Definition: conv.h:47
int o_idx
output index
Definition: conv.h:116
int p_idx
puncture index
Definition: conv.h:117
const uint8_t(* next_state)[2]
Next state array.
Definition: conv.h:64
osmo_conv_term
possibe termination types
Definition: conv.h:44
int N
Inverse of code rate.
Definition: conv.h:57
const int * puncture
Punctured bits indexes.
Definition: conv.h:69
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
int K
Constraint length.
Definition: conv.h:58
Osmocom bit level support code.
Flush encoder state.
Definition: conv.h:45
int len
of data bits
Definition: conv.h:59
const uint8_t * next_term_output
Flush termination output.
Definition: conv.h:66
unsigned int * ae_next
next accumulated error (tmp in scan)
Definition: conv.h:120
uint8_t * state_history
state history [len][n_states]
Definition: conv.h:121
int len
Max o_idx (excl. termination)
Definition: conv.h:114
uint8_t ubit_t
unpacked bit (0 or 1)
Definition: bits.h:19
int i_idx
Next input bit index.
Definition: conv.h:86
int n_states
number of states
Definition: conv.h:112