void *VC_FaceThreadFnc(void *param)
{
            ImageThread_S *pFaceThread;
            PF_Rect_S viRect;
            Uapi_ExpWin_t expWin;
            HNY_AiFaceRectInfo_S *pAiFaceRectInfo = NULL;
            char threadName[64];
            char *pBuf = NULL;
            int i, id, width, height, ret, cnt = 0, faceCnt = 0;
            PF_Rect_S stRect = {0};
            int faceWidthSum = 0, faceHeightSum = 0, faceWidthAvg = 0, faceHeightAvg = 0, faceWidthMax = 0, faceHeightMax = 0;
            int lastFaceX = 0, lastFaceY = 0;
            int minExpChange = 10;
            
            	sprintf(threadName, "FaceFnc");
            	prctl(PR_SET_NAME, (unsigned long)threadName, 0, 0, 0);
            	pBuf = (char *)malloc(sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S));
            	if(pBuf == NULL)
            	{
            		DEBUG_ERROR(MODULE_CODEC, "Call malloc func err!");
            		return NULL;
            	}
            
            memset(&viRect, 0x0, sizeof(PF_Rect_S));
            VC_GetViRect(0, &viRect);
            
            pFaceThread = (ImageThread_S *)param;
            while(pFaceThread->threadRun)
            {
            memset(pBuf, 0x00, sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S));
            ret = SHB_ShareBufGetOneFrame(g_imageManager.metaDataBuf, sizeof(HNY_FrameHeader_S) + sizeof(HNY_AiFaceRectInfo_S), pBuf);
            if(ret <= 0)
            {
            usleep(50 * 1000);
            cnt++;
            if(cnt < 3)
            continue;
            }
            
            if(cnt >= 10)
            {
            cnt = 0;
            expWin.h_offs = 0;
            expWin.v_offs = 0;
            expWin.h_size = 1920;
            expWin.v_size = 1080;
            }
            else
            {
            pAiFaceRectInfo = (HNY_AiFaceRectInfo_S *)(pBuf + sizeof(HNY_FrameHeader_S));
            
            if(pAiFaceRectInfo->faceCnt <= 0)
            {
            usleep(50 * 1000);
            continue;
            }
            
            // 统计当前场景下人脸大小的均值
            faceCnt = pAiFaceRectInfo->faceCnt < 5 ?  pAiFaceRectInfo->faceCnt : 5;
            faceWidthSum = 0;
            faceHeightSum = 0;
            faceWidthMax = 0;
            faceHeightMax = 0;
            for(i = 0; i < faceCnt; i++)
            {
            width = pAiFaceRectInfo->faceRect[i].faceRect.right - pAiFaceRectInfo->faceRect[i].faceRect.left;
            height = pAiFaceRectInfo->faceRect[i].faceRect.bottom - pAiFaceRectInfo->faceRect[i].faceRect.top;
            if(width > viRect.width / 5 || height > viRect.height / 5)
            {
            continue;
            }
            if(width > faceWidthMax)
            {
            faceWidthMax = width;
            }
            if(height > faceHeightMax)
            {
            faceHeightMax = height;
            }
            }
            if(faceCnt != 0)
            {
            faceWidthAvg = faceWidthMax;
            faceHeightAvg = faceHeightMax;
            }
            
            // 当人脸位置发生大跳跃时，不立即更新曝光值，等待下一帧检测
            if(pAiFaceRectInfo->faceCnt > 0 && abs(pAiFaceRectInfo->faceRect[0].faceRect.left - lastFaceX) > viRect.width / 8)
            {
            lastFaceX = pAiFaceRectInfo->faceRect[0].faceRect.left;
            lastFaceY = pAiFaceRectInfo->faceRect[0].faceRect.top;
            usleep(50 * 1000);
            continue;
            }
            
            // 查找最接近上一帧人脸的人脸
            id = -1;
            width = 0;
            height = 0;
            for(i = 0; i < pAiFaceRectInfo->faceCnt; i++)
            {
            int curWidth = pAiFaceRectInfo->faceRect[i].faceRect.right - pAiFaceRectInfo->faceRect[i].faceRect.left;
            int curHeight = pAiFaceRectInfo->faceRect[i].faceRect.bottom - pAiFaceRectInfo->faceRect[i].faceRect.top;
            
            if(curWidth > faceWidthAvg || curHeight > faceHeightAvg)
            {
            continue;
            }
            
            if(id == -1 || (abs(pAiFaceRectInfo->faceRect[i].faceRect.left - lastFaceX) < abs(pAiFaceRectInfo->faceRect[id].faceRect.left - lastFaceX)))
            {
            id = i;
            width = curWidth;
            height = curHeight;
            }
            }
            
            if(id >= 0)
            {
            lastFaceX = pAiFaceRectInfo->faceRect[id].faceRect.left;
            lastFaceY = pAiFaceRectInfo->faceRect[id].faceRect.top;
            
            expWin.h_offs = lastFaceX * viRect.width / 10000;
            expWin.v_offs = lastFaceY * viRect.height / 10000;
            expWin.h_size = width * viRect.width / 10000;
            expWin.v_size = height * viRect.height / 10000;
            stRect.x = expWin.h_offs;
            stRect.y = expWin.v_offs;
            stRect.width = expWin.h_size;
            stRect.height = expWin.v_size;
            
            // 当人脸大小变化超过一定范围时，更新曝光值
            int expChange = abs(stRect.width * stRect.height - g_imageManager.lastFaceSize);
            if(expChange > minExpChange)
            {
            g_imageManager.lastFaceSize = stRect.width * stRect.height;
            ret = VC_SetFaceExp(stRect);
            }
            }
            
            usleep(50 * 1000);
            }
            }
            
            
            free(pBuf);
            
            }
            检查代码中的bug并修复