Example #1
0
static exposure get_exposure(int bv, int simul) {
    exposure expo;
    
    //same tv 
    int same_tv_offset = 0;
    if(same_tv) {
        if(simul && lens_av != LENS_AV_THIS) same_tv_offset = MAX(0, lens_av - av_min);
        else same_tv_offset = MAX(0, RAW2AV(lens_info.raw_aperture_min) - av_min);
    }
    
    //av
    expo.av = MAX(av_max + (MIN(bv - av_off, 0) * av_step) / 10, av_min);
    if(simul && lens_av != LENS_AV_THIS) expo.av = MAX(lens_av, expo.av);
    else expo.av = COERCE(expo.av, RAW2AV(lens_info.raw_aperture_min), RAW2AV(lens_info.raw_aperture_max));
    
    //av
    expo.sv  = MIN(iso_min - (MIN(bv - (iso_off + same_tv_offset), 0) * iso_step) / 10, iso_max);
    if(round_iso) { expo.sv /= 10; expo.sv *= 10; }
    
    //ec
    expo.ec = COERCE(ec - (MIN(bv - (ec_off + same_tv_offset), 0) * ec_step) / 10, ec_min, ec_max);
    
    //tv
    expo.tv = COERCE((bv - expo.av + expo.sv) - expo.ec, tv_min, 130);
    
    //ec
    expo.ec = bv - (expo.tv + expo.av - expo.sv);
    
    return expo;
}
Example #2
0
void restore_kelvin_wb()
{
    msleep(500); // to make sure mode switch is complete
    // sometimes Kelvin WB and WBShift are not remembered, usually in Movie mode 
    lens_set_kelvin_value_only(workaround_wb_kelvin);
    lens_set_wbs_gm(COERCE(((int)workaround_wbs_gm) - 100, -9, 9));
    lens_set_wbs_ba(COERCE(((int)workaround_wbs_ba) - 100, -9, 9));
    //~ NotifyBox(1000, "Restored WB: %dK GM%d BA%d", workaround_wb_kelvin, workaround_wbs_gm, workaround_wbs_ba); msleep(1000);
}
Example #3
0
void lv_rec_update_preset(lv_rec_save_data_t *data)
{
    lv_rec_update_resolution(data);
    
    int presets[] = { 0, 1080, 960, 720, 480 };
    unsigned int preset_yres = presets[COERCE(lv_rec_line_skip_preset, 0, sizeof(presets)/sizeof(presets[0]))];
    
    /* calculate the height after internal cropping */
    data->internallyCroppedHeight = data->height - data->topCrop - data->bottomCrop;
    
    if(preset_yres != 0)
    {
        if(data->internallyCroppedHeight >= preset_yres)
        {
            data->options.linesToSkip = (data->internallyCroppedHeight - preset_yres) / 2;
        }
        else
        {
            data->options.linesToSkip = 0;
        }
        
        /* in raw mode we just can skip two lines */
        if(data->options.rawMode && (data->options.linesToSkip % 2))
        {
            data->options.linesToSkip--;
        }
        
        /* set global option too */
        lv_rec_line_skip = data->options.linesToSkip;
    }
    
    data->finalHeight = data->internallyCroppedHeight - data->options.linesToSkip * 2;
}
Example #4
0
static MENU_SELECT_FUNC(ec_sel) {
    int set = ec;
    ec = COERCE(ec + delta * 5, -50, 50);
    
    if(same_tv && ec - set != 0) {
        set_rear();
        aperture_range_set(NULL, delta * -1);
        iso_curve_set(NULL, delta * -1);
        ec_curve_set(NULL, delta * -1);
    }
}
Example #5
0
static void post_deflicker_save_sidecar_file(int type, char* photo_filename, float ev)
{
    /* find and strip extension */
    char* ext = photo_filename + strlen(photo_filename) - 1;
    while (ext > photo_filename && *ext != '/' && *ext != '.') ext--;
    if (*ext != '.') return;
    *ext = 0;
    
    /* find and strip base filename (e.g. IMG_1234) */
    char* p = ext;
    while (p > photo_filename && *p != '/') p--;
    if (*p != '/') return;
    *p = 0;
    
    /* path components */
    char* dir = photo_filename; /* A:/DCIM/100CANON */
    char* basename = p+1;       /* IMG_1234 */
    char* extension = ext+1;    /* CR2 */
    
    //~ NotifyBox(2000, "'%s'\n'%s'\n'%s'", dir, basename, extension);
    
    char sidecar[100];
    snprintf(sidecar, sizeof(sidecar), "%s/%s.%s", dir, basename, type ? "UFR" : "XMP");

    FILE* f = FIO_CreateFile(sidecar);
    if (!f) return;
    if (type == 0)
    {
        /* not sure */
        int evi = ev * 100000;
        
        my_fprintf(f, xmp_template, FMT_FIXEDPOINT5S(evi));
    }
    else if (type == 1)
    {
        char raw[100];
        char jpg[100];
        snprintf(raw, sizeof(raw), "%s.%s", basename, extension);
        snprintf(jpg, sizeof(jpg), "%s.JPG", basename);
        ev = COERCE(ev, -6, 6);
        int evi = ev * 100000;
        my_fprintf(f, ufraw_template, raw, jpg, FMT_FIXEDPOINT5(evi));
    }
    FIO_CloseFile(f);
}
Example #6
0
static MENU_SELECT_FUNC(last_bv_set) {
    if(last_bv == INT_MIN) last_bv = 20;
    else last_bv = COERCE(last_bv + delta * -5, BV_MIN, BV_MAX);
}
Example #7
0
static MENU_SELECT_FUNC(tv_min_set) {
    tv_min = COERCE(tv_min + delta * 5, -50, 130);
}
Example #8
0
static MENU_SELECT_FUNC(lens_av_set) {
    lens_av += delta * 5;
    if(lens_av < 0) lens_av = LENS_AV_THIS;
    lens_av = COERCE(lens_av, 0, 80);
}
void green_screen_step()
{
   /****************************************************
   *  .. if Canon menu is ACTIVE - return immediately  *
   ****************************************************/

   if (!lv)
   {
      last_green_screen_state = 0;
      return;
   }

   /********************************
   *   Masses of auto variables.   *
   ********************************/

   // unsigned int Xs,Xe;           // X_POSITION of  Cropmark_start/_end
   //~ Xs = g_cropmark_x_start;      // First Pix drawn on (and a multiple of 4)
   //~ Xe = g_cropmark_x_end;        // First Pix not drawn on (multiple of 4)
 
   // unsigned int Vram_pixels = Xe - Xs;
 

   unsigned int vpix, lum1, lum2; 

   // results from previous loop, used for display
   static int total_luma   = 0;
   static int highest_luma = 0;
   static int lowest_luma  = 256;
   static int total_pixels = 0;

   // results for current loop, being updated (will be used at next loop)
   unsigned int total_luma_tmp   = 0;
   unsigned int highest_luma_tmp = 0;
   unsigned int lowest_luma_tmp  = 256;
   unsigned int total_pixels_tmp = 0;

   /****************************************************************
   *   Set address pointers up to first line in Vram               *   
   ****************************************************************/

   uint32_t* lv = (uint32_t *) get_yuv422_vram()->vram;
   if (!lv) return;
   uint8_t* bm = bmp_vram();
   // uint16_t* bm16 = (uint16_t *) bmp_vram();
   uint8_t* bm_mirror = (uint8_t *) get_bvram_mirror();

   unsigned int average_luma = total_luma / total_pixels;
   unsigned int high_delta = highest_luma - average_luma;  // used to work out colour scale
   unsigned int low_delta  = average_luma - lowest_luma;   // colour scale for darker pixels

   /******************************************************************
   *   Go through Crop area.  Note highest and lowest luma, average  *   
   ******************************************************************/

    int high_delta_factor = 1024 / high_delta; // replace division with multiplication
    int low_delta_factor = 1024 / low_delta;

   for(int y = os.y0 + os.off_169; y < os.y_max - os.off_169; y += 2 )
   {
      uint32_t * const v_row = (uint32_t*)( lv        + BM2LV_R(y)    );  // 2 pixels
      uint16_t * const b_row = (uint16_t*)( bm        + BM_R(y)       );  // 2 pixels
      uint16_t * const m_row = (uint16_t*)( bm_mirror + BM_R(y)       );  // 2 pixels
      
      uint8_t* lvp; // that's a moving pointer through lv vram
      uint16_t* bp;  // through bmp vram
      uint16_t* mp;  // through mirror
      
      for (int x = os.x0; x < os.x_max; x += 2)
      {
         lvp = (uint8_t *) (v_row + BM2LV_X(x)/2); lvp++;
         bp = b_row + x/2;
         mp = m_row + x/2;

         /********************************************
         *  Get 4 bytes of vram (ie two vram Pixels) *
         ********************************************/

         // vpix   = [LSB=pix on left] u y1 v y2  [MSB=pix on right] 
         vpix = lv[BM2LV(x,y)/4];

         total_pixels_tmp += 2;
 
         lum1 = ( vpix & 0x0000FF00 ) >>  8;  // y1
         lum2 = ( vpix & 0xFF000000 ) >> 24;  // y2

         /*************************
         *  Update total luma     *
         *************************/

         total_luma_tmp += lum1 + lum2;

         /*************************
         *  new Maximum ?         *
         *************************/

         if (lum1 > highest_luma_tmp)
            highest_luma_tmp = lum1;

         if (lum2 > highest_luma_tmp)
            highest_luma_tmp = lum2;
     

         /*************************
         *  new Miniumum ?         *
         *************************/

         if (lum1 < lowest_luma_tmp)
            lowest_luma_tmp = lum1;

         if (lum2 < lowest_luma_tmp)
            lowest_luma_tmp = lum2;

         /*********************************************************
         *  Initialise writeback colour of overlay to 0  for LUM1 *
         *********************************************************/

         unsigned int lum = (lum1 + lum2) / 2;
         unsigned int col = 0;

         /**************************************
         *  LUM1  Higher than average luma     *
         **************************************/
       
         if (lum > average_luma)
         {
            col = ((lum-average_luma)*12) * high_delta_factor / 1024;
            
            if (col > 12)
               col=12; 

            col = 128 + (col+2) * 8;
        
         }
         else if (lum < average_luma)
         {
            /**************************************
            *  LUM1   Lower than average luma     *
            **************************************/

            col = ((average_luma-lum)*12) * low_delta_factor / 1024;

            if (col > 12)
               col=12; 

            col = 128 - (col+2) * 8;
         }

            if (col) col = ((col * 41) >> 8) + 38;
            unsigned int c = col | (col << 8);
            
         #define BP (*bp)
         #define MP (*mp)
         #define BN (*(bp + BMPPITCH/2))
         #define MN (*(mp + BMPPITCH/2))
         
         if (BP != 0 && BP != MP) { continue; }
         if (BN != 0 && BN != MN) { continue; }
         if ((MP & 0x80808080) || (MN & 0x80808080)) continue;

         MP = BP = c;
         MN = BN = c;

         #undef BP
         #undef MP
         #undef BN
         #undef MN
        }

   } // end of (y loop)
  

   /**********************************
   * commit statistics for next loop *
   **********************************/

   total_luma = total_luma_tmp;
   highest_luma = highest_luma_tmp;
   lowest_luma = lowest_luma_tmp;
   total_pixels = total_pixels_tmp;

   /**********************************
   *   Display average, min and max  *   
   **********************************/

   bmp_printf( FONT(FONT_MED, COLOR_WHITE, COLOR_BLACK), 
               os.x0 + os.x_ex/2 - font_med.width*7, os.y_max - os.off_169 - 47, 
               "Average = %03d",average_luma);

   bmp_printf( FONT(FONT_MED,COLOR_CYAN, COLOR_BLACK), 
               os.x0, os.y_max - os.off_169 - 47, 
               "MIN = %03d",lowest_luma);

   bmp_printf( FONT(FONT_MED,COLOR_YELLOW, COLOR_BLACK), 
               os.x_max - font_med.width*9,
               os.y_max - os.off_169 - 47, 
               "%03d = MAX",highest_luma);


   bmp_printf( FONT(FONT_MED,COLOR_WHITE, COLOR_BLACK), 
               os.x0 + os.x_ex/2 - font_med.width*7, os.y_max - os.off_169 - 27, 
               "Accuracy=%03d%%",((255-(highest_luma-lowest_luma))*99 )/255
             );

   bmp_printf( FONT(FONT_MED,COLOR_CYAN, COLOR_BLACK), 
               os.x0, os.y_max - os.off_169 - 27, 
               "delta %03d", COERCE(average_luma - lowest_luma, 0, 255));

   bmp_printf( FONT(FONT_MED, COLOR_YELLOW, COLOR_BLACK), 
               os.x_max - font_med.width*9,
               os.y_max - os.off_169 - 27, 
               "%03d delta", COERCE(highest_luma - average_luma, 0, 255));

   msleep(10); // don't kill the battery :)

} /* end of green_screen_step() */
Example #10
0
void set_alo(int value)
{
	value = COERCE(value, 0, 3);
	prop_request_change(PROP_ALO, &value, 4);
}
Example #11
0
void LensFocusSetup(int stepsize, int stepdelay, int wait)
{
    lens_focus_stepsize = COERCE(stepsize, 1, 3);
    lens_focus_waitflag = wait;
    lens_focus_delay = stepdelay/10;
}
Example #12
0
static float raw_to_ev_custom(int raw, int white_level)
{
    int raw_max = white_level - raw_info.black_level;
    float raw_ev = -log2f(raw_max) + log2f(COERCE(raw - raw_info.black_level, 1, raw_max));
    return raw_ev;
}