apps/autoexposure/aexp_utils.c File Reference

#include "autoexposure.h"

Include dependency graph for aexp_utils.c:

Go to the source code of this file.

Functions

int poorLog (int x)
int poorExp (int x)
int waitRequstPrevHist (unsigned long next_frame)
long getPercentile (unsigned long frame, int color, unsigned long fraction, int request_colors)
 calculate pixel value corresponding so that specified fraction of all pixels have value less or equal than it both result and input fraction are 16.16 format, so 0x10000 is 1.0
unsigned long gammaDirect (unsigned long x)
 calculates direct gamma conversion using gamma tables indexed by global gamma_index
unsigned long gammaReverse (unsigned long x)
 calculates reverse gamma conversion using gamma tables indexed by global gamma_index
unsigned long get_imageParamsThat (int indx, unsigned long frame)
 histogram is availble for previous frame, not for the current one
int get_imageParamsThatValid (int indx, unsigned long frame)
 return value of parameter 'indx' from frame 'frame' - use pastPars if too late for framePars (31 bits only)
int recalibrateDim (void)
 Measure the percentile input (sensor) level for the specified by [P_AEXP_FRACPIX] fraction of all pixels for VEXPOS = 1 line, use that as a zero level for exposure calculations.


Function Documentation

unsigned long gammaDirect ( unsigned long  x  ) 

calculates direct gamma conversion using gamma tables indexed by global gamma_index

Parameters:
x - argument 0..0xffff (proportional to sensor data)
Returns:
converted result, in the range 0..0xffff (proportional to 8-bit internal data to be compressed)

truncating , no interpolation

Definition at line 180 of file aexp_utils.c.

References gamma_stuct_t::direct, gamma_cache, and gamma_index.

Referenced by whiteBalanceCorr().

unsigned long gammaReverse ( unsigned long  x  ) 

calculates reverse gamma conversion using gamma tables indexed by global gamma_index

Parameters:
x - argument 0..0xffff (proportional to 8-bit internal data to be compressed)
Returns:
converted result, in the range 0..0xffff (proportional to sensor data)

[257] "Gamma" table, 16-bit for both non-scaled prototypes and scaled, 0..0xffff range (hardware will use less)

[256] reverse table to speed-up reversing (still need interpolation).Index - most significant 8 bits, data - largest direct

8 MSBs used as index

seems gamma_reverse[] rounds up, not down

adjust down (is that needed at all?)

adjust up (is that needed at all?)

limit just in case?

Definition at line 193 of file aexp_utils.c.

References gamma_stuct_t::direct, gamma_cache, gamma_direct, gamma_index, gamma_reverse, MDF2, gamma_stuct_t::reverse, and stderr.

Referenced by aexpCorr(), getPercentile(), and whiteBalanceCorr().

unsigned long get_imageParamsThat ( int  indx,
unsigned long  frame 
)

histogram is availble for previous frame, not for the current one

Parameters:
indx parameter indx
frame absolute frame number
Returns:
parameter value (error will be 0xffffffff, but that could be a legitimate value too)

Locate frame info in framePars

too late, try pastPars

not saved

should be retrieved before checking frame (interrupts)

too late even for pastPars? Or a bug?

Definition at line 224 of file aexp_utils.c.

Referenced by PHP_FUNCTION(), and whiteBalanceCorr().

int get_imageParamsThatValid ( int  indx,
unsigned long  frame 
)

return value of parameter 'indx' from frame 'frame' - use pastPars if too late for framePars (31 bits only)

Parameters:
indx parameter index
frame absolute frame number
Returns:
<0 - error, otherwise parameter lower 31 bits of the parameter value

Locate frame info in framePars

too late, try pastPars

not saved

too late even for pastPars? Or a bug?

Definition at line 251 of file aexp_utils.c.

References ELP_FERR, framePars, P_FRAME, framepars_t::pars, PARS_FRAMES_MASK, PARS_SAVE_FROM, PARS_SAVE_NUM, framepars_past_t::past_pars, pastPars, PASTPARS_SAVE_ENTRIES_MASK, stderr, and value.

Referenced by aexpCorr(), and main().

long getPercentile ( unsigned long  frame,
int  color,
unsigned long  fraction,
int  request_colors 
)

calculate pixel value corresponding so that specified fraction of all pixels have value less or equal than it both result and input fraction are 16.16 format, so 0x10000 is 1.0

Parameters:
frame - absolute frame number for which percentile is requested
color - color number (0 - R, 1 - G1(G), 2 - G2(GB), 3 - B). G1 is also used for autoexposure
fraction - fraction of all pixels that should have value less or equal result 16.16 format - 0x10000 == 1.0 == all pixels
request_colors - if 0 - use the same histogram index as already calculated, otherwise it is a bit mask of colors to request, i.e. (1<<color) - request only the specified color, 0xf - request all colors
Returns:
<0 for error, or interpalated pixel "input" value in 0..0x10000 scale

