Trying to read arbitrary video as plain RGB24 pixels so convert frame with sws_scale()
this way:
//...
AVFrame* pic_out = av_frame_alloc();
pic_out->format = AV_PIX_FMT_RGB24;
pic_out->width = 1920;
pic_out->height = 1080;
av_frame_get_buffer( pic_out, 32 );
struct SwsContext * img_convert_ctx = sws_getContext(
1920, 1080, AV_PIX_FMT_YUV420P,
1920, 1080, AV_PIX_FMT_RGB24,
SWS_BICUBIC,
NULL, NULL, NULL
);
//...
sws_scale(
img_convert_ctx,
pic_src->data, //pic_src is from avcodec_receive_frame()
pic_src->linesize,
0,
1080,
pic_out->data,
pic_out->linesize
);
Everything goes without any errors, but pic_out
ends up having the same data as pic_src
.
What could be the problem?
Full minimal example is here (supposed to be RGB24 image is there as 2.bmp which looks like actually being YUV-something)
Problem was I treated pic_out->data
as RGB24 image data, but it needs to be pic_out->data[0]