CHDK_DE Vorschauversion  Trunk Rev. 5836
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
shot_histogram.c-Dateireferenz
#include "camera_info.h"
#include "conf.h"
#include "shot_histogram.h"
#include "raw.h"
#include "file_counter.h"
+ Include-Abhängigkeitsdiagramm für shot_histogram.c:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define SHOT_HISTOGRAM_STEP   31
 
#define SHOT_HISTOGRAM_SAMPLES   1024
 
#define SHOT_HISTOGRAM_SIZE   (SHOT_HISTOGRAM_SAMPLES*sizeof(short))
 

Funktionen

int shot_histogram_set (int enable)
 
void build_shot_histogram ()
 
void write_to_file ()
 
int shot_histogram_get_range (int histo_from, int histo_to)
 
int _module_loader ()
 
int _module_unloader ()
 
int _module_can_unload ()
 

Variablen

int running = 0
 
unsigned short shot_histogram [SHOT_HISTOGRAM_SAMPLES]
 
unsigned short shot_margin_left = 0
 
unsigned short shot_margin_top = 0
 
unsigned short shot_margin_right = 0
 
unsigned short shot_margin_bottom = 0
 
libshothisto_sym _libshothisto
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define SHOT_HISTOGRAM_SAMPLES   1024

Definiert in Zeile 10 der Datei shot_histogram.c.

#define SHOT_HISTOGRAM_SIZE   (SHOT_HISTOGRAM_SAMPLES*sizeof(short))

Definiert in Zeile 11 der Datei shot_histogram.c.

#define SHOT_HISTOGRAM_STEP   31

Definiert in Zeile 7 der Datei shot_histogram.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 132 der Datei shot_histogram.c.

133 {
134  return running == 0;
135 }
int _module_loader ( )

Definiert in Zeile 121 der Datei shot_histogram.c.

122 {
123  running = 1;
124  return 0;
125 }
int _module_unloader ( )

Definiert in Zeile 127 der Datei shot_histogram.c.

128 {
129  return 0;
130 }
void build_shot_histogram ( )

Definiert in Zeile 31 der Datei shot_histogram.c.

32 {
33  // read samples from RAW memory and build an histogram of its luminosity
34  // actually, it' just reading pixels, ignoring difference between R, G and B,
35  // we just need an estimate of luminance
36  if (!running)
37  return;
38 
39  int x, y, x0, x1, y0, y1;
40 
41  short p;
43 
44  // Use sensor active area only
47 
48  // In future, support definition of a sort of "spot metering"
49  x0 = camera_sensor.active_area.x1 + ((shot_margin_left * width) / 10);
50  x1 = camera_sensor.active_area.x2 - ((shot_margin_right * width) / 10);
51  y0 = camera_sensor.active_area.y1 + ((shot_margin_top * height) / 10);
53 
54  // just read one pixel out of SHOT_HISTOGRAM_STEP, one line out of SHOT_HISTOGRAM_STEP
55  if (camera_sensor.bits_per_pixel == 10)
56  {
57  for (y = y0; y < y1; y += SHOT_HISTOGRAM_STEP)
58  for (x = x0; x < x1; x += SHOT_HISTOGRAM_STEP)
59  {
60  p = get_raw_pixel(x,y);
61  shot_histogram[p]++;
62  }
63  }
64  else
65  {
66  // > 10bpp compatibility: discard the lowest N bits
67  int shift = (camera_sensor.bits_per_pixel - 10);
68  for (y = y0; y < y1; y += SHOT_HISTOGRAM_STEP )
69  for (x = x0; x < x1; x += SHOT_HISTOGRAM_STEP )
70  {
71  p = get_raw_pixel(x,y) >> shift;
72  shot_histogram[p]++;
73  }
74  }
75 }
int shot_histogram_get_range ( int  histo_from,
int  histo_to 
)

Definiert in Zeile 97 der Datei shot_histogram.c.

98 {
99  // Examines the histogram, and returns the percentage of pixels that
100  // have luminance between histo_from and histo_to
101  int x, tot, rng;
102  tot=0;
103  rng=0;
104 
105  if (!running)
106  return -1;
107 
108  for (x = 0 ; x < SHOT_HISTOGRAM_SAMPLES; x++)
109  {
110  tot += shot_histogram[x];
111  if (x>=histo_from && x <= histo_to)
112  {
113  rng += shot_histogram[x];
114  }
115  }
116 
117  return (rng*100+tot/2)/tot;
118 }
int shot_histogram_set ( int  enable)

Definiert in Zeile 22 der Datei shot_histogram.c.

23 {
24  // If turning shot histogram off, mark module as unloadable
25  if (!enable)
26  running = 0;
27 
28  return 1;
29 }
void write_to_file ( )

Definiert in Zeile 77 der Datei shot_histogram.c.

78 {
79  // dump last histogram to file
80  // for each shoot, creates a HST_nnnn.DAT file containing 2*1024 bytes
81 
82  char fn[64];
83 
84  // Get path to save raw files
85  raw_get_path(fn);
86 
87  sprintf(fn+strlen(fn), "HST_%04d.DAT", get_target_file_num());
88 
89  int fd = open(fn, O_WRONLY|O_CREAT, 0777);
90  if (fd >= 0)
91  {
93  close(fd);
94  }
95 }

Variablen-Dokumentation

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 151 der Datei shot_histogram.c.

int running = 0

Definiert in Zeile 13 der Datei shot_histogram.c.

unsigned short shot_histogram[SHOT_HISTOGRAM_SAMPLES]

Definiert in Zeile 16 der Datei shot_histogram.c.

unsigned short shot_margin_bottom = 0

Definiert in Zeile 19 der Datei shot_histogram.c.

unsigned short shot_margin_left = 0

Definiert in Zeile 19 der Datei shot_histogram.c.

unsigned short shot_margin_right = 0

Definiert in Zeile 19 der Datei shot_histogram.c.

unsigned short shot_margin_top = 0

Definiert in Zeile 19 der Datei shot_histogram.c.