CHDK_DE Vorschauversion  Trunk Rev. 5777
 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 58 der Datei raw.c.

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

Definiert in Zeile 326 der Datei raw.c.

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

Definiert in Zeile 399 der Datei raw.c.

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

Definiert in Zeile 366 der Datei raw.c.

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

Definiert in Zeile 140 der Datei raw.c.

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

Definiert in Zeile 106 der Datei raw.c.

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

Definiert in Zeile 71 der Datei raw.c.

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

Definiert in Zeile 36 der Datei raw.c.

37 {
39  if (filename)
40  {
41  struct stat st;
42  if ((stat(filename,&st) != 0) || (st.st_size < camera_sensor.raw_size))
43  return;
44  if (prompt)
46  if (st.st_size == camera_sensor.raw_size)
48  else
50  strcpy(fn,filename);
51  }
52 }
void raw_process ( void  )

Definiert in Zeile 190 der Datei raw.c.

191 {
192  // Get pointers to RAW buffers (will be the same on cameras that don't have two or more buffers)
194  char *altrawadr = get_alt_raw_image_addr();
195 
196 #if defined(CAM_CALC_BLACK_LEVEL)
197  int v1 = get_raw_pixel(4, 4);
198  int v2 = get_raw_pixel(4, 5);
199  int v3 = get_raw_pixel(5, 4);
200  int v4 = get_raw_pixel(5, 5);
201  int raw_calc_black_level = (v1 + v2 + v3 + v4) / 4;
202  if (raw_calc_black_level > CAM_BLACK_LEVEL * 2)
203  camera_sensor.black_level = raw_calc_black_level;
204  else
206 #endif
207 
208  if ((conf.save_raw && conf.dng_raw && is_raw_enabled())
210  {
212  }
213 
216 
218 
219  // count/save badpixels if requested
221  {
222  return;
223  }
224 
226  {
227  started();
229  {
231  }
232  else
233  {
234  int fd = open(fn, O_RDONLY, 0777);
235  if (fd >= 0) {
237  close(fd);
238  }
239  }
240 #ifdef OPT_CURVES
241  if (conf.curve_enable)
243 #endif
244  finished();
246  return;
247  }
248 
250 
252 
254  {
256  raw_br_counter = 1;
257  else
258  raw_br_counter++;
259  }
260  else
261  raw_br_counter=0;
262 
263  // if any remote cap targets, skip local raw
264  if (remotecap_get_target())
265  {
268  }
270  {
272 
273  if (conf.save_raw && is_raw_enabled())
274  {
275  raw_savefile(rawadr,altrawadr);
276  }
277  }
278 
279 #ifdef OPT_CURVES
280  if (conf.curve_enable)
282 #endif
283 }
void set_raw_pixel ( unsigned int  x,
unsigned int  y,
unsigned short  v 
)

Definiert in Zeile 287 der Datei raw.c.

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