Changeset 1049


Ignore:
Timestamp:
01/16/11 04:34:15 (2 years ago)
Author:
reyalP
Message:

remove support for creating badpixel.bin with lua, remove badpixel.lua, don't write file twice

Location:
trunk
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/raw.c

    r1046 r1049  
    5959 
    6060#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 
     64int init_badpixel_bin_flag; // contants above to count/create file, > 0 num bad pixel 
     65int 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; 
    7193} 
    7294 
     
    109131   } 
    110132} 
     133#else // no DNG_SUPPORT 
     134static inline int __attribute__((always_inline)) raw_init_badpixel_bin(void) {return 0;} 
    111135#endif 
    112136//------------------------------------------------------------------- 
     
    128152    char* altrawadr = get_alt_raw_image_addr(); 
    129153 
    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    } 
    139158 
    140159    if (develop_raw) { 
     
    184203        && (!((shooting_get_prop(PROPCASE_BRACKET_MODE)==1) && conf.save_raw_in_ev_bracketing)) ) 
    185204    { 
    186         long v; 
    187205        int timer; char txt[30]; 
    188206 
     
    484502int badpixel_task_stack(long p) 
    485503{ 
    486     static unsigned int badpix_cnt1, badpix_cnt2; 
    487     static int raw_conf_bck; 
     504    static unsigned int badpix_cnt1; 
    488505 
    489506    switch(p) 
     
    497514        console_add_line("This takes a few seconds,"); 
    498515        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 
    503519        shooting_set_tv96_direct(96, SET_LATER); 
    504520        action_push(BADPIX_S1); 
     
    509525        action_pop();         
    510526 
    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; 
    513529        shooting_set_tv96_direct(96, SET_LATER); 
    514530 
     
    519535        action_pop(); 
    520536 
    521         badpix_cnt2 = conf.save_raw; 
    522         conf.save_raw = raw_conf_bck; 
    523  
    524537        console_clear(); 
    525         if (badpix_cnt1 == badpix_cnt2) 
     538        if (badpix_cnt1 == init_badpixel_bin_flag) 
    526539        { 
    527540            // TODO script asked confirmation first 
     
    540553            console_add_line("Please try again."); 
    541554        } 
     555        init_badpixel_bin_flag = 0; 
    542556        DeleteFile_Fut(PATH_BAD_TMP_BIN); 
    543557 
     
    548562        break; 
    549563    } 
    550     
     564 
    551565    return 1; 
    552566} 
Note: See TracChangeset for help on using the changeset viewer.