summaryrefslogtreecommitdiffstats
path: root/camera/Encoder_libjpeg.cpp
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2011-10-12 17:39:00 -0500
committerIliyan Malchev <malchev@google.com>2011-10-15 13:44:35 -0700
commit98a55a01029ef90825a1164024d3de5f71caab8d (patch)
tree3ec1497965be48d3d84baf8b6118f54bf9b7a9b2 /camera/Encoder_libjpeg.cpp
parent121766c89aa95a0dffb515676d68c323d3996f00 (diff)
downloadhardware_ti_omap4-98a55a01029ef90825a1164024d3de5f71caab8d.tar.gz
hardware_ti_omap4-98a55a01029ef90825a1164024d3de5f71caab8d.tar.bz2
hardware_ti_omap4-98a55a01029ef90825a1164024d3de5f71caab8d.zip
CameraHal: Fixes for #testVideoSnapshot
1. Add raw notify callback for video snapshot 2. Add new state for video capture + AF 3. We were not populating focal length correctly for jhead. Need to send focal length as a rational in this format "xx/yy" 4. Need to send GPSProcessingMethod as an UNDEFINED ASCII to jhead b/5448171 Change-Id: Ie6be9ad821d1fa106d9c857681f2fa6427d4f283 Signed-off-by: Tyler Luu <tluu@ti.com>
Diffstat (limited to 'camera/Encoder_libjpeg.cpp')
-rw-r--r--camera/Encoder_libjpeg.cpp61
1 files changed, 59 insertions, 2 deletions
diff --git a/camera/Encoder_libjpeg.cpp b/camera/Encoder_libjpeg.cpp
index 152e3cc..f6f6498 100644
--- a/camera/Encoder_libjpeg.cpp
+++ b/camera/Encoder_libjpeg.cpp
@@ -36,6 +36,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
+#include <math.h>
extern "C" {
#include "jpeglib.h"
@@ -207,6 +208,58 @@ const char* ExifElementsTable::degreesToExifOrientation(const char* degrees) {
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) {
+ // convert the decimal string into a rational
+ 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) {
+ // TODO(XXX): Add tags as necessary
+ return (strcmp(tag, TAG_GPS_PROCESSING_METHOD) == 0);
+}
+
void ExifElementsTable::insertExifToJpeg(unsigned char* jpeg, size_t jpeg_size) {
ReadMode_t read_mode = (ReadMode_t)(READ_METADATA | READ_IMAGE);
@@ -264,7 +317,11 @@ status_t ExifElementsTable::insertElement(const char* tag, const char* value) {
return NO_MEMORY;
}
- value_length = strlen(value);
+ if (isAsciiTag(tag)) {
+ value_length = sizeof(ExifAsciiPrefix) + strlen(value + sizeof(ExifAsciiPrefix));
+ } else {
+ value_length = strlen(value);
+ }
if (IsGpsTag(tag)) {
table[position].GpsTag = TRUE;
@@ -280,7 +337,7 @@ status_t ExifElementsTable::insertElement(const char* tag, const char* value) {
table[position].Value = (char*) malloc(sizeof(char) * (value_length + 1));
if (table[position].Value) {
- strcpy(table[position].Value, value);
+ memcpy(table[position].Value, value, value_length + 1);
table[position].DataLength = value_length + 1;
}