[FFmpeg-devel] [PATCH 1/6] avcodec: Remove redundant pix_fmts from decoders

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Feb 8 03:05:27 EET 2024


Andreas Rheinhardt:
> AVCodec.pix_fmts is only intended for encoders (decoders use
> the get_format callback to let the user choose a pix fmt).
> So remove them for the decoders for which this is possible
> without further complications; keep them for now in the codecs
> that actually use them (by passing avctx->codec->pix_fmts to
> ff_get_formatt()).
> 
> Also notice that some of these lists were wrong; e.g.
> 317b7b06fd97cd39feac7df57db22a30550351ff added support for YUV444P16
> for cuviddec, but forgot to add it to pix_fmts.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/crystalhd.c |  1 -
>  libavcodec/cuviddec.c  |  5 -----
>  libavcodec/flashsv.c   |  2 --
>  libavcodec/libdavs2.c  |  2 --
>  libavcodec/libuavs3d.c |  3 ---
>  libavcodec/qsvdec.c    | 11 -----------
>  libavcodec/rkmppdec.c  |  2 --
>  libavcodec/rv10.c      |  8 --------
>  libavcodec/rv30.c      |  4 ----
>  libavcodec/rv40.c      |  4 ----
>  libavcodec/svq1dec.c   |  2 --
>  libavcodec/svq3.c      |  2 --
>  libavcodec/xfacedec.c  |  1 -
>  13 files changed, 47 deletions(-)
> 
> diff --git a/libavcodec/crystalhd.c b/libavcodec/crystalhd.c
> index 86f6cfa6c1..fb190436f5 100644
> --- a/libavcodec/crystalhd.c
> +++ b/libavcodec/crystalhd.c
> @@ -797,7 +797,6 @@ static int crystalhd_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>          .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
>          .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
>                            FF_CODEC_CAP_SETS_FRAME_PROPS, \
> -        .p.pix_fmts     = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, \
>          .p.wrapper_name = "crystalhd", \
>      };
>  
> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index da37207cf2..84edf5c209 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -1174,11 +1174,6 @@ static const AVCodecHWConfigInternal *const cuvid_hw_configs[] = {
>          .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
>          .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
>                            FF_CODEC_CAP_SETS_FRAME_PROPS, \
> -        .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
> -                                                        AV_PIX_FMT_NV12, \
> -                                                        AV_PIX_FMT_P010, \
> -                                                        AV_PIX_FMT_P016, \
> -                                                        AV_PIX_FMT_NONE }, \
>          .hw_configs     = cuvid_hw_configs, \
>          .p.wrapper_name = "cuvid", \
>      };
> diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
> index 8a01e3a4b6..fe00e529a5 100644
> --- a/libavcodec/flashsv.c
> +++ b/libavcodec/flashsv.c
> @@ -511,7 +511,6 @@ const FFCodec ff_flashsv_decoder = {
>      FF_CODEC_DECODE_CB(flashsv_decode_frame),
>      .p.capabilities = AV_CODEC_CAP_DR1,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
>  };
>  #endif /* CONFIG_FLASHSV_DECODER */
>  
> @@ -579,6 +578,5 @@ const FFCodec ff_flashsv2_decoder = {
>      FF_CODEC_DECODE_CB(flashsv_decode_frame),
>      .p.capabilities = AV_CODEC_CAP_DR1,
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_NONE },
>  };
>  #endif /* CONFIG_FLASHSV2_DECODER */
> diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c
> index 179d2f4e4b..5a605c36f6 100644
> --- a/libavcodec/libdavs2.c
> +++ b/libavcodec/libdavs2.c
> @@ -234,7 +234,5 @@ const FFCodec ff_libdavs2_decoder = {
>      .p.capabilities =  AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,
>      .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
>                        FF_CODEC_CAP_AUTO_THREADS,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
> -                                                     AV_PIX_FMT_NONE },
>      .p.wrapper_name = "libdavs2",
>  };
> diff --git a/libavcodec/libuavs3d.c b/libavcodec/libuavs3d.c
> index 66e8d31001..f5d47f28ed 100644
> --- a/libavcodec/libuavs3d.c
> +++ b/libavcodec/libuavs3d.c
> @@ -274,8 +274,5 @@ const FFCodec ff_libuavs3d_decoder = {
>      .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
>                        FF_CODEC_CAP_AUTO_THREADS,
>      .flush          = libuavs3d_flush,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
> -                                                     AV_PIX_FMT_YUV420P10LE,
> -                                                     AV_PIX_FMT_NONE },
>      .p.wrapper_name = "libuavs3d",
>  };
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 559f63698a..812bfd8830 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -1127,17 +1127,6 @@ const FFCodec ff_##x##_qsv_decoder = { \
>      .bsfs           = bsf_name, \
>      .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
>      .p.priv_class   = &x##_qsv_class, \
> -    .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> -                                                    AV_PIX_FMT_P010, \
> -                                                    AV_PIX_FMT_P012, \
> -                                                    AV_PIX_FMT_YUYV422, \
> -                                                    AV_PIX_FMT_Y210, \
> -                                                    AV_PIX_FMT_Y212, \
> -                                                    AV_PIX_FMT_VUYX, \
> -                                                    AV_PIX_FMT_XV30, \
> -                                                    AV_PIX_FMT_XV36, \
> -                                                    AV_PIX_FMT_QSV, \
> -                                                    AV_PIX_FMT_NONE }, \
>      .hw_configs     = qsv_hw_configs, \
>      .p.wrapper_name = "qsv", \
>      .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE, \
> diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
> index 5768568b00..53b6f6d5e8 100644
> --- a/libavcodec/rkmppdec.c
> +++ b/libavcodec/rkmppdec.c
> @@ -575,8 +575,6 @@ static const AVCodecHWConfigInternal *const rkmpp_hw_configs[] = {
>          .flush          = rkmpp_flush, \
>          .p.priv_class   = &rkmpp_##NAME##_dec_class, \
>          .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \
> -        .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \
> -                                                         AV_PIX_FMT_NONE}, \
>          .hw_configs     = rkmpp_hw_configs, \
>          .bsfs           = BSFS, \
>          .p.wrapper_name = "rkmpp", \
> diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
> index 216328ffe7..d32faa628b 100644
> --- a/libavcodec/rv10.c
> +++ b/libavcodec/rv10.c
> @@ -671,10 +671,6 @@ const FFCodec ff_rv10_decoder = {
>      FF_CODEC_DECODE_CB(rv10_decode_frame),
>      .p.capabilities = AV_CODEC_CAP_DR1,
>      .p.max_lowres   = 3,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) {
> -        AV_PIX_FMT_YUV420P,
> -        AV_PIX_FMT_NONE
> -    },
>  };
>  
>  const FFCodec ff_rv20_decoder = {
> @@ -689,8 +685,4 @@ const FFCodec ff_rv20_decoder = {
>      .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
>      .flush          = ff_mpeg_flush,
>      .p.max_lowres   = 3,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) {
> -        AV_PIX_FMT_YUV420P,
> -        AV_PIX_FMT_NONE
> -    },
>  };
> diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c
> index be62577f99..9e13e71805 100644
> --- a/libavcodec/rv30.c
> +++ b/libavcodec/rv30.c
> @@ -303,10 +303,6 @@ const FFCodec ff_rv30_decoder = {
>      .p.capabilities        = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
>                               AV_CODEC_CAP_FRAME_THREADS,
>      .flush                 = ff_mpeg_flush,
> -    .p.pix_fmts            = (const enum AVPixelFormat[]) {
> -        AV_PIX_FMT_YUV420P,
> -        AV_PIX_FMT_NONE
> -    },
>      UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
>      .caps_internal         = FF_CODEC_CAP_ALLOCATE_PROGRESS,
>  };
> diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
> index 3ee405f33c..e48aa1f684 100644
> --- a/libavcodec/rv40.c
> +++ b/libavcodec/rv40.c
> @@ -581,10 +581,6 @@ const FFCodec ff_rv40_decoder = {
>      .p.capabilities        = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
>                               AV_CODEC_CAP_FRAME_THREADS,
>      .flush                 = ff_mpeg_flush,
> -    .p.pix_fmts            = (const enum AVPixelFormat[]) {
> -        AV_PIX_FMT_YUV420P,
> -        AV_PIX_FMT_NONE
> -    },
>      UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
>      .caps_internal         = FF_CODEC_CAP_ALLOCATE_PROGRESS,
>  };
> diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
> index af02063a45..d2cfe4cf40 100644
> --- a/libavcodec/svq1dec.c
> +++ b/libavcodec/svq1dec.c
> @@ -863,6 +863,4 @@ const FFCodec ff_svq1_decoder = {
>      FF_CODEC_DECODE_CB(svq1_decode_frame),
>      .p.capabilities = AV_CODEC_CAP_DR1,
>      .flush          = svq1_flush,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P,
> -                                                     AV_PIX_FMT_NONE },
>  };
> diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
> index 2d03dbc457..d2f53742e1 100644
> --- a/libavcodec/svq3.c
> +++ b/libavcodec/svq3.c
> @@ -1602,7 +1602,5 @@ const FFCodec ff_svq3_decoder = {
>      .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND |
>                        AV_CODEC_CAP_DR1             |
>                        AV_CODEC_CAP_DELAY,
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P,
> -                                                     AV_PIX_FMT_NONE},
>      .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> diff --git a/libavcodec/xfacedec.c b/libavcodec/xfacedec.c
> index 378d6aea0e..78b70cae8c 100644
> --- a/libavcodec/xfacedec.c
> +++ b/libavcodec/xfacedec.c
> @@ -182,5 +182,4 @@ const FFCodec ff_xface_decoder = {
>      .priv_data_size = sizeof(XFaceContext),
>      .init           = xface_decode_init,
>      FF_CODEC_DECODE_CB(xface_decode_frame),
> -    .p.pix_fmts     = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE },
>  };

Will apply this patchset tomorrow unless there are objections.

- Andreas



More information about the ffmpeg-devel mailing list