libosmocore  0.6.3
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 #ifndef __OSMO_CONV_H__
32 #define __OSMO_CONV_H__
33 
34 #include <stdint.h>
35 
36 #include <osmocom/core/bits.h>
37 
49 };
50 
58  int N;
59  int K;
60  int len;
64  const uint8_t (*next_output)[2];
65  const uint8_t (*next_state)[2];
67  const uint8_t *next_term_output;
68  const uint8_t *next_term_state;
70  const int *puncture;
71 };
72 
73 
74 /* Common */
75 
76 int osmo_conv_get_input_length(const struct osmo_conv_code *code, int len);
77 int osmo_conv_get_output_length(const struct osmo_conv_code *code, int len);
78 
79 
80 /* Encoding */
81 
82  /* Low level API */
83 
86  const struct osmo_conv_code *code;
87  int i_idx;
88  int p_idx;
89  uint8_t state;
90 };
91 
92 void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
93  const struct osmo_conv_code *code);
94 void osmo_conv_encode_load_state(struct osmo_conv_encoder *encoder,
95  const ubit_t *input);
96 int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
97  const ubit_t *input, ubit_t *output, int n);
98 int osmo_conv_encode_flush(struct osmo_conv_encoder *encoder, ubit_t *output);
99 
100  /* All-in-one */
101 int osmo_conv_encode(const struct osmo_conv_code *code,
102  const ubit_t *input, ubit_t *output);
103 
104 
105 /* Decoding */
106 
107  /* Low level API */
108 
111  const struct osmo_conv_code *code;
113  int n_states;
115  int len;
117  int o_idx;
118  int p_idx;
120  unsigned int *ae;
121  unsigned int *ae_next;
122  uint8_t *state_history;
123 };
124 
125 void osmo_conv_decode_init(struct osmo_conv_decoder *decoder,
126  const struct osmo_conv_code *code,
127  int len, int start_state);
128 void osmo_conv_decode_reset(struct osmo_conv_decoder *decoder, int start_state);
129 void osmo_conv_decode_rewind(struct osmo_conv_decoder *decoder);
130 void osmo_conv_decode_deinit(struct osmo_conv_decoder *decoder);
131 
132 int osmo_conv_decode_scan(struct osmo_conv_decoder *decoder,
133  const sbit_t *input, int n);
134 int osmo_conv_decode_flush(struct osmo_conv_decoder *decoder,
135  const sbit_t *input);
136 int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder,
137  ubit_t *output, int has_flush, int end_state);
138 
139  /* All-in-one */
140 int osmo_conv_decode(const struct osmo_conv_code *code,
141  const sbit_t *input, ubit_t *output);
142 
143 
146 #endif /* __OSMO_CONV_H__ */