From 3536436b50e4798361aab3c64a6ff212377af5b5 Mon Sep 17 00:00:00 2001 From: Richard Shaw Date: Fri, 22 May 2020 12:09:30 -0500 Subject: [PATCH] Initial import. --- .gitignore | 2 + lpcnetfreedv-private_libs.patch | 15 ++++++ lpcnetfreedv-vector-updates.patch | 62 +++++++++++++++++++++++ lpcnetfreedv.spec | 83 +++++++++++++++++++++++++++++++ sources | 2 + 5 files changed, 164 insertions(+) create mode 100644 .gitignore create mode 100644 lpcnetfreedv-private_libs.patch create mode 100644 lpcnetfreedv-vector-updates.patch create mode 100644 lpcnetfreedv.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0b0f94b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/LPCNet-0.2.tar.gz +/lpcnet_191005_v1.0.tgz diff --git a/lpcnetfreedv-private_libs.patch b/lpcnetfreedv-private_libs.patch new file mode 100644 index 0000000..4b79232 --- /dev/null +++ b/lpcnetfreedv-private_libs.patch @@ -0,0 +1,15 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 6c49f5e..a0b9f0a 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -29,8 +29,8 @@ target_include_directories(lpcnetfreedv INTERFACE + $ + ) + install(TARGETS lpcnetfreedv EXPORT lpcnetfreedv-config +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/lpcnetfreedv ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/lpcnetfreedv + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lpcnet + ) diff --git a/lpcnetfreedv-vector-updates.patch b/lpcnetfreedv-vector-updates.patch new file mode 100644 index 0000000..6000514 --- /dev/null +++ b/lpcnetfreedv-vector-updates.patch @@ -0,0 +1,62 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 680f52c..e536f30 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -52,6 +52,9 @@ message(STATUS "LPCNet version: ${LPCNET_VERSION}") + # Set default flags + set(CMAKE_C_FLAGS "-Wall -W -Wextra -Wno-unused-function -O3 -g -I. -MD ${CMAKE_C_FLAGS} -DENABLE_ASSERTIONS") + ++# Arch specific stuff here ++message(STATUS "Host system arch is: ${CMAKE_SYSTEM_PROCESSOR}") ++ + # Detection of available CPU optimizations + if(NOT DISABLE_CPU_OPTIMIZATION) + if(UNIX AND NOT APPLE) +@@ -87,7 +90,7 @@ elseif(${AVX} OR ${AVX} GREATER 0) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx") + endif() + +-# RPi ++# RPi / ARM 32bit + if(${NEON} OR ${NEON} GREATER 0) + message(STATUS "neon processor flags found or enabled.") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon -march=armv8-a -mtune=cortex-a53") +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 41a78dc..6c49f5e 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -49,7 +49,7 @@ target_link_libraries(dump_data lpcnetfreedv m codec2) + add_executable(test_lpcnet test_lpcnet.c) + target_link_libraries(test_lpcnet lpcnetfreedv m codec2) + +-if(AVX OR AVX2) ++if(AVX OR AVX2 OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + add_executable(test_vec test_vec.c) + target_link_libraries(test_vec m) + else() +diff --git a/src/nnet.c b/src/nnet.c +index 8ad4a26..ccb9c94 100644 +--- a/src/nnet.c ++++ b/src/nnet.c +@@ -43,7 +43,7 @@ + + #ifdef __AVX__ + #include "vec_avx.h" +-#elif __ARM_NEON__ ++#elif __ARM_NEON__ || __aarch64__ + #include "vec_neon.h" + #else + #warning Compiling without any vectorization. This code will be very slow +diff --git a/src/test_vec.c b/src/test_vec.c +index 09b51e7..254292b 100644 +--- a/src/test_vec.c ++++ b/src/test_vec.c +@@ -26,7 +26,7 @@ const char simd[]="AVX2"; + #else + const char simd[]="AVX"; + #endif +-#elif __ARM_NEON__ ++#elif __ARM_NEON__ || __aarch64__ + #include "vec_neon.h" + const char simd[]="NEON"; + #else diff --git a/lpcnetfreedv.spec b/lpcnetfreedv.spec new file mode 100644 index 0000000..fd18f91 --- /dev/null +++ b/lpcnetfreedv.spec @@ -0,0 +1,83 @@ +Name: lpcnetfreedv +Version: 0.2 +Release: 2%{?dist} +Summary: LPCNet for FreeDV + +License: BSD +URL: https://github.com/drowe67/LPCNet +Source0: https://github.com/drowe67/LPCNet/archive/v%{version}/LPCNet-%{version}.tar.gz +Source1: http://rowetel.com/downloads/deep/lpcnet_191005_v1.0.tgz + +# Fixes for aarch64 which has NEON instructions natively +Patch0: lpcnetfreedv-vector-updates.patch +# Make library private for FreeDV +Patch1: lpcnetfreedv-private_libs.patch + +BuildRequires: cmake gcc +BuildRequires: codec2-devel + +%description +Experimental version of LPCNet that has been used to develop FreeDV 2020 - a HF +radio Digial Voice mode for over the air experimentation with Neural Net speech +coding. Possibly the first use of Neural Net speech coding in real world +operation. + +%package devel +Requires: %{name}%{?_isa} = %{version}-%{release} +Summary: Development files and tools for LPCNet + +%description devel +%{summary}. + + +%prep +%autosetup -p1 -n LPCNet-%{version} + + +%build +mkdir build && pushd build +# Add model data archive to the build directory so CMake finds it. +cp %{SOURCE1} . + +# We need to force optimizations to specific values since the build system and +# host system will likely be different. +%ifarch i686 x86_64 + %global _cpuopt "-DAVX=TRUE" +%endif +%ifarch armv7hl + %global _cpuopt "-DNEON=TRUE" +%endif +%ifarch aarch64 ppc64le s390x + # NEON instructions are native in arm64. + %global _cpuopt "" +%endif + +%cmake -DDISABLE_CPU_OPTIMIZATION=TRUE %{_cpuopt} ../ +%make_build + + +%install +pushd build +%make_install + + +%files +%license COPYING +%doc README.md +%{_libdir}/%{name}/lib%{name}.so + +%files devel +%{_bindir}/* +%{_includedir}/lpcnet/ +%{_libdir}/cmake/lpcnetfreedv/ + + +%changelog +* Wed May 13 2020 Richard Shaw - 0.2-2 +- Update per reviewer comments. +- Renamed package to lpcnetfreedv (same as library), repo will be renamed in + the near future. +- Made library private as it is essentially a plugin for freedv. + +* Mon Apr 20 2020 Richard Shaw - 0.2-1 +- Initial packaging. diff --git a/sources b/sources new file mode 100644 index 0000000..2917810 --- /dev/null +++ b/sources @@ -0,0 +1,2 @@ +SHA512 (LPCNet-0.2.tar.gz) = 3fa581512b7431bf4df41a0abc0c4f2b262d57f1bf4756dfb23c774393dccd90bb9f7f874e5192aaabd17ed780007602f363d545d3cfb53bb9ee7022ed4a966c +SHA512 (lpcnet_191005_v1.0.tgz) = ffa52c492f2ef1ca09c34b321b36d9dd26f6d3a2e807f4601858b45a1c6159b45b846bfaf3d37c74acead955c0ad47c2d06cb08b8347d5ec441cd751f2110167