summaryrefslogtreecommitdiff
path: root/media-video/gpac/files/gpac-2.4.0-ffmpeg9.patch
blob: 3de3392263dc521655142d588700ff25aced0419 (plain)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
FFmpeg 9.0 removed the deprecated AVCodec arrays:
https://github.com/FFmpeg/FFmpeg/commit/38221d0ec9d835e42125c4ff9c71214e27049b24

filters/ff_enc.c: In function ‘ffenc_configure_pid_ex’:
filters/ff_enc.c:1585:37: error: ‘AVCodec’ has no member named ‘pix_fmts’
 1585 |                         while (codec->pix_fmts) {
      |                                     ^~

Closes: https://bugs.gentoo.org/985410
See-also: https://github.com/gpac/gpac/issues/3850
Refs: https://github.com/gpac/gpac/pull/3853
Patch: https://github.com/gpac/gpac/commit/12177a199999c96086a8b2ea55f7c2964cc3c68d

From 89dbea46046035c5c0fe33ffe63e2083ab33e868 Mon Sep 17 00:00:00 2001
From: Romain Bouqueau <romain.bouqueau.pro@gmail.com>
Date: Sun, 9 Aug 2026 21:48:15 -0400
Subject: [PATCH 1/3] ffmpeg9 compat: builds until ffmpeg6 where other
 non-ifdef-ed errors happen anyway

---
 src/filters/ff_enc.c | 74 ++++++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 30 deletions(-)

diff --git a/src/filters/ff_enc.c b/src/filters/ff_enc.c
index 78345df5af..59792fb457 100644
--- a/src/filters/ff_enc.c
+++ b/src/filters/ff_enc.c
@@ -1671,14 +1671,16 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 		if (ctx->pfmt) {
 			u32 ff_pfmt = ffmpeg_pixfmt_from_gpac(ctx->pfmt, GF_FALSE);
 			i=0;
-			while (codec->pix_fmts) {
-				if (codec->pix_fmts[i] == AV_PIX_FMT_NONE) break;
-				if (codec->pix_fmts[i] == ff_pfmt) {
+			const enum AVPixelFormat* codec_pix_fmts = NULL;
+			avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+			while (codec_pix_fmts) {
+				if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
+				if (codec_pix_fmts[i] == ff_pfmt) {
 					force_pfmt = ff_pfmt;
 					break;
 				}
 				//handle pixel formats aliases
-				if (ffmpeg_pixfmt_to_gpac(codec->pix_fmts[i], GF_TRUE) == ctx->pfmt) {
+				if (ffmpeg_pixfmt_to_gpac(codec_pix_fmts[i], GF_TRUE) == ctx->pfmt) {
 					force_pfmt = ctx->pixel_fmt;
 					break;
 				}
@@ -1695,15 +1697,17 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 		if (force_pfmt == AV_PIX_FMT_NONE) {
 			change_input_fmt = AV_PIX_FMT_NONE;
 			i=0;
-			while (codec->pix_fmts) {
-				if (codec->pix_fmts[i] == AV_PIX_FMT_NONE) break;
-				if (codec->pix_fmts[i] == ctx->pixel_fmt) {
+			const enum AVPixelFormat* codec_pix_fmts = NULL;
+			avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+			while (codec_pix_fmts) {
+				if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
+				if (codec_pix_fmts[i] == ctx->pixel_fmt) {
 					change_input_fmt = ctx->pixel_fmt;
 					break;
 				}
 				//handle pixel formats aliases
-				if (ffmpeg_pixfmt_to_gpac(codec->pix_fmts[i], GF_TRUE) == pfmt) {
-					ctx->pixel_fmt = change_input_fmt = codec->pix_fmts[i];
+				if (ffmpeg_pixfmt_to_gpac(codec_pix_fmts[i], GF_TRUE) == pfmt) {
+					ctx->pixel_fmt = change_input_fmt = codec_pix_fmts[i];
 					break;
 				}
 				i++;
@@ -1724,9 +1728,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 					if (codec_alt==codec) continue;
 					if (codec_alt->id == codec_id) {
 						i=0;
-						while (codec_alt->pix_fmts) {
-							if (codec_alt->pix_fmts[i] == AV_PIX_FMT_NONE) break;
-							if (codec_alt->pix_fmts[i] == ctx->pixel_fmt) {
+					const enum AVPixelFormat* codec_alt_pix_fmts = NULL;
+					avcodec_get_supported_config(NULL, codec_alt, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_alt_pix_fmts, NULL);
+						while (codec_alt_pix_fmts) {
+							if (codec_alt_pix_fmts[i] == AV_PIX_FMT_NONE) break;
+							if (codec_alt_pix_fmts[i] == ctx->pixel_fmt) {
 								change_input_fmt = ctx->pixel_fmt;
 								GF_LOG(GF_LOG_WARNING, GF_LOG_CODEC, ("[FFEnc] Reassigning codec from %s to %s to match pixel format\n", codec->name, codec_alt->name ));
 								codec = codec_alt;
@@ -1746,10 +1752,12 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 				ff_pmft = AV_PIX_FMT_NONE;
 				i=0;
 				//find a mapped pixel format
-				while (codec->pix_fmts) {
-					if (codec->pix_fmts[i] == AV_PIX_FMT_NONE) break;
-					if (ffmpeg_pixfmt_to_gpac(codec->pix_fmts[i], GF_TRUE)) {
-						ff_pmft = codec->pix_fmts[i];
+				const enum AVPixelFormat* codec_pix_fmts = NULL;
+				avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+				while (codec_pix_fmts) {
+					if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
+					if (ffmpeg_pixfmt_to_gpac(codec_pix_fmts[i], GF_TRUE)) {
+						ff_pmft = codec_pix_fmts[i];
 						break;
 					}
 					i++;
@@ -1793,21 +1801,25 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 		//check audio format
 		ctx->sample_fmt = ffmpeg_audio_fmt_from_gpac(afmt);
 		change_input_fmt = AV_SAMPLE_FMT_NONE;
-		while (codec->sample_fmts) {
-			if (codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) break;
-			if (codec->sample_fmts[i] == ctx->sample_fmt) {
+		const enum AVSampleFormat *codec_sample_fmts = NULL;
+		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void**)&codec_sample_fmts, NULL);
+		while (codec_sample_fmts) {
+			if (codec_sample_fmts[i] == AV_SAMPLE_FMT_NONE) break;
+			if (codec_sample_fmts[i] == ctx->sample_fmt) {
 				change_input_fmt = ctx->sample_fmt;
 				break;
 			}
 			i++;
 		}
 		i=0;
-		if (!codec->supported_samplerates)
+		const int *codec_supported_samplerates = NULL;
+		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0, (const void**)&codec_supported_samplerates, NULL);
+		if (!codec_supported_samplerates)
 			change_input_sr = ctx->sample_rate;
 
-		while (codec->supported_samplerates) {
-			if (!codec->supported_samplerates[i]) break;
-			if (codec->supported_samplerates[i]==ctx->sample_rate) {
+		while (codec_supported_samplerates) {
+			if (!codec_supported_samplerates[i]) break;
+			if (codec_supported_samplerates[i]==ctx->sample_rate) {
 				change_input_sr = ctx->sample_rate;
 				break;
 			}
@@ -1832,12 +1844,14 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			i++;
 		}
 #else
-		if (!codec->ch_layouts)
+		const AVChannelLayout *codec_ch_layouts = NULL;
+		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, (const void**)&codec_ch_layouts, NULL);
+		if (!codec_ch_layouts)
 			change_chan_layout = ctx->channel_layout;
 
-		while (codec->ch_layouts) {
-			if (!codec->ch_layouts[i].nb_channels) break;
-			if (codec->ch_layouts[i].u.mask == ff_ch_layout) {
+		while (codec_ch_layouts) {
+			if (!codec_ch_layouts[i].nb_channels) break;
+			if (codec_ch_layouts[i].u.mask == ff_ch_layout) {
 				change_chan_layout = ctx->channel_layout;
 				break;
 			}
@@ -1855,19 +1869,19 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			|| (ctx->channel_layout != change_chan_layout)
 		) {
 			if (ctx->sample_fmt != change_input_fmt) {
-				ctx->sample_fmt = codec->sample_fmts ? codec->sample_fmts[0] : AV_SAMPLE_FMT_S16;
+				ctx->sample_fmt = codec_sample_fmts ? codec_sample_fmts[0] : AV_SAMPLE_FMT_S16;
 				afmt = ffmpeg_audio_fmt_to_gpac(ctx->sample_fmt);
 				gf_filter_pid_negotiate_property(ctx->in_pid, GF_PROP_PID_AUDIO_FORMAT, &PROP_UINT(afmt) );
 			}
 			if (ctx->sample_rate != change_input_sr) {
-				gf_filter_pid_negotiate_property(ctx->in_pid, GF_PROP_PID_SAMPLE_RATE, &PROP_UINT(codec->supported_samplerates[0]) );
+				gf_filter_pid_negotiate_property(ctx->in_pid, GF_PROP_PID_SAMPLE_RATE, &PROP_UINT(codec_supported_samplerates[0]) );
 			}
 			if (ctx->channel_layout != change_chan_layout) {
 				if (!change_chan_layout) {
 #ifdef FFMPEG_OLD_CHLAYOUT
 					change_chan_layout = ffmpeg_channel_layout_to_gpac(codec->channel_layouts[0]);
 #else
-					change_chan_layout = ffmpeg_channel_layout_to_gpac(codec->ch_layouts[0].u.mask);
+					change_chan_layout = ffmpeg_channel_layout_to_gpac(codec_ch_layouts[0].u.mask);
 #endif
 				}
 				u32 nb_chans = gf_audio_fmt_get_num_channels_from_layout(change_chan_layout);

From aecc4a4af093d7113edd5881a8b95eefd1da94d6 Mon Sep 17 00:00:00 2001
From: Romain Bouqueau <romain.bouqueau.pro@gmail.com>
Date: Mon, 10 Aug 2026 08:02:30 -0400
Subject: [PATCH 2/3] ffmpeg9 removed libpostproc in ALLFFLIBS
 (https://github.com/FFmpeg/FFmpeg/commit/12497766410135f27012077e78b3bdcfc704f7ca)
 and we don't really test it anyway

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 8e0479a4d8..40ba5251f3 100755
--- a/configure
+++ b/configure
@@ -1717,7 +1717,7 @@ config_package faad "faad2" "" "-lfaad -lm" "" '#include <faad.h>
 int main( void ) { NeAACDecOpen(); return 0; }'
 
 
-ffmpeg_lflags="-lz -lavcodec -lavformat -lavutil -lswscale -lpostproc"
+ffmpeg_lflags="-lz -lavcodec -lavformat -lavutil -lswscale"
 ffmpeg_pck_names="libavcodec libavformat libswscale libavutil"
 
 if test "$is_em" = "yes" ; then

From 596affc92c14d84cb9a86cb2af06b403c96d7397 Mon Sep 17 00:00:00 2001
From: Romain Bouqueau <romain.bouqueau.pro@gmail.com>
Date: Mon, 10 Aug 2026 08:22:22 -0400
Subject: [PATCH 3/3] ffmpeg9: add ifdef around api change
 (avcodec_get_supported_config/FFMPEG_HAS_GET_SUPPORTED_CONFIG)

---
 src/filters/ff_common.h |  4 ++++
 src/filters/ff_enc.c    | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/src/filters/ff_common.h b/src/filters/ff_common.h
index 54f37016c7..8424b67153 100644
--- a/src/filters/ff_common.h
+++ b/src/filters/ff_common.h
@@ -68,6 +68,10 @@
 #define FFMPEG_OLD_CHLAYOUT
 #endif
 
+#if AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, LIBAVCODEC_VERSION_MINOR, LIBAVCODEC_VERSION_MICRO) > AV_VERSION_INT(61, 100, 13)
+#define FFMPEG_HAS_GET_SUPPORTED_CONFIG
+#endif
+
 
 GF_FilterArgs ffmpeg_arg_translate(const struct AVOption *opt);
 void ffmpeg_setup_logs(u32 log_class);
diff --git a/src/filters/ff_enc.c b/src/filters/ff_enc.c
index 59792fb457..13db0b144b 100644
--- a/src/filters/ff_enc.c
+++ b/src/filters/ff_enc.c
@@ -1672,7 +1672,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			u32 ff_pfmt = ffmpeg_pixfmt_from_gpac(ctx->pfmt, GF_FALSE);
 			i=0;
 			const enum AVPixelFormat* codec_pix_fmts = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 			avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+#else
+			codec_pix_fmts = codec->pix_fmts;
+#endif
 			while (codec_pix_fmts) {
 				if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
 				if (codec_pix_fmts[i] == ff_pfmt) {
@@ -1698,7 +1702,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			change_input_fmt = AV_PIX_FMT_NONE;
 			i=0;
 			const enum AVPixelFormat* codec_pix_fmts = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 			avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+#else
+			codec_pix_fmts = codec->pix_fmts;
+#endif
 			while (codec_pix_fmts) {
 				if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
 				if (codec_pix_fmts[i] == ctx->pixel_fmt) {
@@ -1728,8 +1736,12 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 					if (codec_alt==codec) continue;
 					if (codec_alt->id == codec_id) {
 						i=0;
-					const enum AVPixelFormat* codec_alt_pix_fmts = NULL;
-					avcodec_get_supported_config(NULL, codec_alt, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_alt_pix_fmts, NULL);
+						const enum AVPixelFormat* codec_alt_pix_fmts = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
+						avcodec_get_supported_config(NULL, codec_alt, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_alt_pix_fmts, NULL);
+#else
+						codec_alt_pix_fmts = codec_alt->pix_fmts;
+#endif
 						while (codec_alt_pix_fmts) {
 							if (codec_alt_pix_fmts[i] == AV_PIX_FMT_NONE) break;
 							if (codec_alt_pix_fmts[i] == ctx->pixel_fmt) {
@@ -1753,7 +1765,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 				i=0;
 				//find a mapped pixel format
 				const enum AVPixelFormat* codec_pix_fmts = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 				avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, (const void**)&codec_pix_fmts, NULL);
+#else
+				codec_pix_fmts = codec->pix_fmts;
+#endif
 				while (codec_pix_fmts) {
 					if (codec_pix_fmts[i] == AV_PIX_FMT_NONE) break;
 					if (ffmpeg_pixfmt_to_gpac(codec_pix_fmts[i], GF_TRUE)) {
@@ -1802,7 +1818,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 		ctx->sample_fmt = ffmpeg_audio_fmt_from_gpac(afmt);
 		change_input_fmt = AV_SAMPLE_FMT_NONE;
 		const enum AVSampleFormat *codec_sample_fmts = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void**)&codec_sample_fmts, NULL);
+#else
+		codec_sample_fmts = codec->sample_fmts;
+#endif
 		while (codec_sample_fmts) {
 			if (codec_sample_fmts[i] == AV_SAMPLE_FMT_NONE) break;
 			if (codec_sample_fmts[i] == ctx->sample_fmt) {
@@ -1813,7 +1833,11 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 		}
 		i=0;
 		const int *codec_supported_samplerates = NULL;
+#ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0, (const void**)&codec_supported_samplerates, NULL);
+#else
+		codec_supported_samplerates = codec->supported_samplerates;
+#endif
 		if (!codec_supported_samplerates)
 			change_input_sr = ctx->sample_rate;
 
@@ -1843,9 +1867,13 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			}
 			i++;
 		}
-#else
+#else /* !FFMPEG_OLD_CHLAYOUT */
 		const AVChannelLayout *codec_ch_layouts = NULL;
+# ifdef FFMPEG_HAS_GET_SUPPORTED_CONFIG
 		avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, (const void**)&codec_ch_layouts, NULL);
+# else
+		codec_ch_layouts = codec->ch_layouts;
+# endif
 		if (!codec_ch_layouts)
 			change_chan_layout = ctx->channel_layout;
 
@@ -1857,7 +1885,7 @@ static GF_Err ffenc_configure_pid_ex(GF_Filter *filter, GF_FilterPid *pid, Bool
 			}
 			i++;
 		}
-#endif
+#endif /* !FFMPEG_OLD_CHLAYOUT */
 		//vorbis in ffmpeg currently requires stereo but channel_layouts is not set
 		if (ctx->codecid==GF_CODECID_VORBIS) {
 			change_chan_layout = gf_audio_fmt_get_layout_from_cicp(gf_audio_fmt_get_cicp_layout(2, 0, 0));