app-emulation/punes: re-apply fix for ffmpeg-8

Closes: https://bugs.gentoo.org/969619
Signed-off-by: Azamat H. Hackimov <azamat.hackimov@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/45900
Closes: https://github.com/gentoo/gentoo/pull/45900
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Azamat H. Hackimov
2026-03-07 20:36:01 +03:00
committed by Sam James
parent d839307ac4
commit 957daaafd2

View File

@@ -1,13 +1,38 @@
From https://github.com/punesemu/puNES/commit/49f86fcf0fab37d4761b713b0a9e7dc342b8f594
From https://github.com/punesemu/puNES/commit/094686fc806c51b105167080fad093f830a9bc04
From https://github.com/punesemu/puNES/commit/057f49044ec547de1ace03911a317a99e31f25cc
From: Essem <smswessem@gmail.com>
Date: Wed, 31 Dec 2025 03:05:30 -0600
Subject: [PATCH] Fix build on FFmpeg 8.0 (#444)
`FF_PROFILE_H264_HIGH` has been deprecated since FFmpeg 6.1, with
`AV_PROFILE_H264_HIGH` acting as its replacement.
--- a/src/core/recording.c
+++ b/src/core/recording.c
@@ -1058,7 +1058,11 @@ static BYTE ffmpeg_video_add_stream_format_h264(void) {
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2024 Fabio Cavallo (aka FHorse)
+ * Copyright (C) 2010-2026 Fabio Cavallo (aka FHorse)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -204,8 +204,10 @@ void recording_init(void) {
}
av_dict_free(&opts);
opts = NULL;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 0, 0)
avcodec_close(test);
- av_free(test);
+#endif
+ avcodec_free_context(&test);
if (finded) {
break;
}
@@ -487,7 +489,9 @@ static void ffmpeg_fstream_close(_ffmpeg_stream *fs) {
fs->encode = FALSE;
fs->avc = NULL;
if (fs->avcc) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 0, 0)
avcodec_close(fs->avcc);
+#endif
avcodec_free_context(&fs->avcc);
}
if (fs->avf) {
@@ -1054,7 +1058,11 @@ static BYTE ffmpeg_video_add_stream_format_h264(void) {
if (vbr < 4000) {
vbr = 4000;
}
@@ -19,3 +44,98 @@ Subject: [PATCH] Fix build on FFmpeg 8.0 (#444)
video->avcc->bit_rate = (int64_t)vbr;
}
video->avcc->thread_count = FFMIN(8, gui_hardware_concurrency());
@@ -1453,8 +1461,16 @@ INLINE static BYTE ffmpeg_audio_write_frame(SWORD *data) {
}
static enum AVSampleFormat ffmpeg_audio_select_sample_fmt(const AVCodec *codec) {
- const enum AVSampleFormat *p = codec->sample_fmts;
+ const enum AVSampleFormat *sample_fmts = NULL;
+ const enum AVSampleFormat *p = NULL;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 13, 100)
+ sample_fmts = codec->sample_fmts;
+#else
+ avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **)&sample_fmts, NULL);
+#endif
+
+ p = sample_fmts;
if (!p) {
return (AV_SAMPLE_FMT_S16);
}
@@ -1465,13 +1481,20 @@ static enum AVSampleFormat ffmpeg_audio_select_sample_fmt(const AVCodec *codec)
}
p++;
}
- return (codec->sample_fmts[0]);
+ return (sample_fmts[0]);
}
static int ffmpeg_audio_select_samplerate(const AVCodec *codec) {
int snd_sample_rate = (snd.samplerate ? snd.samplerate : 44100), best_samplerate = 0;
+ const int *supported_samplerates = NULL;
const int *p = NULL;
- if (!codec->supported_samplerates) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 13, 100)
+ supported_samplerates = codec->supported_samplerates;
+#else
+ avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0, (const void **)&supported_samplerates, NULL);
+#endif
+
+ if (supported_samplerates == NULL) {
switch (codec->id) {
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
@@ -1488,13 +1511,13 @@ static int ffmpeg_audio_select_samplerate(const AVCodec *codec) {
}
}
- p = codec->supported_samplerates;
+ p = supported_samplerates;
while (*p) {
best_samplerate = FFMAX(*p, best_samplerate);
p++;
}
- p = codec->supported_samplerates;
+ p = supported_samplerates;
while (*p) {
if ((*p) == snd_sample_rate) {
best_samplerate = snd_sample_rate;
@@ -1605,10 +1628,17 @@ static AVFrame *ffmpeg_audio_alloc_frame(enum AVSampleFormat sample_fmt, const A
return (avframe);
}
static int ffmpeg_audio_select_channel_layout(const AVCodec *codec, AVChannelLayout *dst) {
- const AVChannelLayout *p = NULL, *best_ch_layout = NULL;
+ const AVChannelLayout *best_ch_layout = NULL;
+ const AVChannelLayout *ch_layouts = NULL;
+ const AVChannelLayout *p = NULL;
int best_nb_channels = 0;
- if (!codec->ch_layouts) {
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 13, 100)
+ ch_layouts = codec->ch_layouts;
+#else
+ avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, (const void **)&ch_layouts, NULL);
+#endif
+ if (ch_layouts == NULL) {
switch (codec->id) {
case AV_CODEC_ID_PCM_S16LE:
case AV_CODEC_ID_PCM_S16BE:
@@ -1628,7 +1658,7 @@ static int ffmpeg_audio_select_channel_layout(const AVCodec *codec, AVChannelLay
}
}
- p = codec->ch_layouts;
+ p = ch_layouts;
while (p->nb_channels) {
int nb_channels = p->nb_channels;
@@ -1639,7 +1669,7 @@ static int ffmpeg_audio_select_channel_layout(const AVCodec *codec, AVChannelLay
p++;
}
- p = codec->ch_layouts;
+ p = ch_layouts;
while (p->nb_channels) {
int nb_channels = p->nb_channels;