获取RGB32像素数据:
像素数据后的格式:AV_PIX_FMT_RGB32
//6.读取每帧画面
//AVPacket 保存每一帧的画面
AVPacket *pkt=nullptr;
//开空间
pkt=(AVPacket*)malloc(sizeof(AVPacket));
//一帧大小
int OnePicsize=av_codec_Context->width*av_codec_Context->height;
//开空间
av_new_packet(pkt,OnePicsize);
//保存的的像素数据
AVFrame *picYUV=nullptr;
picYUV=av_frame_alloc();
picYUV->width=av_codec_Context->width;
picYUV->height=av_codec_Context->height;
picYUV->format=av_codec_Context->pix_fmt;//转码格式和解码格式要一样
//转码后的像素数据
AVFrame *pic=nullptr;
pic=av_frame_alloc();
pic->width=av_codec_Context->width;
pic->height=av_codec_Context->height;
pic->format=av_codec_Context->pix_fmt;//转码格式和解码格式要一样
//一帧码流数据解码后的像素数据多大?
int numByte=avpicture_get_size(AV_PIX_FMT_RGB32,av_codec_Context->width,av_codec_Context->height);
//给AVFrame中的data数据(解码后的图像像素数据)开空间
uint8_t *buffer=(uint8_t *)malloc(sizeof(uint8_t)*numByte);
//填充像素数据
//avpicture_fill((AVPicture*)pic,buffer,AV_PIX_FMT_RGB32,av_codec_Context->width,av_codec_Context->height);
avpicture_fill((AVPicture*)picYUV,buffer,AV_PIX_FMT_RGB32,av_codec_Context->width,av_codec_Context->height);
//压缩时图像会发生变化,解码时得恢复
//解码的转换规则 具体的转换规则SWS_BICUBIC
SwsContext *sws_context=nullptr;
sws_context=sws_getContext(av_codec_Context->width,av_codec_Context->height,av_codec_Context->pix_fmt,
av_codec_Co