CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
raw.h-Dateireferenz
+ Dieser Graph zeigt, welche Datei direkt oder indirekt diese Datei enthält:

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define RAW_PREFIX_IMG   0
 
#define RAW_PREFIX_CRW   1
 
#define RAW_PREFIX_SND   2
 
#define RAW_EXT_JPG   0
 
#define RAW_EXT_CRW   1
 
#define RAW_EXT_CR2   2
 
#define RAW_EXT_THM   3
 
#define RAW_EXT_WAV   4
 

Funktionen

void raw_process (void)
 
void raw_prepare_develop (const char *filename, int prompt)
 
int make_pixel_list (char *ptr, int size)
 
unsigned short get_raw_pixel (unsigned int x, unsigned int y)
 
void set_raw_pixel (unsigned int x, unsigned int y, unsigned short v)
 
char * get_raw_image_addr (void)
 
void patch_bad_pixel (unsigned int x, unsigned int y)
 
int raw_createfile (void)
 
void raw_closefile (int fd)
 
void raw_get_path (char *path)
 

Makro-Dokumentation

#define RAW_EXT_CR2   2

Definiert in Zeile 16 der Datei raw.h.

#define RAW_EXT_CRW   1

Definiert in Zeile 15 der Datei raw.h.

#define RAW_EXT_JPG   0

Definiert in Zeile 14 der Datei raw.h.

#define RAW_EXT_THM   3

Definiert in Zeile 17 der Datei raw.h.

#define RAW_EXT_WAV   4

Definiert in Zeile 18 der Datei raw.h.

#define RAW_PREFIX_CRW   1

Definiert in Zeile 11 der Datei raw.h.

#define RAW_PREFIX_IMG   0

Definiert in Zeile 10 der Datei raw.h.

#define RAW_PREFIX_SND   2

Definiert in Zeile 12 der Datei raw.h.

Dokumentation der Funktionen

char* get_raw_image_addr ( void  )

Definiert in Zeile 59 der Datei raw.c.

59  {
60  char *r=hook_raw_image_addr();
61  if (!conf.raw_cache) return r;
62  else return ADR_TO_CACHED(r);
63 }
unsigned short get_raw_pixel ( unsigned int  x,
unsigned int  y 
)

Definiert in Zeile 327 der Datei raw.c.

327  {
328 #if CAM_SENSOR_BITS_PER_PIXEL==10
329  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*10;
330  switch (x%8) {
331  case 0: return ((0x3fc&(((unsigned short)addr[1])<<2)) | (addr[0] >> 6));
332  case 1: return ((0x3f0&(((unsigned short)addr[0])<<4)) | (addr[3] >> 4));
333  case 2: return ((0x3c0&(((unsigned short)addr[3])<<6)) | (addr[2] >> 2));
334  case 3: return ((0x300&(((unsigned short)addr[2])<<8)) | (addr[5]));
335  case 4: return ((0x3fc&(((unsigned short)addr[4])<<2)) | (addr[7] >> 6));
336  case 5: return ((0x3f0&(((unsigned short)addr[7])<<4)) | (addr[6] >> 4));
337  case 6: return ((0x3c0&(((unsigned short)addr[6])<<6)) | (addr[9] >> 2));
338  case 7: return ((0x300&(((unsigned short)addr[9])<<8)) | (addr[8]));
339  }
340 #elif CAM_SENSOR_BITS_PER_PIXEL==12
341  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/4)*6;
342  switch (x%4) {
343  case 0: return ((unsigned short)(addr[1]) << 4) | (addr[0] >> 4);
344  case 1: return ((unsigned short)(addr[0] & 0x0F) << 8) | (addr[3]);
345  case 2: return ((unsigned short)(addr[2]) << 4) | (addr[5] >> 4);
346  case 3: return ((unsigned short)(addr[5] & 0x0F) << 8) | (addr[4]);
347  }
348 #elif CAM_SENSOR_BITS_PER_PIXEL==14
349  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*14;
350  switch (x%8) {
351  case 0: return ((unsigned short)(addr[ 1]) << 6) | (addr[ 0] >> 2);
352  case 1: return ((unsigned short)(addr[ 0] & 0x03) << 12) | (addr[ 3] << 4) | (addr[ 2] >> 4);
353  case 2: return ((unsigned short)(addr[ 2] & 0x0F) << 10) | (addr[ 5] << 2) | (addr[ 4] >> 6);
354  case 3: return ((unsigned short)(addr[ 4] & 0x3F) << 8) | (addr[ 7]);
355  case 4: return ((unsigned short)(addr[ 6]) << 6) | (addr[ 9] >> 2);
356  case 5: return ((unsigned short)(addr[ 9] & 0x03) << 12) | (addr[ 8] << 4) | (addr[11] >> 4);
357  case 6: return ((unsigned short)(addr[11] & 0x0F) << 10) | (addr[10] << 2) | (addr[13] >> 6);
358  case 7: return ((unsigned short)(addr[13] & 0x3F) << 8) | (addr[12]);
359  }
360 #else
361  #error define get_raw_pixel for sensor bit depth
362 #endif
363  return 0;
364 }
int make_pixel_list ( char *  ptr,
int  size 
)

