一、环境介绍
操作系统: ubuntu18.04
开发平台: RK3399
二、出现的问题
使用FFMPEG的sws_scale函数在ARM平台转换效率很低,使用libyuv提高转换效率。
三、下载编译libyuv
CSDN下载地址:https://download.csdn.net/download/xiaolong1126626497/12631325
GitHub下载地址: https://github.com/lemenkov/libyuv
wbyq@wbyq:~/qt_code/666$ unzip /mnt/hgfs/linux-share-dir/libyuv-master.zip wbyq@wbyq:~/qt_code/666$ cd libyuv-master wbyq@wbyq:~/qt_code/666$ make -f linux.mk
四、示例代码
调用libyuv库方式: 将libyuv.h包含到工程,直接调用转换函数即可(转换函数名称可看下面2个例子),编译时指定libyuv.a库。
//YUYV422转YUV420P
//YUYV422转YUV420P uint8_t* i420_image = video0_yuv420p_buff; uint8_t* i420_image_y_ptr = i420_image; uint8_t* i420_image_u_ptr = i420_image_y_ptr + (VIDEO_WIDTH * VIDEO_HEIGHT); uint8_t* i420_image_v_ptr = i420_image_u_ptr + (int)(VIDEO_WIDTH * VIDEO_HEIGHT * 0.25); libyuv::YUY2ToI420( image_buffer[video_buffer.index],VIDEO_WIDTH*2, (uint8_t*)i420_image_y_ptr, VIDEO_WIDTH, (uint8_t*)i420_image_u_ptr, (VIDEO_WIDTH >> 1), (uint8_t*)i420_image_v_ptr, (VIDEO_WIDTH >> 1), VIDEO_WIDTH, VIDEO_HEIGHT);
YUYV422转ARGB
libyuv::YUY2ToARGB(image_buffer[video_buffer.index],VIDEO_WIDTH*2, argb_buffer,VIDEO_WIDTH*4,VIDEO_WIDTH,VIDEO_HEIGHT);