Ejemplo n.º 1
0
bool
ImpShot::
makeExifHeader(MUINT32 const u4CamMode,
                   MUINT8* const puThumbBuf,
                   MUINT32 const u4ThumbSize,
                   MUINT8* puExifBuf,
                   MUINT32 &u4FinalExifSize,
                   MUINT32 u4ImgIndex,
                   MUINT32 u4GroupId,
                   MUINT32 u4FocusValH,
                   MUINT32 u4FocusValL)
{
    //
    MY_LOGD("+ (u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf) = (%d, %p, %d, %p)",
                            u4CamMode,  puThumbBuf, u4ThumbSize, puExifBuf);

    if (u4ThumbSize > 63 * 1024)
    {
        MY_LOGW("The thumbnail size is large than 63K, the exif header will be broken");
    }
    bool ret = true;
    uint32_t u4App1HeaderSize = 0;
    uint32_t u4AppnHeaderSize = 0;

    uint32_t exifHeaderSize = 0;
    CamExif rCamExif;
    CamExifParam rExifParam;
    CamDbgParam rDbgParam;

    // ExifParam (for Gps)
    if (! mJpegParam.ms8GpsLatitude.isEmpty() && !mJpegParam.ms8GpsLongitude.isEmpty())
    {
        rExifParam.u4GpsIsOn = 1;
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLatitude), mJpegParam.ms8GpsLatitude.string(), mJpegParam.ms8GpsLatitude.length());
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLongitude), mJpegParam.ms8GpsLongitude.string(), mJpegParam.ms8GpsLongitude.length());
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSTimeStamp), mJpegParam.ms8GpsTimestamp.string(), mJpegParam.ms8GpsTimestamp.length());
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSProcessingMethod), mJpegParam.ms8GpsMethod.string(), mJpegParam.ms8GpsMethod.length());
        rExifParam.u4GPSAltitude = ::atoi(mJpegParam.ms8GpsAltitude.string());
    }
    // the bitstream already rotated. rotation should be 0
    rExifParam.u4Orientation = 0;
    rExifParam.u4ZoomRatio = mShotParam.mu4ZoomRatio;
    //
    camera_info rCameraInfo = MtkCamUtils::DevMetaInfo::queryCameraInfo(getOpenId());
    rExifParam.u4Facing = rCameraInfo.facing;
    //
    rExifParam.u4ImgIndex = u4ImgIndex;
    rExifParam.u4GroupId = u4GroupId;
    //
    rExifParam.u4FocusH = u4FocusValH;
    rExifParam.u4FocusL = u4FocusValL;
    //
    //! CamDbgParam (for camMode, shotMode)
    rDbgParam.u4CamMode = u4CamMode;
    rDbgParam.u4ShotMode = getShotMode();
    //
    rCamExif.init(rExifParam,  rDbgParam);
    //
#if USE_3A_EXIF
    Hal3ABase* p3AHal = Hal3ABase::createInstance(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId()));
#endif

    NSCam::IHalSensor* pSensorHal;
    NSCam::IHalSensorList* const pHalSensorList = NSCam::IHalSensorList::get();
    if(pHalSensorList != NULL)
    {
        pSensorHal = pHalSensorList->createSensor(
                                        LOG_TAG,
                                        getOpenId());
        if (NULL == pSensorHal)
        {
            MY_LOGE("Null sensorHal object");
            return MFALSE;
        }
    }
    else
    {
        MY_LOGE("pHalSensorList == NULL");
    }

#if USE_3A_EXIF
    p3AHal->set3AEXIFInfo(&rCamExif);
#endif
    // the bitstream already rotated. it need to swap the width/height
    if (90 == mShotParam.mi4Rotation || 270 == mShotParam.mi4Rotation)
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureHeight,  mShotParam.mi4PictureWidth, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    else
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureWidth, mShotParam.mi4PictureHeight, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    // copy thumbnail image after APP1
    MUINT8 *pdest = puExifBuf + u4App1HeaderSize;
    ::memcpy(pdest, puThumbBuf, u4ThumbSize) ;
    //
#if USE_3A_EXIF
    // 3A Debug Info
    p3AHal->setDebugInfo(&rCamExif);
#endif
    //
    // Sensor Debug Info
    pSensorHal->setDebugInfo(&rCamExif);
    pdest = puExifBuf + u4App1HeaderSize + u4ThumbSize;
    //
    rCamExif.appendDebugExif(pdest, &u4AppnHeaderSize);
    rCamExif.uninit();

    u4FinalExifSize = u4App1HeaderSize + u4ThumbSize + u4AppnHeaderSize;
