4

I am compiling a project that uses both ffmpeg and Ogre. Now on Windows, everything works fine.

But when I want to compile a file with the following line of code:

Ogre::PixelFormat format = Ogre::PF_BYTE_RGBA;

The compiler gives the following error:

error: ‘AVPixelFormat’ is not a member of ‘Ogre’

Which is strange in many ways, as I have not only specified the Ogre namespace with ::, but also there is no AVPixelFormat in Ogre. How does gcc confuse "PixelFormat" with "AVPixelFormat"?

And how can I get rid of that?

I'd love to use int here instead of an enum, but another Ogre function requires format to be in Ogre::PixelFormat.

TheSHEEEP
  • 2,961
  • 2
  • 31
  • 57

2 Answers2

6

Preprocess it first using gcc -E, then grep through the file looking for AVPixelFormat or PixelFormat. I suspect you have a #define or a typedef floating around, you just need to find where this happens, and a precompiled source file is the place this will become apparent.

djechlin
  • 59,258
  • 35
  • 162
  • 290
  • Ah, yes. pixfmt.h from ffmpeg had a macro that defined AVPixelFormat as PixelFormat. Another proof that ffmpeg devs are kinda reckless ;) – TheSHEEEP Dec 07 '12 at 16:02
  • @TheSHEEEP: I would say a proof that macros should die... (and by the way, you should probably accept this answer). – Matthieu M. Dec 07 '12 at 19:40
  • @djechlin: A `typedef` would not, to the best of my knowledge, provoke such an issue. – Matthieu M. Dec 07 '12 at 19:41
  • Sorry for accepting late, had to leave office directly after the answer came in :) I wouldn't say that macros should die. They can be useful & helpful if used correctly. Like.. by not naming something PixelFormat without a namespace ;) – TheSHEEEP Dec 10 '12 at 08:11
3

The problem is in avutil/pixfmt.h:

#define PixelFormat AVPixelFormat

This prevents users from using the word "PixelFormat" anywhere in their own code, even if in namespaces.

This is there as a compatibility hack for older software still using the old identifiers.

The solution is quite simple in case you can edit the code. Just add to the C++ code a

#define FF_API_PIX_FMT 0

before including the ffmpeg headers.

This disables the if in the pixfmt.h header:

#if FF_API_PIX_FMT
#define PixelFormat AVPixelFormat
...

Source: https://trac.ffmpeg.org/ticket/4216

P.S. I know the question is old, but somehow I feel that there is no solution and I needed a solution, so I added it.

Ben
  • 2,314
  • 1
  • 19
  • 36
  • Hi ben, is the edit at http://stackoverflow.com/review/suggested-edits/13669700 part of a meta discussion to burninate? If not, let's create that discussion and burnimerge all at once. And then it should be done by someone with 3k+ rep to not generate too many edits. Cheers. – Ciro Santilli OurBigBook.com Sep 14 '16 at 08:30
  • Hi, well yeah, that is my idea as it is a tag chosen very unhappily. bullet-physics is much more appropriate, many people add bullet for things related to projectiles and bullet points. The tag should be gone and I thought I would edit them all (also this gives me a beatiful amount of reputation:) ). I would love tp do the batch change myself, but I lack reputation. Before we burninate the tag, it would be good for me to clean up the ones that are not related to bullet physics (mainly related to projectiles and bullet-points), which is the other edit I did for several of them. Let us discuss. – Ben Sep 14 '16 at 10:26