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

Tomas Härdin tomas.hardin
Tue Aug 31 08:28:56 CEST 2010


On Mon, 2010-08-30 at 18:19 +0100, M?ns Rullg?rd wrote:
> Tomas H?rdin <tomas.hardin at codemill.se> writes:
> 
> > On Fri, 2010-07-09 at 16:45 +0200, Michael Niedermayer wrote:
> >> On Thu, Jul 08, 2010 at 02:48:29PM +0200, Tomas H?rdin wrote:
> >> > 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.
> >> 
> >> see:
> >> __declspec(dllexport)
> >> __attribute__ ((dllexport))
> >> --export-all
> >> msdn
> >> gcc docs
> >
> > I finally got around to poking at this again. Adding
> > __declspec(dllimport) is enough for the variable to be imported
> > properly. It's already exported. The attached patch defines a macro
> > called AV_DLLIMPORT, listed below:
> >
> > #ifdef WIN32
> > #define AV_DLLIMPORT __declspec(dllimport)
> > #else
> > #define AV_DLLIMPORT
> > #endif
> >
> > I'm not sure this is the prettiest solution, but it works well enough on
> > my Ubuntu machine, in MSYS and in MSVC.
> >
> > I also realized that there are more variables that won't be imported
> > properly in MSVC without such a macro. A quick search among the
> > installed headers indicate that at least the following variables are
> > part of the public API:
> >
> > ff_log2_tab
> > av_reverse
> > av_pix_fmt_descriptors
> > av_md5_size
> > av_sha1_size
> >
> > The attached patch adds AV_DLLIMPORT to those variables, and passes
> > regtests.
> >
> > /Tomas
> >
> >
> > diff --git a/libavutil/common.h b/libavutil/common.h
> > index d054f87..d9d99b1 100644
> > --- a/libavutil/common.h
> > +++ b/libavutil/common.h
> > @@ -59,10 +59,16 @@
> >  #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
> >  #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
> >  
> > +#ifdef WIN32
> > +#define AV_DLLIMPORT __declspec(dllimport)
> > +#else
> > +#define AV_DLLIMPORT
> > +#endif
> > +
> >  /* misc math functions */
> > -extern const uint8_t ff_log2_tab[256];
> > +extern AV_DLLIMPORT const uint8_t ff_log2_tab[256];
> >  
> > -extern const uint8_t av_reverse[256];
> > +extern AV_DLLIMPORT const uint8_t av_reverse[256];
> >  
> >  static inline av_const int av_log2_c(unsigned int v)
> >  {
> 
> Not going to happen.  I have yet to see an actual bug report relating
> to this.  I'll that's been presented is hypothetical problems that
> nobody appears to actually be suffering from.
> 

I am suffering from them, since the same code will link fine with ld but
not with link.exe (MSVC). You can't have variables which are part of the
API that work on one platform but not another..

You are right about a bug report being missing though. I merely thought
it superfluous for such a simple fix. I'll try to submit one when I have
time.

/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100831/dadb2433/attachment.pgp>



More information about the ffmpeg-devel mailing list