[FFmpeg-devel] [PATCH] Implement av_get_pix_fmt_by_name()
Stefano Sabatini
stefano.sabatini-lala
Fri Jan 29 00:05:05 CET 2010
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implement-get-pix-fmt-by-name.patch
Type: text/x-diff
Size: 4363 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100129/586d8c7f/attachment.patch>
More information about the ffmpeg-devel
mailing list