方法1:
来自示例程序;
x264_picture_t pic; //定义要编码的 yuv图像;
param.i_csp = X264_CSP_I420;
x264_picture_alloc( &pic, param.i_csp, param.i_width, param.i_height ) ; //创建 pic空间;
//将YUV数据赋值到pic:
/* Read input frame */
int plane_size = width * height;
if( fread( pic.img.plane[0], 1, plane_size, stdin ) != plane_size )
break;
plane_size = ((width + 1) >> 1) * ((height + 1) >> 1);
if( fread( pic.img.plane[1], 1, plane_size, stdin ) != plane_size )
break;
if( fread( pic.img.plane[2], 1, plane_size, stdin ) != plane_size )
break;
方法2:
直接将一帧yuv赋值到 pic中;
memcpy( pic.img.plane[0], szYUVFrame, m_param.i_width * m_param.i_height*3 / 2 );