Changeset 1049
- Timestamp:
- 01/16/11 04:34:15 (2 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 1 edited
-
CHDK/SCRIPTS/TEST/badpixel.lua (deleted)
-
core/raw.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/raw.c
r1046 r1049 59 59 60 60 #if DNG_SUPPORT 61 unsigned int get_bad_count_and_write_file(const char *fn){ 62 int count=0; 63 unsigned short c[2]; 64 FILE*f; 65 f=fopen(fn,"w+b"); 66 for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++) 67 for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++) 68 if (get_raw_pixel(c[0],c[1])==0) { fwrite(c, 1, 4, f); count++;} 69 fclose(f); 70 return count; 61 #define INIT_BADPIXEL_COUNT -1 62 #define INIT_BADPIXEL_FILE -2 63 64 int init_badpixel_bin_flag; // contants above to count/create file, > 0 num bad pixel 65 int raw_init_badpixel_bin(){ 66 int count; 67 unsigned short c[2]; 68 FILE*f; 69 if(init_badpixel_bin_flag == INIT_BADPIXEL_FILE) { 70 f=fopen(PATH_BAD_TMP_BIN,"w+b"); 71 } else if (init_badpixel_bin_flag == INIT_BADPIXEL_COUNT){ 72 f=NULL; 73 } else { 74 return 0; 75 } 76 count = 0; 77 for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++) { 78 for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++) { 79 if (get_raw_pixel(c[0],c[1])==0) { 80 if(f) { 81 fwrite(c, 1, 4, f); 82 } 83 count++; 84 } 85 } 86 } 87 if(f) { 88 fclose(f); 89 } 90 init_badpixel_bin_flag = count; 91 state_shooting_progress = SHOOTING_PROGRESS_PROCESSING; 92 return 1; 71 93 } 72 94 … … 109 131 } 110 132 } 133 #else // no DNG_SUPPORT 134 static inline int __attribute__((always_inline)) raw_init_badpixel_bin(void) {return 0;} 111 135 #endif 112 136 //------------------------------------------------------------------- … … 128 152 char* altrawadr = get_alt_raw_image_addr(); 129 153 130 // ! ! ! exclusively for badpixel creation ! ! ! 131 // NOTE: get_bad_count_and_write_file() must be called from here and cannot be called 132 // outside of this function. 133 // TODO now that we make badpixel in code, special use of save_raw is not needed 134 // also don't need to actually save a raw when making bad pixel 135 #if DNG_SUPPORT 136 if (conf.save_raw==255) conf.save_raw=get_bad_count_and_write_file(PATH_BAD_TMP_BIN); 137 #endif 138 // 154 // count/save badpixels if requested 155 if(raw_init_badpixel_bin()) { 156 return 0; 157 } 139 158 140 159 if (develop_raw) { … … 184 203 && (!((shooting_get_prop(PROPCASE_BRACKET_MODE)==1) && conf.save_raw_in_ev_bracketing)) ) 185 204 { 186 long v;187 205 int timer; char txt[30]; 188 206 … … 484 502 int badpixel_task_stack(long p) 485 503 { 486 static unsigned int badpix_cnt1, badpix_cnt2; 487 static int raw_conf_bck; 504 static unsigned int badpix_cnt1; 488 505 489 506 switch(p) … … 497 514 console_add_line("This takes a few seconds,"); 498 515 console_add_line("don't panic!"); 499 500 raw_conf_bck = conf.save_raw; 501 conf.save_raw = 255; 502 516 517 init_badpixel_bin_flag = INIT_BADPIXEL_COUNT; 518 503 519 shooting_set_tv96_direct(96, SET_LATER); 504 520 action_push(BADPIX_S1); … … 509 525 action_pop(); 510 526 511 badpix_cnt1 = conf.save_raw;512 conf.save_raw = 255;527 badpix_cnt1 = init_badpixel_bin_flag; 528 init_badpixel_bin_flag = INIT_BADPIXEL_FILE; 513 529 shooting_set_tv96_direct(96, SET_LATER); 514 530 … … 519 535 action_pop(); 520 536 521 badpix_cnt2 = conf.save_raw;522 conf.save_raw = raw_conf_bck;523 524 537 console_clear(); 525 if (badpix_cnt1 == badpix_cnt2)538 if (badpix_cnt1 == init_badpixel_bin_flag) 526 539 { 527 540 // TODO script asked confirmation first … … 540 553 console_add_line("Please try again."); 541 554 } 555 init_badpixel_bin_flag = 0; 542 556 DeleteFile_Fut(PATH_BAD_TMP_BIN); 543 557 … … 548 562 break; 549 563 } 550 564 551 565 return 1; 552 566 }
Note: See TracChangeset
for help on using the changeset viewer.