//[20091123 exif Ratnesh
	void CameraHal::CreateExif(unsigned char* pInThumbnailData,int Inthumbsize,unsigned char* pOutExifBuf,int& OutExifSize,int flag)
	{
		int w =0, h = 0;

		int orientationValue = getOrientation();
		HAL_PRINT("CreateExif orientationValue = %d \n", orientationValue);				
		
		ExifCreator* mExifCreator = new ExifCreator();
		unsigned int ExifSize = 0;
		ExifInfoStructure ExifInfo;
		char ver_date[5] = {NULL,};
		unsigned short tempISO = 0;
		struct v4l2_exif exifobj;
		
		// To read values from driver
		if(mCameraIndex==MAIN_CAMERA)
		{
			getExifInfoFromDriver(&exifobj);
		}
   
		memset(&ExifInfo, NULL, sizeof(ExifInfoStructure));

		strcpy( (char *)&ExifInfo.maker, "SAMSUNG");
		strcpy( (char *)&ExifInfo.model, "GT-I9003");

		mParameters.getPreviewSize(&w, &h);

		mParameters.getPictureSize((int*)&ExifInfo.imageWidth , (int*)&ExifInfo.imageHeight);
		mParameters.getPictureSize((int*)&ExifInfo.pixelXDimension, (int*)&ExifInfo.pixelYDimension);

		struct tm *t = NULL;
		time_t nTime;
		time(&nTime);
		t = localtime(&nTime);

		if(t != NULL)
		{
			sprintf((char *)&ExifInfo.dateTimeOriginal, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
			sprintf((char *)&ExifInfo.dateTimeDigitized, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);						
			sprintf((char *)&ExifInfo.dateTime, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); 					
		}

		if(mCameraIndex==MAIN_CAMERA)
		{
			int cam_ver = GetCamera_version();

			ExifInfo.Camversion[0] = (cam_ver & 0xFF);
			ExifInfo.Camversion[1] = ((cam_ver >> 8) & 0xFF);
			ExifInfo.Camversion[2] = ((cam_ver >> 16) & 0xFF);
			ExifInfo.Camversion[3] = ((cam_ver >> 24) & 0xFF);
			HAL_PRINT("CreateExif GetCamera_version =[%x][%x][%x][%x]\n", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]);	

			sprintf((char *)&ExifInfo.software, "fw %02d.%02d prm %02d.%02d", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]); 	
			if(mThumbnailWidth > 0 && mThumbnailHeight > 0)
			{
				ExifInfo.hasThumbnail = true;
				ExifInfo.thumbStream			= pInThumbnailData;
				ExifInfo.thumbSize				= Inthumbsize;
				ExifInfo.thumbImageWidth		= mThumbnailWidth;
				ExifInfo.thumbImageHeight		= mThumbnailHeight;
			}
			else
			{
				ExifInfo.hasThumbnail = false;
			}

			ExifInfo.exposureProgram            = 3;
			ExifInfo.exposureMode               = 0;
			ExifInfo.contrast                   = convertToExifLMH(getContrast(), 2);
			ExifInfo.fNumber.numerator          = 26;
			ExifInfo.fNumber.denominator        = 10;
			ExifInfo.aperture.numerator         = 26;
			ExifInfo.aperture.denominator       = 10;
			ExifInfo.maxAperture.numerator      = 26;
			ExifInfo.maxAperture.denominator    = 10;
			ExifInfo.focalLength.numerator      = 3430;
			ExifInfo.focalLength.denominator    = 1000;
			//[ 2010 05 01 exif
			ExifInfo.shutterSpeed.numerator 	= exifobj.TV_Value;
			ExifInfo.shutterSpeed.denominator   = 100;
			ExifInfo.exposureTime.numerator     = 1;
			ExifInfo.exposureTime.denominator   = (unsigned int)pow(2.0, ((double)exifobj.TV_Value/100.0));
			//]
			ExifInfo.brightness.numerator       = 5;
			ExifInfo.brightness.denominator     = 9;
			ExifInfo.iso                        = 1;
			ExifInfo.flash                     	= 0;	// default value

			// Flash
			// bit 0    -whether the flash fired
			// bit 1,2 -status of returned light
			// bit 3,4 - indicating the camera's flash mode
			// bit 5    -presence of a flash function
			// bit 6    - red-eye mode

			// refer to flash_mode[] at CameraHal.cpp
			// off = 1
			// on = 2
			// auto = 3


			// Todo : Need to implement how HAL can recognize existance of flash
			//		if( ! isFlashExist )	// pseudo code
			//			ExifInfo.flash = 32;		// bit 5 - No flash function.
			//		else
			{
				LOGD("createExif - flashmode = %d flash result = %d", mPreviousFlashMode, ExifInfo.flash);

				// bit 0
				ExifInfo.flash = ExifInfo.flash | exifobj.flash;
				// bit 3,4
				if(mPreviousFlashMode == 3)	// Flashmode auto
					ExifInfo.flash = ExifInfo.flash |24;
				// bit 6
				// Todo : Need to implement about red-eye			
				//			if(mPreviousFlashMode == ??)	// Flashmode red-eye
				//				ExifInfo.flash = ExifInfo.flash | 64;						
			}

			HAL_PRINT("Main Orientation = %d\n",orientationValue);
			switch(orientationValue)
			{            		
				case 0:
					ExifInfo.orientation                = 1 ;
					break;
				case 90:
					ExifInfo.orientation                = 6 ;
					break;
				case 180:
					ExifInfo.orientation                = 3 ;
					break;
				case 270:
					ExifInfo.orientation                = 8 ;
					break;
				default:
					ExifInfo.orientation                = 1 ;
					break;
			}
			//[ 2010 05 01 exif
			double calIsoValue = 0;
			calIsoValue = pow(2.0,((double)exifobj.SV_Value/100.0))*3.125;
			//]
			if(calIsoValue < 8.909)
			{
				tempISO = 0;
			}
			else if(calIsoValue >=8.909 && calIsoValue < 11.22)
			{
				tempISO = 10;
			}
			else if(calIsoValue >=11.22 && calIsoValue < 14.14)
			{
				tempISO = 12;
			}
			else if(calIsoValue >=14.14 && calIsoValue < 17.82)
			{
				tempISO = 16;
			}
			else if(calIsoValue >=17.82 && calIsoValue < 22.45)
			{
				tempISO = 20;
			}
			else if(calIsoValue >=22.45 && calIsoValue < 28.28)
			{
				tempISO = 25;
			}
			else if(calIsoValue >=28.28 && calIsoValue < 35.64)
			{
				tempISO = 32;
			}
			else if(calIsoValue >=35.64 && calIsoValue < 44.90)
			{
				tempISO = 40;
			}
			else if(calIsoValue >=44.90 && calIsoValue < 56.57)
			{
				tempISO = 50;
			}
			else if(calIsoValue >=56.57 && calIsoValue < 71.27)
			{
				tempISO = 64;
			}
			else if(calIsoValue >=71.27 && calIsoValue < 89.09)
			{
				tempISO = 80;
			}
			else if(calIsoValue >=89.09 && calIsoValue < 112.2)
			{
				tempISO = 100;
			}
			else if(calIsoValue >=112.2 && calIsoValue < 141.4)
			{
				tempISO = 125;
			}
			else if(calIsoValue >=141.4 && calIsoValue < 178.2)
			{
				tempISO = 160;
			}
			else if(calIsoValue >=178.2 && calIsoValue < 224.5)
			{
				tempISO = 200;
			}
			else if(calIsoValue >=224.5 && calIsoValue < 282.8)
			{
				tempISO = 250;
			}
			else if(calIsoValue >=282.8 && calIsoValue < 356.4)
			{
				tempISO = 320;
			}
			else if(calIsoValue >=356.4 && calIsoValue < 449.0)
			{
				tempISO = 400;
			}
			else if(calIsoValue >=449.0 && calIsoValue < 565.7)
			{
				tempISO = 500;
			}
			else if(calIsoValue >=565.7 && calIsoValue < 712.7)
			{
				tempISO = 640;
			}
			else if(calIsoValue >=712.7 && calIsoValue < 890.9)
			{
				tempISO = 800;
			}
			else if(calIsoValue >=890.9 && calIsoValue < 1122)
			{
				tempISO = 1000;
			}
			else if(calIsoValue >=1122 && calIsoValue < 1414)
			{
				tempISO = 1250;
			}
			else if(calIsoValue >=1414 && calIsoValue < 1782)
			{
				tempISO = 160;
			}
			else if(calIsoValue >=1782 && calIsoValue < 2245)
			{
				tempISO = 2000;
			}
			else if(calIsoValue >=2245 && calIsoValue < 2828)
			{
				tempISO = 2500;
			}
			else if(calIsoValue >=2828 && calIsoValue < 3564)
			{
				tempISO = 3200;
			}
			else if(calIsoValue >=3564 && calIsoValue < 4490)
			{
				tempISO = 4000;
			}
			else if(calIsoValue >=4490 && calIsoValue < 5657)
			{
				tempISO = 5000;
			}
			else if(calIsoValue >=5657 && calIsoValue < 7127)
			{
				tempISO = 6400;
			}
			else
			{
				tempISO = 8000;
			}

			if(mPreviousSceneMode <= 1)
			{
				ExifInfo.meteringMode               = mPreviousMetering;
				if(mPreviousWB <= 1)
				{
					ExifInfo.whiteBalance               = 0;
				}
				else
				{
					ExifInfo.whiteBalance               = 1;
				}
				ExifInfo.saturation                 = convertToExifLMH(getSaturation(), 2);
				ExifInfo.sharpness                  = convertToExifLMH(getSharpness(), 2);
				switch(mPreviousISO)
				{
					case 2:
						ExifInfo.isoSpeedRating             = 50;
						break;
					case 3:
						ExifInfo.isoSpeedRating             = 100;
						break;
					case 4:
						ExifInfo.isoSpeedRating             = 200;
						break;
					case 5:
						ExifInfo.isoSpeedRating             = 400;
						break;
					case 6:
						ExifInfo.isoSpeedRating             = 800;
						break;
					default:
						ExifInfo.isoSpeedRating             = tempISO;
						break;
				}                

				switch(getBrightness())
				{
					case 0:
						ExifInfo.exposureBias.numerator = -20;
						break;
					case 1:
						ExifInfo.exposureBias.numerator = -15;
						break;
					case 2:
						ExifInfo.exposureBias.numerator = -10;
						break;
					case 3:
						ExifInfo.exposureBias.numerator =  -5;
						break;
					case 4:
						ExifInfo.exposureBias.numerator =   0;
						break;
					case 5:
						ExifInfo.exposureBias.numerator =   5;
						break;
					case 6:
						ExifInfo.exposureBias.numerator =  10;
						break;
					case 7:
						ExifInfo.exposureBias.numerator =  15;
						break;
					case 8:
						ExifInfo.exposureBias.numerator =  20;
						break;
					default:
						ExifInfo.exposureBias.numerator = 0;
						break;
				}
				ExifInfo.exposureBias.denominator       = 10;
				ExifInfo.sceneCaptureType               = 0;
			}
			else
			{
				switch(mPreviousSceneMode)
				{
					case 3://sunset
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 1;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 4://dawn
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 1;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 5://candlelight
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 1;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 6://beach & snow
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 2;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = 50;
						ExifInfo.exposureBias.numerator     = 10;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 1;
						break;
					case 7://againstlight
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						if(mPreviousFlashMode <= 1)
						{
							ExifInfo.meteringMode               = 3;
						}
						else
						{
							ExifInfo.meteringMode               = 2;
						}
						ExifInfo.exposureBias.numerator 	= 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 8://text
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 2;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 9://night
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 3;
						break;	
					case 10://landscape
						ExifInfo.meteringMode               = 5;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 2;
						ExifInfo.sharpness                  = 2;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 1;
						break;
					case 11://fireworks
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = 50;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 12://portrait
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 1;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 2;
						break;
					case 13://fallcolor
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 2;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 14://indoors
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 2;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = 200;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
					case 15://sports
						ExifInfo.meteringMode               = 2;
						ExifInfo.whiteBalance               = 0;
						ExifInfo.saturation                 = 0;
						ExifInfo.sharpness                  = 0;
						ExifInfo.isoSpeedRating             = tempISO;
						ExifInfo.exposureBias.numerator     = 0;
						ExifInfo.exposureBias.denominator   = 10;
						ExifInfo.sceneCaptureType           = 4;
						break;
				}
			}
		}
