1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
From: Paul Brossier <piem@piem.org>
Date: Tue, 7 Oct 2025 09:01:31 +0200
Subject: [source_avcodec] adjust detection of AVChannelLayout (>ffmpeg 5.0)
Origin: upstream, https://github.com/aubio/aubio/commit/0b947f9634937d27589d995ec90e90d763aca86f
Last-Update: 2024-09-17
Last-Update: 2024-09-17
---
src/io/source_avcodec.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/io/source_avcodec.c b/src/io/source_avcodec.c
index 517aca2..bdacf1b 100644
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -56,6 +56,12 @@
#define av_packet_unref av_free_packet
#endif
+#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57,28,100)
+#warning "libavutil < 57.28.100 is deprecated"
+#else
+#define LIBAVUTIL_HAS_CH_LAYOUT
+#endif
+
#include "aubio_priv.h"
#include "fvec.h"
#include "fmat.h"
@@ -263,7 +269,7 @@ aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path,
/* get input specs */
s->input_samplerate = avCodecCtx->sample_rate;
-#ifdef AVUTIL_CHANNEL_LAYOUT_H
+#ifdef LIBAVUTIL_HAS_CH_LAYOUT
s->input_channels = avCodecCtx->ch_layout.nb_channels;
#else
s->input_channels = avCodecCtx->channels;
@@ -325,7 +331,7 @@ void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s)
#elif defined(HAVE_SWRESAMPLE)
SwrContext *avr = swr_alloc();
#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
-#ifdef AVUTIL_CHANNEL_LAYOUT_H
+#ifdef LIBAVUTIL_HAS_CH_LAYOUT
AVChannelLayout input_layout;
AVChannelLayout output_layout;
av_channel_layout_default(&input_layout, s->input_channels);
@@ -387,7 +393,7 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
int out_samples = 0;
#elif defined(HAVE_SWRESAMPLE)
int in_samples = avFrame->nb_samples;
-#ifdef AVUTIL_CHANNEL_LAYOUT_H
+#ifdef LIBAVUTIL_HAS_CH_LAYOUT
int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->ch_layout.nb_channels;
#else
int max_out_samples = AUBIO_AVCODEC_MAX_BUFFER_SIZE / avCodecCtx->channels;
@@ -458,7 +464,7 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
}
#if LIBAVUTIL_VERSION_MAJOR > 52
-#ifdef AVUTIL_CHANNEL_LAYOUT_H
+#ifdef LIBAVUTIL_HAS_CH_LAYOUT
int frame_channels = avFrame->ch_layout.nb_channels;
#else
int frame_channels = avFrame->channels;
|