[FFmpeg-devel] [PATCH v2 2/6] avutil/csp: eliminate redundant branch

Niklas Haas ffmpeg at haasn.xyz
Wed Dec 4 12:58:47 EET 2024


On Sun, 01 Dec 2024 09:24:17 -0500 Leo Izen <leo.izen at gmail.com> wrote:
>
>
> On 11/30/24 9:23 AM, Niklas Haas wrote:
> > From: Niklas Haas <git at haasn.dev>
> >
> > ---
> >   libavutil/csp.c | 6 +-----
> >   1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/libavutil/csp.c b/libavutil/csp.c
> > index 7ef822c60b..3dd7bc2562 100644
> > --- a/libavutil/csp.c
> > +++ b/libavutil/csp.c
> > @@ -290,11 +290,7 @@ static const av_csp_trc_function trc_funcs[AVCOL_TRC_NB] = {
> >
> >   av_csp_trc_function av_csp_trc_func_from_id(enum AVColorTransferCharacteristic trc)
> >   {
> > -    av_csp_trc_function func;
> >       if (trc >= AVCOL_TRC_NB)
> >           return NULL;
> > -    func = trc_funcs[trc];
> > -    if (!func)
> > -        return NULL;
> > -    return func;
> > +    return trc_funcs[trc];
> >   }
>
> This is future-proof in case there's gaps in H.273, which there are in
> some cases.
>
> Also it prevents a segfault crash if someone passes an enum that hasn't
> been added to FFmpeg yet, but has been added to H.273.

I will reiterate that this commit does not change the behavior of the
function, it only (IMO) simplified the code by eliminating reduntant logic.

Evidently this is not so, as already two people have commented on this change.
I propose to simply drop this commit.

>
> - Leo Izen
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list