Changes in decoding:
-copied decoding routines from libosmocore to gr-gsm, -made cmake files entries for new source files and added linking with libosmocodec, -moved sch.c file to decoding folder.
This commit is contained in:
parent
25ae3e2066
commit
70c25a112a
|
@ -107,7 +107,8 @@ find_package(Volk)
|
|||
find_package(CppUnit)
|
||||
find_package(Doxygen)
|
||||
find_package(Libosmocore)
|
||||
find_package(Libosmocoding)
|
||||
#find_package(Libosmocoding)
|
||||
find_package(Libosmocodec)
|
||||
|
||||
if(NOT GNURADIO_RUNTIME_FOUND)
|
||||
message(FATAL_ERROR "GnuRadio Runtime required to compile gr-gsm")
|
||||
|
@ -121,9 +122,13 @@ endif()
|
|||
if(NOT LIBOSMOCORE_FOUND)
|
||||
message(FATAL_ERROR "Libosmocore required to compile gr-gsm")
|
||||
endif()
|
||||
if(NOT LIBOSMOCODING_FOUND)
|
||||
message(FATAL_ERROR "Libosmocoding required to compile gr-gsm")
|
||||
endif()
|
||||
message( dupa 2!!! )
|
||||
#if(NOT LIBOSMOCODEC_FOUND)
|
||||
# message(FATAL_ERROR "Libosmocodec required to compile gr-gsm")
|
||||
#endif()
|
||||
#if(NOT LIBOSMOCODING_FOUND)
|
||||
# message(FATAL_ERROR "Libosmocoding required to compile gr-gsm")
|
||||
#endif()
|
||||
|
||||
########################################################################
|
||||
# Setup doxygen option
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
INCLUDE(FindPkgConfig)
|
||||
pkg_check_modules(PC_libosmocodec libosmocodec)
|
||||
set(LIBOSMOCODEC_DEFINITIONS ${PC_LIBOSMOCODEC_CFLAGS_OTHER})
|
||||
|
||||
find_path(
|
||||
LIBOSMOCODEC_INCLUDE_DIR
|
||||
NAMES osmocom/codec/codec.h
|
||||
HINTS ${PC_libosmocodec_INCLUDEDIR}
|
||||
${PC_libosmocodec_INCLUDE_DIRS}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
PATHS /usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
find_library(
|
||||
LIBOSMOCODEC_LIBRARY
|
||||
NAMES libosmocodec osmocodec
|
||||
HINTS ${PC_libosmocodec_LIBDIR}
|
||||
${PC_libosmocodec_LIBRARY_DIRS}
|
||||
${CMAKE_INSTALL_PREFIX}/lib/
|
||||
${CMAKE_INSTALL_PREFIX}/lib64/
|
||||
PATHS /usr/local/lib
|
||||
/usr/lib
|
||||
)
|
||||
|
||||
|
||||
set(LIBOSMOCODEC_LIBRARIES ${LIBOSMOCODEC_LIBRARY})
|
||||
set(LIBOSMOCODEC_INCLUDE_DIRS ${LIBOSMOCODEC_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libosmocodec DEFAULT_MSG LIBOSMOCODEC_LIBRARY LIBOSMOCODEC_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBOSMOCODEC_INCLUDE_DIR LIBOSMOCODEC_LIBRARY )
|
|
@ -29,4 +29,4 @@ set(LIBOSMOCODING_INCLUDE_DIRS ${LIBOSMOCODING_INCLUDE_DIR})
|
|||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libosmocoding DEFAULT_MSG LIBOSMOCODING_LIBRARY LIBOSMOCODING_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBOSMOCODING_INCLUDE_DIR LIBOSMOCODING_LIBRARY )
|
||||
mark_as_advanced(LIBOSMOCODING_INCLUDE_DIR LIBOSMOCODING_LIBRARY )
|
|
@ -1,4 +1,5 @@
|
|||
find_package(PkgConfig)
|
||||
#find_package(PkgConfig)
|
||||
INCLUDE(FindPkgConfig)
|
||||
pkg_check_modules(PC_libosmocore libosmocore)
|
||||
pkg_check_modules(PC_libosmogsm libosmogsm)
|
||||
set(LIBOSMOCORE_DEFINITIONS ${PC_LIBOSMOCORE_CFLAGS_OTHER})
|
||||
|
|
|
@ -139,3 +139,4 @@ elseif(SWIG_FIND_REQUIRED)
|
|||
message(FATAL_ERROR "SWIG is required, but was not found.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ list(APPEND grgsm_sources
|
|||
receiver/receiver_impl.cc
|
||||
receiver/receiver_config.cc
|
||||
receiver/viterbi_detector.cc
|
||||
receiver/sch.c
|
||||
decoding/sch.c
|
||||
receiver/clock_offset_control_impl.cc
|
||||
receiver/cx_channel_hopper_impl.cc
|
||||
demapping/universal_ctrl_chans_demapper_impl.cc
|
||||
|
@ -41,6 +41,12 @@ list(APPEND grgsm_sources
|
|||
decoding/GSM660Tables.cpp
|
||||
decoding/GSM503Tables.cpp
|
||||
decoding/ViterbiR204.cpp
|
||||
decoding/osmocom/coding/gsm0503_conv.c
|
||||
decoding/osmocom/coding/gsm0503_coding.c
|
||||
decoding/osmocom/coding/gsm0503_interleaving.c
|
||||
decoding/osmocom/coding/gsm0503_mapping.c
|
||||
decoding/osmocom/coding/gsm0503_parity.c
|
||||
decoding/osmocom/coding/gsm0503_tables.c
|
||||
flow_control/burst_timeslot_splitter_impl.cc
|
||||
flow_control/burst_sdcch_subslot_splitter_impl.cc
|
||||
flow_control/burst_timeslot_filter_impl.cc
|
||||
|
@ -69,7 +75,8 @@ list(APPEND grgsm_sources
|
|||
|
||||
|
||||
add_library(grgsm SHARED ${grgsm_sources})
|
||||
target_link_libraries(grgsm ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCORE_LIBRARIES} ${LIBOSMOCODING_LIBRARIES}
|
||||
target_link_libraries(grgsm ${Boost_LIBRARIES} ${GNURADIO_ALL_LIBRARIES} ${VOLK_LIBRARIES} ${LIBOSMOCODEC_LIBRARIES} ${LIBOSMOCORE_LIBRARIES}
|
||||
# ${LIBOSMOCODING_LIBRARIES}
|
||||
# libraries required by plotting.h - have troubles to be installed by pybombs
|
||||
# boost_iostreams
|
||||
# boost_system
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include <grgsm/decoding/control_channels_decoder.h>
|
||||
extern "C" {
|
||||
#include <osmocom/coding/gsm0503_coding.h>
|
||||
#include "osmocom/coding/gsm0503_coding.h"
|
||||
}
|
||||
|
||||
namespace gr {
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* gsm0503.h
|
||||
*
|
||||
* Copyright (C) 2016 sysmocom s.f.m.c. GmbH
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <osmocom/core/conv.h>
|
||||
|
||||
/*! \file gsm0503.h
|
||||
* Osmocom convolutional encoder/decoder for xCCH channels, see 3GPP TS 05.03
|
||||
*/
|
||||
|
||||
/*! \brief structure describing convolutional code xCCH
|
||||
*
|
||||
* Non-recursive code, flushed, not punctured code.
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_xcch;
|
||||
|
||||
/*! \brief structure describing convolutional code RACH
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_rach;
|
||||
|
||||
/*! \brief structure describing convolutional code SCH
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_sch;
|
||||
|
||||
/*! \brief structures describing convolutional codes CS2/3
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_cs2;
|
||||
extern const struct osmo_conv_code gsm0503_cs3;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/FR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_fr;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/HR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_hr;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 12.2
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_12_2;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 10.2
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_10_2;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 7.95
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_7_95;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 7.4
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_7_4;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 6.7
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_6_7;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 5.9
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_5_9;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 5.15
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_5_15;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AFS 4.75
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_afs_4_75;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 7.95
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_7_95;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 7.4
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_7_4;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 6.7
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_6_7;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 5.9
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_5_9;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 5.15
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_5_15;
|
||||
|
||||
/*! \brief structure describing convolutional code TCH/AHS 4.75
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_tch_ahs_4_75;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-1 DL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs1_dl_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-1 UL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs1_ul_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-1
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs1;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-2
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs2;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-3
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs3;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-4
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs4;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-5 DL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs5_dl_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-5 UL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs5_ul_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-5
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs5;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-6
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs6;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-7 DL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs7_dl_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-7 UL HDR
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs7_ul_hdr;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-7
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs7;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-8
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs8;
|
||||
|
||||
/*! \brief structure describing convolutional code EDGE MCS-9
|
||||
*/
|
||||
extern const struct osmo_conv_code gsm0503_mcs9;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,46 @@
|
|||
#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)
|
||||
|
||||
|
||||
|
||||
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_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);
|
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 "gsm0503_tables.h"
|
||||
#include "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,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,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 "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,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,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 "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,
|
||||
};
|
|
@ -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;
|
File diff suppressed because it is too large
Load Diff
|
@ -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];
|
|
@ -23,7 +23,7 @@
|
|||
#include <string.h>
|
||||
#include "gsm_constants.h"
|
||||
|
||||
#include <osmocom/coding/gsm0503_coding.h>
|
||||
#include "osmocom/coding/gsm0503_coding.h"
|
||||
#include <osmocom/core/utils.h>
|
||||
|
||||
static int ubits2sbits(ubit_t *ubits, sbit_t *sbits, int count)
|
|
@ -30,7 +30,7 @@
|
|||
#include "tch_f_decoder_impl.h"
|
||||
|
||||
extern "C" {
|
||||
#include <osmocom/coding/gsm0503_coding.h>
|
||||
#include "osmocom/coding/gsm0503_coding.h"
|
||||
}
|
||||
|
||||
#define DATA_BYTES 23
|
||||
|
|
Loading…
Reference in New Issue