aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2016-09-23 01:48:59 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-03-07 01:06:38 +0700
commit3262f820b5cfb4c76448f605c9804f3e5ca1023d (patch)
tree1d62b0b5a454955e71e6ce91a869d54f1d8df154
parent68930e85b5945db8ffea055fd178bc1f88b31d99 (diff)
libosmocoding: migrate transcoding routines from OsmoBTS
There are some projects, such as GR-GSM and OsmocomBB, which would benefit from using one shared implementation of GSM 05.03 code. So, this commit introduces a new sub-library called libosmocoding, which (for now) provides GSM, GPRS and EDGE transcoding routines, migrated from OsmoBTS. The original GSM 05.03 code from OsmoBTS was relicensed under GPLv2-or-later with permission of copyright holders (Andreas Eversberg, Alexander Chemeris and Tom Tsou). The following data types are currently supported: - xCCH - PDTCH (CS 1-4 and MCS 1-9) - TCH/FR - TCH/HR - TCH/AFS - RCH/AHS - RACH - SCH Change-Id: I0c3256b87686d878e4e716d12393cad5924fdfa1
-rw-r--r--.gitignore3
-rw-r--r--Doxyfile.coding.in1716
-rw-r--r--Makefile.am16
-rw-r--r--configure.ac4
-rw-r--r--debian/control34
-rw-r--r--include/Makefile.am5
-rw-r--r--include/osmocom/coding/gsm0503_coding.h63
-rw-r--r--include/osmocom/coding/gsm0503_interleaving.h51
-rw-r--r--include/osmocom/coding/gsm0503_mapping.h33
-rw-r--r--include/osmocom/coding/gsm0503_parity.h13
-rw-r--r--include/osmocom/coding/gsm0503_tables.h50
-rw-r--r--libosmocoding.pc.in11
-rw-r--r--src/coding/Makefile.am27
-rw-r--r--src/coding/gsm0503_coding.c2681
-rw-r--r--src/coding/gsm0503_interleaving.c573
-rw-r--r--src/coding/gsm0503_mapping.c291
-rw-r--r--src/coding/gsm0503_parity.c132
-rw-r--r--src/coding/gsm0503_tables.c1732
-rw-r--r--src/coding/libosmocoding.map117
-rw-r--r--src/gsm/libosmogsm.map2
-rw-r--r--tests/Makefile.am12
-rw-r--r--tests/coding/coding_test.c501
-rw-r--r--tests/coding/coding_test.ok21
-rw-r--r--tests/testsuite.at6
-rw-r--r--utils/conv_codes_gsm.py24
25 files changed, 8111 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index 84e11b8f..ecbceddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ Doxyfile.core
Doxyfile.gsm
Doxyfile.vty
Doxyfile.codec
+Doxyfile.coding
debian/autoreconf.after
debian/autoreconf.before
@@ -73,6 +74,7 @@ tests/bits/bitrev_test
tests/a5/a5_test
tests/comp128/comp128_test
tests/auth/milenage_test
+tests/coding/coding_test
tests/conv/conv_test
tests/lapd/lapd_test
tests/gsm0808/gsm0808_test
@@ -105,6 +107,7 @@ utils/osmo-auc-gen
utils/osmo-sim-test
doc/codec
+doc/coding
doc/core
doc/vty/latex
doc/vty/html
diff --git a/Doxyfile.coding.in b/Doxyfile.coding.in
new file mode 100644
index 00000000..d73e6cd4
--- /dev/null
+++ b/Doxyfile.coding.in
@@ -0,0 +1,1716 @@
+# Doxyfile 1.7.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ").
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = libosmocoding
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = @VERSION@
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer
+# a quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF = "Osmocom L1 transcoding library"
+
+# With the PROJECT_LOGO tag one can specify an logo or icon that is
+# included in the documentation. The maximum height of the logo should not
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.
+# Doxygen will copy the logo to the output directory.
+
+PROJECT_LOGO =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = doc/coding
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful if your file system
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this
+# tag. The format is ext=language, where ext is a file extension, and language
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also makes the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
+# unions are shown inside the group in which they are included (e.g. using
+# @ingroup) instead of on a separate page (for HTML and Man pages) or
+# section (for LaTeX and RTF).
+
+INLINE_GROUPED_CLASSES = NO
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penalty.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will roughly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespaces are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
+# will sort the (brief and detailed) documentation of class members so that
+# constructors and destructors are listed first. If set to NO (the default)
+# the constructors will appear in the respective orders defined by
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
+# do proper type resolution of all parameters of a function it will reject a
+# match between the prototype and the implementation of a member function even
+# if there is only one candidate or it is obvious which candidate to choose
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
+# will still accept a match between prototype and implementation in such cases.
+
+STRICT_PROTO_MATCHING = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or macro consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and macros in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. The create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option.
+# You can optionally specify a file name after the option, if omitted
+# DoxygenLayout.xml will be used as the name of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @srcdir@/include/osmocom/coding @srcdir@/src/coding
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
+# *.f90 *.f *.for *.vhd *.vhdl
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+# IMAGE_PATH = images/
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty or if
+# non of the patterns match the file name, INPUT_FILTER is applied.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
+# and it is also possible to disable source filtering for a specific pattern
+# using *.ext= (so without naming a filter). This option only has effect when
+# FILTER_SOURCE_FILES is enabled.
+
+FILTER_SOURCE_PATTERNS =
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header. Note that when using a custom header you are responsible
+# for the proper inclusion of any scripts and style sheets that doxygen
+# needs, which is dependent on the configuration options used.
+# It is adviced to generate a default header using "doxygen -w html
+# header.html footer.html stylesheet.css YourConfigFile" and then modify
+# that header. Note that the header is subject to change so you typically
+# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW!
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that
+# the files will be copied as-is; there are no commands or markers available.
+
+HTML_EXTRA_FILES =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
+# Doxygen will adjust the colors in the stylesheet and background images
+# according to this color. Hue is specified as an angle on a colorwheel,
+# see http://en.wikipedia.org/wiki/Hue for more information.
+# For instance the value 0 represents red, 60 is yellow, 120 is green,
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
+# The allowed range is 0 to 359.
+
+HTML_COLORSTYLE_HUE = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
+# the colors in the HTML output. For a value of 0 the output will use
+# grayscales only. A value of 255 will produce the most vivid colors.
+
+HTML_COLORSTYLE_SAT = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
+# the luminance component of the colors in the HTML output. Values below
+# 100 gradually make the output lighter, whereas values above 100 make
+# the output darker. The value divided by 100 is the actual gamma applied,
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
+# and 100 does not change the gamma.
+
+HTML_COLORSTYLE_GAMMA = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP = YES
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+
+DOCSET_PUBLISHER_ID = org.doxygen.Publisher
+
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+
+DOCSET_PUBLISHER_NAME = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
+# that can be used as input for Qt's qhelpgenerator to generate a
+# Qt Compressed Help (.qch) of the generated HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
+# add. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
+# Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
+# Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+# will be generated, which together with the HTML files, form an Eclipse help
+# plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
+# the help appears.
+
+GENERATE_ECLIPSEHELP = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML
+# documentation. Note that a value of 0 will completely suppress the enum
+# values from appearing in the overview section.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = YES
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
+# links to external symbols imported via tag files in a separate window.
+
+EXT_LINKS_IN_WINDOW = NO
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are
+# not supported properly for IE 6.0, but are supported on all modern browsers.
+# Note that when changing this option you need to delete any form_*.png files
+# in the HTML output before the changes have effect.
+
+FORMULA_TRANSPARENT = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
+# (see http://www.mathjax.org) which uses client side Javascript for the
+# rendering instead of using prerendered bitmaps. Use this if you do not
+# have LaTeX installed or if you want to formulas look prettier in the HTML
+# output. When enabled you also need to install MathJax separately and
+# configure the path to it using the MATHJAX_RELPATH option.
+
+USE_MATHJAX = NO
+
+# When MathJax is enabled you need to specify the location relative to the
+# HTML output directory using the MATHJAX_RELPATH option. The destination
+# directory should contain the MathJax.js script. For instance, if the mathjax
+# directory is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the
+# mathjax.org site, so you can quickly see the result without installing
+# MathJax, but it is strongly recommended to install a local copy of MathJax
+# before deployment.
+
+MATHJAX_RELPATH = http://www.mathjax.org/mathjax
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box
+# for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
+# (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a PHP enabled web server instead of at the web client
+# using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server
+# based approach is that it scales better to large projects and allows
+# full text search. The disadvantages are that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
+# the generated latex document. The footer should contain everything after
+# the last chapter. If it is left blank doxygen will generate a
+# standard footer. Notice: only use this tag if you know what you are doing!
+
+LATEX_FOOTER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include
+# source code with syntax highlighting in the LaTeX output.
+# Note that which sources are shown also depends on other settings
+# such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# pointed to by INCLUDE_PATH will be searched when a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition that
+# overrules the definition found in the source code.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all references to function-like macros
+# that are alone on a line, have an all uppercase name, and do not end with a
+# semicolon, because these will confuse the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES = doc/libosmocore.tag=../../core/html
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE = doc/libosmocoding.tag
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option also works with HAVE_DOT disabled, but it is recommended to
+# install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
+# allowed to run in parallel. When set to 0 (the default) doxygen will
+# base this on the number of processors available in the system. You can set it
+# explicitly to a value larger than 0 to get control over the balance
+# between CPU load and processing speed.
+
+DOT_NUM_THREADS = 0
+
+# By default doxygen will write a font called Helvetica to the output
+# directory and reference it in all dot files that doxygen generates.
+# When you want a differently looking font you can specify the font name
+# using DOT_FONTNAME. You need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will generate a graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are svg, png, jpg, or gif.
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH = /usr/bin/dot
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the
+# \mscfile command).
+
+MSCFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/Makefile.am b/Makefile.am
index 185127e3..1d17da5b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,11 +1,11 @@
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
-SUBDIRS = include src src/vty src/codec src/gsm src/gb src/ctrl src/sim tests utils
+SUBDIRS = include src src/vty src/codec src/gsm src/coding src/gb src/ctrl src/sim tests utils
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \
- libosmogb.pc libosmoctrl.pc
+ libosmogb.pc libosmoctrl.pc libosmocoding.pc
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
@@ -22,7 +22,8 @@ html_DATA = $(top_builddir)/doc/html.tar
$(html_DATA): $(top_builddir)/doc/core/html/index.html \
$(top_builddir)/doc/gsm/html/index.html \
$(top_builddir)/doc/vty/html/index.html \
- $(top_builddir)/doc/codec/html/index.html
+ $(top_builddir)/doc/codec/html/index.html \
+ $(top_builddir)/doc/coding/html/index.html
cd $(top_builddir)/doc && tar cf html.tar */html
$(top_builddir)/doc/core/html/index.html: $(SOURCES) Doxyfile.core
@@ -44,13 +45,18 @@ $(top_builddir)/doc/codec/html/index.html: $(SOURCES) Doxyfile.codec
mkdir -p doc/codec
$(DOXYGEN) Doxyfile.codec
+$(top_builddir)/doc/coding/html/index.html: Doxyfile.coding
+ @rm -rf doc/coding
+ mkdir -p doc/coding
+ $(DOXYGEN) Doxyfile.coding
+
install-data-hook:
cd $(DESTDIR)$(htmldir) && tar xf html.tar && rm -f html.tar
uninstall-hook:
- cd $(DESTDIR)$(htmldir) && rm -rf {core,gsm,vty,codec}
+ cd $(DESTDIR)$(htmldir) && rm -rf {core,gsm,vty,codec,coding}
-DX_CLEAN = doc/{core,gsm,vty,codec}/html/search/* doc/{core,gsm,vty,codec}/{html,latex}/* doc/html.tar doc/{core,gsm,vty,codec}/doxygen_sqlite3.db doc/*.tag
+DX_CLEAN = doc/{core,gsm,vty,codec,coding}/html/search/* doc/{core,gsm,vty,codec,coding}/{html,latex}/* doc/html.tar doc/{core,gsm,vty,codec,coding}/doxygen_sqlite3.db doc/*.tag
endif
MOSTLYCLEANFILES = $(DX_CLEAN)
diff --git a/configure.ac b/configure.ac
index 20b5e635..a18197d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ case $host in
*)
LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
+ LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
;;
esac
AC_SUBST(LTLDFLAGS_OSMOGB)
@@ -228,6 +229,7 @@ fi
AC_OUTPUT(
libosmocore.pc
libosmocodec.pc
+ libosmocoding.pc
libosmovty.pc
libosmogsm.pc
libosmogb.pc
@@ -237,6 +239,7 @@ AC_OUTPUT(
src/Makefile
src/vty/Makefile
src/codec/Makefile
+ src/coding/Makefile
src/sim/Makefile
src/gsm/Makefile
src/gb/Makefile
@@ -248,4 +251,5 @@ AC_OUTPUT(
Doxyfile.gsm
Doxyfile.vty
Doxyfile.codec
+ Doxyfile.coding
Makefile)
diff --git a/debian/control b/debian/control
index 4cdb672e..9b3761b3 100644
--- a/debian/control
+++ b/debian/control
@@ -25,6 +25,7 @@ Section: libs
Architecture: any
Multi-Arch: foreign
Depends: libosmocodec0 (= ${binary:Version}),
+ libosmocoding0 (= ${binary:Version}),
libosmocore8 (= ${binary:Version}),
libosmogb4 (= ${binary:Version}),
libosmogsm7 (= ${binary:Version}),
@@ -76,6 +77,38 @@ Description: Documentation for the osmo codec library
.
This package contains the documentation for the libosmocodec library.
+Package: libosmocoding0
+Section: libs
+Architecture: any
+Multi-Arch: same
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Pre-Depends: ${misc:Pre-Depends}
+Description: Osmo coding library
+ This is part of the libosmocore "meta"-library. The libosmocore library
+ contains various utility functions that were originally developed as part of
+ the OpenBSC project, but which are of a more generic nature and thus useful to
+ (at least) other programs that are developed in the sphere of Free Software /
+ Open Source mobile communication.
+ .
+ The libosmocoding library in particular contains the implementation of
+ GSM, GPRS and EDGE transcoding routines, migrated from OsmoBTS.
+
+Package: libosmocoding-doc
+Architecture: all
+Section: doc
+Depends: ${misc:Depends},
+ libosmocoding0,
+ libjs-jquery
+Description: Documentation for the osmo coding library
+ This is part of the libosmocore "meta"-library. The libosmocore library
+ contains various utility functions that were originally developed as part of
+ the OpenBSC project, but which are of a more generic nature and thus useful to
+ (at least) other programs that are developed in the sphere of Free Software /
+ Open Source mobile communication.
+ .
+ This package contains the documentation for the libosmocoding library.
+
Package: libosmocore8
Section: libs
Architecture: any
@@ -100,6 +133,7 @@ Depends: ${misc:Depends},
libosmocore8,
libjs-jquery,
libosmocodec-doc,
+ libosmocoding-doc,
libosmogsm-doc,
libosmovty-doc
Description: Documentation for the Osmo Core library
diff --git a/include/Makefile.am b/include/Makefile.am
index 770a9c62..f8b1f8f3 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -69,6 +69,11 @@ nobase_include_HEADERS = \
osmocom/gsm/gsm0480.h \
osmocom/gsm/gsm0502.h \
osmocom/gsm/gsm0503.h \
+ osmocom/coding/gsm0503_tables.h \
+ osmocom/coding/gsm0503_parity.h \
+ osmocom/coding/gsm0503_mapping.h \
+ osmocom/coding/gsm0503_interleaving.h \
+ osmocom/coding/gsm0503_coding.h \
osmocom/gsm/gsm0808.h \
osmocom/gsm/gsm23003.h \
osmocom/gsm/gsm48.h \
diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h
new file mode 100644
index 00000000..b8eb2052
--- /dev/null
+++ b/include/osmocom/coding/gsm0503_coding.h
@@ -0,0 +1,63 @@
+#pragma once
+
+#include <stdint.h>
+#include <osmocom/core/bits.h>
+
+#define GSM0503_GPRS_BURSTS_NBITS (116 * 4)
+#define GSM0503_EGPRS_BURSTS_NBITS (348 * 4)
+#define NUM_BYTES(N) ((N + 8 - 1) / 8)
+
+enum gsm0503_egprs_mcs {
+ EGPRS_MCS0,
+ EGPRS_MCS1,
+ EGPRS_MCS2,
+ EGPRS_MCS3,
+ EGPRS_MCS4,
+ EGPRS_MCS5,
+ EGPRS_MCS6,
+ EGPRS_MCS7,
+ EGPRS_MCS8,
+ EGPRS_MCS9,
+ EGPRS_NUM_MCS,
+};
+
+int gsm0503_xcch_encode(ubit_t *bursts, uint8_t *l2_data);
+int gsm0503_xcch_decode(uint8_t *l2_data, sbit_t *bursts,
+ int *n_errors, int *n_bits_total);
+
+int gsm0503_pdtch_encode(ubit_t *bursts, uint8_t *l2_data, uint8_t l2_len);
+int gsm0503_pdtch_decode(uint8_t *l2_data, sbit_t *bursts, uint8_t *usf_p,
+ int *n_errors, int *n_bits_total);
+
+int gsm0503_pdtch_egprs_encode(ubit_t *bursts, uint8_t *l2_data,
+ uint8_t l2_len);
+int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts,
+ uint16_t nbits, uint8_t *usf_p, int *n_errors, int *n_bits_total);
+
+int gsm0503_tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int net_order);
+int gsm0503_tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order,
+ int efr, int *n_errors, int *n_bits_total);
+
+int gsm0503_tch_hr_encode(ubit_t *bursts, uint8_t *tch_data, int len);
+int gsm0503_tch_hr_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
+ int *n_errors, int *n_bits_total);
+
+int gsm0503_tch_afs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft,
+ uint8_t cmr);
+int gsm0503_tch_afs_decode(uint8_t *tch_data, sbit_t *bursts,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
+ uint8_t *cmr, int *n_errors, int *n_bits_total);
+
+int gsm0503_tch_ahs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr);
+int gsm0503_tch_ahs_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
+ uint8_t *cmr, int *n_errors, int *n_bits_total);
+
+int gsm0503_rach_encode(ubit_t *burst, uint8_t *ra, uint8_t bsic);
+int gsm0503_rach_decode(uint8_t *ra, sbit_t *burst, uint8_t bsic);
+
+int gsm0503_sch_encode(ubit_t *burst, uint8_t *sb_info);
+int gsm0503_sch_decode(uint8_t *sb_info, sbit_t *burst);
diff --git a/include/osmocom/coding/gsm0503_interleaving.h b/include/osmocom/coding/gsm0503_interleaving.h
new file mode 100644
index 00000000..f97dff4f
--- /dev/null
+++ b/include/osmocom/coding/gsm0503_interleaving.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <osmocom/core/bits.h>
+
+void gsm0503_xcch_deinterleave(sbit_t *cB, const sbit_t *iB);
+void gsm0503_xcch_interleave(ubit_t *cB, ubit_t *iB);
+
+void gsm0503_tch_fr_deinterleave(sbit_t *cB, sbit_t *iB);
+void gsm0503_tch_fr_interleave(ubit_t *cB, ubit_t *iB);
+
+void gsm0503_tch_hr_deinterleave(sbit_t *cB, sbit_t *iB);
+void gsm0503_tch_hr_interleave(ubit_t *cB, ubit_t *iB);
+
+void gsm0503_mcs1_ul_deinterleave(sbit_t *hc, sbit_t *dc, const sbit_t *iB);
+void gsm0503_mcs1_ul_interleave(const ubit_t *hc,
+ const ubit_t *dc, ubit_t *iB);
+
+void gsm0503_mcs1_dl_deinterleave(sbit_t *u, sbit_t *hc,
+ sbit_t *dc, const sbit_t *iB);
+void gsm0503_mcs1_dl_interleave(const ubit_t *up, const ubit_t *hc,
+ const ubit_t *dc, ubit_t *iB);
+
+void gsm0503_mcs5_ul_deinterleave(sbit_t *hc, sbit_t *dc,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs5_ul_interleave(const ubit_t *hc, const ubit_t *dc,
+ ubit_t *hi, ubit_t *di);
+
+void gsm0503_mcs5_dl_deinterleave(sbit_t *hc, sbit_t *dc,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs5_dl_interleave(const ubit_t *hc, const ubit_t *dc,
+ ubit_t *hi, ubit_t *di);
+
+void gsm0503_mcs7_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs7_ul_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di);
+
+void gsm0503_mcs7_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs7_dl_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di);
+
+void gsm0503_mcs8_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs8_ul_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di);
+
+void gsm0503_mcs8_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di);
+void gsm0503_mcs8_dl_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di);
diff --git a/include/osmocom/coding/gsm0503_mapping.h b/include/osmocom/coding/gsm0503_mapping.h
new file mode 100644
index 00000000..4c6550a4
--- /dev/null
+++ b/include/osmocom/coding/gsm0503_mapping.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <osmocom/core/bits.h>
+
+void gsm0503_xcch_burst_unmap(sbit_t *iB, const sbit_t *eB,
+ sbit_t *hl, sbit_t *hn);
+void gsm0503_xcch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *hl,
+ const ubit_t *hn);
+
+void gsm0503_tch_burst_unmap(sbit_t *iB, sbit_t *eB, sbit_t *h, int odd);
+void gsm0503_tch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *h, int odd);
+
+void gsm0503_mcs5_ul_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, int B);
+void gsm0503_mcs5_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, int B);
+
+void gsm0503_mcs7_ul_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, int B);
+void gsm0503_mcs7_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, int B);
+
+void gsm0503_mcs5_dl_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, const ubit_t *up, int B);
+void gsm0503_mcs5_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, sbit_t *up, int B);
+
+void gsm0503_mcs7_dl_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, const ubit_t *up, int B);
+void gsm0503_mcs7_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, sbit_t *up, int B);
+
+void gsm0503_mcs5_burst_swap(sbit_t *eB);
diff --git a/include/osmocom/coding/gsm0503_parity.h b/include/osmocom/coding/gsm0503_parity.h
new file mode 100644
index 00000000..540124a7
--- /dev/null
+++ b/include/osmocom/coding/gsm0503_parity.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include <osmocom/core/crcgen.h>
+
+const struct osmo_crc64gen_code gsm0503_fire_crc40;
+const struct osmo_crc16gen_code gsm0503_cs234_crc16;
+const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr;
+const struct osmo_crc16gen_code gsm0503_mcs_crc12;
+const struct osmo_crc8gen_code gsm0503_rach_crc6;
+const struct osmo_crc16gen_code gsm0503_sch_crc10;
+const struct osmo_crc8gen_code gsm0503_tch_fr_crc3;
+const struct osmo_crc8gen_code gsm0503_tch_efr_crc8;
+const struct osmo_crc8gen_code gsm0503_amr_crc6;
diff --git a/include/osmocom/coding/gsm0503_tables.h b/include/osmocom/coding/gsm0503_tables.h
new file mode 100644
index 00000000..e6761ca4
--- /dev/null
+++ b/include/osmocom/coding/gsm0503_tables.h
@@ -0,0 +1,50 @@
+#pragma once
+
+#include <stdint.h>
+#include <osmocom/core/bits.h>
+
+extern const ubit_t gsm0503_pdtch_hl_hn_ubit[4][8];
+extern const ubit_t gsm0503_pdtch_edge_hl_hn_ubit[3][8];
+extern const sbit_t gsm0503_pdtch_hl_hn_sbit[4][8];
+extern const sbit_t gsm0503_pdtch_edge_hl_hn_sbit[3][8];
+extern const ubit_t gsm0503_usf2six[8][6];
+extern const ubit_t gsm0503_usf2twelve_ubit[8][12];
+extern const sbit_t gsm0503_usf2twelve_sbit[8][12];
+extern const uint8_t gsm0503_puncture_cs2[588];
+extern const uint8_t gsm0503_puncture_cs3[676];
+extern const uint8_t gsm0503_puncture_mcs1_dl_hdr[108];
+extern const uint8_t gsm0503_puncture_mcs1_ul_hdr[117];
+extern const uint8_t gsm0503_puncture_mcs1_p1[588];
+extern const uint8_t gsm0503_puncture_mcs1_p2[588];
+extern const uint8_t gsm0503_puncture_mcs2_p1[732];
+extern const uint8_t gsm0503_puncture_mcs2_p2[732];
+extern const uint8_t gsm0503_puncture_mcs3_p1[948];
+extern const uint8_t gsm0503_puncture_mcs3_p2[948];
+extern const uint8_t gsm0503_puncture_mcs3_p3[948];
+extern const uint8_t gsm0503_puncture_mcs4_p1[1116];
+extern const uint8_t gsm0503_puncture_mcs4_p2[1116];
+extern const uint8_t gsm0503_puncture_mcs4_p3[1116];
+extern const uint8_t gsm0503_puncture_mcs5_p1[1404];
+extern const uint8_t gsm0503_puncture_mcs5_p2[1404];
+extern const uint8_t gsm0503_puncture_mcs6_p1[1836];
+extern const uint8_t gsm0503_puncture_mcs6_p2[1836];
+extern const uint8_t gsm0503_puncture_mcs7_dl_hdr[135];
+extern const uint8_t gsm0503_puncture_mcs7_ul_hdr[162];
+extern const uint8_t gsm0503_puncture_mcs7_p1[1404];
+extern const uint8_t gsm0503_puncture_mcs7_p2[1404];
+extern const uint8_t gsm0503_puncture_mcs7_p3[1404];
+extern const uint8_t gsm0503_puncture_mcs8_p1[1692];
+extern const uint8_t gsm0503_puncture_mcs8_p2[1692];
+extern const uint8_t gsm0503_puncture_mcs8_p3[1692];
+extern const uint8_t gsm0503_puncture_mcs9_p1[1836];
+extern const uint8_t gsm0503_puncture_mcs9_p2[1836];
+extern const uint8_t gsm0503_puncture_mcs9_p3[1836];
+extern const uint16_t gsm0503_interleave_mcs5[1248];
+extern const uint8_t gsm0503_gsm_fr_map[76];
+extern const uint8_t gsm0503_gsm_efr_protected_bits[65];
+extern const ubit_t gsm0503_afs_ic_ubit[4][8];
+extern const sbit_t gsm0503_afs_ic_sbit[4][8];
+extern const ubit_t gsm0503_ahs_ic_ubit[4][4];
+extern const sbit_t gsm0503_ahs_ic_sbit[4][4];
+extern const uint8_t gsm0503_tch_hr_interleaving[228][2];
+extern const ubit_t gsm0503_mcs5_usf_precode_table[8][36];
diff --git a/libosmocoding.pc.in b/libosmocoding.pc.in
new file mode 100644
index 00000000..580b1702
--- /dev/null
+++ b/libosmocoding.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: Osmocom L1 transcoding Library
+Description: C Utility Library
+Version: @VERSION@
+Libs: -L${libdir} -losmocoding -losmocodec -losmogsm -losmocore
+Cflags: -I${includedir}/
+
diff --git a/src/coding/Makefile.am b/src/coding/Makefile.am
new file mode 100644
index 00000000..5a055c8d
--- /dev/null
+++ b/src/coding/Makefile.am
@@ -0,0 +1,27 @@
+# This is _NOT_ the library release version, it's an API version.
+# Please read Chapter 6 "Library interface versions" of the libtool
+# documentation before making any modification
+LIBVERSION = 0:0:0
+
+AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS)
+AM_CFLAGS = -Wall
+
+lib_LTLIBRARIES = libosmocoding.la
+
+libosmocoding_la_SOURCES = \
+ gsm0503_interleaving.c \
+ gsm0503_mapping.c \
+ gsm0503_tables.c \
+ gsm0503_parity.c \
+ gsm0503_coding.c
+libosmocoding_la_LDFLAGS = \
+ -version-info \
+ $(LIBVERSION) \
+ -no-undefined \
+ $(TALLOC_LIBS)
+libosmocoding_la_LIBADD = \
+ ../libosmocore.la \
+ ../gsm/libosmogsm.la \
+ ../codec/libosmocodec.la
+
+EXTRA_DIST = libosmocoding.map
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
new file mode 100644
index 00000000..30ec387b
--- /dev/null
+++ b/src/coding/gsm0503_coding.c
@@ -0,0 +1,2681 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2015 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
+ * (C) 2016 by Tom Tsou <tom.tsou@ettus.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.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/core/conv.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/core/crcgen.h>
+#include <osmocom/core/endian.h>
+
+#include <osmocom/gprs/protocol/gsm_04_60.h>
+#include <osmocom/gprs/gprs_rlc.h>
+
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/gsm0503.h>
+#include <osmocom/codec/codec.h>
+
+#include <osmocom/coding/gsm0503_interleaving.h>
+#include <osmocom/coding/gsm0503_mapping.h>
+#include <osmocom/coding/gsm0503_tables.h>
+#include <osmocom/coding/gsm0503_coding.h>
+#include <osmocom/coding/gsm0503_parity.h>
+
+/*
+ * EGPRS coding limits
+ */
+
+/* Max header size with parity bits */
+#define EGPRS_HDR_UPP_MAX 54
+
+/* Max encoded header size */
+#define EGPRS_HDR_C_MAX 162
+
+/* Max punctured header size */
+#define EGPRS_HDR_HC_MAX 160
+
+/* Max data block size with parity bits */
+#define EGPRS_DATA_U_MAX 612
+
+/* Max encoded data block size */
+#define EGPRS_DATA_C_MAX 1836
+
+/* Max single block punctured data size */
+#define EGPRS_DATA_DC_MAX 1248
+
+/* Dual block punctured data size */
+#define EGPRS_DATA_C1 612
+#define EGPRS_DATA_C2 EGPRS_DATA_C1
+
+/* TS 101318 Chapter 5.1: 260 bits + 4bit sig */
+#define GSM_FR_BYTES 33
+/* TS 101318 Chapter 5.2: 112 bits, no sig */
+#define GSM_HR_BYTES 14
+/* TS 101318 Chapter 5.3: 244 bits + 4bit sig */
+#define GSM_EFR_BYTES 31
+
+union gprs_rlc_ul_hdr_egprs {
+ struct gprs_rlc_ul_header_egprs_1 type1;
+ struct gprs_rlc_ul_header_egprs_2 type2;
+ struct gprs_rlc_ul_header_egprs_3 type3;
+};
+
+union gprs_rlc_dl_hdr_egprs {
+ struct gprs_rlc_dl_header_egprs_1 type1;
+ struct gprs_rlc_dl_header_egprs_2 type2;
+ struct gprs_rlc_dl_header_egprs_3 type3;
+};
+
+struct gsm0503_mcs_code {
+ uint8_t mcs;
+ uint8_t usf_len;
+
+ /* Header coding */
+ uint8_t hdr_len;
+ uint8_t hdr_code_len;
+ uint8_t hdr_punc_len;
+ const struct osmo_conv_code *hdr_conv;
+ const uint8_t *hdr_punc;
+
+ /* Data coding */
+ uint16_t data_len;
+ uint16_t data_code_len;
+ uint16_t data_punc_len;
+ const struct osmo_conv_code *data_conv;
+ const uint8_t *data_punc[3];
+};
+
+/*
+ * EGPRS UL coding parameters
+ */
+struct gsm0503_mcs_code gsm0503_mcs_ul_codes[EGPRS_NUM_MCS] = {
+ {
+ .mcs = EGPRS_MCS0,
+ },
+ {
+ .mcs = EGPRS_MCS1,
+ .hdr_len = 31,
+ .hdr_code_len = 117,
+ .hdr_punc_len = 80,
+ .hdr_conv = &gsm0503_mcs1_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_ul_hdr,
+
+ .data_len = 178,
+ .data_code_len = 588,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs1,
+ .data_punc = {
+ gsm0503_puncture_mcs1_p1,
+ gsm0503_puncture_mcs1_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS2,
+ .hdr_len = 31,
+ .hdr_code_len = 117,
+ .hdr_punc_len = 80,
+ .hdr_conv = &gsm0503_mcs1_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_ul_hdr,
+
+ .data_len = 226,
+ .data_code_len = 732,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs2,
+ .data_punc = {
+ gsm0503_puncture_mcs2_p1,
+ gsm0503_puncture_mcs2_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS3,
+ .hdr_len = 31,
+ .hdr_code_len = 117,
+ .hdr_punc_len = 80,
+ .hdr_conv = &gsm0503_mcs1_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_ul_hdr,
+
+ .data_len = 298,
+ .data_code_len = 948,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs3,
+ .data_punc = {
+ gsm0503_puncture_mcs3_p1,
+ gsm0503_puncture_mcs3_p2,
+ gsm0503_puncture_mcs3_p3,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS4,
+ .hdr_len = 31,
+ .hdr_code_len = 117,
+ .hdr_punc_len = 80,
+ .hdr_conv = &gsm0503_mcs1_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_ul_hdr,
+
+ .data_len = 354,
+ .data_code_len = 1116,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs4,
+ .data_punc = {
+ gsm0503_puncture_mcs4_p1,
+ gsm0503_puncture_mcs4_p2,
+ gsm0503_puncture_mcs4_p3,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS5,
+ .hdr_len = 37,
+ .hdr_code_len = 135,
+ .hdr_punc_len = 136,
+ .hdr_conv = &gsm0503_mcs5_ul_hdr,
+ .hdr_punc = NULL,
+
+ .data_len = 450,
+ .data_code_len = 1404,
+ .data_punc_len = 1248,
+ .data_conv = &gsm0503_mcs5,
+ .data_punc = {
+ gsm0503_puncture_mcs5_p1,
+ gsm0503_puncture_mcs5_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS6,
+ .hdr_len = 37,
+ .hdr_code_len = 135,
+ .hdr_punc_len = 136,
+ .hdr_conv = &gsm0503_mcs5_ul_hdr,
+ .hdr_punc = NULL,
+
+ .data_len = 594,
+ .data_code_len = 1836,
+ .data_punc_len = 1248,
+ .data_conv = &gsm0503_mcs6,
+ .data_punc = {
+ gsm0503_puncture_mcs6_p1,
+ gsm0503_puncture_mcs6_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS7,
+ .hdr_len = 46,
+ .hdr_code_len = 162,
+ .hdr_punc_len = 160,
+ .hdr_conv = &gsm0503_mcs7_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_ul_hdr,
+
+ .data_len = 900,
+ .data_code_len = 1404,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs7,
+ .data_punc = {
+ gsm0503_puncture_mcs7_p1,
+ gsm0503_puncture_mcs7_p2,
+ gsm0503_puncture_mcs7_p3,
+ }
+ },
+ {
+ .mcs = EGPRS_MCS8,
+ .hdr_len = 46,
+ .hdr_code_len = 162,
+ .hdr_punc_len = 160,
+ .hdr_conv = &gsm0503_mcs7_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_ul_hdr,
+
+ .data_len = 1092,
+ .data_code_len = 1692,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs8,
+ .data_punc = {
+ gsm0503_puncture_mcs8_p1,
+ gsm0503_puncture_mcs8_p2,
+ gsm0503_puncture_mcs8_p3,
+ }
+ },
+ {
+ .mcs = EGPRS_MCS9,
+ .hdr_len = 46,
+ .hdr_code_len = 162,
+ .hdr_punc_len = 160,
+ .hdr_conv = &gsm0503_mcs7_ul_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_ul_hdr,
+
+ .data_len = 1188,
+ .data_code_len = 1836,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs9,
+ .data_punc = {
+ gsm0503_puncture_mcs9_p1,
+ gsm0503_puncture_mcs9_p2,
+ gsm0503_puncture_mcs9_p3,
+ }
+ },
+};
+
+/*
+ * EGPRS DL coding parameters
+ */
+struct gsm0503_mcs_code gsm0503_mcs_dl_codes[EGPRS_NUM_MCS] = {
+ {
+ .mcs = EGPRS_MCS0,
+ },
+ {
+ .mcs = EGPRS_MCS1,
+ .usf_len = 3,
+ .hdr_len = 28,
+ .hdr_code_len = 108,
+ .hdr_punc_len = 68,
+ .hdr_conv = &gsm0503_mcs1_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_dl_hdr,
+
+ .data_len = 178,
+ .data_code_len = 588,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs1,
+ .data_punc = {
+ gsm0503_puncture_mcs1_p1,
+ gsm0503_puncture_mcs1_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS2,
+ .usf_len = 3,
+ .hdr_len = 28,
+ .hdr_code_len = 108,
+ .hdr_punc_len = 68,
+ .hdr_conv = &gsm0503_mcs1_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_dl_hdr,
+
+ .data_len = 226,
+ .data_code_len = 732,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs2,
+ .data_punc = {
+ gsm0503_puncture_mcs2_p1,
+ gsm0503_puncture_mcs2_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS3,
+ .usf_len = 3,
+ .hdr_len = 28,
+ .hdr_code_len = 108,
+ .hdr_punc_len = 68,
+ .hdr_conv = &gsm0503_mcs1_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_dl_hdr,
+
+ .data_len = 298,
+ .data_code_len = 948,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs3,
+ .data_punc = {
+ gsm0503_puncture_mcs3_p1,
+ gsm0503_puncture_mcs3_p2,
+ gsm0503_puncture_mcs3_p3,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS4,
+ .usf_len = 3,
+ .hdr_len = 28,
+ .hdr_code_len = 108,
+ .hdr_punc_len = 68,
+ .hdr_conv = &gsm0503_mcs1_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs1_dl_hdr,
+
+ .data_len = 354,
+ .data_code_len = 1116,
+ .data_punc_len = 372,
+ .data_conv = &gsm0503_mcs4,
+ .data_punc = {
+ gsm0503_puncture_mcs4_p1,
+ gsm0503_puncture_mcs4_p2,
+ gsm0503_puncture_mcs4_p3,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS5,
+ .usf_len = 3,
+ .hdr_len = 25,
+ .hdr_code_len = 99,
+ .hdr_punc_len = 100,
+ .hdr_conv = &gsm0503_mcs5_dl_hdr,
+ .hdr_punc = NULL,
+
+ .data_len = 450,
+ .data_code_len = 1404,
+ .data_punc_len = 1248,
+ .data_conv = &gsm0503_mcs5,
+ .data_punc = {
+ gsm0503_puncture_mcs5_p1,
+ gsm0503_puncture_mcs5_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS6,
+ .usf_len = 3,
+ .hdr_len = 25,
+ .hdr_code_len = 99,
+ .hdr_punc_len = 100,
+ .hdr_conv = &gsm0503_mcs5_dl_hdr,
+ .hdr_punc = NULL,
+
+ .data_len = 594,
+ .data_code_len = 1836,
+ .data_punc_len = 1248,
+ .data_conv = &gsm0503_mcs6,
+ .data_punc = {
+ gsm0503_puncture_mcs6_p1,
+ gsm0503_puncture_mcs6_p2,
+ NULL,
+ },
+ },
+ {
+ .mcs = EGPRS_MCS7,
+ .usf_len = 3,
+ .hdr_len = 37,
+ .hdr_code_len = 135,
+ .hdr_punc_len = 124,
+ .hdr_conv = &gsm0503_mcs7_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_dl_hdr,
+
+ .data_len = 900,
+ .data_code_len = 1404,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs7,
+ .data_punc = {
+ gsm0503_puncture_mcs7_p1,
+ gsm0503_puncture_mcs7_p2,
+ gsm0503_puncture_mcs7_p3,
+ }
+ },
+ {
+ .mcs = EGPRS_MCS8,
+ .usf_len = 3,
+ .hdr_len = 37,
+ .hdr_code_len = 135,
+ .hdr_punc_len = 124,
+ .hdr_conv = &gsm0503_mcs7_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_dl_hdr,
+
+ .data_len = 1092,
+ .data_code_len = 1692,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs8,
+ .data_punc = {
+ gsm0503_puncture_mcs8_p1,
+ gsm0503_puncture_mcs8_p2,
+ gsm0503_puncture_mcs8_p3,
+ }
+ },
+ {
+ .mcs = EGPRS_MCS9,
+ .usf_len = 3,
+ .hdr_len = 37,
+ .hdr_code_len = 135,
+ .hdr_punc_len = 124,
+ .hdr_conv = &gsm0503_mcs7_dl_hdr,
+ .hdr_punc = gsm0503_puncture_mcs7_dl_hdr,
+
+ .data_len = 1188,
+ .data_code_len = 1836,
+ .data_punc_len = 612,
+ .data_conv = &gsm0503_mcs9,
+ .data_punc = {
+ gsm0503_puncture_mcs9_p1,
+ gsm0503_puncture_mcs9_p2,
+ gsm0503_puncture_mcs9_p3,
+ }
+ },
+};
+
+static int osmo_conv_decode_ber(const struct osmo_conv_code *code,
+ const sbit_t *input, ubit_t *output,
+ int *n_errors, int *n_bits_total)
+{
+ int res, i, coded_len;
+ ubit_t recoded[EGPRS_DATA_C_MAX];
+
+ res = osmo_conv_decode(code, input, output);
+
+ if (n_bits_total || n_errors) {
+ coded_len = osmo_conv_encode(code, output, recoded);
+ OSMO_ASSERT(sizeof(recoded) / sizeof(recoded[0]) >= coded_len);
+ }
+
+ /* Count bit errors */
+ if (n_errors) {
+ *n_errors = 0;
+ for (i = 0; i < coded_len; i++) {
+ if (!((recoded[i] && input[i] < 0) ||
+ (!recoded[i] && input[i] > 0)) )
+ *n_errors += 1;
+ }
+ }
+
+ if (n_bits_total)
+ *n_bits_total = coded_len;
+
+ return res;
+}
+
+static int _xcch_decode_cB(uint8_t *l2_data, sbit_t *cB,
+ int *n_errors, int *n_bits_total)
+{
+ ubit_t conv[224];
+ int rv;
+
+ osmo_conv_decode_ber(&gsm0503_xcch, cB,
+ conv, n_errors, n_bits_total);
+
+ rv = osmo_crc64gen_check_bits(&gsm0503_fire_crc40,
+ conv, 184, conv + 184);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(l2_data, 0, conv, 0, 184, 1);
+
+ return 0;
+}
+
+static int _xcch_encode_cB(ubit_t *cB, uint8_t *l2_data)
+{
+ ubit_t conv[224];
+
+ osmo_pbit2ubit_ext(conv, 0, l2_data, 0, 184, 1);
+
+ osmo_crc64gen_set_bits(&gsm0503_fire_crc40, conv, 184, conv + 184);
+
+ osmo_conv_encode(&gsm0503_xcch, conv, cB);
+
+ return 0;
+}
+
+/*
+ * GSM xCCH block transcoding
+ */
+int gsm0503_xcch_decode(uint8_t *l2_data, sbit_t *bursts,
+ int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[456], cB[456];
+ int i;
+
+ for (i = 0; i < 4; i++)
+ gsm0503_xcch_burst_unmap(&iB[i * 114], &bursts[i * 116], NULL, NULL);
+
+ gsm0503_xcch_deinterleave(cB, iB);
+
+ return _xcch_decode_cB(l2_data, cB, n_errors, n_bits_total);
+}
+
+int gsm0503_xcch_encode(ubit_t *bursts, uint8_t *l2_data)
+{
+ ubit_t iB[456], cB[456], hl = 1, hn = 1;
+ int i;
+
+ _xcch_encode_cB(cB, l2_data);
+
+ gsm0503_xcch_interleave(cB, iB);
+
+ for (i = 0; i < 4; i++)
+ gsm0503_xcch_burst_map(&iB[i * 114], &bursts[i * 116], &hl, &hn);
+
+ return 0;
+}
+
+/*
+ * EGPRS PDTCH UL block decoding
+ */
+
+/*
+ * Type 3 - MCS-1,2,3,4
+ * Unmapping and deinterleaving
+ */
+static int egprs_type3_unmap(const sbit_t *bursts, sbit_t *hc, sbit_t *dc)
+{
+ int i;
+ sbit_t iB[456], q[8];
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_xcch_burst_unmap(&iB[i * 114], &bursts[i * 116],
+ q + i * 2, q + i * 2 + 1);
+ }
+
+ gsm0503_mcs1_ul_deinterleave(hc, dc, iB);
+
+ return 0;
+}
+
+/*
+ * Type 2 - MCS-5,6
+ * Unmapping and deinterleaving
+ */
+static int egprs_type2_unmap(const sbit_t *bursts, sbit_t *hc, sbit_t *dc)
+{
+ int i;
+ sbit_t burst[348];
+ sbit_t hi[EGPRS_HDR_HC_MAX];
+ sbit_t di[EGPRS_DATA_DC_MAX];
+
+ for (i = 0; i < 4; i++) {
+ memcpy(burst, &bursts[i * 348], 348);
+
+ gsm0503_mcs5_burst_swap(burst);
+ gsm0503_mcs5_ul_burst_unmap(di, burst, hi, i);
+ }
+
+ gsm0503_mcs5_ul_deinterleave(hc, dc, hi, di);
+
+ return 0;
+}
+
+/*
+ * Type 1 - MCS-7,8,9
+ * Unmapping and deinterleaving - Note that MCS-7 interleaver is unique
+ */
+static int egprs_type1_unmap(const sbit_t *bursts, sbit_t *hc,
+ sbit_t *c1, sbit_t *c2, int msc)
+{
+ int i;
+ sbit_t burst[348];
+ sbit_t hi[EGPRS_HDR_HC_MAX];
+ sbit_t di[EGPRS_DATA_C1 * 2];
+
+ for (i = 0; i < 4; i++) {
+ memcpy(burst, &bursts[i * 348], 348);
+
+ gsm0503_mcs5_burst_swap(burst);
+ gsm0503_mcs7_ul_burst_unmap(di, burst, hi, i);
+ }
+
+ if (msc == EGPRS_MCS7)
+ gsm0503_mcs7_ul_deinterleave(hc, c1, c2, hi, di);
+ else
+ gsm0503_mcs8_ul_deinterleave(hc, c1, c2, hi, di);
+
+ return 0;
+}
+
+/*
+ * Decode EGPRS UL header section
+ *
+ * 1. Depuncture
+ * 2. Convolutional decoding
+ * 3. CRC check
+ */
+static int _egprs_decode_hdr(const sbit_t *hc, int mcs,
+ union gprs_rlc_ul_hdr_egprs *hdr)
+{
+ sbit_t C[EGPRS_HDR_C_MAX];
+ ubit_t upp[EGPRS_HDR_UPP_MAX];
+ int i, j, rc;
+ struct gsm0503_mcs_code *code;
+
+ code = &gsm0503_mcs_ul_codes[mcs];
+
+ /* Skip depuncturing on MCS-5,6 header */
+ if ((mcs == EGPRS_MCS5) || (mcs == EGPRS_MCS6)) {
+ memcpy(C, hc, code->hdr_code_len);
+ goto hdr_conv_decode;
+ }
+
+ if (!code->hdr_punc) {
+ /* Invalid MCS-X header puncture matrix */
+ return -1;
+ }
+
+ i = code->hdr_code_len - 1;
+ j = code->hdr_punc_len - 1;
+
+ for (; i >= 0; i--) {
+ if (!code->hdr_punc[i])
+ C[i] = hc[j--];
+ else
+ C[i] = 0;
+ }
+
+hdr_conv_decode:
+ osmo_conv_decode_ber(code->hdr_conv, C, upp, NULL, NULL);
+ rc = osmo_crc8gen_check_bits(&gsm0503_mcs_crc8_hdr, upp,
+ code->hdr_len, upp + code->hdr_len);
+ if (rc)
+ return -1;
+
+ osmo_ubit2pbit_ext((pbit_t *) hdr, 0, upp, 0, code->hdr_len, 1);
+
+ return 0;
+}
+
+/*
+ * Blind MCS header decoding based on burst length and CRC validation.
+ * Ignore 'q' value coding identification. This approach provides
+ * the strongest chance of header recovery.
+ */
+static int egprs_decode_hdr(union gprs_rlc_ul_hdr_egprs *hdr,
+ const sbit_t *bursts, uint16_t nbits)
+{
+ int rc;
+ sbit_t hc[EGPRS_HDR_HC_MAX];
+
+ if (nbits == GSM0503_GPRS_BURSTS_NBITS) {
+ /* MCS-1,2,3,4 */
+ egprs_type3_unmap(bursts, hc, NULL);
+ rc = _egprs_decode_hdr(hc, EGPRS_MCS1, hdr);
+ if (!rc)
+ return EGPRS_HDR_TYPE3;
+ } else if (nbits == GSM0503_EGPRS_BURSTS_NBITS) {
+ /* MCS-5,6 */
+ egprs_type2_unmap(bursts, hc, NULL);
+ rc = _egprs_decode_hdr(hc, EGPRS_MCS5, hdr);
+ if (!rc)
+ return EGPRS_HDR_TYPE2;
+
+ /* MCS-7,8,9 */
+ egprs_type1_unmap(bursts, hc, NULL, NULL, EGPRS_MCS7);
+ rc = _egprs_decode_hdr(hc, EGPRS_MCS7, hdr);
+ if (!rc)
+ return EGPRS_HDR_TYPE1;
+ }
+
+ return -1;
+}
+
+/*
+ * Parse EGPRS UL header for coding and puncturing scheme (CPS)
+ *
+ * Type 1 - MCS-7,8,9
+ * Type 2 - MCS-5,6
+ * Type 3 - MCS-1,2,3,4
+ */
+static int egprs_parse_ul_cps(struct egprs_cps *cps,
+ union gprs_rlc_ul_hdr_egprs *hdr, int type)
+{
+ uint8_t bits;
+
+ switch (type) {
+ case EGPRS_HDR_TYPE1:
+ bits = hdr->type1.cps;
+ break;
+ case EGPRS_HDR_TYPE2:
+ bits = (hdr->type2.cps_lo << 2) | hdr->type2.cps_hi;
+ break;
+ case EGPRS_HDR_TYPE3:
+ bits = (hdr->type3.cps_lo << 2) | hdr->type3.cps_hi;
+ break;
+ default:
+ return -1;
+ }
+
+ return egprs_get_cps(cps, type, bits);
+}
+
+/*
+ * Decode EGPRS UL data section
+ *
+ * 1. Depuncture
+ * 2. Convolutional decoding
+ * 3. CRC check
+ * 4. Block combining (MCS-7,8,9 only)
+ */
+static int egprs_decode_data(uint8_t *l2_data, sbit_t *c,
+ int mcs, int p, int blk, int *n_errors, int *n_bits_total)
+{
+ ubit_t u[EGPRS_DATA_U_MAX];
+ sbit_t C[EGPRS_DATA_C_MAX];
+
+ int i, j, rc, data_len;
+ struct gsm0503_mcs_code *code;
+
+ if (blk && mcs < EGPRS_MCS7) {
+ /* Invalid MCS-X block state */
+ return -1;
+ }
+
+ code = &gsm0503_mcs_ul_codes[mcs];
+ if (!code->data_punc[p]) {
+ /* Invalid MCS-X data puncture matrix */
+ return -1;
+ }
+
+ /*
+ * MCS-1,6 - single block processing
+ * MCS-7,9 - dual block processing
+ */
+ if (mcs >= EGPRS_MCS7)
+ data_len = code->data_len / 2;
+ else
+ data_len = code->data_len;
+
+ i = code->data_code_len - 1;
+ j = code->data_punc_len - 1;
+
+ for (; i >= 0; i--) {
+ if (!code->data_punc[p][i])
+ C[i] = c[j--];
+ else
+ C[i] = 0;
+ }
+
+ osmo_conv_decode_ber(code->data_conv, C, u, n_errors, n_bits_total);
+ rc = osmo_crc16gen_check_bits(&gsm0503_mcs_crc12, u,
+ data_len, u + data_len);
+ if (rc)
+ return -1;
+
+ /* Offsets output pointer on the second block of Type 1 MCS */
+ osmo_ubit2pbit_ext(l2_data, code->hdr_len + blk * data_len,
+ u, 0, data_len, 1);
+
+ /* Return the number of bytes required for the bit message */
+ return NUM_BYTES(code->hdr_len + code->data_len);
+}
+
+/*
+ * Decode EGPRS UL message
+ *
+ * 1. Header section decoding
+ * 2. Extract CPS settings
+ * 3. Burst unmapping and deinterleaving
+ * 4. Data section decoding
+ */
+int gsm0503_pdtch_egprs_decode(uint8_t *l2_data, sbit_t *bursts, uint16_t nbits,
+ uint8_t *usf_p, int *n_errors, int *n_bits_total)
+{
+ sbit_t dc[EGPRS_DATA_DC_MAX];
+ sbit_t c1[EGPRS_DATA_C1], c2[EGPRS_DATA_C2];
+ int type, rc;
+ struct egprs_cps cps;
+ union gprs_rlc_ul_hdr_egprs *hdr;
+
+ if ((nbits != GSM0503_GPRS_BURSTS_NBITS) &&
+ (nbits != GSM0503_EGPRS_BURSTS_NBITS)) {
+ /* Invalid EGPRS bit length */
+ return -1;
+ }
+
+ hdr = (union gprs_rlc_ul_hdr_egprs *) l2_data;
+ type = egprs_decode_hdr(hdr, bursts, nbits);
+ if (egprs_parse_ul_cps(&cps, hdr, type) < 0)
+ return -1;
+
+ switch (cps.mcs) {
+ case EGPRS_MCS1:
+ case EGPRS_MCS2:
+ case EGPRS_MCS3:
+ case EGPRS_MCS4:
+ egprs_type3_unmap(bursts, NULL, dc);
+ break;
+ case EGPRS_MCS5:
+ case EGPRS_MCS6:
+ egprs_type2_unmap(bursts, NULL, dc);
+ break;
+ case EGPRS_MCS7:
+ case EGPRS_MCS8:
+ case EGPRS_MCS9:
+ egprs_type1_unmap(bursts, NULL, c1, c2, cps.mcs);
+ break;
+ default:
+ /* Invalid MCS-X */
+ return -1;
+ }
+
+ /* Decode MCS-X block, where X = cps.mcs */
+ if (cps.mcs < EGPRS_MCS7) {
+ rc = egprs_decode_data(l2_data, dc, cps.mcs, cps.p[0],
+ 0, n_errors, n_bits_total);
+ if (rc < 0)
+ return -1;
+ } else {
+ /* MCS-7,8,9 block 1 */
+ rc = egprs_decode_data(l2_data, c1, cps.mcs, cps.p[0],
+ 0, n_errors, n_bits_total);
+ if (rc < 0)
+ return -1;
+
+ /* MCS-7,8,9 block 2 */
+ rc = egprs_decode_data(l2_data, c2, cps.mcs, cps.p[1],
+ 1, n_errors, n_bits_total);
+ if (rc < 0)
+ return -1;
+ }
+
+ return rc;
+}
+
+/*
+ * GSM PDTCH block transcoding
+ */
+
+int gsm0503_pdtch_decode(uint8_t *l2_data, sbit_t *bursts, uint8_t *usf_p,
+ int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[456], cB[676], hl_hn[8];
+ ubit_t conv[456];
+ int i, j, k, rv, best = 0, cs = 0, usf = 0; /* make GCC happy */
+
+ for (i = 0; i < 4; i++)
+ gsm0503_xcch_burst_unmap(&iB[i * 114], &bursts[i * 116],
+ hl_hn + i * 2, hl_hn + i * 2 + 1);
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0, k = 0; j < 8; j++)
+ k += abs(((int)gsm0503_pdtch_hl_hn_sbit[i][j]) - ((int)hl_hn[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ cs = i + 1;
+ }
+ }
+
+ gsm0503_xcch_deinterleave(cB, iB);
+
+ switch (cs) {
+ case 1:
+ osmo_conv_decode_ber(&gsm0503_xcch, cB,
+ conv, n_errors, n_bits_total);
+
+ rv = osmo_crc64gen_check_bits(&gsm0503_fire_crc40,
+ conv, 184, conv + 184);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(l2_data, 0, conv, 0, 184, 1);
+
+ return 23;
+ case 2:
+ for (i = 587, j = 455; i >= 0; i--) {
+ if (!gsm0503_puncture_cs2[i])
+ cB[i] = cB[j--];
+ else
+ cB[i] = 0;
+ }
+
+ osmo_conv_decode_ber(&gsm0503_cs2_np, cB,
+ conv, n_errors, n_bits_total);
+
+ for (i = 0; i < 8; i++) {
+ for (j = 0, k = 0; j < 6; j++)
+ k += abs(((int)gsm0503_usf2six[i][j]) - ((int)conv[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ usf = i;
+ }
+ }
+
+ conv[3] = usf & 1;
+ conv[4] = (usf >> 1) & 1;
+ conv[5] = (usf >> 2) & 1;
+ if (usf_p)
+ *usf_p = usf;
+
+ rv = osmo_crc16gen_check_bits(&gsm0503_cs234_crc16,
+ conv + 3, 271, conv + 3 + 271);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(l2_data, 0, conv, 3, 271, 1);
+
+ return 34;
+ case 3:
+ for (i = 675, j = 455; i >= 0; i--) {
+ if (!gsm0503_puncture_cs3[i])
+ cB[i] = cB[j--];
+ else
+ cB[i] = 0;
+ }
+
+ osmo_conv_decode_ber(&gsm0503_cs3_np, cB,
+ conv, n_errors, n_bits_total);
+
+ for (i = 0; i < 8; i++) {
+ for (j = 0, k = 0; j < 6; j++)
+ k += abs(((int)gsm0503_usf2six[i][j]) - ((int)conv[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ usf = i;
+ }
+ }
+
+ conv[3] = usf & 1;
+ conv[4] = (usf >> 1) & 1;
+ conv[5] = (usf >> 2) & 1;
+ if (usf_p)
+ *usf_p = usf;
+
+ rv = osmo_crc16gen_check_bits(&gsm0503_cs234_crc16,
+ conv + 3, 315, conv + 3 + 315);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(l2_data, 0, conv, 3, 315, 1);
+
+ return 40;
+ case 4:
+ for (i = 12; i < 456; i++)
+ conv[i] = (cB[i] < 0) ? 1 : 0;
+
+ for (i = 0; i < 8; i++) {
+ for (j = 0, k = 0; j < 12; j++)
+ k += abs(((int)gsm0503_usf2twelve_sbit[i][j]) - ((int)cB[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ usf = i;
+ }
+ }
+
+ conv[9] = usf & 1;
+ conv[10] = (usf >> 1) & 1;
+ conv[11] = (usf >> 2) & 1;
+ if (usf_p)
+ *usf_p = usf;
+
+ rv = osmo_crc16gen_check_bits(&gsm0503_cs234_crc16,
+ conv + 9, 431, conv + 9 + 431);
+ if (rv) {
+ *n_bits_total = 456 - 12;
+ *n_errors = *n_bits_total;
+ return -1;
+ }
+
+ *n_bits_total = 456 - 12;
+ *n_errors = 0;
+
+ osmo_ubit2pbit_ext(l2_data, 0, conv, 9, 431, 1);
+
+ return 54;
+ default:
+ *n_bits_total = 0;
+ *n_errors = 0;
+ break;
+ }
+
+ return -1;
+}
+
+/*
+ * EGPRS PDTCH UL block encoding
+ */
+static int egprs_type3_map(ubit_t *bursts, ubit_t *hc, ubit_t *dc, int usf)
+{
+ int i;
+ ubit_t iB[456];
+ const ubit_t *hl_hn = gsm0503_pdtch_hl_hn_ubit[3];
+
+ gsm0503_mcs1_dl_interleave(gsm0503_usf2six[usf], hc, dc, iB);
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_xcch_burst_map(&iB[i * 114], &bursts[i * 116],
+ hl_hn + i * 2, hl_hn + i * 2 + 1);
+ }
+
+ return 0;
+}
+
+static int egprs_type2_map(ubit_t *bursts, ubit_t *hc, ubit_t *dc, int usf)
+{
+ int i;
+ const ubit_t *up;
+ ubit_t hi[EGPRS_HDR_HC_MAX];
+ ubit_t di[EGPRS_DATA_DC_MAX];
+
+ gsm0503_mcs5_dl_interleave(hc, dc, hi, di);
+ up = gsm0503_mcs5_usf_precode_table[usf];
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_mcs5_dl_burst_map(di, &bursts[i * 348], hi, up, i);
+ gsm0503_mcs5_burst_swap((sbit_t *) &bursts[i * 348]);
+ }
+
+ return 0;
+}
+
+static int egprs_type1_map(ubit_t *bursts, ubit_t *hc,
+ ubit_t *c1, ubit_t *c2, int usf, int mcs)
+{
+ int i;
+ const ubit_t *up;
+ ubit_t hi[EGPRS_HDR_HC_MAX];
+ ubit_t di[EGPRS_DATA_C1 * 2];
+
+ if (mcs == EGPRS_MCS7)
+ gsm0503_mcs7_dl_interleave(hc, c1, c2, hi, di);
+ else
+ gsm0503_mcs8_dl_interleave(hc, c1, c2, hi, di);
+
+ up = gsm0503_mcs5_usf_precode_table[usf];
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_mcs7_dl_burst_map(di, &bursts[i * 348], hi, up, i);
+ gsm0503_mcs5_burst_swap((sbit_t *) &bursts[i * 348]);
+ }
+
+ return 0;
+}
+
+static int egprs_encode_hdr(ubit_t *hc, uint8_t *l2_data, int mcs)
+{
+ int i, j;
+ ubit_t upp[EGPRS_HDR_UPP_MAX], C[EGPRS_HDR_C_MAX];
+ struct gsm0503_mcs_code *code;
+
+ code = &gsm0503_mcs_dl_codes[mcs];
+
+ osmo_pbit2ubit_ext(upp, 0, l2_data, code->usf_len, code->hdr_len, 1);
+ osmo_crc8gen_set_bits(&gsm0503_mcs_crc8_hdr, upp,
+ code->hdr_len, upp + code->hdr_len);
+
+ osmo_conv_encode(code->hdr_conv, upp, C);
+
+ /* MCS-5,6 header direct puncture instead of table */
+ if ((mcs == EGPRS_MCS5) || (mcs == EGPRS_MCS6)) {
+ memcpy(hc, C, code->hdr_code_len);
+ hc[99] = hc[98];
+ return 0;
+ }
+
+ if (!code->hdr_punc) {
+ /* Invalid MCS-X header puncture matrix */
+ return -1;
+ }
+
+ for (i = 0, j = 0; i < code->hdr_code_len; i++) {
+ if (!code->hdr_punc[i])
+ hc[j++] = C[i];
+ }
+
+ return 0;
+}
+
+static int egprs_encode_data(ubit_t *c, uint8_t *l2_data,
+ int mcs, int p, int blk)
+{
+ int i, j, data_len;
+ ubit_t u[EGPRS_DATA_U_MAX], C[EGPRS_DATA_C_MAX];
+ struct gsm0503_mcs_code *code;
+
+ code = &gsm0503_mcs_dl_codes[mcs];
+
+ /*
+ * Dual block - MCS-7,8,9
+ * Single block - MCS-1,2,3,4,5,6
+ */
+ if (mcs >= EGPRS_MCS7)
+ data_len = code->data_len / 2;
+ else
+ data_len = code->data_len;
+
+ osmo_pbit2ubit_ext(u, 0, l2_data,
+ code->usf_len + code->hdr_len + blk * data_len, data_len, 1);
+
+ osmo_crc16gen_set_bits(&gsm0503_mcs_crc12, u, data_len, u + data_len);
+
+ osmo_conv_encode(code->data_conv, u, C);
+
+ if (!code->data_punc[p]) {
+ /* Invalid MCS-X data puncture matrix */
+ return -1;
+ }
+
+ for (i = 0, j = 0; i < code->data_code_len; i++) {
+ if (!code->data_punc[p][i])
+ c[j++] = C[i];
+ }
+
+ return 0;
+}
+
+/*
+ * Parse EGPRS DL header for coding and puncturing scheme (CPS)
+ *
+ * Type 1 - MCS-7,8,9
+ * Type 2 - MCS-5,6
+ * Type 3 - MCS-1,2,3,4
+ */
+static int egprs_parse_dl_cps(struct egprs_cps *cps,
+ union gprs_rlc_dl_hdr_egprs *hdr, int type)
+{
+ uint8_t bits;
+
+ switch (type) {
+ case EGPRS_HDR_TYPE1:
+ bits = hdr->type1.cps;
+ break;
+ case EGPRS_HDR_TYPE2:
+ bits = hdr->type2.cps;
+ break;
+ case EGPRS_HDR_TYPE3:
+ bits = hdr->type3.cps;
+ break;
+ default:
+ return -1;
+ }
+
+ return egprs_get_cps(cps, type, bits);
+}
+
+/*
+ * EGPRS DL message encoding
+ */
+int gsm0503_pdtch_egprs_encode(ubit_t *bursts,
+ uint8_t *l2_data, uint8_t l2_len)
+{
+ ubit_t hc[EGPRS_DATA_C_MAX], dc[EGPRS_DATA_DC_MAX];
+ ubit_t c1[EGPRS_DATA_C1], c2[EGPRS_DATA_C2];
+ uint8_t mcs;
+ struct egprs_cps cps;
+ union gprs_rlc_dl_hdr_egprs *hdr;
+
+ switch (l2_len) {
+ case 27:
+ mcs = EGPRS_MCS1;
+ break;
+ case 33:
+ mcs = EGPRS_MCS2;
+ break;
+ case 42:
+ mcs = EGPRS_MCS3;
+ break;
+ case 49:
+ mcs = EGPRS_MCS4;
+ break;
+ case 60:
+ mcs = EGPRS_MCS5;
+ break;
+ case 78:
+ mcs = EGPRS_MCS6;
+ break;
+ case 118:
+ mcs = EGPRS_MCS7;
+ break;
+ case 142:
+ mcs = EGPRS_MCS8;
+ break;
+ case 154:
+ mcs = EGPRS_MCS9;
+ break;
+ default:
+ return -1;
+ }
+
+ /* Read header for USF and puncturing matrix selection. */
+ hdr = (union gprs_rlc_dl_hdr_egprs *) l2_data;
+
+ switch (mcs) {
+ case EGPRS_MCS1:
+ case EGPRS_MCS2:
+ case EGPRS_MCS3:
+ case EGPRS_MCS4:
+ /* Check for valid CPS and matching MCS to message size */
+ if ((egprs_parse_dl_cps(&cps, hdr, EGPRS_HDR_TYPE3) < 0) ||
+ (cps.mcs != mcs))
+ goto bad_header;
+
+ egprs_encode_hdr(hc, l2_data, mcs);
+ egprs_encode_data(dc, l2_data, mcs, cps.p[0], 0);
+ egprs_type3_map(bursts, hc, dc, hdr->type3.usf);
+ break;
+ case EGPRS_MCS5:
+ case EGPRS_MCS6:
+ if ((egprs_parse_dl_cps(&cps, hdr, EGPRS_HDR_TYPE2) < 0) ||
+ (cps.mcs != mcs))
+ goto bad_header;
+
+ egprs_encode_hdr(hc, l2_data, mcs);
+ egprs_encode_data(dc, l2_data, mcs, cps.p[0], 0);
+ egprs_type2_map(bursts, hc, dc, hdr->type2.usf);
+ break;
+ case EGPRS_MCS7:
+ case EGPRS_MCS8:
+ case EGPRS_MCS9:
+ if ((egprs_parse_dl_cps(&cps, hdr, EGPRS_HDR_TYPE1) < 0) ||
+ (cps.mcs != mcs))
+ goto bad_header;
+
+ egprs_encode_hdr(hc, l2_data, mcs);
+ egprs_encode_data(c1, l2_data, mcs, cps.p[0], 0);
+ egprs_encode_data(c2, l2_data, mcs, cps.p[1], 1);
+ egprs_type1_map(bursts, hc, c1, c2, hdr->type1.usf, mcs);
+ break;
+ }
+
+ return mcs >= EGPRS_MCS5 ?
+ GSM0503_EGPRS_BURSTS_NBITS : GSM0503_GPRS_BURSTS_NBITS;
+
+bad_header:
+ /* Invalid EGPRS MCS-X header */
+ return -1;
+}
+
+int gsm0503_pdtch_encode(ubit_t *bursts, uint8_t *l2_data, uint8_t l2_len)
+{
+ ubit_t iB[456], cB[676];
+ const ubit_t *hl_hn;
+ ubit_t conv[334];
+ int i, j, usf;
+
+ switch (l2_len) {
+ case 23:
+ osmo_pbit2ubit_ext(conv, 0, l2_data, 0, 184, 1);
+
+ osmo_crc64gen_set_bits(&gsm0503_fire_crc40, conv, 184, conv + 184);
+
+ osmo_conv_encode(&gsm0503_xcch, conv, cB);
+
+ hl_hn = gsm0503_pdtch_hl_hn_ubit[0];
+
+ break;
+ case 34:
+ osmo_pbit2ubit_ext(conv, 3, l2_data, 0, 271, 1);
+ usf = l2_data[0] & 0x7;
+
+ osmo_crc16gen_set_bits(&gsm0503_cs234_crc16, conv + 3,
+ 271, conv + 3 + 271);
+
+ memcpy(conv, gsm0503_usf2six[usf], 6);
+
+ osmo_conv_encode(&gsm0503_cs2_np, conv, cB);
+
+ for (i = 0, j = 0; i < 588; i++)
+ if (!gsm0503_puncture_cs2[i])
+ cB[j++] = cB[i];
+
+ hl_hn = gsm0503_pdtch_hl_hn_ubit[1];
+
+ break;
+ case 40:
+ osmo_pbit2ubit_ext(conv, 3, l2_data, 0, 315, 1);
+ usf = l2_data[0] & 0x7;
+
+ osmo_crc16gen_set_bits(&gsm0503_cs234_crc16, conv + 3,
+ 315, conv + 3 + 315);
+
+ memcpy(conv, gsm0503_usf2six[usf], 6);
+
+ osmo_conv_encode(&gsm0503_cs3_np, conv, cB);
+
+ for (i = 0, j = 0; i < 676; i++)
+ if (!gsm0503_puncture_cs3[i])
+ cB[j++] = cB[i];
+
+ hl_hn = gsm0503_pdtch_hl_hn_ubit[2];
+
+ break;
+ case 54:
+ osmo_pbit2ubit_ext(cB, 9, l2_data, 0, 431, 1);
+ usf = l2_data[0] & 0x7;
+
+ osmo_crc16gen_set_bits(&gsm0503_cs234_crc16, cB + 9,
+ 431, cB + 9 + 431);
+
+ memcpy(cB, gsm0503_usf2twelve_ubit[usf], 12);
+
+ hl_hn = gsm0503_pdtch_hl_hn_ubit[3];
+
+ break;
+ default:
+ return -1;
+ }
+
+ gsm0503_xcch_interleave(cB, iB);
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_xcch_burst_map(&iB[i * 114], &bursts[i * 116],
+ hl_hn + i * 2, hl_hn + i * 2 + 1);
+ }
+
+ return GSM0503_GPRS_BURSTS_NBITS;
+}
+
+/*
+ * GSM TCH/F FR/EFR transcoding
+ */
+
+static void tch_fr_reassemble(uint8_t *tch_data,
+ ubit_t *b_bits, int net_order)
+{
+ int i, j, k, l, o;
+
+ tch_data[0] = 0xd << 4;
+ memset(tch_data + 1, 0, 32);
+
+ if (net_order) {
+ for (i = 0, j = 4; i < 260; i++, j++)
+ tch_data[j >> 3] |= (b_bits[i] << (7 - (j & 7)));
+
+ return;
+ }
+
+ /* reassemble d-bits */
+ i = 0; /* counts bits */
+ j = 4; /* counts output bits */
+ k = gsm0503_gsm_fr_map[0]-1; /* current number bit in element */
+ l = 0; /* counts element bits */
+ o = 0; /* offset input bits */
+ while (i < 260) {
+ tch_data[j >> 3] |= (b_bits[k + o] << (7 - (j & 7)));
+ if (--k < 0) {
+ o += gsm0503_gsm_fr_map[l];
+ k = gsm0503_gsm_fr_map[++l]-1;
+ }
+ i++;
+ j++;
+ }
+}
+
+static void tch_fr_disassemble(ubit_t *b_bits,
+ uint8_t *tch_data, int net_order)
+{
+ int i, j, k, l, o;
+
+ if (net_order) {
+ for (i = 0, j = 4; i < 260; i++, j++)
+ b_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+
+ return;
+ }
+
+ i = 0; /* counts bits */
+ j = 4; /* counts input bits */
+ k = gsm0503_gsm_fr_map[0] - 1; /* current number bit in element */
+ l = 0; /* counts element bits */
+ o = 0; /* offset output bits */
+ while (i < 260) {
+ b_bits[k + o] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+ if (--k < 0) {
+ o += gsm0503_gsm_fr_map[l];
+ k = gsm0503_gsm_fr_map[++l] - 1;
+ }
+ i++;
+ j++;
+ }
+}
+
+static void tch_hr_reassemble(uint8_t *tch_data, ubit_t *b_bits)
+{
+ int i, j;
+
+ tch_data[0] = 0x00; /* F = 0, FT = 000 */
+ memset(tch_data + 1, 0, 14);
+
+ for (i = 0, j = 8; i < 112; i++, j++)
+ tch_data[j >> 3] |= (b_bits[i] << (7 - (j & 7)));
+}
+
+static void tch_hr_disassemble(ubit_t *b_bits, uint8_t *tch_data)
+{
+ int i, j;
+
+ for (i = 0, j = 8; i < 112; i++, j++)
+ b_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+}
+
+static void tch_efr_reassemble(uint8_t *tch_data, ubit_t *b_bits)
+{
+ int i, j;
+
+ tch_data[0] = 0xc << 4;
+ memset(tch_data + 1, 0, 30);
+
+ for (i = 0, j = 4; i < 244; i++, j++)
+ tch_data[j >> 3] |= (b_bits[i] << (7 - (j & 7)));
+}
+
+static void tch_efr_disassemble(ubit_t *b_bits, uint8_t *tch_data)
+{
+ int i, j;
+
+ for (i = 0, j = 4; i < 244; i++, j++)
+ b_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+}
+
+static void tch_amr_reassemble(uint8_t *tch_data, ubit_t *d_bits, int len)
+{
+ int i, j;
+
+ memset(tch_data, 0, (len + 7) >> 3);
+
+ for (i = 0, j = 0; i < len; i++, j++)
+ tch_data[j >> 3] |= (d_bits[i] << (7 - (j & 7)));
+}
+
+static void tch_amr_disassemble(ubit_t *d_bits, uint8_t *tch_data, int len)
+{
+ int i, j;
+
+ for (i = 0, j = 0; i < len; i++, j++)
+ d_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+}
+
+static void tch_fr_d_to_b(ubit_t *b_bits, ubit_t *d_bits)
+{
+ int i;
+
+ for (i = 0; i < 260; i++)
+ b_bits[gsm610_bitorder[i]] = d_bits[i];
+}
+
+static void tch_fr_b_to_d(ubit_t *d_bits, ubit_t *b_bits)
+{
+ int i;
+
+ for (i = 0; i < 260; i++)
+ d_bits[i] = b_bits[gsm610_bitorder[i]];
+}
+
+static void tch_hr_d_to_b(ubit_t *b_bits, ubit_t *d_bits)
+{
+ int i;
+
+ const uint16_t *map;
+
+ if (!d_bits[93] && !d_bits[94])
+ map = gsm620_unvoiced_bitorder;
+ else
+ map = gsm620_voiced_bitorder;
+
+ for (i = 0; i < 112; i++)
+ b_bits[map[i]] = d_bits[i];
+}
+
+static void tch_hr_b_to_d(ubit_t *d_bits, ubit_t *b_bits)
+{
+ int i;
+ const uint16_t *map;
+
+ if (!b_bits[34] && !b_bits[35])
+ map = gsm620_unvoiced_bitorder;
+ else
+ map = gsm620_voiced_bitorder;
+
+ for (i = 0; i < 112; i++)
+ d_bits[i] = b_bits[map[i]];
+}
+
+static void tch_efr_d_to_w(ubit_t *b_bits, ubit_t *d_bits)
+{
+ int i;
+
+ for (i = 0; i < 260; i++)
+ b_bits[gsm660_bitorder[i]] = d_bits[i];
+}
+
+static void tch_efr_w_to_d(ubit_t *d_bits, ubit_t *b_bits)
+{
+ int i;
+
+ for (i = 0; i < 260; i++)
+ d_bits[i] = b_bits[gsm660_bitorder[i]];
+}
+
+static void tch_efr_protected(ubit_t *s_bits, ubit_t *b_bits)
+{
+ int i;
+
+ for (i = 0; i < 65; i++)
+ b_bits[i] = s_bits[gsm0503_gsm_efr_protected_bits[i] - 1];
+}
+
+static void tch_fr_unreorder(ubit_t *d, ubit_t *p, ubit_t *u)
+{
+ int i;
+
+ for (i = 0; i < 91; i++) {
+ d[i << 1] = u[i];
+ d[(i << 1) + 1] = u[184 - i];
+ }
+
+ for (i = 0; i < 3; i++)
+ p[i] = u[91 + i];
+}
+
+static void tch_fr_reorder(ubit_t *u, ubit_t *d, ubit_t *p)
+{
+ int i;
+
+ for (i = 0; i < 91; i++) {
+ u[i] = d[i << 1];
+ u[184 - i] = d[(i << 1) + 1];
+ }
+
+ for (i = 0; i < 3; i++)
+ u[91 + i] = p[i];
+}
+
+static void tch_hr_unreorder(ubit_t *d, ubit_t *p, ubit_t *u)
+{
+ memcpy(d, u, 95);
+ memcpy(p, u + 95, 3);
+}
+
+static void tch_hr_reorder(ubit_t *u, ubit_t *d, ubit_t *p)
+{
+ memcpy(u, d, 95);
+ memcpy(u + 95, p, 3);
+}
+
+static void tch_efr_reorder(ubit_t *w, ubit_t *s, ubit_t *p)
+{
+ memcpy(w, s, 71);
+ w[71] = w[72] = s[69];
+ memcpy(w + 73, s + 71, 50);
+ w[123] = w[124] = s[119];
+ memcpy(w + 125, s + 121, 53);
+ w[178] = w[179] = s[172];
+ memcpy(w + 180, s + 174, 50);
+ w[230] = w[231] = s[222];
+ memcpy(w + 232, s + 224, 20);
+ memcpy(w + 252, p, 8);
+}
+
+static void tch_efr_unreorder(ubit_t *s, ubit_t *p, ubit_t *w)
+{
+ int sum;
+
+ memcpy(s, w, 71);
+ sum = s[69] + w[71] + w[72];
+ s[69] = (sum > 2);
+ memcpy(s + 71, w + 73, 50);
+ sum = s[119] + w[123] + w[124];
+ s[119] = (sum > 2);
+ memcpy(s + 121, w + 125, 53);
+ sum = s[172] + w[178] + w[179];
+ s[172] = (sum > 2);
+ memcpy(s + 174, w + 180, 50);
+ sum = s[220] + w[230] + w[231];
+ s[222] = (sum > 2);
+ memcpy(s + 224, w + 232, 20);
+ memcpy(p, w + 252, 8);
+}
+
+static void tch_amr_merge(ubit_t *u, ubit_t *d, ubit_t *p, int len, int prot)
+{
+ memcpy(u, d, prot);
+ memcpy(u + prot, p, 6);
+ memcpy(u + prot + 6, d + prot, len - prot);
+}
+
+static void tch_amr_unmerge(ubit_t *d, ubit_t *p,
+ ubit_t *u, int len, int prot)
+{
+ memcpy(d, u, prot);
+ memcpy(p, u + prot, 6);
+ memcpy(d + prot, u + prot + 6, len - prot);
+}
+
+int gsm0503_tch_fr_decode(uint8_t *tch_data, sbit_t *bursts,
+ int net_order, int efr, int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[912], cB[456], h;
+ ubit_t conv[185], s[244], w[260], b[65], d[260], p[8];
+ int i, rv, len, steal = 0;
+
+ for (i = 0; i < 8; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114],
+ &bursts[i * 116], &h, i >> 2);
+ steal -= h;
+ }
+
+ gsm0503_tch_fr_deinterleave(cB, iB);
+
+ if (steal > 0) {
+ rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total);
+ if (rv) {
+ /* Error decoding FACCH frame */
+ return -1;
+ }
+
+ return 23;
+ }
+
+ osmo_conv_decode_ber(&gsm0503_tch_fr, cB, conv, n_errors, n_bits_total);
+
+ tch_fr_unreorder(d, p, conv);
+
+ for (i = 0; i < 78; i++)
+ d[i + 182] = (cB[i + 378] < 0) ? 1 : 0;
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_tch_fr_crc3, d, 50, p);
+ if (rv) {
+ /* Error checking CRC8 for the FR part of an EFR/FR frame */
+ return -1;
+ }
+
+ if (efr) {
+ tch_efr_d_to_w(w, d);
+
+ tch_efr_unreorder(s, p, w);
+
+ tch_efr_protected(s, b);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_tch_efr_crc8, b, 65, p);
+ if (rv) {
+ /* Error checking CRC8 for the EFR part of an EFR frame */
+ return -1;
+ }
+
+ tch_efr_reassemble(tch_data, s);
+
+ len = GSM_EFR_BYTES;
+ } else {
+ tch_fr_d_to_b(w, d);
+
+ tch_fr_reassemble(tch_data, w, net_order);
+
+ len = GSM_FR_BYTES;
+ }
+
+ return len;
+}
+
+int gsm0503_tch_fr_encode(ubit_t *bursts, uint8_t *tch_data,
+ int len, int net_order)
+{
+ ubit_t iB[912], cB[456], h;
+ ubit_t conv[185], w[260], b[65], s[244], d[260], p[8];
+ int i;
+
+ switch (len) {
+ case GSM_EFR_BYTES: /* TCH EFR */
+
+ tch_efr_disassemble(s, tch_data);
+
+ tch_efr_protected(s, b);
+
+ osmo_crc8gen_set_bits(&gsm0503_tch_efr_crc8, b, 65, p);
+
+ tch_efr_reorder(w, s, p);
+
+ tch_efr_w_to_d(d, w);
+
+ goto coding_efr_fr;
+ case GSM_FR_BYTES: /* TCH FR */
+ tch_fr_disassemble(w, tch_data, net_order);
+
+ tch_fr_b_to_d(d, w);
+
+coding_efr_fr:
+ osmo_crc8gen_set_bits(&gsm0503_tch_fr_crc3, d, 50, p);
+
+ tch_fr_reorder(conv, d, p);
+
+ memcpy(cB + 378, d + 182, 78);
+
+ osmo_conv_encode(&gsm0503_tch_fr, conv, cB);
+
+ h = 0;
+
+ break;
+ case GSM_MACBLOCK_LEN: /* FACCH */
+ _xcch_encode_cB(cB, tch_data);
+
+ h = 1;
+
+ break;
+ default:
+ return -1;
+ }
+
+ gsm0503_tch_fr_interleave(cB, iB);
+
+ for (i = 0; i < 8; i++) {
+ gsm0503_tch_burst_map(&iB[i * 114],
+ &bursts[i * 116], &h, i >> 2);
+ }
+
+ return 0;
+}
+
+int gsm0503_tch_hr_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
+ int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[912], cB[456], h;
+ ubit_t conv[98], b[112], d[112], p[3];
+ int i, rv, steal = 0;
+
+ /* Only unmap the stealing bits */
+ if (!odd) {
+ for (i = 0; i < 4; i++) {
+ gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 0);
+ steal -= h;
+ }
+
+ for (i = 2; i < 5; i++) {
+ gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 1);
+ steal -= h;
+ }
+ }
+
+ /* If we found a stole FACCH, but only at correct alignment */
+ if (steal > 0) {
+ for (i = 0; i < 6; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114],
+ &bursts[i * 116], NULL, i >> 2);
+ }
+
+ for (i = 2; i < 4; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114 + 456],
+ &bursts[i * 116], NULL, 1);
+ }
+
+ gsm0503_tch_fr_deinterleave(cB, iB);
+
+ rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total);
+ if (rv) {
+ /* Error decoding FACCH frame */
+ return -1;
+ }
+
+ return GSM_MACBLOCK_LEN;
+ }
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114],
+ &bursts[i * 116], NULL, i >> 1);
+ }
+
+ gsm0503_tch_hr_deinterleave(cB, iB);
+
+ osmo_conv_decode_ber(&gsm0503_tch_hr, cB, conv, n_errors, n_bits_total);
+
+ tch_hr_unreorder(d, p, conv);
+
+ for (i = 0; i < 17; i++)
+ d[i + 95] = (cB[i + 211] < 0) ? 1 : 0;
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p);
+ if (rv) {
+ /* Error checking CRC8 for an HR frame */
+ return -1;
+ }
+
+ tch_hr_d_to_b(b, d);
+
+ tch_hr_reassemble(tch_data, b);
+
+ return 15;
+}
+
+int gsm0503_tch_hr_encode(ubit_t *bursts, uint8_t *tch_data, int len)
+{
+ ubit_t iB[912], cB[456], h;
+ ubit_t conv[98], b[112], d[112], p[3];
+ int i;
+
+ switch (len) {
+ case 15: /* TCH HR */
+ tch_hr_disassemble(b, tch_data);
+
+ tch_hr_b_to_d(d, b);
+
+ osmo_crc8gen_set_bits(&gsm0503_tch_fr_crc3, d + 73, 22, p);
+
+ tch_hr_reorder(conv, d, p);
+
+ osmo_conv_encode(&gsm0503_tch_hr, conv, cB);
+
+ memcpy(cB + 211, d + 95, 17);
+
+ h = 0;
+
+ gsm0503_tch_hr_interleave(cB, iB);
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_tch_burst_map(&iB[i * 114],
+ &bursts[i * 116], &h, i >> 1);
+ }
+
+ break;
+ case GSM_MACBLOCK_LEN: /* FACCH */
+ _xcch_encode_cB(cB, tch_data);
+
+ h = 1;
+
+ gsm0503_tch_fr_interleave(cB, iB);
+
+ for (i = 0; i < 6; i++) {
+ gsm0503_tch_burst_map(&iB[i * 114],
+ &bursts[i * 116], &h, i >> 2);
+ }
+
+ for (i = 2; i < 4; i++) {
+ gsm0503_tch_burst_map(&iB[i * 114 + 456],
+ &bursts[i * 116], &h, 1);
+ }
+
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+int gsm0503_tch_afs_decode(uint8_t *tch_data, sbit_t *bursts,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
+ uint8_t *cmr, int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[912], cB[456], h;
+ ubit_t d[244], p[6], conv[250];
+ int i, j, k, best = 0, rv, len, steal = 0, id = 0;
+ *n_errors = 0; *n_bits_total = 0;
+
+ for (i=0; i<8; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114], &bursts[i * 116], &h, i >> 2);
+ steal -= h;
+ }
+
+ gsm0503_tch_fr_deinterleave(cB, iB);
+
+ if (steal > 0) {
+ rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total);
+ if (rv) {
+ /* Error decoding FACCH frame */
+ return -1;
+ }
+
+ return GSM_MACBLOCK_LEN;
+ }
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0, k = 0; j < 8; j++)
+ k += abs(((int)gsm0503_afs_ic_sbit[i][j]) - ((int)cB[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ id = i;
+ }
+ }
+
+ /* Check if indicated codec fits into range of codecs */
+ if (id >= codecs) {
+ /* Codec mode out of range, return id */
+ return id;
+ }
+
+ switch ((codec_mode_req) ? codec[*ft] : codec[id]) {
+ case 7: /* TCH/AFS12.2 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_12_2, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 244, 81);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 81, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 12.2 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 244);
+
+ len = 31;
+
+ break;
+ case 6: /* TCH/AFS10.2 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_10_2, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 204, 65);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 65, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 10.2 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 204);
+
+ len = 26;
+
+ break;
+ case 5: /* TCH/AFS7.95 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_7_95, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 159, 75);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 75, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 7.95 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 159);
+
+ len = 20;
+
+ break;
+ case 4: /* TCH/AFS7.4 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_7_4, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 148, 61);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 61, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 7.4 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 148);
+
+ len = 19;
+
+ break;
+ case 3: /* TCH/AFS6.7 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_6_7, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 134, 55);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 55, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 6.7 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 134);
+
+ len = 17;
+
+ break;
+ case 2: /* TCH/AFS5.9 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_5_9, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 118, 55);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 55, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 5.9 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 118);
+
+ len = 15;
+
+ break;
+ case 1: /* TCH/AFS5.15 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_5_15, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 103, 49);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 49, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 5.15 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 103);
+
+ len = 13;
+
+ break;
+ case 0: /* TCH/AFS4.75 */
+ osmo_conv_decode_ber(&gsm0503_tch_afs_4_75, cB + 8,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 95, 39);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 39, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 4.75 frame */
+ return -1;
+ }
+
+ tch_amr_reassemble(tch_data, d, 95);
+
+ len = 12;
+
+ break;
+ default:
+ /* Unknown frame type */
+ *n_bits_total = 448;
+ *n_errors = *n_bits_total;
+ return -1;
+ }
+
+ /* Change codec request / indication, if frame is valid */
+ if (codec_mode_req)
+ *cmr = id;
+ else
+ *ft = id;
+
+ return len;
+}
+
+int gsm0503_tch_afs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft,
+ uint8_t cmr)
+{
+ ubit_t iB[912], cB[456], h;
+ ubit_t d[244], p[6], conv[250];
+ int i;
+ uint8_t id;
+
+ if (len == GSM_MACBLOCK_LEN) { /* FACCH */
+ _xcch_encode_cB(cB, tch_data);
+
+ h = 1;
+
+ goto facch;
+ }
+
+ h = 0;
+
+ if (codec_mode_req) {
+ if (cmr >= codecs) {
+ /* FIXME: CMR ID is not in codec list! */
+ return -1;
+ }
+ id = cmr;
+ } else {
+ if (ft >= codecs) {
+ /* FIXME: FT ID is not in codec list! */
+ return -1;
+ }
+ id = ft;
+ }
+
+ switch (codec[ft]) {
+ case 7: /* TCH/AFS12.2 */
+ if (len != 31)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 244);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 81, p);
+
+ tch_amr_merge(conv, d, p, 244, 81);
+
+ osmo_conv_encode(&gsm0503_tch_afs_12_2, conv, cB + 8);
+
+ break;
+ case 6: /* TCH/AFS10.2 */
+ if (len != 26)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 204);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 65, p);
+
+ tch_amr_merge(conv, d, p, 204, 65);
+
+ osmo_conv_encode(&gsm0503_tch_afs_10_2, conv, cB + 8);
+
+ break;
+ case 5: /* TCH/AFS7.95 */
+ if (len != 20)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 159);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 75, p);
+
+ tch_amr_merge(conv, d, p, 159, 75);
+
+ osmo_conv_encode(&gsm0503_tch_afs_7_95, conv, cB + 8);
+
+ break;
+ case 4: /* TCH/AFS7.4 */
+ if (len != 19)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 148);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 61, p);
+
+ tch_amr_merge(conv, d, p, 148, 61);
+
+ osmo_conv_encode(&gsm0503_tch_afs_7_4, conv, cB + 8);
+
+ break;
+ case 3: /* TCH/AFS6.7 */
+ if (len != 17)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 134);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 55, p);
+
+ tch_amr_merge(conv, d, p, 134, 55);
+
+ osmo_conv_encode(&gsm0503_tch_afs_6_7, conv, cB + 8);
+
+ break;
+ case 2: /* TCH/AFS5.9 */
+ if (len != 15)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 118);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 55, p);
+
+ tch_amr_merge(conv, d, p, 118, 55);
+
+ osmo_conv_encode(&gsm0503_tch_afs_5_9, conv, cB + 8);
+
+ break;
+ case 1: /* TCH/AFS5.15 */
+ if (len != 13)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 103);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 49, p);
+
+ tch_amr_merge(conv, d, p, 103, 49);
+
+ osmo_conv_encode(&gsm0503_tch_afs_5_15, conv, cB + 8);
+
+ break;
+ case 0: /* TCH/AFS4.75 */
+ if (len != 12)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 95);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 39, p);
+
+ tch_amr_merge(conv, d, p, 95, 39);
+
+ osmo_conv_encode(&gsm0503_tch_afs_4_75, conv, cB + 8);
+
+ break;
+ default:
+ /* FIXME: FT %ft is not supported */
+ return -1;
+ }
+
+ memcpy(cB, gsm0503_afs_ic_ubit[id], 8);
+
+facch:
+ gsm0503_tch_fr_interleave(cB, iB);
+
+ for (i = 0; i < 8; i++) {
+ gsm0503_tch_burst_map(&iB[i * 114],
+ &bursts[i * 116], &h, i >> 2);
+ }
+
+ return 0;
+
+invalid_length:
+ /* FIXME: payload length %len does not comply with codec type %ft */
+ return -1;
+}
+
+int gsm0503_tch_ahs_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft,
+ uint8_t *cmr, int *n_errors, int *n_bits_total)
+{
+ sbit_t iB[912], cB[456], h;
+ ubit_t d[244], p[6], conv[135];
+ int i, j, k, best = 0, rv, len, steal = 0, id = 0;
+
+ /* only unmap the stealing bits */
+ if (!odd) {
+ for (i = 0; i < 4; i++) {
+ gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 0);
+ steal -= h;
+ }
+ for (i = 2; i < 5; i++) {
+ gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 1);
+ steal -= h;
+ }
+ }
+
+ /* if we found a stole FACCH, but only at correct alignment */
+ if (steal > 0) {
+ for (i = 0; i < 6; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114],
+ &bursts[i * 116], NULL, i >> 2);
+ }
+
+ for (i = 2; i < 4; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114 + 456],
+ &bursts[i * 116], NULL, 1);
+ }
+
+ gsm0503_tch_fr_deinterleave(cB, iB);
+
+ rv = _xcch_decode_cB(tch_data, cB, n_errors, n_bits_total);
+ if (rv) {
+ /* Error decoding FACCH frame */
+ return -1;
+ }
+
+ return GSM_MACBLOCK_LEN;
+ }
+
+ for (i = 0; i < 4; i++) {
+ gsm0503_tch_burst_unmap(&iB[i * 114],
+ &bursts[i * 116], NULL, i >> 1);
+ }
+
+ gsm0503_tch_hr_deinterleave(cB, iB);
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0, k = 0; j < 4; j++)
+ k += abs(((int)gsm0503_ahs_ic_sbit[i][j]) - ((int)cB[j]));
+
+ if (i == 0 || k < best) {
+ best = k;
+ id = i;
+ }
+ }
+
+ /* Check if indicated codec fits into range of codecs */
+ if (id >= codecs) {
+ /* Codec mode out of range, return id */
+ return id;
+ }
+
+ switch ((codec_mode_req) ? codec[*ft] : codec[id]) {
+ case 5: /* TCH/AHS7.95 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_7_95, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 123, 67);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 67, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 7.95 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 36; i++)
+ d[i + 123] = (cB[i + 192] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 159);
+
+ len = 20;
+
+ break;
+ case 4: /* TCH/AHS7.4 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_7_4, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 120, 61);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 61, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 7.4 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 28; i++)
+ d[i + 120] = (cB[i + 200] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 148);
+
+ len = 19;
+
+ break;
+ case 3: /* TCH/AHS6.7 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_6_7, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 110, 55);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 55, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 6.7 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 24; i++)
+ d[i + 110] = (cB[i + 204] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 134);
+
+ len = 17;
+
+ break;
+ case 2: /* TCH/AHS5.9 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_5_9, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 102, 55);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 55, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 5.9 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 16; i++)
+ d[i + 102] = (cB[i + 212] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 118);
+
+ len = 15;
+
+ break;
+ case 1: /* TCH/AHS5.15 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_5_15, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 91, 49);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 49, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 5.15 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 12; i++)
+ d[i + 91] = (cB[i + 216] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 103);
+
+ len = 13;
+
+ break;
+ case 0: /* TCH/AHS4.75 */
+ osmo_conv_decode_ber(&gsm0503_tch_ahs_4_75, cB + 4,
+ conv, n_errors, n_bits_total);
+
+ tch_amr_unmerge(d, p, conv, 83, 39);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_amr_crc6, d, 39, p);
+ if (rv) {
+ /* Error checking CRC8 for an AMR 4.75 frame */
+ return -1;
+ }
+
+ for (i = 0; i < 12; i++)
+ d[i + 83] = (cB[i + 216] < 0) ? 1 : 0;
+
+ tch_amr_reassemble(tch_data, d, 95);
+
+ len = 12;
+
+ break;
+ default:
+ /* Unknown frame type */
+ *n_bits_total = 159;
+ *n_errors = *n_bits_total;
+ return -1;
+ }
+
+ /* Change codec request / indication, if frame is valid */
+ if (codec_mode_req)
+ *cmr = id;
+ else
+ *ft = id;
+
+ return len;
+}
+
+int gsm0503_tch_ahs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
+ int codec_mode_req, uint8_t *codec, int codecs, uint8_t ft,
+ uint8_t cmr)
+{
+ ubit_t iB[912], cB[456], h;
+ ubit_t d[244], p[6], conv[135];
+ int i;
+ uint8_t id;
+
+ if (len == GSM_MACBLOCK_LEN) { /* FACCH */
+ _xcch_encode_cB(cB, tch_data);
+
+ h = 1;
+
+ gsm0503_tch_fr_interleave(cB, iB);
+
+ for (i = 0; i < 6; i++)
+ gsm0503_tch_burst_map(&iB[i * 114], &bursts[i * 116],
+ &h, i >> 2);
+ for (i = 2; i < 4; i++)
+ gsm0503_tch_burst_map(&iB[i * 114 + 456],
+ &bursts[i * 116], &h, 1);
+
+ return 0;
+ }
+
+ h = 0;
+
+ if (codec_mode_req) {
+ if (cmr >= codecs) {
+ /* FIXME: CMR ID %d not in codec list */
+ return -1;
+ }
+ id = cmr;
+ } else {
+ if (ft >= codecs) {
+ /* FIXME: FT ID %d not in codec list */
+ return -1;
+ }
+ id = ft;
+ }
+
+ switch (codec[ft]) {
+ case 5: /* TCH/AHS7.95 */
+ if (len != 20)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 159);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 67, p);
+
+ tch_amr_merge(conv, d, p, 123, 67);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_7_95, conv, cB + 4);
+
+ memcpy(cB + 192, d + 123, 36);
+
+ break;
+ case 4: /* TCH/AHS7.4 */
+ if (len != 19)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 148);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 61, p);
+
+ tch_amr_merge(conv, d, p, 120, 61);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_7_4, conv, cB + 4);
+
+ memcpy(cB + 200, d + 120, 28);
+
+ break;
+ case 3: /* TCH/AHS6.7 */
+ if (len != 17)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 134);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 55, p);
+
+ tch_amr_merge(conv, d, p, 110, 55);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_6_7, conv, cB + 4);
+
+ memcpy(cB + 204, d + 110, 24);
+
+ break;
+ case 2: /* TCH/AHS5.9 */
+ if (len != 15)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 118);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 55, p);
+
+ tch_amr_merge(conv, d, p, 102, 55);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_5_9, conv, cB + 4);
+
+ memcpy(cB + 212, d + 102, 16);
+
+ break;
+ case 1: /* TCH/AHS5.15 */
+ if (len != 13)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 103);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 49, p);
+
+ tch_amr_merge(conv, d, p, 91, 49);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_5_15, conv, cB + 4);
+
+ memcpy(cB + 216, d + 91, 12);
+
+ break;
+ case 0: /* TCH/AHS4.75 */
+ if (len != 12)
+ goto invalid_length;
+
+ tch_amr_disassemble(d, tch_data, 95);
+
+ osmo_crc8gen_set_bits(&gsm0503_amr_crc6, d, 39, p);
+
+ tch_amr_merge(conv, d, p, 83, 39);
+
+ osmo_conv_encode(&gsm0503_tch_ahs_4_75, conv, cB + 4);
+
+ memcpy(cB + 216, d + 83, 12);
+
+ break;
+ default:
+ /* FIXME: FT %ft is not supported */
+ return -1;
+ }
+
+ memcpy(cB, gsm0503_afs_ic_ubit[id], 4);
+
+ gsm0503_tch_hr_interleave(cB, iB);
+
+ for (i = 0; i < 4; i++)
+ gsm0503_tch_burst_map(&iB[i * 114], &bursts[i * 116], &h, i >> 1);
+
+ return 0;
+
+invalid_length:
+ /* FIXME: payload length %len does not comply with codec type %ft */
+ return -1;
+}
+
+/*
+ * GSM RACH transcoding
+ */
+
+/*
+ * GSM RACH apply BSIC to parity
+ *
+ * p(j) = p(j) xor b(j) j = 0, ..., 5
+ * b(0) = MSB of PLMN colour code
+ * b(5) = LSB of BS colour code
+ */
+static int rach_apply_bsic(ubit_t *d, uint8_t bsic)
+{
+ int i;
+
+ /* Apply it */
+ for (i = 0; i < 6; i++)
+ d[8 + i] ^= ((bsic >> (5 - i)) & 1);
+
+ return 0;
+}
+
+int gsm0503_rach_decode(uint8_t *ra, sbit_t *burst, uint8_t bsic)
+{
+ ubit_t conv[14];
+ int rv;
+
+ osmo_conv_decode(&gsm0503_rach, burst, conv);
+
+ rach_apply_bsic(conv, bsic);
+
+ rv = osmo_crc8gen_check_bits(&gsm0503_rach_crc6, conv, 8, conv + 8);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(ra, 0, conv, 0, 8, 1);
+
+ return 0;
+}
+
+int gsm0503_rach_encode(ubit_t *burst, uint8_t *ra, uint8_t bsic)
+{
+ ubit_t conv[14];
+
+ osmo_pbit2ubit_ext(conv, 0, ra, 0, 8, 1);
+
+ osmo_crc8gen_set_bits(&gsm0503_rach_crc6, conv, 8, conv + 8);
+
+ rach_apply_bsic(conv, bsic);
+
+ osmo_conv_encode(&gsm0503_rach, conv, burst);
+
+ return 0;
+}
+
+/*
+ * GSM SCH transcoding
+ */
+int gsm0503_sch_decode(uint8_t *sb_info, sbit_t *burst)
+{
+ ubit_t conv[35];
+ int rv;
+
+ osmo_conv_decode(&gsm0503_sch, burst, conv);
+
+ rv = osmo_crc16gen_check_bits(&gsm0503_sch_crc10, conv, 25, conv + 25);
+ if (rv)
+ return -1;
+
+ osmo_ubit2pbit_ext(sb_info, 0, conv, 0, 25, 1);
+
+ return 0;
+}
+
+int gsm0503_sch_encode(ubit_t *burst, uint8_t *sb_info)
+{
+ ubit_t conv[35];
+
+ osmo_pbit2ubit_ext(conv, 0, sb_info, 0, 25, 1);
+
+ osmo_crc16gen_set_bits(&gsm0503_sch_crc10, conv, 25, conv + 25);
+
+ osmo_conv_encode(&gsm0503_sch, conv, burst);
+
+ return 0;
+}
diff --git a/src/coding/gsm0503_interleaving.c b/src/coding/gsm0503_interleaving.c
new file mode 100644
index 00000000..22ad6f69
--- /dev/null
+++ b/src/coding/gsm0503_interleaving.c
@@ -0,0 +1,573 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2016 by Tom Tsou <tom.tsou@ettus.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.
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/coding/gsm0503_tables.h>
+#include <osmocom/coding/gsm0503_interleaving.h>
+
+/*
+ * GSM xCCH interleaving and burst mapping
+ *
+ * Interleaving:
+ *
+ * Given 456 coded input bits, form 4 blocks of 114 bits:
+ *
+ * i(B, j) = c(n, k) k = 0, ..., 455
+ * n = 0, ..., N, N + 1, ...
+ * B = B_0 + 4n + (k mod 4)
+ * j = 2(49k mod 57) + ((k mod 8) div 4)
+ *
+ * Mapping on Burst:
+ *
+ * e(B, j) = i(B, j)
+ * e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
+ * e(B, 57) = h_l(B)
+ * e(B, 58) = h_n(B)
+ *
+ * Where hl(B) and hn(B) are bits in burst B indicating flags.
+ */
+
+void gsm0503_xcch_deinterleave(sbit_t *cB, const sbit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 456; k++) {
+ B = k & 3;
+ j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
+ cB[k] = iB[B * 114 + j];
+ }
+}
+
+void gsm0503_xcch_interleave(ubit_t *cB, ubit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 456; k++) {
+ B = k & 3;
+ j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
+ iB[B * 114 + j] = cB[k];
+ }
+}
+
+void gsm0503_mcs1_dl_deinterleave(sbit_t *u, sbit_t *hc,
+ sbit_t *dc, const sbit_t *iB)
+{
+ int k;
+ sbit_t c[452];
+ sbit_t cp[456];
+
+ gsm0503_xcch_deinterleave(cp, iB);
+
+ for (k = 0; k < 25; k++)
+ c[k] = cp[k];
+ for (k = 26; k < 82; k++)
+ c[k - 1] = cp[k];
+ for (k = 83; k < 139; k++)
+ c[k - 2] = cp[k];
+ for (k = 140; k < 424; k++)
+ c[k - 3] = cp[k];
+ for (k = 425; k < 456; k++)
+ c[k - 4] = cp[k];
+
+ if (u) {
+ for (k = 0; k < 12; k++)
+ u[k] = c[k];
+ }
+
+ if (hc) {
+ for (k = 12; k < 80; k++)
+ hc[k - 12] = c[k];
+ }
+
+ if (dc) {
+ for (k = 80; k < 452; k++)
+ dc[k - 80] = c[k];
+ }
+}
+
+void gsm0503_mcs1_dl_interleave(const ubit_t *up, const ubit_t *hc,
+ const ubit_t *dc, ubit_t *iB)
+{
+ int k;
+ ubit_t c[452];
+ ubit_t cp[456];
+
+ for (k = 0; k < 12; k++)
+ c[k] = up[k];
+ for (k = 12; k < 80; k++)
+ c[k] = hc[k - 12];
+ for (k = 80; k < 452; k++)
+ c[k] = dc[k - 80];
+
+ for (k = 0; k < 25; k++)
+ cp[k] = c[k];
+ for (k = 26; k < 82; k++)
+ cp[k] = c[k - 1];
+ for (k = 83; k < 139; k++)
+ cp[k] = c[k - 2];
+ for (k = 140; k < 424; k++)
+ cp[k] = c[k - 3];
+ for (k = 425; k < 456; k++)
+ cp[k] = c[k - 4];
+
+ cp[25] = 0;
+ cp[82] = 0;
+ cp[139] = 0;
+ cp[424] = 0;
+
+ gsm0503_xcch_interleave(cp, iB);
+}
+
+void gsm0503_mcs1_ul_deinterleave(sbit_t *hc, sbit_t *dc, const sbit_t *iB)
+{
+ int k;
+ sbit_t c[452];
+ sbit_t cp[456];
+
+ gsm0503_xcch_deinterleave(cp, iB);
+
+ for (k = 0; k < 25; k++)
+ c[k] = cp[k];
+ for (k = 26; k < 82; k++)
+ c[k - 1] = cp[k];
+ for (k = 83; k < 139; k++)
+ c[k - 2] = cp[k];
+ for (k = 140; k < 424; k++)
+ c[k - 3] = cp[k];
+ for (k = 425; k < 456; k++)
+ c[k - 4] = cp[k];
+
+ if (hc) {
+ for (k = 0; k < 80; k++)
+ hc[k] = c[k];
+ }
+
+ if (dc) {
+ for (k = 80; k < 452; k++)
+ dc[k - 80] = c[k];
+ }
+}
+
+void gsm0503_mcs1_ul_interleave(const ubit_t *hc, const ubit_t *dc, ubit_t *iB)
+{
+ int k;
+ ubit_t c[452];
+ ubit_t cp[456];
+
+ for (k = 0; k < 80; k++)
+ c[k] = hc[k];
+ for (k = 80; k < 452; k++)
+ c[k] = dc[k - 80];
+
+ for (k = 0; k < 25; k++)
+ cp[k] = c[k];
+ for (k = 26; k < 82; k++)
+ cp[k] = c[k - 1];
+ for (k = 83; k < 139; k++)
+ cp[k] = c[k - 2];
+ for (k = 140; k < 424; k++)
+ cp[k] = c[k - 3];
+ for (k = 425; k < 456; k++)
+ cp[k] = c[k - 4];
+
+ cp[25] = 0;
+ cp[82] = 0;
+ cp[139] = 0;
+ cp[424] = 0;
+
+ gsm0503_xcch_interleave(cp, iB);
+}
+
+void gsm0503_mcs5_ul_interleave(const ubit_t *hc, const ubit_t *dc,
+ ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+
+ /* Header */
+ for (k = 0; k < 136; k++) {
+ j = 34 * (k % 4) + 2 * (11 * k % 17) + k % 8 / 4;
+ hi[j] = hc[k];
+ }
+
+ /* Data */
+ for (k = 0; k < 1248; k++) {
+ j = gsm0503_interleave_mcs5[k];
+ di[j] = dc[k];
+ }
+}
+
+void gsm0503_mcs5_ul_deinterleave(sbit_t *hc, sbit_t *dc,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 136; k++) {
+ j = 34 * (k % 4) + 2 * (11 * k % 17) + k % 8 / 4;
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (dc) {
+ for (k = 0; k < 1248; k++) {
+ j = gsm0503_interleave_mcs5[k];
+ dc[k] = di[j];
+ }
+ }
+}
+
+void gsm0503_mcs5_dl_interleave(const ubit_t *hc, const ubit_t *dc,
+ ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+
+ /* Header */
+ for (k = 0; k < 100; k++) {
+ j = 25 * (k % 4) + ((17 * k) % 25);
+ hi[j] = hc[k];
+ }
+
+ /* Data */
+ for (k = 0; k < 1248; k++) {
+ j = gsm0503_interleave_mcs5[k];
+ di[j] = dc[k];
+ }
+}
+
+void gsm0503_mcs5_dl_deinterleave(sbit_t *hc, sbit_t *dc,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 100; k++) {
+ j = 25 * (k % 4) + ((17 * k) % 25);
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (dc) {
+ for (k = 0; k < 1248; k++) {
+ j = gsm0503_interleave_mcs5[k];
+ dc[k] = di[j];
+ }
+ }
+}
+
+void gsm0503_mcs7_dl_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ for (k = 0; k < 124; k++) {
+ j = 31 * (k % 4) + ((17 * k) % 31);
+ hi[j] = hc[k];
+ }
+
+ memcpy(&dc[0], c1, 612);
+ memcpy(&dc[612], c2, 612);
+
+ /* Data */
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
+ (k + 2 - k / 408) % 3;
+ di[j] = dc[k];
+ }
+}
+
+
+void gsm0503_mcs7_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 124; k++) {
+ j = 31 * (k % 4) + ((17 * k) % 31);
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (c1 && c2) {
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
+ (k + 2 - k / 408) % 3;
+ dc[k] = di[j];
+ }
+
+ memcpy(c1, &dc[0], 612);
+ memcpy(c2, &dc[612], 612);
+ }
+}
+
+void gsm0503_mcs7_ul_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ for (k = 0; k < 160; k++) {
+ j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
+ hi[j] = hc[k];
+ }
+
+ memcpy(&dc[0], c1, 612);
+ memcpy(&dc[612], c2, 612);
+
+ /* Data */
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
+ (k + 2 - k / 408) % 3;
+ di[j] = dc[k];
+ }
+}
+
+void gsm0503_mcs7_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 160; k++) {
+ j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (c1 && c2) {
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (k % 4) + 3 * (44 * k % 102 + k / 4 % 2) +
+ (k + 2 - k / 408) % 3;
+ dc[k] = di[j];
+ }
+
+ memcpy(c1, &dc[0], 612);
+ memcpy(c2, &dc[612], 612);
+ }
+}
+
+void gsm0503_mcs8_ul_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ for (k = 0; k < 160; k++) {
+ j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
+ hi[j] = hc[k];
+ }
+
+ memcpy(&dc[0], c1, 612);
+ memcpy(&dc[612], c2, 612);
+
+ /* Data */
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (2 * (k / 612) + (k % 2)) +
+ 3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
+ di[j] = dc[k];
+ }
+}
+
+void gsm0503_mcs8_ul_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 160; k++) {
+ j = 40 * (k % 4) + 2 * (13 * (k / 8) % 20) + k % 8 / 4;
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (c1 && c2) {
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (2 * (k / 612) + (k % 2)) +
+ 3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
+ dc[k] = di[j];
+ }
+
+ memcpy(c1, &dc[0], 612);
+ memcpy(c2, &dc[612], 612);
+ }
+}
+
+void gsm0503_mcs8_dl_interleave(const ubit_t *hc, const ubit_t *c1,
+ const ubit_t *c2, ubit_t *hi, ubit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ for (k = 0; k < 124; k++) {
+ j = 31 * (k % 4) + ((17 * k) % 31);
+ hi[j] = hc[k];
+ }
+
+ memcpy(&dc[0], c1, 612);
+ memcpy(&dc[612], c2, 612);
+
+ /* Data */
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (2 * (k / 612) + (k % 2)) +
+ 3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
+ di[j] = dc[k];
+ }
+}
+
+void gsm0503_mcs8_dl_deinterleave(sbit_t *hc, sbit_t *c1, sbit_t *c2,
+ const sbit_t *hi, const sbit_t *di)
+{
+ int j, k;
+ ubit_t dc[1224];
+
+ /* Header */
+ if (hc) {
+ for (k = 0; k < 124; k++) {
+ j = 31 * (k % 4) + ((17 * k) % 31);
+ hc[k] = hi[j];
+ }
+ }
+
+ /* Data */
+ if (c1 && c2) {
+ for (k = 0; k < 1224; k++) {
+ j = 306 * (2 * (k / 612) + (k % 2)) +
+ 3 * (74 * k % 102 + k / 2 % 2) + (k + 2 - k / 204) % 3;
+ dc[k] = di[j];
+ }
+
+ memcpy(c1, &dc[0], 612);
+ memcpy(c2, &dc[612], 612);
+ }
+}
+
+/*
+ * GSM TCH FR/EFR/AFS interleaving and burst mapping
+ *
+ * Interleaving:
+ *
+ * Given 456 coded input bits, form 8 blocks of 114 bits,
+ * where even bits of the first 4 blocks and odd bits of the last 4 blocks
+ * are used:
+ *
+ * i(B, j) = c(n, k) k = 0, ..., 455
+ * n = 0, ..., N, N + 1, ...
+ * B = B_0 + 4n + (k mod 8)
+ * j = 2(49k mod 57) + ((k mod 8) div 4)
+ *
+ * Mapping on Burst:
+ *
+ * e(B, j) = i(B, j)
+ * e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
+ * e(B, 57) = h_l(B)
+ * e(B, 58) = h_n(B)
+ *
+ * Where hl(B) and hn(B) are bits in burst B indicating flags.
+ */
+
+void gsm0503_tch_fr_deinterleave(sbit_t *cB, sbit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 456; k++) {
+ B = k & 7;
+ j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
+ cB[k] = iB[B * 114 + j];
+ }
+}
+
+void gsm0503_tch_fr_interleave(ubit_t *cB, ubit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 456; k++) {
+ B = k & 7;
+ j = 2 * ((49 * k) % 57) + ((k & 7) >> 2);
+ iB[B * 114 + j] = cB[k];
+ }
+}
+
+/*
+ * GSM TCH HR/AHS interleaving and burst mapping
+ *
+ * Interleaving:
+ *
+ * Given 288 coded input bits, form 4 blocks of 114 bits,
+ * where even bits of the first 2 blocks and odd bits of the last 2 blocks
+ * are used:
+ *
+ * i(B, j) = c(n, k) k = 0, ..., 227
+ * n = 0, ..., N, N + 1, ...
+ * B = B_0 + 2n + b
+ * j, b = table[k];
+ *
+ * Mapping on Burst:
+ *
+ * e(B, j) = i(B, j)
+ * e(B, 59 + j) = i(B, 57 + j) j = 0, ..., 56
+ * e(B, 57) = h_l(B)
+ * e(B, 58) = h_n(B)
+ *
+ * Where hl(B) and hn(B) are bits in burst B indicating flags.
+ */
+
+void gsm0503_tch_hr_deinterleave(sbit_t *cB, sbit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 228; k++) {
+ B = gsm0503_tch_hr_interleaving[k][1];
+ j = gsm0503_tch_hr_interleaving[k][0];
+ cB[k] = iB[B * 114 + j];
+ }
+}
+
+void gsm0503_tch_hr_interleave(ubit_t *cB, ubit_t *iB)
+{
+ int j, k, B;
+
+ for (k = 0; k < 228; k++) {
+ B = gsm0503_tch_hr_interleaving[k][1];
+ j = gsm0503_tch_hr_interleaving[k][0];
+ iB[B * 114 + j] = cB[k];
+ }
+}
diff --git a/src/coding/gsm0503_mapping.c b/src/coding/gsm0503_mapping.c
new file mode 100644
index 00000000..366eeb45
--- /dev/null
+++ b/src/coding/gsm0503_mapping.c
@@ -0,0 +1,291 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2016 by Tom Tsou <tom.tsou@ettus.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.
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/coding/gsm0503_mapping.h>
+
+void gsm0503_xcch_burst_unmap(sbit_t *iB, const sbit_t *eB,
+ sbit_t *hl, sbit_t *hn)
+{
+ memcpy(iB, eB, 57);
+ memcpy(iB + 57, eB + 59, 57);
+
+ if (hl)
+ *hl = eB[57];
+
+ if (hn)
+ *hn = eB[58];
+}
+
+void gsm0503_xcch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *hl,
+ const ubit_t *hn)
+{
+ memcpy(eB, iB, 57);
+ memcpy(eB + 59, iB + 57, 57);
+
+ if (hl)
+ eB[57] = *hl;
+ if (hn)
+ eB[58] = *hn;
+}
+
+void gsm0503_tch_burst_unmap(sbit_t *iB, sbit_t *eB, sbit_t *h, int odd)
+{
+ int i;
+
+ /* brainfuck: only copy even or odd bits */
+ if (iB) {
+ for (i = odd; i < 57; i += 2)
+ iB[i] = eB[i];
+ for (i = 58 - odd; i < 114; i += 2)
+ iB[i] = eB[i + 2];
+ }
+
+ if (h) {
+ if (!odd)
+ *h = eB[58];
+ else
+ *h = eB[57];
+ }
+}
+
+void gsm0503_tch_burst_map(ubit_t *iB, ubit_t *eB, const ubit_t *h, int odd)
+{
+ int i;
+
+ /* brainfuck: only copy even or odd bits */
+ if (eB) {
+ for (i = odd; i < 57; i += 2)
+ eB[i] = iB[i];
+ for (i = 58 - odd; i < 114; i += 2)
+ eB[i + 2] = iB[i];
+ }
+
+ if (h) {
+ if (!odd)
+ eB[58] = *h;
+ else
+ eB[57] = *h;
+ }
+}
+
+void gsm0503_mcs5_dl_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, const ubit_t *up, int B)
+{
+ int j;
+ int q[8] = { 0, 0, 0, 0, 0, 0, 0, 0, };
+
+ for (j = 0; j < 156; j++)
+ eB[j] = di[312 * B + j];
+ for (j = 156; j < 168; j++)
+ eB[j] = hi[25 * B + j - 156];
+ for (j = 168; j < 174; j++)
+ eB[j] = up[9 * B + j - 168];
+ for (j = 174; j < 176; j++)
+ eB[j] = q[2 * B + j - 174];
+ for (j = 176; j < 179; j++)
+ eB[j] = up[9 * B + j - 170];
+ for (j = 179; j < 192; j++)
+ eB[j] = hi[25 * B + j - 167];
+ for (j = 192; j < 348; j++)
+ eB[j] = di[312 * B + j - 36];
+}
+
+void gsm0503_mcs5_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, sbit_t *up, int B)
+{
+ int j;
+
+ for (j = 0; j < 156; j++)
+ di[312 * B + j] = eB[j];
+ for (j = 156; j < 168; j++)
+ hi[25 * B + j - 156] = eB[j];
+ for (j = 168; j < 174; j++)
+ up[9 * B + j - 168] = eB[j];
+
+ for (j = 176; j < 179; j++)
+ up[9 * B + j - 170] = eB[j];
+ for (j = 179; j < 192; j++)
+ hi[25 * B + j - 167] = eB[j];
+ for (j = 192; j < 348; j++)
+ di[312 * B + j - 36] = eB[j];
+}
+
+void gsm0503_mcs5_ul_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, int B)
+{
+ int j;
+
+ for (j = 0; j < 156; j++)
+ eB[j] = di[312 * B + j];
+ for (j = 156; j < 174; j++)
+ eB[j] = hi[34 * B + j - 156];
+ for (j = 174; j < 176; j++)
+ eB[j] = 0;
+ for (j = 176; j < 192; j++)
+ eB[j] = hi[34 * B + j - 158];
+ for (j = 192; j < 348; j++)
+ eB[j] = di[312 * B + j - 36];
+}
+
+void gsm0503_mcs5_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, int B)
+{
+ int j;
+
+ for (j = 0; j < 156; j++)
+ di[312 * B + j] = eB[j];
+ for (j = 156; j < 174; j++)
+ hi[34 * B + j - 156] = eB[j];
+ for (j = 176; j < 192; j++)
+ hi[34 * B + j - 158] = eB[j];
+ for (j = 192; j < 348; j++)
+ di[312 * B + j - 36] = eB[j];
+}
+
+void gsm0503_mcs7_dl_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, const ubit_t *up, int B)
+{
+ int j;
+ int q[8] = { 1, 1, 1, 0, 0, 1, 1, 1, };
+
+ for (j = 0; j < 153; j++)
+ eB[j] = di[306 * B + j];
+ for (j = 153; j < 168; j++)
+ eB[j] = hi[31 * B + j - 153];
+ for (j = 168; j < 174; j++)
+ eB[j] = up[9 * B + j - 168];
+ for (j = 174; j < 176; j++)
+ eB[j] = q[2 * B + j - 174];
+ for (j = 176; j < 179; j++)
+ eB[j] = up[9 * B + j - 170];
+ for (j = 179; j < 195; j++)
+ eB[j] = hi[31 * B + j - 164];
+ for (j = 195; j < 348; j++)
+ eB[j] = di[306 * B + j - 42];
+}
+
+void gsm0503_mcs7_dl_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, sbit_t *up, int B)
+{
+ int j;
+
+ for (j = 0; j < 153; j++)
+ di[306 * B + j] = eB[j];
+ for (j = 153; j < 168; j++)
+ hi[31 * B + j - 153] = eB[j];
+ for (j = 168; j < 174; j++)
+ up[9 * B + j - 168] = eB[j];
+
+ for (j = 176; j < 179; j++)
+ up[9 * B + j - 170] = eB[j];
+ for (j = 179; j < 195; j++)
+ hi[31 * B + j - 164] = eB[j];
+ for (j = 195; j < 348; j++)
+ di[306 * B + j - 42] = eB[j];
+}
+
+void gsm0503_mcs7_ul_burst_map(const ubit_t *di, ubit_t *eB,
+ const ubit_t *hi, int B)
+{
+ int j;
+ int q[8] = { 1, 1, 1, 0, 0, 1, 1, 1, };
+
+ for (j = 0; j < 153; j++)
+ eB[j] = di[306 * B + j];
+ for (j = 153; j < 174; j++)
+ eB[j] = hi[40 * B + j - 153];
+ for (j = 174; j < 176; j++)
+ eB[j] = q[2 * B + j - 174];
+ for (j = 176; j < 195; j++)
+ eB[j] = hi[40 * B + j - 155];
+ for (j = 195; j < 348; j++)
+ eB[j] = di[306 * B + j - 42];
+}
+
+void gsm0503_mcs7_ul_burst_unmap(sbit_t *di, const sbit_t *eB,
+ sbit_t *hi, int B)
+{
+ int j;
+
+ for (j = 0; j < 153; j++)
+ di[306 * B + j] = eB[j];
+ for (j = 153; j < 174; j++)
+ hi[40 * B + j - 153] = eB[j];
+
+ for (j = 176; j < 195; j++)
+ hi[40 * B + j - 155] = eB[j];
+ for (j = 195; j < 348; j++)
+ di[306 * B + j - 42] = eB[j];
+}
+
+void gsm0503_mcs5_burst_swap(sbit_t *eB)
+{
+ sbit_t t[14];
+
+ t[0] = eB[155];
+ t[1] = eB[158];
+ t[2] = eB[161];
+ t[3] = eB[164];
+ t[4] = eB[167];
+ t[5] = eB[170];
+ t[6] = eB[173];
+ t[7] = eB[195];
+ t[8] = eB[196];
+ t[9] = eB[198];
+ t[10] = eB[199];
+ t[11] = eB[201];
+ t[12] = eB[202];
+ t[13] = eB[204];
+
+ eB[155] = eB[142];
+ eB[158] = eB[144];
+ eB[161] = eB[145];
+ eB[164] = eB[147];
+ eB[167] = eB[148];
+ eB[170] = eB[150];
+ eB[173] = eB[151];
+ eB[195] = eB[176];
+ eB[196] = eB[179];
+ eB[198] = eB[182];
+ eB[199] = eB[185];
+ eB[201] = eB[188];
+ eB[202] = eB[191];
+ eB[204] = eB[194];
+
+ eB[142] = t[0];
+ eB[144] = t[1];
+ eB[145] = t[2];
+ eB[147] = t[3];
+ eB[148] = t[4];
+ eB[150] = t[5];
+ eB[151] = t[6];
+ eB[176] = t[7];
+ eB[179] = t[8];
+ eB[182] = t[9];
+ eB[185] = t[10];
+ eB[188] = t[11];
+ eB[191] = t[12];
+ eB[194] = t[13];
+}
diff --git a/src/coding/gsm0503_parity.c b/src/coding/gsm0503_parity.c
new file mode 100644
index 00000000..99198ba8
--- /dev/null
+++ b/src/coding/gsm0503_parity.c
@@ -0,0 +1,132 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2016 by Tom Tsou <tom.tsou@ettus.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.
+ */
+
+#include <stdint.h>
+
+#include <osmocom/core/crcgen.h>
+#include <osmocom/coding/gsm0503_parity.h>
+
+/*
+ * GSM (SACCH) parity (FIRE code)
+ *
+ * g(x) = (x^23 + 1)(x^17 + x^3 + 1)
+ * = x^40 + x^26 + x^23 + x^17 + x^3 + a1
+ */
+const struct osmo_crc64gen_code gsm0503_fire_crc40 = {
+ .bits = 40,
+ .poly = 0x0004820009ULL,
+ .init = 0x0000000000ULL,
+ .remainder = 0xffffffffffULL,
+};
+
+/*
+ * GSM PDTCH CS-2, CS-3, CS-4 parity
+ *
+ * g(x) = x^16 + x^12 + x^5 + 1
+ */
+const struct osmo_crc16gen_code gsm0503_cs234_crc16 = {
+ .bits = 16,
+ .poly = 0x1021,
+ .init = 0x0000,
+ .remainder = 0xffff,
+};
+
+/*
+ * EDGE MCS header parity
+ *
+ */
+const struct osmo_crc8gen_code gsm0503_mcs_crc8_hdr = {
+ .bits = 8,
+ .poly = 0x49,
+ .init = 0x00,
+ .remainder = 0xff,
+};
+
+/*
+ * EDGE MCS data parity
+ *
+ */
+const struct osmo_crc16gen_code gsm0503_mcs_crc12 = {
+ .bits = 12,
+ .poly = 0x0d31,
+ .init = 0x0000,
+ .remainder = 0x0fff,
+};
+
+/*
+ * GSM RACH parity
+ *
+ * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
+ */
+const struct osmo_crc8gen_code gsm0503_rach_crc6 = {
+ .bits = 6,
+ .poly = 0x2f,
+ .init = 0x00,
+ .remainder = 0x3f,
+};
+
+/*
+ * GSM SCH parity
+ *
+ * g(x) = x^10 + x^8 + x^6 + x^5 + x^4 + x^2 + 1
+ */
+const struct osmo_crc16gen_code gsm0503_sch_crc10 = {
+ .bits = 10,
+ .poly = 0x175,
+ .init = 0x000,
+ .remainder = 0x3ff,
+};
+
+/*
+ * GSM TCH FR/HR/EFR parity
+ *
+ * g(x) = x^3 + x + 1
+ */
+const struct osmo_crc8gen_code gsm0503_tch_fr_crc3 = {
+ .bits = 3,
+ .poly = 0x3,
+ .init = 0x0,
+ .remainder = 0x7,
+};
+
+/*
+ * GSM TCH EFR parity
+ *
+ * g(x) = x^8 + x^4 + x^3 + x^2 + 1
+ */
+const struct osmo_crc8gen_code gsm0503_tch_efr_crc8 = {
+ .bits = 8,
+ .poly = 0x1d,
+ .init = 0x00,
+ .remainder = 0x00,
+};
+
+/*
+ * GSM AMR parity
+ *
+ * g(x) = x^6 + x^5 + x^3 + x^2 + x^1 + 1
+ */
+const struct osmo_crc8gen_code gsm0503_amr_crc6 = {
+ .bits = 6,
+ .poly = 0x2f,
+ .init = 0x00,
+ .remainder = 0x3f,
+};
diff --git a/src/coding/gsm0503_tables.c b/src/coding/gsm0503_tables.c
new file mode 100644
index 00000000..90ca88d8
--- /dev/null
+++ b/src/coding/gsm0503_tables.c
@@ -0,0 +1,1732 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2016 by Tom Tsou <tom.tsou@ettus.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.
+ */
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/coding/gsm0503_tables.h>
+
+const ubit_t gsm0503_pdtch_hl_hn_ubit[4][8] = {
+ { 1,1, 1,1, 1,1, 1,1 },
+ { 1,1, 0,0, 1,0, 0,0 },
+ { 0,0, 1,0, 0,0, 0,1 },
+ { 0,0, 0,1, 0,1, 1,0 },
+};
+
+const ubit_t gsm0503_pdtch_edge_hl_hn_ubit[3][8] = {
+ { 0,0, 0,1, 0,1, 1,0 },
+ { 0,0, 0,0, 0,0, 0,0 },
+ { 1,1, 1,0, 0,1, 1,1 },
+};
+
+const sbit_t gsm0503_pdtch_hl_hn_sbit[4][8] = {
+ { -127,-127, -127,-127, -127,-127, -127,-127 },
+ { -127,-127, 127, 127, -127, 127, 127, 127 },
+ { 127, 127, -127, 127, 127, 127, 127,-127 },
+ { 127, 127, 127,-127, 127,-127, -127, 127 },
+};
+
+const sbit_t gsm0503_pdtch_edge_hl_hn_sbit[3][8] = {
+ { 127, 127, 127,-127, 127,-127, -127, 127 },
+ { 127, 127, 127, 127, 127, 127, 127, 127 },
+ { -127,-127, -127, 127, 127,-127, -127,-127 },
+};
+
+const ubit_t gsm0503_usf2six[8][6] = {
+ { 0,0,0, 0,0,0 },
+ { 1,0,0, 1,0,1 },
+ { 0,1,0, 1,1,0 },
+ { 1,1,0, 0,1,1 },
+ { 0,0,1, 0,1,1 },
+ { 1,0,1, 1,1,0 },
+ { 0,1,1, 1,0,1 },
+ { 1,1,1, 0,0,0 },
+};
+
+const ubit_t gsm0503_usf2twelve_ubit[8][12] = {
+ { 0,0,0, 0,0,0, 0,0,0, 0,0,0 },
+ { 1,1,0, 1,0,0, 0,0,1, 0,1,1 },
+ { 0,0,1, 1,0,1, 1,1,0, 1,1,0 },
+ { 1,1,1, 0,0,1, 1,1,1, 1,0,1 },
+ { 0,0,0, 0,1,1, 0,1,1, 1,0,1 },
+ { 1,1,0, 1,1,1, 0,1,0, 1,1,0 },
+ { 0,0,1, 1,1,0, 1,0,1, 0,1,1 },
+ { 1,1,1, 0,1,0, 1,0,0, 0,0,0 },
+};
+
+const sbit_t gsm0503_usf2twelve_sbit[8][12] = {
+ { 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127 },
+ { -127,-127, 127, -127, 127, 127, 127, 127,-127, 127,-127,-127 },
+ { 127, 127,-127, -127, 127,-127, -127,-127, 127, -127,-127, 127 },
+ { -127,-127,-127, 127, 127,-127, -127,-127,-127, -127, 127,-127 },
+ { 127, 127, 127, 127,-127,-127, 127,-127,-127, -127, 127,-127 },
+ { -127,-127, 127, -127,-127,-127, 127,-127, 127, -127,-127, 127 },
+ { 127, 127,-127, -127,-127, 127, -127, 127,-127, 127,-127,-127 },
+ { -127,-127,-127, 127,-127, 127, -127, 127, 127, 127, 127, 127 },
+};
+
+const uint8_t gsm0503_puncture_cs2[588] = {
+ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1,
+ 0,0,0,1, 0,0,0,0, 0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1,
+ 0,0,0,1, 0,0,0,1, 0,0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
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+ 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0, 1,1,0,
+};
+
+const uint16_t gsm0503_interleave_mcs5[1248] = {
+ 0, 463, 890, 1038, 220, 371, 795, 946, 582, 733, 1160, 63, 490, 641, 277, 428,
+ 852, 1003, 185, 333, 1223, 120, 547, 698, 1122, 28, 915, 1066, 242, 390, 817, 968,
+ 610, 761, 1185, 85, 512, 660, 305, 453, 880, 1031, 204, 355, 782, 1242, 148, 575,
+ 723, 1150, 50, 474, 625, 1088, 267, 418, 845, 993, 169, 320, 1207, 113, 537, 688,
+ 1115, 12, 902, 1050, 232, 383, 807, 958, 594, 745, 1172, 75, 502, 653, 289, 440,
+ 864, 1015, 197, 345, 1235, 132, 559, 710, 1134, 40, 927, 1078, 254, 402, 829, 980,
+ 159, 622, 773, 1197, 97, 524, 672, 1099, 5, 465, 892, 1043, 216, 367, 794, 942,
+ 587, 735, 1162, 62, 486, 637, 279, 430, 857, 1005, 181, 332, 1219, 125, 549, 700,
+ 1127, 24, 914, 1062, 244, 395, 819, 970, 606, 757, 1184, 87, 514, 665, 301, 452,
+ 876, 1027, 209, 357, 784, 1247, 144, 571, 722, 1146, 52, 479, 627, 1090, 266, 414,
+ 841, 992, 171, 322, 1209, 109, 536, 684, 1111, 17, 904, 1055, 228, 379, 806, 954,
+ 599, 747, 1174, 74, 498, 649, 291, 442, 869, 1017, 193, 344, 1231, 137, 561, 712,
+ 1139, 36, 926, 1074, 256, 407, 831, 982, 158, 618, 769, 1196, 99, 526, 677, 1101,
+ 7, 458, 894, 1033, 227, 363, 802, 941, 577, 740, 1152, 70, 485, 645, 284, 420,
+ 859, 998, 189, 328, 1215, 127, 542, 702, 1117, 35, 922, 1061, 246, 385, 824, 960,
+ 605, 765, 1180, 92, 504, 667, 309, 448, 887, 1023, 211, 350, 786, 1237, 155, 567,
+ 730, 1145, 54, 469, 632, 1080, 274, 413, 849, 988, 176, 312, 1202, 117, 532, 695,
+ 1107, 19, 906, 1045, 239, 375, 814, 953, 589, 752, 1164, 82, 497, 657, 296, 432,
+ 871, 1010, 201, 340, 1227, 139, 554, 714, 1129, 47, 934, 1073, 258, 397, 836, 972,
+ 166, 617, 777, 1192, 104, 516, 679, 1094, 9, 460, 899, 1035, 223, 362, 798, 937,
+ 579, 742, 1157, 66, 481, 644, 286, 425, 861, 1000, 188, 324, 1214, 129, 544, 707,
+ 1119, 31, 918, 1057, 251, 387, 826, 965, 601, 764, 1176, 94, 509, 669, 308, 444,
+ 883, 1022, 213, 352, 791, 1239, 151, 566, 726, 1141, 59, 471, 634, 1085, 270, 409,
+ 848, 984, 178, 317, 1204, 116, 528, 691, 1106, 21, 911, 1047, 235, 374, 810, 949,
+ 591, 754, 1169, 78, 493, 656, 298, 437, 873, 1012, 200, 336, 1226, 141, 556, 719,
+ 1131, 43, 930, 1069, 263, 399, 838, 977, 162, 613, 776, 1188, 106, 521, 681, 1096,
+ 2, 462, 889, 1040, 219, 370, 797, 945, 584, 732, 1159, 65, 489, 640, 276, 427,
+ 854, 1002, 184, 335, 1222, 122, 546, 697, 1124, 27, 917, 1065, 241, 392, 816, 967,
+ 609, 760, 1187, 84, 511, 662, 304, 455, 879, 1030, 206, 354, 781, 1244, 147, 574,
+ 725, 1149, 49, 476, 624, 1087, 269, 417, 844, 995, 168, 319, 1206, 112, 539, 687,
+ 1114, 14, 901, 1052, 231, 382, 809, 957, 596, 744, 1171, 77, 501, 652, 288, 439,
+ 866, 1014, 196, 347, 1234, 134, 558, 709, 1136, 39, 929, 1077, 253, 404, 828, 979,
+ 161, 621, 772, 1199, 96, 523, 674, 1098, 4, 467, 891, 1042, 218, 366, 793, 944,
+ 586, 737, 1161, 61, 488, 636, 281, 429, 856, 1007, 180, 331, 1218, 124, 551, 699,
+ 1126, 26, 913, 1064, 243, 394, 821, 969, 608, 756, 1183, 89, 513, 664, 300, 451,
+ 878, 1026, 208, 359, 783, 1246, 146, 570, 721, 1148, 51, 478, 629, 1089, 265, 416,
+ 840, 991, 173, 321, 1211, 108, 535, 686, 1110, 16, 903, 1054, 230, 378, 805, 956,
+ 598, 749, 1173, 73, 500, 648, 293, 441, 868, 1019, 192, 343, 1230, 136, 563, 711,
+ 1138, 38, 925, 1076, 255, 406, 833, 981, 157, 620, 768, 1195, 101, 525, 676, 1103,
+ 6, 457, 896, 1032, 226, 365, 801, 940, 576, 739, 1154, 69, 484, 647, 283, 422,
+ 858, 997, 191, 327, 1217, 126, 541, 704, 1116, 34, 921, 1060, 248, 384, 823, 962,
+ 604, 767, 1179, 91, 506, 666, 311, 447, 886, 1025, 210, 349, 788, 1236, 154, 569,
+ 729, 1144, 56, 468, 631, 1082, 273, 412, 851, 987, 175, 314, 1201, 119, 531, 694,
+ 1109, 18, 908, 1044, 238, 377, 813, 952, 588, 751, 1166, 81, 496, 659, 295, 434,
+ 870, 1009, 203, 339, 1229, 138, 553, 716, 1128, 46, 933, 1072, 260, 396, 835, 974,
+ 165, 616, 779, 1191, 103, 518, 678, 1093, 11, 459, 898, 1037, 222, 361, 800, 936,
+ 581, 741, 1156, 68, 480, 643, 285, 424, 863, 999, 187, 326, 1213, 131, 543, 706,
+ 1121, 30, 920, 1056, 250, 389, 825, 964, 600, 763, 1178, 93, 508, 671, 307, 446,
+ 882, 1021, 215, 351, 790, 1241, 150, 565, 728, 1140, 58, 473, 633, 1084, 272, 408,
+ 847, 986, 177, 316, 1203, 115, 530, 690, 1105, 23, 910, 1049, 234, 373, 812, 948,
+ 593, 753, 1168, 80, 492, 655, 297, 436, 875, 1011, 199, 338, 1225, 143, 555, 718,
+ 1133, 42, 932, 1068, 262, 401, 837, 976, 164, 612, 775, 1190, 105, 520, 683, 1095,
+ 1, 464, 888, 1039, 221, 369, 796, 947, 583, 734, 1158, 64, 491, 639, 278, 426,
+ 853, 1004, 183, 334, 1221, 121, 548, 696, 1123, 29, 916, 1067, 240, 391, 818, 966,
+ 611, 759, 1186, 86, 510, 661, 303, 454, 881, 1029, 205, 356, 780, 1243, 149, 573,
+ 724, 1151, 48, 475, 626, 1086, 268, 419, 843, 994, 170, 318, 1208, 111, 538, 689,
+ 1113, 13, 900, 1051, 233, 381, 808, 959, 595, 746, 1170, 76, 503, 651, 290, 438,
+ 865, 1016, 195, 346, 1233, 133, 560, 708, 1135, 41, 928, 1079, 252, 403, 830, 978,
+ 160, 623, 771, 1198, 98, 522, 673, 1100, 3, 466, 893, 1041, 217, 368, 792, 943,
+ 585, 736, 1163, 60, 487, 638, 280, 431, 855, 1006, 182, 330, 1220, 123, 550, 701,
+ 1125, 25, 912, 1063, 245, 393, 820, 971, 607, 758, 1182, 88, 515, 663, 302, 450,
+ 877, 1028, 207, 358, 785, 1245, 145, 572, 720, 1147, 53, 477, 628, 1091, 264, 415,
+ 842, 990, 172, 323, 1210, 110, 534, 685, 1112, 15, 905, 1053, 229, 380, 804, 955,
+ 597, 748, 1175, 72, 499, 650, 292, 443, 867, 1018, 194, 342, 1232, 135, 562, 713,
+ 1137, 37, 924, 1075, 257, 405, 832, 983, 156, 619, 770, 1194, 100, 527, 675, 1102,
+ 8, 456, 895, 1034, 225, 364, 803, 939, 578, 738, 1153, 71, 483, 646, 282, 421,
+ 860, 996, 190, 329, 1216, 128, 540, 703, 1118, 33, 923, 1059, 247, 386, 822, 961,
+ 603, 766, 1181, 90, 505, 668, 310, 449, 885, 1024, 212, 348, 787, 1238, 153, 568,
+ 731, 1143, 55, 470, 630, 1081, 275, 411, 850, 989, 174, 313, 1200, 118, 533, 693,
+ 1108, 20, 907, 1046, 237, 376, 815, 951, 590, 750, 1165, 83, 495, 658, 294, 433,
+ 872, 1008, 202, 341, 1228, 140, 552, 715, 1130, 45, 935, 1071, 259, 398, 834, 973,
+ 167, 615, 778, 1193, 102, 517, 680, 1092, 10, 461, 897, 1036, 224, 360, 799, 938,
+ 580, 743, 1155, 67, 482, 642, 287, 423, 862, 1001, 186, 325, 1212, 130, 545, 705,
+ 1120, 32, 919, 1058, 249, 388, 827, 963, 602, 762, 1177, 95, 507, 670, 306, 445,
+ 884, 1020, 214, 353, 789, 1240, 152, 564, 727, 1142, 57, 472, 635, 1083, 271, 410,
+ 846, 985, 179, 315, 1205, 114, 529, 692, 1104, 22, 909, 1048, 236, 372, 811, 950,
+ 592, 755, 1167, 79, 494, 654, 299, 435, 874, 1013, 198, 337, 1224, 142, 557, 717,
+ 1132, 44, 931, 1070, 261, 400, 839, 975, 163, 614, 774, 1189, 107, 519, 682, 1097,
+};
+
+/* this corresponds to the bit-lengths of the individual codec
+ * parameters as indicated in Table 1.1 of TS 06.10 */
+const uint8_t gsm0503_gsm_fr_map[76] = {
+ 6, 6, 5, 5, 4, 4, 3, 3, 7, 2, 2, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 7, 2, 2, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 2, 2, 6, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 2, 2, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3
+};
+
+/* this table describes the 65 most importaint bits from EFR coded
+ * bits as indicated in TS 05.03 (3.1.1.1) */
+const uint8_t gsm0503_gsm_efr_protected_bits[65] = {
+ 39, 40, 41, 42, 43, 44, 48, 87, 45, 2,
+ 3, 8, 10, 18, 19, 24, 46, 47,142,143,
+ 144,145,146,147, 92, 93,195,196, 98,137,
+ 148, 94,197,149,150, 95,198, 4, 5, 11,
+ 12, 16, 9, 6, 7, 13, 17, 20, 96,199,
+ 1, 14, 15, 21, 25, 26, 28,151,201,190,
+ 240, 88,138,191,241
+};
+
+/* Encoded in-band data for speech frames */
+const ubit_t gsm0503_afs_ic_ubit[4][8] = {
+ { 0,0,0,0,0,0,0,0 },
+ { 0,1,0,1,1,1,0,1 },
+ { 1,0,1,1,1,0,1,0 },
+ { 1,1,1,0,0,1,1,1 },
+};
+
+const sbit_t gsm0503_afs_ic_sbit[4][8] = {
+ { 127, 127, 127, 127, 127, 127, 127, 127 },
+ { 127,-127, 127,-127,-127,-127, 127,-127 },
+ { -127, 127,-127,-127,-127, 127,-127, 127 },
+ { -127,-127,-127, 127, 127,-127,-127,-127 },
+};
+
+const ubit_t gsm0503_ahs_ic_ubit[4][4] = {
+ { 0,0,0,0 },
+ { 1,0,0,1 },
+ { 1,1,1,0 },
+ { 0,1,1,1 },
+};
+
+const sbit_t gsm0503_ahs_ic_sbit[4][4] = {
+ { 127, 127, 127, 127 },
+ { -127, 127, 127,-127 },
+ { -127,-127,-127, 127 },
+ { 127,-127,-127,-127 },
+};
+
+const uint8_t gsm0503_tch_hr_interleaving[228][2] = {
+ { 0 ,0 }, { 1 ,2 }, { 78 ,1 }, { 79 ,3 }, { 48 ,0 }, { 49 ,2 },
+ { 54 ,1 }, { 55 ,3 }, { 24 ,0 }, { 25 ,2 }, { 30 ,1 }, { 31 ,3 },
+ { 72 ,0 }, { 73 ,2 }, { 6 ,1 }, { 7 ,3 }, { 96 ,0 }, { 97 ,2 },
+ { 12 ,0 }, { 13 ,2 }, { 102,1 }, { 103,3 }, { 60 ,0 }, { 61 ,2 },
+ { 66 ,1 }, { 67 ,3 }, { 90 ,1 }, { 91 ,3 }, { 36 ,0 }, { 37 ,2 },
+ { 42 ,1 }, { 43 ,3 }, { 18 ,1 }, { 19 ,3 }, { 84 ,0 }, { 85 ,2 },
+ { 108,0 }, { 109,2 }, { 2 ,0 }, { 3 ,2 }, { 80 ,1 }, { 81 ,3 },
+ { 50 ,0 }, { 51 ,2 }, { 56 ,1 }, { 57 ,3 }, { 26 ,0 }, { 27 ,2 },
+ { 32 ,1 }, { 33 ,3 }, { 74 ,0 }, { 75 ,2 }, { 8 ,1 }, { 9 ,3 },
+ { 98 ,0 }, { 99 ,2 }, { 14 ,0 }, { 15 ,2 }, { 104,1 }, { 105,3 },
+ { 62 ,0 }, { 63 ,2 }, { 68 ,1 }, { 69 ,3 }, { 92 ,1 }, { 93 ,3 },
+ { 38 ,0 }, { 39 ,2 }, { 44 ,1 }, { 45 ,3 }, { 20 ,1 }, { 21 ,3 },
+ { 86 ,0 }, { 87 ,2 }, { 110,0 }, { 111,2 }, { 4 ,0 }, { 5 ,2 },
+ { 82 ,1 }, { 83 ,3 }, { 52 ,0 }, { 53 ,2 }, { 58 ,1 }, { 59 ,3 },
+ { 28 ,0 }, { 29 ,2 }, { 34 ,1 }, { 35 ,3 }, { 76 ,0 }, { 77 ,2 },
+ { 10 ,1 }, { 11 ,3 }, { 100,0 }, { 101,2 }, { 16 ,0 }, { 17 ,2 },
+ { 106,1 }, { 107,3 }, { 64 ,0 }, { 65 ,2 }, { 70 ,1 }, { 71 ,3 },
+ { 94 ,1 }, { 95 ,3 }, { 40 ,0 }, { 41 ,2 }, { 46 ,1 }, { 47 ,3 },
+ { 22 ,1 }, { 23 ,3 }, { 88 ,0 }, { 89 ,2 }, { 112,0 }, { 113,2 },
+ { 6 ,0 }, { 7 ,2 }, { 84 ,1 }, { 85 ,3 }, { 54 ,0 }, { 55 ,2 },
+ { 60 ,1 }, { 61 ,3 }, { 30 ,0 }, { 31 ,2 }, { 36 ,1 }, { 37 ,3 },
+ { 78 ,0 }, { 79 ,2 }, { 12 ,1 }, { 13 ,3 }, { 102,0 }, { 103,2 },
+ { 18 ,0 }, { 19 ,2 }, { 108,1 }, { 109,3 }, { 66 ,0 }, { 67 ,2 },
+ { 72 ,1 }, { 73 ,3 }, { 96 ,1 }, { 97 ,3 }, { 42 ,0 }, { 43 ,2 },
+ { 48 ,1 }, { 49 ,3 }, { 24 ,1 }, { 25 ,3 }, { 90 ,0 }, { 91 ,2 },
+ { 0 ,1 }, { 1 ,3 }, { 8 ,0 }, { 9 ,2 }, { 86 ,1 }, { 87 ,3 },
+ { 56 ,0 }, { 57 ,2 }, { 62 ,1 }, { 63 ,3 }, { 32 ,0 }, { 33 ,2 },
+ { 38 ,1 }, { 39 ,3 }, { 80 ,0 }, { 81 ,2 }, { 14 ,1 }, { 15 ,3 },
+ { 104,0 }, { 105,2 }, { 20 ,0 }, { 21 ,2 }, { 110,1 }, { 111,3 },
+ { 68 ,0 }, { 69 ,2 }, { 74 ,1 }, { 75 ,3 }, { 98 ,1 }, { 99 ,3 },
+ { 44 ,0 }, { 45 ,2 }, { 50 ,1 }, { 51 ,3 }, { 26 ,1 }, { 27 ,3 },
+ { 92 ,0 }, { 93 ,2 }, { 2 ,1 }, { 3 ,3 }, { 10 ,0 }, { 11 ,2 },
+ { 88 ,1 }, { 89 ,3 }, { 58 ,0 }, { 59 ,2 }, { 64 ,1 }, { 65 ,3 },
+ { 34 ,0 }, { 35 ,2 }, { 40 ,1 }, { 41 ,3 }, { 82 ,0 }, { 83 ,2 },
+ { 16 ,1 }, { 17 ,3 }, { 106,0 }, { 107,2 }, { 22 ,0 }, { 23 ,2 },
+ { 112,1 }, { 113,3 }, { 70 ,0 }, { 71 ,2 }, { 76 ,1 }, { 77 ,3 },
+ { 100,1 }, { 101,3 }, { 46 ,0 }, { 47 ,2 }, { 52 ,1 }, { 53 ,3 },
+ { 28 ,1 }, { 29 ,3 }, { 94 ,0 }, { 95 ,2 }, { 4 ,1 }, { 5 ,3 },
+};
+
+/*
+ * 3GPP TS 05.03 5.1.9.1.2 "USF precoding"
+ */
+const ubit_t gsm0503_mcs5_usf_precode_table[8][36] = {
+ { 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0, },
+ { 1,1,1,1,1,0,0,0,0, 1,1,1,1,0,0,0,0,0, 1,1,1,1,1,1,0,0,0, 1,1,1,1,1,0,0,0,1, },
+ { 1,1,1,0,0,1,1,1,0, 1,1,1,0,1,1,1,0,0, 1,1,0,0,0,0,1,1,0, 1,1,0,0,0,1,1,0,0, },
+ { 1,0,0,1,1,1,1,0,0, 1,1,0,0,0,0,0,1,1, 1,0,1,1,1,0,1,1,1, 0,0,1,0,0,1,1,1,1, },
+ { 0,0,0,1,1,0,0,1,1, 0,0,1,0,1,1,0,1,0, 1,0,0,0,0,1,1,0,1, 1,1,1,1,1,1,1,1,0, },
+ { 1,1,0,1,0,1,0,1,1, 0,0,0,1,1,0,1,0,1, 0,1,1,1,0,1,0,1,1, 1,0,0,1,0,1,0,1,1, },
+ { 0,0,1,0,0,1,1,0,1, 1,0,1,1,1,1,1,1,1, 0,1,1,0,1,0,0,0,1, 0,0,1,1,1,0,1,0,0, },
+ { 0,1,1,0,1,0,1,1,1, 0,1,0,1,0,1,1,1,1, 0,0,0,1,1,1,1,1,0, 0,1,0,0,1,0,0,1,1, },
+};
diff --git a/src/coding/libosmocoding.map b/src/coding/libosmocoding.map
new file mode 100644
index 00000000..dbb53dec
--- /dev/null
+++ b/src/coding/libosmocoding.map
@@ -0,0 +1,117 @@
+LIBOSMOCODING_1.0 {
+global:
+
+gsm0503_pdtch_hl_hn_ubit;
+gsm0503_pdtch_edge_hl_hn_ubit;
+gsm0503_pdtch_hl_hn_sbit;
+gsm0503_pdtch_edge_hl_hn_sbit;
+gsm0503_usf2six;
+gsm0503_usf2twelve_ubit;
+gsm0503_usf2twelve_sbit;
+gsm0503_puncture_cs2;
+gsm0503_puncture_cs3;
+gsm0503_puncture_mcs1_dl_hdr;
+gsm0503_puncture_mcs1_ul_hdr;
+gsm0503_puncture_mcs1_p1;
+gsm0503_puncture_mcs1_p2;
+gsm0503_puncture_mcs2_p1;
+gsm0503_puncture_mcs2_p2;
+gsm0503_puncture_mcs3_p1;
+gsm0503_puncture_mcs3_p2;
+gsm0503_puncture_mcs3_p3;
+gsm0503_puncture_mcs4_p1;
+gsm0503_puncture_mcs4_p2;
+gsm0503_puncture_mcs4_p3;
+gsm0503_puncture_mcs5_p1;
+gsm0503_puncture_mcs5_p2;
+gsm0503_puncture_mcs6_p1;
+gsm0503_puncture_mcs6_p2;
+gsm0503_puncture_mcs7_dl_hdr;
+gsm0503_puncture_mcs7_ul_hdr;
+gsm0503_puncture_mcs7_p1;
+gsm0503_puncture_mcs7_p2;
+gsm0503_puncture_mcs7_p3;
+gsm0503_puncture_mcs8_p1;
+gsm0503_puncture_mcs8_p2;
+gsm0503_puncture_mcs8_p3;
+gsm0503_puncture_mcs9_p1;
+gsm0503_puncture_mcs9_p2;
+gsm0503_puncture_mcs9_p3;
+gsm0503_interleave_mcs5;
+gsm0503_gsm_fr_map;
+gsm0503_gsm_efr_protected_bits;
+gsm0503_afs_ic_ubit;
+gsm0503_afs_ic_sbit;
+gsm0503_ahs_ic_ubit;
+gsm0503_ahs_ic_sbit;
+gsm0503_tch_hr_interleaving;
+gsm0503_mcs5_usf_precode_table;
+
+gsm0503_fire_crc40;
+gsm0503_cs234_crc16;
+gsm0503_mcs_crc8_hdr;
+gsm0503_mcs_crc12;
+gsm0503_rach_crc6;
+gsm0503_sch_crc10;
+gsm0503_tch_fr_crc3;
+gsm0503_tch_efr_crc8;
+gsm0503_amr_crc6;
+
+gsm0503_xcch_burst_unmap;
+gsm0503_xcch_burst_map;
+gsm0503_tch_burst_unmap;
+gsm0503_tch_burst_map;
+gsm0503_mcs5_ul_burst_map;
+gsm0503_mcs5_ul_burst_unmap;
+gsm0503_mcs7_ul_burst_map;
+gsm0503_mcs7_ul_burst_unmap;
+gsm0503_mcs5_dl_burst_map;
+gsm0503_mcs5_dl_burst_unmap;
+gsm0503_mcs7_dl_burst_map;
+gsm0503_mcs7_dl_burst_unmap;
+gsm0503_mcs5_burst_swap;
+
+gsm0503_xcch_deinterleave;
+gsm0503_xcch_interleave;
+gsm0503_tch_fr_deinterleave;
+gsm0503_tch_fr_interleave;
+gsm0503_tch_hr_deinterleave;
+gsm0503_tch_hr_interleave;
+gsm0503_mcs1_ul_deinterleave;
+gsm0503_mcs1_ul_interleave;
+gsm0503_mcs1_dl_deinterleave;
+gsm0503_mcs1_dl_interleave;
+gsm0503_mcs5_ul_deinterleave;
+gsm0503_mcs5_ul_interleave;
+gsm0503_mcs5_dl_deinterleave;
+gsm0503_mcs5_dl_interleave;
+gsm0503_mcs7_ul_deinterleave;
+gsm0503_mcs7_ul_interleave;
+gsm0503_mcs7_dl_deinterleave;
+gsm0503_mcs7_dl_interleave;
+gsm0503_mcs8_ul_deinterleave;
+gsm0503_mcs8_ul_interleave;
+gsm0503_mcs8_dl_deinterleave;
+gsm0503_mcs8_dl_interleave;
+
+gsm0503_xcch_encode;
+gsm0503_xcch_decode;
+gsm0503_pdtch_encode;
+gsm0503_pdtch_decode;
+gsm0503_pdtch_egprs_encode;
+gsm0503_pdtch_egprs_decode;
+gsm0503_tch_fr_encode;
+gsm0503_tch_fr_decode;
+gsm0503_tch_hr_encode;
+gsm0503_tch_hr_decode;
+gsm0503_tch_afs_encode;
+gsm0503_tch_afs_decode;
+gsm0503_tch_ahs_encode;
+gsm0503_tch_ahs_decode;
+gsm0503_rach_encode;
+gsm0503_rach_decode;
+gsm0503_sch_encode;
+gsm0503_sch_decode;
+
+local: *;
+};
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 5f2fb8f3..8d284760 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -85,6 +85,8 @@ gsm0503_rach;
gsm0503_sch;
gsm0503_cs2;
gsm0503_cs3;
+gsm0503_cs2_np;
+gsm0503_cs3_np;
gsm0503_tch_fr;
gsm0503_tch_hr;
gsm0503_tch_afs_12_2;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0472082e..496ed658 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,7 +14,8 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \
smscb/gsm0341_test stats/stats_test ctrl/ctrl_test \
bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \
tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_test \
- write_queue/wqueue_test socket/socket_test
+ write_queue/wqueue_test socket/socket_test \
+ coding/coding_test
if ENABLE_MSGFILE
check_PROGRAMS += msgfile/msgfile_test
@@ -146,6 +147,13 @@ write_queue_wqueue_test_LDADD = $(top_builddir)/src/libosmocore.la
socket_socket_test_SOURCES = socket/socket_test.c
socket_socket_test_LDADD = $(top_builddir)/src/libosmocore.la
+coding_coding_test_SOURCES = coding/coding_test.c
+coding_coding_test_LDADD = \
+ $(top_builddir)/src/libosmocore.la \
+ $(top_builddir)/src/gsm/libosmogsm.la \
+ $(top_builddir)/src/codec/libosmocodec.la \
+ $(top_builddir)/src/coding/libosmocoding.la
+
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
:;{ \
@@ -184,7 +192,7 @@ EXTRA_DIST = testsuite.at $(srcdir)/package.m4 $(TESTSUITE) \
gsup/gsup_test.ok gsup/gsup_test.err \
oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \
write_queue/wqueue_test.ok socket/socket_test.ok \
- socket/socket_test.err
+ socket/socket_test.err coding/coding_test.ok
DISTCLEANFILES = atconfig atlocal
noinst_HEADERS = conv/conv.h
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
new file mode 100644
index 00000000..9a00f0d3
--- /dev/null
+++ b/tests/coding/coding_test.c
@@ -0,0 +1,501 @@
+/*
+ * (C) 2013 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2015 by Alexander Chemeris <Alexander.Chemeris@fairwaves.co>
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/core/utils.h>
+
+#include <osmocom/coding/gsm0503_coding.h>
+
+#define ASSERT_TRUE(rc) \
+ if (!(rc)) { \
+ printf("Assert failed in %s:%d.\n", \
+ __FILE__, __LINE__); \
+ abort(); \
+ }
+
+/* set condition to 1, to show debugging */
+#define printd if (0) printf
+
+static int ubits2sbits(ubit_t *ubits, sbit_t *sbits, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (*ubits == 0x23) {
+ ubits++;
+ sbits++;
+ continue;
+ }
+
+ if ((*ubits++) & 1) {
+ *sbits++ = -127;
+ } else {
+ *sbits++ = 127;
+ }
+ }
+
+ return count;
+}
+
+static void test_xcch(uint8_t *l2)
+{
+ uint8_t result[23];
+ ubit_t bursts_u[116 * 4];
+ sbit_t bursts_s[116 * 4];
+ int n_errors, n_bits_total;
+
+ /* Encode L2 message */
+ printd("Encoding: %s\n", osmo_hexdump(l2, 23));
+ gsm0503_xcch_encode(bursts_u, l2);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 116 * 4);
+
+ printd("U-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
+ bursts_u[57], bursts_u[58]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 116, 57),
+ bursts_u[57 + 116], bursts_u[58 + 116]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 232, 57),
+ bursts_u[57 + 232], bursts_u[58 + 232]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 348, 57),
+ bursts_u[57 + 348], bursts_u[58 + 348]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));
+
+ printd("S-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s, 57),
+ (uint8_t)bursts_s[57], (uint8_t)bursts_s[58]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 116, 57),
+ (uint8_t)bursts_s[57 + 116], (uint8_t)bursts_s[58 + 116]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 232, 57),
+ (uint8_t)bursts_s[57 + 232], (uint8_t)bursts_s[58 + 232]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 348, 57),
+ (uint8_t)bursts_s[57 + 348], (uint8_t)bursts_s[58 + 348]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 348, 57));
+
+ /* Destroy some bits */
+ memset(bursts_s, 0, 30);
+ memset(bursts_s + 116, 0, 30);
+
+ /* Decode, correcting errors */
+ gsm0503_xcch_decode(result, bursts_s, &n_errors, &n_bits_total);
+ printd("Decoded: %s\n", osmo_hexdump(result, 23));
+ printf("xcch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
+ n_errors, n_bits_total, (float) n_errors / n_bits_total);
+
+ ASSERT_TRUE(n_bits_total == 456);
+ ASSERT_TRUE(!memcmp(l2, result, 23));
+
+ printd("\n");
+}
+
+static void test_rach(uint8_t bsic, uint8_t ra)
+{
+ uint8_t result;
+ ubit_t bursts_u[36];
+ sbit_t bursts_s[36];
+
+ /* Encode L2 message */
+ printd("Encoding: %02x\n", ra);
+ gsm0503_rach_encode(bursts_u, &ra, bsic);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 36);
+
+ printd("U-Bits:\n");
+ printd("%s\n", osmo_hexdump(bursts_u, 36));
+
+ printd("S-Bits:\n");
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s, 36));
+
+ /* Destroy some bits */
+ memset(bursts_s + 6, 0, 8);
+
+ /* Decode, correcting errors */
+ gsm0503_rach_decode(&result, bursts_s, bsic);
+ printd("Decoded: %02x\n", result);
+
+ ASSERT_TRUE(ra == result);
+
+ printd("\n");
+}
+
+static void test_sch(uint8_t *info)
+{
+ uint8_t result[4];
+ ubit_t bursts_u[78];
+ sbit_t bursts_s[78];
+
+ /* Zero bits 25 and above */
+ info[3] &= 1;
+ result[3] = 0;
+
+ /* Encode L2 message */
+ printd("Encoding: %s\n", osmo_hexdump(info, 4));
+ gsm0503_sch_encode(bursts_u, info);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 78);
+
+ printd("U-Bits:\n");
+ printd("%s\n", osmo_hexdump(bursts_u, 78));
+
+ printd("S-Bits:\n");
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s, 78));
+
+ /* Destroy some bits */
+ memset(bursts_s + 6, 0, 10);
+
+ /* Decode, correcting errors */
+ gsm0503_sch_decode(result, bursts_s);
+ printd("Decoded: %s\n", osmo_hexdump(result, 4));
+
+ ASSERT_TRUE(!memcmp(info, result, 4));
+
+ printd("\n");
+}
+
+static void test_fr(uint8_t *speech, int len)
+{
+ uint8_t result[33];
+ ubit_t bursts_u[116 * 8];
+ sbit_t bursts_s[116 * 8];
+ int n_errors, n_bits_total;
+ int rc;
+
+ memset(bursts_u, 0x23, sizeof(bursts_u));
+ memset(bursts_s, 0, sizeof(bursts_s));
+
+ /* Encode L2 message */
+ printd("Encoding: %s\n", osmo_hexdump(speech, len));
+ gsm0503_tch_fr_encode(bursts_u, speech, len, 1);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 116 * 8);
+
+ printd("U-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
+ bursts_u[57], bursts_u[58]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 116, 57),
+ bursts_u[57 + 116], bursts_u[58 + 116]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 232, 57),
+ bursts_u[57 + 232], bursts_u[58 + 232]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 348, 57),
+ bursts_u[57 + 348], bursts_u[58 + 348]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 464, 57),
+ bursts_u[57 + 464], bursts_u[58 + 464]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 464, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 580, 57),
+ bursts_u[57 + 580], bursts_u[58 + 580]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 580, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 696, 57),
+ bursts_u[57 + 696], bursts_u[58 + 696]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 696, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 812, 57),
+ bursts_u[57 + 812], bursts_u[58 + 812]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 812, 57));
+
+ printd("S-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s, 57),
+ (uint8_t)bursts_s[57], (uint8_t)bursts_s[58]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 116, 57),
+ (uint8_t)bursts_s[57 + 116], (uint8_t)bursts_s[58 + 116]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 232, 57),
+ (uint8_t)bursts_s[57 + 232], (uint8_t)bursts_s[58 + 232]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 348, 57),
+ (uint8_t)bursts_s[57 + 348], (uint8_t)bursts_s[58 + 348]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 348, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 464, 57),
+ (uint8_t)bursts_s[57 + 464], (uint8_t)bursts_s[58 + 464]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 464, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 580, 57),
+ (uint8_t)bursts_s[57 + 580], (uint8_t)bursts_s[58 + 580]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 580, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 696, 57),
+ (uint8_t)bursts_s[57 + 696], (uint8_t)bursts_s[58 + 696]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 696, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 812, 57),
+ (uint8_t)bursts_s[57 + 812], (uint8_t)bursts_s[58 + 812]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 812, 57));
+
+ /* Destroy some bits */
+ memset(bursts_s + 6, 0, 20);
+
+ /* Decode, correcting errors */
+ rc = gsm0503_tch_fr_decode(result, bursts_s, 1, len == 31,
+ &n_errors, &n_bits_total);
+ printd("Decoded: %s\n", osmo_hexdump(result, len));
+ printf("tch_fr_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
+ n_errors, n_bits_total, (float)n_errors/n_bits_total);
+
+ ASSERT_TRUE(rc == len);
+ ASSERT_TRUE(!memcmp(speech, result, len));
+
+ printd("\n");
+}
+
+static void test_hr(uint8_t *speech, int len)
+{
+ uint8_t result[23];
+ ubit_t bursts_u[116 * 6];
+ sbit_t bursts_s[116 * 6];
+ int n_errors, n_bits_total;
+ int rc;
+
+ memset(bursts_u, 0x23, sizeof(bursts_u));
+ memset(bursts_s, 0, sizeof(bursts_s));
+
+ /* Encode L2 message */
+ printd("Encoding: %s\n", osmo_hexdump(speech, len));
+ gsm0503_tch_hr_encode(bursts_u, speech, len);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 116 * 6);
+
+ printd("U-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
+ bursts_u[57], bursts_u[58]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 116, 57),
+ bursts_u[57 + 116], bursts_u[58 + 116]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 232, 57),
+ bursts_u[57 + 232], bursts_u[58 + 232]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 348, 57),
+ bursts_u[57 + 348], bursts_u[58 + 348]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 464, 57),
+ bursts_u[57 + 464], bursts_u[58 + 464]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 464, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 580, 57),
+ bursts_u[57 + 580], bursts_u[58 + 580]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 580, 57));
+
+ printd("S-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s, 57),
+ (uint8_t)bursts_s[57], (uint8_t)bursts_s[58]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 116, 57),
+ (uint8_t)bursts_s[57 + 116], (uint8_t)bursts_s[58 + 116]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 232, 57),
+ (uint8_t)bursts_s[57 + 232], (uint8_t)bursts_s[58 + 232]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 348, 57),
+ (uint8_t)bursts_s[57 + 348], (uint8_t)bursts_s[58 + 348]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 348, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 464, 57),
+ (uint8_t)bursts_s[57 + 464], (uint8_t)bursts_s[58 + 464]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 464, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 580, 57),
+ (uint8_t)bursts_s[57 + 580], (uint8_t)bursts_s[58 + 580]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 580, 57));
+
+ /* Destroy some bits */
+ memset(bursts_s + 6, 0, 20);
+
+ /* Decode, correcting errors */
+ rc = gsm0503_tch_hr_decode(result, bursts_s, 0,
+ &n_errors, &n_bits_total);
+ printd("Decoded: %s\n", osmo_hexdump(result, len));
+ printf("tch_hr_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
+ n_errors, n_bits_total, (float)n_errors/n_bits_total);
+
+ ASSERT_TRUE(rc == len);
+ ASSERT_TRUE(!memcmp(speech, result, len));
+
+ printd("\n");
+}
+
+static void test_pdtch(uint8_t *l2, int len)
+{
+ uint8_t result[len];
+ ubit_t bursts_u[116 * 4];
+ sbit_t bursts_s[116 * 4];
+ int n_errors, n_bits_total;
+ int rc;
+
+ /* Zero the not coded tail bits */
+ switch (len) {
+ case 34:
+ case 54:
+ l2[len - 1] &= 0x7f;
+ result[len - 1] &= 0x7f;
+ break;
+ case 40:
+ l2[len - 1] &= 0x07;
+ result[len - 1] &= 0x07;
+ break;
+ }
+
+ /* Encode L2 message */
+ printd("Encoding: %s\n", osmo_hexdump(l2, len));
+ gsm0503_pdtch_encode(bursts_u, l2, len);
+
+ /* Prepare soft-bits */
+ ubits2sbits(bursts_u, bursts_s, 116 * 4);
+
+ printd("U-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u, 57),
+ bursts_u[57], bursts_u[58]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 116, 57),
+ bursts_u[57 + 116], bursts_u[58 + 116]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 232, 57),
+ bursts_u[57 + 232], bursts_u[58 + 232]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump(bursts_u + 348, 57),
+ bursts_u[57 + 348], bursts_u[58 + 348]);
+ printd("%s\n", osmo_hexdump(bursts_u + 59 + 348, 57));
+
+ printd("S-Bits:\n");
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s, 57),
+ (uint8_t)bursts_s[57], (uint8_t)bursts_s[58]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 116, 57),
+ (uint8_t)bursts_s[57 + 116], (uint8_t)bursts_s[58 + 116]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 116, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 232, 57),
+ (uint8_t)bursts_s[57 + 232], (uint8_t)bursts_s[58 + 232]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 232, 57));
+ printd("%s %02x %02x ", osmo_hexdump((uint8_t *)bursts_s + 348, 57),
+ (uint8_t)bursts_s[57 + 348], (uint8_t)bursts_s[58 + 348]);
+ printd("%s\n", osmo_hexdump((uint8_t *)bursts_s + 59 + 348, 57));
+
+ /* Decode */
+ rc = gsm0503_pdtch_decode(result, bursts_s, NULL,
+ &n_errors, &n_bits_total);
+ printd("Decoded: %s\n", osmo_hexdump(result, len));
+ printf("pdtch_decode: n_errors=%d n_bits_total=%d ber=%.2f\n",
+ n_errors, n_bits_total, (float)n_errors/n_bits_total);
+
+ ASSERT_TRUE(rc == len);
+ ASSERT_TRUE(!memcmp(l2, result, len));
+
+ printd("\n");
+}
+
+uint8_t test_l2[][23] = {
+ /* Dummy frame */
+ { 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ /* Random frame */
+ { 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+ 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8 },
+ /* jolly frame */
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
+};
+
+uint8_t test_macblock[][54] = {
+ /* Random frame */
+ { 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+ 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0x59, 0xa8, 0x42,
+ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xa3, 0xaf, 0x5f, 0xc6, 0x36, 0x43, 0x44, 0xab,
+ 0xd9, 0x6d, 0x7d, 0x62, 0x24, 0xc9, 0xd2, 0x92,
+ 0xfa, 0x27, 0x5d, 0x71, 0x7a, 0xa8 },
+ /* jolly frame */
+ { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
+};
+
+uint8_t test_speech_fr[33];
+uint8_t test_speech_efr[31];
+uint8_t test_speech_hr[15];
+
+int main(int argc, char **argv)
+{
+ int i, len_l2, len_mb;
+
+ len_l2 = sizeof(test_l2) / sizeof(test_l2[0]);
+ len_mb = sizeof(test_macblock) / sizeof(test_macblock[0]);
+
+ for (i = 0; i < len_l2; i++)
+ test_xcch(test_l2[i]);
+
+ for (i = 0; i < 256; i++) {
+ test_rach(0x3f, i);
+ test_rach(0x00, i);
+ test_rach(0x1a, i);
+ }
+
+ for (i = 0; i < len_l2; i++)
+ test_sch(test_l2[i]);
+
+ for (i = 0; i < sizeof(test_speech_fr); i++)
+ test_speech_fr[i] = i;
+ test_speech_fr[0] = 0xd0;
+ test_fr(test_speech_fr, sizeof(test_speech_fr));
+
+ for (i = 0; i < sizeof(test_speech_efr); i++)
+ test_speech_efr[i] = i;
+ test_speech_efr[0] = 0xc0;
+ test_fr(test_speech_efr, sizeof(test_speech_efr));
+
+ for (i = 0; i < len_l2; i++)
+ test_fr(test_l2[i], sizeof(test_l2[0]));
+
+ for (i = 0; i < sizeof(test_speech_hr); i++)
+ test_speech_hr[i] = i * 17;
+ test_speech_hr[0] = 0x00;
+ test_hr(test_speech_hr, sizeof(test_speech_hr));
+
+ for (i = 0; i < len_l2; i++)
+ test_hr(test_l2[i], sizeof(test_l2[0]));
+
+ for (i = 0; i < len_mb; i++) {
+ test_pdtch(test_macblock[i], 23);
+ test_pdtch(test_macblock[i], 34);
+ test_pdtch(test_macblock[i], 40);
+ test_pdtch(test_macblock[i], 54);
+ }
+
+ printf("Success\n");
+
+ return 0;
+}
diff --git a/tests/coding/coding_test.ok b/tests/coding/coding_test.ok
new file mode 100644
index 00000000..5030e4d2
--- /dev/null
+++ b/tests/coding/coding_test.ok
@@ -0,0 +1,21 @@
+xcch_decode: n_errors=60 n_bits_total=456 ber=0.13
+xcch_decode: n_errors=60 n_bits_total=456 ber=0.13
+xcch_decode: n_errors=60 n_bits_total=456 ber=0.13
+tch_fr_decode: n_errors=8 n_bits_total=378 ber=0.02
+tch_fr_decode: n_errors=8 n_bits_total=378 ber=0.02
+tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02
+tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02
+tch_fr_decode: n_errors=10 n_bits_total=456 ber=0.02
+tch_hr_decode: n_errors=10 n_bits_total=211 ber=0.05
+tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02
+tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02
+tch_hr_decode: n_errors=10 n_bits_total=456 ber=0.02
+pdtch_decode: n_errors=0 n_bits_total=456 ber=0.00
+pdtch_decode: n_errors=132 n_bits_total=588 ber=0.22
+pdtch_decode: n_errors=220 n_bits_total=676 ber=0.33
+pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00
+pdtch_decode: n_errors=0 n_bits_total=456 ber=0.00
+pdtch_decode: n_errors=132 n_bits_total=588 ber=0.22
+pdtch_decode: n_errors=220 n_bits_total=676 ber=0.33
+pdtch_decode: n_errors=0 n_bits_total=444 ber=0.00
+Success
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 6d8c5d3e..51050f02 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -45,6 +45,12 @@ cat $abs_srcdir/conv/conv_test.ok > expout
AT_CHECK([$abs_top_builddir/tests/conv/conv_test], [0], [expout])
AT_CLEANUP
+AT_SETUP([coding])
+AT_KEYWORDS([coding])
+cat $abs_srcdir/coding/coding_test.ok > expout
+AT_CHECK([$abs_top_builddir/tests/coding/coding_test], [0], [expout])
+AT_CLEANUP
+
AT_SETUP([msgb])
AT_KEYWORDS([msgb])
cat $abs_srcdir/msgb/msgb_test.ok > expout
diff --git a/utils/conv_codes_gsm.py b/utils/conv_codes_gsm.py
index 1bee6db1..279bd3a8 100644
--- a/utils/conv_codes_gsm.py
+++ b/utils/conv_codes_gsm.py
@@ -111,6 +111,30 @@ conv_codes = [
]
),
+ # CS2 definition (non-punctured)
+ ConvolutionalCode(
+ 290,
+ shared_polys["xcch"],
+ name = "cs2_np",
+ description = [
+ "CS2 convolutional code (non-punctured):",
+ "G0 = 1 + D3 + D4",
+ "G1 = 1 + D + D3 + D4",
+ ]
+ ),
+
+ # CS3 definition (non-punctured)
+ ConvolutionalCode(
+ 334,
+ shared_polys["xcch"],
+ name = "cs3_np",
+ description = [
+ "CS3 convolutional code (non-punctured):",
+ "G0 = 1 + D3 + D4",
+ "G1 = 1 + D + D3 + D4",
+ ]
+ ),
+
# TCH_AFS_12_2 definition
ConvolutionalCode(
250,