# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/gpac/hotfix-ffmpeg.patch # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- # from arch diff --git a/src/filters/ff_enc.c b/src/filters/ff_enc.c index 78345df5a..59792fb45 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);