256 of cumulated histogram values (in pixels)

256 of rounded percentiles (1 byte) - used as a starting point for linear interpolation

number of pixels corresponding to a specified fraction (rounded down)

Get the histogram (including percentiles)

at minimum for the new frame request_colors= 1<<color

wait for all histograms, not just Y (G1)

wait for just Y (G1)

specify that reverse histogram(s) are needed

request histograms for the specified frame

histograms for frame will be available 1 frame later

8 MSBs used as index

seems hist_percentile[perc] rounds up, not down

adjust down (is that needed at all?)

adjust up (is that needed at all?)

here perc_frac is the intermediate result, so that (1<<PERCENTILE_SHIFT) corresponds to full scale of after-gamma data Now we need to "un-gamma" it to reference to the (supposingly linear) input range that is proportional to exposure

here file->fpos resets to 0?

Definition at line 106 of file aexp_utils.c.

References COLOR_Y_NUMBER, histogram_stuct_t::cumul_hist, ELP_FERR, fd_gamma_cache, fd_histogram_cache, G_THIS_FRAME, gamma_index, GAMMA_MODE_NEED_REVERSE, gammaReverse(), GLOBALPARS, histogram_stuct_t::gtab, hist_index, histogram_cache, LSEEK_HIST_NEEDED, LSEEK_HIST_WAIT_C, LSEEK_HIST_WAIT_Y, MDF2, MDF7, histogram_stuct_t::percentile, PERCENTILE_1, PERCENTILE_SHIFT, SEEK_CUR, SEEK_END, SEEK_SET, stderr, this_frame, and write.

Referenced by aexpCorr(), and recalibrateDim().

int poorExp ( int  x  ) 

Definition at line 62 of file aexp_utils.c.

int poorLog ( int  x  ) 

*************************************************************************** ! FILE NAME : aexp_utils.c ! DESCRIPTION: Daemon to adjust camera exposure and white balance ! Copyright (C) 2008 Elphel, Inc. ! -----------------------------------------------------------------------------** ! This program is free software: you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation, either version 3 of the License, or ! (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! ! You should have received a copy of the GNU General Public License ! along with this program. If not, see <http://www.gnu.org/licenses/>. ! -----------------------------------------------------------------------------** ! !

Log
aexp_utils.c,v
! Revision 1.1.1.1 2008/11/27 20:04:01 elphel ! ! ! Revision 1.2 2008/11/18 19:30:16 elphel ! Added initialization of the "next" frame - otherwise it wait _very_ long if the camera frame number is reset ! ! Revision 1.1 2008/11/15 23:08:24 elphel ! 8.0.alpha17 - split autoexposure source file ! !

0-> 0 32-> 512 64-> 768 128 ->1024 256 ->1280 0x10000000 -> 0x1900 0x80000000 -> 0x1c00

0..511 gets here

first time always

Definition at line 35 of file aexp_utils.c.

Referenced by aexpCorr().

int recalibrateDim ( void   ) 

Measure the percentile input (sensor) level for the specified by [P_AEXP_FRACPIX] fraction of all pixels for VEXPOS = 1 line, use that as a zero level for exposure calculations.

Returns:
0 - OK

or is +1 enough? 2 seems to be required for Micron free running mode, for async 1 is OK

no error check here

all colors are needed. Will skip frames

all colors are needed. Will skip frames

Definition at line 277 of file aexp_utils.c.

References fd_fparmsall, fd_histogram_cache, framePars, FRAMEPARS_SETFRAME, G_HIST_DIM_01, G_HIST_DIM_23, G_THIS_FRAME, getPercentile(), GLOBALPARS, MDF1, P_AEXP_FRACPIX, P_VEXPOS, framepars_t::pars, PARS_FRAMES_MASK, RECALIBRATE_AFTER, RECALIBRATE_AHEAD, SEEK_SET, stderr, this_frame, and write.

Referenced by main().

int waitRequstPrevHist ( unsigned long  next_frame  ) 

Definition at line 70 of file aexp_utils.c.

References fd_fparmsall, FRAMEPARS_SETFRAME, G_THIS_FRAME, GLOBALPARS, LSEEK_FRAME_WAIT_ABS, MDF2, P_HISTRQ_YC, SEEK_END, stderr, this_frame, and write.

Referenced by main().


Generated on Fri Nov 28 00:06:41 2008 for elphel by  doxygen 1.5.1