[FFmpeg-devel] [PATCH 3/8] Optimize / simplify av_get_pix_fmt_name().
Michael Niedermayer
michaelni
Fri Nov 5 16:40:43 CET 2010
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
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101105/4f74ff42/attachment.pgp>
More information about the ffmpeg-devel
mailing list