From: Mark Salyzyn Date: Tue, 16 Sep 2014 21:00:10 +0000 (-0700) Subject: Manta: exynos: libcamera2: Add Exif subsec time X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=be8daa966251dcd40d3b004e66cef9ad160542b9;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git Manta: exynos: libcamera2: Add Exif subsec time - Add SUBSEC_TIME, SUBSEC_TIME_ORG and SUBSEC_TIME_DIGITIZE - resolve compiler warnings Bug: 17472049 Change-Id: I930b9643998017ad07b982a9a905afc29882b669 --- diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index a722a90..4d65914 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -33,6 +33,7 @@ //#define LOG_NDEBUG 0 #define LOG_TAG "ExynosCameraHAL2" +#include #include #include @@ -5790,11 +5791,13 @@ void ExynosCameraHWInterface2::m_setExifChangedAttribute(exif_attribute_t *exifI } //3 Date time - time_t rawtime; + struct timeval rawtime; struct tm *timeinfo; - time(&rawtime); - timeinfo = localtime(&rawtime); + gettimeofday(&rawtime, NULL); + timeinfo = localtime(&rawtime.tv_sec); strftime((char *)exifInfo->date_time, 20, "%Y:%m:%d %H:%M:%S", timeinfo); + snprintf((char *)exifInfo->sub_sec, sizeof(exifInfo->sub_sec), "%03lu", + (unsigned long)rawtime.tv_usec / 1000UL); //2 0th IFD Exif Private Tags //3 Exposure Time diff --git a/libcamera2/ExynosExif.h b/libcamera2/ExynosExif.h index 0b5a599..532e411 100644 --- a/libcamera2/ExynosExif.h +++ b/libcamera2/ExynosExif.h @@ -30,8 +30,9 @@ #define IFD_SIZE 12 #define OFFSET_SIZE 4 -#define NUM_0TH_IFD_TIFF 10 -#define NUM_0TH_IFD_EXIF 22 +/* Add any additional writeExifIfd() in sections, increase buffer size */ +#define NUM_0TH_IFD_TIFF 11 +#define NUM_0TH_IFD_EXIF 24 #define NUM_0TH_IFD_GPS 10 #define NUM_1TH_IFD_TIFF 9 @@ -55,6 +56,7 @@ #define EXIF_TAG_ORIENTATION 0x0112 #define EXIF_TAG_SOFTWARE 0x0131 #define EXIF_TAG_DATE_TIME 0x0132 +#define EXIF_TAG_SUBSEC_TIME 0x9290 #define EXIF_TAG_YCBCR_POSITIONING 0x0213 #define EXIF_TAG_EXIF_IFD_POINTER 0x8769 #define EXIF_TAG_GPS_IFD_POINTER 0x8825 @@ -66,7 +68,9 @@ #define EXIF_TAG_ISO_SPEED_RATING 0x8827 #define EXIF_TAG_EXIF_VERSION 0x9000 #define EXIF_TAG_DATE_TIME_ORG 0x9003 +#define EXIF_TAG_SUBSEC_TIME_ORG 0x9291 #define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004 +#define EXIF_TAG_SUBSEC_TIME_DIGITIZE 0x9292 #define EXIF_TAG_SHUTTER_SPEED 0x9201 #define EXIF_TAG_APERTURE 0x9202 #define EXIF_TAG_BRIGHTNESS 0x9203 @@ -181,6 +185,7 @@ typedef struct { unsigned char software[32]; unsigned char exif_version[4]; unsigned char date_time[20]; + unsigned char sub_sec[4]; unsigned char user_comment[150]; uint32_t width; diff --git a/libcamera2/ExynosJpegEncoderForCamera.cpp b/libcamera2/ExynosJpegEncoderForCamera.cpp index d47b41b..e5b84a9 100644 --- a/libcamera2/ExynosJpegEncoderForCamera.cpp +++ b/libcamera2/ExynosJpegEncoderForCamera.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#define LOG_TAG "ExynosJpegForCamera" #include #include "ExynosJpegEncoderForCamera.h" @@ -22,7 +23,6 @@ static const char ExifAsciiPrefix[] = { 0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0 }; #define JPEG_ERROR_LOG ALOGE -#define LOG_TAG "ExynosJpegForCamera" #define JPEG_THUMBNAIL_QUALITY (60) #define EXIF_LIMIT_SIZE (64*1024) @@ -212,7 +212,7 @@ int ExynosJpegEncoderForCamera::setOutBuf(int buf, char* vBuf, int size) return ERROR_NOT_YET_CREATED; } - if (buf == NULL) { + if (!buf) { return ERROR_BUFFR_IS_NULL; } @@ -260,7 +260,7 @@ int ExynosJpegEncoderForCamera::encode(int *size, exif_attribute_t *exifInfo) int iJpegBuffer = m_stMainOutBuf.ionBuffer[0]; char *pcJpegBuffer = m_stMainOutBuf.pcBuf[0]; - if (pcJpegBuffer[0] == NULL) { + if (!pcJpegBuffer[0]) { JPEG_ERROR_LOG("%s::pcJpegBuffer[0] is null!!\n", __func__); return ERROR_OUT_BUFFER_CREATE_FAIL; } @@ -361,6 +361,8 @@ int ExynosJpegEncoderForCamera::makeExif (unsigned char *exifOut, strlen((char *)exifInfo->software) + 1, exifInfo->software, &LongerTagOffest, pIfdStart); writeExifIfd(&pCur, EXIF_TAG_DATE_TIME, EXIF_TYPE_ASCII, 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME, EXIF_TYPE_ASCII, + sizeof(exifInfo->sub_sec), exifInfo->sub_sec); writeExifIfd(&pCur, EXIF_TAG_YCBCR_POSITIONING, EXIF_TYPE_SHORT, 1, exifInfo->ycbcr_positioning); writeExifIfd(&pCur, EXIF_TAG_EXIF_IFD_POINTER, EXIF_TYPE_LONG, @@ -394,8 +396,12 @@ int ExynosJpegEncoderForCamera::makeExif (unsigned char *exifOut, 4, exifInfo->exif_version); writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_ORG, EXIF_TYPE_ASCII, 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME_ORG, EXIF_TYPE_ASCII, + sizeof(exifInfo->sub_sec), exifInfo->sub_sec); writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_DIGITIZE, EXIF_TYPE_ASCII, 20, exifInfo->date_time, &LongerTagOffest, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME_DIGITIZE, EXIF_TYPE_ASCII, + sizeof(exifInfo->sub_sec), exifInfo->sub_sec); writeExifIfd(&pCur, EXIF_TAG_SHUTTER_SPEED, EXIF_TYPE_SRATIONAL, 1, (rational_t *)&exifInfo->shutter_speed, &LongerTagOffest, pIfdStart); writeExifIfd(&pCur, EXIF_TAG_APERTURE, EXIF_TYPE_RATIONAL, @@ -561,14 +567,13 @@ int ExynosJpegEncoderForCamera::makeExif (unsigned char *exifOut, memcpy(pNextIfdOffset, &tmp, OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD } - unsigned char App1Marker[2] = { 0xff, 0xe1 }; - memcpy(pApp1Start, App1Marker, 2); - pApp1Start += 2; + *(pApp1Start++) = 0xff; + *(pApp1Start++) = 0xe1; *size = 10 + LongerTagOffest; tmp = *size - 2; // APP1 Maker isn't counted - unsigned char size_mm[2] = {(tmp >> 8) & 0xFF, tmp & 0xFF}; - memcpy(pApp1Start, size_mm, 2); + *(pApp1Start++) = (tmp >> 8) & 0xFF; + *(pApp1Start++) = tmp & 0xFF; return ERROR_NONE; }