Skip to content

Commit

Permalink
scriptless badpixel.bin creation, from ultimA in http://chdk.setepont…
Browse files Browse the repository at this point in the history
  • Loading branch information
reyalP authored and reyalP committed Jan 9, 2011
1 parent bd66c51 commit 229feb9
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHDK/LANG/english.lng
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@
423 "Rear curtain flash sync"
424 "DNG format"
425 "RAW buffer cached"
426 "Cannot load CHDK/badpixel.bin\nPlease run \nCHDK/SCRIPTS/TEST/badpixel.lua"
426 "Cannot load CHDK/badpixel.bin\nUse Create badpixel.bin in raw menu"
427 "Show raw saving time"
428 "Connect 4"
429 "Opponent:"
Expand Down Expand Up @@ -594,3 +594,5 @@
456 "Filter edges"
457 "Always show"
458 " Pano overlap (%)"
459 "Create badpixel.bin"
460 "You need to be in REC-mode\nfor this operation."
2 changes: 2 additions & 0 deletions CHDK/LANG/german.lng
Original file line number Diff line number Diff line change
Expand Up @@ -576,3 +576,5 @@
456 "Konturenfilterung"
457 "Kontinuierlich anz."
458 " Pano-�berlappung (%)"
459 "badpixel.bin erstellen"
460 "REC-Modus erforderlich."
2 changes: 2 additions & 0 deletions CHDK/LANG/hungarian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,5 @@
456 "�lek sz�r�se"
457 "Folyamatos megjel."
458 " �tfed�s (%)"
459 "badpixel.bin ment�se"
460 "El�bb l�pj REC-modba."
6 changes: 6 additions & 0 deletions core/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ static void cb_zebra_restore_screen();
static void cb_zebra_restore_osd();
#if DNG_SUPPORT
static void cb_change_dng();
void gui_menuproc_badpixel_create(int arg);
#endif
#if defined (DNG_EXT_FROM)
static void cb_change_dng_usb_ext();
Expand Down Expand Up @@ -821,6 +822,7 @@ static CMenuItem raw_submenu_items[] = {
#if DNG_SUPPORT
{0x5c,LANG_MENU_DNG_FORMAT, MENUITEM_BOOL | MENUITEM_ARG_CALLBACK, &conf.dng_raw , (int)cb_change_dng },
{0x5c,LANG_MENU_RAW_DNG_EXT, MENUITEM_BOOL, &conf.raw_dng_ext},
{0x2a,LANG_MENU_BADPIXEL_CREATE, MENUITEM_PROC, (int*)gui_menuproc_badpixel_create },
#endif
{0x5c,LANG_MENU_RAW_CACHED, MENUITEM_BOOL, &conf.raw_cache },
{0x51,LANG_MENU_BACK, MENUITEM_UP },
Expand Down Expand Up @@ -1008,6 +1010,10 @@ void cb_change_dng(){
conf_change_dng();
if ((old==1) && (conf.dng_raw==0)) gui_mbox_init(LANG_ERROR, LANG_CANNOT_OPEN_BADPIXEL_FILE, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
}

void gui_menuproc_badpixel_create(int arg) {
create_badpixel_bin();
}
#endif

#if defined (DNG_EXT_FROM)
Expand Down
2 changes: 2 additions & 0 deletions core/gui_lang.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ static char* gui_lang_default = \
"456 \"Filter edges\"\n"
"457 \"Always show\"\n"
"458 \" Pano overlap (%)\"\n"
"459 \"Create badpixel.bin\"\n"
"460 \"You need to be in REC-mode\\nfor this operation.\"\n"
;

//-------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion core/gui_lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,11 @@
#define LANG_MENU_EDGE_FILTER 456
#define LANG_MENU_EDGE_SHOW 457
#define LANG_MENU_EDGE_PANO_OVERLAP 458
#define LANG_MENU_BADPIXEL_CREATE 459
#define LANG_MSG_RECMODE_REQUIRED 460
//-------------------------------------------------------------------

#define GUI_LANG_ITEMS 458
#define GUI_LANG_ITEMS 460

//-------------------------------------------------------------------
extern void gui_lang_init();
Expand Down
95 changes: 94 additions & 1 deletion core/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#if DNG_SUPPORT
#include "dng.h"
#include "math.h"
#include "keyboard.h"
#include "action_stack.h"
#include "gui_draw.h"
#include "gui_mbox.h"
#include "gui_lang.h"
#endif
#ifdef OPT_CURVES
#include "curves.h"
Expand Down Expand Up @@ -49,7 +54,7 @@ char* get_alt_raw_image_addr(void){ // return inactive buffer for cameras with m

//-------------------------------------------------------------------

unsigned int get_bad_count_and_write_file(char *fn){
unsigned int get_bad_count_and_write_file(const char *fn){
int count=0;
unsigned short c[2];
FILE*f;
Expand Down Expand Up @@ -122,6 +127,8 @@ int raw_savefile() {
char* altrawadr = get_alt_raw_image_addr();

// ! ! ! exclusively for special script which creates badpixel.bin ! ! !
// NOTE: get_bad_count_and_write_file() must be called from here and cannot be called
// outside of this function.
if (conf.save_raw==255) conf.save_raw=get_bad_count_and_write_file("A/CHDK/bad_tmp.bin");
//

Expand Down Expand Up @@ -441,4 +448,90 @@ void unpatch_bad_pixels_b(void){
int badpixel_list_loaded_b(void){
return binary_count;
}

// -----------------------------------------------

enum BadpixelFSM
{
BADPIX_START,
BADPIX_S1,
BADPIX_S2
};

int badpixel_task_stack(long p)
{
static unsigned int badpix_cnt1, badpix_cnt2;
static int raw_conf_bck;

switch(p)
{

case BADPIX_START:
action_pop();

console_clear();
console_add_line("Wait please... ");
console_add_line("This takes a few seconds,");
console_add_line("don't panic!");

raw_conf_bck = conf.save_raw;
conf.save_raw = 255;

shooting_set_tv96_direct(96, SET_LATER);
action_push(BADPIX_S1);
action_push(AS_SHOOT);
action_push_delay(3000);
break;
case BADPIX_S1:
action_pop();

badpix_cnt1 = conf.save_raw;
shooting_set_tv96_direct(96, SET_LATER);

action_push(BADPIX_S2);
action_push(AS_SHOOT);
break;
case BADPIX_S2:
action_pop();

badpix_cnt2 = conf.save_raw;
conf.save_raw = raw_conf_bck;

console_clear();
if (badpix_cnt1 == badpix_cnt2)
{
char msg[32];
console_add_line("badpixel.bin created.");
sprintf(msg, "Bad pixel count: %d", badpix_cnt1);
console_add_line(msg);
}
else
{
console_add_line("badpixel.bin failed.");
console_add_line("Please try again.");
}

action_push_delay(3000);
break;
default:
action_stack_standard(p);
break;
}

return 1;
}


void create_badpixel_bin()
{
if (!(mode_get() & MODE_REC))
{
gui_mbox_init(LANG_ERROR, LANG_MSG_RECMODE_REQUIRED, MBOX_BTN_OK|MBOX_TEXT_CENTER, NULL);
return;
}

gui_set_mode(GUI_MODE_ALT);
action_stack_create(&badpixel_task_stack, BADPIX_START);
}

#endif
4 changes: 4 additions & 0 deletions core/raw.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ extern void raw_postprocess();
extern void raw_prepare_develop(const char* filename);
extern void load_bad_pixels_list(const char* filename);
unsigned short get_raw_pixel(unsigned int x,unsigned int y);

#if DNG_SUPPORT
void load_bad_pixels_list_b(char* filename);
void unload_bad_pixels_list_b(void);
void patch_bad_pixels_b(void);
void unpatch_bad_pixels_b(void);
int badpixel_list_loaded_b(void);
char* get_raw_image_addr(void);
void create_badpixel_bin();
#endif

//-------------------------------------------------------------------
#endif

0 comments on commit 229feb9

Please sign in to comment.