YUV12源数据转BGR24

char* YV12ToBGR24(char* pYUV,char *pBGR24,int width,int height)
{
    LOGE("==YV12ToBGR24==");

    const long len = width * height;
    char* yData = pYUV;
    char* vData = &yData[len];
    char* uData = &vData[len >> 2];

    int bgr[3];
    int yIdx,uIdx,vIdx,idx;
    for (int i = 0;i < height;i++){
        for (int j = 0;j < width;j++){
            yIdx = i * width + j;
            vIdx = (i/2) * (width/2) + (j/2);
            uIdx = vIdx;

            bgr[0] = (int)(yData[yIdx] + 1.732446 * (uData[vIdx] - 128));                                    // b分量
            bgr[1] = (int)(yData[yIdx] - 0.698001 * (uData[uIdx] - 128) - 0.703125 * (vData[vIdx] - 128));    // g分量
            bgr[2] = (int)(yData[yIdx] + 1.370705 * (vData[uIdx] - 128));                                    // r分量

            for (int k = 0;k < 3;k++){
                idx = (i * width + j) * 3 + k;
                if(bgr[k] >= 0 && bgr[k] <= 255)
                    pBGR24[idx] = bgr[k];
                else
                    pBGR24[idx] = (bgr[k] < 0)?0:255;
            }
        }
    }

    LOGE("==YV12ToBGR24 complete==");
    LOGE("prgb data is :%s .", pBGR24);
    return pBGR24;
}

发表评论

评论列表,共 3 条评论

  • Barrynot

    Ethical opinion ! smalloffering By the skin of one's teeth click on the lace subordinate to to decrease

    http://facebook.topratinglist.com?14484

  • Barrynot

    Hi What we take in here is , an bewitchingoffering Candid click on the curtail subordinate to to balance

    https://drive.google.com/file/d/1nPzbXI-X80oFGMvyEJSXVsIfMB20O9WH/preview

  • DariusNal

    Hy there, Look what we file in the avocation you! an differentfor the ease being Are you in?

    https://drive.google.com/file/d/18IIU01t2MAORSz27qZZNIWky7x-D--Wt/preview

About This Page

Made with bootstrap and jquery by TaoYuan.

Contact Me

Click! If you are interested