From 9a3ef17d8b9f96fa05b5439c89bbfc2868d0f268 Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期五, 28 四月 2017 14:53:00 +0800
Subject: [PATCH] optimize

---
 VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
index 997305c..aec1267 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/FaceCache.cpp
+++ b/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;
 

--
Gitblit v1.8.0