diff options
author | Niklas Haas <git@haasn.dev> | 2024-04-05 19:21:43 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2024-09-08 13:59:29 +0200 |
commit | 088108fc7a24d28b0a83b051b5027ebe32d20f30 (patch) | |
tree | 6258a793f70409d6f1264bb80b35337786fa0753 | |
parent | 13cec7bb5fbaad4e41fba32bb73f5835137abd3b (diff) | |
download | ffmpeg-088108fc7a24d28b0a83b051b5027ebe32d20f30.tar.gz |
avcodec/allcodecs: add backcompat for new config API
In order to avoid breaking older clients not yet using the new API, we
need to add backwards compatibility for codecs which have switched from
init_static() to get_supported_config().
This function can be removed entirely once the deprecated static fields
are removed.
-rw-r--r-- | libavcodec/allcodecs.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 563afde355..0d61b665af 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -913,9 +913,48 @@ const FFCodec * codec_list[] = { static AVOnce av_codec_static_init = AV_ONCE_INIT; static void av_codec_init_static(void) { + int dummy; for (int i = 0; codec_list[i]; i++) { - if (codec_list[i]->init_static_data) - codec_list[i]->init_static_data((FFCodec*)codec_list[i]); + const FFCodec *codec = codec_list[i]; + if (codec->init_static_data) { + codec->init_static_data((FFCodec*) codec); + continue; + } + + /* Backward compatibility with deprecated public fields */ + if (!codec->get_supported_config) + continue; + +FF_DISABLE_DEPRECATION_WARNINGS + switch (codec->p.type) { + case AVMEDIA_TYPE_VIDEO: + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void **) &codec->p.pix_fmts, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_FRAME_RATE, 0, + (const void **) &codec->p.supported_framerates, + &dummy); + break; + case AVMEDIA_TYPE_AUDIO: + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void **) &codec->p.sample_fmts, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_SAMPLE_RATE, 0, + (const void **) &codec->p.supported_samplerates, + &dummy); + codec->get_supported_config(NULL, &codec->p, + AV_CODEC_CONFIG_CHANNEL_LAYOUT, 0, + (const void **) &codec->p.ch_layouts, + &dummy); + break; + default: + break; + } +FF_ENABLE_DEPRECATION_WARNINGS } } |