From: Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: Fix deprecation warnings on pix_fmts
Date: Thu, 6 Feb 2025 01:25:01 +0800
Message-ID: <tencent_26934E25705C2DF69AAF400D9A059F32AB08@qq.com> (raw)
In-Reply-To: <tencent_B24F805509274FB8FA9634CD7DA07F4D9407@qq.com>
I prefer another version which doesn't drop const modifier.
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-February/339331.html
> On Feb 6, 2025, at 00:07, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>
> From: Zhao Zhili <zhilizhao@tencent.com>
>
> ---
> libavcodec/allcodecs.c | 6 ++---
> libavcodec/libx264.c | 53 +++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 50 insertions(+), 9 deletions(-)
>
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 4e1b1c9b45..d2ec4c3045 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -811,9 +811,9 @@ extern const FFCodec ff_libvvenc_encoder;
> /* preferred over libwebp */
> extern const FFCodec ff_libwebp_anim_encoder;
> extern const FFCodec ff_libwebp_encoder;
> -extern const FFCodec ff_libx262_encoder;
> -extern const FFCodec ff_libx264_encoder;
> -extern const FFCodec ff_libx264rgb_encoder;
> +extern FFCodec ff_libx262_encoder;
> +extern FFCodec ff_libx264_encoder;
> +extern FFCodec ff_libx264rgb_encoder;
> extern FFCodec ff_libx265_encoder;
> extern const FFCodec ff_libxeve_encoder;
> extern const FFCodec ff_libxevd_decoder;
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 409f45fc7d..c4bc7c48f5 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -1607,6 +1607,12 @@ static const FFCodecDefault x264_defaults[] = {
> { NULL },
> };
>
> +static int X264_get_supported_config(const AVCodecContext *avctx,
> + const AVCodec *codec,
> + enum AVCodecConfig config,
> + unsigned flags, const void **out,
> + int *out_num);
> +
> #if CONFIG_LIBX264_ENCODER
> static const AVClass x264_class = {
> .class_name = "libx264",
> @@ -1615,7 +1621,7 @@ static const AVClass x264_class = {
> .version = LIBAVUTIL_VERSION_INT,
> };
>
> -const FFCodec ff_libx264_encoder = {
> +FFCodec ff_libx264_encoder = {
> .p.name = "libx264",
> CODEC_LONG_NAME("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
> .p.type = AVMEDIA_TYPE_VIDEO,
> @@ -1633,13 +1639,13 @@ const FFCodec ff_libx264_encoder = {
> .flush = X264_flush,
> .close = X264_close,
> .defaults = x264_defaults,
> - .p.pix_fmts = pix_fmts_all,
> .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
> .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS
> #if X264_BUILD < 158
> | FF_CODEC_CAP_NOT_INIT_THREADSAFE
> #endif
> ,
> + .get_supported_config = X264_get_supported_config,
> };
> #endif
>
> @@ -1651,7 +1657,7 @@ static const AVClass rgbclass = {
> .version = LIBAVUTIL_VERSION_INT,
> };
>
> -const FFCodec ff_libx264rgb_encoder = {
> +FFCodec ff_libx264rgb_encoder = {
> .p.name = "libx264rgb",
> CODEC_LONG_NAME("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB"),
> .p.type = AVMEDIA_TYPE_VIDEO,
> @@ -1659,7 +1665,6 @@ const FFCodec ff_libx264rgb_encoder = {
> .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_OTHER_THREADS |
> AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> - .p.pix_fmts = pix_fmts_8bit_rgb,
> .p.priv_class = &rgbclass,
> .p.wrapper_name = "libx264",
> .priv_data_size = sizeof(X264Context),
> @@ -1672,6 +1677,7 @@ const FFCodec ff_libx264rgb_encoder = {
> | FF_CODEC_CAP_NOT_INIT_THREADSAFE
> #endif
> ,
> + .get_supported_config = X264_get_supported_config,
> };
> #endif
>
> @@ -1683,7 +1689,7 @@ static const AVClass X262_class = {
> .version = LIBAVUTIL_VERSION_INT,
> };
>
> -const FFCodec ff_libx262_encoder = {
> +FFCodec ff_libx262_encoder = {
> .p.name = "libx262",
> CODEC_LONG_NAME("libx262 MPEG2VIDEO"),
> .p.type = AVMEDIA_TYPE_VIDEO,
> @@ -1691,7 +1697,6 @@ const FFCodec ff_libx262_encoder = {
> .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_OTHER_THREADS |
> AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
> - .p.pix_fmts = pix_fmts_8bit,
> .color_ranges = AVCOL_RANGE_MPEG,
> .p.priv_class = &X262_class,
> .p.wrapper_name = "libx264",
> @@ -1702,5 +1707,41 @@ const FFCodec ff_libx262_encoder = {
> .defaults = x264_defaults,
> .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
> FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS,
> + .get_supported_config = X264_get_supported_config,
> };
> #endif
> +
> +static int X264_get_supported_config(const AVCodecContext *avctx,
> + const AVCodec *codec,
> + enum AVCodecConfig config,
> + unsigned flags, const void **out,
> + int *out_num)
> +{
> + if (config == AV_CODEC_CONFIG_PIX_FORMAT) {
> +#if CONFIG_LIBX264_ENCODER
> + if (codec == &ff_libx264_encoder.p) {
> + *out = pix_fmts_all;
> + *out_num = FF_ARRAY_ELEMS(pix_fmts_all) - 1;
> + return 0;
> + }
> +#endif
> +
> +#if CONFIG_LIBX264RGB_ENCODER
> + if (codec == &ff_libx264rgb_encoder.p) {
> + *out = pix_fmts_8bit_rgb;
> + *out_num = FF_ARRAY_ELEMS(pix_fmts_8bit_rgb) - 1;
> + return 0;
> + }
> +#endif
> +#if CONFIG_LIBX262_ENCODER
> + if (codec == &ff_libx262_encoder.p) {
> + *out = pix_fmts_8bit;
> + *out_num = FF_ARRAY_ELEMS(pix_fmts_8bit) - 1;
> + }
> +#endif
> + return AVERROR(EINVAL);
> + }
> +
> + return ff_default_get_supported_config(avctx, codec, config, flags, out,
> + out_num);
> +}
> --
> 2.46.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
prev parent reply other threads:[~2025-02-05 17:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 16:07 Zhao Zhili
2025-02-05 17:25 ` Zhao Zhili [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_26934E25705C2DF69AAF400D9A059F32AB08@qq.com \
--to=quinkblack-at-foxmail.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git