#if USE_3A_EXIF
    p3AHal->destroyInstance();
#endif
    pSensorHal->destroyInstance();
    pSensorHal = NULL;

    MY_LOGD("- (app1Size, appnSize, exifSize) = (%d, %d, %d)",
                          u4App1HeaderSize, u4AppnHeaderSize, u4FinalExifSize);
    return ret;
}
//-----------------------------------------------------------------------------
MBOOL
VideoSnapshotScenario::
integrateJpg(void)
{
    FUNCTION_IN;
    //
    MBOOL result = MTRUE;
    JpgTypeEnum thumbJpgType;
    MUINT32 exifHeaderSize = 0, debugExifHeaderSize = 0;
    CamExif jpgExif;
    CamExifParam jpgExifParam;
    CamDbgParam jpgDbgParam;
    camera_info cameraInfo = MtkCamUtils::DevMetaInfo::queryCameraInfo(mSensorId);
    Hal3ABase* p3AHal = Hal3ABase::createInstance(MtkCamUtils::DevMetaInfo::queryHalSensorDev(mSensorId));
    //
    if( mRotate == 90 ||
        mRotate == 270)
    {
        thumbJpgType = JpgType_ThumbRotate;
    }
    else
    {
        thumbJpgType = JpgType_Thumb;
    }
    //
    //allocMem(MemType_Jpg);
    mJpgInfo[JpgType_Img].bitStrSize = 0;
    //
    if( !mpParamsMgr->getStr(CameraParameters::KEY_GPS_LATITUDE).isEmpty() &&
        !mpParamsMgr->getStr(CameraParameters::KEY_GPS_LONGITUDE).isEmpty())
    {
        jpgExifParam.u4GpsIsOn = 1;
        ::strncpy(reinterpret_cast<char*>(jpgExifParam.uGPSLatitude),           mpParamsMgr->getStr(CameraParameters::KEY_GPS_LATITUDE).string(),          sizeof(jpgExifParam.uGPSLatitude) );
        ::strncpy(reinterpret_cast<char*>(jpgExifParam.uGPSLongitude),          mpParamsMgr->getStr(CameraParameters::KEY_GPS_LONGITUDE).string(),         sizeof(jpgExifParam.uGPSLongitude) );
        ::strncpy(reinterpret_cast<char*>(jpgExifParam.uGPSTimeStamp),          mpParamsMgr->getStr(CameraParameters::KEY_GPS_TIMESTAMP).string(),         sizeof(jpgExifParam.uGPSTimeStamp) );
        ::strncpy(reinterpret_cast<char*>(jpgExifParam.uGPSProcessingMethod),   mpParamsMgr->getStr(CameraParameters::KEY_GPS_PROCESSING_METHOD).string(), sizeof(jpgExifParam.uGPSProcessingMethod) );
        jpgExifParam.u4GPSAltitude = ::atoi(mpParamsMgr->getStr(CameraParameters::KEY_GPS_ALTITUDE).string());
    }
    else
    {
        MY_LOGD("No GPS data");
    }
    //
    jpgExifParam.u4Orientation = 0;
    jpgExifParam.u4ZoomRatio = 0;
    jpgExifParam.u4Facing = cameraInfo.facing;
    //
    jpgDbgParam.u4CamMode = eAppMode_VideoMode;
    jpgDbgParam.u4ShotMode = 0;
    //
    jpgExif.init(
        jpgExifParam,
        jpgDbgParam);
    //
    p3AHal->set3AEXIFInfo(&jpgExif);
    //
    if(mIsThumb)
    {
        jpgExif.makeExifApp1(
            mJpgInfo[JpgType_Main].width,
            mJpgInfo[JpgType_Main].height,
            mJpgInfo[thumbJpgType].bitStrSize,
            (MUINT8*)(mIMemBufInfo[MemType_Jpg].virtAddr),
            &exifHeaderSize);
    }
    else
    {
        jpgExif.makeExifApp1(
            mJpgInfo[JpgType_Main].width,
            mJpgInfo[JpgType_Main].height,
            0,
            (MUINT8*)(mIMemBufInfo[MemType_Jpg].virtAddr),
            &exifHeaderSize);
    }
    //
    mJpgInfo[JpgType_Img].bitStrSize += exifHeaderSize;
    MY_LOGD("JPG bitStrSize:Add exif(%d/%d)",
            exifHeaderSize,
            mJpgInfo[JpgType_Img].bitStrSize);
    //
    if(mIsThumb)
    {
        memcpy(
            (MUINT8*)(mIMemBufInfo[MemType_Jpg].virtAddr+mJpgInfo[JpgType_Img].bitStrSize),
            (MUINT8*)(mIMemBufInfo[MemType_JpgThumb].virtAddr),
            mJpgInfo[thumbJpgType].bitStrSize);
        //freeMem(MemType_JpgThumb);
        mJpgInfo[JpgType_Img].bitStrSize += mJpgInfo[thumbJpgType].bitStrSize;
        MY_LOGD("JPG bitStrSize:Add Thumbnail(%d/%d)",
                mJpgInfo[thumbJpgType].bitStrSize,
                mJpgInfo[JpgType_Img].bitStrSize);
    }
    //
    p3AHal->setDebugInfo(&jpgExif);
    mpSensorHal->setDebugInfo(&jpgExif);
    jpgExif.appendDebugExif(
        (MUINT8*)(mIMemBufInfo[MemType_Jpg].virtAddr+mJpgInfo[JpgType_Img].bitStrSize),
        &debugExifHeaderSize);
    mJpgInfo[JpgType_Img].bitStrSize += debugExifHeaderSize;
    MY_LOGD("JPG bitStrSize:Add debug exif(%d/%d)",
            debugExifHeaderSize,
            mJpgInfo[JpgType_Img].bitStrSize);
    //
    memcpy(
        (MUINT8*)(mIMemBufInfo[MemType_Jpg].virtAddr+mJpgInfo[JpgType_Img].bitStrSize),
        (MUINT8*)(mIMemBufInfo[MemType_JpgMain].virtAddr),
        mJpgInfo[JpgType_Main].bitStrSize);
    //freeMem(MemType_JpgMain);
    mJpgInfo[JpgType_Img].bitStrSize += mJpgInfo[JpgType_Main].bitStrSize;
    MY_LOGD("JPG bitStrSize:Add Main(%d/%d)",
            mJpgInfo[JpgType_Main].bitStrSize,
            mJpgInfo[JpgType_Img].bitStrSize);
    //
    saveData(
        mIMemBufInfo[MemType_Jpg].virtAddr,
        mJpgInfo[JpgType_Img].bitStrSize,
        "/sdcard/vss.jpg");
    //
    EXIT:
    p3AHal->destroyInstance();
    jpgExif.uninit();
    //
    MY_LOGD("JpgBitSize(%d)",mJpgInfo[JpgType_Img].bitStrSize);
    FUNCTION_OUT;
    return result;
}
MBOOL
PREFEATUREABSE::
makeExifHeader(MUINT32 const u4CamMode, 
    			     MUINT8* const puThumbBuf, 
				       MUINT32 const u4ThumbSize, 
				       MUINT8* puExifBuf, 
				       MUINT32 &u4FinalExifSize,
				       MUINT32 const Width,
				       MUINT32 const Height,  
				       MUINT32 u4ImgIndex, 
				       MUINT32 u4GroupId) 
{
    //
    MY_LOGD("+ (u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf) = (%d, %p, %d, %p)", 
                            u4CamMode,  puThumbBuf, u4ThumbSize, puExifBuf); 

    if (u4ThumbSize > 63 * 1024) 
    {
        MY_LOGW("The thumbnail size is large than 63K, the exif header will be broken"); 
    }
    bool ret = true;
    uint32_t u4App1HeaderSize = 0; 
    uint32_t u4AppnHeaderSize = 0; 

    uint32_t exifHeaderSize = 0;
    CamExif rCamExif;
    CamExifParam rExifParam;
    CamDbgParam rDbgParam;
            
    // ExifParam (for Gps)
    if (! mpParamsMgr->getStr(CameraParameters::KEY_GPS_LATITUDE).isEmpty() && !mpParamsMgr->getStr(CameraParameters::KEY_GPS_LONGITUDE).isEmpty()) 
    {
        rExifParam.u4GpsIsOn = 1; 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLatitude), mpParamsMgr->getStr(CameraParameters::KEY_GPS_LATITUDE).string(), mpParamsMgr->getStr(CameraParameters::KEY_GPS_LATITUDE).length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLongitude), mpParamsMgr->getStr(CameraParameters::KEY_GPS_LONGITUDE).string(), mpParamsMgr->getStr(CameraParameters::KEY_GPS_LONGITUDE).length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSTimeStamp), mpParamsMgr->getStr(CameraParameters::KEY_GPS_TIMESTAMP).string(), mpParamsMgr->getStr(CameraParameters::KEY_GPS_TIMESTAMP).length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSProcessingMethod), mpParamsMgr->getStr(CameraParameters::KEY_GPS_PROCESSING_METHOD).string(), mpParamsMgr->getStr(CameraParameters::KEY_GPS_PROCESSING_METHOD).length()); 
        rExifParam.u4GPSAltitude = ::atoi(mpParamsMgr->getStr(CameraParameters::KEY_GPS_ALTITUDE).string()); 
    } 
    
    rExifParam.u4Orientation = mpParamsMgr->getInt(CameraParameters::KEY_ROTATION);; 
    rExifParam.u4ZoomRatio = mpParamsMgr->getZoomRatio(); 
    //
    rExifParam.u4ImgIndex = u4ImgIndex;
    rExifParam.u4GroupId = u4GroupId;
    // 
    //! CamDbgParam (for camMode, shotMode)
    rDbgParam.u4CamMode = u4CamMode; 
    //
    rCamExif.init(rExifParam,  rDbgParam);
    //    
    // the bitstream already rotated. it need to swap the width/height
    if (90 == rExifParam.u4Orientation || 270 == rExifParam.u4Orientation) 
    {
        rCamExif.makeExifApp1(Height,  Width, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    else 
    {
        rCamExif.makeExifApp1(Width, Height, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    // copy thumbnail image after APP1 
    MUINT8 *pdest = puExifBuf + u4App1HeaderSize; 
    ::memcpy(pdest, puThumbBuf, u4ThumbSize) ; 
    // 

    pdest = puExifBuf + u4App1HeaderSize + u4ThumbSize; 
    //
    rCamExif.appendDebugExif(pdest, &u4AppnHeaderSize);
    rCamExif.uninit();

    u4FinalExifSize = u4App1HeaderSize + u4ThumbSize + u4AppnHeaderSize; 

    MY_LOGD("- (app1Size, appnSize, exifSize) = (%d, %d, %d)", 
                          u4App1HeaderSize, u4AppnHeaderSize, u4FinalExifSize); 
    return ret;
}
Ejemplo n.º 4
0
bool
ImpShot::
makeExifHeader(MUINT32 const u4CamMode, 
    			   MUINT8* const puThumbBuf, 
				   MUINT32 const u4ThumbSize, 
				   MUINT8* puExifBuf, 
				   MUINT32 &u4FinalExifSize, 
				   MUINT32 u4ImgIndex, 
				   MUINT32 u4GroupId,
                   MUINT32 u4FocusValH,
                   MUINT32 u4FocusValL)
{
    //
    MY_LOGD("[ImpShot]+ (u4CamMode, puThumbBuf, u4ThumbSize, puExifBuf) = (%d, %p, %d, %p)", 
                            u4CamMode,  puThumbBuf, u4ThumbSize, puExifBuf); 

    if (u4ThumbSize > 63 * 1024) 
    {
        MY_LOGW("The thumbnail size is large than 63K, the exif header will be broken"); 
    }
    bool ret = true;
    uint32_t u4App1HeaderSize = 0; 
    uint32_t u4AppnHeaderSize = 0; 

    uint32_t exifHeaderSize = 0;
    CamExif rCamExif;
    CamExifParam rExifParam;
    CamDbgParam rDbgParam;

    // ExifParam (for Gps)
    if (! mJpegParam.ms8GpsLatitude.isEmpty() && !mJpegParam.ms8GpsLongitude.isEmpty()) 
    {
        rExifParam.u4GpsIsOn = 1; 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLatitude), mJpegParam.ms8GpsLatitude.string(), mJpegParam.ms8GpsLatitude.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSLongitude), mJpegParam.ms8GpsLongitude.string(), mJpegParam.ms8GpsLongitude.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSTimeStamp), mJpegParam.ms8GpsTimestamp.string(), mJpegParam.ms8GpsTimestamp.length()); 
        ::strncpy(reinterpret_cast<char*>(rExifParam.uGPSProcessingMethod), mJpegParam.ms8GpsMethod.string(), mJpegParam.ms8GpsMethod.length()); 
        rExifParam.u4GPSAltitude = ::atoi(mJpegParam.ms8GpsAltitude.string()); 
    } 
    // the bitstream already rotated. rotation should be 0
    //Add for JPEG-Sensor	
    MBOOL outputJPEGFile, bFixedOrientation; 
    SensorHal* pSensorHal = SensorHal::createInstance(); 
    MUINT32 u4DeviceID = 0;

    if (NULL != pSensorHal)
    {
        u4DeviceID = static_cast<MUINT32>(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId()));	
        MY_LOGW("[shot][makeExifHeader] u4DeviceID=%d\n", u4DeviceID); 
        
    	pSensorHal->init(); 	
    	//get sensor format info
    	pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID),
    							  SENSOR_CMD_GET_YUV_SENSOR_CAPTURE_OUTPUT_JPEG,
    							  (MBOOL)&outputJPEGFile,
    							  0,
    							  0
    							 );
    	pSensorHal->sendCommand(static_cast<halSensorDev_e>(u4DeviceID),
    							  SENSOR_CMD_GET_YUV_SENSOR_FIXED_JPEG_ORIENTATION,
    							  (MBOOL)&bFixedOrientation,
    							  0,
    							  0
    							 );
    }
    else
    {
        outputJPEGFile = 0;
        bFixedOrientation = 0;
    }


    if (outputJPEGFile && bFixedOrientation)
    {
        rExifParam.u4Orientation = mShotParam.mi4Rotation; 
        MY_LOGW("[shot][makeExifHeader] u4Orientation=%d, bFixedOrientation=%d, outputJPEGFile=%d\n", mShotParam.mi4Rotation, bFixedOrientation, outputJPEGFile); 
    }
    else
    {
        rExifParam.u4Orientation = 0; 
        MY_LOGW("[shot][makeExifHeader] nonJpegSensor, u4Orientation=0\n"); 
    }
	
    rExifParam.u4ZoomRatio = mShotParam.mu4ZoomRatio; 
    //
    camera_info rCameraInfo = MtkCamUtils::DevMetaInfo::queryCameraInfo(getOpenId()); 
    rExifParam.u4Facing = rCameraInfo.facing; 
    //
    rExifParam.u4ImgIndex = u4ImgIndex;
    rExifParam.u4GroupId = u4GroupId;
    //
    rExifParam.u4FocusH = u4FocusValH;
    rExifParam.u4FocusL = u4FocusValL;
    // 
    //! CamDbgParam (for camMode, shotMode)
    rDbgParam.u4CamMode = u4CamMode; 
    rDbgParam.u4ShotMode = getShotMode();    
    //
    rCamExif.init(rExifParam,  rDbgParam);
    //    
    Hal3ABase* p3AHal = Hal3ABase::createInstance(MtkCamUtils::DevMetaInfo::queryHalSensorDev(getOpenId())); 
    p3AHal->set3AEXIFInfo(&rCamExif); 
    // the bitstream already rotated. it need to swap the width/height
    
    if ((!outputJPEGFile) && (90 == mShotParam.mi4Rotation || 270 == mShotParam.mi4Rotation))
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureHeight,  mShotParam.mi4PictureWidth, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    else 
    {
        rCamExif.makeExifApp1(mShotParam.mi4PictureWidth, mShotParam.mi4PictureHeight, u4ThumbSize, puExifBuf,  &u4App1HeaderSize);
    }
    // copy thumbnail image after APP1 
    MUINT8 *pdest = puExifBuf + u4App1HeaderSize; 
    ::memcpy(pdest, puThumbBuf, u4ThumbSize) ; 
    // 
    // 3A Debug Info 
    p3AHal->setDebugInfo(&rCamExif); 
    //
    // Sensor Debug Info 
    pSensorHal->setDebugInfo(&rCamExif); 
    pdest = puExifBuf + u4App1HeaderSize + u4ThumbSize; 
    //
    rCamExif.appendDebugExif(pdest, &u4AppnHeaderSize);
    rCamExif.uninit();

    u4FinalExifSize = u4App1HeaderSize + u4ThumbSize + u4AppnHeaderSize; 
    p3AHal->destroyInstance(); 
    pSensorHal->destroyInstance(); 

    MY_LOGD("- (app1Size, appnSize, exifSize) = (%d, %d, %d)", 
                          u4App1HeaderSize, u4AppnHeaderSize, u4FinalExifSize); 
    return ret;
}