diff options
author | Niklas Haas <git@haasn.dev> | 2024-04-05 19:58:07 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2024-09-08 13:59:29 +0200 |
commit | de421cac8b63904750754e4e138b0b2ee70da2f0 (patch) | |
tree | 85e51ff13e3dd611ef3fe0bf4342c02c7cf8a377 | |
parent | 088108fc7a24d28b0a83b051b5027ebe32d20f30 (diff) | |
download | ffmpeg-de421cac8b63904750754e4e138b0b2ee70da2f0.tar.gz |
avcodec/libx265: switch to get_supported_config()
-rw-r--r-- | libavcodec/libx265.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index de0ad03ee3..513f473307 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -949,14 +949,28 @@ static const enum AVPixelFormat x265_csp_twelve[] = { AV_PIX_FMT_NONE }; -static av_cold void libx265_encode_init_csp(FFCodec *codec) +static int libx265_get_supported_config(const AVCodecContext *avctx, + const AVCodec *codec, + enum AVCodecConfig config, + unsigned flags, const void **out, + int *out_num) { - if (x265_api_get(12)) - codec->p.pix_fmts = x265_csp_twelve; - else if (x265_api_get(10)) - codec->p.pix_fmts = x265_csp_ten; - else if (x265_api_get(8)) - codec->p.pix_fmts = x265_csp_eight; + if (config == AV_CODEC_CONFIG_PIX_FORMAT) { + if (x265_api_get(12)) { + *out = x265_csp_twelve; + *out_num = FF_ARRAY_ELEMS(x265_csp_twelve) - 1; + } else if (x265_api_get(10)) { + *out = x265_csp_ten; + *out_num = FF_ARRAY_ELEMS(x265_csp_ten) - 1; + } else if (x265_api_get(8)) { + *out = x265_csp_eight; + *out_num = FF_ARRAY_ELEMS(x265_csp_eight) - 1; + } else + return AVERROR_EXTERNAL; + return 0; + } + + return ff_default_get_supported_config(avctx, codec, config, flags, out, out_num); } #define OFFSET(x) offsetof(libx265Context, x) @@ -1013,7 +1027,7 @@ FFCodec ff_libx265_encoder = { .p.priv_class = &class, .p.wrapper_name = "libx265", .init = libx265_encode_init, - .init_static_data = libx265_encode_init_csp, + .get_supported_config = libx265_get_supported_config, FF_CODEC_ENCODE_CB(libx265_encode_frame), .close = libx265_encode_close, .priv_data_size = sizeof(libx265Context), |