我有一个旧版本的FFmpeg代码:
int ret = img_convert((AVPicture *)picture, c->pix_fmt,
(AVPicture *)input_picture, (PixelFormat)input_pix_fmt,
width, height);
if (ret < 0)
return false;
我注意到在新的ffmpeg中, img_convert()已被 sws_scale()取代,我按照格式进行了更改,如下所示:
int w = width;
int h = height;
static struct SwsContext *img_convert_ctx
= sws_getContext(w, h, (PixelFormat)input_pix_fmt,
w, h, c->pix_fmt,
SWS_BICUBIC, NULL, NULL, NULL);
int ret = sws_scale(img_convert_ctx,
input_picture->data,
input_picture->linesize,
0,
height,
(AVPicture *)picture,
(AVPicture *)picture);
if (ret < 0) {
return false;
}
sws_freeContext(img_convert_ctx);
但它给出了错误:
error: cannot convert ‘AVPicture*’ to ⏎
‘uint8_t* const* {aka unsigned char* const*}’ for argument ‘6’ to ⏎
‘int sws_scale(SwsContext*, const uint8_t* const*, ⏎
const int*, int, int, uint8_t* const*, const int*)’
似乎错误属于sws_scale的最后两个参数。我应该如何修改它?
是否由 c和c ++不兼容问题引起?我现在在C中运行FFmpeg,并使用 extern C 来包含标题。
答案 0 :(得分:2)
sws_scale没有AVPicture的概念。而是传递数据线和线条化线。这是
sws_scale(
img_convert_ctx,
input_picture->data,
input_picture->linesize,
0,
height,
picture->data,
picture->linesize
);
顺便说一句,您可以复制AVPicture
结构,因此没有理由使用指针。