00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __H_AUTOEXPOSURE__
00029 #define __H_AUTOEXPOSURE__
00030
00031 #include <unistd.h>
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <signal.h>
00035 #include <fcntl.h>
00036 #include <errno.h>
00037 #include <sys/types.h>
00038 #include <sys/socket.h>
00039 #include <sys/stat.h>
00040
00041
00042 #include <time.h>
00043 #include <string.h>
00044 #include <syslog.h>
00045
00046 #include <netinet/in.h>
00047 #include <sys/mman.h>
00048 #include <sys/ioctl.h>
00049
00050 #include <asm/elphel/c313a.h>
00051 #include <asm/elphel/exifa.h>
00052 #include <asm/elphel/ext353.h>
00053 #include <asm/byteorder.h>
00054
00055 #include "aexp_utils.h"
00056 #include "aexp_corr.h"
00057 #include "white_balance.h"
00058 #include "hdr_control.h"
00059 #include "globalsinit.h"
00060
00061 #define THIS_DEBUG 1
00062
00063
00064
00065
00066 #if THIS_DEBUG
00067 #define MDF0(x) { if (autoexposure_debug & (1 << 0)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00068 #define MDF1(x) { if (autoexposure_debug & (1 << 1)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00069 #define MDF2(x) { if (autoexposure_debug & (1 << 2)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00070
00071 #define MDF3(x) { if (autoexposure_debug & (1 << 3)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00072
00073 #define MDF4(x) { if (autoexposure_debug & (1 << 4)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00074 #define MDF5(x) { if (autoexposure_debug & (1 << 5)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00075 #define MDF6(x) { if (autoexposure_debug & (1 << 6)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00076 #define MDF7(x) { if (autoexposure_debug & (1 << 7)) {fprintf(stderr,"%s:%d:%s: ",__FILE__,__LINE__,__FUNCTION__);x;} }
00077 #else
00078 #define MDF0(x)
00079 #define MDF1(x)
00080 #define MDF2(x)
00081 #define MDF3(x)
00082 #define MDF4(x)
00083 #define MDF5(x)
00084 #define MDF6(x)
00085 #define MDF7(x)
00086 #endif
00087
00088 #define START_SKIP_FRAMES 8 // don't try autoexposure until this number of frames after startup
00089 #define get_imageParamsThis(x) ( framePars[this_frame & PARS_FRAMES_MASK].pars[x])
00090 #define min(x,y) ((x<y)?x:y)
00091
00092
00093 #define RECALIBRATE_AHEAD 3 // Darken frame 3 ahead of current to measure histograms
00094 #define EXPOS_AHEAD 3 // minimal frames ahead of the current to set VEXPOS
00095 #define DEFAULT_AE_PERIOD_CHANGE 4
00096 #define DEFAULT_AE_PERIOD_NOCHANGE 1
00097 #define DEFAULT_WB_PERIOD_CHANGE 16
00098 #define DEFAULT_WB_PERIOD_NOCHANGE 4
00099 #define RECALIBRATE_AFTER 2 // number of dim frames
00100 #define DEFAULT_BLACK_CALIB 0xa00
00101 #define HDR_PATTERN1_8 0xaa
00102 #define HDR_PATTERN2_8 0x66
00103 #define HDR_PATTERN1 (HDR_PATTERN1_8 | (HDR_PATTERN1_8 << 8) | (HDR_PATTERN1_8 << 16) | (HDR_PATTERN1_8 << 24))
00104 #define HDR_PATTERN2 (HDR_PATTERN2_8 | (HDR_PATTERN2_8 << 8) | (HDR_PATTERN2_8 << 16) | (HDR_PATTERN2_8 << 24))
00105 #define DEFAULT_WB_WHITELEV 0xfae1 // 98%
00106 #define DEFAULT_WB_WHITEFRAC 0x028f // 1%
00107 #define PERCENTILE_SHIFT 16
00108 #define PERCENTILE_1 (1 << PERCENTILE_SHIFT)
00109
00110 #endif