mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
68930e85b5
commit
3262f820b5
|
@ -36,6 +36,7 @@ Doxyfile.core
|
||||||
Doxyfile.gsm
|
Doxyfile.gsm
|
||||||
Doxyfile.vty
|
Doxyfile.vty
|
||||||
Doxyfile.codec
|
Doxyfile.codec
|
||||||
|
Doxyfile.coding
|
||||||
|
|
||||||
debian/autoreconf.after
|
debian/autoreconf.after
|
||||||
debian/autoreconf.before
|
debian/autoreconf.before
|
||||||
|
@ -73,6 +74,7 @@ tests/bits/bitrev_test
|
||||||
tests/a5/a5_test
|
tests/a5/a5_test
|
||||||
tests/comp128/comp128_test
|
tests/comp128/comp128_test
|
||||||
tests/auth/milenage_test
|
tests/auth/milenage_test
|
||||||
|
tests/coding/coding_test
|
||||||
tests/conv/conv_test
|
tests/conv/conv_test
|
||||||
tests/lapd/lapd_test
|
tests/lapd/lapd_test
|
||||||
tests/gsm0808/gsm0808_test
|
tests/gsm0808/gsm0808_test
|
||||||
|
@ -105,6 +107,7 @@ utils/osmo-auc-gen
|
||||||
utils/osmo-sim-test
|
utils/osmo-sim-test
|
||||||
|
|
||||||
doc/codec
|
doc/codec
|
||||||
|
doc/coding
|
||||||
doc/core
|
doc/core
|
||||||
doc/vty/latex
|
doc/vty/latex
|
||||||
doc/vty/html
|
doc/vty/html
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
16
Makefile.am
16
Makefile.am
|
@ -1,11 +1,11 @@
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include
|
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
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \
|
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
|
BUILT_SOURCES = $(top_srcdir)/.version
|
||||||
$(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 \
|
$(html_DATA): $(top_builddir)/doc/core/html/index.html \
|
||||||
$(top_builddir)/doc/gsm/html/index.html \
|
$(top_builddir)/doc/gsm/html/index.html \
|
||||||
$(top_builddir)/doc/vty/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
|
cd $(top_builddir)/doc && tar cf html.tar */html
|
||||||
|
|
||||||
$(top_builddir)/doc/core/html/index.html: $(SOURCES) Doxyfile.core
|
$(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
|
mkdir -p doc/codec
|
||||||
$(DOXYGEN) Doxyfile.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:
|
install-data-hook:
|
||||||
cd $(DESTDIR)$(htmldir) && tar xf html.tar && rm -f html.tar
|
cd $(DESTDIR)$(htmldir) && tar xf html.tar && rm -f html.tar
|
||||||
|
|
||||||
uninstall-hook:
|
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
|
endif
|
||||||
|
|
||||||
MOSTLYCLEANFILES = $(DX_CLEAN)
|
MOSTLYCLEANFILES = $(DX_CLEAN)
|
||||||
|
|
|
@ -42,6 +42,7 @@ case $host in
|
||||||
*)
|
*)
|
||||||
LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
|
LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
|
||||||
LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
|
LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
|
||||||
|
LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
AC_SUBST(LTLDFLAGS_OSMOGB)
|
AC_SUBST(LTLDFLAGS_OSMOGB)
|
||||||
|
@ -228,6 +229,7 @@ fi
|
||||||
AC_OUTPUT(
|
AC_OUTPUT(
|
||||||
libosmocore.pc
|
libosmocore.pc
|
||||||
libosmocodec.pc
|
libosmocodec.pc
|
||||||
|
libosmocoding.pc
|
||||||
libosmovty.pc
|
libosmovty.pc
|
||||||
libosmogsm.pc
|
libosmogsm.pc
|
||||||
libosmogb.pc
|
libosmogb.pc
|
||||||
|
@ -237,6 +239,7 @@ AC_OUTPUT(
|
||||||
src/Makefile
|
src/Makefile
|
||||||
src/vty/Makefile
|
src/vty/Makefile
|
||||||
src/codec/Makefile
|
src/codec/Makefile
|
||||||
|
src/coding/Makefile
|
||||||
src/sim/Makefile
|
src/sim/Makefile
|
||||||
src/gsm/Makefile
|
src/gsm/Makefile
|
||||||
src/gb/Makefile
|
src/gb/Makefile
|
||||||
|
@ -248,4 +251,5 @@ AC_OUTPUT(
|
||||||
Doxyfile.gsm
|
Doxyfile.gsm
|
||||||
Doxyfile.vty
|
Doxyfile.vty
|
||||||
Doxyfile.codec
|
Doxyfile.codec
|
||||||
|
Doxyfile.coding
|
||||||
Makefile)
|
Makefile)
|
||||||
|
|
|
@ -25,6 +25,7 @@ Section: libs
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Multi-Arch: foreign
|
Multi-Arch: foreign
|
||||||
Depends: libosmocodec0 (= ${binary:Version}),
|
Depends: libosmocodec0 (= ${binary:Version}),
|
||||||
|
libosmocoding0 (= ${binary:Version}),
|
||||||
libosmocore8 (= ${binary:Version}),
|
libosmocore8 (= ${binary:Version}),
|
||||||
libosmogb4 (= ${binary:Version}),
|
libosmogb4 (= ${binary:Version}),
|
||||||
libosmogsm7 (= ${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.
|
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
|
Package: libosmocore8
|
||||||
Section: libs
|
Section: libs
|
||||||
Architecture: any
|
Architecture: any
|
||||||
|
@ -100,6 +133,7 @@ Depends: ${misc:Depends},
|
||||||
libosmocore8,
|
libosmocore8,
|
||||||
libjs-jquery,
|
libjs-jquery,
|
||||||
libosmocodec-doc,
|
libosmocodec-doc,
|
||||||
|
libosmocoding-doc,
|
||||||
libosmogsm-doc,
|
libosmogsm-doc,
|
||||||
libosmovty-doc
|
libosmovty-doc
|
||||||
Description: Documentation for the Osmo Core library
|
Description: Documentation for the Osmo Core library
|
||||||
|
|
|
@ -69,6 +69,11 @@ nobase_include_HEADERS = \
|
||||||
osmocom/gsm/gsm0480.h \
|
osmocom/gsm/gsm0480.h \
|
||||||
osmocom/gsm/gsm0502.h \
|
osmocom/gsm/gsm0502.h \
|
||||||
osmocom/gsm/gsm0503.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/gsm0808.h \
|
||||||
osmocom/gsm/gsm23003.h \
|
osmocom/gsm/gsm23003.h \
|
||||||
osmocom/gsm/gsm48.h \
|
osmocom/gsm/gsm48.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);
|
|
@ -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);
|
|
@ -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);
|
|
@ -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;
|
|
@ -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];
|
|
@ -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}/
|
||||||
|
|
|
@ -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
|
File diff suppressed because it is too large
Load Diff
|
@ -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];
|
||||||
|
}
|
||||||
|
}
|
|
@ -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];
|
||||||
|
}
|
|
@ -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,
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -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: *;
|
||||||
|
};
|
|
@ -85,6 +85,8 @@ gsm0503_rach;
|
||||||
gsm0503_sch;
|
gsm0503_sch;
|
||||||
gsm0503_cs2;
|
gsm0503_cs2;
|
||||||
gsm0503_cs3;
|
gsm0503_cs3;
|
||||||
|
gsm0503_cs2_np;
|
||||||
|
gsm0503_cs3_np;
|
||||||
gsm0503_tch_fr;
|
gsm0503_tch_fr;
|
||||||
gsm0503_tch_hr;
|
gsm0503_tch_hr;
|
||||||
gsm0503_tch_afs_12_2;
|
gsm0503_tch_afs_12_2;
|
||||||
|
|
|
@ -14,7 +14,8 @@ check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \
|
||||||
smscb/gsm0341_test stats/stats_test ctrl/ctrl_test \
|
smscb/gsm0341_test stats/stats_test ctrl/ctrl_test \
|
||||||
bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \
|
bitvec/bitvec_test msgb/msgb_test bits/bitcomp_test \
|
||||||
tlv/tlv_test gsup/gsup_test oap/oap_test fsm/fsm_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
|
if ENABLE_MSGFILE
|
||||||
check_PROGRAMS += msgfile/msgfile_test
|
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_SOURCES = socket/socket_test.c
|
||||||
socket_socket_test_LDADD = $(top_builddir)/src/libosmocore.la
|
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.
|
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
|
||||||
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
|
$(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 \
|
gsup/gsup_test.ok gsup/gsup_test.err \
|
||||||
oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \
|
oap/oap_test.ok fsm/fsm_test.ok fsm/fsm_test.err \
|
||||||
write_queue/wqueue_test.ok socket/socket_test.ok \
|
write_queue/wqueue_test.ok socket/socket_test.ok \
|
||||||
socket/socket_test.err
|
socket/socket_test.err coding/coding_test.ok
|
||||||
|
|
||||||
DISTCLEANFILES = atconfig atlocal
|
DISTCLEANFILES = atconfig atlocal
|
||||||
noinst_HEADERS = conv/conv.h
|
noinst_HEADERS = conv/conv.h
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -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
|
|
@ -45,6 +45,12 @@ cat $abs_srcdir/conv/conv_test.ok > expout
|
||||||
AT_CHECK([$abs_top_builddir/tests/conv/conv_test], [0], [expout])
|
AT_CHECK([$abs_top_builddir/tests/conv/conv_test], [0], [expout])
|
||||||
AT_CLEANUP
|
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_SETUP([msgb])
|
||||||
AT_KEYWORDS([msgb])
|
AT_KEYWORDS([msgb])
|
||||||
cat $abs_srcdir/msgb/msgb_test.ok > expout
|
cat $abs_srcdir/msgb/msgb_test.ok > expout
|
||||||
|
|
|
@ -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
|
# TCH_AFS_12_2 definition
|
||||||
ConvolutionalCode(
|
ConvolutionalCode(
|
||||||
250,
|
250,
|
||||||
|
|
Loading…
Reference in New Issue