Changeset 1862


Ignore:
Timestamp:
05/19/12 00:33:36 (12 months ago)
Author:
philmoz
Message:

Add SubSecTime? & SubSecTimeOriginal? tags to DNG header.
http://chdk.setepontos.com/index.php?topic=5785.msg85594#msg85594

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/dng.c

    r1809 r1862  
    5050static int cam_AsShotNeutral[]          = {1000,1000,1000,1000,1000,1000}; 
    5151static char cam_datetime[20]            = "";                   // DateTimeOriginal 
     52static char cam_subsectime[4]           = "";                   // DateTimeOriginal (milliseconds component) 
    5253static int cam_shutter[2]               = { 0, 1000000 };       // Shutter speed 
    5354static int cam_aperture[2]              = { 0, 10 };            // Aperture 
     
    178179#define METERING_MODE_INDEX         10      // tag 0x9207 
    179180#define FLASH_MODE_INDEX            11      // tag 0x9209 
     181#define SSTIME_INDEX                13      // tag 0x9290 
     182#define SSTIME_ORIG_INDEX           14      // tag 0x9291 
    180183 
    181184struct dir_entry exif_ifd[]={ 
     
    193196    {0x9209, T_SHORT,      1,  0},                         // Flash mode 
    194197    {0x920A, T_RATIONAL,   1,  (int)cam_focal_length},     // FocalLength 
     198    {0x9290, T_ASCII|T_PTR,4,  (int)cam_subsectime},       // DateTime milliseconds 
     199    {0x9291, T_ASCII|T_PTR,4,  (int)cam_subsectime},       // DateTimeOriginal milliseconds 
    195200    {0xA405, T_SHORT|T_PTR,1,  (int)&exif_data.effective_focal_length},    // FocalLengthIn35mmFilm 
    196201}; 
     
    312317    exif_ifd[METERING_MODE_INDEX].offset = get_metering_mode_for_exif(exif_data.metering_mode); 
    313318    exif_ifd[FLASH_MODE_INDEX].offset = get_flash_mode_for_exif(exif_data.flash_mode, exif_data.flash_fired); 
     319    exif_ifd[SSTIME_INDEX].count = exif_ifd[SSTIME_ORIG_INDEX].count = strlen(cam_subsectime)+1; 
    314320 
    315321    // calculating offset of RAW data and count of entries for each IFD 
     
    491497    short short_prop_val; 
    492498    time_t datetime; 
     499    long subsectime; 
    493500    struct tm *ttm; 
    494     extern volatile long shutter_open_time; // defined in platform/generic/capt_seq.c 
     501    extern volatile long shutter_open_time;         // defined in platform/generic/capt_seq.c 
     502    extern volatile long shutter_open_tick_count;   // defined in platform/generic/capt_seq.c 
    495503    int wb[3]; 
    496504 
     
    503511 
    504512    // Date & time tag (note - uses shutter speed from 'short_prop_val' code above) 
    505     if (shutter_open_time) { datetime = shutter_open_time + pow_calc(1, 2, 1, -short_prop_val, 96); shutter_open_time=0;} // shutter closing time 
    506     else  datetime = time(NULL); 
     513    if (shutter_open_time) 
     514    { 
     515        // milliseconds component of shutter_open_time 
     516        subsectime = (shutter_open_tick_count - camera_info.tick_count_offset) % 1000; 
     517        // shutter closing time 
     518        datetime = shutter_open_time + ((cam_shutter[0] + (subsectime * 1000)) / 1000000); 
     519        shutter_open_time=0; 
     520    } 
     521    else 
     522    { 
     523        datetime = time(NULL); 
     524        // milliseconds component of datetime 
     525        subsectime = (get_tick_count() - camera_info.tick_count_offset) % 1000; 
     526    } 
    507527    ttm = localtime(&datetime); 
    508528    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); 
     529    sprintf(cam_subsectime, "%02d", subsectime/10);     // camera tick count is only accurate to 10 msec intervals 
    509530 
    510531    get_property_case(camera_info.props.av, &short_prop_val, sizeof(short_prop_val)); 
  • trunk/core/main.c

    r1823 r1862  
    249249#endif 
    250250 
     251    // Calculate the value of get_tick_count() when the clock ticks over to the next second 
     252    // Used to calculate the SubSecondTime value when saving DNG files. 
     253    long t1, t2; 
     254    t2 = time(0); 
     255    do 
     256    { 
     257        t1 = t2; 
     258        camera_info.tick_count_offset = get_tick_count(); 
     259        t2 = time(0); 
     260        msleep(10); 
     261    } while (t1 != t2); 
     262    camera_info.tick_count_offset = camera_info.tick_count_offset % 1000; 
     263 
    251264    while (1) 
    252265    { 
  • trunk/core/module_exportlist.c

    r1828 r1862  
    3737 
    3838extern long shutter_open_time; // defined in platform/generic/capt_seq.c 
     39extern long shutter_open_tick_count; // defined in platform/generic/capt_seq.c 
    3940 
    4041 
     
    280281 
    281282            &shutter_open_time, 
     283            &shutter_open_tick_count, 
    282284                        &state_shooting_progress, 
    283285                        get_raw_pixel, 
  • trunk/include/camera.h

    r1830 r1862  
    305305    } props; 
    306306    int rombaseaddr, maxramaddr; 
     307    int tick_count_offset;      // get_tick_count value at which the clock ticks over 1 second 
    307308} _cam_info; 
    308309 
  • trunk/platform/generic/capt_seq.c

    r1693 r1862  
    1616 
    1717static long raw_save_stage; 
    18 volatile long shutter_open_time=0; // for DNG EXIF creation 
     18volatile long shutter_open_time=0;      // for DNG EXIF creation 
     19volatile long shutter_open_tick_count;  // for DNG EXIF creation 
    1920 
    2021void __attribute__((naked,noinline)) capt_seq_hook_raw_here() 
     
    7677    }; 
    7778 
    78  shutter_open_time=_time((void*)0);  
     79 shutter_open_time=_time((void*)0); 
     80 shutter_open_tick_count = get_tick_count(); 
    7981 
    8082 asm volatile("LDMFD   SP!, {R0-R12,PC}\n"); 
  • trunk/platform/ixus40_sd300/sub/100j/capt_seq.c

    r716 r1862  
    2323static long raw_save_stage; 
    2424volatile long shutter_open_time=0; // for DNG EXIF creation, dummy for this camera 
     25volatile long shutter_open_tick_count;  // for DNG EXIF creation 
    2526 
    2627void __attribute__((naked,noinline)) capt_seq_hook_raw_here() 
  • trunk/platform/ixus40_sd300/sub/100k/capt_seq.c

    r716 r1862  
    1313static long raw_save_stage; 
    1414volatile long shutter_open_time=0; // for DNG EXIF creation, dummy for this camera 
     15volatile long shutter_open_tick_count;  // for DNG EXIF creation 
    1516 
    1617void __attribute__((naked,noinline)) capt_seq_hook_raw_here() 
  • trunk/platform/sx130is/sub/101c/capt_seq.c

    r1128 r1862  
    1414  
    1515        shutter_open_time=_time((void*)0);  
     16    shutter_open_tick_count = get_tick_count(); 
    1617 
    1718        // Firmware also tests for 3 and 7, meaning unknown, so we don't touch them 
  • trunk/platform/sx130is/sub/101d/capt_seq.c

    r1377 r1862  
    1414  
    1515        shutter_open_time=_time((void*)0);  
     16    shutter_open_tick_count = get_tick_count(); 
    1617 
    1718        // Firmware also tests for 3 and 7, meaning unknown, so we don't touch them 
  • trunk/platform/sx130is/sub/101f/capt_seq.c

    r1377 r1862  
    1414  
    1515        shutter_open_time=_time((void*)0);  
     16    shutter_open_tick_count = get_tick_count(); 
    1617 
    1718        // Firmware also tests for 3 and 7, meaning unknown, so we don't touch them 
  • trunk/platform/sx150is/sub/100a/capt_seq.c

    r1598 r1862  
    1414  
    1515        shutter_open_time=_time((void*)0);  
     16    shutter_open_tick_count = get_tick_count(); 
    1617 
    1718        // Firmware also tests for 3 and 7, meaning unknown, so we don't touch them 
Note: See TracChangeset for help on using the changeset viewer.