exynos4: hal: include: Exif.h: always keep two decimal places in macros
authorghepeu <ghepeu@gmail.com>
Fri, 10 May 2013 12:19:23 +0000 (14:19 +0200)
committerghepeu <ghepeu@gmail.com>
Fri, 10 May 2013 12:27:52 +0000 (14:27 +0200)
The APEX macros always rounded to int, losing too much precision. Ensure
that we always keep at least two decimal digits.

The more precise F-number comes from the value recorded by the camera
closed source driver.

Added a new macro APEX_SHUTTER_TO_EXPOSURE(x) (credit to tryptophane).

Change-Id: Ief43c15c6517d8dc48d4d4bc9e93df9eb01e6b91

exynos4/hal/include/Exif.h

index 71e2241de110a5937fb3dc8efb83dd3adce4a3df..6bf37305d99e406d2858331072aabed7e59cb658 100644 (file)
 #include <math.h>
 
 #define EXIF_LOG2(x)                    (log((double)(x)) / log(2.0))
-#define APEX_FNUM_TO_APERTURE(x)        ((int)(EXIF_LOG2((double)(x)) * 2 + 0.5))
+#define APEX_FNUM_TO_APERTURE(x)        ((int)(EXIF_LOG2((double)(x)) * 200.0 + 0.5))
 #define APEX_EXPOSURE_TO_SHUTTER(x)     ((x) >= 1 ?                                 \
-                                        (int)(-(EXIF_LOG2((double)(x)) + 0.5)) :    \
-                                        (int)(-(EXIF_LOG2((double)(x)) - 0.5)))
-#define APEX_ISO_TO_FILMSENSITIVITY(x)  ((int)(EXIF_LOG2((x) / 3.125) + 0.5))
+                                        (int)(-(EXIF_LOG2((double)(x)) * 100.0 + 0.5)) :    \
+                                        (int)(-(EXIF_LOG2((double)(x)) * 100.0 - 0.5)))
+#define APEX_ISO_TO_FILMSENSITIVITY(x)  ((int)(EXIF_LOG2((x) / 3.125) * 100.0 + 0.5))
+#define APEX_SHUTTER_TO_EXPOSURE(x)     ((int)((pow(2.0, (double)(x) / 100.0)) + 0.5))
 
 #define NUM_SIZE                    2
 #define IFD_SIZE                    12
@@ -147,15 +148,15 @@ typedef enum {
 #define EXIF_DEF_USERCOMMENTS   "User comments"
 
 #define EXIF_DEF_YCBCR_POSITIONING  1   /* centered */
-#define EXIF_DEF_FNUMBER_NUM        26  /* 2.6 */
-#define EXIF_DEF_FNUMBER_DEN        10
+#define EXIF_DEF_FNUMBER_NUM        265  /* 2.65 */
+#define EXIF_DEF_FNUMBER_DEN        100
 #define EXIF_DEF_EXPOSURE_PROGRAM   3   /* aperture priority */
 #define EXIF_DEF_FOCAL_LEN_NUM      278 /* 2.78mm */
 #define EXIF_DEF_FOCAL_LEN_DEN      100
 #define EXIF_DEF_FLASH              0   /* O: off, 1: on*/
 #define EXIF_DEF_COLOR_SPACE        1
 #define EXIF_DEF_EXPOSURE_MODE      EXIF_EXPOSURE_AUTO
-#define EXIF_DEF_APEX_DEN           10
+#define EXIF_DEF_APEX_DEN           100
 
 #define EXIF_DEF_COMPRESSION        6
 #define EXIF_DEF_RESOLUTION_NUM     72