11 const AVPicture *src,
int src_pix_fmt,
12 int src_width,
int src_height) {
13 static struct SwsContext *img_convert_ctx =
nullptr;
14 if (img_convert_ctx==
nullptr) {
16 img_convert_ctx = sws_getContext(src_width, src_height,
17 (AVPixelFormat)src_pix_fmt,
18 src_width, src_height,
19 (AVPixelFormat)dst_pix_fmt,
21 nullptr,
nullptr,
nullptr);
25 if (img_convert_ctx!=
nullptr) {
36 sws_scale(img_convert_ctx, ((AVPicture*)src)->data,
37 ((AVPicture*)src)->linesize, 0, src_height,
38 ((AVPicture*)dst)->data, ((AVPicture*)dst)->linesize);
41 fprintf(stderr,
"image conversion failed\n");
int stable_img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, int src_pix_fmt, int src_width, int src_height)