Program is crashing when using swscale (yuv420p->bgr24) on an target image with alignment 1. The underlying OS is Ubuntu 18.04LTS Server edition. The code is working fine on Windows 10, Ubuntu18.04LTS Desktop, OSX.
#include <libswscale/swscale.h>
#include <libavutil/imgutils.h>
typedef unsigned char byte;
void yuv420ToBgr24(uint8_t* srcData[4], int srcStride[4], uint8_t* tgtData[4], int tgtStride[4], int w, int h)
{
struct SwsContext* context = sws_getContext(w, h, AV_PIX_FMT_YUV420P,
w, h, AV_PIX_FMT_BGR24,
SWS_FAST_BILINEAR | SWS_BITEXACT, NULL, NULL, NULL);
{
sws_scale(context,
srcData, srcStride, 0, h,
tgtData, tgtStride);
}
sws_freeContext(context);
}
void main()
{
int w = 854; int h = 400;
uint8_t* yuvData[4]; int yuvStride[4];
av_image_alloc(yuvData, yuvStride, w, h, AV_PIX_FMT_YUV420P, 16);
uint8_t* bgrData[4]; int bgrStride[4];
av_image_alloc(bgrData, bgrStride, w, h, AV_PIX_FMT_BGR24, 1); //if align is 1 then segfault is obtained
yuv420ToBgr24(yuvData, yuvStride, bgrData, bgrStride, w, h);
printf("done\n");
}