summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO21
-rw-r--r--8ccad693.patch550
-rw-r--r--PKGBUILD61
-rw-r--r--fix_build_32bit.patch42
4 files changed, 610 insertions, 64 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 1d5d3ecb3c56..d809c26067ac 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = lib32-chromaprint
pkgdesc = Library for extracting fingerprints from any audio source (32-bit)
- pkgver = 1.5.0
- pkgrel = 5
+ pkgver = 1.5.1
+ pkgrel = 2
url = https://acoustid.org/chromaprint
arch = x86_64
license = LGPL2.1
@@ -10,12 +10,17 @@ pkgbase = lib32-chromaprint
makedepends = gtest
depends = lib32-ffmpeg
depends = chromaprint
- source = chromaprint-1.5.0.tar.gz::https://github.com/acoustid/chromaprint/archive/v1.5.0.tar.gz
+ source = https://github.com/acoustid/chromaprint/archive/v1.5.1/chromaprint-1.5.1.tar.gz
source = fix_build_32bit.patch
- sha512sums = 333114949928abdf5d4b11aba1db6ec487eebe526324c68d903b3fa80a3af87a28d942af765a2f873e63a1bf222b658b6438cd10cde4446f61b26ea91f537469
- sha512sums = d67e955398cf50e96e3ff5c16544c11745dad84c19d2ea965759f71c05c84cd1b0299becb287575135f8d921c906b2dbfa87ab3da659af3bcc203205e96af5b1
- b2sums = 930d1a7b8fa30dc726f78e3fc93c4e1aef5036b60ceee003c36ce7ea344523ce8b3abc294a4204e9acb6472600e7cfa5b15b1ca27c2917bd161b59cac1e7120c
- b2sums = 8a0e13c019df0d745ecd7eb4b2a49f1e8a2918c86d751ffadcc033899c091e37434a2e319f820a7f63da841984cf4a36e1849782dabc9a2503ab10ba546efb45
+ source = 8ccad693.patch
+ source = https://github.com/acoustid/chromaprint/commit/aa67c95b.patch
+ sha512sums = ea16e4d2b879c15b1d9b9ec93878da8b893f1834c70942663e1d2d106c2e0a661094fe2dd3bae7a6c2a1f9d5d8fab5e0b0ba493561090cf57b2228606fad1e66
+ sha512sums = 64d67c17e65f89dbee629074fcd9131c89aa493ff7be9da8c97031e7ed0ee4768e7350182c016eb52e6614307d3a668eb2d4e64586d77793cc79b319734b6b44
+ sha512sums = 9eb62b6b165fb2a48fe6399025a51161347cb56b8b7d28819a90be38425d145d2997aecb203dbadf40bcb469b0757ad8f836dca7dbb1db95f923a427f3c2d9ee
+ sha512sums = 92a9491fe1cd4cedae4f36335de961f87c5ebba642ab52866011c43f34862c194afa9d25e5e54e5abc80112d69c39cc04c2ddd2a7a2fe799b35a3846c0d1e172
+ b2sums = 9f7f030e97d3114cf679df298d313ea826c0fb05e7e7d8a10090d0a27ed0811b380b81b29fce973e0493826c478964367396311fd0484619cb2fc4c2d8e0d4c0
+ b2sums = 442949f3de7ef38f80e629cc644cda5816c3f092268e489e23952404ea767b39213a808e7aaf2fb28d024fea46b3ecab99fbef283fff8d297f0ff4e8d7435adc
+ b2sums = 085dd1c64347a76cf912d327d8782fafd392777aae9dd565b1e84860e12a1262d9b25f908c54b96147abf74c82824529c6e100f5943ddff725358bb7aa19da47
+ b2sums = e49352aef51ef19874d51dabf5ecc5f703d7e441f34b37c8cef538395688a0c42a57bb0b75dc5af2140f2ab752ef7421635c29c45d5c3708789561b3a552b84c
pkgname = lib32-chromaprint
-
diff --git a/8ccad693.patch b/8ccad693.patch
new file mode 100644
index 000000000000..97fc0748855b
--- /dev/null
+++ b/8ccad693.patch
@@ -0,0 +1,550 @@
+From 8ccad6937177b1b92e40ab8f4447ea27bac009a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com>
+Date: Fri, 4 Nov 2022 21:47:38 +0100
+Subject: [PATCH] Use FFmpeg 5.x (#120)
+
+* Use FFmpeg 5.1.2 for CI builds
+
+* Build on Ubuntu 20.04
+
+* Upgrade code to FFmpeg 5.x APIs
+
+* Only set FFmpeg include dirs if building tools
+
+* No longer needed
+
+* Use ubuntu 20.04
+---
+ .github/workflows/build.yml | 6 +-
+ CMakeLists.txt | 16 --
+ package/build.sh | 4 +-
+ src/audio/ffmpeg_audio_processor.h | 2 -
+ src/audio/ffmpeg_audio_processor_avresample.h | 72 -------
+ src/audio/ffmpeg_audio_processor_swresample.h | 18 +-
+ src/audio/ffmpeg_audio_reader.h | 197 +++++++++---------
+ tests/CMakeLists.txt | 6 +
+ 8 files changed, 122 insertions(+), 199 deletions(-)
+ delete mode 100644 src/audio/ffmpeg_audio_processor_avresample.h
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index f8d6a32..4da2405 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -84,9 +84,6 @@ find_package(FFmpeg)
+ if(FFMPEG_LIBRARIES)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_LIBRARIES ${FFMPEG_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -lm)
+- check_function_exists(av_packet_unref HAVE_AV_PACKET_UNREF)
+- check_function_exists(av_frame_alloc HAVE_AV_FRAME_ALLOC)
+- check_function_exists(av_frame_free HAVE_AV_FRAME_FREE)
+ cmake_pop_check_state()
+ endif()
+
+@@ -163,14 +160,11 @@ message(STATUS "Using ${FFT_LIB} for FFT calculations")
+ if(NOT AUDIO_PROCESSOR_LIB)
+ if(FFMPEG_LIBSWRESAMPLE_FOUND)
+ set(AUDIO_PROCESSOR_LIB "swresample")
+- elseif(FFMPEG_LIBAVRESAMPLE_FOUND)
+- set(AUDIO_PROCESSOR_LIB "avresample")
+ endif()
+ endif()
+
+ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ if(FFMPEG_LIBSWRESAMPLE_FOUND)
+- set(USE_AVRESAMPLE OFF)
+ set(USE_SWRESAMPLE ON)
+ set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBSWRESAMPLE_LIBRARIES})
+ set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBSWRESAMPLE_INCLUDE_DIRS})
+@@ -178,16 +172,6 @@ if(AUDIO_PROCESSOR_LIB STREQUAL "swresample")
+ message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+ endif()
+ message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+-elseif(AUDIO_PROCESSOR_LIB STREQUAL "avresample")
+- if(FFMPEG_LIBAVRESAMPLE_FOUND)
+- set(USE_AVRESAMPLE ON)
+- set(USE_SWRESAMPLE OFF)
+- set(AUDIO_PROCESSOR_LIBRARIES ${FFMPEG_LIBAVRESAMPLE_LIBRARIES})
+- set(AUDIO_PROCESSOR_INCLUDE_DIRS ${FFMPEG_LIBAVRESAMPLE_INCLUDE_DIRS})
+- else()
+- message(FATAL_ERROR "Selected ${AUDIO_PROCESSOR_LIB} for audio processing, but the library is not found")
+- endif()
+- message(STATUS "Using ${AUDIO_PROCESSOR_LIB} for audio conversion")
+ else()
+ message(STATUS "Building without audio conversion support, please install FFmpeg with libswresample")
+ endif()
+diff --git a/src/audio/ffmpeg_audio_processor.h b/src/audio/ffmpeg_audio_processor.h
+index 7628fc7..39f4f6d 100644
+--- a/src/audio/ffmpeg_audio_processor.h
++++ b/src/audio/ffmpeg_audio_processor.h
+@@ -10,8 +10,6 @@
+
+ #if defined(USE_SWRESAMPLE)
+ #include "audio/ffmpeg_audio_processor_swresample.h"
+-#elif defined(USE_AVRESAMPLE)
+-#include "audio/ffmpeg_audio_processor_avresample.h"
+ #else
+ #error "no audio processing library"
+ #endif
+diff --git a/src/audio/ffmpeg_audio_processor_avresample.h b/src/audio/ffmpeg_audio_processor_avresample.h
+deleted file mode 100644
+index bd85f92..0000000
+--- a/src/audio/ffmpeg_audio_processor_avresample.h
++++ /dev/null
+@@ -1,72 +0,0 @@
+-// Copyright (C) 2016 Lukas Lalinsky
+-// Distributed under the MIT license, see the LICENSE file for details.
+-
+-#ifndef CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-#define CHROMAPRINT_AUDIO_FFMPEG_AUDIO_PROCESSOR_AVRESAMPLE_H_
+-
+-extern "C" {
+-#include <libavresample/avresample.h>
+-}
+-
+-namespace chromaprint {
+-
+-class FFmpegAudioProcessor {
+-public:
+- FFmpegAudioProcessor() {
+- m_resample_ctx = avresample_alloc_context();
+- }
+-
+- ~FFmpegAudioProcessor() {
+- avresample_free(&m_resample_ctx);
+- }
+-
+- void SetCompatibleMode() {
+- av_opt_set_int(m_resample_ctx, "filter_size", 16, 0);
+- av_opt_set_int(m_resample_ctx, "phase_shift", 8, 0);
+- av_opt_set_int(m_resample_ctx, "linear_interp", 1, 0);
+- av_opt_set_double(m_resample_ctx, "cutoff", 0.8, 0);
+- }
+-
+- void SetInputChannelLayout(int64_t channel_layout) {
+- av_opt_set_int(m_resample_ctx, "in_channel_layout", channel_layout, 0);
+- }
+-
+- void SetInputSampleFormat(AVSampleFormat sample_format) {
+- av_opt_set_int(m_resample_ctx, "in_sample_fmt", sample_format, 0);
+- }
+-
+- void SetInputSampleRate(int sample_rate) {
+- av_opt_set_int(m_resample_ctx, "in_sample_rate", sample_rate, 0);
+- }
+-
+- void SetOutputChannelLayout(int64_t channel_layout) {
+- av_opt_set_int(m_resample_ctx, "out_channel_layout", channel_layout, 0);
+- }
+-
+- void SetOutputSampleFormat(AVSampleFormat sample_format) {
+- av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_format, 0);
+- }
+-
+- void SetOutputSampleRate(int sample_rate) {
+- av_opt_set_int(m_resample_ctx, "out_sample_fmt", sample_rate, 0);
+- }
+-
+- int Init() {
+- return avresample_open(m_resample_ctx);
+- }
+-
+- int Convert(uint8_t **out, int out_count, const uint8_t **in, int in_count) {
+- return avresample_convert(m_resample_ctx, out, 0, out_count, (uint8_t **) in, 0, in_count);
+- }
+-
+- int Flush(uint8_t **out, int out_count) {
+- return avresample_read(m_resample_ctx, out, out_count);
+- }
+-
+-private:
+- AVAudioResampleContext *m_resample_ctx = nullptr;
+-};
+-
+-}; // namespace chromaprint
+-
+-#endif
+diff --git a/src/audio/ffmpeg_audio_processor_swresample.h b/src/audio/ffmpeg_audio_processor_swresample.h
+index b86266b..b1d4bea 100644
+--- a/src/audio/ffmpeg_audio_processor_swresample.h
++++ b/src/audio/ffmpeg_audio_processor_swresample.h
+@@ -28,30 +28,28 @@ class FFmpegAudioProcessor {
+ av_opt_set_double(m_swr_ctx, "cutoff", 0.8, 0);
+ }
+
+- void SetInputChannelLayout(int64_t channel_layout) {
+- av_opt_set_int(m_swr_ctx, "icl", channel_layout, 0);
+- av_opt_set_int(m_swr_ctx, "ich", av_get_channel_layout_nb_channels(channel_layout), 0);
++ void SetInputChannelLayout(AVChannelLayout *channel_layout) {
++ av_opt_set_int(m_swr_ctx, "in_channel_layout", channel_layout->u.mask, 0);
+ }
+
+ void SetInputSampleFormat(AVSampleFormat sample_format) {
+- av_opt_set_int(m_swr_ctx, "isf", sample_format, 0);
++ av_opt_set_sample_fmt(m_swr_ctx, "in_sample_fmt", sample_format, 0);
+ }
+
+ void SetInputSampleRate(int sample_rate) {
+- av_opt_set_int(m_swr_ctx, "isr", sample_rate, 0);
++ av_opt_set_int(m_swr_ctx, "in_sample_rate", sample_rate, 0);
+ }
+
+- void SetOutputChannelLayout(int64_t channel_layout) {
+- av_opt_set_int(m_swr_ctx, "ocl", channel_layout, 0);
+- av_opt_set_int(m_swr_ctx, "och", av_get_channel_layout_nb_channels(channel_layout), 0);
++ void SetOutputChannelLayout(AVChannelLayout *channel_layout) {
++ av_opt_set_int(m_swr_ctx, "out_channel_layout", channel_layout->u.mask, 0);
+ }
+
+ void SetOutputSampleFormat(AVSampleFormat sample_format) {
+- av_opt_set_int(m_swr_ctx, "osf", sample_format, 0);
++ av_opt_set_sample_fmt(m_swr_ctx, "out_sample_fmt", sample_format, 0);
+ }
+
+ void SetOutputSampleRate(int sample_rate) {
+- av_opt_set_int(m_swr_ctx, "osr", sample_rate, 0);
++ av_opt_set_int(m_swr_ctx, "out_sample_rate", sample_rate, 0);
+ }
+
+ int Init() {
+diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
+index 5550164..1c6b346 100644
+--- a/src/audio/ffmpeg_audio_reader.h
++++ b/src/audio/ffmpeg_audio_reader.h
+@@ -62,7 +62,7 @@ class FFmpegAudioReader {
+ bool Read(const int16_t **data, size_t *size);
+
+ bool IsOpen() const { return m_opened; }
+- bool IsFinished() const { return m_finished && !m_got_frame; }
++ bool IsFinished() const { return !m_has_more_packets && !m_has_more_frames; }
+
+ std::string GetError() const { return m_error; }
+ int GetErrorCode() const { return m_error_code; }
+@@ -74,20 +74,19 @@ class FFmpegAudioReader {
+ uint8_t *m_convert_buffer[1] = { nullptr };
+ int m_convert_buffer_nb_samples = 0;
+
+- AVInputFormat *m_input_fmt = nullptr;
++ const AVInputFormat *m_input_fmt = nullptr;
+ AVDictionary *m_input_opts = nullptr;
+
+ AVFormatContext *m_format_ctx = nullptr;
+ AVCodecContext *m_codec_ctx = nullptr;
+- AVFrame *m_frame = nullptr;
+ int m_stream_index = -1;
+ std::string m_error;
+ int m_error_code = 0;
+- bool m_finished = false;
+ bool m_opened = false;
+- int m_got_frame = 0;
+- AVPacket m_packet;
+- AVPacket m_packet0;
++ bool m_has_more_packets = true;
++ bool m_has_more_frames = true;
++ AVPacket *m_packet = nullptr;
++ AVFrame *m_frame = nullptr;
+
+ int m_output_sample_rate = 0;
+ int m_output_channels = 0;
+@@ -98,19 +97,12 @@ class FFmpegAudioReader {
+
+ inline FFmpegAudioReader::FFmpegAudioReader() {
+ av_log_set_level(AV_LOG_QUIET);
+-
+- av_init_packet(&m_packet);
+- m_packet.data = nullptr;
+- m_packet.size = 0;
+-
+- m_packet0 = m_packet;
+ }
+
+ inline FFmpegAudioReader::~FFmpegAudioReader() {
+ Close();
+ av_dict_free(&m_input_opts);
+ av_freep(&m_convert_buffer[0]);
+- av_packet_unref(&m_packet0);
+ }
+
+ inline bool FFmpegAudioReader::SetInputFormat(const char *name) {
+@@ -135,11 +127,10 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ Close();
+
+- av_init_packet(&m_packet);
+- m_packet.data = nullptr;
+- m_packet.size = 0;
+-
+- m_packet0 = m_packet;
++ m_packet = av_packet_alloc();
++ if (!m_packet) {
++ return false;
++ }
+
+ ret = avformat_open_input(&m_format_ctx, file_name.c_str(), m_input_fmt, &m_input_opts);
+ if (ret < 0) {
+@@ -153,26 +144,31 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ return false;
+ }
+
+- AVCodec *codec;
++ const AVCodec *codec;
+ ret = av_find_best_stream(m_format_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, &codec, 0);
+ if (ret < 0) {
+ SetError("Could not find any audio stream in the file", ret);
+ return false;
+ }
+ m_stream_index = ret;
++ auto stream = m_format_ctx->streams[m_stream_index];
+
+- m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
++ m_codec_ctx = avcodec_alloc_context3(codec);
+ m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
+
++ ret = avcodec_parameters_to_context(m_codec_ctx, stream->codecpar);
++ if (ret < 0) {
++ SetError("Could not copy the stream parameters", ret);
++ return false;
++ }
++
+ ret = avcodec_open2(m_codec_ctx, codec, nullptr);
+ if (ret < 0) {
+ SetError("Could not open the codec", ret);
+ return false;
+ }
+
+- if (!m_codec_ctx->channel_layout) {
+- m_codec_ctx->channel_layout = av_get_default_channel_layout(m_codec_ctx->channels);
+- }
++ av_dump_format(m_format_ctx, 0, "foo", 0);
+
+ m_frame = av_frame_alloc();
+ if (!m_frame) {
+@@ -183,19 +179,23 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ m_output_sample_rate = m_codec_ctx->sample_rate;
+ }
+
+- if (!m_output_channels) {
+- m_output_channels = m_codec_ctx->channels;
++ AVChannelLayout output_channel_layout;
++ if (m_output_channels) {
++ av_channel_layout_default(&output_channel_layout, m_output_channels);
++ } else {
++ m_output_channels = m_codec_ctx->ch_layout.nb_channels;
++ av_channel_layout_default(&output_channel_layout, m_output_channels);
+ }
+
+- if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
++ if (m_codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16 || m_codec_ctx->ch_layout.nb_channels != m_output_channels || m_codec_ctx->sample_rate != m_output_sample_rate) {
+ m_converter.reset(new FFmpegAudioProcessor());
+ m_converter->SetCompatibleMode();
+ m_converter->SetInputSampleFormat(m_codec_ctx->sample_fmt);
+ m_converter->SetInputSampleRate(m_codec_ctx->sample_rate);
+- m_converter->SetInputChannelLayout(m_codec_ctx->channel_layout);
++ m_converter->SetInputChannelLayout(&(m_codec_ctx->ch_layout));
+ m_converter->SetOutputSampleFormat(AV_SAMPLE_FMT_S16);
+ m_converter->SetOutputSampleRate(m_output_sample_rate);
+- m_converter->SetOutputChannelLayout(av_get_default_channel_layout(m_output_channels));
++ m_converter->SetOutputChannelLayout(&output_channel_layout);
+ auto ret = m_converter->Init();
+ if (ret != 0) {
+ SetError("Could not create an audio converter instance", ret);
+@@ -203,10 +203,11 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+ }
+ }
+
++ av_channel_layout_uninit(&output_channel_layout);
++
+ m_opened = true;
+- m_finished = false;
+- m_got_frame = 0;
+- m_nb_packets = 0;
++ m_has_more_packets = true;
++ m_has_more_frames = true;
+ m_decode_error = 0;
+
+ return true;
+@@ -214,6 +215,7 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
+
+ inline void FFmpegAudioReader::Close() {
+ av_frame_free(&m_frame);
++ av_packet_free(&m_packet);
+
+ m_stream_index = -1;
+
+@@ -252,91 +254,98 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
+ return false;
+ }
+
++ *data = nullptr;
++ *size = 0;
++
+ int ret;
++ bool needs_packet = false;
+ while (true) {
+- while (m_packet.size <= 0) {
+- av_packet_unref(&m_packet0);
+- av_init_packet(&m_packet);
+- m_packet.data = nullptr;
+- m_packet.size = 0;
+- ret = av_read_frame(m_format_ctx, &m_packet);
++ while (needs_packet && m_packet->size == 0) {
++ ret = av_read_frame(m_format_ctx, m_packet);
+ if (ret < 0) {
+ if (ret == AVERROR_EOF) {
+- m_finished = true;
++ needs_packet = false;
++ m_has_more_packets = false;
+ break;
+- } else {
++ }
++ SetError("Error reading from the audio source", ret);
++ return false;
++ }
++ if (m_packet->stream_index == m_stream_index) {
++ needs_packet = false;
++ } else {
++ av_packet_unref(m_packet);
++ }
++ }
++
++ if (m_packet->size != 0) {
++ ret = avcodec_send_packet(m_codec_ctx, m_packet);
++ if (ret < 0) {
++ if (ret != AVERROR(EAGAIN)) {
+ SetError("Error reading from the audio source", ret);
+ return false;
+ }
+- }
+- m_packet0 = m_packet;
+- if (m_packet.stream_index != m_stream_index) {
+- m_packet.data = nullptr;
+- m_packet.size = 0;
+ } else {
+- m_nb_packets++;
++ av_packet_unref(m_packet);
+ }
+ }
+
+- ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
++ ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ if (ret < 0) {
+- if (m_decode_error) {
+- SetError("Error decoding audio frame", m_decode_error);
+- return false;
++ if (ret == AVERROR_EOF) {
++ m_has_more_frames = false;
++ } else if (ret == AVERROR(EAGAIN)) {
++ if (m_has_more_packets) {
++ needs_packet = true;
++ continue;
++ } else {
++ m_has_more_frames = false;
++ }
+ }
+- m_decode_error = ret;
+- m_packet.data = nullptr;
+- m_packet.size = 0;
+- continue;
++ SetError("Error decoding the audio source", ret);
++ return false;
+ }
+
+- break;
+- }
+-
+- m_decode_error = 0;
+-
+- const int decoded = std::min(ret, m_packet.size);
+- m_packet.data += decoded;
+- m_packet.size -= decoded;
+-
+- if (m_got_frame) {
+- if (m_converter) {
+- if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
+- int linsize;
+- av_freep(&m_convert_buffer[0]);
+- m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
+- ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
+- if (ret < 0) {
+- SetError("Couldn't allocate audio converter buffer", ret);
++ if (m_frame->nb_samples > 0) {
++ if (m_converter) {
++ if (m_frame->nb_samples > m_convert_buffer_nb_samples) {
++ int linsize;
++ av_freep(&m_convert_buffer[0]);
++ m_convert_buffer_nb_samples = std::max(1024 * 8, m_frame->nb_samples);
++ ret = av_samples_alloc(m_convert_buffer, &linsize, m_codec_ctx->ch_layout.nb_channels, m_convert_buffer_nb_samples, AV_SAMPLE_FMT_S16, 1);
++ if (ret < 0) {
++ SetError("Couldn't allocate audio converter buffer", ret);
++ return false;
++ }
++ }
++ auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
++ if (nb_samples < 0) {
++ SetError("Couldn't convert audio", ret);
+ return false;
+ }
+- }
+- auto nb_samples = m_converter->Convert(m_convert_buffer, m_convert_buffer_nb_samples, (const uint8_t **) m_frame->data, m_frame->nb_samples);
+- if (nb_samples < 0) {
+- SetError("Couldn't convert audio", ret);
+- return false;
+- }
+- *data = (const int16_t *) m_convert_buffer[0];
+- *size = nb_samples;
+- } else {
+- *data = (const int16_t *) m_frame->data[0];
+- *size = m_frame->nb_samples;
+- }
+- } else {
+- if (m_finished && m_converter) {
+- auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
+- if (nb_samples < 0) {
+- SetError("Couldn't convert audio", ret);
+- return false;
+- } else if (nb_samples > 0) {
+- m_got_frame = 1;
+ *data = (const int16_t *) m_convert_buffer[0];
+ *size = nb_samples;
++ } else {
++ *data = (const int16_t *) m_frame->data[0];
++ *size = m_frame->nb_samples;
++ }
++ } else {
++ if (m_converter) {
++ if (IsFinished()) {
++ auto nb_samples = m_converter->Flush(m_convert_buffer, m_convert_buffer_nb_samples);
++ if (nb_samples < 0) {
++ SetError("Couldn't convert audio", ret);
++ return false;
++ } else if (nb_samples > 0) {
++ *data = (const int16_t *) m_convert_buffer[0];
++ *size = nb_samples;
++ }
++ }
+ }
+ }
+- }
+
+- return true;
++ return true;
++ }
+ }
+
+ inline void FFmpegAudioReader::SetError(const char *message, int errnum) {
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index a2b517b..123e643 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -38,6 +38,12 @@ set(SRCS
+
+ if(BUILD_TOOLS)
+ set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
++ include_directories(
++ ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
++ ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
++ ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
++ ${AUDIO_PROCESSOR_INCLUDE_DIRS}
++ )
+ link_libraries(fpcalc_libs)
+ endif()
+
diff --git a/PKGBUILD b/PKGBUILD
index e2db6f78c4cf..40b7a4f74d82 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,8 +3,8 @@
_basename=chromaprint
pkgname=lib32-chromaprint
-pkgver=1.5.0
-pkgrel=5
+pkgver=1.5.1
+pkgrel=2
pkgdesc="Library for extracting fingerprints from any audio source (32-bit)"
url="https://acoustid.org/chromaprint"
arch=('x86_64')
@@ -12,19 +12,24 @@ license=('LGPL2.1' 'MIT')
depends=('lib32-ffmpeg' 'chromaprint')
makedepends=('cmake' 'gtest')
# upstream signs with DSA key: https://github.com/acoustid/chromaprint/issues/81
-source=("${_basename}-${pkgver}.tar.gz::https://github.com/acoustid/${_basename}/archive/v${pkgver}.tar.gz"
- "fix_build_32bit.patch")
-sha512sums=('333114949928abdf5d4b11aba1db6ec487eebe526324c68d903b3fa80a3af87a28d942af765a2f873e63a1bf222b658b6438cd10cde4446f61b26ea91f537469'
- 'd67e955398cf50e96e3ff5c16544c11745dad84c19d2ea965759f71c05c84cd1b0299becb287575135f8d921c906b2dbfa87ab3da659af3bcc203205e96af5b1')
-b2sums=('930d1a7b8fa30dc726f78e3fc93c4e1aef5036b60ceee003c36ce7ea344523ce8b3abc294a4204e9acb6472600e7cfa5b15b1ca27c2917bd161b59cac1e7120c'
- '8a0e13c019df0d745ecd7eb4b2a49f1e8a2918c86d751ffadcc033899c091e37434a2e319f820a7f63da841984cf4a36e1849782dabc9a2503ab10ba546efb45')
+source=(https://github.com/acoustid/${_basename}/archive/v$pkgver/$_basename-$pkgver.tar.gz
+ fix_build_32bit.patch
+ 8ccad693.patch
+ https://github.com/acoustid/chromaprint/commit/aa67c95b.patch)
+sha512sums=('ea16e4d2b879c15b1d9b9ec93878da8b893f1834c70942663e1d2d106c2e0a661094fe2dd3bae7a6c2a1f9d5d8fab5e0b0ba493561090cf57b2228606fad1e66'
+ '64d67c17e65f89dbee629074fcd9131c89aa493ff7be9da8c97031e7ed0ee4768e7350182c016eb52e6614307d3a668eb2d4e64586d77793cc79b319734b6b44'
+ '9eb62b6b165fb2a48fe6399025a51161347cb56b8b7d28819a90be38425d145d2997aecb203dbadf40bcb469b0757ad8f836dca7dbb1db95f923a427f3c2d9ee'
+ '92a9491fe1cd4cedae4f36335de961f87c5ebba642ab52866011c43f34862c194afa9d25e5e54e5abc80112d69c39cc04c2ddd2a7a2fe799b35a3846c0d1e172')
+b2sums=('9f7f030e97d3114cf679df298d313ea826c0fb05e7e7d8a10090d0a27ed0811b380b81b29fce973e0493826c478964367396311fd0484619cb2fc4c2d8e0d4c0'
+ '442949f3de7ef38f80e629cc644cda5816c3f092268e489e23952404ea767b39213a808e7aaf2fb28d024fea46b3ecab99fbef283fff8d297f0ff4e8d7435adc'
+ '085dd1c64347a76cf912d327d8782fafd392777aae9dd565b1e84860e12a1262d9b25f908c54b96147abf74c82824529c6e100f5943ddff725358bb7aa19da47'
+ 'e49352aef51ef19874d51dabf5ecc5f703d7e441f34b37c8cef538395688a0c42a57bb0b75dc5af2140f2ab752ef7421635c29c45d5c3708789561b3a552b84c')
prepare() {
- cd "${_basename}-${pkgver}"
-
- patch -Np1 -i ../fix_build_32bit.patch
-
- rm -v cmake/modules/FindGTest.cmake
+ patch -d "$_basename-$pkgver" -p1 < fix_build_32bit.patch
+ patch -d "$_basename-$pkgver" -p1 < 8ccad693.patch
+ patch -d "$_basename-$pkgver" -p1 < aa67c95b.patch # Port to ffmpeg 5
+ sed -e '/CMAKE_CXX_STANDARD/d' -i "$_basename-$pkgver/CMakeLists.txt" # Don't enforce c++11
}
build() {
@@ -32,31 +37,27 @@ build() {
export CXX='g++ -m32'
export PKG_CONFIG='/usr/bin/i686-pc-linux-gnu-pkg-config'
- cd "${_basename}-${pkgver}"
-
- cmake -S . -B build \
- -DCMAKE_INSTALL_PREFIX=/usr \
- -DLIB_SUFFIX=32 \
- -DCMAKE_BUILD_TYPE='None' \
- -DBUILD_TESTS=ON \
- -DGTEST_SOURCE_DIR=/usr/src/googletest/ \
- -Wno-dev
+ cmake -DCMAKE_INSTALL_PREFIX=/usr \
+ -DLIB_SUFFIX=32 \
+ -DCMAKE_BUILD_TYPE='None' \
+ -DBUILD_TESTS=ON \
+ -DGTEST_SOURCE_DIR=/usr/src/googletest/ \
+ -Wno-dev \
+ -B build \
+ -S "$_basename-$pkgver"
- make VERBOSE=1 -C build
+ cmake --build build
}
check() {
- cd "${_basename}-${pkgver}"
-
- make VERBOSE=1 -C build check
+ cmake --build build --target check
}
package() {
- cd "${_basename}-${pkgver}"
-
- make VERBOSE=1 DESTDIR="${pkgdir}" install -C build
+ DESTDIR="$pkgdir" cmake --install build
- install -vDm 644 LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
+ install -vDm 644 $_basename-$pkgver/LICENSE.md -t "$pkgdir/usr/share/licenses/$pkgname"
+ install -vDm 644 $_basename-$pkgver/{NEWS.txt,README.md} -t "$pkgdir/usr/share/doc/$pkgname"
cd "$pkgdir"/usr
diff --git a/fix_build_32bit.patch b/fix_build_32bit.patch
index ab1c7dfd08be..33cb65864c68 100644
--- a/fix_build_32bit.patch
+++ b/fix_build_32bit.patch
@@ -1,6 +1,6 @@
-diff '--color=auto' --unified --recursive --text chromaprint-v1.5.0.orig/CMakeLists.txt chromaprint-v1.5.0.new/CMakeLists.txt
---- chromaprint-v1.5.0.orig/CMakeLists.txt 2020-04-15 01:08:10.000000000 -0300
-+++ chromaprint-v1.5.0.new/CMakeLists.txt 2020-06-10 01:42:01.000000000 -0300
+diff '--color=auto' --unified --recursive --text chromaprint-1.5.1.orig/CMakeLists.txt chromaprint-1.5.1.new/CMakeLists.txt
+--- chromaprint-1.5.1.orig/CMakeLists.txt 2021-12-23 02:57:54.000000000 -0300
++++ chromaprint-1.5.1.new/CMakeLists.txt 2021-12-28 18:06:18.377350124 -0300
@@ -1,11 +1,21 @@
-cmake_minimum_required(VERSION 3.3)
+cmake_minimum_required(VERSION 2.8.12)
@@ -14,29 +14,27 @@ diff '--color=auto' --unified --recursive --text chromaprint-v1.5.0.orig/CMakeLi
+endif()
+
+project(chromaprint C CXX)
-
+
set(chromaprint_VERSION_MAJOR 1)
set(chromaprint_VERSION_MINOR 5)
- set(chromaprint_VERSION_PATCH 0)
+ set(chromaprint_VERSION_PATCH 1)
set(chromaprint_VERSION "${chromaprint_VERSION_MAJOR}.${chromaprint_VERSION_MINOR}.${chromaprint_VERSION_PATCH}")
-
+
-project(chromaprint LANGUAGES C CXX VERSION "${chromaprint_VERSION}")
+set(PROJECT_VERSION "${chromaprint_VERSION}")
-
+
set(chromaprint_SOVERSION 1)
-
-@@ -21,14 +31,14 @@
-
- find_package(Threads)
-
--option(BUILD_SHARED_LIBS "Build shared libraries" ON)
--
+
+@@ -24,12 +34,14 @@
+
+ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
+
-set(CMAKE_CXX_STANDARD 11)
-+check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
++check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORTS_CXX11)
+if(COMPILER_SUPPORTS_CXX11)
-+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+endif()
-
+
-if(BUILD_SHARED_LIBS)
- set(CMAKE_C_VISIBILITY_PRESET hidden)
- set(CMAKE_CXX_VISIBILITY_PRESET hidden)
@@ -45,13 +43,5 @@ diff '--color=auto' --unified --recursive --text chromaprint-v1.5.0.orig/CMakeLi
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
-
+
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
-@@ -60,6 +70,7 @@
- set(FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to")
- endif()
-
-+option(BUILD_SHARED_LIBS "Build shared libraries" ON)
- option(BUILD_TOOLS "Build command line tools" OFF)
- option(BUILD_TESTS "Build test suite" OFF)
-