[FFmpeg-devel] [PATCH] pixdesc: Add av_get_pix_fmt_descriptor()

Måns Rullgård mans
Thu Jul 8 15:25:10 CEST 2010


Tomas H?rdin <tomas.hardin at codemill.se> writes:

> Hi
>
> While poking around with MinGW compiled lav* DLLs in MSVC I noticed
> link.exe can't resolve references to av_pix_fmt_descriptors. This is due
> to how import libraries work, but I'm not an expert. The important thing
> is that only functions get exported properly - globals don't.

I vaguely recall us having similar problems a few years ago.  I think
the offending variable ended up being removed eventually for other
reasons.

> To fix this I propose the lavu API be extended with a function
> called av_get_pix_fmt_descriptor which returns a pointer to an
> AVPixFmtDescriptor for a specified format.
>
> There are probably more globals that have this problem, but some quick
> greping didn't yield many results.
>
> Patch attached. Minor version bump included.
>
> (I assume av_pix_fmt_descriptors is meant to be user accessible since
> ffplay uses it and certain information contained within can't be
> accessed any other way)
>
> /Tomas
>
> diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> index 6233680..f86cdde 100644
> --- a/libavutil/pixdesc.c
> +++ b/libavutil/pixdesc.c
> @@ -789,6 +789,11 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
>      },
>  };
>  
> +const AVPixFmtDescriptor* av_get_pix_fmt_descriptor(enum PixelFormat pix_fmt)
> +{
> +    return &av_pix_fmt_descriptors[pix_fmt];
> +}

This might need a bounds check.  If pixel formats are added, calling
an older library with a new format would have bad consequences.  Do we
care about such a situation?

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list