[FFmpeg-devel] [PATCH 3/8] Optimize / simplify av_get_pix_fmt_name().

Stefano Sabatini stefano.sabatini-lala
Sun Nov 7 16:03:56 CET 2010


On date Friday 2010-11-05 16:40:43 +0100, Michael Niedermayer encoded:
> On Fri, Nov 05, 2010 at 01:14:46PM +0100, Stefano Sabatini wrote:
> > On date Friday 2010-11-05 12:10:51 +0100, Jean-Daniel Dupas encoded:
> > > 
> > > Le 5 nov. 2010 ? 12:00, Stefano Sabatini a ?crit :
> > > 
> > > > ---
> > > > libavutil/pixdesc.c |    6 ++----
> > > > 1 files changed, 2 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> > > > index c099d03..01e2917 100644
> > > > --- a/libavutil/pixdesc.c
> > > > +++ b/libavutil/pixdesc.c
> > > > @@ -816,10 +816,8 @@ static enum PixelFormat get_pix_fmt_internal(const char *name)
> > > > 
> > > > const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
> > > > {
> > > > -    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
> > > > -        return NULL;
> > > > -    else
> > > > -        return av_pix_fmt_descriptors[pix_fmt].name;
> > > > +    return ((unsigned)pix_fmt >= PIX_FMT_NB) ?
> > > > +        av_pix_fmt_descriptors[pix_fmt].name : NULL;
> > > > }
> > > > 
> > > 
> > > shouldn't it be "<= PIX_FMT_NB" ? 
> > 
> > No, it should be "< PIX_FMT_NB", thanks for spotting.
> > 
> > Patch updated.
> > -- 
> > FFmpeg = Fostering & Frenzy Mere Pitiful Elastic Governor
> 
> >  pixdesc.c |    6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 6548dcfc19ea1c9ed82c06f0b9b22880419e139b  0003-Optimize-simplify-av_get_pix_fmt_name.patch
> > From 438e68486e1a0211c0005efd244d872ed08478e2 Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > Date: Fri, 5 Nov 2010 11:28:13 +0100
> > Subject: [PATCH 3/8] Optimize / simplify av_get_pix_fmt_name().
> > 
> > ---
> >  libavutil/pixdesc.c |    6 ++----
> >  1 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> > index c099d03..65fd259 100644
> > --- a/libavutil/pixdesc.c
> > +++ b/libavutil/pixdesc.c
> > @@ -816,10 +816,8 @@ static enum PixelFormat get_pix_fmt_internal(const char *name)
> >  
> >  const char *av_get_pix_fmt_name(enum PixelFormat pix_fmt)
> >  {
> > -    if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
> > -        return NULL;
> > -    else
> > -        return av_pix_fmt_descriptors[pix_fmt].name;
> > +    return (unsigned)pix_fmt < PIX_FMT_NB ?
> > +        av_pix_fmt_descriptors[pix_fmt].name : NULL;
> >  }
> 
> i agree with doing th unsigned trick
> the change to ? : is just compressing lines to worsen readability

Applied with no ? : syntax.
-- 
FFmpeg = Fundamentalist Forgiving Minimal Puritan Everlasting God



More information about the ffmpeg-devel mailing list