nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From df8402575f1550d79c751051e9006fd3b7fa0fe0 Mon Sep 17 00:00:00 2001
2From: Hannes Braun <hannes@hannesbraun.net>
3Date: Thu, 9 Oct 2025 20:28:34 +0200
4Subject: [PATCH] Fix compatibility with FFmpeg 8
5
6---
7 src/spek-fft.cc | 25 ++++++++++++++++---------
8 1 file changed, 16 insertions(+), 9 deletions(-)
9
10diff --git a/src/spek-fft.cc b/src/spek-fft.cc
11index 3105213f..00d4fa5c 100644
12--- a/src/spek-fft.cc
13+++ b/src/spek-fft.cc
14@@ -2,7 +2,7 @@
15
16 #define __STDC_CONSTANT_MACROS
17 extern "C" {
18-#include <libavcodec/avfft.h>
19+#include <libavutil/tx.h>
20 }
21
22 #include "spek-fft.h"
23@@ -16,7 +16,10 @@ class FFTPlanImpl : public FFTPlan
24 void execute() override;
25
26 private:
27- struct RDFTContext *cx;
28+ struct AVTXContext *cx;
29+ av_tx_fn tx;
30+ float* tmp;
31+ const int len;
32 };
33
34 std::unique_ptr<FFTPlan> FFT::create(int nbits)
35@@ -24,27 +27,31 @@ std::unique_ptr<FFTPlan> FFT::create(int nbits)
36 return std::unique_ptr<FFTPlan>(new FFTPlanImpl(nbits));
37 }
38
39-FFTPlanImpl::FFTPlanImpl(int nbits) : FFTPlan(nbits), cx(av_rdft_init(nbits, DFT_R2C))
40+FFTPlanImpl::FFTPlanImpl(int nbits) : FFTPlan(nbits), len(1 << nbits)
41 {
42+ const float scale = 1.0;
43+ av_tx_init(&this->cx, &this->tx, AV_TX_FLOAT_RDFT, 0, this->len, &scale, 0);
44+ this->tmp = (float*) av_malloc((this->len + 2) * sizeof(float));
45 }
46
47 FFTPlanImpl::~FFTPlanImpl()
48 {
49- av_rdft_end(this->cx);
50+ av_tx_uninit(&this->cx);
51+ av_freep(&this->tmp);
52 }
53
54 void FFTPlanImpl::execute()
55 {
56- av_rdft_calc(this->cx, this->get_input());
57+ this->tx(this->cx, this->tmp, this->get_input(), sizeof(AVComplexFloat));
58
59 // Calculate magnitudes.
60 int n = this->get_input_size();
61 float n2 = n * n;
62- this->set_output(0, 10.0f * log10f(this->get_input(0) * this->get_input(0) / n2));
63- this->set_output(n / 2, 10.0f * log10f(this->get_input(1) * this->get_input(1) / n2));
64+ this->set_output(0, 10.0f * log10f(this->tmp[0] * this->tmp[0] / n2));
65 for (int i = 1; i < n / 2; i++) {
66- float re = this->get_input(i * 2);
67- float im = this->get_input(i * 2 + 1);
68+ float re = this->tmp[i * 2];
69+ float im = this->tmp[i * 2 + 1];
70 this->set_output(i, 10.0f * log10f((re * re + im * im) / n2));
71 }
72+ this->set_output(n / 2, 10.0f * log10f(this->tmp[this->len] * this->tmp[this->len] / n2));
73 }
74