--- a/libffabi/src/ffabi.c 2024-05-14 18:23:17.000000000 +0200 +++ b/libffabi/src/ffabi.c 2026-09-19 00:02:11.395239310 +0200 @@ -33,6 +33,33 @@ static ffm_realloc_t proc_realloc = NULL; static ffm_free_t proc_free = NULL; +static const AVChannelLayout *ffabi_get_ch_layouts(const AVCodec *codec) +{ + const AVChannelLayout *ch_layouts = NULL; + int nb = 0; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **)&ch_layouts, &nb); + return ch_layouts; +} + +static const int *ffabi_get_supported_samplerates(const AVCodec *codec) +{ + const int *rates = NULL; + int nb = 0; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **)&rates, &nb); + return rates; +} + +static const enum AVSampleFormat *ffabi_get_sample_fmts(const AVCodec *codec) +{ + const enum AVSampleFormat *fmts = NULL; + int nb = 0; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **)&fmts, &nb); + return fmts; +} + void *ffabi_memalign(size_t align, size_t size) { return (*proc_memalign)(align,size); @@ -211,8 +238,7 @@ av_packet_free(&ctx->pck); if (ctx->avctx) { - avcodec_close(ctx->avctx); - av_free(ctx->avctx); + avcodec_free_context(&(ctx->avctx)); } av_free(ctx); @@ -374,7 +400,7 @@ #endif ctx->avctx->profile = (info->profile != FFM_PROFILE_UNKNOWN) ? - info->profile : FF_PROFILE_UNKNOWN; + info->profile : AV_PROFILE_UNKNOWN; if ((CodecFlags&FFM_CODEC_FLAG_GLOBAL_HEADER)!=0) ctx->avctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; @@ -420,8 +446,7 @@ av_freep(&ctx->frame_extended_data); if (ctx->avctx) { - avcodec_close(ctx->avctx); - av_free(ctx->avctx); + avcodec_free_context(&(ctx->avctx)); } av_free(ctx); @@ -537,12 +562,13 @@ unsigned int count_ch_layouts_out = 0; uint64_t* channel_layouts; unsigned int i; + const AVChannelLayout* ch_layouts = ffabi_get_ch_layouts(codec); len = strlen(codec->name); if (len >= FFM_CODEC_INFO_NAME_MAX_LENGTH) return -1; - if (NULL != codec->ch_layouts) { - while (0 != codec->ch_layouts[count_ch_layouts_in].nb_channels) + if (NULL != ch_layouts) { + while (0 != ch_layouts[count_ch_layouts_in].nb_channels) { count_ch_layouts_in++; } @@ -560,8 +586,8 @@ for (i = 0; i < count_ch_layouts_in; i++) { - if (AV_CHANNEL_ORDER_NATIVE != codec->ch_layouts[i].order) continue; - channel_layouts[count_ch_layouts_out++] = codec->ch_layouts[i].u.mask; + if (AV_CHANNEL_ORDER_NATIVE != ch_layouts[i].order) continue; + channel_layouts[count_ch_layouts_out++] = ch_layouts[i].u.mask; } channel_layouts[count_ch_layouts_out] = 0; @@ -573,6 +599,8 @@ { AVCodec* codec; int i; + const AVChannelLayout* ch_layouts; + const enum AVSampleFormat* sample_fmts; memset(info, 0, sizeof(*info)); @@ -588,11 +616,11 @@ info->name = codec->name; info->long_name = codec->long_name; - info->sample_rates = codec->supported_samplerates; + info->sample_rates = ffabi_get_supported_samplerates(codec); #ifdef FFABI_HAVE_OLD_CHANNEL_LAYOUT info->channel_layouts = codec->channel_layouts; #else - if (NULL == codec->ch_layouts) { + if (NULL == ch_layouts) { info->channel_layouts = NULL; } else { if (set_codec_info_extended(info, codec)) { @@ -604,18 +632,19 @@ info->capabilities = codec->capabilities; if (codec->profiles) { for (i=0;i<32;i++) { - if (codec->profiles[i].profile==FF_PROFILE_UNKNOWN) + if (codec->profiles[i].profile==AV_PROFILE_UNKNOWN) break; info->profiles_names[i]=codec->profiles[i].name; info->profiles_values[i]=codec->profiles[i].profile; info->profiles_count = i+1; } } - if (codec->sample_fmts) { + sample_fmts = ffabi_get_sample_fmts(codec); + if (sample_fmts) { for (i=0;i<16;i++) { - if (codec->sample_fmts[i]==AV_SAMPLE_FMT_NONE) + if (sample_fmts[i]==AV_SAMPLE_FMT_NONE) break; - info->sample_formats[i]=(uint8_t)back_translate_sample_fmt(codec->sample_fmts[i]); + info->sample_formats[i]=(uint8_t)back_translate_sample_fmt(sample_fmts[i]); info->sample_formats_count = i+1; } } @@ -695,8 +724,7 @@ } if (avctx) { - avcodec_close(avctx); - av_free(avctx); + avcodec_free_context(&avctx); } return err; }