yuv420转rgba,yuv420内存排列为yyyy,u,v
bool yuv420ToRgb(uint8_t* yuv, int w, int h, uint8_t* rgb)
{
uint8_t* pBufy = new uint8_t[w * h];
uint8_t* pBufu = new uint8_t[w * h / 4];
uint8_t* pBufv = new uint8_t[w * h / 4];
memcpy(pBufy, yuv, w * h);
memcpy(pBufu, yuv + w * h, w * h / 4);
memcpy(pBufv, yuv + w * h * 5 / 4, w * h / 4);
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
int r = (int)(pBufy[y * w + x] + 1.370705 * (pBufv[y * w / 4 + x /
int g = (int)(pBufy[y * w + x] - 0.698001 * (pBufu[y * w / 4 + x / 2] - 128) - 0.703125 * (pBufv[y * w / 4 + x / 2] - 128));
int b = (int)(pBufy[y * w + x] + 1.732446 * (pBufu[y * w / 4 + x / 2] - 128));
if (r > 255)
r = 255;
if (r < 0)
r = 0;
if (g &g