Пример #2
0
	//[20091123 exif Ratnesh
	void CameraHal::CreateExif(unsigned char* pInThumbnailData, int Inthumbsize,
		unsigned char* pOutExifBuf, int& OutExifSize, int flag)
	{
		//                                0   90  180 270 360
		const int MAIN_ORIENTATION[]  = { 1,  6,  3,  8,  1};
		const int FRONT_ORIENTATION[] = { 3,  6,  1,  8,  3};
			
		ExifCreator* mExifCreator = new ExifCreator();
		unsigned int ExifSize = 0;
		ExifInfoStructure ExifInfo;
		char ver_date[5] = {NULL,};
		unsigned short tempISO = 0;
		struct v4l2_exif exifobj;
		
		int orientationValue = getOrientation();
		LOGV("CreateExif orientationValue = %d \n", orientationValue);	

		memset(&ExifInfo, NULL, sizeof(ExifInfoStructure));

		strcpy( (char *)&ExifInfo.maker, "SAMSUNG");
		
		mParameters.getPictureSize((int*)&ExifInfo.imageWidth , (int*)&ExifInfo.imageHeight);
		mParameters.getPictureSize((int*)&ExifInfo.pixelXDimension, (int*)&ExifInfo.pixelYDimension);

		struct tm *t = NULL;
		time_t nTime;
		time(&nTime);
		t = localtime(&nTime);

		if(t != NULL)
		{
			sprintf((char *)&ExifInfo.dateTimeOriginal, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
			sprintf((char *)&ExifInfo.dateTimeDigitized, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);						
			sprintf((char *)&ExifInfo.dateTime, "%4d:%02d:%02d %02d:%02d:%02d", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); 					
		}
				
		if(mCameraIndex==MAIN_CAMERA)
		{
			if(orientationValue<=360)
				ExifInfo.orientation = MAIN_ORIENTATION[orientationValue/90];
			else
				ExifInfo.orientation = 0;
			
			getExifInfoFromDriver(&exifobj);
			strcpy( (char *)&ExifInfo.model, "GT-I8320 M4MO");
			int cam_ver = GetCamera_version();
			ExifInfo.Camversion[0] = (cam_ver & 0xFF);
			ExifInfo.Camversion[1] = ((cam_ver >> 8) & 0xFF);
			//HAL_PRINT("CreateExif GetCamera_version =[%x][%x][%x][%x]\n", ExifInfo.Camversion[2],ExifInfo.Camversion[3],ExifInfo.Camversion[0],ExifInfo.Camversion[1]);	
			sprintf((char *)&ExifInfo.software, "%02X%02X", ExifInfo.Camversion[1], ExifInfo.Camversion[0]); 	
// TODO: get thumbnail offset of m4mo jpeg data
			// if(mThumbnailWidth > 0 && mThumbnailHeight > 0)
			// {
				// ExifInfo.hasThumbnail = true;
				// ExifInfo.thumbStream			= pInThumbnailData;
				// ExifInfo.thumbSize				= Inthumbsize;
				// ExifInfo.thumbImageWidth		= mThumbnailWidth;
				// ExifInfo.thumbImageHeight		= mThumbnailHeight;
			// }
			// else
			{
				ExifInfo.hasThumbnail = false;
			}

			ExifInfo.exposureProgram            = 3;
			ExifInfo.exposureMode               = 0;
			ExifInfo.contrast                   = convertToExifLMH(getContrast(), 2);
			ExifInfo.fNumber.numerator          = 26;
			ExifInfo.fNumber.denominator        = 10;
			ExifInfo.aperture.numerator         = 26;
			ExifInfo.aperture.denominator       = 10;
			ExifInfo.maxAperture.numerator      = 26;
			ExifInfo.maxAperture.denominator    = 10;
			ExifInfo.focalLength.numerator      = 4610;
			ExifInfo.focalLength.denominator    = 1000;
			//[ 2010 05 01 exif
			ExifInfo.shutterSpeed.numerator 	= exifobj.shutter_speed_numerator;
			ExifInfo.shutterSpeed.denominator   = exifobj.shutter_speed_denominator;
			ExifInfo.exposureTime.numerator     = exifobj.exposure_time_numerator;
			ExifInfo.exposureTime.denominator   = exifobj.exposure_time_denominator;
			//]
			ExifInfo.brightness.numerator       = exifobj.brigtness_numerator;
			ExifInfo.brightness.denominator     = exifobj.brightness_denominator;
			ExifInfo.iso                        = 1;
			ExifInfo.isoSpeedRating             = roundIso(exifobj.iso);
			// Flash
			// bit 0    -whether the flash fired
			// bit 1,2 -status of returned light
			// bit 3,4 - indicating the camera's flash mode
			// bit 5    -presence of a flash function
			// bit 6    - red-eye mode

			// refer to flash_mode[] at CameraHal.cpp
			// off = 1
			// on = 2
			// auto = 3
			ExifInfo.flash  					= exifobj.flash 
												| (mPreviousFlashMode == 3)?(3<<4):0;	// default value
			
			ExifInfo.whiteBalance               = (mPreviousWB <= 1)?0:1;
			ExifInfo.meteringMode               = mPreviousMetering;
			ExifInfo.saturation                 = convertToExifLMH(getSaturation(), 2);
			ExifInfo.sharpness                  = convertToExifLMH(getSharpness(), 2);  
			ExifInfo.exposureBias.numerator 	= (getBrightness()-4)*5;
			ExifInfo.exposureBias.denominator   = 10;
			ExifInfo.sceneCaptureType           = mPreviousSceneMode;
		
			// ExifInfo.meteringMode               = 2;
			// ExifInfo.whiteBalance               = 1;
			// ExifInfo.saturation                 = 0;
			// ExifInfo.sharpness                  = 0;
			// ExifInfo.isoSpeedRating             = tempISO;
			// ExifInfo.exposureBias.numerator     = 0;
			// ExifInfo.exposureBias.denominator   = 10;
			// ExifInfo.sceneCaptureType           = 4;
		}
		
		else // VGA Camera
		{	
			if(orientationValue<=360)