Video编程的一些方法

测试的时候没有yuv420p数据的时候可以用下面的函数来填充

static void fill_yuv_image(unsigned char *yptr, unsigned char *uptr, 
						   unsigned char *vptr, int frame_index, int width, int height)
{
	int x, y, i;
	i = frame_index;

	/* Y */
	for(y=0;y<height;y++) 
	{
		for(x=0;x<width;x++) 
		{
			yptr[y * width + x] = x + y + i * 3;
		}
	}

	/* Cb and Cr */
	for(y=0;y<height/2;y++) 
	{
		for(x=0;x<width/2;x++)
		{
			uptr[y * width/2 + x] = 128 + y + i * 2;
			vptr[y * width/2 + x] = 64 + x + i * 5;
		}
	}
}


你可能感兴趣的:(Video编程的一些方法)