[vlc-devel] [PATCH] switcher: Fix compilation with ffmpeg-0.10.2

Richard Grenville pyxlcy at gmail.com
Wed Mar 21 10:01:07 CET 2012


On Wed, Mar 21, 2012 at 03:41:33AM -0400, Rafaël Carré wrote:
> > ---
> > #define LIBAVCODEC_VERSION_MAJOR 53
> > /* ... */
> > #define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
> > ---
> > 
> > So ffmpeg should already have replaced FF_*_TYPE with the correct
> > AV_PICTURE_TYPE_*, why this is not happening? Eventually I found these
> > things in vlc's git tree, ./modules/codec/avcodec.h, which switch.c
> > includes, too:
> 
> Perhaps because your headers are too recent (LIBAVCODEC_VERSION_MAJOR >= 54)

Hmm? "#define LIBAVCODEC_VERSION_MAJOR 53", it's clearly written there.
I use ffmpeg-0.10.2.

I did a test just now:
---
$ cd /var/tmp/portage/media-video/vlc-2.0.1/work/vlc-2.0.1/modules/stream_out
$ gcc -E -dD -I/usr/include/libavcodec -I../../include switcher.c | grep FF_P_TYPE
#define FF_P_TYPE AV_PICTURE_TYPE_P
#define AV_PICTURE_TYPE_P FF_P_TYPE
        id->p_frame->pict_type = FF_P_TYPE;
    case FF_P_TYPE:
---

Two circular macro definitions are there, and FF_P_TYPE is not replaced
correctly. After I commented out the 3 "#define AV_PICTURE_TYPE_*
FF_*_TYPE" lines in ./modules/codec/avcodec/avcodec.h, it worked as
expected:

---
$ gcc -E -dD -I/usr/include/libavcodec -I../../include switcher.c | grep FF_P_TYPE
#define FF_P_TYPE AV_PICTURE_TYPE_P
---

Obviously it's a VLC bug related to these 3 lines.

> 
> > ---
> > #if LIBAVCODEC_VERSION_MAJOR < 54
> > #   define AV_PICTURE_TYPE_B        FF_B_TYPE
> > #   define AV_PICTURE_TYPE_I        FF_I_TYPE
> > #   define AV_PICTURE_TYPE_P        FF_P_TYPE
> > ---
> > 
> > They are introduced in commit 8f24e725ff9945975f6d7232477cff7f7a8e2cff
> > "avcodec: update to libavcodec 54", by Rafaël Carré, aka, you. Together
> > with ffmpeg-0.10's code in avcodec.h and version.h, they generated a
> > circular macro definition, replace A with B, then replace B with A...
> 
> Weird, perhaps we need to add some ifdef.
> I thought the code has been tested with different (old and new) versions
> though.
> 

Perhaps the gcc version you use to test vlc handles circular macro
definitions in a different fashion? Like, your gcc is smarter than mine.
:-)

> > However I didn't pay attention to the compatiblity with older ffmpeg
> > versions. I always use a fully updated system and don't quite understand
> > what "older versions" mean. :-)
> 
> It means 2 or 3 years old, perhaps more.
> 
> e.g. try last Ubuntu LTS and VLC should continue to build (and run), or
> error out at configure stage.

Thanks for the explanation. Looks like developing a software is truly
much harder than submitting patches, so many things to consider. :-)



More information about the vlc-devel mailing list