Definiert in Zeile 400 der Datei raw.c.

400  {
401  int x,y;
402  struct point *pixel;
403  char *endptr;
404 
405  if ( size <=0 ) return 0;
406 
407  while(*ptr) {
408  while (*ptr==' ' || *ptr=='\t') ++ptr; // whitespaces
409  x=strtol(ptr, &endptr, 0);
410  if (endptr != ptr) {
411  ptr = endptr;
412  if (*ptr++==',') {
413  while (*ptr==' ' || *ptr=='\t') ++ptr; // whitespaces
414  if (*ptr!='\n' && *ptr!='\r') {
415  y=strtol(ptr, &endptr, 0);
416  if (endptr != ptr) {
417  ptr = endptr;
418  pixel=malloc(sizeof(struct point));
419  if (pixel) {
420  (*pixel).x=x;
421  (*pixel).y=y;
422  (*pixel).next=pixel_list;
423  pixel_list=pixel;
424  }
425  }
426  }
427  }
428  }
429  while (*ptr && *ptr!='\n') ++ptr; // unless end of line
430  if (*ptr) ++ptr;
431  }
432  return 0;
433 }
void patch_bad_pixel ( unsigned int  x,
unsigned int  y 
)

Definiert in Zeile 367 der Datei raw.c.

367  {
368  int sum=0;
369  int nzero=0;
370  int i,j;
371  int val;
372  if ((x>=2) && (x<camera_sensor.raw_rowpix-2) && (y>=2) && (y<camera_sensor.raw_rows-2)) {
373  if ((conf.bad_pixel_removal==1) || (conf.save_raw && conf.dng_raw)) { // interpolation or DNG saving
374  for (i=-2; i<=2; i+=2)
375  for (j=-2; j<=2; j+=2)
376  if ((i!=0) && (j!=0)) {
377  val=get_raw_pixel(x+i, y+j);
378  if (val) {sum+=val; nzero++;}
379  }
380  if (nzero) set_raw_pixel(x,y,sum/nzero);
381  } else if (conf.bad_pixel_removal==2) // or this makes RAW converter (internal/external)
382  set_raw_pixel(x,y,0);
383  }
384 }
void raw_closefile ( int  fd)

Definiert in Zeile 141 der Datei raw.c.

142 {
143  if(fd < 0) {
144  return;
145  }
146 
147  struct utimbuf t;
148  t.actime = t.modtime = raw_create_time;
149  close(fd);
150  utime(fn, &t);
151 
152 }
int raw_createfile ( void  )

Definiert in Zeile 107 der Datei raw.c.

