diff mbox series

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

Message ID 43eeb66b5c0ff96e06078161c8b03d4332801bd3.camel@haerdin.se
State New
Headers show
Series [FFmpeg-devel] lavf/mxfenc: Use nb_components, not av_pix_fmt_count_planes() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Tomas Härdin Oct. 29, 2024, 3:13 p.m. UTC

Comments

Tomas Härdin Oct. 29, 2024, 3:43 p.m. UTC | #1
tis 2024-10-29 klockan 12:21 -0300 skrev James Almer:
> > From ce4b1dfb97530b242f899e5d1686f98fa83a7698 Mon Sep 17 00:00:00
> > 2001
> > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@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;

I can't really see how that would happen, but I suppose it doesn't
hurt.

I see elsewhere in the code an assert that the returned pointer is not
NULL (mxf_write_ffv1_desc()), and explicit checks for it

Updated patch attached. Passes fate-mxf

/Tomas
Pierre-Anthony Lemieux Oct. 29, 2024, 3:48 p.m. UTC | #2
LGTM

On Tue, Oct 29, 2024 at 8:43 AM Tomas Härdin <git@haerdin.se> wrote:
>
> tis 2024-10-29 klockan 12:21 -0300 skrev James Almer:
> > > From ce4b1dfb97530b242f899e5d1686f98fa83a7698 Mon Sep 17 00:00:00
> > > 2001
> > > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@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;
>
> I can't really see how that would happen, but I suppose it doesn't
> hurt.
>
> I see elsewhere in the code an assert that the returned pointer is not
> NULL (mxf_write_ffv1_desc()), and explicit checks for it
>
> Updated patch attached. Passes fate-mxf
>
> /Tomas
> _______________________________________________
> 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".
diff mbox series

Patch

From ce4b1dfb97530b242f899e5d1686f98fa83a7698 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@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;
 
     /* JPEG2000 subdescriptor key */
     avio_write(pb, mxf_jpeg2000_subdescriptor_key, 16);
@@ -2638,7 +2638,7 @@  static int mxf_parse_jpeg2000_frame(AVFormatContext *s, AVStream *st, AVPacket *
 {
     MXFContext *mxf = s->priv_data;
     MXFStreamContext *sc = st->priv_data;
-    int component_count = av_pix_fmt_count_planes(st->codecpar->format);
+    int component_count = av_pix_fmt_desc_get(st->codecpar->format)->nb_components;
     GetByteContext g;
     uint32_t j2k_ncomponents;
 
-- 
2.39.2