Beispiel #1
0
static void post_deflicker_task()
{
    /* not quite correct in burst mode, but at least only one task will run at a time */
    /* so at least the last deflicker in a burst sequence should be correct */
    deflicker_waiting++;
    take_semaphore(deflicker_sem, 0);
    deflicker_waiting--;
    
    int raw_fast = raw_hist_get_percentile_level(post_deflicker_percentile*10, GRAY_PROJECTION_GREEN, 4);
    //~ console_printf("fast deflick: %d\n", raw_fast);
    int raw = raw_fast;
        
    /* no rush? do a precise deflicker */
    for (int i = 0; i < 10; i++)
    {
        msleep(100);
        if (deflicker_waiting) break;
    }
    if (!deflicker_waiting)
    {
        int raw_precise = raw_hist_get_percentile_level(post_deflicker_percentile*10, GRAY_PROJECTION_GREEN, 0);
        //~ console_printf("precise deflick: %d\n", raw_precise);
        if (raw_precise > 0 && raw_precise < 16384) raw = raw_precise;
    }
    //~ else console_printf("hurry, hurry\n");
    
    if (raw <= 0 || raw >= 16384)
    {
        deflicker_last_correction_x100 = 0;
        give_semaphore(deflicker_sem);
        return;
    }
    
    /* assume a fixed white level, like most raw image processors do */
    /* any value around 15000 will do (the effect of changing it would be a small shift in exposure, same amount in all images) */
    /* without this, variations in the the default (autodetected) white level will introduce flicker */
    float ev = raw_to_ev_custom(raw, 15000);

    float correction = post_deflicker_target_level - ev;
    deflicker_last_correction_x100 = (int)roundf(correction * 100);

    console_printf("deflick corr: %s%d.%02d\n", FMT_FIXEDPOINT2S(deflicker_last_correction_x100));
    post_deflicker_save_sidecar_file_for_cr2(post_deflicker_sidecar_type, get_shooting_card()->file_number, correction);
    give_semaphore(deflicker_sem);
}
Beispiel #2
0
static void
focus_toggle( void * priv )
{
    if (focus_rack_delta) return; // another rack focus operation in progress
    menu_enable_lv_transparent_mode();
    focus_task_delta = -focus_task_delta;
    focus_rack_delta = focus_task_delta;
    give_semaphore( focus_task_sem );
}
Beispiel #3
0
void
lens_focus_start(
    int     dir
)
{
    if( dir == 0 )
        focus_task_dir_n_speedx = focus_dir ? 1 : -1;
    else
        focus_task_dir_n_speedx = dir; // this includes the focus speed multiplier (1 = FF+, 2 = FF++)

    give_semaphore( focus_task_sem );
}
Beispiel #4
0
// this can be called from more tasks (gui, prop handler, menu), so it needs to be thread safe
void config_save()
{
#ifdef CONFIG_CONFIG_FILE
    take_semaphore(config_save_sem, 0);
    update_disp_mode_bits_from_params();
    char config_file[0x80];
    snprintf(config_file, sizeof(config_file), "%smagic.cfg", get_config_dir());
    config_save_file(config_file);
    config_menu_save_flags();
    module_save_configs();
    if (config_deleted) config_autosave = 1; /* this can be improved, because it's not doing a proper "undo" */
    config_deleted = 0;
    give_semaphore(config_save_sem);
#endif
}