qsv的像素格式转换

av_hwframe_transfer_data

一种方法:
AVFrame *src_frame, *dst_frame;
AVPixelFormat src_fmt, dst_fmt;

//设置源和目标帧的像素格式
src_fmt = AV_PIX_FMT_RGB24;
dst_fmt = AV_PIX_FMT_YUV420P;

//初始化源和目标帧
av_hwframe_get_buffer(src_frame, src_fmt);
av_hwframe_get_buffer(dst_frame, dst_fmt);

//转换数据
av_hwframe_transfer_data(dst_frame, src_frame, 0);

av_image_get_buffer_size(AV_PIX_FMT_NV12, 1280, 720, );
AV_PIX_FMT_ALIGN_NONE:不进行对齐;AV_PIX_FMT_ALIGN_4:每行的字节数必须是4的倍数;AV_PIX_FMT_ALIGN_8:每行的字节数必须是8的倍数;AV_PIX_FMT_ALIGN_16:每行的字节数必须是16的倍数;AV_PIX_FMT_ALIGN_32:每行的字节数必须是32的倍数。

一般情况下,使用AV_PIX_FMT_ALIGN_NONE即可,只有在特殊情况下,比如使用DSP进行图像处理时,才需要使用其他对齐方式。

你可能感兴趣的:(ffmpeg,advance,ffmpeg,gpu像素格式转换,硬件解码)