Reputation: 300
My code is very straightforward; it consumes YUV420P data, resizes it, and produces a PNG or JPEG image (OS X Lion, Apple's gcc 4.2.1). It works fine; I'm using ffmpeg (HEAD, as of mumble days ago), but when running in -pedantic-errors mode (which I like to do from time to time):
zc_libav.c:30: error: passing argument 2 of ‘sws_scale’ from incompatible pointer type
Ouch! Well, what's my code look like?
sws_scale(sws_ctx,
in_pic->data,
in_pic->linesize,
0,
in->y,
out_pic->data,
out_pic->linesize);
(You can assume for the sake of argument that the in_pic and out_pic AVPicture structures have been properly initialized, as the code works).
Well, what're the offending data types?
from libswscale/swscale.h:
int sws_scale(struct SwsContext *c, const uint8_t* const srcSlice[], …
from libavcodec/avcodec.h
typedef struct AVPicture {
uint8_t *data[4];
int linesize[4]; ///< number of bytes per line
} AVPicture;
As I noted above, when I change -pedantic-errors to -pedantic, I get the same complaint, but the code compiles and runs correctly. For my own neurotic sanity, is there any way to get the advantages of -pedantic-errors and, you know, compile this code?
Upvotes: 3
Views: 1681
Reputation: 64308
This would be ok in C++, but C doesn't have the same rules regarding const. It doesn't like that you are passing a non-const uint8_t ** to a function that takes a const uint8_t *const *.
In C, you can convert an X * to a const X *, but it only works for one pointer level. The next pointer level has to match exactly.
Upvotes: 4