Exemplo n.º 1
0
status_t
ParamsManager::
setParameters(CameraParameters const& params)
{
    IParamsManager::showParameters(params.flatten());
    //
    status_t    status = OK;
    bool        bIsSceneChanged = false;
    Size        oldPrvSize, tmpPrvSize, newPrvSize;
    Size        oldPicSize, newPicSize;
    //
    //  (1) Check to see if new parameters are valid or not.
    if  ( OK != (status = checkParams(params)) )
    {
        MY_LOGE("checkParams() return %d", status);
        return  status;
    }

    //  (2) Check to see if Scene Changes or not.
    MY_LOGD("%d: +", getOpenId());
    RWLock::AutoWLock _lock(mRWLock);
    MY_LOGD("AutoWLock");
    //
    char const*const pOldScene = mParameters.get(CameraParameters::KEY_SCENE_MODE);
    char const*const pNewScene =      params.get(CameraParameters::KEY_SCENE_MODE);
    if  ( 0 != ::strcmp(pOldScene, pNewScene) )
    {
        //  scene mode has changed
        MY_LOGD("Scene change: %s -> %s", pOldScene, pNewScene);
        bIsSceneChanged = true;
    }
    //
    //  (3.1) Check to see if Preview Size Changes or not. Get old preview size
    mParameters.getPreviewSize(&oldPrvSize.width, &oldPrvSize.height);
    params.getPreviewSize(&tmpPrvSize.width, &tmpPrvSize.height);

    //  (3.2) Get old&new picture size  
    mParameters.getPictureSize(&oldPicSize.width, &oldPicSize.height);
    params.getPictureSize(&newPicSize.width, &newPicSize.height);

    //  (4) Update Parameter
    mParameters = params;
    if  ( bIsSceneChanged ) {
        if  ( ! updateSceneAndParams() ) {
            status = BAD_VALUE;
        }
    }

    //  (5) Update Parameter: preview size
    updatePreviewSize();

    // (6) Update FOV according to picture size
    MY_LOGI("picSZ(%d,%d)->(%d,%d)",oldPicSize.width,oldPicSize.height,newPicSize.width,newPicSize.height);
    if(oldPicSize.width != newPicSize.width || oldPicSize.height != newPicSize.height)
    {
        updateFov(newPicSize);
    }      
    
    //  (3.2) Check to see if Preview Size Changes or not. Get new preview size
    mParameters.getPreviewSize(&newPrvSize.width, &newPrvSize.height);
    if  ( oldPrvSize.width != newPrvSize.width || oldPrvSize.height != newPrvSize.height )
    {
        MY_LOGD(
            "Preview Size change: %dx%d/%dx%d -> (%dx%d)",
            oldPrvSize.width, oldPrvSize.height,
            tmpPrvSize.width, tmpPrvSize.height,
            newPrvSize.width, newPrvSize.height
        );
    }
    //
    MY_LOGD("-");
    return status;
}
MBOOL
Mhal_facebeauty::
createFullFrame(IMEM_BUF_INFO Srcbufinfo)
{
    MBOOL  ret = MTRUE;
    MINT32 err = 0;
    CPTLog(Event_FBShot_createFullFrame, CPTFlagStart);
    MY_LOGD("[createFullFrame] + \n");
    NSCamShot::ISingleShot *pSingleShot = NSCamShot::ISingleShot::createInstance(eShotMode_FaceBeautyShot, "FaceBeautyshot");
    //
    pSingleShot->init();
    EImageFormat ePostViewFmt = static_cast<EImageFormat>(android::MtkCamUtils::FmtUtils::queryImageioFormat(mShotParam.ms8PostviewDisplayFormat)); 

    ImgBufInfo rSrcImgInfo;

    rSrcImgInfo.u4ImgWidth = mu4W_yuv;
    rSrcImgInfo.u4ImgHeight = mu4H_yuv;
    rSrcImgInfo.eImgFmt = eImgFmt_YV16;    
    rSrcImgInfo.u4Stride[0] = rSrcImgInfo.u4ImgWidth;
    rSrcImgInfo.u4Stride[1] = rSrcImgInfo.u4ImgWidth >> 1;
    rSrcImgInfo.u4Stride[2] = rSrcImgInfo.u4ImgWidth >> 1;
    rSrcImgInfo.u4BufSize = Srcbufinfo.size;
    rSrcImgInfo.u4BufVA = Srcbufinfo.virtAddr;
    rSrcImgInfo.u4BufPA = Srcbufinfo.phyAddr;
    rSrcImgInfo.i4MemID = Srcbufinfo.memID;
    pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_YUV, rSrcImgInfo);

    ImgBufInfo rPostImgInfo;
    rPostImgInfo.u4ImgWidth = mShotParam.mi4PostviewWidth;
    rPostImgInfo.u4ImgHeight = mShotParam.mi4PostviewHeight;                   
    rPostImgInfo.eImgFmt = ePostViewFmt;
    rPostImgInfo.u4Stride[0] = rPostImgInfo.u4ImgWidth;
    rPostImgInfo.u4Stride[1] = rPostImgInfo.u4ImgWidth >> 1;
    rPostImgInfo.u4Stride[2] = rPostImgInfo.u4ImgWidth >> 1;
    // using blurimg buffer for reduce buffer size
    rPostImgInfo.u4BufSize = mpBlurImg.size;
    rPostImgInfo.u4BufVA = mpBlurImg.virtAddr;
    rPostImgInfo.u4BufPA = mpBlurImg.phyAddr;
    rPostImgInfo.i4MemID = mpBlurImg.memID;

    pSingleShot->registerImgBufInfo(ECamShot_BUF_TYPE_POSTVIEW, rPostImgInfo);
    
    //
        
    pSingleShot->enableDataMsg(ECamShot_DATA_MSG_YUV
                                 //| ECamShot_DATA_MSG_JPEG
                                 );
    pSingleShot->enableNotifyMsg(NSCamShot::ECamShot_NOTIFY_MSG_EOF);
    // shot param
    NSCamShot::ShotParam rShotParam(eImgFmt_YV16,         //yuv format
                         mShotParam.mi4PictureWidth,      //picutre width
                         mShotParam.mi4PictureHeight,     //picture height
                         0,                               //picture rotation in jpg
                         0,                               //picture flip
                         ePostViewFmt,
                         mShotParam.mi4PostviewWidth,      //postview width
                         mShotParam.mi4PostviewHeight,     //postview height
                         0,                                //postview rotation
                         0,                                //postview flip
                         mShotParam.mu4ZoomRatio           //zoom
                        );

    // jpeg param
    NSCamShot::JpegParam rJpegParam(mJpegParam.mu4JpegQuality,       //Quality
                         MTRUE                            //isSOI
                        );


    // sensor param
        NSCamShot::SensorParam rSensorParam(static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())),                             //Device ID 

