[FFmpeg-devel] [PATCH] lavf/mxfenc: Use nb_components, not av_pix_fmt_count_planes()

James Almer jamrial at gmail.com
Tue Oct 29 17:21:30 EET 2024


> From ce4b1dfb97530b242f899e5d1686f98fa83a7698 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git at haerdin.se>
> Date: Tue, 29 Oct 2024 16:13:04 +0100
> Subject: [PATCH] lavf/mxfenc: Use nb_components, not av_pix_fmt_count_planes()
> 
> This fixed https://trac.ffmpeg.org/ticket/11267
> ---
>  libavformat/mxfenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 57be9e6ef6..e66df0fba2 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -1488,7 +1488,7 @@ static void mxf_write_jpeg2000_subdesc(AVFormatContext *s, AVStream *st)
>      MXFStreamContext *sc = st->priv_data;
>      AVIOContext *pb = s->pb;
>      int64_t pos;
> -    int component_count = av_pix_fmt_count_planes(st->codecpar->format);
> +    int component_count = av_pix_fmt_desc_get(st->codecpar->format)->nb_components;

I don't think anything ensures that av_pix_fmt_desc_get() here will not 
return NULL, so maybe instead do:

> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(st->codecpar->format);
> int component_count;
> 
> if (!desc)
>     return AVERROR(EINVAL);
> 
> component_count = desc->nb_components;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241029/a9c52caa/attachment.sig>


More information about the ffmpeg-devel mailing list