deadbeef: cherry-pick from upstream the commit for ffmpeg 7

This commit is contained in:
John McQuah 2024-08-30 13:08:23 +00:00
parent 3ccc878a23
commit ac4b083b7c
3 changed files with 173 additions and 5 deletions

View File

@ -1,6 +1,7 @@
untrusted comment: verify with /etc/ports/jmq.pub
RWTTPlFarK9CxENLU5vibFJbRXGl8E2Uw0VdqRmAxqmYk2dELPA7sjs01xohMQ7sH6Diw+O2ZMnHMGTXkKAVr7W9OQcHhddd8Qo=
SHA256 (Pkgfile) = a6a3646e615cf043ddad5161940d2f62faa0a8a6b2c6201f808ac1910f6cb8c9
RWTTPlFarK9CxC2pw2FeFep5FKbGY1sch6+WO/aYdBgrwG+WLlN/jCb5n5BKdhIwcAL/y+LNL5lZz8oTmJBiLQ4oGYHslMnoGAI=
SHA256 (Pkgfile) = a2ab2aee19a39c27315652fd4e061bb70b0a75381e53ee90a51c8e5dc5ccb1a5
SHA256 (.footprint) = 9560351c569f21d9b7312c91e3c9fabd88a7dd5e29bd1ef83b62da223fd5f190
SHA256 (deadbeef-1.9.6.tar.bz2) = 9d77b3d8afdeab5027d24bd18e9cfc04ce7d6ab3ddc043cc8e84c82b41b79c04
SHA256 (dbq) = 9a30884403429b68ac00266b4b0aa92d7d643a4185be9802759b14d07ea46fa3
SHA256 (support-ffmpeg7-api.patch) = d544041b162c3abbfa64b4a3ff1d3084cf14e5680db81903f9828190dbf8b129

View File

