From 5480d3d59d5d27b5d21ce50478cdfcf64e537cd8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 14 Jan 2023 08:45:12 -0600 Subject: [PATCH] Switch to faster nanors Reed-Solomon implementation (#753) --- .gitmodules | 4 ++++ CMakeLists.txt | 10 +++++++--- src/stream.cpp | 3 +-- third-party/nanors | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) create mode 160000 third-party/nanors diff --git a/.gitmodules b/.gitmodules index b79222a2..c6b2af2c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -42,3 +42,7 @@ path = third-party/ffmpeg-macos-aarch64 url = https://github.com/LizardByte/build-deps branch = ffmpeg-macos-aarch64 +[submodule "third-party/nanors"] + path = third-party/nanors + url = https://github.com/sleepybishop/nanors.git + branch = master diff --git a/CMakeLists.txt b/CMakeLists.txt index 855daef4..b88bba2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,8 +337,8 @@ configure_file(version.h.in version.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(SUNSHINE_TARGET_FILES - third-party/moonlight-common-c/reedsolomon/rs.c - third-party/moonlight-common-c/reedsolomon/rs.h + third-party/nanors/rs.c + third-party/nanors/rs.h third-party/moonlight-common-c/src/Input.h third-party/moonlight-common-c/src/Rtsp.h third-party/moonlight-common-c/src/RtspParser.c @@ -385,6 +385,9 @@ set(SUNSHINE_TARGET_FILES set_source_files_properties(src/upnp.cpp PROPERTIES COMPILE_FLAGS -Wno-pedantic) +set_source_files_properties(third-party/nanors/rs.c + PROPERTIES COMPILE_FLAGS "-include deps/obl/autoshim.h -ftree-vectorize") + # Pre-compiled binaries if(WIN32) set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-windows-x86_64") @@ -424,7 +427,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/third-party ${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/enet/include - ${CMAKE_CURRENT_SOURCE_DIR}/third-party/moonlight-common-c/reedsolomon + ${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors + ${CMAKE_CURRENT_SOURCE_DIR}/third-party/nanors/deps/obl ${FFMPEG_INCLUDE_DIRS} ${PLATFORM_INCLUDE_DIRS} ) diff --git a/src/stream.cpp b/src/stream.cpp index 6b470ddb..78667aa1 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -1077,8 +1077,7 @@ void audioBroadcastThread(udp::socket &sock) { // works correctly. This is possible because the data and FEC shard count is // constant and known in advance. const unsigned char parity[] = { 0x77, 0x40, 0x38, 0x0e, 0xc7, 0xa7, 0x0d, 0x6c }; - memcpy(&rs.get()->m[16], parity, sizeof(parity)); - memcpy(rs.get()->parity, parity, sizeof(parity)); + memcpy(rs.get()->p, parity, sizeof(parity)); audio_packet->rtp.header = 0x80; audio_packet->rtp.packetType = 97; diff --git a/third-party/nanors b/third-party/nanors new file mode 160000 index 00000000..395e5ada --- /dev/null +++ b/third-party/nanors @@ -0,0 +1 @@ +Subproject commit 395e5ada44dd8d5974eaf6bb6b17f23406e3ca72