Changeset 1498


Ignore:
Timestamp:
12/22/11 20:48:32 (17 months ago)
Author:
tsv
Message:

Flat modules branch update:

  • Fix IO function wrappers
  • Reconciled to trunk1497
  • Fixed some forgotten in previous reconcilation changes
Location:
branches/reyalp-flt
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/reyalp-flt/core/conf.c

    r1493 r1498  
    66#include "camera.h" 
    77#include "raw.h" 
     8#include "dng.h" 
    89#include "gui_draw.h" 
    910#include "gui_osd.h" 
  • branches/reyalp-flt/core/dng.c

    r1460 r1498  
    66#include "string.h" 
    77#include "platform.h" 
     8#include "conf.h" 
    89#include "math.h" 
     10#include "console.h" 
    911#include "dng.h" 
     12#include "raw.h" 
     13#include "action_stack.h" 
     14#include "gui_mbox.h" 
     15#include "gui_lang.h" 
     16 
     17//thumbnail 
     18#define DNG_TH_WIDTH 128 
     19#define DNG_TH_HEIGHT 96 
     20// higly recommended that DNG_TH_WIDTH*DNG_TH_HEIGHT would be divisible by 512 
     21 
     22struct dir_entry{unsigned short tag; unsigned short type; unsigned int count; unsigned int offset;}; 
     23 
     24#define T_BYTE 1 
     25#define T_ASCII 2 
     26#define T_SHORT 3 
     27#define T_LONG 4 
     28#define T_RATIONAL 5 
     29#define T_SBYTE 6 
     30#define T_UNDEFINED 7 
     31#define T_SSHORT 8 
     32#define T_SLONG 9 
     33#define T_SRATIONAL 10 
     34#define T_FLOAT 11 
     35#define T_DOUBLE 12 
     36 
     37#define CAM_DEFAULT_CROP_ORIGIN_W ((CAM_ACTIVE_AREA_X2-CAM_ACTIVE_AREA_X1-CAM_JPEG_WIDTH )/2) 
     38#define CAM_DEFAULT_CROP_ORIGIN_H ((CAM_ACTIVE_AREA_Y2-CAM_ACTIVE_AREA_Y1-CAM_JPEG_HEIGHT)/2) 
     39 
     40unsigned short get_exp_program_for_exif(int exp_program); 
     41unsigned short get_orientation_for_exif(short orientation); 
     42unsigned short get_flash_mode_for_exif(short mode, short fired); 
     43unsigned short get_metering_mode_for_exif(short metering_mode); 
    1044 
    1145const int cam_DefaultCropSize[]={CAM_JPEG_WIDTH, CAM_JPEG_HEIGHT};    // jpeg size 
     
    85119 {0x115,  T_SHORT,     1,  1}, // SamplesPerPixel: 1 
    86120 {0x116,  T_SHORT,     1,  CAM_RAW_ROWS}, //RowsPerStrip 
    87  {0x117,  T_LONG,      1,  CAM_RAW_ROWPIX*CAM_RAW_ROWS*CAM_SENSOR_BITS_PER_PIXEL/8}, // StripByteCounts = CHDK RAW size 
     121 {0x117,  T_LONG,      1,  CAM_RAW_ROWS*RAW_ROWLEN}, // StripByteCounts = CHDK RAW size 
    88122 {0x11A,  T_RATIONAL,  1,  (int)cam_Resolution}, // XResolution 
    89123 {0x11B,  T_RATIONAL,  1,  (int)cam_Resolution}, // YResolution 
     
    101135 
    102136 
     137static int cam_shutter[2]       = { 0, 1000000 };       // Shutter speed 
     138static int cam_aperture[2]      = { 0, 10 };            // Aperture 
     139static char cam_datetime[20]    = "";                   // DateTimeOriginal 
     140static int cam_apex_shutter[2]  = { 0, 96 };            // Shutter speed in APEX units 
     141static int cam_apex_aperture[2] = { 0, 96 };            // Aperture in APEX units 
     142static int cam_exp_bias[2]      = { 0, 96 }; 
     143static int cam_max_av[2]        = { 0, 96 }; 
     144static int cam_focal_length[2]  = { 0, 1000 }; 
     145 
    103146struct dir_entry EXIF_IFD[]={ 
    104  {0x829A, T_RATIONAL,  1,  0}, //ExposureTime 
    105  {0x829D, T_RATIONAL,  1,  0}, //FNumber 
     147 {0x829A, T_RATIONAL,  1,  (int)cam_shutter},           // Shutter speed 
     148 {0x829D, T_RATIONAL,  1,  (int)cam_aperture},          // Aperture 
    106149 {0x8822, T_SHORT,     1,  0}, //ExposureProgram 
    107150 {0x8827, T_SHORT,     1,  0}, //ISOSpeedRatings 
    108151 {0x9000, T_UNDEFINED, 4,  0x31323230}, // ExifVersion: 2.21 
    109  {0x9003, T_ASCII,     20, 0}, // DateTimeOriginal 
    110  {0x9201, T_SRATIONAL, 1,  0}, // ShutterSpeedValue 
    111  {0x9202, T_RATIONAL,  1,  0}, // ApertureValue 
    112  {0x9204, T_SRATIONAL, 1,  0}, // ExposureBias 
    113  {0x9205, T_RATIONAL,  1,  0}, //MaxApertureValue 
     152 {0x9003, T_ASCII,     20, (int)cam_datetime},          // DateTimeOriginal 
     153 {0x9201, T_SRATIONAL, 1,  (int)cam_apex_shutter},      // ShutterSpeedValue (APEX units) 
     154 {0x9202, T_RATIONAL,  1,  (int)cam_apex_aperture},     // ApertureValue (APEX units) 
     155 {0x9204, T_SRATIONAL, 1,  (int)cam_exp_bias},          // ExposureBias 
     156 {0x9205, T_RATIONAL,  1,  (int)cam_max_av},            // MaxApertureValue 
    114157 {0x9207, T_SHORT,     1,  0}, // Metering mode 
    115158 {0x9209, T_SHORT,     1,  0}, // Flash mode 
    116  {0x920A, T_RATIONAL,  1,  0}, //FocalLength 
     159 {0x920A, T_RATIONAL,  1,  (int)cam_focal_length},      // FocalLength 
    117160 {0xA405, T_SHORT,     1,  0}, //FocalLengthIn35mmFilm 
    118161 {0} 
     
    167210#define TIFF_HDR_SIZE (8) 
    168211 
    169 char* tmp_buf; 
    170 int tmp_buf_size; 
    171 int tmp_buf_offset; 
    172 void add_to_buf(void* var, int size){ 
    173  memcpy(tmp_buf+tmp_buf_offset,var,size); 
    174  tmp_buf_offset+=size; 
     212char* dng_header_buf; 
     213int dng_header_buf_size; 
     214int dng_header_buf_offset; 
     215char *thumbnail_buf; 
     216 
     217void add_to_buf(void* var, int size) 
     218{ 
     219 memcpy(dng_header_buf+dng_header_buf_offset,var,size); 
     220 dng_header_buf_offset+=size; 
    175221} 
    176222  
    177 void create_dng_header(struct t_data_for_exif* exif_data){ 
     223struct t_data_for_exif{ 
     224 short iso; 
     225 int exp_program; 
     226 int effective_focal_length; 
     227 short orientation; 
     228 short flash_mode; 
     229 short flash_fired; 
     230 short metering_mode; 
     231}; 
     232 
     233static struct t_data_for_exif exif_data; 
     234 
     235void create_dng_header(){ 
    178236 int var; 
    179237 int i,j; 
     
    209267     case 0xC614: IFD_LIST[j].entry[i].count = strlen((char*)IFD_LIST[j].entry[i].offset) + 1; break;   // UniqueCameraModel 
    210268     case 0x132 : 
    211      case 0x9003: IFD_LIST[j].entry[i].offset=(int)get_date_for_exif(exif_data->time); break; //DateTimeOriginal 
    212      case 0x8827: IFD_LIST[j].entry[i].offset=exif_data->iso; break;//ISOSpeedRatings 
    213      case 0x829D: IFD_LIST[j].entry[i].offset=(int)get_av_for_exif(exif_data->av); break; //FNumber 
    214      case 0x829A: IFD_LIST[j].entry[i].offset=(int)get_tv_for_exif(exif_data->tv); break; //ExposureTime 
    215      case 0x9205: IFD_LIST[j].entry[i].offset=(int)get_max_av_for_exif(exif_data->max_av); break; //MaxApertureValue 
    216      case 0x9204: IFD_LIST[j].entry[i].offset=(int)get_exp_bias_for_exif(exif_data->exp_bias); break; //ExposureBias 
    217      case 0x8822: IFD_LIST[j].entry[i].offset=get_exp_program_for_exif(exif_data->exp_program); break;//ExposureProgram 
    218      case 0x920A: IFD_LIST[j].entry[i].offset=(int)get_focal_length_for_exif(exif_data->focal_length); break; //FocalLength 
    219      case 0xA405: IFD_LIST[j].entry[i].offset=exif_data->effective_focal_length/1000; break; ////FocalLengthIn35mmFilm 
    220      case 0x0112: IFD_LIST[j].entry[i].offset=get_orientation_for_exif(exif_data->orientation); break; //Orientation 
    221      case 0x9209: IFD_LIST[j].entry[i].offset=get_flash_mode_for_exif(exif_data->flash_mode, exif_data->flash_fired); break; //Flash mode 
    222      case 0x9207: IFD_LIST[j].entry[i].offset=get_metering_mode_for_exif(exif_data->metering_mode); break; // Metering mode 
    223      case 0x9201: IFD_LIST[j].entry[i].offset=(int)get_shutter_speed_for_exif(exif_data->tv); break; // ShutterSpeedValue 
    224      case 0x9202: IFD_LIST[j].entry[i].offset=(int)get_aperture_for_exif(exif_data->av); break; // ApertureValue 
     269     case 0x8827: IFD_LIST[j].entry[i].offset=exif_data.iso; break;//ISOSpeedRatings 
     270     case 0x8822: IFD_LIST[j].entry[i].offset=get_exp_program_for_exif(exif_data.exp_program); break;//ExposureProgram 
     271     case 0xA405: IFD_LIST[j].entry[i].offset=exif_data.effective_focal_length/1000; break; ////FocalLengthIn35mmFilm 
     272     case 0x0112: IFD_LIST[j].entry[i].offset=get_orientation_for_exif(exif_data.orientation); break; //Orientation 
     273     case 0x9209: IFD_LIST[j].entry[i].offset=get_flash_mode_for_exif(exif_data.flash_mode, exif_data.flash_fired); break; //Flash mode 
     274     case 0x9207: IFD_LIST[j].entry[i].offset=get_metering_mode_for_exif(exif_data.metering_mode); break; // Metering mode 
    225275#if defined(OPT_GPS) 
    226276     case 0x0001: IFD_LIST[j].entry[i].offset=gps.latitudeRef; break; 
     
    257307 // creating buffer for writing data 
    258308 raw_offset=(raw_offset/512+1)*512; // exlusively for CHDK fast file writing 
    259  tmp_buf_size=raw_offset; 
    260  tmp_buf=umalloc(raw_offset); 
    261  tmp_buf_offset=0; 
    262  if (!tmp_buf) return; 
     309 dng_header_buf_size=raw_offset; 
     310 dng_header_buf=umalloc(raw_offset); 
     311 dng_header_buf_offset=0; 
     312 if (!dng_header_buf) return; 
     313 
     314 // create buffer for thumbnail 
     315 thumbnail_buf = malloc(DNG_TH_WIDTH*DNG_TH_HEIGHT*3); 
     316 if (!thumbnail_buf) 
     317 { 
     318     ufree(dng_header_buf); 
     319     dng_header_buf = 0; 
     320     return; 
     321 } 
    263322 
    264323 //  writing  offsets for EXIF IFD and RAW data and calculating offset for extra data 
     
    327386 } 
    328387 
    329  
    330388 // writing zeros to tail of dng header (just for fun) 
    331  for (i=tmp_buf_offset; i<tmp_buf_size; i++) tmp_buf[i]=0; 
    332  
    333 } 
    334  
    335 void free_dng_header(void){ 
    336  ufree(tmp_buf); 
    337  tmp_buf=NULL; 
    338 } 
    339  
    340 char* get_dng_header(void){ 
    341  return tmp_buf; 
    342 } 
    343  
    344 int get_dng_header_size(void){ 
    345  return tmp_buf_size; 
    346 } 
    347  
    348 char *get_date_for_exif(unsigned long time){ 
    349  static char buf[20]; 
    350  struct tm *ttm; 
    351  ttm = localtime(&time); 
    352  sprintf(buf, "%04d:%02d:%02d %02d:%02d:%02d", ttm->tm_year+1900, ttm->tm_mon+1, ttm->tm_mday, ttm->tm_hour, ttm->tm_min, ttm->tm_sec); 
    353  return buf; 
    354 } 
    355  
    356 unsigned int* get_av_for_exif(short av){ 
    357  static unsigned int fnumber[2]={0,10}; 
    358  fnumber[0]=10*pow(2,av/192.0); 
    359  return fnumber; 
    360 } 
    361  
    362 int* get_tv_for_exif(short tv){ 
    363  static int exp_time[2]={0,1000000}; 
    364  exp_time[0]=1000000*pow(2,-tv/96.0); 
    365  return exp_time; 
    366 } 
    367  
    368 unsigned int* get_max_av_for_exif(short max_av){ 
    369  static unsigned int mav[2]={0,96}; 
    370  mav[0]=max_av; 
    371  return mav; 
    372 } 
    373  
    374 int* get_exp_bias_for_exif(short exp_bias){ 
    375  static int bias[2]={0,96}; 
    376  bias[0]=exp_bias; 
    377  return bias; 
    378 } 
    379  
    380 int* get_shutter_speed_for_exif(short tv){ 
    381  static int speed[2]={0,96}; 
    382  speed[0]=tv; 
    383  return speed; 
    384 } 
    385  
    386 int* get_aperture_for_exif(short av){ 
    387  static int aperture[2]={0,96}; 
    388  aperture[0]=av; 
    389  return aperture; 
    390 } 
    391  
     389 for (i=dng_header_buf_offset; i<dng_header_buf_size; i++) dng_header_buf[i]=0; 
     390} 
     391 
     392void free_dng_header(void) 
     393{ 
     394    if (dng_header_buf) 
     395    { 
     396        ufree(dng_header_buf); 
     397        dng_header_buf=NULL; 
     398} 
     399    if (thumbnail_buf) 
     400    { 
     401        free(thumbnail_buf); 
     402        thumbnail_buf = 0; 
     403} 
     404} 
    392405 
    393406unsigned short get_exp_program_for_exif(int exp_program){ 
     
    399412  default: return 0; 
    400413 } 
    401 } 
    402  
    403 unsigned int* get_focal_length_for_exif(int focal_length){ 
    404  static unsigned int fl[2]={0,1000}; 
    405  fl[0]=focal_length; 
    406  return fl; 
    407414} 
    408415 
     
    436443} 
    437444 
    438 struct t_data_for_exif* capture_data_for_exif(void){ 
    439  static struct t_data_for_exif data; 
     445void capture_data_for_exif(void) 
     446{ 
     447 short short_prop_val; 
     448 unsigned long datetime; 
     449 struct tm *ttm; 
    440450 extern volatile long shutter_open_time; // defined in platform/generic/capt_seq.c 
    441451 int wb[3]; 
    442  data.iso=shooting_get_iso_market(); 
    443  get_property_case(PROPCASE_TV, &data.tv, sizeof(data.tv)); 
    444  if (shutter_open_time) { data.time=shutter_open_time+pow(2,-data.tv/96.0); shutter_open_time=0;} // shutter closing time 
    445  else  data.time=time(NULL); 
    446  get_property_case(PROPCASE_AV, &data.av, sizeof(data.av)); 
    447  get_property_case(PROPCASE_MIN_AV, &data.max_av, sizeof(data.max_av)); 
    448  get_property_case(PROPCASE_EV_CORRECTION_2, &data.exp_bias, sizeof(data.exp_bias)); 
    449  data.exp_program=mode_get() & MODE_SHOOTING_MASK; 
    450  data.focal_length=get_focal_length(shooting_get_zoom()); 
    451  data.effective_focal_length=get_effective_focal_length(shooting_get_zoom()); 
    452  get_property_case(PROPCASE_ORIENTATION_SENSOR, &data.orientation, sizeof(data.orientation)); 
     452 
     453 exif_data.iso=shooting_get_iso_market(); 
     454 
     455 // Shutter speed tags 
     456 get_property_case(PROPCASE_TV, &short_prop_val, sizeof(short_prop_val)); 
     457 cam_shutter[0]      = 1000000 * pow(2,-short_prop_val / 96.0); 
     458 cam_apex_shutter[0] = short_prop_val; 
     459 
     460 // Date & time tag (note - uses shutter speed from 'short_prop_val' code above) 
     461 if (shutter_open_time) { datetime = shutter_open_time+pow(2,-short_prop_val/96.0); shutter_open_time=0;} // shutter closing time 
     462 else  datetime = time(NULL); 
     463 ttm = localtime(&datetime); 
     464 sprintf(cam_datetime, "%04d:%02d:%02d %02d:%02d:%02d", ttm->tm_year+1900, ttm->tm_mon+1, ttm->tm_mday, ttm->tm_hour, ttm->tm_min, ttm->tm_sec); 
     465 
     466 get_property_case(PROPCASE_AV, &short_prop_val, sizeof(short_prop_val)); 
     467 cam_aperture[0]      = 10 * pow(2,short_prop_val / 192.0); 
     468 cam_apex_aperture[0] = short_prop_val; 
     469 
     470 get_property_case(PROPCASE_MIN_AV, &short_prop_val, sizeof(short_prop_val)); 
     471 cam_max_av[0] = short_prop_val; 
     472 
     473 get_property_case(PROPCASE_EV_CORRECTION_2, &short_prop_val, sizeof(short_prop_val)); 
     474 cam_exp_bias[0] = short_prop_val; 
     475 
     476 exif_data.exp_program=mode_get() & MODE_SHOOTING_MASK; 
     477 
     478 cam_focal_length[0] = get_focal_length(shooting_get_zoom()); 
     479 exif_data.effective_focal_length = get_effective_focal_length(shooting_get_zoom()); 
     480 
     481 get_property_case(PROPCASE_ORIENTATION_SENSOR, &exif_data.orientation, sizeof(exif_data.orientation)); 
    453482 get_parameter_data(PARAM_CAMERA_NAME, &cam_name, sizeof(cam_name)); 
    454  get_property_case(PROPCASE_FLASH_MODE, &data.flash_mode, sizeof(data.flash_mode)); 
    455  get_property_case(PROPCASE_FLASH_FIRE, &data.flash_fired, sizeof(data.flash_fired)); 
    456  get_property_case(PROPCASE_METERING_MODE, &data.metering_mode, sizeof(data.metering_mode)); 
     483 get_property_case(PROPCASE_FLASH_MODE, &exif_data.flash_mode, sizeof(exif_data.flash_mode)); 
     484 get_property_case(PROPCASE_FLASH_FIRE, &exif_data.flash_fired, sizeof(exif_data.flash_fired)); 
     485 get_property_case(PROPCASE_METERING_MODE, &exif_data.metering_mode, sizeof(exif_data.metering_mode)); 
     486 
    457487 get_property_case(PROPCASE_WB_ADJ, &wb, sizeof(wb));   
    458488 cam_AsShotNeutral[1]=wb[1]; 
    459489 cam_AsShotNeutral[3]=wb[0]; 
    460490 cam_AsShotNeutral[5]=wb[2]; 
    461  return &data; 
    462 } 
     491} 
     492 
     493//------------------------------------------------------------------- 
    463494 
    464495void convert_dng_to_chdk_raw(char* fn){ 
     
    503534} 
    504535 
     536//------------------------------------------------------------------- 
     537// Functions for creating DNG thumbnail image 
     538 
     539static unsigned char gamma[256]; 
     540 
     541void fill_gamma_buf(void) { 
     542    int i; 
     543    if (gamma[255]) return; 
     544#if defined(CAMERA_sx30) || defined(CAMERA_sx40hs) || defined(CAMERA_g12) || defined(CAMERA_ixus310_elph500hs) 
     545    for (i=0; i<12; i++) gamma[i]=255*pow(i/255.0, 0.5); 
     546    for (i=12; i<64; i++) gamma[i]=255*pow(i/255.0, 0.4); 
     547    for (i=64; i<=255; i++) gamma[i]=255*pow(i/255.0, 0.25); 
     548#else 
     549    for (i=0; i<=255; i++) gamma[i]=255*pow(i/255.0, 0.5); 
     550#endif 
     551} 
     552 
     553void create_thumbnail() { 
     554    register unsigned int i, j, x, y; 
     555    register char *buf = thumbnail_buf; 
     556 
     557    for (i=0; i<DNG_TH_HEIGHT; i++) 
     558        for (j=0; j<DNG_TH_WIDTH; j++) 
     559        { 
     560            x = (CAM_ACTIVE_AREA_X1+((CAM_ACTIVE_AREA_X2-CAM_ACTIVE_AREA_X1)*j)/DNG_TH_WIDTH) & 0xFFFFFFFE; 
     561            y = (CAM_ACTIVE_AREA_Y1+((CAM_ACTIVE_AREA_Y2-CAM_ACTIVE_AREA_Y1)*i)/DNG_TH_HEIGHT) & 0xFFFFFFFE; 
     562 
     563#if cam_CFAPattern==0x02010100    // Red  Green  Green  Blue 
     564            *buf++ = gamma[get_raw_pixel(x,y)>>(CAM_SENSOR_BITS_PER_PIXEL-8)];           // red pixel 
     565            *buf++ = gamma[6*(get_raw_pixel(x+1,y)>>(CAM_SENSOR_BITS_PER_PIXEL-8))/10];  // green pixel 
     566            *buf++ = gamma[get_raw_pixel(x+1,y+1)>>(CAM_SENSOR_BITS_PER_PIXEL-8)];       // blue pixel 
     567#elif cam_CFAPattern==0x01000201 // Green  Blue  Red  Green 
     568            *buf++ = gamma[get_raw_pixel(x,y+1)>>(CAM_SENSOR_BITS_PER_PIXEL-8)];         // red pixel 
     569            *buf++ = gamma[6*(get_raw_pixel(x,y)>>(CAM_SENSOR_BITS_PER_PIXEL-8))/10];    // green pixel 
     570            *buf++ = gamma[get_raw_pixel(x+1,y)>>(CAM_SENSOR_BITS_PER_PIXEL-8)];         // blue pixel 
     571#else  
     572    #error please define new pattern here 
     573#endif 
     574        } 
     575} 
     576 
     577//------------------------------------------------------------------- 
     578// Functions for handling DNG bad pixel file creation and bad pixel 
     579// removal from images. 
     580 
     581#define INIT_BADPIXEL_COUNT -1 
     582#define INIT_BADPIXEL_FILE -2 
     583 
     584#define PATH_BADPIXEL_BIN "A/CHDK/badpixel.bin" 
     585#define PATH_BAD_TMP_BIN "A/CHDK/bad_tmp.bin" 
     586 
     587int init_badpixel_bin_flag; // contants above to count/create file, > 0 num bad pixel 
     588 
     589int raw_init_badpixel_bin() { 
     590    int count; 
     591    unsigned short c[2]; 
     592    FILE*f; 
     593    if(init_badpixel_bin_flag == INIT_BADPIXEL_FILE) { 
     594        f=fopen(PATH_BAD_TMP_BIN,"w+b"); 
     595    } else if (init_badpixel_bin_flag == INIT_BADPIXEL_COUNT) { 
     596        f=NULL; 
     597    } else { 
     598        return 0; 
     599    } 
     600    count = 0; 
     601#ifdef DNG_VERT_RLE_BADPIXELS 
     602    for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++) 
     603    { 
     604        for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++) 
     605        { 
     606            if (get_raw_pixel(c[0],c[1])==0) 
     607            { 
     608                unsigned short l; 
     609                for (l=0; l<7; l++) if (get_raw_pixel(c[0],c[1]+l+1)!=0) break; 
     610                c[1] = c[1] | (l << 13); 
     611                if (f) fwrite(c, 1, 4, f); 
     612                c[1] = (c[1] & 0x1FFF) + l; 
     613                count = count + l + 1; 
     614            } 
     615        } 
     616    } 
     617#else 
     618    for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++)  
     619    { 
     620        for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++)  
     621        { 
     622            if (get_raw_pixel(c[0],c[1])==0)  
     623            { 
     624                if (f) fwrite(c, 1, 4, f); 
     625                count++; 
     626            } 
     627        } 
     628    } 
     629#endif 
     630    if (f) fclose(f); 
     631    init_badpixel_bin_flag = count; 
     632    state_shooting_progress = SHOOTING_PROGRESS_PROCESSING; 
     633    return 1; 
     634} 
     635 
     636short* binary_list=NULL; 
     637int binary_count=-1; 
     638 
     639void load_bad_pixels_list_b(char* filename) { 
     640    struct stat st; 
     641    long filesize; 
     642    void* ptr; 
     643    FILE *fd; 
     644    binary_count=-1; 
     645    if (stat(filename,&st)!=0) return; 
     646    filesize=st.st_size; 
     647    if (filesize%(2*sizeof(short)) != 0) return; 
     648        if (filesize == 0) { binary_count = 0; return; }        // Allow empty badpixel.bin file 
     649    ptr=malloc(filesize); 
     650    if (!ptr) return; 
     651    fd=fopen(filename, "rb"); 
     652    if (fd) { 
     653        fread(ptr,1, filesize,fd); 
     654        fclose(fd); 
     655        binary_list=ptr; 
     656        binary_count=filesize/(2*sizeof(short)); 
     657    } 
     658    else free(ptr); 
     659} 
     660 
     661void unload_bad_pixels_list_b(void) { 
     662    if (binary_list) free(binary_list); 
     663    binary_list=NULL; 
     664    binary_count=-1; 
     665} 
     666 
     667void patch_bad_pixels_b(void) { 
     668    int i; 
     669    short* ptr=binary_list; 
     670#ifdef DNG_VERT_RLE_BADPIXELS 
     671    short y, cnt; 
     672    for (i=0; i<binary_count; i++, ptr+=2) 
     673    { 
     674        y = ptr[1] & 0x1FFF; 
     675        cnt = (ptr[1] >> 13) & 7; 
     676        for (; cnt>=0; cnt--, y++) 
     677            if (get_raw_pixel(ptr[0], y)==0) 
     678                patch_bad_pixel(ptr[0], y); 
     679    } 
     680#else 
     681    for (i=0; i<binary_count; i++, ptr+=2) 
     682        if (get_raw_pixel(ptr[0], ptr[1])==0) 
     683            patch_bad_pixel(ptr[0], ptr[1]); 
     684#endif 
     685} 
     686 
     687int badpixel_list_loaded_b(void) { 
     688        return (binary_count >= 0) ? 1 : 0; 
     689} 
     690 
     691// ----------------------------------------------- 
     692 
     693enum BadpixelFSM { 
     694    BADPIX_START, 
     695    BADPIX_S1, 
     696    BADPIX_S2 
     697}; 
     698 
     699int badpixel_task_stack(long p) { 
     700    static unsigned int badpix_cnt1; 
     701 
     702    switch(p) { 
     703        case BADPIX_START: 
     704            action_pop(); 
     705 
     706            console_clear(); 
     707            console_add_line("Wait please... "); 
     708            console_add_line("This takes a few seconds,"); 
     709            console_add_line("don't panic!"); 
     710 
     711            init_badpixel_bin_flag = INIT_BADPIXEL_COUNT; 
     712 
     713            shooting_set_tv96_direct(96, SET_LATER); 
     714            action_push(BADPIX_S1); 
     715            action_push(AS_SHOOT); 
     716            action_push_delay(3000); 
     717            break; 
     718        case BADPIX_S1: 
     719            action_pop(); 
     720 
     721            badpix_cnt1 = init_badpixel_bin_flag; 
     722            init_badpixel_bin_flag = INIT_BADPIXEL_FILE; 
     723            shooting_set_tv96_direct(96, SET_LATER); 
     724 
     725            action_push(BADPIX_S2); 
     726            action_push(AS_SHOOT); 
     727            break; 
     728        case BADPIX_S2: 
     729            action_pop(); 
     730 
     731            console_clear(); 
     732            if (badpix_cnt1 == init_badpixel_bin_flag) { 
     733                // TODO script asked confirmation first 
     734                // should sanity check bad pixel count at least, 
     735                // wrong buffer address could make badpixel bigger than available mem 
     736                char msg[32]; 
     737                console_add_line("badpixel.bin created."); 
     738                sprintf(msg, "Bad pixel count: %d", badpix_cnt1); 
     739                console_add_line(msg); 
     740                remove(PATH_BADPIXEL_BIN); 
     741                rename(PATH_BAD_TMP_BIN,PATH_BADPIXEL_BIN); 
     742            } else { 
     743                console_add_line("badpixel.bin failed."); 
     744                console_add_line("Please try again."); 
     745            } 
     746            init_badpixel_bin_flag = 0; 
     747            remove(PATH_BAD_TMP_BIN); 
     748 
     749            action_push_delay(3000); 
     750            break; 
     751        default: 
     752            action_stack_standard(p); 
     753            break; 
     754    } 
     755 
     756    return 1; 
     757} 
     758 
     759 
     760void create_badpixel_bin() { 
     761    if (!(mode_get() & MODE_REC)) { 
     762        gui_mbox_init(LANG_ERROR, LANG_MSG_RECMODE_REQUIRED, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
     763        return; 
     764    } 
     765 
     766    gui_set_mode(GUI_MODE_ALT); 
     767    action_stack_create(&badpixel_task_stack, BADPIX_START); 
     768} 
     769 
     770//------------------------------------------------------------------- 
     771// Write DNG header and thumbnail to file 
     772 
     773void write_dng_header(int fd) 
     774{ 
     775    if (dng_header_buf) 
     776    { 
     777        fill_gamma_buf(); 
     778        patch_bad_pixels_b(); 
     779        create_thumbnail(); 
     780        write(fd, dng_header_buf, dng_header_buf_size); 
     781        write(fd, thumbnail_buf, DNG_TH_WIDTH*DNG_TH_HEIGHT*3); 
     782    } 
     783} 
     784 
    505785#endif //DNG_SUPPORT 
  • branches/reyalp-flt/core/dng.h

    r744 r1498  
    44#define DNG_H 
    55 
    6 struct dir_entry{unsigned short tag; unsigned short type; unsigned int count; unsigned int offset;}; 
     6#if DNG_SUPPORT 
    77 
    8 #define T_BYTE 1 
    9 #define T_ASCII 2 
    10 #define T_SHORT 3 
    11 #define T_LONG 4 
    12 #define T_RATIONAL 5 
    13 #define T_SBYTE 6 
    14 #define T_UNDEFINED 7 
    15 #define T_SSHORT 8 
    16 #define T_SLONG 9 
    17 #define T_SRATIONAL 10 
    18 #define T_FLOAT 11 
    19 #define T_DOUBLE 12 
     8extern int raw_init_badpixel_bin(); 
     9extern void capture_data_for_exif(void); 
     10extern void create_dng_header(); 
     11extern void free_dng_header(void); 
     12extern void write_dng_header(int fd); 
    2013 
    21 #define CAM_DEFAULT_CROP_ORIGIN_W ((CAM_ACTIVE_AREA_X2-CAM_ACTIVE_AREA_X1-CAM_JPEG_WIDTH )/2) 
    22 #define CAM_DEFAULT_CROP_ORIGIN_H ((CAM_ACTIVE_AREA_Y2-CAM_ACTIVE_AREA_Y1-CAM_JPEG_HEIGHT)/2) 
     14extern void convert_dng_to_chdk_raw(char* fn); 
    2315 
    24 //thumbnail 
    25 #define DNG_TH_WIDTH 128 
    26 #define DNG_TH_HEIGHT 96 
    27 // higly recommended that DNG_TH_WIDTH*DNG_TH_HEIGHT would be divisible by 512 
    28  
    29 struct t_data_for_exif{ 
    30  unsigned long time; 
    31  short iso; 
    32  short tv; 
    33  short av; 
    34  short exp_bias; 
    35  int exp_program; 
    36  short max_av; 
    37  int focal_length; 
    38  int effective_focal_length; 
    39  short orientation; 
    40  short flash_mode; 
    41  short flash_fired; 
    42  short metering_mode; 
    43 }; 
    44  
    45 void create_dng_header(struct t_data_for_exif* exif_data); 
    46 void free_dng_header(void); 
    47 char* get_dng_header(void); 
    48 int get_dng_header_size(void); 
    49  
    50 struct t_data_for_exif* capture_data_for_exif(void); 
    51  
    52 char *get_date_for_exif(unsigned long time); 
    53 unsigned int* get_av_for_exif(short av); 
    54 int* get_tv_for_exif(short tv); 
    55 unsigned int* get_max_av_for_exif(short max_av); 
    56 int* get_exp_bias_for_exif(short exp_bias); 
    57 unsigned short get_exp_program_for_exif(int exp_program); 
    58 unsigned int* get_focal_length_for_exif(int focal_length); 
    59 unsigned short get_orientation_for_exif(short orientation); 
    60 unsigned short get_flash_mode_for_exif(short mode, short fired); 
    61 unsigned short get_metering_mode_for_exif(short metering_mode); 
    62 int* get_shutter_speed_for_exif(short tv); 
    63 int* get_aperture_for_exif(short av); 
    64  
    65 void convert_dng_to_chdk_raw(char* fn); 
     16extern void load_bad_pixels_list_b(char* filename); 
     17extern void unload_bad_pixels_list_b(void); 
     18extern int badpixel_list_loaded_b(void); 
     19extern void create_badpixel_bin(); 
    6620 
    6721#endif 
     22 
     23#endif 
  • branches/reyalp-flt/core/gui.c

    r1493 r1498  
    3030#include "motion_detector.h" 
    3131#include "raw.h" 
     32#include "dng.h" 
    3233#ifdef OPT_CURVES 
    3334        #include "curves.h" 
  • branches/reyalp-flt/core/gui_draw.h

    r1494 r1498  
    120120#define COLOR_HISTO_BG_PLAY 0x99 
    121121#define COLOR_HISTO_RG_PLAY 0x66 
     122#undef SCREEN_COLOR 
     123#define SCREEN_COLOR        0x15        // try for a dark color in both record and play mode 
    122124 
    123125// Icon colors 
  • branches/reyalp-flt/core/module_wrappers.c

    r1494 r1498  
    1616{ 
    1717        int real_flags = flags & ~(STD_O_TRUNC|STD_O_CREAT); 
    18         if ( flags & STD_O_TRUNC ) real_flags = O_TRUNC; 
    19         if ( flags & STD_O_CREAT ) real_flags = O_CREAT; 
     18        if ( flags & STD_O_TRUNC ) real_flags |= O_TRUNC; 
     19        if ( flags & STD_O_CREAT ) real_flags |= O_CREAT; 
    2020        return open( name, real_flags, mode); 
    2121} 
     
    9595        memset( &(dir->de), 0, sizeof(dir->de)); 
    9696#else 
     97        dir->de.unk1 = de->unk1; 
    9798        dir->de.attrib = de->attrib; 
    9899        dir->de.size  = de->size; 
  • branches/reyalp-flt/core/ptp.c

    r1469 r1498  
    428428        } 
    429429        free(buf); 
     430        if(data_size > 0 && ptp.code != PTP_RC_OK) { 
     431            flush_recv_ptp_data(data,data_size); 
     432        } 
    430433        break; 
    431434      } 
  • branches/reyalp-flt/core/raw.c

    r1493 r1498  
    44#include "raw.h" 
    55#include "console.h" 
    6 #if DNG_SUPPORT 
    76    #include "dng.h" 
    8     #include "math.h" 
    9     #include "keyboard.h" 
    10     #include "action_stack.h" 
    11     #include "gui_draw.h" 
    12     #include "gui_mbox.h" 
    13     #include "gui_lang.h" 
    14 #endif 
    157#ifdef OPT_CURVES 
    168    #include "modules.h" 
     
    2315#define RAW_TARGET_FILENAME     "%s%04d%s" 
    2416#define RAW_BRACKETING_FILENAME "%s%04d_%02d%s"  
    25  
    26 #define PATH_BADPIXEL_BIN "A/CHDK/badpixel.bin" 
    27 #define PATH_BAD_TMP_BIN "A/CHDK/bad_tmp.bin" 
    2817 
    2918//------------------------------------------------------------------- 
     
    5544    else return (char*) ((int)hook_alt_raw_image_addr()&~CAM_UNCACHED_BIT); 
    5645} 
    57  
    58 //------------------------------------------------------------------- 
    59  
    60 #if DNG_SUPPORT 
    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 #ifdef DNG_VERT_RLE_BADPIXELS 
    78     for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++) 
    79     { 
    80         for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++) 
    81         { 
    82             if (get_raw_pixel(c[0],c[1])==0) 
    83             { 
    84                 unsigned short l; 
    85                 for (l=0; l<7; l++) if (get_raw_pixel(c[0],c[1]+l+1)!=0) break; 
    86                 c[1] = c[1] | (l << 13); 
    87                 if (f) fwrite(c, 1, 4, f); 
    88                 c[1] = (c[1] & 0x1FFF) + l; 
    89                 count = count + l + 1; 
    90             } 
    91         } 
    92     } 
    93 #else 
    94     for (c[1]=CAM_ACTIVE_AREA_Y1; c[1]<CAM_ACTIVE_AREA_Y2; c[1]++)  
    95     { 
    96         for (c[0]=CAM_ACTIVE_AREA_X1; c[0]<CAM_ACTIVE_AREA_X2; c[0]++)  
    97         { 
    98             if (get_raw_pixel(c[0],c[1])==0)  
    99             { 
    100                 if (f) fwrite(c, 1, 4, f); 
    101                 count++; 
    102             } 
    103         } 
    104     } 
    105 #endif 
    106     if (f) fclose(f); 
    107     init_badpixel_bin_flag = count; 
    108     state_shooting_progress = SHOOTING_PROGRESS_PROCESSING; 
    109     return 1; 
    110 } 
    111  
    112 unsigned short get_raw_pixel(unsigned int x,unsigned  int y); 
    113  
    114 static unsigned char gamma[256]; 
    115  
    116 void fill_gamma_buf(void) { 
    117     int i; 
    118     if (gamma[255]) return; 
    119 #if defined(CAMERA_sx30) || defined(CAMERA_sx40hs) || defined(CAMERA_g12) || defined(CAMERA_ixus310_elph500hs) 
    120     for (i=0; i<12; i++) gamma[i]=255*pow(i/255.0, 0.5); 
    121     for (i=12; i<64; i++) gamma[i]=255*pow(i/255.0, 0.4); 
    122     for (i=64; i<=255; i++) gamma[i]=255*pow(i/255.0, 0.25); 
    123 #else 
    124     for (i=0; i<=255; i++) gamma[i]=255*pow(i/255.0, 0.5); 
    125 #endif 
    126 } 
    127  
    128 void create_thumbnail(char* buf) { 
    129     unsigned int i, j, x, y; 
    130     unsigned char r, g, b; 
    131     for (i=0; i<DNG_TH_HEIGHT; i++) 
    132         for (j=0; j<DNG_TH_WIDTH; j++) { 
    133             x=CAM_ACTIVE_AREA_X1+((CAM_ACTIVE_AREA_X2-CAM_ACTIVE_AREA_X1)*j)/DNG_TH_WIDTH; 
    134             y=CAM_ACTIVE_AREA_Y1+((CAM_ACTIVE_AREA_Y2-CAM_ACTIVE_AREA_Y1)*i)/DNG_TH_HEIGHT; 
    135 #if cam_CFAPattern==0x02010100    // Red  Green  Green  Blue 
    136             r=gamma[get_raw_pixel((x/2)*2,(y/2)*2)>>(CAM_SENSOR_BITS_PER_PIXEL-8)]; // red pixel 
    137             g=gamma[6*(get_raw_pixel((x/2)*2+1,(y/2)*2)>>(CAM_SENSOR_BITS_PER_PIXEL-8))/10]; // green pixel 
    138             b=gamma[get_raw_pixel((x/2)*2+1,(y/2)*2+1)>>(CAM_SENSOR_BITS_PER_PIXEL-8)]; //blue pixel 
    139 #elif cam_CFAPattern==0x01000201 // Green  Blue  Red  Green 
    140             r=gamma[get_raw_pixel((x/2)*2,(y/2)*2+1)>>(CAM_SENSOR_BITS_PER_PIXEL-8)]; // red pixel 
    141             g=gamma[6*(get_raw_pixel((x/2)*2,(y/2)*2)>>(CAM_SENSOR_BITS_PER_PIXEL-8))/10]; // green pixel 
    142             b=gamma[get_raw_pixel((x/2)*2+1,(y/2)*2)>>(CAM_SENSOR_BITS_PER_PIXEL-8)]; //blue pixel 
    143 #else  
    144     #error please define new pattern here 
    145 #endif 
    146             *buf++=r; *buf++=g; *buf++=b; 
    147         } 
    148 } 
    149 #else // no DNG_SUPPORT 
    150     static inline int __attribute__((always_inline)) raw_init_badpixel_bin(void) {return 0;} 
    151 #endif 
    15246//------------------------------------------------------------------- 
    15347 
     
    15852    static int br_counter;  
    15953#if DNG_SUPPORT 
    160     struct t_data_for_exif* exif_data = NULL; 
    161     char *thumbnail_buf = NULL; 
    162     if (conf.dng_raw) exif_data=capture_data_for_exif(); 
     54    if (conf.dng_raw) capture_data_for_exif(); 
    16355#endif     
    16456    if (state_kbd_script_run && shot_histogram_isenabled()) build_shot_histogram(); 
     
    16860    char* altrawadr = get_alt_raw_image_addr(); 
    16961 
     62#if DNG_SUPPORT 
    17063    // count/save badpixels if requested 
    17164    if(raw_init_badpixel_bin()) { 
    17265        return 0; 
    17366    } 
     67#endif     
    17468 
    17569    if (develop_raw) { 
     
    251145            if (conf.dng_raw) 
    252146            { 
    253                 fill_gamma_buf(); 
    254                 create_dng_header(exif_data); 
    255                 thumbnail_buf = malloc(DNG_TH_WIDTH*DNG_TH_HEIGHT*3); 
    256                 if (get_dng_header() && thumbnail_buf) { 
    257                     patch_bad_pixels_b(); 
    258                     create_thumbnail(thumbnail_buf); 
    259                     write(fd, get_dng_header(), get_dng_header_size()); 
    260                     write(fd, thumbnail_buf, DNG_TH_WIDTH*DNG_TH_HEIGHT*3); 
     147                create_dng_header(); 
     148                write_dng_header(fd); 
    261149                    reverse_bytes_order2(rawadr, altrawadr, hook_raw_size()); 
    262                 } 
    263150                // Write alternate (inactive) buffer that we reversed the bytes into above (if only one buffer then it will be the active buffer instead) 
    264151                write(fd, (char*)(((unsigned long)altrawadr)|CAM_UNCACHED_BIT), hook_raw_size()); 
     
    272159            utime(fn, &t); 
    273160 
    274             if (conf.dng_raw) { 
    275                 if (get_dng_header() && thumbnail_buf) { 
     161            if (conf.dng_raw) 
     162            { 
    276163                    if (rawadr == altrawadr)    // If only one RAW buffer then we have to swap the bytes back 
    277164                        reverse_bytes_order2(rawadr, altrawadr, hook_raw_size()); 
    278                     //unpatch_bad_pixels_b(); 
    279                 } 
    280                 if (get_dng_header()) free_dng_header(); 
    281                 if (thumbnail_buf) free(thumbnail_buf); 
     165                free_dng_header(); 
    282166            } 
    283167#else 
     
    458342 
    459343} 
    460  
    461 #if DNG_SUPPORT 
    462 short* binary_list=NULL; 
    463 int binary_count=-1; 
    464  
    465 void load_bad_pixels_list_b(char* filename) { 
    466     struct stat st; 
    467     long filesize; 
    468     void* ptr; 
    469     FILE *fd; 
    470     binary_count=-1; 
    471     if (stat(filename,&st)!=0) return; 
    472     filesize=st.st_size; 
    473     if (filesize%(2*sizeof(short)) != 0) return; 
    474         if (filesize == 0) { binary_count = 0; return; }        // Allow empty badpixel.bin file 
    475     ptr=malloc(filesize); 
    476     if (!ptr) return; 
    477     fd=fopen(filename, "rb"); 
    478     if (fd) { 
    479         fread(ptr,1, filesize,fd); 
    480         fclose(fd); 
    481         binary_list=ptr; 
    482         binary_count=filesize/(2*sizeof(short)); 
    483     } 
    484     else free(ptr); 
    485 } 
    486  
    487 void unload_bad_pixels_list_b(void) { 
    488     if (binary_list) free(binary_list); 
    489     binary_list=NULL; 
    490     binary_count=-1; 
    491 } 
    492  
    493 void patch_bad_pixels_b(void) { 
    494     int i; 
    495     short* ptr=binary_list; 
    496 #ifdef DNG_VERT_RLE_BADPIXELS 
    497     short y, cnt; 
    498     for (i=0; i<binary_count; i++, ptr+=2) 
    499     { 
    500         y = ptr[1] & 0x1FFF; 
    501         cnt = (ptr[1] >> 13) & 7; 
    502         for (; cnt>=0; cnt--, y++) 
    503             if (get_raw_pixel(ptr[0], y)==0) 
    504                 patch_bad_pixel(ptr[0], y); 
    505     } 
    506 #else 
    507     for (i=0; i<binary_count; i++, ptr+=2) 
    508         if (get_raw_pixel(ptr[0], ptr[1])==0) 
    509             patch_bad_pixel(ptr[0], ptr[1]); 
    510 #endif 
    511 } 
    512 /* 
    513 void unpatch_bad_pixels_b(void) { 
    514     int i; 
    515     short* ptr=binary_list; 
    516     for (i=0; i<binary_count; i++, ptr+=2) set_raw_pixel(ptr[0], ptr[1], 0); 
    517 } 
    518 */ 
    519 int badpixel_list_loaded_b(void) { 
    520         return (binary_count >= 0) ? 1 : 0; 
    521 } 
    522  
    523 // ----------------------------------------------- 
    524  
    525 enum BadpixelFSM { 
    526     BADPIX_START, 
    527     BADPIX_S1, 
    528     BADPIX_S2 
    529 }; 
    530  
    531 int badpixel_task_stack(long p) { 
    532     static unsigned int badpix_cnt1; 
    533  
    534     switch(p) { 
    535         case BADPIX_START: 
    536             action_pop(); 
    537  
    538             console_clear(); 
    539             console_add_line("Wait please... "); 
    540             console_add_line("This takes a few seconds,"); 
    541             console_add_line("don't panic!"); 
    542  
    543             init_badpixel_bin_flag = INIT_BADPIXEL_COUNT; 
    544  
    545             shooting_set_tv96_direct(96, SET_LATER); 
    546             action_push(BADPIX_S1); 
    547             action_push(AS_SHOOT); 
    548             action_push_delay(3000); 
    549             break; 
    550         case BADPIX_S1: 
    551             action_pop(); 
    552  
    553             badpix_cnt1 = init_badpixel_bin_flag; 
    554             init_badpixel_bin_flag = INIT_BADPIXEL_FILE; 
    555             shooting_set_tv96_direct(96, SET_LATER); 
    556  
    557             action_push(BADPIX_S2); 
    558             action_push(AS_SHOOT); 
    559             break; 
    560         case BADPIX_S2: 
    561             action_pop(); 
    562  
    563             console_clear(); 
    564             if (badpix_cnt1 == init_badpixel_bin_flag) { 
    565                 // TODO script asked confirmation first 
    566                 // should sanity check bad pixel count at least, 
    567                 // wrong buffer address could make badpixel bigger than available mem 
    568                 char msg[32]; 
    569                 console_add_line("badpixel.bin created."); 
    570                 sprintf(msg, "Bad pixel count: %d", badpix_cnt1); 
    571                 console_add_line(msg); 
    572                 remove(PATH_BADPIXEL_BIN); 
    573                 rename(PATH_BAD_TMP_BIN,PATH_BADPIXEL_BIN); 
    574             } else { 
    575                 console_add_line("badpixel.bin failed."); 
    576                 console_add_line("Please try again."); 
    577             } 
    578             init_badpixel_bin_flag = 0; 
    579             remove(PATH_BAD_TMP_BIN); 
    580  
    581             action_push_delay(3000); 
    582             break; 
    583         default: 
    584             action_stack_standard(p); 
    585             break; 
    586     } 
    587  
    588     return 1; 
    589 } 
    590  
    591  
    592 void create_badpixel_bin() { 
    593     if (!(mode_get() & MODE_REC)) { 
    594         gui_mbox_init(LANG_ERROR, LANG_MSG_RECMODE_REQUIRED, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL); 
    595         return; 
    596     } 
    597  
    598     gui_set_mode(GUI_MODE_ALT); 
    599     action_stack_create(&badpixel_task_stack, BADPIX_START); 
    600 } 
    601  
    602 #endif 
  • branches/reyalp-flt/core/raw.h

    r1494 r1498  
    2424extern void raw_prepare_develop(const char* filename); 
    2525extern void load_bad_pixels_list(const char* filename); 
    26 unsigned short get_raw_pixel(unsigned int x,unsigned  int y); 
    27  
    28 #if DNG_SUPPORT 
    29 void load_bad_pixels_list_b(char* filename); 
    30 void unload_bad_pixels_list_b(void); 
    31 void patch_bad_pixels_b(void); 
    32 void unpatch_bad_pixels_b(void); 
    33 int badpixel_list_loaded_b(void); 
    34 void create_badpixel_bin(); 
    35 #endif 
    36 char* get_raw_image_addr(void); 
     26extern unsigned short get_raw_pixel(unsigned int x,unsigned  int y); 
     27extern char* get_raw_image_addr(void); 
     28extern void patch_bad_pixel(unsigned int x,unsigned  int y); 
    3729 
    3830//------------------------------------------------------------------- 
  • branches/reyalp-flt/include/stdlib_unified.h

    r1494 r1498  
    2727// Universal struct of directory entry 
    2828struct STD_dirent { 
    29     char            d_name[13]; 
     29    char            d_name[100]; 
    3030    unsigned long       unk1; 
    3131    unsigned char       attrib; 
  • branches/reyalp-flt/platform/ixus120_sd940/platform_camera.h

    r1418 r1498  
    7272    // camera name 
    7373    #define PARAM_CAMERA_NAME 4 // parameter number for GetParameterData 
     74        #define PARAM_DISPLAY_MODE1     57      // param number for LCD display mode when camera in playback 
     75        #define PARAM_DISPLAY_MODE2     58      // param number for LCD display mode when camera in record view hold mode        
     76         
    7477    #undef  CAM_SENSOR_BITS_PER_PIXEL 
    7578    #define CAM_SENSOR_BITS_PER_PIXEL   12 
  • branches/reyalp-flt/platform/ixus310_elph500hs/kbd.c

    r1420 r1498  
    346346    { 3, KEY_DISPLAY        , 0x00000008, LB(0,4), 0, "Back",  0,    GUI_MODE_MENU,      GUI_MODE_MENU, MODE_REC|MODE_PLAY }, 
    347347        { 3, KEY_DISPLAY            , 0x00000008, LB(0,4), 0, "Disp",  0,    GUI_MODE_PALETTE,   100,           MODE_REC|MODE_PLAY }, 
    348     { 3, KEY_UP                     , 0x00000010, RB(0,1), 0, "Up",    0,    GUI_MODE_MENU,      100,           MODE_REC|MODE_PLAY }, 
    349         { 3, KEY_LEFT               , 0x00000020, RB(0,2), 0, "Left",  0,    GUI_MODE_MENU,      100,           MODE_REC|MODE_PLAY }, 
    350     { 3, KEY_RIGHT                  , 0x00000040, RB(0,3), 0, "Right", 0,    GUI_MODE_MENU,      100,           MODE_REC|MODE_PLAY }, 
    351         { 3, KEY_DOWN               , 0x00000080, RB(0,4), 0, "Down",  0,    GUI_MODE_MENU,      100,           MODE_REC|MODE_PLAY }, 
     348    { 3, KEY_UP                     , 0x00000010, RB(0,1), 0, "Up",    0,    GUI_MODE_ALT,       100,           MODE_REC|MODE_PLAY }, 
     349        { 3, KEY_LEFT               , 0x00000020, RB(0,2), 0, "Left",  0,    GUI_MODE_ALT,       100,           MODE_REC|MODE_PLAY }, 
     350    { 3, KEY_RIGHT                  , 0x00000040, RB(0,3), 0, "Right", 0,    GUI_MODE_ALT,       100,           MODE_REC|MODE_PLAY }, 
     351        { 3, KEY_DOWN               , 0x00000080, RB(0,4), 0, "Down",  0,    GUI_MODE_ALT,       100,           MODE_REC|MODE_PLAY }, 
    352352 
    353353    { 3, KEY_UP                     , 0x00000010, RB(0,0), 0, "Man",   "Focus",  GUI_MODE_ALT, GUI_MODE_ALT, MODE_REC, &conf.subj_dist_override_koef, 0, &conf.touchscreen_disable_shortcut_controls }, 
  • branches/reyalp-flt/platform/ixus310_elph500hs/platform_camera.h

    r1410 r1498  
    4646        #define CAM_VIDEO_QUALITY_ONLY          1 
    4747    #define CAM_EXT_TV_RANGE            1 
    48     //#define CAM_EV_IN_VIDEO             1 
    49         //#define CAM_SHOW_OSD_IN_SHOOT_MENU  1 
    50     //#define CAM_QUALITY_OVERRIDE    1 
    5148 
    5249    #define CAM_HAS_ND_FILTER           1 
     
    7168    // camera name 
    7269    #define PARAM_CAMERA_NAME 4 // parameter number for GetParameterData 
     70    #define PARAM_DISPLAY_MODE1             60 // param number for LCD display mode when camera in playback 
     71    #define PARAM_DISPLAY_MODE2             64  // param number for LCD display mode when camera in record view hold mode 
    7372    #undef  CAM_SENSOR_BITS_PER_PIXEL 
    7473    #define CAM_SENSOR_BITS_PER_PIXEL   12 
     
    9089    #define     CAM_DNG_LENS_INFO           { 43,10, 188,10, 20,10, 58,10 }     // See comments in camera.h 
    9190 
    92         //need fixing ***************************************************** 
    93 /* 
    94     #define cam_CalibrationIlluminant1  17              // Standard Light A 
    95     //colormatrix from sx220hs 
    96         #define CAM_COLORMATRIX1 \ 
    97     14458, 10000, -5704, 10000, -1562, 10000, \ 
    98     -2520, 10000, 11470, 10000,  1388, 10000, \ 
    99     -1336, 10000,  2334, 10000,  4387, 10000 
    100 */ 
    10191        #define cam_CalibrationIlluminant1  1 
    10292        #define CAM_COLORMATRIX1        \ 
     
    118108    #define CAM_FIRMWARE_MEMINFO        1       // Use 'GetMemInfo' to get free memory size. 
    119109 
    120     #define CAM_DRIVE_MODE_FROM_TIMER_MODE      // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
     110    #define CAM_DRIVE_MODE_FROM_TIMER_MODE  1   // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    121111                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
    122112                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
  • branches/reyalp-flt/platform/sx30/platform_camera.h

    r1453 r1498  
    2525        #define CAM_DRYOS_2_3_R39                       1 
    2626 
    27         #define CAM_RAW_ROWPIX                          4464 
    28         #define CAM_RAW_ROWS                            3276 
    29  
    3027        #define CAM_SWIVEL_SCREEN                       1 
    3128        #define CAM_ADJUSTABLE_ALT_BUTTON       1 
     
    3936        #define CAM_HAS_JOGDIAL                         1 
    4037        #undef  CAM_USE_ZOOM_FOR_MF 
    41         #undef  CAM_UNCACHED_BIT                        // shut up compiler 
     38    #undef  CAM_UNCACHED_BIT 
    4239        #define CAM_UNCACHED_BIT                        0x40000000 
    4340        #define CAM_SHOW_OSD_IN_SHOOT_MENU  1 
     
    6461           -16441, 1000000,   142319, 1000000,  375979, 1000000 
    6562 
    66         // cropping 
     63    // Sensor size, DNG image size & cropping 
     64    #define CAM_RAW_ROWPIX                  4464 
     65    #define CAM_RAW_ROWS                    3276 
    6766        #define CAM_JPEG_WIDTH                          4368 
    6867        #define CAM_JPEG_HEIGHT                         3254 
     
    7473        // camera name 
    7574        #define PARAM_CAMERA_NAME                       4 // parameter number for GetParameterData 
     75    #define PARAM_DISPLAY_MODE1             59  // param number for LCD display mode when camera in playback 
     76    #define PARAM_DISPLAY_MODE2             62  // param number for LCD display mode when camera in record view hold mode 
    7677        #undef  CAM_SENSOR_BITS_PER_PIXEL 
    7778        #define CAM_SENSOR_BITS_PER_PIXEL       12 
     
    106107    #define CAM_FIRMWARE_MEMINFO        1       // Use 'GetMemInfo' to get free memory size. 
    107108 
    108     #define CAM_DRIVE_MODE_FROM_TIMER_MODE      // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
     109    #define CAM_DRIVE_MODE_FROM_TIMER_MODE  1   // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    109110                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
    110111                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
  • branches/reyalp-flt/platform/sx40hs/platform_camera.h

    r1453 r1498  
    2626    #define CAM_DRYOS_2_3_R47                   1 
    2727 
    28         #define CAM_RAW_ROWPIX                          4176 // Found @0xff18e050 
    29         #define CAM_RAW_ROWS                            3060 // Found @0xff18e05c 
    3028        #undef  CAM_UNCACHED_BIT 
    3129        #define CAM_UNCACHED_BIT                        0x40000000 // Found @0xff02bea8 
     
    6765         -5801, 100000,   71589, 100000, 118914, 100000 
    6866 
    69         // cropping 
     67    // Sensor size, DNG image size & cropping 
     68    #define CAM_RAW_ROWPIX                  4176 // Found @0xff18e050 
     69    #define CAM_RAW_ROWS                    3060 // Found @0xff18e05c 
    7070        #define CAM_JPEG_WIDTH                          4072 
    7171        #define CAM_JPEG_HEIGHT                         3044 
     
    7777        // camera name 
    7878        #define PARAM_CAMERA_NAME                       4 // parameter number for GetParameterData 
     79    #define PARAM_DISPLAY_MODE1             59  // param number for LCD display mode when camera in playback 
     80    #define PARAM_DISPLAY_MODE2             62  // param number for LCD display mode when camera in record view hold mode 
    7981        #undef  CAM_SENSOR_BITS_PER_PIXEL 
    8082        #define CAM_SENSOR_BITS_PER_PIXEL       12 
     
    105107                                                                                                                        // see http://chdk.setepontos.com/index.php?topic=6179.0 
    106108 
    107 //    #define CAM_KEY_CLICK_DELAY         150 // Does SX40 need extra delay for clicks ??? 
     109    #define CAM_KEY_CLICK_DELAY             150 // SX40 needs extra delay for clicks 
    108110 
    109111    #define CAM_FIRMWARE_MEMINFO        1       // Use 'GetMemInfo' to get free memory size. 
    110112 
    111     #define CAM_DRIVE_MODE_FROM_TIMER_MODE      // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
     113    #define CAM_DRIVE_MODE_FROM_TIMER_MODE  1   // use PROPCASE_TIMER_MODE to check for multiple shot custom timer. 
    112114                                                // Used to enabled bracketing in custom timer, required on many recent cameras 
    113115                                                // see http://chdk.setepontos.com/index.php/topic,3994.405.html 
  • branches/reyalp-flt/tools/finsig_dryos.c

    r1458 r1498  
    21642164         
    21652165        int found_ev = 0; 
    2166         int tried_ev = 0; 
    21672166 
    21682167        count = 0; 
     
    21722171                if (strcmp(curr_name, string_sigs[i].name) == 0) 
    21732172                { 
    2174                         tried_ev = 1; 
    21752173                        if (find_strsig(fw, &string_sigs[i], -1)) 
    21762174                        { 
     
    22032201         
    22042202        int found_ev = 0; 
    2205         int tried_ev = 0; 
    22062203 
    22072204        count = 0; 
     
    22152212                        if (strcmp(curr_name, string_sigs[i].name) == 0) 
    22162213                        { 
    2217                                 tried_ev = 1; 
    22182214                                if (find_strsig(fw, &string_sigs[i], k)) 
    22192215                                { 
     
    23142310         
    23152311        int found_ev = 0; 
    2316         int tried_ev = 0; 
    23172312 
    23182313        count = 0; 
     
    23232318                if (strcmp(curr_name, string_sigs[i].name) == 0) 
    23242319                { 
    2325                         tried_ev = 1; 
    23262320                        if (find_strsig(fw, &string_sigs[i], k)) 
    23272321                        { 
  • branches/reyalp-flt/tools/packfi2/fi2enc.c

    r768 r1498  
    9797{ 
    9898        unsigned long i; 
    99         size_t hdrsize, flen; 
     99        size_t flen; 
    100100        uint32_t cs; 
    101101        FILE *fi, *fo; 
     
    116116        } 
    117117        aes128_expandkey( exkey, key ); 
    118         hdrsize = 0; 
    119118        cs = 0; 
    120119        memset(&hdr, 0, sizeof (hdr)); 
     
    125124        hdr.ch=0; 
    126125        hdr.unk2=1; 
    127         hdrsize = 32; 
    128126        fi2rec.addr=0; 
    129127        fi2rec.fboot = 1; 
Note: See TracChangeset for help on using the changeset viewer.