[FFmpeg-devel] [PATCH] Implement av_get_pix_fmt_by_name()

Michael Niedermayer michaelni
Fri Jan 29 01:19:36 CET 2010


On Fri, Jan 29, 2010 at 12:05:05AM +0100, Stefano Sabatini wrote:
> On date Thursday 2010-01-28 23:22:03 +0100, Michael Niedermayer encoded:
> > On Thu, Jan 28, 2010 at 10:38:03PM +0100, Stefano Sabatini wrote:
> [...]
> > > f3e4d5070216d22c0cd6cbc289660ea1c13b804a  implement-get-pix-fmt-by-name.patch
> > > Index: ffmpeg/libavutil/pixdesc.c
> > > ===================================================================
> > > --- ffmpeg.orig/libavutil/pixdesc.c	2010-01-20 19:52:08.000000000 +0100
> > > +++ ffmpeg/libavutil/pixdesc.c	2010-01-28 22:35:17.000000000 +0100
> > > @@ -654,6 +654,43 @@
> > >      },
> > >  };
> > >  
> > > +static enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
> > 
> > static functions should not have av prefixes
> > 
> > 
> > > +{
> > > +    enum PixelFormat pix_fmt;
> > > +
> > > +    for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> > > +        if (av_pix_fmt_descriptors[pix_fmt].name &&
> > > +            !strcmp(av_pix_fmt_descriptors[pix_fmt].name, name))
> > > +            return pix_fmt;
> > > +
> > > +    return PIX_FMT_NONE;
> > > +}
> > > +
> > > +#if HAVE_BIGENDIAN
> > > +#   define X_NE(be, le) be
> > > +#else
> > > +#   define X_NE(be, le) le
> > > +#endif
> > > +
> > > +enum PixelFormat av_get_pix_fmt_by_name(const char *name)
> > > +{
> > > +    enum PixelFormat pix_fmt;
> > > +
> > > +    if (!strcmp(name, "rgb32"))
> > > +        name = X_NE("argb", "bgra");
> > > +    else if (!strcmp(name, "bgr32"))
> > > +        name = X_NE("abgr", "rgba");
> > 
> > this list is not complete also its quite easy to add a new format and forget
> > this list
> 
> mmh this is what is currently supported, we left those definitions for
> a precise reason:
> ------------------------------------------------------------------------
> r18163 | stefano | 2009-03-22 23:50:19 +0100 (Sun, 22 Mar 2009) | 19 lines
> 
> Make the pixel formats which were defined as macros:
> PIX_FMT_ARGB
> PIX_FMT_RGBA
> PIX_FMT_ABGR
> PIX_FMT_BGRA
> 
> defined as enum PixelFormat values, and viceversa make:
> PIX_FMT_RGB32
> PIX_FMT_RGB32_1
> PIX_FMT_BGR32  
> PIX_FMT_BGR32_1
> 
> defined as macros, also resort accordingly the enum PixelFormat
> list.
> Also make avcodec_get_pix_fmt() recognize the "rgb32" and "bgr32"
> aliases, in order to make ffmpeg pass regressions test.
> 
> This change breaks ABI backward compatibility.
> ------------------------------------------------------------------------
> 
> Please elaborate, new patch attached, regards.
> -- 
> FFmpeg = Freak and Faithless Mind-dumbing Portable Epic Game

>  libavcodec/avcodec.h    |    4 ++++
>  libavcodec/imgconvert.c |   33 +++------------------------------
>  libavutil/pixdesc.c     |   37 +++++++++++++++++++++++++++++++++++++
>  libavutil/pixdesc.h     |   13 +++++++++++++
>  4 files changed, 57 insertions(+), 30 deletions(-)
> e5e9c160bfb1e22ea556ae29a1b550288d09b184  implement-get-pix-fmt-by-name.patch

if it makes you happy, ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100129/673d8ea6/attachment.pgp>



More information about the ffmpeg-devel mailing list