diff --git a/libcamera/QualcommCameraHardware.cpp b/libcamera/QualcommCameraHardware.cpp index 58eda93..45ca727 100644 --- a/libcamera/QualcommCameraHardware.cpp +++ b/libcamera/QualcommCameraHardware.cpp @@ -14,7 +14,6 @@ ** limitations under the License. */ -//#define LOG_NDEBUG 0 #define LOG_TAG "QualcommCameraHardware" #include @@ -32,8 +31,6 @@ #include #include "raw2jpeg.h" -// #define iLog(fmt, args...) LOGD(fmt, ##args) - #define LIKELY(exp) __builtin_expect(!!(exp), 1) #define UNLIKELY(exp) __builtin_expect(!!(exp), 0) @@ -579,7 +576,7 @@ static bool native_stop_preview(int camfd) strerror(errno)); return false; } - LOGV("Kalim: Finalizado Start_preview XXXXXXXXXXXXXXXXXXXXXX"); + LOGV("Kalim: Finalizado Stop_preview XXXXXXXXXXXXXXXXXXXXXX"); return true; } @@ -622,13 +619,13 @@ static bool native_stop_snapshot (int camfd) void *jpeg_encoder_thread( void *user ) { - LOGD("jpeg_encoder_thread E"); + LOGV("jpeg_encoder_thread E"); sp obj = QualcommCameraHardware::getInstance(); if (obj != 0) { obj->runJpegEncodeThread(user); } else LOGW("not starting frame thread: the object went away!"); - LOGD("jpeg_encoder_thread X"); + LOGV("jpeg_encoder_thread X"); return NULL; } @@ -721,10 +718,10 @@ void QualcommCameraHardware::jpeg_set_location() bool encode_location = true; camera_position_type pt; -#define PARSE_LOCATION(what,type,fmt,desc) do { \ + #define PARSE_LOCATION(what,type,fmt,desc) do { \ pt.what = 0; \ const char *what##_str = mParameters.get("gps-"#what); \ - LOGV("GPS PARM %s --> [%s]", "gps-"#what, what##_str); \ + LOGV("GPS PARM %s --> [%s]", "gps-"#what, what##_str); \ if (what##_str) { \ type what = 0; \ if (sscanf(what##_str, fmt, &what) == 1) \ @@ -736,7 +733,7 @@ void QualcommCameraHardware::jpeg_set_location() } \ } \ else { \ - LOGV("GPS " #what " not specified: " \ + LOGV("GPS " #what " not specified: " \ "defaulting to zero in EXIF header."); \ encode_location = false; \ } \ @@ -748,7 +745,7 @@ void QualcommCameraHardware::jpeg_set_location() PARSE_LOCATION(latitude, double, "%lf", "double float"); PARSE_LOCATION(longitude, double, "%lf", "double float"); -#undef PARSE_LOCATION + #undef PARSE_LOCATION if (encode_location) { LOGD("setting image location ALT %d LAT %lf LON %lf", @@ -767,22 +764,22 @@ void QualcommCameraHardware::runFrameThread(void *data) // lifetime of this object. We do not want to dlclose() libmmcamera while // LINK_cam_frame is still running. void *libhandle = ::dlopen("libmmcamera.so", RTLD_NOW); - LOGV("FRAME: loading libmmcamera at %p", libhandle); + LOGD("FRAME: loading libmmcamera at %p", libhandle); if (!libhandle) { LOGE("FATAL ERROR: could not dlopen libmmcamera.so: %s", dlerror()); } if (libhandle) #endif { - LOGV("Before LINK_cam_frame"); + LOGD("Before LINK_cam_frame"); LINK_cam_frame(data); - LOGV("After LINK_cam_frame"); + LOGD("After LINK_cam_frame"); } #if DLOPEN_LIBMMCAMERA if (libhandle) { ::dlclose(libhandle); - LOGV("FRAME: dlclose(libmmcamera)"); + LOGD("FRAME: dlclose(libmmcamera)"); } #endif @@ -798,35 +795,32 @@ void QualcommCameraHardware::runJpegEncodeThread(void *data) { unsigned char *buffer ; -// readFromMemory( (unsigned char *)mRawHeap->mHeap->base(), 2097152, buffer ) ; -// writeToMemory( buffer, 2560, 1920, (unsigned char *)mJpegHeap->mHeap->base(), (int *)&mJpegSize ) ; - int rotation = mParameters.getInt("rotation"); LOGD("native_jpeg_encode, rotation = %d", rotation); bool encode_location = true; camera_position_type pt; - #define PARSE_LOCATION(what,type,fmt,desc) do { \ - pt.what = 0; \ - const char *what##_str = mParameters.get("gps-"#what); \ - LOGD("GPS PARM %s --> [%s]", "gps-"#what, what##_str); \ - if (what##_str) { \ - type what = 0; \ - if (sscanf(what##_str, fmt, &what) == 1) \ - pt.what = what; \ - else { \ - LOGE("GPS " #what " %s could not" \ - " be parsed as a " #desc, what##_str); \ - encode_location = false; \ - } \ - } \ - else { \ - LOGD("GPS " #what " not specified: " \ - "defaulting to zero in EXIF header."); \ - encode_location = false; \ - } \ - } while(0) + #define PARSE_LOCATION(what,type,fmt,desc) do { \ + pt.what = 0; \ + const char *what##_str = mParameters.get("gps-"#what); \ + LOGD("GPS PARM %s --> [%s]", "gps-"#what, what##_str); \ + if (what##_str) { \ + type what = 0; \ + if (sscanf(what##_str, fmt, &what) == 1) \ + pt.what = what; \ + else { \ + LOGE("GPS " #what " %s could not" \ + " be parsed as a " #desc, what##_str); \ + encode_location = false; \ + } \ + } \ + else { \ + LOGD("GPS " #what " not specified: " \ + "defaulting to zero in EXIF header."); \ + encode_location = false; \ + } \ + } while(0) PARSE_LOCATION(timestamp, long, "%ld", "long"); if (!pt.timestamp) pt.timestamp = time(NULL); @@ -834,14 +828,14 @@ void QualcommCameraHardware::runJpegEncodeThread(void *data) PARSE_LOCATION(latitude, double, "%lf", "double float"); PARSE_LOCATION(longitude, double, "%lf", "double float"); - #undef PARSE_LOCATION + #undef PARSE_LOCATION if (encode_location) { LOGD("setting image location ALT %d LAT %lf LON %lf", pt.altitude, pt.latitude, pt.longitude); } else { - LOGV("not setting image location"); + LOGD("not setting image location"); } @@ -852,8 +846,6 @@ void QualcommCameraHardware::runJpegEncodeThread(void *data) npt = NULL ; } - // writeExif( mRawHeap->mHeap->base(), mJpegHeap->mHeap->base(), mJpegSize, &mJpegSize, rotation , npt ); - int jpeg_quality = mParameters.getInt("jpeg-quality"); LOGD("Kalim: Inicio conversion a JPEG ----------------------------------------------------------------------------------------------"); @@ -861,10 +853,12 @@ void QualcommCameraHardware::runJpegEncodeThread(void *data) LOGD("KalimochoAz jpeg convert, current jpeg main img Height =%d", mRawHeight); LOGD("KalimochoAz jpeg convert, current jpeg main img Width =%d", mRawWidth); if( yuv420_save2jpeg((unsigned char*) mJpegHeap->mHeap->base(), mRawHeap->mHeap->base(), mRawWidth, mRawHeight, jpeg_quality, &mJpegSize) ) - LOGV("Kalim: JpegConvetida Correctamente ***********************************************************************************************************"); + LOGD("Kalim: JpegConvetida Correctamente ***********************************************************************************************************"); else - LOGV("Kalim: Fallo de conversion a JPEG xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); - LOGD("KalimochoAz jpeg convert, current jpeg main img jpegSize =%d ........", mJpegSize); + LOGE("Kalim: Fallo de conversion a JPEG xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + + writeExif( mJpegHeap->mHeap->base(), mJpegHeap->mHeap->base(), mJpegSize, &mJpegSize, rotation , npt ); + LOGD("KalimochoAz jpeg convert, current jpeg main img jpegSize=%d ........", mJpegSize); receiveJpegPicture(); } @@ -873,10 +867,10 @@ void *frame_thread(void *user) { LOGV("frame_thread E"); sp obj = QualcommCameraHardware::getInstance(); -// if (obj != 0) { -// obj->runFrameThread(user); -// } -// else LOGW("not starting frame thread: the object went away!"); + if (obj != 0) { + obj->runFrameThread(user); + } + else LOGE("not starting frame thread: the object went away!"); LOGV("frame_thread X"); return NULL; } @@ -888,13 +882,11 @@ bool QualcommCameraHardware::initPreview() LOGV("initPreview E: preview size=%dx%d", mPreviewWidth, mPreviewHeight); mFrameThreadWaitLock.lock(); - // Kalim FAKE ------------------------ ( si lo elimino no grabamos la foto ) mFrameThreadRunning = false; - // ----------------------------------- while (mFrameThreadRunning) { - LOGV("initPreview: waiting for old frame thread to complete."); + LOGD("initPreview: waiting for old frame thread to complete."); mFrameThreadWait.wait(mFrameThreadWaitLock); - LOGV("initPreview: old frame thread completed."); + LOGD("initPreview: old frame thread completed."); } LOGI("KALIM: Wait for unlock frame"); @@ -907,19 +899,14 @@ bool QualcommCameraHardware::initPreview() LOGI("KALIM: Wait INSIDE for unlock tread to be finished"); LOGV("initPreview: waiting for old snapshot thread to complete."); mSnapshotThreadWait.wait(mSnapshotThreadWaitLock); - LOGV("initPreview: old snapshot thread completed."); + LOGD("initPreview: old snapshot thread completed."); } LOGI("KALIM: Wait for unlock thread AGAIN"); mSnapshotThreadWaitLock.unlock(); mPreviewFrameSize = mPreviewWidth * mPreviewHeight * 3/2; // actual -/* mPreviewHeap = new PreviewPmemPool(mCameraControlFd, - mPreviewWidth * mPreviewHeight * 2, // worst - kPreviewBufferCount, - mPreviewFrameSize, - 0, - "preview"); -*/ + + LOGD("Kalim: Preview PmemPool creation"); mPreviewHeap = new PmemPool( "/dev/pmem_adsp", mCameraControlFd, MSM_PMEM_OUTPUT2, @@ -928,6 +915,7 @@ bool QualcommCameraHardware::initPreview() mPreviewFrameSize, 0, "preview"); + LOGD("Kalim: Preview PmemPool end"); LOGI("KALIM: try to initialize preview"); if (!mPreviewHeap->initialized()) { @@ -957,6 +945,7 @@ bool QualcommCameraHardware::initPreview() pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + LOGD("Kalim: Creating Preview thread"); mFrameThreadRunning = !pthread_create(&mFrameThread, &attr, frame_thread, @@ -989,12 +978,11 @@ void QualcommCameraHardware::deinitPreview(void) // the frame-thread's callback. This we have to make the frame thread // detached, and use a separate mechanism to wait for it to complete. - /* if (LINK_camframe_terminate() < 0) + if (LINK_camframe_terminate() < 0) LOGE("failed to stop the camframe thread: %s", strerror(errno)); else LOGV("terminate frame_thread successfully"); - */ LOGV("deinitPreview X"); } @@ -1122,6 +1110,7 @@ void QualcommCameraHardware::release() LOGD("release E"); Mutex::Autolock l(&mLock); + #if DLOPEN_LIBMMCAMERA if (libmmcamera == NULL) { LOGE("ERROR: multiple release!"); @@ -1146,10 +1135,6 @@ void QualcommCameraHardware::release() stopPreviewInternal(); } - //FIXME: crash when released - //LOGV("KALIM Join IMAGE"); - //LINK_jpeg_encoder_join(); - if (mRawInitialized) deinitRaw(); LOGV("CAMERA_EXIT"); @@ -1222,7 +1207,6 @@ void QualcommCameraHardware::release() singleton_wait.signal(); LOGV("Kalim Hardware Release ------- FIN"); - //FIXME: crash when released LOGV("KALIM Join IMAGE"); LINK_jpeg_encoder_join(); @@ -1269,29 +1253,6 @@ status_t QualcommCameraHardware::startPreviewInternal() } } -/* - int ret; - unsigned long timeout = 2000; // 2s - struct pollfd fds[] = { - { mCameraControlFd, POLLIN | POLLRDNORM }, - }; - - // polling, found in Donut dmesg. - ret = poll(fds, 1, timeout); - switch (ret) { - case -1: - LOGE("poll error"); - break; - case 0: - LOGE("poll timeout"); - break; - default: - if (fds[0].revents & POLLIN) { - LOGV("frame is ready!"); - } - } - */ - mCameraRunning = native_start_preview(mCameraControlFd); if (!mCameraRunning) { deinitPreview(); @@ -1419,6 +1380,7 @@ void *auto_focus_thread(void *user) status_t QualcommCameraHardware::autoFocus() { LOGV("autoFocus E"); + Mutex::Autolock l(&mLock); if (mCameraControlFd < 0) { @@ -1426,14 +1388,6 @@ status_t QualcommCameraHardware::autoFocus() return UNKNOWN_ERROR; } - /* Not sure this is still needed with new APIs .. - if (mMsgEnabled & CAMERA_MSG_FOCUS) { - LOGW("Auto focus is already in progress"); - return NO_ERROR; - // No idea how to rewrite this - //return mAutoFocusCallback == af_cb ? NO_ERROR : INVALID_OPERATION; - }*/ - { mAutoFocusThreadLock.lock(); if (!mAutoFocusThreadRunning) { @@ -1563,7 +1517,6 @@ status_t QualcommCameraHardware::setParameters( LOGV("actual size %d x %d", mPreviewWidth, mPreviewHeight); - // FIXME: validate snapshot sizes, params.getPictureSize(&mRawWidth, &mRawHeight); mDimension.picture_width = mRawWidth; mDimension.picture_height = mRawHeight; @@ -1594,7 +1547,6 @@ status_t QualcommCameraHardware::setParameters( setWhiteBalance(); setEffect(); setAntibanding(); - // FIXME: set nightshot and luma adaptatiom LOGV("setParameters: X"); return NO_ERROR ; @@ -1698,7 +1650,6 @@ void QualcommCameraHardware::receivePreviewFrame(struct msm_frame_t *frame) if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME) { Mutex::Autolock rLock(&mRecordFrameLock); mDataCbTimestamp(systemTime(), CAMERA_MSG_VIDEO_FRAME, mPreviewHeap->mBuffers[offset], mCallbackCookie); /* guess? */ - //mDataCb(CAMERA_MSG_VIDEO_FRAME, mPreviewHeap->mBuffers[offset], mCallbackCookie); if (mReleasedRecordingFrame != true) { LOGV("block for release frame request/command"); @@ -1851,11 +1802,6 @@ void QualcommCameraHardware::receiveJpegPicture(void) } else LOGV("JPEG callback was cancelled--not delivering image."); - // Kalim FAKE to avoid join makes fail ---------------------- - // LOGV("KALIM Join IMAGE 2"); - // LINK_jpeg_encoder_join(); - // ---------------------------------------------------------- - if( mRawInitialized ) { deinitRaw(); } @@ -1984,6 +1930,7 @@ QualcommCameraHardware::PmemPool::PmemPool(const char *pmem_pool, mPmemType(pmem_type), mCameraControlFd(camera_control_fd) { + LOGD("Init PmemPool E"); LOGV("constructing MemPool %s backed by pmem pool %s: " "%d frames @ %d bytes, offset %d, buffer size %d", mName, @@ -2078,6 +2025,7 @@ QualcommCameraHardware::PreviewPmemPool::PreviewPmemPool( name) { LOGV("QualcommCameraHardware::PreviewPmemPool::PreviewPmemPool"); + if (initialized()) { //NOTE : SOME PREVIEWPMEMPOOL SPECIFIC CODE MAY BE ADDED } @@ -2087,8 +2035,8 @@ QualcommCameraHardware::PreviewPmemPool::~PreviewPmemPool() { LOGV("destroying PreviewPmemPool"); if (initialized()) { - LOGV("releasing PreviewPmemPool memory %p from module %d", - base, QDSP_MODULE_VFETASK); + //LOGV("releasing PreviewPmemPool memory %p from module %d", + // base, QDSP_MODULE_VFETASK); } } diff --git a/libcamera/QualcommCameraHardware.h b/libcamera/QualcommCameraHardware.h index 5be2500..d1ca60a 100644 --- a/libcamera/QualcommCameraHardware.h +++ b/libcamera/QualcommCameraHardware.h @@ -28,7 +28,7 @@ extern "C" { #include "msm_camera.h" } -#define version "11.04.01" +#define version "7002" #define MSM_CAMERA_CONTROL "/dev/msm_camera/msm_camera0" #define JPEG_EVENT_DONE 0 /* guess */ @@ -206,7 +206,6 @@ private: static const int kJpegBufferCount = 1; static const int kRawFrameHeaderSize = 0; - //TODO: put the picture dimensions in the CameraParameters object; CameraParameters mParameters; int mPreviewHeight; int mPreviewWidth; diff --git a/libcamera/exifwriter.c b/libcamera/exifwriter.c index 4efcaa3..e8045b3 100644 --- a/libcamera/exifwriter.c +++ b/libcamera/exifwriter.c @@ -1,7 +1,7 @@ #include "exifwriter.h" #include "jhead.h" -#define LOG_TAG "ExifWriter" +#define LOG_TAG "ExifWriterCamera" #include @@ -20,12 +20,12 @@ float *float2degminsec( float deg ) { - float *res = malloc( sizeof(float)*3 ) ; - res[0] = floorf( deg ) ; - float min = ( deg - res[0] ) * 60. ; - res[1] = floorf( min ) ; - res[2] = ( min - res[1] ) * 60. ; - return res ; + float *res = malloc( sizeof(float)*3 ); + res[0] = floorf( deg ); + float min = ( deg - res[0] ) * 60.; + res[1] = floorf( min ); + res[2] = ( min - res[1] ) * 60.; + return res; } @@ -35,12 +35,12 @@ float *float2degminsec( float deg ) // char * float2rationnal( float src ) { - long m[2][2] ; - float x, startx ; - long maxden = 1000 ; - long ai ; + long m[2][2]; + float x, startx; + long maxden = 1000; + long ai; - startx = x = src ; + startx = x = src; /* initialize matrix */ m[0][0] = m[1][1] = 1; @@ -74,23 +74,23 @@ char * float2rationnal( float src ) LOGV("%ld/%ld, error = %e\n", m[0][0], m[1][0], startx - ((float) m[0][0] / (float) m[1][0])); - char *res = (char *)malloc( 256 * sizeof(char) ) ; + char *res = (char *)malloc( 256 * sizeof(char) ); - snprintf( res, 256, "%ld/%ld", m[0][0], m[1][0] ) ; - return res ; + snprintf( res, 256, "%ld/%ld", m[0][0], m[1][0] ); + return res; } char * coord2degminsec( float src ) { - char *res = (char *)malloc( 256 * sizeof(char) ) ; - float *dms = float2degminsec( fabs(src) ) ; - strcpy( res, float2rationnal(dms[0]) ) ; - strcat( res , "," ) ; - strcat( res , float2rationnal(dms[1]) ) ; - strcat( res , "," ) ; - strcat( res , float2rationnal(dms[2]) ) ; - free( dms ) ; - return res ; + char *res = (char *)malloc( 256 * sizeof(char) ); + float *dms = float2degminsec( fabs(src) ); + strcpy( res, float2rationnal(dms[0]) ); + strcat( res , "," ); + strcat( res , float2rationnal(dms[1]) ); + strcat( res , "," ); + strcat( res , float2rationnal(dms[2]) ); + free( dms ); + return res; } static void dump_to_file(const char *fname, @@ -125,11 +125,12 @@ char * coord2degminsec( float src ) } void writeExif( void *origData, void *destData , int origSize , uint32_t *resultSize, int orientation,camera_position_type *pt ) { - const char *filename = "/data/temp.jpg" ; + const char *filename = "/data/temp.jpg"; - dump_to_file( filename, (uint8_t *)origData, origSize ) ; - chmod( filename, S_IRWXU ) ; - ResetJpgfile() ; + dump_to_file( filename, (uint8_t *)origData, origSize ); + LOGD("KalimochoAz WRITE EXIF Filename %s", filename); + chmod( filename, S_IRWXU ); + ResetJpgfile(); memset(&ImageInfo, 0, sizeof(ImageInfo)); @@ -137,115 +138,119 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result ImageInfo.MeteringMode = -1; ImageInfo.Whitebalance = -1; - int gpsTag = 0 ; + int gpsTag = 0; if( pt != NULL ) { - gpsTag = 6 ; + LOGD("KalimochoAz EXIF ADD GPS DATA ........"); + gpsTag = 6; + } else{ + LOGD("KalimochoAz EXIF NO GPS ........"); } - ExifElement_t *t = (ExifElement_t *)malloc( sizeof(ExifElement_t)*(3+gpsTag) ) ; + ExifElement_t *t = (ExifElement_t *)malloc( sizeof(ExifElement_t)*(3+gpsTag) ); - ExifElement_t *it = t ; - // Store file date/time. - (*it).Tag = TAG_ORIENTATION ; - (*it).Format = FMT_USHORT ; - (*it).DataLength = 1 ; - unsigned short v ; - if( orientation == 90 ) { - (*it).Value = "6" ; - } else if( orientation == 180 ) { - (*it).Value = "3" ; - } else { - (*it).Value = "1" ; - } - (*it).GpsTag = FALSE ; + ExifElement_t *it = t; + // Store file date/time. + (*it).Tag = TAG_ORIENTATION; + (*it).Format = FMT_USHORT; + (*it).DataLength = 1; + unsigned short v; + LOGD("KalimochoAz EXIF Orientation %d ยบ", orientation); + if( orientation == 90 ) { + (*it).Value = "6"; + } else if( orientation == 180 ) { + (*it).Value = "3"; + } else { + (*it).Value = "1"; + } + (*it).GpsTag = FALSE; - it++; + it++; - (*it).Tag = TAG_MAKE ; - (*it).Format = FMT_STRING ; - (*it).Value = "Samsung" ; - (*it).DataLength = 8 ; - (*it).GpsTag = FALSE ; + (*it).Tag = TAG_MAKE; + (*it).Format = FMT_STRING; + (*it).Value = "HTC"; + (*it).DataLength = 8; + (*it).GpsTag = FALSE; - it++ ; + it++; - (*it).Tag = TAG_MODEL ; - (*it).Format = FMT_STRING ; - (*it).Value = "Galaxy with GAOSP" ; - (*it).DataLength = 18 ; - (*it).GpsTag = FALSE ; + (*it).Tag = TAG_MODEL; + (*it).Format = FMT_STRING; + (*it).Value = "Tattoo with CyanogenMOD"; + (*it).DataLength = 18; + (*it).GpsTag = FALSE; if( pt != NULL ) { - LOGD("pt->latitude == %f", pt->latitude ) ; - LOGD("pt->longitude == %f", pt->longitude ) ; - LOGD("pt->altitude == %d", pt->altitude ) ; + LOGD("pt->latitude == %f", pt->latitude ); + LOGD("pt->longitude == %f", pt->longitude ); + LOGD("pt->altitude == %d", pt->altitude ); - it++ ; - (*it).Tag = 0x01 ; - (*it).Format = FMT_STRING ; - if( pt->latitude > 0 ) { - (*it).Value = "N" ; - } else { - (*it).Value = "S" ; - } - (*it).DataLength = 2 ; - (*it).GpsTag = TRUE ; + it++; + (*it).Tag = 0x01; + (*it).Format = FMT_STRING; + if( pt->latitude > 0 ) { + (*it).Value = "N"; + } else { + (*it).Value = "S"; + } + (*it).DataLength = 2; + (*it).GpsTag = TRUE; - it++ ; - char *mylat = coord2degminsec( pt->latitude ) ; + it++; + char *mylat = coord2degminsec( pt->latitude ); - (*it).Tag = 0x02 ; - (*it).Format = FMT_URATIONAL ; - (*it).Value = mylat ; - (*it).DataLength = 3 ; - (*it).GpsTag = TRUE ; - free( mylat ) ; + (*it).Tag = 0x02; + (*it).Format = FMT_URATIONAL; + (*it).Value = mylat; + (*it).DataLength = 3; + (*it).GpsTag = TRUE; + free( mylat ); - it++ ; - (*it).Tag = 0x03 ; - (*it).Format = FMT_STRING ; - if( (*pt).longitude > 0 ) { - (*it).Value = "E" ; - } else { - (*it).Value = "W" ; - } - (*it).DataLength = 2 ; - (*it).GpsTag = TRUE ; + it++; + (*it).Tag = 0x03; + (*it).Format = FMT_STRING; + if( (*pt).longitude > 0 ) { + (*it).Value = "E"; + } else { + (*it).Value = "W"; + } + (*it).DataLength = 2; + (*it).GpsTag = TRUE; - it++ ; - char *mylong = coord2degminsec( (*pt).longitude ) ; + it++; + char *mylong = coord2degminsec( (*pt).longitude ); - (*it).Tag = 0x04 ; - (*it).Format = FMT_URATIONAL ; - (*it).Value = mylong ; - (*it).DataLength = 3 ; - (*it).GpsTag = TRUE ; + (*it).Tag = 0x04; + (*it).Format = FMT_URATIONAL; + (*it).Value = mylong; + (*it).DataLength = 3; + (*it).GpsTag = TRUE; - free( mylong ) ; + free( mylong ); - it++ ; - (*it).Tag = 0x05 ; - (*it).Format = FMT_USHORT ; - if( (*pt).altitude > 0 ) { - (*it).Value = "0" ; - } else { - (*it).Value = "1" ; - } - (*it).DataLength = 1 ; - (*it).GpsTag = TRUE ; + it++; + (*it).Tag = 0x05; + (*it).Format = FMT_USHORT; + if( (*pt).altitude > 0 ) { + (*it).Value = "0"; + } else { + (*it).Value = "1"; + } + (*it).DataLength = 1; + (*it).GpsTag = TRUE; - it++ ; - char *myalt = float2rationnal( fabs( (*pt).altitude ) ) ; + it++; + char *myalt = float2rationnal( fabs( (*pt).altitude ) ); - (*it).Tag = 0x06 ; - (*it).Format = FMT_SRATIONAL ; - (*it).Value = myalt ; - (*it).DataLength = 1 ; - (*it).GpsTag = TRUE ; + (*it).Tag = 0x06; + (*it).Format = FMT_SRATIONAL; + (*it).Value = myalt; + (*it).DataLength = 1; + (*it).GpsTag = TRUE; - free( myalt ) ; + free( myalt ); } @@ -257,26 +262,28 @@ void writeExif( void *origData, void *destData , int origSize , uint32_t *result } } strncpy(ImageInfo.FileName, filename, PATH_MAX); + LOGD("KalimochoAz Image EXIF Filename %s", filename); ReadMode_t ReadMode; ReadMode = READ_METADATA; ReadMode |= READ_IMAGE; int res = ReadJpegFile(filename, (ReadMode_t)ReadMode ); + LOGD("KalimochoAz READ EXIF Filename %s", filename); create_EXIF( t, 3, gpsTag); - WriteJpegFile(filename); - chmod( filename, S_IRWXU ) ; - DiscardData(); + WriteJpegFile(filename); + chmod( filename, S_IRWXU ); + DiscardData(); - FILE *src ; - src = fopen( filename, "r") ; + FILE *src; + src = fopen( filename, "r"); - fseek( src, 0L, SEEK_END ) ; - (*resultSize) = ftell(src) ; - fseek( src, 0L, SEEK_SET ) ; + fseek( src, 0L, SEEK_END ); + (*resultSize) = ftell(src); + fseek( src, 0L, SEEK_SET ); - int read = fread( destData, 1, (*resultSize), src ) ; + int read = fread( destData, 1, (*resultSize), src ); - unlink( filename ); + unlink( filename ); } diff --git a/libcamera/exifwriter.h b/libcamera/exifwriter.h index 1a49431..41ff044 100644 --- a/libcamera/exifwriter.h +++ b/libcamera/exifwriter.h @@ -6,8 +6,8 @@ typedef struct { uint32_t timestamp; /* seconds since 1/6/1980 */ - double latitude; /* degrees, WGS ellipsoid */ - double longitude; /* degrees */ + double latitude; /* degrees, WGS ellipsoid */ + double longitude; /* degrees */ int16_t altitude; /* meters */ } camera_position_type; diff --git a/libcamera/jpegConvert.cpp b/libcamera/jpegConvert.cpp index db74f33..5212d21 100644 --- a/libcamera/jpegConvert.cpp +++ b/libcamera/jpegConvert.cpp @@ -1,8 +1,22 @@ /* - Version: 1.0 - Coded by: Josebagar 02/2011 (linux version) - Revised and Recoded: KalimochoAz 02/2011 (android conversions) Done for CyanogenMOD - Free code: feel free to use, copy, modify or criticize. But please leave it as free code always +** Copyright 2008, Google Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +/* +** Version: 1.0 +** Coded by: Josebagar 02/2011 (linux version) +** Revised and Recoded: KalimochoAz 02/2011 (android conversions) Done for CyanogenMOD */ #include #include @@ -165,4 +179,4 @@ int yuv420_save2jpeg(unsigned char *dest, void *src, int width, int height, int delete encoder; return true; -} \ No newline at end of file +}