有两种方式可以进行图像像素之间的转换》
① avpicture_fill(&pic, buffer, PIX_FMT_RGB24, width, height)
sws_getcontext(width, height, PIX_FMT_YUV420P, width, height, PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL)
sws_scale(sCtx, pFrame->data, pFrame->linesize,
0 /*数据开始地址*/ , height /*数据行数*/ , pic.data , pic.linesize)
实现将YUV420P 像素转换为 RGB24格式。
转换结束后,数据同时写入 pic 和 buffer
② 将avpicture_alloc替换 avpicture_fill 方法
avpicture_alloc(&pic, PIX_FMT_RGB24, width, height) //申请AVPicture内存
③ 但是当将数据转换为RGB24时,如果直接调用memcpy拷贝数据,出来的图像会倒置,
需要一行一行复制数据。
::调用下述代码可以实现YUV420P转换为RGB24格式
④:RGB24和BGR24的区别。