Build tools on F36+ with ffmpeg-free

Also, clean out extra whitespace in the spec file.
This commit is contained in:
Neal Gompa 2022-04-21 09:00:01 -04:00
parent 4b3d4369ac
commit ee7a83083d
2 changed files with 118 additions and 10 deletions

View File

@ -0,0 +1,74 @@
From 6d938d70b1d52634f8b0d88cb29da87f8d5b35a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
Date: Mon, 17 Jan 2022 04:41:33 +0100
Subject: [PATCH] Port to ffmpeg 5.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Replace removed functionality like accessing the codec context
from an AVStream and avcodec_decode_audio4()
Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
---
src/audio/ffmpeg_audio_reader.h | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/audio/ffmpeg_audio_reader.h b/src/audio/ffmpeg_audio_reader.h
index 5550164..a3b8de7 100644
--- a/src/audio/ffmpeg_audio_reader.h
+++ b/src/audio/ffmpeg_audio_reader.h
@@ -74,7 +74,7 @@ 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;
@@ -153,7 +153,7 @@ 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);
@@ -161,7 +161,13 @@ inline bool FFmpegAudioReader::Open(const std::string &file_name) {
}
m_stream_index = ret;
+#if LIBAVCODEC_VERSION_MAJOR >= 59
+ const AVCodec *streamcodec = avcodec_find_decoder(m_format_ctx->streams[m_stream_index]->codecpar->codec_id);
+ m_codec_ctx = avcodec_alloc_context3(streamcodec);
+ avcodec_parameters_to_context(m_codec_ctx, m_format_ctx->streams[m_stream_index]->codecpar);
+#else
m_codec_ctx = m_format_ctx->streams[m_stream_index]->codec;
+#endif
m_codec_ctx->request_sample_fmt = AV_SAMPLE_FMT_S16;
ret = avcodec_open2(m_codec_ctx, codec, nullptr);
@@ -278,7 +284,21 @@ inline bool FFmpegAudioReader::Read(const int16_t **data, size_t *size) {
}
}
+#if LIBAVCODEC_VERSION_MAJOR < 59
ret = avcodec_decode_audio4(m_codec_ctx, m_frame, &m_got_frame, &m_packet);
+#else
+ ret = avcodec_receive_frame(m_codec_ctx, m_frame);
+ if (ret == 0)
+ m_got_frame = true;
+ if(ret == AVERROR(EAGAIN))
+ ret = 0;
+ if (ret == 0)
+ ret = avcodec_send_packet(m_codec_ctx, &m_packet);
+ if (ret == AVERROR(EAGAIN))
+ ret = 0;
+ if (ret >= 0)
+ ret = m_packet.size;
+#endif
if (ret < 0) {
if (m_decode_error) {
SetError("Error decoding audio frame", m_decode_error);

View File

@ -1,20 +1,29 @@
%if 0%{?fedora} >= 36
%bcond_without ffmpeg
%else
%bcond_with ffmpeg
%endif
Name: chromaprint
Version: 1.5.1
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Library implementing the AcoustID fingerprinting
License: GPLv2+
URL: http://www.acoustid.org/chromaprint
Source: https://github.com/acoustid/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz
# From: https://github.com/acoustid/chromaprint/pull/108
Patch: chromaprint-PR108-Port-to-ffmpeg-5.patch
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: fftw-devel >= 3
%description
Chromaprint library is the core component of the AcoustID project. It's a
client-side library that implements a custom algorithm for extracting
Chromaprint library is the core component of the AcoustID project. It's a
client-side library that implements a custom algorithm for extracting
fingerprints from raw audio sources.
The library exposes a simple C API. The documentation for the C API can be
@ -27,8 +36,8 @@ Summary: Library implementing the AcoustID fingerprinting
Obsoletes: python-chromaprint < 0.6-3
%description -n libchromaprint
Chromaprint library is the core component of the AcoustID project. It's a
client-side library that implements a custom algorithm for extracting
Chromaprint library is the core component of the AcoustID project. It's a
client-side library that implements a custom algorithm for extracting
fingerprints from raw audio sources.
The library exposes a simple C API. The documentation for the C API can be
@ -37,26 +46,42 @@ found in the main header file.
License for binaries is GPLv2+ but source code is MIT + LGPLv2+
%package -n libchromaprint-devel
Summary: Headers for developing programs that will use %{name}
Summary: Headers for developing programs that will use %{name}
Requires: libchromaprint%{?_isa} = %{version}-%{release}
%description -n libchromaprint-devel
This package contains the headers that programmers will need to develop
applications which will use %{name}.
applications which will use %{name}.
The library exposes a simple C API. The documentation for the C API can be
found in the main header file.
%if %{with ffmpeg}
%package tools
Summary: Chromaprint audio fingerprinting tools
BuildRequires: ffmpeg-free-devel
Requires: libchromaprint%{?_isa} = %{version}-%{release}
%description tools
Chromaprint library is the core component of the AcoustID project. It's a
client-side library that implements a custom algorithm for extracting
fingerprints from raw audio sources.
This is a set of Chromaprint tools related to acoustic fingerprinting
featuring fpcalc an standalone AcoustID tool used by Picard.
License for binaries is GPLv2+ but source code is MIT + LGPLv2+
%endif
%prep
%autosetup -n %{name}-%{version}
%autosetup -p1
%build
# examples and cli tools equire ffmpeg, so turn off; test depend of external artifact so turn off.
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTS=OFF \
-DBUILD_TOOLS=OFF \
.
-DBUILD_TOOLS=%{?with_ffmpeg:ON}%{!?with_ffmpeg:OFF}
%cmake_build
@ -76,7 +101,16 @@ rm -f %{buildroot}%{_libdir}/lib*.la
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/*.pc
%if %{with ffmpeg}
%files tools
%{_bindir}/fpcalc
%endif
%changelog
* Thu Apr 21 2022 Neal Gompa <ngompa@fedoraproject.org> - 1.5.1-3
- Build tools on F36+ with ffmpeg-free
- Clean out extra whitespace in the spec file
* Wed Jan 19 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild