CHDK_DE Vorschauversion  Trunk Rev. 5279
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
shot_histogram.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.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 11 der Datei shot_histogram.c.

#define SHOT_HISTOGRAM_SIZE   (SHOT_HISTOGRAM_SAMPLES*sizeof(short))

Definiert in Zeile 12 der Datei shot_histogram.c.

#define SHOT_HISTOGRAM_STEP   31

Definiert in Zeile 8 der Datei shot_histogram.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 133 der Datei shot_histogram.c.

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

Definiert in Zeile 122 der Datei shot_histogram.c.

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

Definiert in Zeile 128 der Datei shot_histogram.c.

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

Definiert in Zeile 32 der Datei shot_histogram.c.

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

Definiert in Zeile 98 der Datei shot_histogram.c.

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

Definiert in Zeile 23 der Datei shot_histogram.c.

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

Definiert in Zeile 78 der Datei shot_histogram.c.

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

Variablen-Dokumentation

ModuleInfo _module_info
int running = 0

Definiert in Zeile 14 der Datei shot_histogram.c.

unsigned short shot_histogram[SHOT_HISTOGRAM_SAMPLES]

Definiert in Zeile 17 der Datei shot_histogram.c.

unsigned short shot_margin_bottom = 0

Definiert in Zeile 20 der Datei shot_histogram.c.

unsigned short shot_margin_left = 0

Definiert in Zeile 20 der Datei shot_histogram.c.

unsigned short shot_margin_right = 0

Definiert in Zeile 20 der Datei shot_histogram.c.

unsigned short shot_margin_top = 0

Definiert in Zeile 20 der Datei shot_histogram.c.