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

Michael Niedermayer michaelni
Thu Jan 28 23:22:03 CET 2010


On Thu, Jan 28, 2010 at 10:38:03PM +0100, Stefano Sabatini wrote:
> On date Wednesday 2010-01-27 17:28:04 -0800, Baptiste Coudurier encoded:
> > On 01/27/2010 05:10 PM, Stefano Sabatini wrote:
> >> On date Thursday 2009-11-26 22:45:31 +0100, Stefano Sabatini encoded:
> >>> On date Saturday 2009-11-07 17:52:50 +0100, Stefano Sabatini encoded:
> >>>> Hi,
> >>>>
> >>>> as in subject.
> >>>>
> >>>> This is going to replace avcodec_get_pix_fmt().
> >>>
> >>> Patch updated and slightly changed, now it should be intended as a
> >>> move of the code of avcodec_get_pix_fmt() to libavutil.
> >>
> >> Ping (I need this, my idea is to make swscale-test take in input IN
> >> OUT as a format, should help when debugging conversion code without to
> >> rely on lavfi).
> >>
> >> Regards.
> >>
> >>
> >> implement-get-pix-fmt-by-name.patch
> >>
> >>
> >> Index: ffmpeg/libavutil/pixdesc.c
> >> ===================================================================
> >> --- ffmpeg.orig/libavutil/pixdesc.c	2009-11-29 10:47:45.000000000 +0100
> >> +++ ffmpeg/libavutil/pixdesc.c	2009-11-29 11:04:14.000000000 +0100
> >> @@ -648,6 +648,43 @@
> >>       },
> >>   };
> >>
> >> +enum PixelFormat av_get_pix_fmt_by_name_internal(const char *name)
> >
> > Missing static.
> 
> Updated.
> -- 
> FFmpeg = Fast & Foolish Moronic Philosophical Eager Gargoyle

>  libavcodec/avcodec.h    |    4 ++++
>  libavcodec/imgconvert.c |   33 +++------------------------------
>  libavutil/pixdesc.c     |   37 +++++++++++++++++++++++++++++++++++++
>  libavutil/pixdesc.h     |   13 +++++++++++++
>  4 files changed, 57 insertions(+), 30 deletions(-)
> 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

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- 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/20100128/479d7bdd/attachment.pgp>



More information about the ffmpeg-devel mailing list