mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-17 01:24:47 +00:00
musly: add patches for FFmpeg 7, C++17, and external deps
This commit is contained in:
parent
c3c5af2c4b
commit
7245ee2b5d
341
pkgs/by-name/mu/musly/0001-Fix-build-with-FFmpeg-7.patch
Normal file
341
pkgs/by-name/mu/musly/0001-Fix-build-with-FFmpeg-7.patch
Normal file
@ -0,0 +1,341 @@
|
|||||||
|
From ab430ea4460aba050d97d3e3a712a3b6dd809db9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Emily <hello@emily.moe>
|
||||||
|
Date: Mon, 15 Jul 2024 00:41:04 +0100
|
||||||
|
Subject: [PATCH 1/4] Fix build with FFmpeg 7
|
||||||
|
|
||||||
|
---
|
||||||
|
libmusly/CMakeLists.txt | 5 --
|
||||||
|
libmusly/decoders/libav.cpp | 136 +++++++++++-------------------------
|
||||||
|
2 files changed, 42 insertions(+), 99 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libmusly/CMakeLists.txt b/libmusly/CMakeLists.txt
|
||||||
|
index d6d3680..98151df 100644
|
||||||
|
--- a/libmusly/CMakeLists.txt
|
||||||
|
+++ b/libmusly/CMakeLists.txt
|
||||||
|
@@ -16,11 +16,6 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
|
||||||
|
PROPERTIES COMPILE_FLAGS "-DLIBMUSLY_EXTERNAL ${LIBMUSLY_EXTERNAL_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-if(EXISTS "${LIBAV_INCLUDE_DIRS}/libavutil/channel_layout.h")
|
||||||
|
- set_source_files_properties(decoders/libav.cpp
|
||||||
|
- PROPERTIES COMPILE_FLAGS "-DHAVE_AVUTIL_CHANNEL_LAYOUT")
|
||||||
|
-endif()
|
||||||
|
-
|
||||||
|
if(USE_OPENMP AND OPENMP_FOUND)
|
||||||
|
# disable OpenMP for kiss FFT, it slows things down terribly
|
||||||
|
set_source_files_properties(kissfft/kiss_fft.c
|
||||||
|
diff --git a/libmusly/decoders/libav.cpp b/libmusly/decoders/libav.cpp
|
||||||
|
index a78b904..90f93ae 100644
|
||||||
|
--- a/libmusly/decoders/libav.cpp
|
||||||
|
+++ b/libmusly/decoders/libav.cpp
|
||||||
|
@@ -20,37 +20,13 @@
|
||||||
|
extern "C" {
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
-#ifdef HAVE_AVUTIL_CHANNEL_LAYOUT
|
||||||
|
#include <libavutil/channel_layout.h>
|
||||||
|
-#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "minilog.h"
|
||||||
|
#include "resampler.h"
|
||||||
|
#include "libav.h"
|
||||||
|
|
||||||
|
-// We define some macros to be compatible to different libav versions
|
||||||
|
-// without spreading #if and #else all over the place.
|
||||||
|
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 45, 101)
|
||||||
|
-#define AV_FRAME_ALLOC avcodec_alloc_frame
|
||||||
|
-#define AV_FRAME_UNREF avcodec_get_frame_defaults
|
||||||
|
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 28, 0)
|
||||||
|
-#define AV_FRAME_FREE(X) av_free(*(X))
|
||||||
|
-#else
|
||||||
|
-#define AV_FRAME_FREE avcodec_free_frame
|
||||||
|
-#endif
|
||||||
|
-#else
|
||||||
|
-#define AV_FRAME_ALLOC av_frame_alloc
|
||||||
|
-#define AV_FRAME_UNREF av_frame_unref
|
||||||
|
-#define AV_FRAME_FREE av_frame_free
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 7, 0)
|
||||||
|
-#define AV_PACKET_UNREF av_free_packet
|
||||||
|
-#else
|
||||||
|
-#define AV_PACKET_UNREF av_packet_unref
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
namespace musly {
|
||||||
|
namespace decoders {
|
||||||
|
|
||||||
|
@@ -58,12 +34,6 @@ MUSLY_DECODER_REGIMPL(libav, 0);
|
||||||
|
|
||||||
|
libav::libav()
|
||||||
|
{
|
||||||
|
-#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
|
||||||
|
- av_register_all();
|
||||||
|
-#endif
|
||||||
|
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
|
||||||
|
- avcodec_register_all();
|
||||||
|
-#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -177,13 +147,7 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
AVStream *st = fmtx->streams[audio_stream_idx];
|
||||||
|
|
||||||
|
// find a decoder for the stream
|
||||||
|
-#if (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 14, 0)) || ((LIBAVCODEC_VERSION_MICRO >= 100) && (LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 33, 100)))
|
||||||
|
- // old libav version (libavcodec < 57.14 for libav, < 57.33 for ffmpeg):
|
||||||
|
- // stream has a codec context we can use
|
||||||
|
- AVCodecContext *decx = st->codec;
|
||||||
|
- #define AVCODEC_FREE_CONTEXT(x)
|
||||||
|
-#else
|
||||||
|
- // new libav version: need to create codec context for stream
|
||||||
|
+ // need to create codec context for stream
|
||||||
|
AVCodecParameters *decp = st->codecpar;
|
||||||
|
AVCodecContext *decx = avcodec_alloc_context3(NULL);
|
||||||
|
if (!decx) {
|
||||||
|
@@ -200,71 +164,63 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
return std::vector<float>(0);
|
||||||
|
}
|
||||||
|
- #if LIBAVCODEC_VERSION_MICRO >= 100
|
||||||
|
- #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,3,102)
|
||||||
|
- // only available in ffmpeg, deprecated after 58
|
||||||
|
- av_codec_set_pkt_timebase(decx, st->time_base);
|
||||||
|
- #endif
|
||||||
|
- #endif
|
||||||
|
- #define AVCODEC_FREE_CONTEXT(x) avcodec_free_context(x)
|
||||||
|
-#endif
|
||||||
|
- AVCodec *dec = avcodec_find_decoder(decx->codec_id);
|
||||||
|
+ const AVCodec *dec = avcodec_find_decoder(decx->codec_id);
|
||||||
|
if (!dec) {
|
||||||
|
MINILOG(logERROR) << "Could not find codec.";
|
||||||
|
|
||||||
|
- AVCODEC_FREE_CONTEXT(&decx);
|
||||||
|
+ avcodec_free_context(&decx);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
return std::vector<float>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// open the decoder
|
||||||
|
// (kindly ask for stereo downmix and floats, but not all decoders care)
|
||||||
|
- decx->request_channel_layout = AV_CH_LAYOUT_STEREO_DOWNMIX;
|
||||||
|
decx->request_sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp critical
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
- avret = avcodec_open2(decx, dec, NULL);
|
||||||
|
+ AVDictionary *options = NULL;
|
||||||
|
+ av_dict_set(&options, "downmix", "stereo", 0);
|
||||||
|
+ avret = avcodec_open2(decx, dec, &options);
|
||||||
|
}
|
||||||
|
if (avret < 0) {
|
||||||
|
MINILOG(logERROR) << "Could not open codec.";
|
||||||
|
|
||||||
|
- AVCODEC_FREE_CONTEXT(&decx);
|
||||||
|
+ avcodec_free_context(&decx);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
return std::vector<float>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Currently only mono and stereo files are supported.
|
||||||
|
- if ((decx->channels != 1) && (decx->channels != 2)) {
|
||||||
|
+ if ((decx->ch_layout.nb_channels != 1) && (decx->ch_layout.nb_channels != 2)) {
|
||||||
|
MINILOG(logWARNING) << "Unsupported number of channels: "
|
||||||
|
- << decx->channels;
|
||||||
|
+ << decx->ch_layout.nb_channels;
|
||||||
|
|
||||||
|
- AVCODEC_FREE_CONTEXT(&decx);
|
||||||
|
+ avcodec_free_context(&decx);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
return std::vector<float>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate a frame
|
||||||
|
- AVFrame* frame = AV_FRAME_ALLOC();
|
||||||
|
+ AVFrame* frame = av_frame_alloc();
|
||||||
|
if (!frame) {
|
||||||
|
MINILOG(logWARNING) << "Could not allocate frame";
|
||||||
|
|
||||||
|
- AVCODEC_FREE_CONTEXT(&decx);
|
||||||
|
+ avcodec_free_context(&decx);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
return std::vector<float>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocate and initialize a packet
|
||||||
|
- AVPacket pkt;
|
||||||
|
- av_init_packet(&pkt);
|
||||||
|
- pkt.data = NULL;
|
||||||
|
- pkt.size = 0;
|
||||||
|
+ AVPacket* pkt = av_packet_alloc();
|
||||||
|
+ pkt->data = NULL;
|
||||||
|
+ pkt->size = 0;
|
||||||
|
int got_frame = 0;
|
||||||
|
|
||||||
|
// configuration
|
||||||
|
const int input_stride = av_get_bytes_per_sample(decx->sample_fmt);
|
||||||
|
- const int num_planes = av_sample_fmt_is_planar(decx->sample_fmt) ? decx->channels : 1;
|
||||||
|
+ const int num_planes = av_sample_fmt_is_planar(decx->sample_fmt) ? decx->ch_layout.nb_channels : 1;
|
||||||
|
const int output_stride = sizeof(float) * num_planes;
|
||||||
|
int decode_samples; // how many samples to decode; zero to decode all
|
||||||
|
|
||||||
|
@@ -296,7 +252,7 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
// fault when trying to access frame->data[i] for i > 0 further below)
|
||||||
|
if ((excerpt_start > 0) and (av_seek_frame(fmtx, audio_stream_idx,
|
||||||
|
excerpt_start * st->time_base.den / st->time_base.num,
|
||||||
|
- AVSEEK_FLAG_BACKWARD || AVSEEK_FLAG_ANY) >= 0)) {
|
||||||
|
+ AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_ANY) >= 0)) {
|
||||||
|
// skipping went fine: decode only what's needed
|
||||||
|
decode_samples = excerpt_length * decx->sample_rate;
|
||||||
|
excerpt_start = 0;
|
||||||
|
@@ -333,7 +289,7 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
// excerpt_start tells us up to how many seconds to cut from the beginning.
|
||||||
|
|
||||||
|
// read packets
|
||||||
|
- const int channels = decx->channels;
|
||||||
|
+ const int channels = decx->ch_layout.nb_channels;
|
||||||
|
const int sample_rate = decx->sample_rate;
|
||||||
|
float* buffer = NULL;
|
||||||
|
int buffersize = 0;
|
||||||
|
@@ -344,35 +300,29 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
{
|
||||||
|
// skip all frames that are not part of the audio stream, and spurious
|
||||||
|
// frames possibly found after seeking (wrong channels / sample_rate)
|
||||||
|
- while (((avret = av_read_frame(fmtx, &pkt)) >= 0)
|
||||||
|
- && ((pkt.stream_index != audio_stream_idx) ||
|
||||||
|
- (decx->channels != channels) ||
|
||||||
|
+ while (((avret = av_read_frame(fmtx, pkt)) >= 0)
|
||||||
|
+ && ((pkt->stream_index != audio_stream_idx) ||
|
||||||
|
+ (decx->ch_layout.nb_channels != channels) ||
|
||||||
|
(decx->sample_rate != sample_rate)))
|
||||||
|
{
|
||||||
|
- AV_PACKET_UNREF(&pkt);
|
||||||
|
+ av_packet_unref(pkt);
|
||||||
|
MINILOG(logTRACE) << "Skipping frame...";
|
||||||
|
}
|
||||||
|
if (avret < 0) {
|
||||||
|
// stop decoding if av_read_frame() failed
|
||||||
|
- AV_PACKET_UNREF(&pkt);
|
||||||
|
+ av_packet_unref(pkt);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
- uint8_t* data = pkt.data;
|
||||||
|
- int size = pkt.size;
|
||||||
|
- while (pkt.size > 0) {
|
||||||
|
+ uint8_t* data = pkt->data;
|
||||||
|
+ int size = pkt->size;
|
||||||
|
+ while (pkt->size > 0) {
|
||||||
|
|
||||||
|
// try to decode a frame
|
||||||
|
- AV_FRAME_UNREF(frame);
|
||||||
|
+ av_frame_unref(frame);
|
||||||
|
|
||||||
|
int len = 0;
|
||||||
|
got_frame = 0;
|
||||||
|
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 48, 101)
|
||||||
|
- len = avcodec_decode_audio4(decx, frame, &got_frame, &pkt);
|
||||||
|
- if (len < 0) {
|
||||||
|
- avret = AVERROR(EINVAL);
|
||||||
|
- }
|
||||||
|
-#else
|
||||||
|
avret = avcodec_receive_frame(decx, frame);
|
||||||
|
if (avret == 0) {
|
||||||
|
got_frame = 1;
|
||||||
|
@@ -381,14 +331,13 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
avret = 0;
|
||||||
|
}
|
||||||
|
if (avret == 0) {
|
||||||
|
- avret = avcodec_send_packet(decx, &pkt);
|
||||||
|
+ avret = avcodec_send_packet(decx, pkt);
|
||||||
|
if (avret == 0) {
|
||||||
|
- len = pkt.size;
|
||||||
|
+ len = pkt->size;
|
||||||
|
} else if (avret == AVERROR(EAGAIN)) {
|
||||||
|
avret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-#endif
|
||||||
|
if (avret < 0) {
|
||||||
|
MINILOG(logWARNING) << "Error decoding an audio frame";
|
||||||
|
|
||||||
|
@@ -400,8 +349,8 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
|
||||||
|
// if too many frames failed decoding, abort
|
||||||
|
MINILOG(logERROR) << "Too many errors, aborting.";
|
||||||
|
- AV_FRAME_FREE(&frame);
|
||||||
|
- AV_PACKET_UNREF(&pkt);
|
||||||
|
+ av_frame_free(&frame);
|
||||||
|
+ av_packet_unref(pkt);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
if (buffer) {
|
||||||
|
delete[] buffer;
|
||||||
|
@@ -414,7 +363,7 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
// if we got a frame
|
||||||
|
if (got_frame) {
|
||||||
|
// do we need to increase the buffer size?
|
||||||
|
- int input_samples = frame->nb_samples*decx->channels;
|
||||||
|
+ int input_samples = frame->nb_samples*decx->ch_layout.nb_channels;
|
||||||
|
if (input_samples > buffersize) {
|
||||||
|
if (buffer) {
|
||||||
|
delete[] buffer;
|
||||||
|
@@ -434,8 +383,8 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
input_samples / num_planes) < 0) {
|
||||||
|
MINILOG(logERROR) << "Strange sample format. Abort.";
|
||||||
|
|
||||||
|
- AV_FRAME_FREE(&frame);
|
||||||
|
- AV_PACKET_UNREF(&pkt);
|
||||||
|
+ av_frame_free(&frame);
|
||||||
|
+ av_packet_unref(pkt);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
if (buffer) {
|
||||||
|
delete[] buffer;
|
||||||
|
@@ -445,7 +394,7 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
}
|
||||||
|
|
||||||
|
// inplace downmix to mono, if required
|
||||||
|
- if (decx->channels == 2) {
|
||||||
|
+ if (decx->ch_layout.nb_channels == 2) {
|
||||||
|
for (int i = 0; i < frame->nb_samples; i++) {
|
||||||
|
buffer[i] = (buffer[i*2] + buffer[i*2+1]) / 2.0f;
|
||||||
|
}
|
||||||
|
@@ -457,13 +406,13 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
}
|
||||||
|
|
||||||
|
// consume the packet
|
||||||
|
- pkt.data += len;
|
||||||
|
- pkt.size -= len;
|
||||||
|
+ pkt->data += len;
|
||||||
|
+ pkt->size -= len;
|
||||||
|
}
|
||||||
|
- pkt.data = data;
|
||||||
|
- pkt.size = size;
|
||||||
|
+ pkt->data = data;
|
||||||
|
+ pkt->size = size;
|
||||||
|
|
||||||
|
- AV_PACKET_UNREF(&pkt);
|
||||||
|
+ av_packet_unref(pkt);
|
||||||
|
}
|
||||||
|
MINILOG(logTRACE) << "Decoding loop finished.";
|
||||||
|
|
||||||
|
@@ -514,13 +463,12 @@ libav::decodeto_22050hz_mono_float(
|
||||||
|
if (buffer) {
|
||||||
|
delete[] buffer;
|
||||||
|
}
|
||||||
|
- AV_FRAME_FREE(&frame);
|
||||||
|
+ av_frame_free(&frame);
|
||||||
|
#ifdef _OPENMP
|
||||||
|
#pragma omp critical
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
- avcodec_close(decx);
|
||||||
|
- AVCODEC_FREE_CONTEXT(&decx);
|
||||||
|
+ avcodec_free_context(&decx);
|
||||||
|
avformat_close_input(&fmtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
35
pkgs/by-name/mu/musly/0002-Fix-build-with-C-17.patch
Normal file
35
pkgs/by-name/mu/musly/0002-Fix-build-with-C-17.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 75efe27cbb03f2883e53e7a7f68386d93e2c1874 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Emily <hello@emily.moe>
|
||||||
|
Date: Sat, 3 Aug 2024 12:17:19 +0100
|
||||||
|
Subject: [PATCH 2/4] Fix build with C++17
|
||||||
|
|
||||||
|
---
|
||||||
|
musly/main.cpp | 5 ++++-
|
||||||
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/musly/main.cpp b/musly/main.cpp
|
||||||
|
index a9644f2..bb8b7ae 100644
|
||||||
|
--- a/musly/main.cpp
|
||||||
|
+++ b/musly/main.cpp
|
||||||
|
@@ -14,6 +14,7 @@
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
+#include <random>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <limits>
|
||||||
|
#include <map>
|
||||||
|
@@ -239,7 +240,9 @@ tracks_initialize(
|
||||||
|
else {
|
||||||
|
// use a random subset of 1000 tracks
|
||||||
|
std::vector<musly_track*> tracks2(tracks);
|
||||||
|
- std::random_shuffle(tracks2.begin(), tracks2.end());
|
||||||
|
+ std::random_device seeder;
|
||||||
|
+ std::default_random_engine rng(seeder());
|
||||||
|
+ std::shuffle(tracks2.begin(), tracks2.end(), rng);
|
||||||
|
ret = musly_jukebox_setmusicstyle(mj, tracks2.data(), 1000);
|
||||||
|
}
|
||||||
|
if (ret != 0) {
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
151
pkgs/by-name/mu/musly/0003-Modernize-CMake-build-system.patch
Normal file
151
pkgs/by-name/mu/musly/0003-Modernize-CMake-build-system.patch
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
From 8abe6385e433b44c43134b4deef208c7498ab0d7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Emily <hello@emily.moe>
|
||||||
|
Date: Sat, 3 Aug 2024 12:21:12 +0100
|
||||||
|
Subject: [PATCH 3/4] Modernize CMake build system
|
||||||
|
|
||||||
|
Use GNUInstallDirs, CTest, and FindPkgConfig.
|
||||||
|
---
|
||||||
|
.travis.yml | 2 +-
|
||||||
|
CMakeLists.txt | 25 +++++++++++--------------
|
||||||
|
libmusly/CMakeLists.txt | 11 +++--------
|
||||||
|
musly/CMakeLists.txt | 6 +-----
|
||||||
|
4 files changed, 16 insertions(+), 28 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/.travis.yml b/.travis.yml
|
||||||
|
index 8556b26..b051004 100644
|
||||||
|
--- a/.travis.yml
|
||||||
|
+++ b/.travis.yml
|
||||||
|
@@ -19,7 +19,7 @@ matrix:
|
||||||
|
script:
|
||||||
|
- mkdir -p build
|
||||||
|
- cd build
|
||||||
|
- - cmake -DBUILD_TEST=ON ..
|
||||||
|
+ - cmake ..
|
||||||
|
- make -j
|
||||||
|
- ctest -V
|
||||||
|
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 4fab4ab..8d8bf0e 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -4,9 +4,11 @@
|
||||||
|
# (c) 2013-2014, Dominik Schnitzer <dominik@schnitzer.at>
|
||||||
|
# 2014, Jan Schlueter <jan.schlueter@ofai.at>
|
||||||
|
|
||||||
|
-cmake_minimum_required(VERSION 2.8)
|
||||||
|
+cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
|
project(musly)
|
||||||
|
+include(GNUInstallDirs)
|
||||||
|
+include(CTest)
|
||||||
|
set(MUSLY_VERSION "0.2")
|
||||||
|
add_definitions(-DMUSLY_VERSION="${MUSLY_VERSION}")
|
||||||
|
|
||||||
|
@@ -36,8 +38,6 @@ else ()
|
||||||
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
-option(BUILD_TEST "Build selftest executable" OFF)
|
||||||
|
-
|
||||||
|
option(USE_OPENMP "Compile with OpenMP support (Parallelization)" OFF)
|
||||||
|
if (USE_OPENMP)
|
||||||
|
find_package(OpenMP)
|
||||||
|
@@ -54,26 +54,23 @@ if (USE_OPENMP)
|
||||||
|
endif()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
-set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
|
-
|
||||||
|
-find_package(Eigen3 REQUIRED)
|
||||||
|
-find_package(LibAV 0.8 COMPONENTS avcodec avformat avutil REQUIRED)
|
||||||
|
+find_package(PkgConfig REQUIRED)
|
||||||
|
+pkg_check_modules(EIGEN3 REQUIRED IMPORTED_TARGET eigen3)
|
||||||
|
+pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
||||||
|
+ libavcodec
|
||||||
|
+ libavformat
|
||||||
|
+ libavutil)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
- "${PROJECT_BINARY_DIR}"
|
||||||
|
"${PROJECT_SOURCE_DIR}/include")
|
||||||
|
|
||||||
|
add_subdirectory(libmusly)
|
||||||
|
add_subdirectory(musly)
|
||||||
|
add_subdirectory(include)
|
||||||
|
-if (BUILD_TEST)
|
||||||
|
- enable_testing()
|
||||||
|
+if (BUILD_TESTING)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
set(musly_DOC_FILES AUTHORS COPYING README.md)
|
||||||
|
-set(musly_DOC_PATH "share/doc/musly")
|
||||||
|
-install(FILES ${musly_DOC_FILES}
|
||||||
|
- DESTINATION ${musly_DOC_PATH})
|
||||||
|
-
|
||||||
|
+install(FILES ${musly_DOC_FILES} DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||||
|
diff --git a/libmusly/CMakeLists.txt b/libmusly/CMakeLists.txt
|
||||||
|
index 98151df..b9f6d11 100644
|
||||||
|
--- a/libmusly/CMakeLists.txt
|
||||||
|
+++ b/libmusly/CMakeLists.txt
|
||||||
|
@@ -4,9 +4,6 @@
|
||||||
|
# (c) 2013-2014, Dominik Schnitzer <dominik@schnitzer.at>
|
||||||
|
# 2014-2016, Jan Schlueter <jan.schlueter@ofai.at>
|
||||||
|
|
||||||
|
-add_subdirectory(
|
||||||
|
- libresample)
|
||||||
|
-
|
||||||
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
|
||||||
|
add_subdirectory(
|
||||||
|
external)
|
||||||
|
@@ -24,8 +21,6 @@ endif()
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${LIBMUSLY_INCLUDE}
|
||||||
|
- ${EIGEN3_INCLUDE_DIR}
|
||||||
|
- ${LIBAV_INCLUDE_DIRS}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
add_library(libmusly
|
||||||
|
@@ -60,7 +55,8 @@ set_target_properties(libmusly
|
||||||
|
|
||||||
|
target_link_libraries(libmusly
|
||||||
|
${LIBMUSLY_LIBS}
|
||||||
|
- ${LIBAV_LIBRARIES})
|
||||||
|
+ PkgConfig::EIGEN3
|
||||||
|
+ PkgConfig::FFMPEG)
|
||||||
|
if(WIN32 OR MINGW)
|
||||||
|
# link against winsock2 for ntohl() and htonl()
|
||||||
|
target_link_libraries(libmusly ws2_32)
|
||||||
|
@@ -69,5 +65,4 @@ endif()
|
||||||
|
set_target_properties(libmusly
|
||||||
|
PROPERTIES PREFIX "")
|
||||||
|
|
||||||
|
-install(TARGETS libmusly
|
||||||
|
- DESTINATION lib)
|
||||||
|
+install(TARGETS libmusly)
|
||||||
|
diff --git a/musly/CMakeLists.txt b/musly/CMakeLists.txt
|
||||||
|
index 88d153b..846ed2c 100644
|
||||||
|
--- a/musly/CMakeLists.txt
|
||||||
|
+++ b/musly/CMakeLists.txt
|
||||||
|
@@ -3,10 +3,6 @@
|
||||||
|
|
||||||
|
# (c) 2013, Dominik Schnitzer <dominik@schnitzer.at>
|
||||||
|
|
||||||
|
-include_directories(
|
||||||
|
- ${EIGEN3_INCLUDE_DIR})
|
||||||
|
-
|
||||||
|
-
|
||||||
|
add_executable(musly
|
||||||
|
tools.cpp
|
||||||
|
fileiterator.cpp
|
||||||
|
@@ -17,4 +13,4 @@ add_executable(musly
|
||||||
|
target_link_libraries(musly
|
||||||
|
libmusly)
|
||||||
|
|
||||||
|
-install(TARGETS musly DESTINATION bin)
|
||||||
|
+install(TARGETS musly)
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -0,0 +1,110 @@
|
|||||||
|
From e4a0d0b48905bb949831c30c941e921da0b6f09c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Emily <hello@emily.moe>
|
||||||
|
Date: Sat, 3 Aug 2024 12:21:12 +0100
|
||||||
|
Subject: [PATCH 4/4] Use pkg-config to find libresample and kissfft
|
||||||
|
|
||||||
|
---
|
||||||
|
.travis.yml | 2 ++
|
||||||
|
CMakeLists.txt | 12 ++++++++++++
|
||||||
|
libmusly/CMakeLists.txt | 12 +++---------
|
||||||
|
libmusly/powerspectrum.h | 2 +-
|
||||||
|
libmusly/resampler.h | 2 +-
|
||||||
|
5 files changed, 19 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/.travis.yml b/.travis.yml
|
||||||
|
index b051004..b354641 100644
|
||||||
|
--- a/.travis.yml
|
||||||
|
+++ b/.travis.yml
|
||||||
|
@@ -31,3 +31,5 @@ addons:
|
||||||
|
- libavcodec-dev
|
||||||
|
- libavformat-dev
|
||||||
|
- libavutil-dev
|
||||||
|
+ - libresample-dev
|
||||||
|
+ - libkissfft-dev
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 8d8bf0e..c5b0d2c 100644
|
||||||
|
--- a/CMakeLists.txt
|
||||||
|
+++ b/CMakeLists.txt
|
||||||
|
@@ -60,6 +60,18 @@ pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
|
||||||
|
libavcodec
|
||||||
|
libavformat
|
||||||
|
libavutil)
|
||||||
|
+pkg_check_modules(LIBRESAMPLE REQUIRED IMPORTED_TARGET libresample)
|
||||||
|
+pkg_search_module(KISSFFT REQUIRED IMPORTED_TARGET
|
||||||
|
+ kissfft-simd
|
||||||
|
+ kissfft-double
|
||||||
|
+ kissfft-float
|
||||||
|
+ kissfft-int32_t
|
||||||
|
+ kissfft-int16_t
|
||||||
|
+ kissfft-simd-openmp
|
||||||
|
+ kissfft-double-openmp
|
||||||
|
+ kissfft-float-openmp
|
||||||
|
+ kissfft-int32_t-openmp
|
||||||
|
+ kissfft-int16_t-openmp)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
"${PROJECT_SOURCE_DIR}/include")
|
||||||
|
diff --git a/libmusly/CMakeLists.txt b/libmusly/CMakeLists.txt
|
||||||
|
index b9f6d11..6f8c8e9 100644
|
||||||
|
--- a/libmusly/CMakeLists.txt
|
||||||
|
+++ b/libmusly/CMakeLists.txt
|
||||||
|
@@ -13,19 +13,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
|
||||||
|
PROPERTIES COMPILE_FLAGS "-DLIBMUSLY_EXTERNAL ${LIBMUSLY_EXTERNAL_FLAGS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
-if(USE_OPENMP AND OPENMP_FOUND)
|
||||||
|
- # disable OpenMP for kiss FFT, it slows things down terribly
|
||||||
|
- set_source_files_properties(kissfft/kiss_fft.c
|
||||||
|
- PROPERTIES COMPILE_FLAGS "-U_OPENMP")
|
||||||
|
-endif()
|
||||||
|
-
|
||||||
|
include_directories(
|
||||||
|
${LIBMUSLY_INCLUDE}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
add_library(libmusly
|
||||||
|
- kissfft/kiss_fft.c
|
||||||
|
- kissfft/kiss_fftr.c
|
||||||
|
methods/mandelellis.cpp
|
||||||
|
methods/timbre.cpp
|
||||||
|
decoders/libav.cpp
|
||||||
|
@@ -56,7 +48,9 @@ set_target_properties(libmusly
|
||||||
|
target_link_libraries(libmusly
|
||||||
|
${LIBMUSLY_LIBS}
|
||||||
|
PkgConfig::EIGEN3
|
||||||
|
- PkgConfig::FFMPEG)
|
||||||
|
+ PkgConfig::FFMPEG
|
||||||
|
+ PkgConfig::LIBRESAMPLE
|
||||||
|
+ PkgConfig::KISSFFT)
|
||||||
|
if(WIN32 OR MINGW)
|
||||||
|
# link against winsock2 for ntohl() and htonl()
|
||||||
|
target_link_libraries(libmusly ws2_32)
|
||||||
|
diff --git a/libmusly/powerspectrum.h b/libmusly/powerspectrum.h
|
||||||
|
index 6957db4..096fc31 100644
|
||||||
|
--- a/libmusly/powerspectrum.h
|
||||||
|
+++ b/libmusly/powerspectrum.h
|
||||||
|
@@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
#include <Eigen/Core>
|
||||||
|
extern "C" {
|
||||||
|
- #include "kissfft/kiss_fftr.h"
|
||||||
|
+ #include <kissfft/kiss_fftr.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/libmusly/resampler.h b/libmusly/resampler.h
|
||||||
|
index df8aaa4..f48e22a 100644
|
||||||
|
--- a/libmusly/resampler.h
|
||||||
|
+++ b/libmusly/resampler.h
|
||||||
|
@@ -14,7 +14,7 @@
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
extern "C" {
|
||||||
|
- #include "libresample/libresample.h"
|
||||||
|
+ #include <libresample.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace musly {
|
||||||
|
--
|
||||||
|
2.45.2
|
||||||
|
|
@ -4,32 +4,55 @@
|
|||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
cmake,
|
cmake,
|
||||||
ninja,
|
ninja,
|
||||||
|
pkg-config,
|
||||||
eigen,
|
eigen,
|
||||||
ffmpeg_4,
|
ffmpeg_7,
|
||||||
|
libresample,
|
||||||
|
kissfft,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
pname = "musly";
|
pname = "musly";
|
||||||
version = "0.1-unstable-2019-09-05";
|
version = "0.1-unstable-2019-09-05";
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
"bin"
|
||||||
|
"dev"
|
||||||
|
"out"
|
||||||
|
"doc"
|
||||||
|
];
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "dominikschnitzer";
|
owner = "dominikschnitzer";
|
||||||
repo = "musly";
|
repo = "musly";
|
||||||
rev = "7a0c6a9a2782e6fca84fb86fce5232a8c8a104ed";
|
rev = "7a0c6a9a2782e6fca84fb86fce5232a8c8a104ed";
|
||||||
hash = "sha256-DOvGGx3pCcvPPsT97sQlINjT1sJy8ZWvxLsFGGZbgzE=";
|
hash = "sha256-DOvGGx3pCcvPPsT97sQlINjT1sJy8ZWvxLsFGGZbgzE=";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
# Fix build with FFmpeg 7, C++17, and external libresample and kissfft
|
||||||
|
# https://github.com/dominikschnitzer/musly/pull/53
|
||||||
|
# Last commit omitted, as it is a large non‐functional removal
|
||||||
|
./0001-Fix-build-with-FFmpeg-7.patch
|
||||||
|
./0002-Fix-build-with-C-17.patch
|
||||||
|
./0003-Modernize-CMake-build-system.patch
|
||||||
|
./0004-Use-pkg-config-to-find-libresample-and-kissfft.patch
|
||||||
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
cmake
|
cmake
|
||||||
ninja
|
ninja
|
||||||
|
pkg-config
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
eigen
|
eigen
|
||||||
ffmpeg_4
|
ffmpeg_7
|
||||||
|
libresample
|
||||||
|
kissfft
|
||||||
];
|
];
|
||||||
fixupPhase = lib.optionalString stdenv.isDarwin ''
|
|
||||||
install_name_tool -change libmusly.dylib $out/lib/libmusly.dylib $out/bin/musly
|
doCheck = true;
|
||||||
install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/bin/musly
|
|
||||||
install_name_tool -change libmusly_resample.dylib $out/lib/libmusly_resample.dylib $out/lib/libmusly.dylib
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
homepage = "https://www.musly.org";
|
homepage = "https://www.musly.org";
|
||||||
|
Loading…
Reference in New Issue
Block a user