开发者

Migration from Windows ffmpeg 0.52 to linux ffmpeg 0.61 code error. How to fix it?

Previously I used ffmpeg on windows (0.52 build I found somewhere). Now I am porting to linux and to latest ffmpeg. So far I got 4 errors in 2 lines On such simple line:

size = avpicture_get_size(pix_fmt, nWidth, nHeight);

I get:

  initializing argument 1 of ‘int avpicture_get_size(PixelFormat, int, int)’    C/C++ Problem

and

invalid conversion from ‘int’ to ‘PixelFormat’      C/C++ Problem

And On such simple line

 avpicture_fill((AVPicture *)picture, picture_buf, pix_fmt, nWidth, nHeight);

I get:

 initializing argument 3 of ‘int avpicture_fill(AVPicture*, uint8_t*, PixelFormat, int, int)’       C/C++ Problem

and

invalid co开发者_开发问答nversion from ‘int’ to ‘PixelFormat’      C/C++ Problem

Code compiled and worked perfectly under Windows ffmpeg 0.52 but now gives such error on linux g++ on ffmpeg 0.6.1

How to fix such errors?


PixelFormat is defined as an enum in pixfmt.h. I think that the problem is that in C++, there is no implicit conversion from an int to an enum. So, you need to explicitly convert the int to PixelFormat. Try this:

size = avpicture_get_size(static_cast<PixelFormat>(pix_fmt), nWidth, nHeight);

or you could just make pix_fmt a PixelFormat instead of an int.

I don't know why this worked previously, because C++ does not allow int to enum conversion without a cast. I think C does allow this though so maybe it was being compiled s C previously.

Edit: I just saw the API change from int to enum. So that is why it compiled previously.


Well the FFMPEG API has changed from old 0.52 to 0.6.1. You have to check the new API calls and adapt them. pix_fmt was an int, and is now a PixelFormat as your errors point out :)

In your case, the pixel format was an int in API calls in old FFMPEG and is now (0.6) an enum PixelFormat.

my2c


In addition to above answers, take a look at the old and new versions of APIs.

Old

New

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