houxiao
2017-04-28 9a3ef17d8b9f96fa05b5439c89bbfc2868d0f268
VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
@@ -20,7 +20,7 @@
//#define YUV420_TO_RGB888 1
//#define YUV420_TO_RGB565 1
#define YUV420_TO_ARGB8888 1
#define YUV420_TO_ABGR8888 1
struct FcPmBreackerContext
{
@@ -98,7 +98,7 @@
        return true;
    }
    bool convertYUV420ToARGB8888()
    bool convertYUV420ToABGR8888()
    {
        int src_height = height;
        int src_width = width;
@@ -106,12 +106,23 @@
        const uint8* src_u = (const uint8*)(src_y + (src_height * src_width));
        const uint8* src_v = (const uint8*)(src_u + (src_height * src_width / 4));
        libyuv::I420ToARGB(src_y, src_width,
        libyuv::I420ToABGR(src_y, src_width, // android ARGB_8888 is ABGR
                             src_u, SUBSAMPLE(src_width, 2),
                             src_v, SUBSAMPLE(src_width, 2),
                             frameRGB, 4 * src_width,
                             src_width, src_height);
        frameRGBSize = src_height * src_width * 4;
        //{
        //    static size_t f = 0;
        //    char fname[50];
        //    sprintf(fname, "/sdcard/face-%u.argb", ++f);
        //    FILE *pFile = fopen(fname, "wb");
        //    fwrite(frameRGB, 1, frameRGBSize, pFile);
        //    fclose(pFile);
        //    if (f > 10)exit(0);
        //}
        return true;
    }
};
@@ -411,7 +422,7 @@
    return true;
}
#elif YUV420_TO_ARGB8888
#elif YUV420_TO_ABGR8888
bool FaceCache::getFaceListImage(std::vector<NativeImgIdx>& imgIdxes, uint8_t* buffImg, size_t& buffImgMaxSize)
{
@@ -422,7 +433,7 @@
    if (ctx.frameRGBSize == 0)
    {
        //#todo should optimize not convert the whole image
        if (! ctx.convertYUV420ToARGB8888())
        if (! ctx.convertYUV420ToABGR8888())
            return false;
    }
@@ -440,7 +451,7 @@
        NativeImgIdx imgidx;
        imgidx.offset = offset;
        imgidx.size = roiMat.total() * roiMat.elemSize();
        imgidx.type = MB_Frame::MBFT_ARGB8888;
        imgidx.type = MB_Frame::MBFT_ABGR8888;
        imgidx.width = roiMat.cols;
        imgidx.height = roiMat.rows;