108 {
109  int fd;
110 
111  // fail if less than one raw + jpeg space free
112  if(GetRawCount() < 1) {
113  return -1;
114  }
116 
117  raw_get_path(fn);
118 
120  sprintf(fn+strlen(fn),
126  } else {
127  sprintf(fn+strlen(fn),
132  }
133  fd = open(fn, O_WRONLY|O_CREAT, 0777);
134 
135  return fd;
136 }
void raw_get_path ( char *  path)

Definiert in Zeile 72 der Datei raw.c.

73 {
74  char rdir[32];
75 
76  switch ( conf.raw_in_dir )
77  {
78  case 2:
79  strcpy(path,"A/RAW");
80  mkdir_if_not_exist(path);
81  get_target_dir_name(rdir);
82  strcat(path, &rdir[6]) ;
83  break ;
84  case 1:
85  mkdir_if_not_exist("A/DCIM");
86  get_target_dir_name(path);
87  break ;
88  default:
89  mkdir_if_not_exist("A/DCIM");
91  break ;
92  }
93  mkdir_if_not_exist(path);
94  strcat(path, "/");
95 }
void raw_prepare_develop ( const char *  filename,
int  prompt 
)

Definiert in Zeile 37 der Datei raw.c.

38 {
40  if (filename)
41  {
42  struct stat st;
43  if ((stat(filename,&st) != 0) || (st.st_size < camera_sensor.raw_size))
44  return;
45  if (prompt)
47  if (st.st_size == camera_sensor.raw_size)
49  else
51  strcpy(fn,filename);
52  }
53 }
void raw_process ( void  )

Definiert in Zeile 191 der Datei raw.c.

192 {
193  // Get pointers to RAW buffers (will be the same on cameras that don't have two or more buffers)
195  char *altrawadr = get_alt_raw_image_addr();
196 
197 #if defined(CAM_CALC_BLACK_LEVEL)
198  int v1 = get_raw_pixel(4, 4);
199  int v2 = get_raw_pixel(4, 5);
200  int v3 = get_raw_pixel(5, 4);
201  int v4 = get_raw_pixel(5, 5);
202  int raw_calc_black_level = (v1 + v2 + v3 + v4) / 4;
203  if (raw_calc_black_level > CAM_BLACK_LEVEL * 2)
204  camera_sensor.black_level = raw_calc_black_level;
205  else
207 #endif
208 
209  if ((conf.save_raw && conf.dng_raw && is_raw_enabled())
211  {
213  }
214 
217 
219 
220  // count/save badpixels if requested
222  {
223  return;
224  }
225 
227  {
228  started();
230  {
232  }
233  else
234  {
235  int fd = open(fn, O_RDONLY, 0777);
236  if (fd >= 0) {
238  close(fd);
239  }
240  }
241 #ifdef OPT_CURVES
242  if (conf.curve_enable)
244 #endif
245  finished();
247  return;
248  }
249 
251 
253 
255  {
257  raw_br_counter = 1;
258  else
259  raw_br_counter++;
260  }
261  else
262  raw_br_counter=0;
263 
264  // if any remote cap targets, skip local raw
265  if (remotecap_get_target())
266  {
269  }
271  {
273 
274  if (conf.save_raw && is_raw_enabled())
275  {
276  raw_savefile(rawadr,altrawadr);
277  }
278  }
279 
280 #ifdef OPT_CURVES
281  if (conf.curve_enable)
283 #endif
284 }
void set_raw_pixel ( unsigned int  x,
unsigned int  y,
unsigned short  v 
)

Definiert in Zeile 288 der Datei raw.c.

288  {
289 #if CAM_SENSOR_BITS_PER_PIXEL==10
290  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*10;
291  switch (x%8) {
292  case 0: addr[0]=(addr[0]&0x3F)|(value<<6); addr[1]=value>>2; break;
293  case 1: addr[0]=(addr[0]&0xC0)|(value>>4); addr[3]=(addr[3]&0x0F)|(value<<4); break;
294  case 2: addr[2]=(addr[2]&0x03)|(value<<2); addr[3]=(addr[3]&0xF0)|(value>>6); break;
295  case 3: addr[2]=(addr[2]&0xFC)|(value>>8); addr[5]=value; break;
296  case 4: addr[4]=value>>2; addr[7]=(addr[7]&0x3F)|(value<<6); break;
297  case 5: addr[6]=(addr[6]&0x0F)|(value<<4); addr[7]=(addr[7]&0xC0)|(value>>4); break;
298  case 6: addr[6]=(addr[6]&0xF0)|(value>>6); addr[9]=(addr[9]&0x03)|(value<<2); break;
299  case 7: addr[8]=value; addr[9]=(addr[9]&0xFC)|(value>>8); break;
300  }
301 #elif CAM_SENSOR_BITS_PER_PIXEL==12
302  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/4)*6;
303  switch (x%4) {
304  case 0: addr[0] = (addr[0]&0x0F) | (unsigned char)(value << 4); addr[1] = (unsigned char)(value >> 4); break;
305  case 1: addr[0] = (addr[0]&0xF0) | (unsigned char)(value >> 8); addr[3] = (unsigned char)value; break;
306  case 2: addr[2] = (unsigned char)(value >> 4); addr[5] = (addr[5]&0x0F) | (unsigned char)(value << 4); break;
307  case 3: addr[4] = (unsigned char)value; addr[5] = (addr[5]&0xF0) | (unsigned char)(value >> 8); break;
308  }
309 #elif CAM_SENSOR_BITS_PER_PIXEL==14
310  unsigned char* addr=(unsigned char*)rawadr+y*camera_sensor.raw_rowlen+(x/8)*14;
311  switch (x%8) {
312  case 0: addr[ 0]=(addr[0]&0x03)|(value<< 2); addr[ 1]=value>>6; break;
313  case 1: addr[ 0]=(addr[0]&0xFC)|(value>>12); addr[ 2]=(addr[ 2]&0x0F)|(value<< 4); addr[ 3]=value>>4; break;
314  case 2: addr[ 2]=(addr[2]&0xF0)|(value>>10); addr[ 4]=(addr[ 4]&0x3F)|(value<< 6); addr[ 5]=value>>2; break;
315  case 3: addr[ 4]=(addr[4]&0xC0)|(value>> 8); addr[ 7]=value; break;
316  case 4: addr[ 6]=value>>6; addr[ 9]=(addr[ 9]&0x03)|(value<< 2); break;
317  case 5: addr[ 8]=value>>4; addr[ 9]=(addr[ 9]&0xFC)|(value>>12); addr[11]=(addr[11]&0x0F)|(value<<4); break;
318  case 6: addr[10]=value>>2; addr[11]=(addr[11]&0xF0)|(value>>10); addr[13]=(addr[13]&0x3F)|(value<<6); break;
319  case 7: addr[12]=value; addr[13]=(addr[13]&0xC0)|(value>> 8); break;
320  }
321 #else
322  #error define set_raw_pixel for sensor bit depth
323 #endif
324 }