diff --git a/baselibs.conf b/baselibs.conf new file mode 100644 index 0000000..7599ddc --- /dev/null +++ b/baselibs.conf @@ -0,0 +1 @@ +libcodec2-0_8 diff --git a/codec2-0.6.tar.xz b/codec2-0.6.tar.xz deleted file mode 100644 index c498d00..0000000 --- a/codec2-0.6.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:57754bf3507a7ac9f9402cae054787a3572bea6a791137cdd5fa35f6c5af1144 -size 8352824 diff --git a/codec2-0.8.1.tar.xz b/codec2-0.8.1.tar.xz new file mode 100644 index 0000000..fb5e393 --- /dev/null +++ b/codec2-0.8.1.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a07cdaacf59c3f7dbb1c63b769d443af486c434b3bd031fb4edd568ce3e613d6 +size 8868212 diff --git a/codec2-licensed-stuff.patch b/codec2-licensed-stuff.patch new file mode 100644 index 0000000..d4cd461 --- /dev/null +++ b/codec2-licensed-stuff.patch @@ -0,0 +1,495 @@ +Index: src/CMakeLists.txt +=================================================================== +--- src/CMakeLists.txt.orig ++++ src/CMakeLists.txt +@@ -378,8 +378,8 @@ target_link_libraries(drs232 ${CMAKE_REQ + add_executable(drs232_ldpc drs232_ldpc.c) + target_link_libraries(drs232_ldpc ${CMAKE_REQUIRED_LIBRARIES} codec2) + +-add_definitions(-DHORUS_L2_RX -DINTERLEAVER -DSCRAMBLER) +-add_executable(horus_demod horus_demod.c horus_api.c horus_l2.c fsk.c kiss_fft.c) ++add_definitions(-DHORUS_L2_RX -DINTERLEAVER -DSCRAMBLER -DRUN_TIME_TABLES) ++add_executable(horus_demod horus_demod.c horus_api.c horus_l2.c golay23.c fsk.c kiss_fft.c) + target_link_libraries(horus_demod ${CMAKE_REQUIRED_LIBRARIES}) + + install(TARGETS codec2 EXPORT codec2-config +Index: src/golay23.c +=================================================================== +--- src/golay23.c.orig ++++ src/golay23.c +@@ -53,7 +53,7 @@ static int inited = 0; + //since we want to avoid bit-reversing inside syndrome() we bit-reverse the polynomial instead + #define GOLAY_POLYNOMIAL 0xC75 //AE3 reversed + +-static int syndrome(int c) { ++int golay23_syndrome(int c) { + //could probably be done slightly smarter, but works + int x; + for (x = 11; x >= 0; x--) { +@@ -85,7 +85,7 @@ static int popcount(unsigned int c) { + #if defined(NO_TABLES) || defined(RUN_TIME_TABLES) + static int golay23_encode_no_tables(int c) { + c <<= 11; +- return syndrome(c) | c; ++ return golay23_syndrome(c) | c; + } + #endif + +@@ -101,7 +101,7 @@ static int golay23_decode_no_tables(int + + for (x = 0; x < 23; x++) { + int t; +- int s = syndrome(c); ++ int s = golay23_syndrome(c); + + if (popcount(s) <= 3) { + return unrotate(c ^ s, x) & 0xFFF; +@@ -109,7 +109,7 @@ static int golay23_decode_no_tables(int + + for (t = 0; t < 23; t++) { + int c2 = c ^ (1 << t); +- int s = syndrome(c2); ++ int s = golay23_syndrome(c2); + + if (popcount(s) <= 2) { + return unrotate(c2 ^ s, x) & 0xFFF; +@@ -138,13 +138,13 @@ void golay23_init(void) { + //1-bit errors + for (x = 0; x < 23; x++) { + int d = 1< + #include + #include "horus_l2.h" ++#include "golay23.h" ++ + + #ifdef HORUS_L2_UNITTEST + #define HORUS_L2_RX + #endif + +-#define RUN_TIME_TABLES +- + static char uw[] = {'$','$'}; + + /* Function Prototypes ------------------------------------------------*/ + +-int32_t get_syndrome(int32_t pattern); +-void golay23_init(void); +-int golay23_decode(int received_codeword); ++#ifdef INTERLEAVER + void interleave(unsigned char *inout, int nbytes, int dir); ++#endif ++#ifdef SCRAMBLER + void scramble(unsigned char *inout, int nbytes); ++#endif + + /* Functions ----------------------------------------------------------*/ + +@@ -177,7 +175,7 @@ int horus_l2_encode_tx_packet(unsigned c + #ifdef DEBUG0 + fprintf(stderr, " ningolay: %d ingolay: 0x%04x\n", ningolay, ingolay); + #endif +- golayparity = get_syndrome(ingolay<<11); ++ golayparity = golay23_syndrome(ingolay<<11); + ingolay = 0; + + #ifdef DEBUG0 +@@ -219,7 +217,7 @@ int horus_l2_encode_tx_packet(unsigned c + + if (ningolay % 12) { + ingolay >>= 1; +- golayparity = get_syndrome(ingolay<<12); ++ golayparity = golay23_syndrome(ingolay<<12); + #ifdef DEBUG0 + fprintf(stderr, " ningolay: %d ingolay: 0x%04x\n", ningolay, ingolay); + fprintf(stderr, " golayparity: 0x%04x\n", golayparity); +@@ -292,8 +290,10 @@ void horus_l2_decode_rx_packet(unsigned + unsigned char *pin = input_rx_data; + int ninbit, ingolay, ningolay, paritybyte, nparitybits; + int ninbyte, shift, inbit, golayparitybit, i, outbit, outbyte, noutbits, outdata; ++ #if defined(SCRAMBLER) || defined(INTERLEAVER) + int num_tx_data_bytes = horus_l2_get_num_tx_data_bytes(num_payload_data_bytes); +- ++ #endif ++ + /* optional scrambler and interleaver - we dont interleave UW */ + + #ifdef SCRAMBLER +@@ -878,291 +878,6 @@ int main(void) { + } + #endif + +-/*---------------------------------------------------------------------------*\ +- +- GOLAY FUNCTIONS +- +-\*---------------------------------------------------------------------------*/ +- +-/* File: golay23.c +- * Title: Encoder/decoder for a binary (23,12,7) Golay code +- * Author: Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) +- * Date: August 1994 +- * +- * The binary (23,12,7) Golay code is an example of a perfect code, that is, +- * the number of syndromes equals the number of correctable error patterns. +- * The minimum distance is 7, so all error patterns of Hamming weight up to +- * 3 can be corrected. The total number of these error patterns is: +- * +- * Number of errors Number of patterns +- * ---------------- ------------------ +- * 0 1 +- * 1 23 +- * 2 253 +- * 3 1771 +- * ---- +- * Total number of error patterns = 2048 = 2^{11} = number of syndromes +- * -- +- * number of redundant bits -------^ +- * +- * Because of its relatively low length (23), dimension (12) and number of +- * redundant bits (11), the binary (23,12,7) Golay code can be encoded and +- * decoded simply by using look-up tables. The program below uses a 16K +- * encoding table and an 8K decoding table. +- * +- * For more information, suggestions, or other ideas on implementing error +- * correcting codes, please contact me at (I'm temporarily in Japan, but +- * below is my U.S. address): +- * +- * Robert Morelos-Zaragoza +- * 770 S. Post Oak Ln. #200 +- * Houston, Texas 77056 +- * +- * email: robert@spectra.eng.hawaii.edu +- * +- * Homework: Add an overall parity-check bit to get the (24,12,8) +- * extended Golay code. +- * +- * COPYRIGHT NOTICE: This computer program is free for non-commercial purposes. +- * You may implement this program for any non-commercial application. You may +- * also implement this program for commercial purposes, provided that you +- * obtain my written permission. Any modification of this program is covered +- * by this copyright. +- * +- * == Copyright (c) 1994 Robert Morelos-Zaragoza. All rights reserved. == +- */ +- +-#include +-#include +-#include +-#define X22 0x00400000 /* vector representation of X^{22} */ +-#define X11 0x00000800 /* vector representation of X^{11} */ +-#define MASK12 0xfffff800 /* auxiliary vector for testing */ +-#define GENPOL 0x00000c75 /* generator polinomial, g(x) */ +- +-/* Global variables: +- * +- * pattern = error pattern, or information, or received vector +- * encoding_table[] = encoding table +- * decoding_table[] = decoding table +- * data = information bits, i(x) +- * codeword = code bits = x^{11}i(x) + (x^{11}i(x) mod g(x)) +- * numerr = number of errors = Hamming weight of error polynomial e(x) +- * position[] = error positions in the vector representation of e(x) +- * recd = representation of corrupted received polynomial r(x) = c(x) + e(x) +- * decerror = number of decoding errors +- * a[] = auxiliary array to generate correctable error patterns +- */ +- +-#ifdef HORUS_L2_RX +-static int inited = 0; +- +-#ifdef RUN_TIME_TABLES +-static int encoding_table[4096], decoding_table[2048]; +-#else +-#include "golayenctable.h" +-#include "golaydectable.h" +-#endif +- +-#ifdef RUN_TIME_TABLES +-static int arr2int(int a[], int r) +-/* +- * Convert a binary vector of Hamming weight r, and nonzero positions in +- * array a[1]...a[r], to a long integer \sum_{i=1}^r 2^{a[i]-1}. +- */ +-{ +- int i; +- long mul, result = 0, temp; +- +- for (i=1; i<=r; i++) { +- mul = 1; +- temp = a[i]-1; +- while (temp--) +- mul = mul << 1; +- result += mul; +- } +- return(result); +-} +-#endif +-#endif +- +-#ifdef HORUS_L2_RX +-void nextcomb(int n, int r, int a[]) +-/* +- * Calculate next r-combination of an n-set. +- */ +-{ +- int i, j; +- +- a[r]++; +- if (a[r] <= n) +- return; +- j = r - 1; +- while (a[j] == n - r + j) +- j--; +- for (i = r; i >= j; i--) +- a[i] = a[j] + i - j + 1; +- return; +-} +-#endif +- +-int32_t get_syndrome(int32_t pattern) +-/* +- * Compute the syndrome corresponding to the given pattern, i.e., the +- * remainder after dividing the pattern (when considering it as the vector +- * representation of a polynomial) by the generator polynomial, GENPOL. +- * In the program this pattern has several meanings: (1) pattern = infomation +- * bits, when constructing the encoding table; (2) pattern = error pattern, +- * when constructing the decoding table; and (3) pattern = received vector, to +- * obtain its syndrome in decoding. +- */ +-{ +- int32_t aux = X22; +- +- if (pattern >= X11) +- while (pattern & MASK12) { +- while (!(aux & pattern)) +- aux = aux >> 1; +- pattern ^= (aux/X11) * GENPOL; +- } +- return(pattern); +-} +- +-#ifdef HORUS_L2_RX +- +-/*---------------------------------------------------------------------------*\ +- +- FUNCTION....: golay23_init() +- AUTHOR......: David Rowe +- DATE CREATED: 3 March 2013 +- +- Call this once when you start your program to init the Golay tables. +- +-\*---------------------------------------------------------------------------*/ +- +-void golay23_init(void) { +-#ifdef RUN_TIME_TABLES +- int i; +- long temp; +- int a[4]; +- int pattern; +- +- /* +- * --------------------------------------------------------------------- +- * Generate ENCODING TABLE +- * +- * An entry to the table is an information vector, a 32-bit integer, +- * whose 12 least significant positions are the information bits. The +- * resulting value is a codeword in the (23,12,7) Golay code: A 32-bit +- * integer whose 23 least significant bits are coded bits: Of these, the +- * 12 most significant bits are information bits and the 11 least +- * significant bits are redundant bits (systematic encoding). +- * --------------------------------------------------------------------- +- */ +- for (pattern = 0; pattern < 4096; pattern++) { +- temp = pattern << 11; /* multiply information by X^{11} */ +- encoding_table[pattern] = temp + get_syndrome(temp);/* add redundancy */ +- } +- +- /* +- * --------------------------------------------------------------------- +- * Generate DECODING TABLE +- * +- * An entry to the decoding table is a syndrome and the resulting value +- * is the most likely error pattern. First an error pattern is generated. +- * Then its syndrome is calculated and used as a pointer to the table +- * where the error pattern value is stored. +- * --------------------------------------------------------------------- +- * +- * (1) Error patterns of WEIGHT 1 (SINGLE ERRORS) +- */ +- decoding_table[0] = 0; +- decoding_table[1] = 1; +- temp = 1; +- for (i=2; i<= 23; i++) { +- temp *= 2; +- decoding_table[get_syndrome(temp)] = temp; +- } +- /* +- * (2) Error patterns of WEIGHT 2 (DOUBLE ERRORS) +- */ +- a[1] = 1; a[2] = 2; +- temp = arr2int(a,2); +- decoding_table[get_syndrome(temp)] = temp; +- for (i=1; i<253; i++) { +- nextcomb(23,2,a); +- temp = arr2int(a,2); +- decoding_table[get_syndrome(temp)] = temp; +- } +- /* +- * (3) Error patterns of WEIGHT 3 (TRIPLE ERRORS) +- */ +- a[1] = 1; a[2] = 2; a[3] = 3; +- temp = arr2int(a,3); +- decoding_table[get_syndrome(temp)] = temp; +- for (i=1; i<1771; i++) { +- nextcomb(23,3,a); +- temp = arr2int(a,3); +- decoding_table[get_syndrome(temp)] = temp; +- } +-#endif +- inited = 1; +-} +- +-/*---------------------------------------------------------------------------*\ +- +- FUNCTION....: golay23_encode() +- AUTHOR......: David Rowe +- DATE CREATED: 3 March 2013 +- +- Given 12 bits of data retiurns a 23 bit codeword for transmission +- over the channel. +- +-\*---------------------------------------------------------------------------*/ +- +-int golay23_encode(int data) { +- assert(inited); +- assert(data <= 0xfff); +- +- //printf("data: 0x%x\n", data); +- return encoding_table[data]; +-} +- +-/*---------------------------------------------------------------------------*\ +- +- FUNCTION....: golay23_decode() +- AUTHOR......: David Rowe +- DATE CREATED: 3 March 2013 +- +- Given a 23 bit received codeword, returns the 12 bit corrected data. +- +-\*---------------------------------------------------------------------------*/ +- +-int golay23_decode(int received_codeword) { +- assert(inited); +- assert((received_codeword < (1<<23)) && (received_codeword >= 0)); +- +- //printf("syndrome: 0x%x\n", get_syndrome(received_codeword)); +- return received_codeword ^= decoding_table[get_syndrome(received_codeword)]; +-} +- +-int golay23_count_errors(int recd_codeword, int corrected_codeword) +-{ +- int errors = 0; +- int diff, i; +- +- diff = recd_codeword ^ corrected_codeword; +- for(i=0; i<23; i++) { +- if (diff & 0x1) +- errors++; +- diff >>= 1; +- } +- +- return errors; +-} +- +-#endif +- + // from http://stackoverflow.com/questions/10564491/function-to-calculate-a-crc16-checksum + + unsigned short horus_l2_gen_crc16(unsigned char* data_p, unsigned char length) { diff --git a/codec2-no_return_random.patch b/codec2-no_return_random.patch new file mode 100644 index 0000000..597e794 --- /dev/null +++ b/codec2-no_return_random.patch @@ -0,0 +1,12 @@ +Index: codec2-0.8.1/src/gp_interleaver.c +=================================================================== +--- codec2-0.8.1.orig/src/gp_interleaver.c ++++ codec2-0.8.1/src/gp_interleaver.c +@@ -74,6 +74,7 @@ int choose_interleaver_b(int Nbits) + /* if we get it means a Nbits we dont have in our table so choke */ + + assert(0); ++ return(0); + } + + diff --git a/codec2.changes b/codec2.changes index e9384b0..997cc4f 100644 --- a/codec2.changes +++ b/codec2.changes @@ -1,3 +1,22 @@ +------------------------------------------------------------------- +Sat Aug 11 07:14:59 UTC 2018 - tchvatal@suse.com + +- Apply upstream patch to fix ambiguous license situation: + * codec2-licensed-stuff.patch + +------------------------------------------------------------------- +Tue Jul 17 11:08:45 UTC 2018 - mpluskal@suse.com + +- Update to version 0.8.1: + * No upstream changelog provided +- Add codec2-no_return_random.patch +- Add baselibs.conf + +------------------------------------------------------------------- +Mon Jul 31 23:55:03 UTC 2017 - wk@ire.pw.edu.pl + +- Update to version 0.7 + ------------------------------------------------------------------- Tue May 30 12:25:22 UTC 2017 - mpluskal@suse.com diff --git a/codec2.spec b/codec2.spec index 7464aa8..f484faa 100644 --- a/codec2.spec +++ b/codec2.spec @@ -1,7 +1,7 @@ # # spec file for package codec2 # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,19 +16,21 @@ # -%define libname lib%{name}-0_6 +%define libname lib%{name}-0_8 Name: codec2 -Version: 0.6 +Version: 0.8.1 Release: 0 Summary: Low bit rate speech codec # octave and asterisk directories contain GPL-2.0 licensed code but its not -# used build, only used in examples subpackage. src/horus_l2.* is not free -# for non-commercial usage but is not used either. -License: LGPL-2.1 +# used build, only used in examples subpackage. +License: LGPL-2.1-only Group: Productivity/Hamradio/Other -Url: http://rowetel.com/codec2.html -Source: http://files.freedv.org/codec2/codec2-%{version}.tar.xz +URL: http://rowetel.com/codec2.html +Source: https://hobbes1069.fedorapeople.org/freetel/codec2/codec2-%{version}.tar.xz Source1: %{name}-rpmlintrc +Source2: baselibs.conf +Patch0: codec2-no_return_random.patch +Patch1: codec2-licensed-stuff.patch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: pkgconfig @@ -42,7 +44,7 @@ between 700 and 3200 bit/s. %package -n %{libname} Summary: Low bit rate speech codec -License: LGPL-2.1 +License: LGPL-2.1-only Group: System/Libraries %description -n %{libname} @@ -51,7 +53,7 @@ between 700 and 3200 bit/s. %package devel Summary: Development library for codec2 -License: GPL-2.0 AND LGPL-2.1 +License: GPL-2.0-only AND LGPL-2.1-only Group: Development/Libraries/C and C++ Requires: %{libname} = %{version} @@ -61,7 +63,7 @@ between 700 and 3200 bit/s. %package examples Summary: Example code for Codec 2 -License: GPL-2.0 AND LGPL-2.1 +License: GPL-2.0-only AND LGPL-2.1-only Group: Productivity/Hamradio/Other Requires: %{name}-devel = %{version} BuildArch: noarch @@ -71,16 +73,15 @@ Example code for Codec 2, including test voices and matlab/octave files. %prep %setup -q -# horus_l2.* is not needed for building and has to be removed due to -# licensing reasons -rm -rf src/horus_l2.* +%patch0 -p1 +%patch1 -p0 %build %cmake \ -DINSTALL_EXAMPLES=TRUE \ -DUNITTEST=TRUE \ -Wno-dev -make %{?_smp_mflags} +%make_jobs %install %cmake_install @@ -105,8 +106,8 @@ EOF %postun -n %{libname} -p /sbin/ldconfig %files -%defattr(-,root,root) -%doc COPYING README README_fdmdv.txt +%license COPYING +%doc README README_fdmdv.txt %{_bindir}/c2dec %{_bindir}/c2demo %{_bindir}/c2enc @@ -125,17 +126,14 @@ EOF %{_bindir}/insert_errors %files -n %{libname} -%defattr(-,root,root) %{_libdir}/libcodec2.so.* %files devel -%defattr(-, root, root) %{_includedir}/* %{_libdir}/libcodec2.so %{_libdir}/pkgconfig/%{name}.pc %files examples -%defattr(-,root,root) %{_datadir}/%{name}/ %changelog