CHDK_DE Vorschauversion  Trunk Rev. 5905
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
autoiso.c-Dateireferenz
#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   36
 

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_STEP_SIZE   36

Definiert in Zeile 29 der Datei autoiso.c.

Dokumentation der Funktionen

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

Definiert in Zeile 73 der Datei autoiso.c.

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

Definiert in Zeile 38 der Datei autoiso.c.

39 {
40  int yscale = vid_get_viewport_yscale(); // Y scale factor (2 for 480 line high lv buffer)
41 #ifdef THUMB_FW
42  int vp_width = vid_get_viewport_width_proper() * 2; // X bytes per row
43 #else
44  int vp_width = vid_get_viewport_width_proper() * 6 / 4; // X bytes per row
45 #endif
46  int vp_height = vid_get_viewport_height_proper() / yscale; // Number of rows to process (every second row if 480 high lv buffer)
47 
48  int total = (vp_width * vp_height) / HISTO_STEP_SIZE;
49 
50  unsigned char *img = vid_get_viewport_active_buffer();
51  if (img)
52  {
53  if (h == 0) h = live_histogram_proc;
54  memset(h, 0, sizeof(unsigned short)*256);
55 
56  int vp_offset = vid_get_viewport_byte_width() * yscale; // Bytes length of each row (or double row)
57  img += vid_get_viewport_image_offset() + 1; // Skip border and move to 1st Y component in each block
58 
59  int x, y;
60  for (y=0; y<vp_height; y+=1, img+=vp_offset)
61  {
62  for (x=HISTO_STEP_SIZE/2; x<vp_width; x+=HISTO_STEP_SIZE)
63  {
64  h[img[x]] += 1;
65 // img[x] = img[x+2] = 255; // Change sampled values on screen for debugging
66  }
67  }
68  }
69 
70  return total;
71 }
static void shooting_calc_autoiso_coef ( int  min_shutter)
static

Definiert in Zeile 90 der Datei autoiso.c.

91 {
92  if (shutter2_values[conf.autoiso2_shutter_enum] >= min_shutter)
93  {
94  conf.autoiso2_coef = 0.0;
95  }
96  else
97  {
99  (float)( shutter2_values[conf.autoiso2_shutter_enum] - min_shutter);
100  }
101 }
static void shooting_recalc_conf_autoiso_values ( )
static

Definiert in Zeile 103 der Datei autoiso.c.

104 {
105  // convert market to real iso
110 
111  // There are two exceptional situation:
112  // 1. shutter_numerator2 should be < shutter_numerator1, otherwise exceptional situation
113  // 2. autoiso2 <= autoiso1
116 
117  // C2=( iso2_max_auto_real - iso_max_auto_real) / ( tv_num[autoiso2_shutter] - tv_numerator[autoiso_shutter])
119 }
void shooting_set_autoiso ( int  iso_mode)

Definiert in Zeile 121 der Datei autoiso.c.

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

Variablen-Dokumentation

unsigned short live_histogram_proc[256]
static

Definiert in Zeile 32 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 87 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 88 der Datei autoiso.c.