[Xvid-devel] Patch for XVID MPEG-4 DirectShow/MediaFoundation filter

Jerker Bäck jerker.back at gmail.com
Thu Jun 23 01:00:39 CEST 2011


Hi Michael,

> What I don't like is that it introduces platform and compiler (even
> compiler version!) specific code into xvid.h. The main API header is not
> really the place for this. Normally, such stuff is handled in portab.h.
> Obviously however, it is not an option to include portab.h in xvid.h.
I appreciate this approach, keeping the library free from all that mess.
However, this patch is not so much for building the library as it is to
present it for clients.

> #ifndef XVID_IMPEXP
> #define XVID_IMPEXP             extern
> #endif
OK, fine by me.

> #ifndef XVID_CALL
> #define XVID_CALL
> #endif
I can understand that you mean something like: If you need XVID_CALL, define
it to whatever you need it to be. But this is BMO wrong, as I said, the
library have an implicit, unspoken requirement for the __cdecl calling
convention, therefore all past compiles of Xvid export its functions as
__cdecl. This information is missing and is not optional. You as the
maintainer must set a rule here. Suppose I develop a Media Foundation
interface based on Xvid and I for some reason want to use __stdcall calling
convention in my DLL. When the compiler includes xvid.h, it assumes that all
xvid functions also are __stdcall since the calling convention information
is not specified. With other words, you have already decided what the
standard Xvid calling convention should be. You just didn't express it.
 
AFAIK, using different calling conventions is Windows specific and all
Windows compilers must support this feature. The "universal" compiler define
for the Windows target is _WIN32 (one underscore). Which gives:

#if defined(_WIN32)
#define XVID_CALL               __cdecl
#else
#define XVID_CALL
#endif

If you still are reluctant to change this, it is better to skip this part
all together (keeping the implicit requirement, not pretend it is optional).

Regards
Jerker




More information about the Xvid-devel mailing list