From ac7c48b4dee99d4c772f133d70d8d1b38262fcd2 Mon Sep 17 00:00:00 2001 From: Author Name Date: Fri, 7 Jul 2023 12:20:59 +0930 Subject: shallow zip-file copy from codec2 e9d726bf20 --- src/gp_interleaver.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 src/gp_interleaver.c (limited to 'src/gp_interleaver.c') diff --git a/src/gp_interleaver.c b/src/gp_interleaver.c new file mode 100644 index 0000000..26e74bf --- /dev/null +++ b/src/gp_interleaver.c @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: gp_interleaver.c + AUTHOR......: David Rowe + DATE CREATED: April 2018 + + Golden Prime Interleaver. My interpretation of "On the Analysis and + Design of Good Algebraic Interleavers", Xie et al,eq (5). + + See also octave/gp_interleaver.m + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2018 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. 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 Lesser General Public License + along with this program; if not, see . +*/ + +#include +#include +#include "gp_interleaver.h" + +/* + Choose b for Golden Prime Interleaver. b is chosen to be the + closest integer, which is relatively prime to N, to the Golden + section of N. + + Implemented with a LUT in C for convenience, Octave version + has a more complete implementation. If you find you need some more + numbers head back to the Octave choose_interleaver_b() function. +*/ + +static const int b_table[] = { + 56, 37, /* 700E: HRA_56_56 */ + 106, 67, /* 2020B: (112,56) partial protection */ + 112, 71, /* 700D: HRA_112_112 */ + 128, 83, /* datac0: H_128_256_5 */ + 192, 127, /* datac13: H_256_512_4, 128 data bits used */ + 210, 131, /* 2020: HRAb_396_504 with 312 data bits used */ + 736, 457, /* datac4: H_1024_2048_4f, 448 data bits used */ + 1024, 641, /* datac3: H_1024_2048_4f */ + 1290, 797, /* datac2: H2064_516_sparse */ + 4096, 2531 /* datac1: H_4096_8192_3d */ +}; + +int choose_interleaver_b(int Nbits) +{ + int i; + for(i=0; i> 1; + interleaved_frame[i*2+1] = temp[i] & 1; + } +} + +void gp_deinterleave_bits(char frame[], char interleaved_frame[], int Nbits) +{ + char temp[Nbits]; + int b = choose_interleaver_b(Nbits); + int i,j; + + for (i=0; i> 1; + frame[i*2 + 1] = temp[i] & 1; + } +} -- cgit v1.2.3