当前位置:操作系统 > 安卓/Android >>

msm7x27a添加camera差值以及添加新拍照分辨率尺寸

前段时间客户要求在高通7系列上加camera的差值,所以个人研究了一下这个差值的做法。

首先贴上要加载的文件的地址:

vendor/qcom/android-open/libcamera2/QualcommCameraHardware.cpp

vendor/qcom/proprietary/mm-camera/apps/appslib/snapshot.c

vendor/qcom/proprietary/mm-camera/common/mm_camera_inte易做图ce.h

 

 

1.首先看mm_camera_inte易做图ce.h

typedef struct {
struct camera_size_type mIn;
struct camera_size_type mOut;
int8_t mEnable;
}interpolaton_info_t;


interpolaton_info_t  *p_interpolaton_info;


//添加差值结构体定义interpolaton_info_t并申请变量*p_interpolaton_info。

 


2. 查看QualcommCameraHardware.cpp

static interpolaton_info_t  mInterpolatonInfo;    //定义变量

 

 

bool QualcommCameraHardware::startCamera()
{
    LOGV("startCamera E");

 

 

   。。。

 


    if (pthread_join(mDeviceOpenThread, NULL) != 0) {
         LOGE("openCamera thread exit failed");
         return false;
    }

    mCfgControl.mm_camera_query_parms(CAMERA_PARM_PICT_SIZE, (void **)&picture_sizes, &PICTURE_SIZE_COUNT);
#ifdef  HAVE_SW_CAM_IMAGE_INTERPOLATION
/* max pict size supported by cureent yuv sensor is 5M,how to change?
*   eg:if(picture_sizes->width == 2592 && picture_sizes->height == 1944)---->8MP
*        if(picture_sizes->width == 3200 && picture_sizes->height == 2400)---->12MP
*          ......
*        and so on
*  { 4000, 3000}, // 12MP
*  { 3200, 2400}, // 8MP
*  { 2592, 1944}, // 5MP
*  { 2048, 1536}, // 3MP QXGA
*  { 1920, 1080}, //HD1080
*  { 1600, 1200}, // 2MP UXGA
*  { 1280, 768}, //WXGA
*  { 1280, 720}, //HD720
*  { 1024, 768}, // 1MP XGA
*  { 800, 600}, //SVGA
*  { 800, 480}, // WVGA
*  { 640, 480}, // VGA
*  { 352, 288}, //CIF
*  { 320, 240}, // QVGA
*  { 176, 144} // QCIF
*
*/
memset(&mInterpolatonInfo,0,sizeof(interpolaton_info_t));
if(picture_sizes->width == 640 &&  picture_sizes->height == 480)   //这里是添加差值的起步点,从拍照640x480开始差值,即30万开始。
{
LOGE("zzb change the supported pict sizes before(%d,%d)",picture_sizes->width,picture_sizes->height);
mInterpolatonInfo.mIn = *picture_sizes;
picture_sizes -= 1;   //把拍照的指针向前移一位(根据要求可以移自己想要的位置)
PICTURE_SIZE_COUNT += 1;   //这个是和上面的picture_sizes相对应的
mInterpolatonInfo.mOut = *picture_sizes;     //这个是差值的输出分辨率
mInterpolatonInfo.mEnable = false;
LOGE("zm change the supported pict sizes after(%d,%d)",picture_sizes->width,picture_sizes->height);
}
#endif

if ((picture_sizes == NULL) || (!PICTURE_SIZE_COUNT)) {
        LOGE("startCamera X: could not get snapshot sizes");
        return false;
    }

 

 

。。。

}     // END startCamera()

 


bool QualcommCameraHardware::initImageEncodeParameters(int size)
{
    LOGV("%s: E", __FUNCTION__);


memset(&mImageEncodeParms, 0, sizeof(encode_params_t));
    int jpeg_quality = mParameters.getInt("jpeg-quality");
    bool ret;
#ifdef HAVE_SW_CAM_IMAGE_INTERPOLATION
//zm
    mImageEncodeParms.p_interpolaton_info = &mInterpolatonInfo;
#endif
    if (jpeg_quality >= 0) {
        LOGV("initJpegParameters, current jpeg main img quality =%d",
             jpeg_quality);
        //Application can pass quality of zero
        //when there is no back sensor connected.
        //as jpeg quality of zero is not accepted at
        //camera stack, pass default value.
        if(jpeg_quality == 0) jpeg_quality = 85;
        mImageEncodeParms.quality = jpeg_quality;
        ret = native_set_parms(CAMERA_PARM_JPEG_MAINIMG_QUALITY, sizeof(int), &jpeg_quality);
        if(!ret){
          LOGE("initJpegParametersX: failed to set main image quality");
          return false;
        }
    }


   。。。

 


}      //END  initImageEncodeParameters(int size)

 


CameraParameters QualcommCameraHardware::getParameters() const
{
    LOGV("getParameters: EX");
#ifdef HAVE_SW_CAM_IMAGE_INTERPOLATION
//zm
LOGE("zm:getParameters:state%d,in(%d,%d),out(%d,%d)",mInterpolatonInfo.mEnable,mInterpolatonInfo.mIn.width,mInterpolatonInfo.mIn.height,mInterpolatonInfo.mOut.width,mInterpolatonInfo.mOut.height);
if(mInterpolatonInfo.mEnable)
{
CameraParameters para = mParameters;
para.setPictureSize(mInterpolatonInfo.mOut.width,mInterpolatonInfo.mOut.height);      //设置为输出差值分辨率的值
return para;
}
#endif
    return mParameters;
}  //END  getParameters()

 

 

status_t QualcommCameraHardware::setPictureSize(const CameraParameters& params)
{
    int width, height;
    params.getPictureSize(&width, &height);
    LOGV("requested picture size %d x %d", width, height);


#ifdef HAVE_SW_CAM_IMAGE_INTERPOLATION
    LOGE("zm requested picture size %d x %d", width, height);
//zm
//support 1MP XGA-> SVGA -> WVGA    modify by zhangmin 2013.4.25 {begain
if(width == 1024 && height == 768)         //根据要求菜单的拍照分辨率导出差值分辨率的值
//if(mInterpolatonInfo.mOut.width == width && mInterpolatonInfo.mOut.height == height)
{
mInterpolatonInfo.mEnable = true;
width = mInterpolatonInfo.mIn.width;          //这个是基值(即差值的起始点)
height = mInterpolatonInfo.mIn.height;
mInterpolatonInfo.mOut.width = 1024;      //这个是输出要差值的分辨率
mInterpolatonInfo.mOut.height = 768;
LOGE("zm chg picture size %d x %d", width, height);
}
else if(width == 1280 && height == 960)   // output 1280x960
{
mInterpolatonInfo.mEnable = true;
width = mInterpolatonInfo.mIn.width;
height = mInterpolatonInfo.mIn.

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,