File 0001-adjust-detection-of-AVChannelLayout-ffmpeg-5.0.patch of Package aubio
From 2568384e7d3776daf041fa09d422c55ec8755e25 Mon Sep 17 00:00:00 2001
From: Paul Brossier <piem@piem.org>
Date: Wed, 27 Dec 2023 18:58:55 +0100
Subject: [PATCH] adjust detection of AVChannelLayout (> ffmpeg 5.0)
---
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 765a5a1..aa2b006 100644
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -52,6 +52,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"
@@ -255,7 +261,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;
@@ -313,7 +319,7 @@ void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s)
if ( s->avr == NULL ) {
int err;
SwrContext *avr = swr_alloc();
-#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);
@@ -360,7 +366,7 @@ void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
SwrContext *avr = s->avr;
int got_frame = 0;
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;
@@ -430,7 +436,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;
--
2.53.0