libosmocore  0.9.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 #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