@ -2,15 +2,16 @@
# URL: http://deadbeef.sourceforge.io
# Maintainer: John McQuah, jmcquah at disroot dot org
# Depends on: alsa-lib gtk3 jansson libdispatch libmad yasm
# Optional: cdparanoia libcdio libsndfile libsamplerate mpg123 flac libogg libvorbis faad2 wildmidi dbus opusfile pulseaudio pipewire wavpack libzip
# Optional: libcdio libsndfile libsamplerate mpg123 flac libogg libvorbis faad2 ffmpeg wildmidi dbus opusfile pulseaudio pipewire wavpack libzip
name=deadbeef
version=1.9.6
release=1
source=(https://sourceforge.net/projects/$name/files/travis/linux/$version/$name-$version.tar.bz2 dbq)
release=2
source=(https://sourceforge.net/projects/$name/files/travis/linux/$version/$name-$version.tar.bz2 dbq support-ffmpeg7-api.patch)
build() {
cd $name-$version
patch -Np1 -i ../support-ffmpeg7-api.patch
sed -e "/CFLAGS/s/ -Werror//" -i plugins/gtkui/Makefile.*
sed -e "/CFLAGS/s/ -Werror//" -i configure

View File

@ -0,0 +1,166 @@
--- a/plugins/ffmpeg/ffmpeg.c 2023-11-07 18:15:17.000000000 +0000
+++ b/plugins/ffmpeg/ffmpeg.c 2024-06-22 15:09:29.000000000 +0000
@@ -62,7 +62,7 @@
typedef struct {
DB_fileinfo_t info;
- AVCodec *codec;
+ const AVCodec *codec;
AVCodecContext *codec_context;
int need_to_free_codec_context;
AVFormatContext *format_context;
@@ -115,12 +115,20 @@
// ensure that the buffer can contain entire frame of frame_size bytes per channel
static int
ensure_buffer (ffmpeg_info_t *info, size_t frame_size) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ if (!info->buffer || info->buffer_size < frame_size * info->codec_context->ch_layout.nb_channels) {
+#else
if (!info->buffer || info->buffer_size < frame_size * info->codec_context->channels) {
+#endif
if (info->buffer) {
free (info->buffer);
info->buffer = NULL;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ info->buffer_size = frame_size*info->codec_context->ch_layout.nb_channels;
+#else
info->buffer_size = frame_size*info->codec_context->channels;
+#endif
info->left_in_buffer = 0;
int err = posix_memalign ((void **)&info->buffer, 16, info->buffer_size);
if (err) {
@@ -137,7 +145,7 @@
if (format_context->streams[stream_index]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
return 0;
}
- AVCodec *codec = avcodec_find_decoder(format_context->streams[stream_index]->codecpar->codec_id);
+ const AVCodec *codec = avcodec_find_decoder(format_context->streams[stream_index]->codecpar->codec_id);
if (codec == NULL) {
return 0;
}
@@ -154,7 +162,7 @@
if (ctx == NULL) {
return 0;
}
- AVCodec *codec = avcodec_find_decoder (ctx->codec_id);
+ const AVCodec *codec = avcodec_find_decoder (ctx->codec_id);
if (codec == NULL) {
return 0;
}
@@ -231,7 +239,11 @@
int bps = av_get_bytes_per_sample (info->codec_context->sample_fmt)*8;
int samplerate = info->codec_context->sample_rate;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ if (bps <= 0 || info->codec_context->ch_layout.nb_channels <= 0 || samplerate <= 0) {
+#else
if (bps <= 0 || info->codec_context->channels <= 0 || samplerate <= 0) {
+#endif
return -1;
}
@@ -248,7 +260,12 @@
_info->plugin = &plugin.decoder;
_info->readpos = 0;
_info->fmt.bps = bps;
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ _info->fmt.channels = info->codec_context->ch_layout.nb_channels;
+#else
_info->fmt.channels = info->codec_context->channels;
+#endif
+
_info->fmt.samplerate = samplerate;
if (info->codec_context->sample_fmt == AV_SAMPLE_FMT_FLT || info->codec_context->sample_fmt == AV_SAMPLE_FMT_FLTP) {
_info->fmt.is_float = 1;
@@ -296,7 +313,9 @@
av_packet_unref (&info->pkt);
}
if (info->codec_context) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 0, 0)
avcodec_close (info->codec_context);
+#endif
// The ctx is owned by AVFormatContext in legacy mode
if (info->need_to_free_codec_context) {
@@ -396,7 +415,11 @@
return -1;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ int chCnt = info->codec_context->ch_layout.nb_channels;
+#else
int chCnt = info->codec_context->channels;
+#endif
int chSize = info->pkt.size / chCnt;
uint32_t *pOut = (uint32_t *)info->buffer;
uint8_t marker = 0x05;
@@ -462,25 +485,30 @@
return -1;
}
if (av_sample_fmt_is_planar(info->codec_context->sample_fmt)) {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ int chCnt = info->codec_context->ch_layout.nb_channels;
+#else
+ int chCnt = info->codec_context->channels;
+#endif
out_size = 0;
- for (int c = 0; c < info->codec_context->channels; c++) {
+ for (int c = 0; c < chCnt; c++) {
for (int i = 0; i < info->frame->nb_samples; i++) {
if (_info->fmt.bps == 8) {
- info->buffer[i*info->codec_context->channels+c] = ((int8_t *)info->frame->extended_data[c])[i];
+ info->buffer[i*chCnt+c] = ((int8_t *)info->frame->extended_data[c])[i];
out_size++;
}
else if (_info->fmt.bps == 16) {
int16_t outsample = ((int16_t *)info->frame->extended_data[c])[i];
- ((int16_t*)info->buffer)[i*info->codec_context->channels+c] = outsample;
+ ((int16_t*)info->buffer)[i*chCnt+c] = outsample;
out_size += 2;
}
else if (_info->fmt.bps == 24) {
- memcpy (&info->buffer[(i*info->codec_context->channels+c)*3], &((int8_t*)info->frame->extended_data[c])[i*3], 3);
+ memcpy (&info->buffer[(i*chCnt+c)*3], &((int8_t*)info->frame->extended_data[c])[i*3], 3);
out_size += 3;
}
else if (_info->fmt.bps == 32) {
int32_t sample = ((int32_t *)info->frame->extended_data[c])[i];
- ((int32_t*)info->buffer)[i*info->codec_context->channels+c] = sample;
+ ((int32_t*)info->buffer)[i*chCnt+c] = sample;
out_size += 4;
}
}
@@ -784,7 +812,11 @@
trace ("ffmpeg: samplerate is %d\n", samplerate);
trace ("ffmpeg: duration is %f\n", duration);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ if (bps <= 0 || info.codec_context->ch_layout.nb_channels <= 0 || samplerate <= 0) {
+#else
if (bps <= 0 || info.codec_context->channels <= 0 || samplerate <= 0) {
+#endif
goto error;
}
@@ -819,7 +851,11 @@
deadbeef->pl_add_meta (it, ":FILE_SIZE", s);
snprintf (s, sizeof (s), "%d", bps);
deadbeef->pl_add_meta (it, ":BPS", s);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0)
+ snprintf (s, sizeof (s), "%d", info.codec_context->ch_layout.nb_channels);
+#else
snprintf (s, sizeof (s), "%d", info.codec_context->channels);
+#endif
deadbeef->pl_add_meta (it, ":CHANNELS", s);
if (is_codec_dsd(info.codec_context->codec_id)) {
snprintf (s, sizeof (s), "%d", samplerate * 8);
@@ -904,7 +940,7 @@
n = add_new_exts (n, new_exts, ';');
}
else {
- AVInputFormat *ifmt = NULL;
+ const AVInputFormat *ifmt = NULL;
/*
* It's quite complicated to enumerate all supported extensions in
* ffmpeg. If a decoder defines extensions in ffmpeg, the probing