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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
From https://github.com/punesemu/puNES/commit/49f86fcf0fab37d4761b713b0a9e7dc342b8f594
From https://github.com/punesemu/puNES/commit/094686fc806c51b105167080fad093f830a9bc04
From https://github.com/punesemu/puNES/commit/057f49044ec547de1ace03911a317a99e31f25cc
--- a/src/core/recording.c
+++ b/src/core/recording.c
@@ -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;
}
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 31, 102)
+ video->avcc->profile = AV_PROFILE_H264_HIGH;
+#else
video->avcc->profile = FF_PROFILE_H264_HIGH;
+#endif
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;
|