From 26f2e7cd2887960b0131525783938da90c2a7a4b Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Wed, 25 Aug 2021 18:50:20 +0300 Subject: [PATCH] Add G.719 support on Linux --- .gitignore | 10 +++++++++- CMakeLists.txt | 27 ++++++++++++++++++++++++-- cmake/vgmstream.cmake | 5 ++++- ext_libs/libg719_decode/CMakeLists.txt | 11 +++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 ext_libs/libg719_decode/CMakeLists.txt diff --git a/.gitignore b/.gitignore index b0ec7495..82c9d62a 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,12 @@ Release # cmake stuff /build -/cmake-build* \ No newline at end of file +/cmake-build* +CMakeCache.txt +CMakeFiles +/lib +/cli/vgmstream_cli +/cli/vgmstream123 +/audacious/vgmstream.so +/audacious/Makefile +cmake_install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a41d0988..44126d11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,9 +49,12 @@ set_ffmpeg(ON FALSE) option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF) set(MAIATRAC3PLUS_PATH CACHE PATH "Path to MAIATRAC3+") option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON) +option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON) +if(NOT WIN32) + set(G719_PATH CACHE PATH "Path to G.719 decoder") +endif() if(WIN32) # May need to see if it is possible to get these to work on non-Windows systems too - option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON) option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON) option(USE_CELT "Use libcelt for support of FSB CELT versions 0.6.1 and 0.11.0" ON) option(USE_SPEEX "Use libspeex for support of SPEEX" ON) @@ -221,6 +224,26 @@ if(USE_MAIATRAC3PLUS) message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)") endif() endif() +if(NOT WIN32 AND USE_G719) + if(G719_PATH) + configure_file( + ${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt + ${G719_PATH}/CMakeLists.txt + COPYONLY) + add_subdirectory(${G719_PATH}) + else() + include(FetchContent) + FetchContent_Populate(libg719_decode + GIT_REPOSITORY https://github.com/kode54/libg719_decode.git + SOURCE_DIR ${VGM_SOURCE_DIR}/dependencies/libg719_decode + ) + configure_file( + ${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt + ${VGM_SOURCE_DIR}/dependencies/libg719_decode/CMakeLists.txt + COPYONLY) + add_subdirectory(${libg719_decode_SOURCE_DIR}) + endif() +endif() add_subdirectory(src) if(WIN32) add_subdirectory(ext_libs) @@ -273,8 +296,8 @@ message(STATUS " Vorbis: ${USE_VORBIS}") message(STATUS " FFmpeg: ${USE_FFMPEG}") message(STATUS " MAIATRAC3+: ${USE_MAIATRAC3PLUS}") message(STATUS " G.722.1: ${USE_G7221}") +message(STATUS " G.719: ${USE_G719}") if(WIN32) - message(STATUS " G.719: ${USE_G719}") message(STATUS " ATRAC9: ${USE_ATRAC9}") message(STATUS " FSB CELT: ${USE_CELT}") message(STATUS " SPEEX: ${USE_SPEEX}") diff --git a/cmake/vgmstream.cmake b/cmake/vgmstream.cmake index 8c89abf0..5ffb8446 100644 --- a/cmake/vgmstream.cmake +++ b/cmake/vgmstream.cmake @@ -79,10 +79,13 @@ macro(setup_target TARGET) if(USE_G719) target_compile_definitions(${TARGET} PRIVATE VGM_USE_G719) - if(LINK) + if(WIN32 AND LINK) add_dependencies(${TARGET} libg719_decode) target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg719_decode.lib) endif() + if(NOT WIN32 AND LINK) + target_link_libraries(${TARGET} g719_decode) + endif() endif() if(USE_MAIATRAC3PLUS) diff --git a/ext_libs/libg719_decode/CMakeLists.txt b/ext_libs/libg719_decode/CMakeLists.txt new file mode 100644 index 00000000..09fffe79 --- /dev/null +++ b/ext_libs/libg719_decode/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.18) +project(libg719_decode) + +file(GLOB_RECURSE SOURCES "reference_code/*.c") + +add_library(g719_decode STATIC g719.c ${SOURCES}) + +target_include_directories(g719_decode PRIVATE reference_code/include) + +set_property(TARGET g719_decode PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_definitions(g719_decode PRIVATE VAR_ARRAYS)