From 27e2035aa8a3b01ea5e0f41df7a247a89b0e6bc3 Mon Sep 17 00:00:00 2001 From: Greisberger Christophe Date: Sat, 30 May 2026 10:37:56 +0200 Subject: [PATCH] Add new port: libtwolame - MPEG Audio Layer 2 encoder for broadcast-quality audio (#51728) Co-authored-by: Kai Pastor Co-authored-by: Victor Romero --- .../patches/001-fix-tl-api-export.patch | 11 +++++ .../patches/002-disable-doc-subdir.patch | 25 ++++++++++++ .../patches/003-fix-kr-declaration.patch | 14 +++++++ .../patches/004-fix-frontend-msvc.patch | 17 ++++++++ .../patches/005-fix-pc-in-case.patch | 13 ++++++ ports/libtwolame/portfile.cmake | 40 +++++++++++++++++++ ports/libtwolame/usage | 6 +++ ports/libtwolame/vcpkg.json | 19 +++++++++ versions/baseline.json | 4 ++ versions/l-/libtwolame.json | 9 +++++ 10 files changed, 158 insertions(+) create mode 100644 ports/libtwolame/patches/001-fix-tl-api-export.patch create mode 100644 ports/libtwolame/patches/002-disable-doc-subdir.patch create mode 100644 ports/libtwolame/patches/003-fix-kr-declaration.patch create mode 100644 ports/libtwolame/patches/004-fix-frontend-msvc.patch create mode 100644 ports/libtwolame/patches/005-fix-pc-in-case.patch create mode 100644 ports/libtwolame/portfile.cmake create mode 100644 ports/libtwolame/usage create mode 100644 ports/libtwolame/vcpkg.json create mode 100644 versions/l-/libtwolame.json diff --git a/ports/libtwolame/patches/001-fix-tl-api-export.patch b/ports/libtwolame/patches/001-fix-tl-api-export.patch new file mode 100644 index 0000000000..622944fc40 --- /dev/null +++ b/ports/libtwolame/patches/001-fix-tl-api-export.patch @@ -0,0 +1,11 @@ +--- a/libtwolame/twolame.h ++++ b/libtwolame/twolame.h +@@ -263,7 +263,7 @@ + * \return The number of bytes put in output buffer + * or a negative value on error + */ +-int twolame_encode_buffer_float32_interleaved(twolame_options * glopts, ++TL_API int twolame_encode_buffer_float32_interleaved(twolame_options * glopts, + const float pcm[], + int num_samples, + unsigned char *mp2buffer, int mp2buffer_size); diff --git a/ports/libtwolame/patches/002-disable-doc-subdir.patch b/ports/libtwolame/patches/002-disable-doc-subdir.patch new file mode 100644 index 0000000000..2e2cca723a --- /dev/null +++ b/ports/libtwolame/patches/002-disable-doc-subdir.patch @@ -0,0 +1,25 @@ +diff --git a/Makefile.am b/Makefile.am +index 6504bf7..a00cb6d 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,6 +1,6 @@ + ACLOCAL_AMFLAGS = -I build-scripts + +-SUBDIRS = . libtwolame frontend simplefrontend doc tests ++SUBDIRS = . libtwolame frontend simplefrontend tests + + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = twolame.pc +@@ -23,11 +23,7 @@ ChangeLog: + [ -d .git ] && git log > ChangeLog || true + + pkgdocdir = @docdir@ +-pkgdoc_DATA = \ +- AUTHORS \ +- COPYING \ +- README \ +- NEWS ++pkgdoc_DATA = + + EXTRA_DIST = \ + $(pkgdoc_DATA) \ diff --git a/ports/libtwolame/patches/003-fix-kr-declaration.patch b/ports/libtwolame/patches/003-fix-kr-declaration.patch new file mode 100644 index 0000000000..b3696f986e --- /dev/null +++ b/ports/libtwolame/patches/003-fix-kr-declaration.patch @@ -0,0 +1,14 @@ +--- a/libtwolame/psycho_2.c ++++ b/libtwolame/psycho_2.c +@@ -54,10 +54,7 @@ + 4.5, 4.5, 4.5, 3.5, 3.5, 3.5 + }; + +-static void psycho_2_read_absthr(absthr, table) +-FLOAT *absthr; +-int table; +-{ ++static void psycho_2_read_absthr(FLOAT *absthr, int table) { + int j; + #include "psycho_2_absthr.h" + diff --git a/ports/libtwolame/patches/004-fix-frontend-msvc.patch b/ports/libtwolame/patches/004-fix-frontend-msvc.patch new file mode 100644 index 0000000000..4703d31d58 --- /dev/null +++ b/ports/libtwolame/patches/004-fix-frontend-msvc.patch @@ -0,0 +1,17 @@ +--- a/frontend/frontend.c ++++ b/frontend/frontend.c +@@ -20,7 +20,14 @@ + + #include + #include + #include ++ ++#ifdef HAVE_CONFIG_H ++#include "config.h" ++#endif ++ ++#ifdef HAVE_UNISTD_H + #include ++#endif + #include + diff --git a/ports/libtwolame/patches/005-fix-pc-in-case.patch b/ports/libtwolame/patches/005-fix-pc-in-case.patch new file mode 100644 index 0000000000..7e20aa6e0c --- /dev/null +++ b/ports/libtwolame/patches/005-fix-pc-in-case.patch @@ -0,0 +1,13 @@ +diff --git a/twolame.pc.in b/twolame.pc.in +index 0395b69..882c984 100644 +--- a/twolame.pc.in ++++ b/twolame.pc.in +@@ -8,6 +8,6 @@ Description: An optimized MPEG Audio Layer 2 encoder + Requires: + Version: @VERSION@ + Libs: -L${libdir} -ltwolame +-Libs.Private: @LIBS@ ++Libs.private: @LIBS@ + Cflags: -I${includedir} + Cflags.private: -DLIBTWOLAME_STATIC + \ No newline at end of file diff --git a/ports/libtwolame/portfile.cmake b/ports/libtwolame/portfile.cmake new file mode 100644 index 0000000000..2f23208bef --- /dev/null +++ b/ports/libtwolame/portfile.cmake @@ -0,0 +1,40 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO njh/twolame + REF "${VERSION}" + SHA512 9a0d3ef430ca93b561caa7e56fe60c126135b1c36294a280fa21699402b3922a3992035f3d421f3bbe131cdc04459cc907059dfe0c2f512427f305fe3936e54d + HEAD_REF main + PATCHES + patches/001-fix-tl-api-export.patch + patches/002-disable-doc-subdir.patch + patches/003-fix-kr-declaration.patch + patches/004-fix-frontend-msvc.patch + patches/005-fix-pc-in-case.patch +) + +set(options "") +if("tool" IN_LIST FEATURES) + list(APPEND options "--enable-sndfile") + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + list(APPEND options "LIBS=\$LIBS -lgetopt") + endif() +else() + list(APPEND options "--disable-sndfile") +endif() + +vcpkg_configure_make( + SOURCE_PATH "${SOURCE_PATH}" + AUTOCONFIG + OPTIONS + ${options} +) + +vcpkg_install_make() +vcpkg_fixup_pkgconfig() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/tools") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") diff --git a/ports/libtwolame/usage b/ports/libtwolame/usage new file mode 100644 index 0000000000..4ad92c8369 --- /dev/null +++ b/ports/libtwolame/usage @@ -0,0 +1,6 @@ +The package libtwolame can be imported via CMake FindPkgConfig module: + + find_package(PkgConfig REQUIRED) + pkg_check_modules(twolame REQUIRED IMPORTED_TARGET twolame) + target_link_libraries(main PkgConfig::twolame) + \ No newline at end of file diff --git a/ports/libtwolame/vcpkg.json b/ports/libtwolame/vcpkg.json new file mode 100644 index 0000000000..472d0f0392 --- /dev/null +++ b/ports/libtwolame/vcpkg.json @@ -0,0 +1,19 @@ +{ + "name": "libtwolame", + "version": "0.4.0", + "description": "TwoLAME is an optimised MPEG Audio Layer 2 (MP2) encoder", + "homepage": "https://www.twolame.org", + "license": "LGPL-2.1-or-later", + "features": { + "tool": { + "description": "Build the twolame command-line frontend", + "dependencies": [ + { + "name": "getopt-win32", + "platform": "windows & !mingw" + }, + "libsndfile" + ] + } + } +} diff --git a/versions/baseline.json b/versions/baseline.json index 4c2a5814f3..b40cc660f6 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5768,6 +5768,10 @@ "baseline": "1.4.0", "port-version": 0 }, + "libtwolame": { + "baseline": "0.4.0", + "port-version": 0 + }, "libu2f-server": { "baseline": "1.1.0", "port-version": 6 diff --git a/versions/l-/libtwolame.json b/versions/l-/libtwolame.json new file mode 100644 index 0000000000..b304507923 --- /dev/null +++ b/versions/l-/libtwolame.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "e00ea4eb67bd8ad572b6883e178aed7856a5f68b", + "version": "0.4.0", + "port-version": 0 + } + ] +}