void
BaseCamAdapter::
showParameters(String8 const& param) const
{
    static char bufParam[4096];

    const int count = 768;
    char *pbuf = bufParam;
    char ch;
    uint32_t len;
    uint32_t i, loop;

    pbuf[0] = 0;
    len = param.length();
    if ( len > 4096) {
        len = 4096;
    }

    ::strcpy(pbuf, param.string());
    loop = (len + count - 1) / count;

    CAM_LOGD("[showParameters]: %d, %d \n", loop, len);
    for (i = 0; i < loop; i++) {
        ch = pbuf[count];
        pbuf[count] = 0;
        CAM_LOGD("(%s) \n", pbuf);
        pbuf[count] = ch;
        pbuf += count;
    }
}
/******************************************************************************
* save the buffer to the file
*******************************************************************************/
static bool
saveBufToFile(char const*const fname, MUINT8 *const buf, MUINT32 const size)
{
    int nw, cnt = 0;
    uint32_t written = 0;

    CAM_LOGD("(name, buf, size) = (%s, %x, %d)", fname, buf, size);
    CAM_LOGD("opening file [%s]\n", fname);
    int fd = ::open(fname, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU);
    if (fd < 0) {
        CAM_LOGE("failed to create file [%s]: %s", fname, ::strerror(errno));
        return false;
    }

    CAM_LOGD("writing %d bytes to file [%s]\n", size, fname);
    while (written < size) {
        nw = ::write(fd,
                     buf + written,
                     size - written);
        if (nw < 0) {
            CAM_LOGE("failed to write to file [%s]: %s", fname, ::strerror(errno));
            break;
        }
        written += nw;
        cnt++;
    }
    CAM_LOGD("done writing %d bytes to file [%s] in %d passes\n", size, fname, cnt);
    ::close(fd);
    return true;
}
Пример #3
0
MINT32
halMAV::mHal3dfMerge(MUINT32 *MavResult
)
{
      MINT32 err = S_MAV_OK;
      MavResultInfo    MyMavResultInfo;
      MavPipeResultInfo* MyMAVResult=(MavPipeResultInfo*)MavResult;
      //MFLOAT* myMavResult=(MFLOAT*)MavResult;
    CAM_LOGD("[mHalMavMerge] \n");
    if (!m_pMTKMavObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavMerge] Err, Init has been called \n");
    }
    m_pMTKMavObj->MavMerge((MUINT32 *)&MyMavResultInfo);
    MyMAVResult->ViewIdx=MyMavResultInfo.ViewIdx;
    MyMAVResult->ClipWidth=MyMavResultInfo.ClipWidth;
    MyMAVResult->ClipHeight=MyMavResultInfo.ClipHeight;
    MyMAVResult->RetCode=MyMavResultInfo.RetCode;
    MyMAVResult->ErrPattern=MyMavResultInfo.ErrPattern;
    memcpy(MyMAVResult->ImageHmtx,(void*)&MyMavResultInfo.ImageHmtx,sizeof(MFLOAT)*MAV_MAX_IMAGE_NUM*RANK*RANK);

    for(int i=0;i<MAV_MAX_IMAGE_NUM;i++)
    {
           MyMAVResult->ImageInfo[i].ClipX = MyMavResultInfo.ImageInfo[i].ClipX;
           MyMAVResult->ImageInfo[i].ClipY = MyMavResultInfo.ImageInfo[i].ClipY;
           //LOGD("[mHalMavMerge] MyMavResultInfo %f %f %f , %f %f %f , %f %f %f \n",(MFLOAT)MyMavResultInfo.ImageHmtx[i][0][0],(MFLOAT)MyMavResultInfo.ImageHmtx[i][0][1],(MFLOAT)MyMavResultInfo.ImageHmtx[i][0][2],(MFLOAT)MyMavResultInfo.ImageHmtx[i][1][0],(MFLOAT)MyMavResultInfo.ImageHmtx[i][1][1],(MFLOAT)MyMavResultInfo.ImageHmtx[i][1][2],(MFLOAT)MyMavResultInfo.ImageHmtx[i][2][0],(MFLOAT)MyMavResultInfo.ImageHmtx[i][2][1],(MFLOAT)MyMavResultInfo.ImageHmtx[i][2][2]);
           //LOGD("[mHalMavMerge] MyMAVResult Width %d  Height %d ",MyMAVResult->ImageInfo[i].Width,MyMAVResult->ImageInfo[i].Height);
           //LOGD("[mHalMavMerge] MavResult %f %f %f , %f %f %f , %f %f %f \n",(MFLOAT)*(myMavResult+(i*9)),(MFLOAT)*(myMavResult+(i*9+1)),(MFLOAT)*(myMavResult+(i*9+2)),(MFLOAT)*(myMavResult+(i*9+3)),(MFLOAT)*(myMavResult+(i*9+4)),(MFLOAT)*(myMavResult+(i*9+5)),(MFLOAT)*(myMavResult+(i*9+6)),(MFLOAT)*(myMavResult+(i*9+7)),(MFLOAT)*(myMavResult+(i*9+8)));
    }

    return S_MAV_OK;
}
Пример #4
0
/******************************************************************************
*   convert rgb565 to jpeg file 
*******************************************************************************/
bool rgb565toJpeg(uint8_t *pbufIn, uint8_t *pbufOut, uint32_t width, uint32_t height, uint32_t *psize)
{
    uint32_t size = 0;

    // It's sw encode, the buffer address must be virtual address
    CAM_LOGD("[rgb565toJpeg] pbufIn: 0x%x, pbufOut: 0x%x, width: %d, height: %d \n", (uint32_t) pbufIn, (uint32_t) pbufOut, width, height);

    SkImageEncoder::Type fm =  SkImageEncoder::kJPEG_Type;
    bool success = false;
    SkImageEncoder *pencoder = SkImageEncoder::Create(fm);
    if (NULL != pencoder) {
        SkMemoryWStream *pskMemStream = new SkMemoryWStream(pbufOut, width * height * 2);
        if (NULL != pskMemStream) {
            SkBitmap *pbitmap = new SkBitmap;
            if (NULL != pbitmap) {
                pbitmap->setConfig(SkBitmap::kRGB_565_Config, width, height);
                pbitmap->setPixels(pbufIn);
                success = pencoder->encodeStream(pskMemStream, *pbitmap, 85);
                if (success) {
                    size = pskMemStream->getBytesWritten();
                }
            }
            delete pbitmap;
        }
        delete pskMemStream;
        delete pencoder;
    }

    *psize = size;
    CAM_LOGD(" size: %d \n", size);
    return success;
}
Пример #5
0
MINT32
halMAV::mHal3dfGetMavResult(void* pParaOut
)
{
    MINT32 err = S_MAV_OK;
    CAM_LOGD("[mHal3dfGetMavResult] \n");
    if (!m_pMTKMavObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHal3dfGetMavResult] Err, object not exist \n");
    }
    m_pMTKMavObj->MavFeatureCtrl(MAV_FEATURE_GET_RESULT, 0, pParaOut);
    return err;
}
Пример #6
0
MINT32
halMAV::mHalMavMain(
)
{
      MINT32 err = S_MAV_OK;
    CAM_LOGD("[mHalMavMain] \n");
    if (!m_pMTKMavObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavMain] Err, Init has been called \n");
    }
    m_pMTKMavObj->MavMain();
    return S_MAV_OK;
}
Пример #7
0
MINT32
halMAV::mHal3dfAddImg(MavPipeImageInfo* pParaIn
)
{
      MINT32 err = S_MAV_OK;
    CAM_LOGD("[mHalMavAddImg] \n");
    if (!m_pMTKMavObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavAddImg] Err, Init has been called \n");
    }
    MAV_OPTIMIZE=pParaIn->ControlFlow;
    m_pMTKMavObj->MavFeatureCtrl(MAV_FEATURE_ADD_IMAGE,pParaIn,NULL);
    mHalMavMain();
    return err;
}
Пример #8
0
MBOOL
Mhal_facebeauty::
SaveJpg()
{
    //optimize jpg save in step2
    CAM_LOGD(" Save JPG %s",mShotParam.ms8ShotFileName.string());
    if(mShotParam.ms8ShotFileName.string()!=NULL)
    {
        CAM_LOGD("Save JPG");
        sem_init(&semJPGDone, 0, 0);
        UtilityStatus = 2;
        sem_post(&semUtilitythread);
    }
    return  MTRUE;
}
Пример #9
0
sp<IShot>
createFBShot(char const*const pszShotName,
    uint32_t const u4ShotMode,
    int32_t const i4OpenId,
    MtkCameraFaceMetadata* FaceInfo,
    int32_t const       iSmoothLevel,
    int32_t const       iSkinColor,
    int32_t const       iSharp
)
{
    sp<IShot>       pShot = NULL;
    sp<Mhal_facebeauty>  pImpShot = NULL;
    CAM_LOGD("new FBShot");
    pImpShot = new Mhal_facebeauty(pszShotName,u4ShotMode,i4OpenId);
    if  ( pImpShot == 0 ) {
        CAM_LOGE("[%s] new FBShot \n", __FUNCTION__);
        goto lbExit;
    }
    //
    //  (1.2) initialize Implementator if needed.
    if  ( ! pImpShot->onCreate(FaceInfo) ) {
        CAM_LOGE("[%s] FBShot onCreate() \n", __FUNCTION__);
        goto lbExit;
    }
    //
    //  (2)   new Interface.
    pShot = new IShot(pImpShot);
    if  ( pShot == 0 ) {
        CAM_LOGE("[%s] FBShot new IShot \nt", __FUNCTION__);
        goto lbExit;
    }


lbExit:
    //
    int LS = iSmoothLevel;
    int LC = iSkinColor;
    int LW = iSharp;
    //(3)  tuning parameter
    LS+=5;
    LC+=5;
    LW+=5;

    pImpShot->mSmoothLevel = LS;
    pImpShot->mBrightLevel = LC;
    pImpShot->mRuddyLevel = 10-LC;
    pImpShot->mWarpLevel = LW;
    pImpShot->mContrastLevel = 5;

    if(pImpShot->mRuddyLevel<3)
        pImpShot->mRuddyLevel = 3;

    //  Free all resources if this function fails.
    if  ( pShot == 0 && pImpShot != 0 ) {
        pImpShot->onDestroy();
        pImpShot = NULL;
    }
    //
    return  pShot;
}
Пример #10
0
void
IParamsManager::
showParameters(String8 const& rs8Param)
{
    String8 s8Log;
    ssize_t const max_cpy_len = 767;

    size_t loop = 0;
    size_t const len = rs8Param.length();
    char const* pHead = rs8Param.string();
    char const*const pEnd = pHead + len;

    for (; pHead < pEnd;)
    {
        ssize_t cpy_len = pEnd - pHead;
        if  ( cpy_len > max_cpy_len )
        {
            cpy_len = max_cpy_len;
        }
        s8Log.setTo(pHead, cpy_len);
        CAM_LOGD("%s", s8Log.string());
        pHead += cpy_len;
        loop++;
    }
    MY_LOGD("%zu %zu", loop, len);
}
Пример #11
0
MINT32 halMAV::mHal3dfSetWokBuff(void* pWorkingBuff)
{
    MINT32 err = S_MAV_OK;
    CAM_LOGD("[mHal3dfSetWokBuff] %p", pWorkingBuff);
    m_pMTKMavObj->MavFeatureCtrl(MAV_FEATURE_SET_WORKBUF_ADDR, pWorkingBuff, NULL);
    return err;
}
Пример #12
0
MINT32
halMAV::mHal3dfUninit(
)
{
    CAM_LOGD("[mHalMavUninit] \n");

    if (m_pMTKMavObj) {
        m_pMTKMavObj->MavReset();
        m_pMTKMavObj->destroyInstance();
    }
    m_pMTKMavObj = NULL;

    if (m_pMTKPanoMotionObj) {
        m_pMTKPanoMotionObj->MotionExit();
        m_pMTKPanoMotionObj->destroyInstance();
    }
    m_pMTKPanoMotionObj = NULL;

    if (m_pMTKMotionObj) {
        m_pMTKMotionObj->MotionExit();
        m_pMTKMotionObj->destroyInstance();
    }
    m_pMTKMotionObj = NULL;

    if (m_pMTKWarpObj) {
        m_pMTKWarpObj->WarpReset();
        m_pMTKWarpObj->destroyInstance(m_pMTKWarpObj);
    }
    m_pMTKWarpObj = NULL;

    return S_MAV_OK;
}
sp<IShot>
createNormalShot(char const*const pszShotName,
    uint32_t const u4ShotMode,
    int32_t const i4OpenId)
{
    sp<IShot>       pShot = NULL;
    sp<NormalShot>  pImpShot = NULL;
    CAM_LOGD("new NormalShot");
    pImpShot = new NormalShot(pszShotName, u4ShotMode, i4OpenId);
    if  ( pImpShot == 0 ) {
        CAM_LOGE("[%s] new NormalShot", __FUNCTION__);
        goto lbExit;
    }
    //
    //  (1.2) initialize Implementator if needed.
    if  ( ! pImpShot->onCreate() ) {
        CAM_LOGE("[%s] NormalShot onCreate()", __FUNCTION__);
        goto lbExit;
    }
    //  (2)   new Interface.
    pShot = new IShot(pImpShot);
    if  ( pShot == 0 ) {
        CAM_LOGE("[%s] NormalShot new IShot", __FUNCTION__);
        goto lbExit;
    }   
lbExit:
    //  Free all resources if this function fails.
    if  ( pShot == 0 && pImpShot != 0 ) {
        pImpShot->onDestroy();
        pImpShot = NULL;
    }

    return  pShot;     
}
Пример #14
0
MINT32
halMAV::mHal3dfCrop(MUINT32 *MavResult,MUINT8 ImgNum
)
{
    MINT32 err = S_MAV_OK;

    WarpImageInfo    MyImageInfo;
    MavPipeResultInfo MyMavPipeResultInfo;
    memcpy((void*)&MyMavPipeResultInfo, MavResult, sizeof(MavPipeResultInfo));
    MFLOAT Imtx[9] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };

    MyImageInfo.ImgAddr[0] = MyMavPipeResultInfo.ImageInfo[0].ImgAddr;
    MyImageInfo.ImgNum = ImgNum;
    MyImageInfo.ImgFmt = WARP_IMAGE_YV12;
    MyImageInfo.Width = MyMavPipeResultInfo.ImageInfo[0].Width;
    MyImageInfo.Height = MyMavPipeResultInfo.ImageInfo[0].Height;
    MyImageInfo.ClipWidth = MyMavPipeResultInfo.ClipWidth;
    MyImageInfo.ClipHeight = MyMavPipeResultInfo.ClipHeight;

    CAM_LOGD("[mHalMavWarp] ImgAddr %p ClipWidth %d ClipHeight %d ImgNum %d\n",MyImageInfo.ImgAddr,MyMavPipeResultInfo.ClipWidth,MyMavPipeResultInfo.ClipHeight,ImgNum); 
    for(int i=0;i<MAV_MAX_IMAGE_NUM;i++)
    {
        memcpy(MyImageInfo.Hmtx[i], Imtx, sizeof(MFLOAT)*RANK*RANK);
        MyImageInfo.ClipX[i] = MyMavPipeResultInfo.ImageInfo[i].ClipX;
        MyImageInfo.ClipY[i] = MyMavPipeResultInfo.ImageInfo[i].ClipY;
        //CAM_LOGD("[mHalMavWarp] ClipX %d ClipY %d time %d\n",MyImageInfo.ClipX[i],MyImageInfo.ClipY[i],i);
    }
    m_pMTKWarpObj->WarpFeatureCtrl(WARP_FEATURE_ADD_IMAGE, &MyImageInfo, NULL);
    // warping
    m_pMTKWarpObj->WarpMain();
    m_pMTKMavObj->MavReset();
    return err;
}
halAUTORAMABase*
halAUTORAMATmp::
getInstance()
{
    CAM_LOGD("[halAUTORAMATmp] getInstance \n");
    static halAUTORAMATmp singleton;
    return &singleton;
}
Пример #16
0
hal3DFBase*
hal3DFTmp::
getInstance()
{
    CAM_LOGD("[hal3DFTmp] getInstance \n");
    static hal3DFTmp singleton;
    return &singleton;
}
Пример #17
0
MINT32
halMAV::mHal3dfInit(void* MavInitInData,void* MotionInitInData,void* WarpInitInData,void* Pano3DInitInData
)
{
    MINT32 err = S_MAV_OK;
    MavInitInfo myInfo;
    MTKMotionEnvInfo MyMotionEnvInfo;
    MTKMotionTuningPara MyMotionTuningPara;
    CAM_LOGD("[mHalMavInit] \n");

    if (m_pMTKMavObj)
        CAM_LOGD("[mHalMavInit] m_pMTKMavObj Init has been called \n");
    else
        m_pMTKMavObj = MTKMav::createInstance(DRV_MAV_OBJ_SW);
    //Not use initial function to set working buffer
    myInfo.WorkingBuffAddr=(MUINT8 *)MavInitInData;
    myInfo.pTuningInfo = NULL;
    m_pMTKMavObj->MavInit((void*)&myInfo, NULL);

    if (m_pMTKMotionObj)
        CAM_LOGD("[mHalMavInit] m_pMTKMotionObj Init has been called \n");
    else
        m_pMTKMotionObj = MTKMotion::createInstance(DRV_MOTION_OBJ_MAV);
    MyMotionEnvInfo.WorkingBuffAddr = (MUINT8 *)Pano3DInitInData;
    MyMotionEnvInfo.pTuningPara = NULL;
    m_pMTKMotionObj->MotionInit(&MyMotionEnvInfo, NULL);

    if (m_pMTKPanoMotionObj)
        CAM_LOGD("[mHalMavInit] m_pMTKPanoMotionObj Init has been called \n");
    else
        m_pMTKPanoMotionObj = MTKMotion::createInstance(DRV_MOTION_OBJ_PANO);
    MyMotionEnvInfo.WorkingBuffAddr = (MUINT8 *)MotionInitInData;
    MyMotionEnvInfo.pTuningPara = &MyMotionTuningPara;
    MyMotionEnvInfo.SrcImgWidth = MOTION_IM_WIDTH;
    MyMotionEnvInfo.SrcImgHeight = MOTION_IM_HEIGHT;
    MyMotionEnvInfo.WorkingBuffSize = MOTION_WORKING_BUFFER_SIZE;
    MyMotionEnvInfo.pTuningPara->OverlapRatio = OVERLAP_RATIO;
    m_pMTKPanoMotionObj->MotionInit(&MyMotionEnvInfo, NULL);

    if (m_pMTKWarpObj)
        CAM_LOGD("[mHalMavInit] m_pMTKWarpObj Init has been called \n");
    else
        m_pMTKWarpObj = MTKWarp::createInstance(DRV_WARP_OBJ_MAV);
    m_pMTKWarpObj->WarpInit((MUINT32*)WarpInitInData,NULL);
    return err;
}
MBOOL
Mhal_facebeauty::
fgCamShotNotifyCb(MVOID* user, CamShotNotifyInfo const msg)
{
    CAM_LOGD("[fgCamShotNotifyCb] + "); 
    Mhal_facebeauty *pFBlShot = reinterpret_cast <Mhal_facebeauty *>(user); 
    if (NULL != pFBlShot) 
    {
        CAM_LOGD("[fgCamShotNotifyCb] call back type %d",msg.msgType);
        if (NSCamShot::ECamShot_NOTIFY_MSG_EOF == msg.msgType) 
        {
            pFBlShot->mpShotCallback->onCB_Shutter(true, 0); 
            CAM_LOGD("[fgCamShotNotifyCb] call back done");                                                     
        }
    }
    CAM_LOGD("[fgCamShotNotifyCb] -"); 
    return MTRUE;
}
Пример #19
0
hal3DFBase*
halMAV::
getInstance()
{
    CAM_LOGD("[halMAV] getInstance \n");
    if (pHalMAV == NULL) {
        pHalMAV = new halMAV();
    }
    return pHalMAV;
}
Пример #20
0
void
halMAV::
destroyInstance()
{
    CAM_LOGD("[halMAV] destroyInstance \n");
    if (pHalMAV) {
        delete pHalMAV;
    }
    pHalMAV = NULL;
}
Пример #21
0
halMAV::halMAV()
{
    CAM_LOGD("[halMAV consturtor] \n");
    m_pMTKMavObj = NULL;
    m_pMTKMotionObj = NULL;
    m_pMTKWarpObj = NULL;
    m_pMTKPanoMotionObj = NULL;
    memset(&MAVPreMotionResult,0,sizeof(MAVMotionResultInfo));
    FrameCunt=0;
}
Пример #22
0
void EngUtil(MINT32 sensorInd, IHal3A* pHal3a, sp<IParamsManager> spParamsMgr)
{
    FUNCTION_IN;
    
    //(2) BV value (3A --> AP)
    FrameOutputParam_T RTParams;
    pHal3a->getRTParams(RTParams);
    int rt_BV = RTParams.i4BrightValue_x10;
    int rt_FPS = RTParams.u4FRameRate_x10;
    spParamsMgr->updateBrightnessValue(rt_BV);

    // Get fps from timestamp of pass1 buffer
    //spParamsMgr->updatePreviewFrameInterval(0); // Todo: Cannot find the timestampe // spParamsMgr->updatePreviewFrameInterval(i4P1_Frame_Interval);
    

    int index, shutter, isp_gain, sensor_gain;    
    index = RTParams.u4AEIndex;
    shutter = RTParams.u4PreviewShutterSpeed_us; // RTParams.u4ShutterSpeed_us; // NOT in "aaa_hal_common.h" // Only in "aaa_hal_base.h"
    isp_gain = RTParams.u4PreviewISPGain_x1024; // RTParams.u4ISPGain_x1024; // NOT in "aaa_hal_common.h" // Only in "aaa_hal_base.h"
    sensor_gain = RTParams.u4PreviewSensorGain_x1024; // RTParams.u4SensorGain_x1024; // NOT in "aaa_hal_common.h" // Only in "aaa_hal_base.h"
    // Get AE index, shutter, isp_gain, sensor_gain
    spParamsMgr->updatePreviewAEIndexShutterGain(index, shutter, isp_gain, sensor_gain);

    shutter = RTParams.u4CapShutterSpeed_us;
    isp_gain = RTParams.u4CapISPGain_x1024;
    sensor_gain = RTParams.u4CapSensorGain_x1024;
    // Get Capture shutter, isp_gain, sensor_gain from Preview
    spParamsMgr->updateCaptureShutterGain(shutter, isp_gain, sensor_gain);

    { // EV Calibration
        MINT32 iAECurrentEV;
        MUINT32 iOutLen;
        iAECurrentEV = 0;

        NS3A::AeMgr::getInstance(IHalSensorList::get()->querySensorDevIdx(sensorInd)).CCTOPAEGetCurrentEV(&iAECurrentEV, &iOutLen); // MINT32 AeMgr::CCTOPAEGetCurrentEV(MINT32 *a_pAECurrentEV, MUINT32 *a_pOutLen)

        AE_NVRAM_T AENVRAM;
        AENVRAM.rCCTConfig.i4BVOffset = 0;
        NS3A::AeMgr::getInstance(IHalSensorList::get()->querySensorDevIdx(sensorInd)).CCTOPAEGetNVRAMParam(&AENVRAM, &iOutLen); // MINT32 AeMgr::CCTOPAEGetNVRAMParam(MVOID *a_pAENVRAM, MUINT32 *a_pOutLen)

        if (spParamsMgr != NULL)
        {
            spParamsMgr->set(MtkCameraParameters::KEY_ENG_EV_CALBRATION_OFFSET_VALUE, iAECurrentEV + AENVRAM.rCCTConfig.i4BVOffset);

            spParamsMgr->getStr(MtkCameraParameters::KEY_ENG_EV_CALBRATION_OFFSET_VALUE).string();
            CAM_LOGD("KEY_ENG_EV_CALBRATION_OFFSET_VALUE = %s", spParamsMgr->getStr(MtkCameraParameters::KEY_ENG_EV_CALBRATION_OFFSET_VALUE).string()); // debug
        }
        else
        {
            // Show some message for spParamsMgr is NULL
        }
    }

    FUNCTION_OUT;
}
Пример #23
0
MINT32 halMAV::mHal3dfGetWokSize(int SrcWidth, int SrcHeight, MUINT32 &WorkingSize)
{
    MINT32 err = S_MAV_OK;
      MUINT32 mav_buf_size = 0;
      MavImageInfo MyMavInfo;
    MyMavInfo.Width = SrcWidth;
    MyMavInfo.Height = SrcHeight;
    CAM_LOGD("[mHal3dfGetWokSize] %p %p ", &MyMavInfo, &mav_buf_size);
    m_pMTKMavObj->MavFeatureCtrl(MAV_FEATURE_GET_WORKBUF_SIZE, &MyMavInfo, &mav_buf_size);
    WorkingSize = mav_buf_size;
    return err;
}
Пример #24
0
MBOOL
Mhal_facebeauty::
WaitSaveDone()
{
    //optimize jpg save in step2
    CAM_LOGD(" WaitSaveDone %s",mShotParam.ms8ShotFileName.string());
    if(mShotParam.ms8ShotFileName.string()!=NULL)
    {
        sem_wait(&semJPGDone);
    }
    return  MTRUE;
}
Пример #25
0
MVOID* FBUtility(void *arg)
{
    MBOOL ret = MFALSE;
    while(UtilityStatus)
    {
        CAM_LOGD("[FBUtility] Wait in UtilityStatus %d",UtilityStatus);
        sem_wait(&semUtilitythread);
        CAM_LOGD("[FBUtility] get command UtilityStatus %d",UtilityStatus);
        switch(UtilityStatus)
        {
            case 3: // memory allocate
                CAM_LOGD("[FBUtility] memory allocate");
                mpFbObj->FBWorkingBufferSize = mpFbObj->mpFb->getWorkingBuffSize(mpFbObj->mu4W_yuv,mpFbObj->mu4H_yuv,mpFbObj->mDSWidth,mpFbObj->mDSHeight,((mpFbObj->mu4W_yuv >> 1) & 0xFFFFFFF0),((mpFbObj->mu4H_yuv >> 1) & 0xFFFFFFF0));
                CAM_LOGD("[requestBufs] FBWorkingBufferSize %d",mpFbObj->FBWorkingBufferSize);
                mpFbObj->mpWorkingBuferr.size = mpFbObj->FBWorkingBufferSize;
                if(!(mpFbObj->allocMem(mpFbObj->mpWorkingBuferr)))
                {
                    mpFbObj->mpWorkingBuferr.size = 0;
                    CAM_LOGE("[requestBufs] mpWorkingBuferr alloc fail");
                }

                mpFbObj->mpAmap.size = mpFbObj->mu4SourceSize;
                if(!(mpFbObj->allocMem(mpFbObj->mpAmap)))
                {
                    mpFbObj->mpAmap.size = 0;
                    CAM_LOGE("[requestBufs] mpAmap alloc fail");
                }

                mpFbObj->mpBlurImg.size = mpFbObj->mu4SourceSize;
                if(!(mpFbObj->allocMem(mpFbObj->mpBlurImg)))
                {
                    mpFbObj->mpBlurImg.size = 0;
                    CAM_LOGE("[requestBufs] mpBlurImg alloc fail");
                }

                sem_post(&semMemoryDone);
                break;
            case 2: // jpg encode
                CAM_LOGD("[FBUtility] jpg encode ");
                ret = mpFbObj->createFBJpegImg(mpFbObj->mpSource,mpFbObj->mu4W_yuv,mpFbObj->mu4H_yuv,1);
                if  ( ! ret )
                {
                    CAM_LOGD("[FBUtility] jpg encode fail");
                }
                sem_post(&semJPGDone);
                break;
            case 0:
            default:
                break;
        }
    }
    CAM_LOGD("[FBUtility] out");
    return NULL;
}
Пример #26
0
MINT32
halMAV::mHal3dfGetResult(MUINT32& MavResult,MUINT32& ClipWidth, MUINT32& ClipHeight
)
{
     MINT32 err = S_MAV_OK;
     WarpResultInfo MyResultInfo;
     m_pMTKWarpObj->WarpFeatureCtrl(WARP_FEATURE_GET_RESULT, NULL, &MyResultInfo);
     if(MyResultInfo.RetCode!=1)
     {
           CAM_LOGD("[mHalMavGetResult] Warp fail %d\n",MyResultInfo.RetCode);
           MavResult=0;
           ClipWidth = 0;
           ClipHeight = 0;
           err = E_MAV_ERR;
     }
     else
     {
           CAM_LOGD("[mHalMavGetResult] Warp success\n");
           ClipWidth = MyResultInfo.Width;
           ClipHeight = MyResultInfo.Height;
           MavResult=1;
     }
     return err;
}
/******************************************************************************
*   read the file to the buffer
*******************************************************************************/
static uint32_t
loadFileToBuf(char const*const fname, uint8_t*const buf, uint32_t size)
{
    int nr, cnt = 0;
    uint32_t readCnt = 0;

    CAM_LOGD("opening file [%s] adr 0x%x\n", fname,buf);
    int fd = ::open(fname, O_RDONLY);
    if (fd < 0) {
        CAM_LOGE("failed to create file [%s]: %s", fname, strerror(errno));
        return readCnt;
    }
    //
    if (size == 0) {
        size = ::lseek(fd, 0, SEEK_END);
        ::lseek(fd, 0, SEEK_SET);
    }
    //
    CAM_LOGD("read %d bytes from file [%s]\n", size, fname);
    while (readCnt < size) {
        nr = ::read(fd,
                    buf + readCnt,
                    size - readCnt);
        if (nr < 0) {
            CAM_LOGE("failed to read from file [%s]: %s",
                        fname, strerror(errno));
            break;
        }
        readCnt += nr;
        cnt++;
    }
    CAM_LOGD("done reading %d bytes to file [%s] in %d passes\n", size, fname, cnt);
    ::close(fd);

    return readCnt;
}
MBOOL
Mhal_facebeauty::
fgCamShotDataCb(MVOID* user, CamShotDataInfo const msg)
{
    Mhal_facebeauty *pFBlShot = reinterpret_cast<Mhal_facebeauty *>(user); 
    CAM_LOGD("[fgCamShotDataCb] type %d +" ,msg.msgType);
    if (NULL != pFBlShot) 
    {
        if (NSCamShot::ECamShot_DATA_MSG_POSTVIEW == msg.msgType) 
        {
            pFBlShot->handlePostViewData( msg.puData, msg.u4Size);  
        }
        else if (NSCamShot::ECamShot_DATA_MSG_JPEG == msg.msgType)
        {
            pFBlShot->handleJpegData(msg.puData, msg.u4Size, reinterpret_cast<MUINT8*>(msg.ext1), msg.ext2,1);
        }
        else if (NSCamShot::ECamShot_DATA_MSG_YUV == msg.msgType)
        {
            pFBlShot->handleYuvDataCallback(msg.puData, msg.u4Size);
        }       
    }
    CAM_LOGD("[fgCamShotDataCb] -" );
    return MTRUE; 
}
Пример #29
0
MINT32
halMAV::mHal3dfWarp(MavPipeImageInfo* pParaIn, MUINT32 *MavResult,MUINT8 ImgNum
)
{
      MINT32 err = S_MAV_OK;
      WarpImageInfo    MyImageInfo;
      MavPipeResultInfo MyMavPipeResultInfo;
    CAM_LOGD("[mHalMavWarp] \n");
    if (!m_pMTKWarpObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavWarp] Err, Init has been called \n");
    }
    memcpy((void*)&MyMavPipeResultInfo, MavResult, sizeof(MavPipeResultInfo));
    if(MAV_OPTIMIZE)
    {
          CAM_LOGD("[mHal3dfWarp] Optimize Ture \n");
        MyImageInfo.ImgAddr[0] = pParaIn->ImgAddr;
        MyImageInfo.ImgNum = 1;
        MyImageInfo.ImgFmt = WARP_IMAGE_NV21;
        MyImageInfo.Width = pParaIn->Width;
        MyImageInfo.Height = pParaIn->Height;
        memcpy(MyImageInfo.Hmtx[0], MyMavPipeResultInfo.ImageHmtx[ImgNum], 9*sizeof(float));
        MyImageInfo.ClipWidth = pParaIn->Width;
        MyImageInfo.ClipHeight = pParaIn->Height;
        MyImageInfo.ClipX[0] = 0;
        MyImageInfo.ClipY[0] = 0;
    }
    else
    {
          CAM_LOGD("[mHal3dfWarp] Optimize false \n");
        
        if(ImgNum>MAV_MAX_IMAGE_NUM)  // protect wrong parameter > MAV_MAX_IMAGE_NUM
        {
        	CAM_LOGD("[mHal3dfWarp] Image Number Overflow, ImgNum %d > MAV_MAX_IMAGE_NUM %d\n", ImgNum,  MAV_MAX_IMAGE_NUM); 
        	ImgNum=MAV_MAX_IMAGE_NUM;
        }
        
        MyImageInfo.ImgNum = ImgNum;
        MyImageInfo.ImgFmt = WARP_IMAGE_NV21;
        MyImageInfo.Width = pParaIn->Width;
        MyImageInfo.Height = pParaIn->Height;
        MyImageInfo.ClipWidth = MyMavPipeResultInfo.ClipWidth;
        MyImageInfo.ClipHeight = MyMavPipeResultInfo.ClipHeight;
        memcpy(MyImageInfo.Hmtx, MyMavPipeResultInfo.ImageHmtx, sizeof(MFLOAT)*ImgNum*RANK*RANK);

        for(int i=0;i<ImgNum;i++)
        {
            MyImageInfo.ImgAddr[i] = MyMavPipeResultInfo.ImageInfo[i].ImgAddr;
            MyImageInfo.ClipX[i] = MyMavPipeResultInfo.ImageInfo[i].ClipX;
            MyImageInfo.ClipY[i] = MyMavPipeResultInfo.ImageInfo[i].ClipY;
            CAM_LOGD("[mHalMavWarp] ClipX %d ClipY %d time %d",MyImageInfo.ClipX[i],MyImageInfo.ClipY[i],i);
            CAM_LOGD("[mHalMavWarp] ImgAddr 0x%x ImgNum %d Width %d Height %d ClipWidth %d ClipHeight %d",MyImageInfo.ImgAddr[i],MyImageInfo.ImgNum,MyImageInfo.Width,MyImageInfo.Height,MyImageInfo.ClipWidth,MyImageInfo.ClipHeight);
            CAM_LOGD("[mHalMavWarp] Hmtx %f %f %f , %f %f %f , %f %f %f",(MFLOAT)MyImageInfo.Hmtx[i][0],(MFLOAT)MyImageInfo.Hmtx[i][1],(MFLOAT)MyImageInfo.Hmtx[i][2],(MFLOAT)MyImageInfo.Hmtx[i][3],(MFLOAT)MyImageInfo.Hmtx[i][4],(MFLOAT)MyImageInfo.Hmtx[i][5],(MFLOAT)MyImageInfo.Hmtx[i][6],(MFLOAT)MyImageInfo.Hmtx[i][7],(MFLOAT)MyImageInfo.Hmtx[i][8]);

        }
        if(MyMavPipeResultInfo.RetCode!=S_MAV_OK)
        {
            CAM_LOGD("[mHal3dfWarp] Rectify error martix reset \n");
            for(int i=0;i<MAV_MAX_IMAGE_NUM;i++)
            {
                MyImageInfo.Hmtx[i][0]=1.f;
                MyImageInfo.Hmtx[i][1]=0.f;
                MyImageInfo.Hmtx[i][2]=0.f;
                MyImageInfo.Hmtx[i][3]=0.f;
                MyImageInfo.Hmtx[i][4]=1.f;
                MyImageInfo.Hmtx[i][5]=0.f;
                MyImageInfo.Hmtx[i][6]=0.f;
                MyImageInfo.Hmtx[i][7]=0.f;
                MyImageInfo.Hmtx[i][8]=1.f;
            }
        }
    }


    m_pMTKWarpObj->WarpFeatureCtrl(WARP_FEATURE_ADD_IMAGE, &MyImageInfo, NULL);

    // warping
    m_pMTKWarpObj->WarpMain();

    return err;
}
Пример #30
0
MINT32
halMAV::mHal3dfDoMotion(void* InputData,MUINT32* MotionResult, MUINT32 u4SrcImgWidth, MUINT32 u4SrcImgHeight)
{
      MINT32 err = S_MAV_OK;
      MTKMotionProcInfo MotionInfo;
      MAVMotionResultInfo*  MAVMotionResult = (MAVMotionResultInfo*)MotionResult;
    //eis_stat_t* EISResult=(eis_stat_t*) InputData;
    CAM_LOGD("[mHalMavDoMotion] FrameCunt %d. u4SrcImgWidth: %d. u4SrcImgHeight: %d. \n", FrameCunt, u4SrcImgWidth, u4SrcImgHeight);
    if(FrameCunt<3)
    {
       MAVMotionResult->MV_X=0;
       MAVMotionResult->MV_Y=0;
       MAVMotionResult->ReadyToShot=0;
         FrameCunt++;
         return err;
    }
    else
         FrameCunt=3;
    if (!m_pMTKPanoMotionObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavDoMotion] Err, m_pMTKPanoMotionObj Init has been called \n");
    }

    MotionInfo.ImgAddr = InputData;
    CAM_LOGD("[mHalMAVDoMotion] ImgAddr 0x%x\n",MotionInfo.ImgAddr);
    m_pMTKPanoMotionObj->MotionFeatureCtrl(MTKMOTION_FEATURE_SET_PROC_INFO, &MotionInfo, NULL);
    m_pMTKPanoMotionObj->MotionMain();
    m_pMTKPanoMotionObj->MotionFeatureCtrl(MTKMOTION_FEATURE_GET_RESULT, NULL, MotionResult);

    if (!m_pMTKMotionObj) {
        err = E_MAV_ERR;
        CAM_LOGD("[mHalMavDoMotion] Err, m_pMTKMotionObj Init has been called \n");
    }

    MFLOAT fScaleW = (-1) * float(u4SrcImgWidth) / 320.0f;
    MFLOAT fScaleH = (-1) * float(u4SrcImgHeight) / 240.0f;
    CAM_LOGD("[mHalMavDoMotion] MVX/Y: (%f, %f). PreMVX/Y: (%f, %f). fScaleW/H: (%f, %f).\n",(MFLOAT)MAVMotionResult->MV_X,(MFLOAT)MAVMotionResult->MV_Y,(MFLOAT)MAVPreMotionResult.MV_X,(MFLOAT)MAVPreMotionResult.MV_Y, fScaleW, fScaleH);
    for(int i=0;i<MOTION_TOTAL_BN;i++)
    {
        //MotionInfo.MotionValueXY[i*2]=(MFLOAT)EISResult->i4LMV_X[i]/256;
        //MotionInfo.MotionValueXY[(i*2)+1]=(MFLOAT)EISResult->i4LMV_Y[i]/256;
        //MotionInfo.TrustValueXY[i*2]=(MFLOAT)EISResult->i4Trust_X[i];
        //MotionInfo.TrustValueXY[(i*2)+1]=(MFLOAT)EISResult->i4Trust_Y[i];
        //CAM_LOGD("[mHalMavDoMotion] MVX %f MVY %f TVX %f TVY %f\n",(MFLOAT)EISResult.i4LMV_X[i],(MFLOAT)EISResult.i4LMV_Y[i],(MFLOAT)EISResult.i4Trust_X[i],(MFLOAT)EISResult.i4Trust_Y[i]);

        MotionInfo.MotionValueXY[i*2]=(MFLOAT)(MAVMotionResult->MV_X-MAVPreMotionResult.MV_X);
        MotionInfo.MotionValueXY[(i*2)+1]=(MFLOAT)(MAVMotionResult->MV_Y-MAVPreMotionResult.MV_Y);
//        MotionInfo.MotionValueXY[i*2]*= -2;
//        MotionInfo.MotionValueXY[(i*2)+1]*= -2;
        MotionInfo.MotionValueXY[i*2]*= fScaleW;
        MotionInfo.MotionValueXY[(i*2)+1]*= fScaleH;
        MotionInfo.TrustValueXY[i*2]= 50;
        MotionInfo.TrustValueXY[(i*2)+1]= 50;
    }
    MAVPreMotionResult.MV_X=MAVMotionResult->MV_X;
    MAVPreMotionResult.MV_Y=MAVMotionResult->MV_Y;
    m_pMTKMotionObj->MotionFeatureCtrl(MTKMOTION_FEATURE_SET_PROC_INFO, &MotionInfo, NULL);
    m_pMTKMotionObj->MotionMain();
    m_pMTKMotionObj->MotionFeatureCtrl(MTKMOTION_FEATURE_GET_RESULT, NULL, MotionResult);
    return S_MAV_OK;
}