CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
autoiso.c-Dateireferenz
#include "stdlib.h"
#include "camera_info.h"
#include "math.h"
#include "conf.h"
#include "viewport.h"
#include "shooting.h"
#include "modes.h"
#include "lens.h"
+ Include-Abhängigkeitsdiagramm für autoiso.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define HISTO_STEP_SIZE   6
 
#define HISTO_BLOCK_BYTES   6
 
#define HISTO_BLOCK_SCALE   2
 

Funktionen

int live_histogram_read_y (unsigned short *h)
 
static int live_histogram_get_range (int total, int from, int to)
 
static void shooting_calc_autoiso_coef (int min_shutter)
 
static void shooting_recalc_conf_autoiso_values ()
 
void shooting_set_autoiso (int iso_mode)
 

Variablen

static unsigned short live_histogram_proc [256]
 
static const int shutter1_values [] = { 0, 2, 4, 6, 8, 15, 30, 60, 125, 250, 500, 1000, 2000 }
 
static const int shutter2_values [] = { 0, 1, 2, 4, 6, 8, 12, 15, 20, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 500, 1000, 2000 }
 

Makro-Dokumentation

#define HISTO_BLOCK_BYTES   6

Definiert in Zeile 33 der Datei autoiso.c.

#define HISTO_BLOCK_SCALE   2

Definiert in Zeile 39 der Datei autoiso.c.

#define HISTO_STEP_SIZE   6

Definiert in Zeile 31 der Datei autoiso.c.

Dokumentation der Funktionen

static int live_histogram_get_range ( int  total,
int  from,
int  to 
)
static

Definiert in Zeile 76 der Datei autoiso.c.

77 {
78  if (from < 0) from = 0;
79  if (to > 255) to = 255;
80 
81  int rv = 0;
82  for(; from<=to; from++)
83  rv += live_histogram_proc[from];
84 
85  return (rv * 100) / total;
86 }
int live_histogram_read_y ( unsigned short *  h)

Definiert in Zeile 47 der Datei autoiso.c.

48 {
49  int total;
50 
51  int vp_width = vid_get_viewport_width();
52  int vp_height = vid_get_viewport_height();
53  int vp_offset = vid_get_viewport_row_offset();
54 
55  total = (vp_width * vp_height) / (HISTO_STEP_SIZE * HISTO_BLOCK_SCALE);
56  memset(h, 0, sizeof(unsigned short)*256);
57 
58  unsigned char *img = vid_get_viewport_active_buffer();
59  if (!img) return total;
60 
61  img += vid_get_viewport_image_offset() + 1;
62 
63  int y;
64  for (y=0; y<vp_height; y++, img += vp_offset)
65  {
66  int x;
67  for (x=0; x<vp_width; x += HISTO_STEP_SIZE*HISTO_BLOCK_SCALE, img+=HISTO_STEP_SIZE*HISTO_BLOCK_BYTES)
68  {
69  ++h[*img];
70  }
71  }
72 
73  return total;
74 }
static void shooting_calc_autoiso_coef ( int  min_shutter)
static

Definiert in Zeile 93 der Datei autoiso.c.

94 {
95  if (shutter2_values[conf.autoiso2_shutter_enum] >= min_shutter)
96  {
97  conf.autoiso2_coef = 0.0;
98  }
99  else
100  {
102  (float)( shutter2_values[conf.autoiso2_shutter_enum] - min_shutter);
103  }
104 }
static void shooting_recalc_conf_autoiso_values ( )
static

Definiert in Zeile 106 der Datei autoiso.c.

107 {
108  // convert market to real iso
113 
114  // There are two exceptional situation:
115  // 1. shutter_numerator2 should be < shutter_numerator1, otherwise exceptional situation
116  // 2. autoiso2 <= autoiso1
119 
120  // C2=( iso2_max_auto_real - iso_max_auto_real) / ( tv_num[autoiso2_shutter] - tv_numerator[autoiso_shutter])
122 }
void shooting_set_autoiso ( int  iso_mode)

Definiert in Zeile 124 der Datei autoiso.c.

125 {
126  short max_iso;
127 
128  if (iso_mode<=0)
130 
131  switch (iso_mode)
132  {
133  case -1: // ISO HI
134  //max_iso = conf.autoiso_max_iso_hi*10;
135  max_iso = conf.autoiso_max_iso_hi_real;
136  break;
137  case 0: // ISO AUTO
138  //max_iso = conf.autoiso_max_iso_auto*10;
140  break;
141  default:
142  return;
143  }
144 
145  // TODO also long shutter ?
147  return; //Only operate outside of M and Tv
148 
149  int ev_overexp = 0;
150  if (conf.overexp_ev_enum)
151  {
152  // No shoot_histogram exist here because no future shot exist yet :)
154 
155  // step 32 is 1/3ev for tv96
157  ev_overexp = conf.overexp_ev_enum << 5;
158  }
159 
160  float current_shutter = shooting_get_shutter_speed_from_tv96(shooting_get_tv96());
161 
162  short current_iso = shooting_get_iso_real();
163 
164  short min_shutter = shutter1_values[conf.autoiso_shutter_enum];
165  if (min_shutter == 0)
166  {
167  short IS_factor = (shooting_get_is_mode()<=1)?conf.autoiso_is_factor:1;
168  min_shutter = get_focal_length(lens_get_zoom_point())*conf.autoiso_user_factor / (IS_factor*1000);
169  //min_shutter is NOT 1/Xs but optimized for the calculation.
171  shooting_calc_autoiso_coef( min_shutter );
172  }
173 
174  short target_iso = current_iso * min_shutter * current_shutter;
175  short min_iso = conf.autoiso_min_iso_real;
176 
177  if (target_iso > max_iso)
178  {
179  ev_overexp=0;
180 
181  // AutoISO2 if
182  // it is turned on (C2!=0.0)
183  // and it has valid iso2/shutter2 ( C2<0)
184  // and non-IsoHI mode
185  if ( !iso_mode && conf.autoiso2_coef < 0.0 )
186  {
187  target_iso = (max_iso - min_shutter*conf.autoiso2_coef) / ( 1.0 - conf.autoiso2_coef / (current_shutter * current_iso) );
188  if ( target_iso > conf.autoiso2_max_iso_auto_real )
189  target_iso = conf.autoiso2_max_iso_auto_real;
190  }
191  else
192  {
193  target_iso = max_iso;
194  }
195  }
196  else if (target_iso < min_iso)
197  {
198  target_iso = min_iso;
199  }
200 
201  float target_shutter = current_shutter * current_iso / target_iso;
202 
203  if (target_shutter > 0)
205 
206  shooting_set_iso_real(target_iso, SET_NOW);
207 }

Variablen-Dokumentation

unsigned short live_histogram_proc[256]
static

Definiert in Zeile 41 der Datei autoiso.c.

const int shutter1_values[] = { 0, 2, 4, 6, 8, 15, 30, 60, 125, 250, 500, 1000, 2000 }
static

Definiert in Zeile 90 der Datei autoiso.c.

const int shutter2_values[] = { 0, 1, 2, 4, 6, 8, 12, 15, 20, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 500, 1000, 2000 }
static

Definiert in Zeile 91 der Datei autoiso.c.