-rw-r--r-- | v3/Android.mk | 10 | ||||
-rw-r--r-- | v3/EmulatedFakeCamera3.cpp | 29 | ||||
-rw-r--r-- | v3/EmulatedFakeCamera3.h | 4 | ||||
-rw-r--r-- | v3/LoadXml.cpp | 208 | ||||
-rw-r--r-- | v3/LoadXml.h | 48 | ||||
-rw-r--r--[-rwxr-xr-x] | v3/QemuClient.h | 2 | ||||
-rw-r--r-- | v3/fake-pipeline2/JpegCompressor.cpp | 328 | ||||
-rw-r--r-- | v3/fake-pipeline2/JpegCompressor.h | 53 | ||||
-rw-r--r-- | v3/fake-pipeline2/Sensor.cpp | 93 | ||||
-rw-r--r-- | v3/inc/qemu_pipe.h | 94 | ||||
-rw-r--r-- | v3/inc/qemud.h | 153 |
11 files changed, 362 insertions, 660 deletions
diff --git a/v3/fake-pipeline2/JpegCompressor.cpp b/v3/fake-pipeline2/JpegCompressor.cpp index 6a24882..2ef5c8b 100644 --- a/v3/fake-pipeline2/JpegCompressor.cpp +++ b/v3/fake-pipeline2/JpegCompressor.cpp @@ -220,54 +220,6 @@ status_t JpegCompressor::readyToRun() { return OK; } -status_t JpegCompressor::Create_Exif_Use_Libjpeg() { - ExifElementsTable* exiftable = NULL; - struct camera2_jpeg_blob blob; - int offset; - status_t res; - if (mNeedexif) { - memset(&blob,0,sizeof(struct camera2_jpeg_blob)); - exiftable = new ExifElementsTable(); - GenExif(exiftable); - } - - if (mJpegRequest.mNeedThumbnail) { - res = thumbcompress(); - } - - if (exiftable) { - uint32_t realjpegsize = 0; - Section_t* exif_section = NULL; - ExifElementsTable* exif = exiftable; - exif->insertExifToJpeg((unsigned char*)mJpegBuffer.img,mMainJpegSize); - if ((mJpegRequest.mNeedThumbnail) && (mDstThumbBuffer != NULL)) { - exif->insertExifThumbnailImage((const char*)mDstThumbBuffer,mThumbJpegSize); - } - exif_section = FindSection(M_EXIF); - if (exif_section) { - exif->saveJpeg((unsigned char*) mJpegBuffer.img, mMainJpegSize + exif_section->Size); - } - for (uint32_t size = (mMainJpegSize + exif_section->Size - 2); size > 0; size--) { - if (checkJpegEnd(mJpegBuffer.img + size)) { - realjpegsize = (size + MARKER_LENGTH); - break; - } - } - offset = mMaxbufsize-sizeof(struct camera2_jpeg_blob); - blob.jpeg_blob_id = 0x00FF; - blob.jpeg_size = realjpegsize; - memcpy(mJpegBuffer.img+offset, &blob, sizeof(struct camera2_jpeg_blob)); - } - - if (mNeedexif) { - if (exiftable != NULL) { - delete exiftable; - exiftable = NULL; - } - } - return res; -} - status_t JpegCompressor::Create_Exif_Use_Libexif() { struct camera2_jpeg_blob blob; int offset; @@ -449,11 +401,7 @@ bool JpegCompressor::threadLoop() { res = compress(); -#if PLATFORM_SDK_VERSION <= 22 - Create_Exif_Use_Libjpeg(); -#else Create_Exif_Use_Libexif(); -#endif mListener->onJpegDone(mJpegBuffer, res == OK, mJpegRequest); @@ -939,166 +887,6 @@ void JpegCompressor::SetExifInfo(struct ExifInfo info) { memcpy(&mInfo, &info, sizeof(struct ExifInfo)); } -int JpegCompressor::GenExif(ExifElementsTable* exiftable) -{ - char exifcontent[256]; - int width,height; - bool newexif = true; //add new exif tag for cts - float exposuretime = 1.0; - float ApertureValue = 1.0; - int flash = 0; - int whitebalance = 1; - int iso = 100; - char SubSecTime[10] = "63"; - char SubSecTimeOrig[10]= "63"; - char SubSecTimeDig[10]= "63"; - char property[PROPERTY_VALUE_MAX]; - - property_get("ro.product.manufacturer", property, EXIF_MAKE_DEFAULT); - exiftable->insertElement("Make",property); - property_get("ro.product.model", property, EXIF_MODEL_DEFAULT); - exiftable->insertElement("Model",property); -// int orientation = mInfo.orientation; - width = mInfo.mainwidth; - height = mInfo.mainheight; -#if 0 - if (orientation == 0) - orientation = 1; - else if (orientation == 90) - orientation = 6; - else if (orientation == 180) - orientation = 3; - else if (orientation == 270) - orientation = 8; - sprintf(exifcontent,"%d",orientation); - exiftable->insertElement("Orientation",(const char*)exifcontent); -#endif - sprintf(exifcontent,"%d",width); - exiftable->insertElement("ImageWidth",(const char*)exifcontent); - sprintf(exifcontent,"%d",height); - exiftable->insertElement("ImageLength",(const char*)exifcontent); - - sprintf(exifcontent,"%f",exposuretime); - exiftable->insertElement("ExposureTime",(const char*)exifcontent); - sprintf(exifcontent,"%f",ApertureValue); - exiftable->insertElement("ApertureValue",(const char*)exifcontent); - sprintf(exifcontent,"%d",flash); - exiftable->insertElement("Flash",(const char*)exifcontent); - sprintf(exifcontent,"%d",whitebalance); - exiftable->insertElement("WhiteBalance",(const char*)exifcontent); - sprintf(exifcontent,"%d",iso); - exiftable->insertElement("ISOSpeedRatings",(const char*)exifcontent); - if (newexif) { - time_t times; - { - time(×); - struct tm tmstruct; - tmstruct = *(localtime(×)); //convert to local time - strftime(exifcontent, 30, "%Y:%m:%d %H:%M:%S", &tmstruct); - exiftable->insertElement("DateTimeDigitized",(const char*)exifcontent); - } - { - sprintf(exifcontent, "%s", SubSecTime); - exiftable->insertElement("SubSecTime",(const char*)exifcontent); - } - { - - sprintf(exifcontent, "%s", SubSecTimeOrig); - exiftable->insertElement("SubSecTimeOriginal",(const char*)exifcontent); - } - { - - sprintf(exifcontent, "%s", SubSecTimeDig); - exiftable->insertElement("SubSecTimeDigitized",(const char*)exifcontent); - } - } - - if (mInfo.has_focallen) { - float focallen = mInfo.focallen; - if (focallen >= 0) { - int focalNum = focallen*1000; - int focalDen = 1000; - sprintf(exifcontent,"%d/%d",focalNum,focalDen); - exiftable->insertElement("FocalLength",(const char*)exifcontent); - } - } - time_t times; - { - time(×); - struct tm tmstruct; - tmstruct = *(localtime(×)); //convert to local time - strftime(exifcontent, 30, "%Y:%m:%d %H:%M:%S", &tmstruct); - exiftable->insertElement("DateTime",(const char*)exifcontent); - } - if (mInfo.has_gpsTimestamp) { - times = mInfo.gpsTimestamp; - if (times != -1) { - struct tm tmstruct; - tmstruct = *(gmtime(×));//convert to standard time - strftime(exifcontent, 20, "%Y:%m:%d", &tmstruct); - exiftable->insertElement("GPSDateStamp",(const char*)exifcontent); - sprintf(exifcontent,"%d/%d,%d/%d,%d/%d",tmstruct.tm_hour,1,tmstruct.tm_min,1,tmstruct.tm_sec,1); - exiftable->insertElement("GPSTimeStamp",(const char*)exifcontent); - } - } - if (mInfo.has_latitude) { - int offset = 0; - float latitude = mInfo.latitude; - if (latitude < 0.0) { - offset = 1; - latitude*= (float)(-1); - } - int latitudedegree = latitude; - float latitudeminuts = (latitude-(float)latitudedegree)*60; - int latitudeminuts_int = latitudeminuts; - float latituseconds = (latitudeminuts-(float)latitudeminuts_int)*60+0.5; - int latituseconds_int = latituseconds; - sprintf(exifcontent,"%d/%d,%d/%d,%d/%d",latitudedegree,1,latitudeminuts_int,1,latituseconds_int,1); - exiftable->insertElement("GPSLatitude",(const char*)exifcontent); - exiftable->insertElement("GPSLatitudeRef",(offset==1)?"S":"N"); - } - if (mInfo.has_longitude) { - int offset = 0; - float longitude = mInfo.longitude; - if (longitude < 0.0) { - offset = 1; - longitude*= (float)(-1); - } - int longitudedegree = longitude; - float longitudeminuts = (longitude-(float)longitudedegree)*60; - int longitudeminuts_int = longitudeminuts; - float longitudeseconds = (longitudeminuts-(float)longitudeminuts_int)*60+0.5; - int longitudeseconds_int = longitudeseconds; - sprintf(exifcontent,"%d/%d,%d/%d,%d/%d",longitudedegree,1,longitudeminuts_int,1,longitudeseconds_int,1); - exiftable->insertElement("GPSLongitude",(const char*)exifcontent); - exiftable->insertElement("GPSLongitudeRef",(offset==1)?"S":"N"); - } - if (mInfo.has_altitude) { - int offset = 0; - float altitude = mInfo.altitude; - if (altitude < 0.0) { - offset = 1; - altitude*= (float)(-1); - } - int altitudenum = altitude*1000; - int altitudedec= 1000; - sprintf(exifcontent,"%d/%d",altitudenum,altitudedec); - exiftable->insertElement("GPSAltitude",(const char*)exifcontent); - sprintf(exifcontent,"%d",offset); - exiftable->insertElement("GPSAltitudeRef",(const char*)exifcontent); - } - if (mInfo.has_gpsProcessingMethod) { - char* processmethod = (char*)mInfo.gpsProcessingMethod; - if (processmethod != NULL) { - memset(exifcontent,0,sizeof(exifcontent)); - char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 };//asicii - memcpy(exifcontent,ExifAsciiPrefix,8); - memcpy(exifcontent+8,processmethod,strlen(processmethod)); - exiftable->insertElement("GPSProcessingMethod",(const char*)exifcontent); - } - } - return 1; -} void JpegCompressor::exif_entry_set_string (ExifData * pEdata, ExifIfd eEifd, ExifTag eEtag, const char *s) { @@ -1567,120 +1355,4 @@ EXIT: return NULL; } -const char* ExifElementsTable::degreesToExifOrientation(const char* degrees) { - for (unsigned int i = 0; i < ARRAY_SIZE(degress_to_exif_lut); i++) { - if (!strcmp(degrees, degress_to_exif_lut[i].string1)) { - return degress_to_exif_lut[i].string2; - } - } - return NULL; -} -void ExifElementsTable::stringToRational(const char* str, unsigned int* num, unsigned int* den) { - int len; - char * tempVal = NULL; - if (str != NULL) { - len = strlen(str); - tempVal = (char*) malloc( sizeof(char) * (len + 1)); - } - if (tempVal != NULL) { - size_t den_len; - char *ctx; - unsigned int numerator = 0; - unsigned int denominator = 0; - char* temp = NULL; - memset(tempVal, '\0', len + 1); - strncpy(tempVal, str, len); - temp = strtok_r(tempVal, ".", &ctx); - if (temp != NULL) - numerator = atoi(temp); - if (!numerator) - numerator = 1; - temp = strtok_r(NULL, ".", &ctx); - if (temp != NULL) { - den_len = strlen(temp); - if(HUGE_VAL == den_len ) { - den_len = 0; - } - denominator = static_cast<unsigned int>(pow(10, den_len)); - numerator = numerator * denominator + atoi(temp); - } else { - denominator = 1; - } - free(tempVal); - *num = numerator; - *den = denominator; - } -} -bool ExifElementsTable::isAsciiTag(const char* tag) { - return (strcmp(tag, TAG_GPS_PROCESSING_METHOD) == 0); -} -status_t ExifElementsTable::insertElement(const char* tag, const char* value) { - int value_length = 0; - status_t ret = NO_ERROR; - if (!value || !tag) { - return -EINVAL; - } - if (position >= MAX_EXIF_TAGS_SUPPORTED) { - CAMHAL_LOGEA("Max number of EXIF elements already inserted"); - return NO_MEMORY; - } - if (isAsciiTag(tag)) { - value_length = sizeof(ExifAsciiPrefix) + strlen(value + sizeof(ExifAsciiPrefix)); - } else { - value_length = strlen(value); - } - if (IsGpsTag(tag)) { - table[position].GpsTag = TRUE; - table[position].Tag = GpsTagNameToValue(tag); - gps_tag_count++; - } else { - table[position].GpsTag = FALSE; - table[position].Tag = TagNameToValue(tag); - exif_tag_count++; - } - table[position].DataLength = 0; - table[position].Value = (char*) malloc(sizeof(char) * (value_length + 1)); - if (table[position].Value) { - memcpy(table[position].Value, value, value_length + 1); - table[position].DataLength = value_length + 1; - } - position++; - return ret; -} -void ExifElementsTable::saveJpeg(unsigned char* jpeg, size_t jpeg_size) { - int ret; - if (jpeg_opened) { - ret = WriteJpegToBuffer(jpeg, jpeg_size); - ALOGD("saveJpeg :: ret =%d",ret); - DiscardData(); - jpeg_opened = false; - } -} -void ExifElementsTable::insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size) { - ReadMode_t read_mode = (ReadMode_t)(READ_METADATA | READ_IMAGE); - ResetJpgfile(); - if (ReadJpegSectionsFromBuffer(jpeg, jpeg_size, read_mode)) { - jpeg_opened = true; - create_EXIF(table, exif_tag_count, gps_tag_count,true); - } -} -status_t ExifElementsTable::insertExifThumbnailImage(const char* thumb, int len) { - status_t ret = NO_ERROR; - if ((len > 0) && jpeg_opened) { - ret = ReplaceThumbnailFromBuffer(thumb, len); - CAMHAL_LOGDB("insertExifThumbnailImage. ReplaceThumbnail(). ret=%d", ret); - } - return ret; -} -ExifElementsTable::~ExifElementsTable() { - int num_elements = gps_tag_count + exif_tag_count; - for (int i = 0; i < num_elements; i++) { - if (table[i].Value) { - free(table[i].Value); - } - } - if (jpeg_opened) { - DiscardData(); - } -} } // namespace android |