summaryrefslogtreecommitdiffstats
path: root/Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h
diff options
context:
space:
mode:
authorTom2012-01-11 17:00:30 +0100
committerTom2012-01-11 17:00:30 +0100
commit9fcc469afa01fc9ea42e4cbb96c5b195c5bcd371 (patch)
tree89d4015f6a34119069665d74a67d871fcd124509 /Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h
parentrefresh (diff)
downloadimsi-catcher-detection-9fcc469afa01fc9ea42e4cbb96c5b195c5bcd371.tar.gz
imsi-catcher-detection-9fcc469afa01fc9ea42e4cbb96c5b195c5bcd371.tar.xz
imsi-catcher-detection-9fcc469afa01fc9ea42e4cbb96c5b195c5bcd371.zip
all reupped
Diffstat (limited to 'Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h')
-rw-r--r--Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h b/Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h
new file mode 100644
index 0000000..db3058c
--- /dev/null
+++ b/Src/osmolib/src/shared/libosmocore/include/osmocom/core/conv.h
@@ -0,0 +1,115 @@
+/*
+ * conv.h
+ *
+ * Copyright (C) 2011 Sylvain Munaut <tnt@246tNt.com>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*! \defgroup conv Convolutional encoding and decoding routines
+ * @{
+ */
+
+/*! \file conv.h
+ * \file Osmocom convolutional encoder and decoder
+ */
+
+#ifndef __OSMO_CONV_H__
+#define __OSMO_CONV_H__
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+
+/*! \brief structure describing a given convolutional code */
+struct osmo_conv_code {
+ int N;
+ int K;
+ int len;
+
+ const uint8_t (*next_output)[2];
+ const uint8_t (*next_state)[2];
+
+ const uint8_t *next_term_output;
+ const uint8_t *next_term_state;
+
+ const int *puncture;
+};
+
+
+/* Encoding */
+
+ /* Low level API */
+/*! \brief convolutional encoder state */
+struct osmo_conv_encoder {
+ const struct osmo_conv_code *code; /*!< \brief for which code? */
+ int i_idx; /*!< \brief Next input bit index */
+ int p_idx; /*!< \brief Current puncture index */
+ uint8_t state; /*!< \brief Current state */
+};
+
+void osmo_conv_encode_init(struct osmo_conv_encoder *encoder,
+ const struct osmo_conv_code *code);
+int osmo_conv_encode_raw(struct osmo_conv_encoder *encoder,
+ const ubit_t *input, ubit_t *output, int n);
+int osmo_conv_encode_finish(struct osmo_conv_encoder *encoder, ubit_t *output);
+
+ /* All-in-one */
+int osmo_conv_encode(const struct osmo_conv_code *code,
+ const ubit_t *input, ubit_t *output);
+
+
+/* Decoding */
+
+ /* Low level API */
+/*! \brief convolutional decoder state */
+struct osmo_conv_decoder {
+ /*! \brief description of convolutional code */
+ const struct osmo_conv_code *code;
+
+ int n_states; /*!< \brief number of states */
+
+ int len; /*!< \brief Max o_idx (excl. termination) */
+
+ int o_idx; /*!< \brief output index */
+ int p_idx; /*!< \brief puncture index */
+
+ unsigned int *ae; /*!< \brief accumulater error */
+ unsigned int *ae_next; /*!< \brief next accumulated error (tmp in scan) */
+ uint8_t *state_history; /*!< \brief state history [len][n_states] */
+};
+
+void osmo_conv_decode_init(struct osmo_conv_decoder *decoder,
+ const struct osmo_conv_code *code, int len);
+void osmo_conv_decode_reset(struct osmo_conv_decoder *decoder);
+void osmo_conv_decode_deinit(struct osmo_conv_decoder *decoder);
+
+int osmo_conv_decode_scan(struct osmo_conv_decoder *decoder,
+ const sbit_t *input, int n);
+int osmo_conv_decode_finish(struct osmo_conv_decoder *decoder,
+ const sbit_t *input);
+int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder,
+ ubit_t *output, int has_finish);
+
+ /* All-in-one */
+int osmo_conv_decode(const struct osmo_conv_code *code,
+ const sbit_t *input, ubit_t *output);
+
+
+/*! }@ */
+
+#endif /* __OSMO_CONV_H__ */