#warning [FIXME] workaround for Alta phone capture mode can not work 
                             ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG,         //Scenaio 
                             //ACDK_SCENARIO_ID_CAMERA_PREVIEW,         //Scenaio 
                             10,                                       //bit depth 
                             MFALSE,                                   //bypass delay
                             MFALSE                                   //bypass scenario
                            );
    //
    pSingleShot->setCallbacks(fgCamShotNotifyCb, fgCamShotDataCb, this);
    //
    pSingleShot->setShotParam(rShotParam);

    //
    pSingleShot->setJpegParam(rJpegParam);

    //
    pSingleShot->startOne(rSensorParam);

    //
    pSingleShot->uninit();

    //
    pSingleShot->destroyInstance();
    
    if(mShotParam.ms8ShotFileName.string()!=NULL)
    {
        ret = createFBJpegImg(Srcbufinfo,mu4W_yuv,mu4H_yuv,1);
        if  ( ! ret )
        {
            goto lbExit;
        }
    }
    #ifdef Debug_Mode     
    loadFileToBuf("/data/FBSOURCE.yuv",(uint8_t*)Srcbufinfo.virtAddr,Srcbufinfo.size);   
    saveBufToFile("/sdcard/img.yuv", (uint8_t*)Srcbufinfo.virtAddr, Srcbufinfo.size); 
    #endif
    CPTLog(Event_FBShot_createFullFrame, CPTFlagEnd);
    MY_LOGD("[createFullFrame] - \n");
lbExit:
    return  ret;
}