- Timestamp:
- 04/01/10 10:10:59 (3 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
core/conf.c (modified) (1 diff)
-
core/gui.c (modified) (5 diffs)
-
core/gui_osd.c (modified) (7 diffs)
-
core/gui_osd.h (modified) (1 diff)
-
core/luascript.c (modified) (5 diffs)
-
core/luascript.h (modified) (1 diff)
-
include/conf.h (modified) (1 diff)
-
include/platform.h (modified) (2 diffs)
-
lib/ubasic/camera_functions.c (modified) (1 diff)
-
lib/ubasic/tokenizer.c (modified) (1 diff)
-
lib/ubasic/tokenizer.h (modified) (1 diff)
-
lib/ubasic/ubasic.c (modified) (1 diff)
-
platform/generic/shooting.c (modified) (3 diffs)
-
version.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/conf.c
r177 r305 278 278 CONF_INFO(124, conf.show_osd_in_review, CONF_DEF_VALUE, i:0, NULL), 279 279 280 CONF_INFO(125, conf.dof_dist_from_lens, CONF_DEF_VALUE, i:0, NULL),280 // CONF_INFO(125, conf.dof_dist_from_lens, CONF_DEF_VALUE, i:0, NULL), 281 281 282 282 CONF_INFO(126, conf.clear_bracket, CONF_DEF_VALUE, i:1, NULL), -
trunk/core/gui.c
r302 r305 484 484 {0x5c,LANG_MENU_DOF_HYPERFOCAL_IN_MISC, MENUITEM_BOOL, &conf.dof_hyperfocal_in_misc}, 485 485 {0x5c,LANG_MENU_DOF_DEPTH_LIMIT_IN_MISC, MENUITEM_BOOL, &conf.dof_depth_in_misc}, 486 {0x5c,LANG_MENU_DOF_DIST_FROM_LENS, MENUITEM_BOOL, &conf.dof_dist_from_lens},487 486 {0x51,LANG_MENU_BACK, MENUITEM_UP }, 488 487 {0} … … 1302 1301 1303 1302 const char* gui_dof_show_value_enum(int change, int arg) { 1304 static const char* modes[]={ "Don't", "Separate", " In Misc" };1303 static const char* modes[]={ "Don't", "Separate", "+Separate", "In Misc", "+In Misc" }; 1305 1304 1306 1305 conf.show_dof+=change; … … 2420 2419 int m=mode_get()&MODE_SHOOTING_MASK; 2421 2420 if ((m==MODE_M) || (m==MODE_AV)) 2422 conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance_ f(shooting_get_aperture_from_av96(shooting_get_user_av96()),get_focal_length(lens_get_zoom_point()));2421 conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance_1e3_f(shooting_get_aperture_from_av96(shooting_get_user_av96()),get_focal_length(lens_get_zoom_point()))/1000; 2423 2422 else conf.subj_dist_override_value=(int)shooting_get_hyperfocal_distance(); 2424 2423 shooting_set_focus(shooting_get_subject_distance_override_value(), SET_NOW); … … 2824 2823 if (conf.show_dof!=DOF_DONT_SHOW) gui_osd_calc_dof(); 2825 2824 2826 if ( conf.show_dof==DOF_SHOW_IN_DOF) gui_osd_draw_dof();2825 if ((conf.show_dof==DOF_SHOW_IN_DOF) || (conf.show_dof==DOF_SHOW_IN_DOF_EX)) gui_osd_draw_dof(); 2827 2826 2828 2827 if (conf.values_show_real_iso || conf.values_show_market_iso || conf.values_show_ev_seted || conf.values_show_ev_measured || conf.values_show_bv_measured || conf.values_show_bv_seted || conf.values_show_overexposure || conf.values_show_canon_overexposure || conf.values_show_luminance) gui_osd_calc_expo_param(); … … 2833 2832 if ((conf.show_values==SHOW_ALWAYS && mode_photo) || ((mode_video || movie_status > 1)&& conf.show_values_in_video) || ((kbd_is_key_pressed(KEY_SHOOT_HALF) || (recreview_hold==1)) && (conf.show_values==SHOW_HALF))) 2834 2833 gui_osd_draw_values(1); 2835 else if (shooting_get_common_focus_mode() && mode_photo && conf.show_values && !( conf.show_dof==DOF_SHOW_IN_DOF))2834 else if (shooting_get_common_focus_mode() && mode_photo && conf.show_values && !((conf.show_dof==DOF_SHOW_IN_DOF) || (conf.show_dof==DOF_SHOW_IN_DOF_EX))) 2836 2835 gui_osd_draw_values(2); 2837 2836 else if (conf.show_values==SHOW_HALF) -
trunk/core/gui_osd.c
r275 r305 82 82 #endif 83 83 84 static DOF_TYPE dof;84 DOF_TYPE dof_values; 85 85 static EXPO_TYPE expo; 86 86 … … 338 338 gui_grid_draw_osd(1); 339 339 } 340 if ( conf.show_dof == DOF_SHOW_IN_DOF) {340 if ((conf.show_dof == DOF_SHOW_IN_DOF) || (conf.show_dof == DOF_SHOW_IN_DOF_EX)) { 341 341 gui_osd_draw_dof(); 342 342 } … … 858 858 void gui_osd_calc_dof() { 859 859 860 int av, av_min, c_of_c, fl, v, v1, m; 861 //long lfpfl=lens_get_focus_pos_fl(); 862 863 #if CAM_HAS_IRIS_DIAPHRAGM 864 av=shooting_get_real_aperture(); 865 #else 866 av=shooting_get_min_real_aperture(); 867 #endif 868 fl=get_focal_length(lens_get_zoom_point()); 869 dof.far_limit=-1.0; 870 dof.near_limit=-1.0; 871 dof.depth_of_field=-1.0; 872 dof.hyperfocal_distance=-1.0; 873 dof.subject_distance=-1.0; 874 875 if ((av!=0) && (fl!=0)) { 876 if (conf.dof_subj_dist_as_near_limit) { 877 v1=(fl*fl); 878 dof.near_limit=shooting_get_canon_subject_distance(); 879 av_min=shooting_get_min_real_aperture(); 880 c_of_c=circle_of_confusion*10; 881 if ((av_min!=0) && (c_of_c!=0)) dof.hyperfocal_distance=v1/(c_of_c*av_min); 882 if ((dof.near_limit>0) && (dof.near_limit<MAX_DIST)) { 883 v=(dof.hyperfocal_distance-dof.near_limit); 884 m=dof.hyperfocal_distance*dof.near_limit; 885 if ((v>0) && (m>0)) dof.subject_distance=m/v; 886 } 887 dof.hyperfocal_distance=v1/(c_of_c*av); 888 if ((dof.subject_distance>0) && (dof.subject_distance<MAX_DIST)) { 889 v = (dof.hyperfocal_distance-dof.subject_distance); 890 m=dof.hyperfocal_distance*dof.subject_distance; 891 if ((v>0) && (m>0)) dof.far_limit=m/v; 892 dof.depth_of_field=dof.far_limit-dof.near_limit; 893 } 894 } 895 else { 896 dof.subject_distance=shooting_get_canon_subject_distance(); 897 dof.hyperfocal_distance=(fl*fl)/(10*circle_of_confusion*av); 898 if (dof.subject_distance>0 && dof.subject_distance<MAX_DIST) { 899 m = dof.hyperfocal_distance*dof.subject_distance; 900 v = (dof.hyperfocal_distance+dof.subject_distance); 901 if ((v>0) && (m>0)) dof.near_limit=m/v; 902 v = (dof.hyperfocal_distance-dof.subject_distance); 903 if ((v>0) && (m>0)) dof.far_limit=m/v; 904 dof.depth_of_field=dof.far_limit-dof.near_limit; 905 } 906 } 907 } 908 if (conf.dof_dist_from_lens) { 909 int h=shooting_get_lens_to_focal_plane_width(); 910 if (dof.subject_distance>0) dof.subject_distance-=h; 911 if (dof.far_limit>0) dof.far_limit-=h; 912 if (dof.near_limit>0) dof.near_limit-=h; 913 if (dof.hyperfocal_distance>0) dof.hyperfocal_distance-=h; 914 } 860 shooting_update_dof_values(); 915 861 } 916 862 … … 934 880 void gui_osd_draw_dof() { 935 881 936 //gui_osd_calc_dof(); 937 //strcpy(osd_buf, ""); 938 draw_string(conf.dof_pos.x, conf.dof_pos.y, "S/R1/R2:", conf.osd_color); 939 sprintf_dist(osd_buf, dof.subject_distance); 940 int i=strlen(osd_buf); 941 osd_buf[i]='/'; 942 sprintf_dist(osd_buf+i+1, dof.near_limit); 943 i=strlen(osd_buf); 944 osd_buf[i]='/'; 945 sprintf_dist(osd_buf+i+1, dof.far_limit); 946 draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y, osd_buf, conf.osd_color); 947 948 draw_string(conf.dof_pos.x, conf.dof_pos.y+FONT_HEIGHT, "DOF/HYP:", conf.osd_color); 949 sprintf_dist(osd_buf, dof.depth_of_field); 882 color valid_col = (conf.osd_color & 0xff00) | COLOR_GREEN; 883 int i=8; 884 short f_ex = (conf.show_dof==DOF_SHOW_IN_DOF_EX); 885 draw_string(conf.dof_pos.x, conf.dof_pos.y, "S/NL/FL:", conf.osd_color); 886 sprintf_dist(osd_buf, (float)dof_values.subject_distance); 950 887 int j=strlen(osd_buf); 951 osd_buf[j]='/'; 952 sprintf_dist(osd_buf+j+1, dof.hyperfocal_distance); 953 draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); 954 888 draw_string(conf.dof_pos.x+i*FONT_WIDTH, conf.dof_pos.y, osd_buf, 889 (f_ex && (dof_values.distance_valid || shooting_get_focus_mode()))?valid_col:conf.osd_color); 890 i=i+j; 891 draw_string(conf.dof_pos.x+i*FONT_WIDTH, conf.dof_pos.y, "/", conf.osd_color); 892 sprintf_dist(osd_buf, (float)dof_values.near_limit); 893 j=strlen(osd_buf); 894 draw_string(conf.dof_pos.x+(++i)*FONT_WIDTH, conf.dof_pos.y, osd_buf, 895 (f_ex && dof_values.distance_valid)?valid_col:conf.osd_color); 896 i=i+j; 897 draw_string(conf.dof_pos.x+i*FONT_WIDTH, conf.dof_pos.y, "/", conf.osd_color); 898 sprintf_dist(osd_buf, (float)dof_values.far_limit); 899 draw_string(conf.dof_pos.x+(++i)*FONT_WIDTH, conf.dof_pos.y, osd_buf, 900 (f_ex && dof_values.distance_valid)?valid_col:conf.osd_color); 901 i=8; 902 draw_string(conf.dof_pos.x, conf.dof_pos.y+FONT_HEIGHT, "DOF/HYP:", conf.osd_color); 903 sprintf_dist(osd_buf, (float)dof_values.depth_of_field); 904 j=strlen(osd_buf); 905 draw_string(conf.dof_pos.x+i*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, osd_buf, 906 (f_ex && dof_values.distance_valid)?valid_col:conf.osd_color); 907 i=i+j; 908 draw_string(conf.dof_pos.x+i*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, "/", conf.osd_color); 909 sprintf_dist(osd_buf, (float)dof_values.hyperfocal_distance); 910 draw_string(conf.dof_pos.x+(++i)*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, osd_buf, 911 (f_ex && dof_values.hyperfocal_valid)?valid_col:conf.osd_color); 955 912 } 956 913 … … 1014 971 } 1015 972 1016 973 /* 1017 974 void gui_print_osd_misc_string_dist(const char * title, int value) { 1018 975 strcpy(osd_buf, title); … … 1021 978 osd_buf[9]=0; 1022 979 draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); 980 m+=FONT_HEIGHT; 981 } 982 */ 983 984 void gui_print_osd_dof_string_dist(const char * title, int value, short use_good_color) { 985 strcpy(osd_buf, title); 986 int i=strlen(osd_buf); 987 if (i<8) { 988 draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); 989 sprintf_dist(osd_buf, (float)value); 990 sprintf(osd_buf+strlen(osd_buf), "%9s", ""); 991 osd_buf[9-i]=0; 992 draw_string(conf.values_pos.x+i*FONT_WIDTH, conf.values_pos.y+m, osd_buf, use_good_color?((conf.osd_color & 0xff00) | COLOR_GREEN):conf.osd_color); 993 } else { 994 osd_buf[9]=0; 995 draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); 996 } 1023 997 m+=FONT_HEIGHT; 1024 998 } … … 1177 1151 } 1178 1152 1179 1180 1153 if ((conf.values_show_real_aperture) && (showtype==1)) 1181 1154 gui_print_osd_misc_string_float("Av :", "%d.%02d ", 100, shooting_get_real_aperture()); 1182 if ((conf.show_dof==DOF_SHOW_IN_MISC) && (showtype)) { 1183 //if (kbd_is_key_pressed(KEY_SHOOT_HALF) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH)) 1184 //gui_osd_calc_dof(); 1185 if (conf.dof_subj_dist_in_misc) gui_print_osd_misc_string_dist("SD :", dof.subject_distance); 1186 if (conf.dof_near_limit_in_misc) gui_print_osd_misc_string_dist("NL :", dof.near_limit); 1187 if (conf.dof_far_limit_in_misc) gui_print_osd_misc_string_dist("FL :", dof.far_limit); 1188 if (conf.dof_depth_in_misc) gui_print_osd_misc_string_dist("DOF:", dof.depth_of_field); 1189 if (conf.dof_hyperfocal_in_misc) gui_print_osd_misc_string_dist("HYP:", dof.hyperfocal_distance); 1155 short f_ex = (conf.show_dof==DOF_SHOW_IN_MISC_EX); 1156 if (((conf.show_dof==DOF_SHOW_IN_MISC) && (showtype)) || f_ex) { 1157 if (f_ex) gui_osd_calc_dof(); 1158 if (conf.dof_subj_dist_in_misc) gui_print_osd_dof_string_dist("SD :", dof_values.subject_distance, 1159 f_ex && (dof_values.distance_valid || shooting_get_focus_mode())); 1160 if (conf.dof_near_limit_in_misc) gui_print_osd_dof_string_dist("NL :", dof_values.near_limit, 1161 f_ex && dof_values.distance_valid); 1162 if (conf.dof_far_limit_in_misc) gui_print_osd_dof_string_dist("FL :", dof_values.far_limit, 1163 f_ex && dof_values.distance_valid); 1164 if (conf.dof_depth_in_misc) gui_print_osd_dof_string_dist("DOF:", dof_values.depth_of_field, 1165 f_ex && dof_values.distance_valid); 1166 if (conf.dof_hyperfocal_in_misc) gui_print_osd_dof_string_dist("HYP:", dof_values.hyperfocal_distance, 1167 f_ex && dof_values.hyperfocal_valid); 1190 1168 } 1191 1169 if (showtype==1) { -
trunk/core/gui_osd.h
r11 r305 30 30 #define DOF_DONT_SHOW 0 31 31 #define DOF_SHOW_IN_DOF 1 32 #define DOF_SHOW_IN_MISC 2 32 #define DOF_SHOW_IN_DOF_EX 2 33 #define DOF_SHOW_IN_MISC 3 34 #define DOF_SHOW_IN_MISC_EX 4 33 35 //ARM End 34 36 -
trunk/core/luascript.c
r282 r305 18 18 #include "curves.h" 19 19 20 DOF_TYPE dof_values; 21 20 22 static int luaCB_set_curve_state( lua_State* L ) 21 23 { … … 129 131 } 130 132 131 static int luaCB_get_dof( lua_State* L ) 132 { 133 lua_pushnumber( L, shooting_get_depth_of_field() ); 134 return 1; 135 } 136 137 static int luaCB_get_far_limit( lua_State* L ) 138 { 139 lua_pushnumber( L, shooting_get_far_limit_of_acceptable_sharpness() ); 133 static int luaCB_get_dofinfo( lua_State* L ) 134 { 135 shooting_update_dof_values(); 136 lua_createtable(L, 0, 12); 137 SET_BOOL_FIELD("hyp_valid", (dof_values.hyperfocal_valid!=0)); 138 SET_BOOL_FIELD("focus_valid", (dof_values.distance_valid!=0)); 139 SET_INT_FIELD("aperture", dof_values.aperture_value); 140 SET_INT_FIELD("coc", circle_of_confusion); 141 SET_INT_FIELD("focal_length", dof_values.focal_length); 142 SET_INT_FIELD("eff_focal_length", get_effective_focal_length(lens_get_zoom_point())); 143 SET_INT_FIELD("focus", dof_values.subject_distance); 144 SET_INT_FIELD("near", dof_values.near_limit); 145 SET_INT_FIELD("far", dof_values.far_limit); 146 SET_INT_FIELD("hyp_dist", dof_values.hyperfocal_distance); 147 SET_INT_FIELD("dof", dof_values.depth_of_field); 148 SET_INT_FIELD("min_stack_dist", dof_values.min_stack_distance); 140 149 return 1; 141 150 } … … 153 162 } 154 163 155 static int luaCB_get_focal_length( lua_State* L )156 {157 lua_pushnumber( L, get_focal_length(lens_get_zoom_point()) );158 return 1;159 }160 161 static int luaCB_get_hyp_dist( lua_State* L )162 {163 lua_pushnumber( L, shooting_get_hyperfocal_distance() );164 return 1;165 }166 167 164 static int luaCB_get_iso_market( lua_State* L ) 168 165 { … … 186 183 { 187 184 lua_pushnumber( L, GetJpgCount() ); 188 return 1;189 }190 191 static int luaCB_get_near_limit( lua_State* L )192 {193 lua_pushnumber( L, shooting_get_near_limit_of_acceptable_sharpness() );194 185 return 1; 195 186 } … … 1364 1355 FUNC(get_day_seconds); 1365 1356 FUNC(get_disk_size); 1366 FUNC(get_dof); 1367 FUNC(get_far_limit); 1357 FUNC(get_dofinfo); 1368 1358 FUNC(get_free_disk_space); 1369 1359 FUNC(get_focus); 1370 FUNC(get_focal_length);1371 FUNC(get_hyp_dist);1372 1360 FUNC(get_iso_market); 1373 1361 FUNC(get_iso_mode); 1374 1362 FUNC(get_iso_real); 1375 1363 FUNC(get_jpg_count); 1376 FUNC(get_near_limit);1377 1364 FUNC(get_prop); 1378 1365 FUNC(get_raw_count); -
trunk/core/luascript.h
r11 r305 7 7 8 8 #endif 9 10 #define SET_STR_FIELD( KEY, VAL ) \ 11 lua_pushstring( L, VAL ); \ 12 lua_setfield( L, -2, KEY ) 13 14 #define SET_INT_FIELD( KEY, VAL ) \ 15 lua_pushnumber( L, VAL ); \ 16 lua_setfield( L, -2, KEY ) 17 18 #define SET_BOOL_FIELD( KEY, VAL ) \ 19 lua_pushboolean( L, VAL ); \ 20 lua_setfield( L, -2, KEY ) 21 -
trunk/include/conf.h
r177 r305 219 219 int dof_hyperfocal_in_misc; 220 220 int dof_depth_in_misc; 221 int dof_dist_from_lens;221 // int dof_dist_from_lens; 222 222 223 223 -
trunk/include/platform.h
r282 r305 143 143 144 144 typedef struct { 145 int subject_distance; 146 int near_limit; 147 int far_limit; 148 int hyperfocal_distance; 149 int depth_of_field; 150 int lens_to_focal_plane_width; 145 short hyperfocal_valid; 146 short distance_valid; 147 int hyperfocal_distance_1e3; 148 int aperture_value; 149 int focal_length; 150 int subject_distance; 151 int near_limit; 152 int far_limit; 153 int hyperfocal_distance; 154 int depth_of_field; 155 int min_stack_distance; 151 156 } DOF_TYPE; 157 158 extern DOF_TYPE dof_values; 152 159 153 160 typedef struct { … … 320 327 short shooting_get_focus_state(); 321 328 short shooting_get_focus_ok(); 329 void shooting_update_dof_values(); 322 330 int shooting_get_hyperfocal_distance(); 323 int shooting_get_hyperfocal_distance_ f(int av, int fl);331 int shooting_get_hyperfocal_distance_1e3_f(int av, int fl); 324 332 int shooting_get_near_limit_of_acceptable_sharpness(); 325 333 int shooting_get_far_limit_of_acceptable_sharpness(); 326 334 int shooting_get_depth_of_field(); 335 int shooting_get_min_stack_distance(); 327 336 int shooting_get_subject_distance(); 328 337 int shooting_get_subject_distance_override_value(); -
trunk/lib/ubasic/camera_functions.c
r282 r305 362 362 } 363 363 364 short shooting_get_min_stack_distance() 365 { 366 printf("*** shooting_get_min_stack_distance ***\n"); 367 return 77; 368 } 369 364 370 short shooting_get_iso_market() 365 371 { -
trunk/lib/ubasic/tokenizer.c
r282 r305 125 125 {"get_iso", TOKENIZER_GET_ISO_MODE}, //FOR COMPATIBILITY 126 126 {"get_jpg_count", TOKENIZER_GET_JPG_COUNT}, 127 {"get_min_stack_dist", TOKENIZER_GET_MIN_STACK_DIST}, 127 128 {"get_movie_status", TOKENIZER_GET_MOVIE_STATUS}, 128 129 {"get_mode", TOKENIZER_GET_MODE}, // Returns 0 in recordmode, 1 in playmode -
trunk/lib/ubasic/tokenizer.h
r282 r305 199 199 TOKENIZER_GET_FOCUS_STATE, 200 200 TOKENIZER_GET_FOCUS_OK, 201 TOKENIZER_GET_MIN_STACK_DIST, 201 202 202 203 } ubasic_token; -
trunk/lib/ubasic/ubasic.c
r298 r305 540 540 r = get_focal_length(lens_get_zoom_point()); 541 541 break; 542 case TOKENIZER_GET_MIN_STACK_DIST: 543 accept(TOKENIZER_GET_MIN_STACK_DIST); 544 r = shooting_get_min_stack_distance(); 545 break; 542 546 } 543 547 default: -
trunk/platform/generic/shooting.c
r302 r305 60 60 static EXPO_BRACKETING_VALUES bracketing; 61 61 62 DOF_TYPE dof_values; 63 62 64 //*********************** 63 65 /* … … 419 421 } 420 422 421 int shooting_get_hyperfocal_distance_() 422 { 423 int av=shooting_get_real_aperture(); 424 int fl=get_focal_length(lens_get_zoom_point()); 425 if ((av>0) && (fl>0)) return (fl*fl)/(10*circle_of_confusion*av); 423 short shooting_get_aperture_from_av96_1e3(short av96) { 424 if (av96) return (short)(pow(sqrt2, (((double)av96)/96.0))*1000.0 + 0.5); 425 else return -1; 426 } 427 428 int shooting_get_hyperfocal_distance_1e3_f2(int av_1e3, int fl) 429 { 430 if ((av_1e3>0) && (fl>0) && (circle_of_confusion>0)) 431 return (((fl*fl)/(av_1e3*circle_of_confusion)*2000)+2*fl+1)/2; 426 432 else return (-1); 427 433 } 428 434 435 int shooting_get_hyperfocal_distance_1e3_f(int av, int fl) 436 { 437 if ((av>0) && (fl>0) && (circle_of_confusion>0)) 438 return (((fl*fl)/(av*circle_of_confusion)*200)+2*fl+1)/2; 439 else return (-1); 440 } 441 442 int shooting_get_near_limit_f(int s, int av, int fl) 443 { 444 int h_1e3 = shooting_get_hyperfocal_distance_1e3_f(av, fl); 445 int m = ((h_1e3 - fl)+500)/1000*s; 446 int v = ((h_1e3 + 1000*s - 2*fl)+500)/1000; 447 if ((m>0) && (v>0)) return ((2*m/v+1)/2); 448 else return (-1); 449 } 450 451 int shooting_get_far_limit_f(int s, int av, int fl) 452 { 453 if (s<MAX_DIST) { 454 int h_1e3 = shooting_get_hyperfocal_distance_1e3_f(av, fl); 455 int m = ((h_1e3 - fl)+500)/1000*s; 456 int v = ((h_1e3 - 1000*s)+500)/1000; 457 if ((m>0) && (v>0)) return ((2*m/v+1)/2); 458 else return (-1); 459 } else return (-1); 460 } 461 462 int shooting_get_canon_subject_distance() 463 { 464 if (conf.dof_use_exif_subj_dist) 465 return shooting_get_exif_subject_dist(); 466 else 467 return (lens_get_focus_pos_from_lens()); 468 } 469 470 int shooting_get_subject_distance_() 471 { 472 if (!conf.dof_subj_dist_as_near_limit) return shooting_get_canon_subject_distance(); 473 else return shooting_get_far_limit_f(shooting_get_canon_subject_distance(), 474 shooting_get_min_real_aperture(), 475 get_focal_length(lens_get_zoom_point())); 476 } 477 478 void shooting_update_dof_values() 479 { 480 short f_focus_ok = shooting_get_focus_ok(); 481 short f_hyp_calc = 0; 482 short f_dist_calc = 0; 483 484 int av_1e3 = shooting_get_aperture_from_av96_1e3(_GetCurrentAvValue() & ~1); 485 int man_av_1e3 = shooting_get_aperture_from_av96_1e3(shooting_get_user_av96()); 486 int dist = shooting_get_subject_distance_(); 487 int fl = get_focal_length(lens_get_zoom_point()); 488 489 int mode = mode_get()&MODE_SHOOTING_MASK; 490 if ((mode==MODE_M || mode==MODE_AV) && (man_av_1e3>0) && !f_focus_ok) { 491 av_1e3 = man_av_1e3; //manual av in AV and M Mode and not shoot_half 492 } 493 494 int hyp_1e3 = dof_values.hyperfocal_distance_1e3; 495 int hyp = dof_values.hyperfocal_distance; 496 497 if (dof_values.aperture_value!=av_1e3 || dof_values.focal_length!=fl || (hyp_1e3<0)) { 498 //calc new hyperfocal distance and min stack distance 499 f_hyp_calc = 1; 500 hyp_1e3 = -1; 501 hyp = -1; 502 dof_values.aperture_value = av_1e3; 503 dof_values.focal_length = fl; 504 hyp_1e3 = shooting_get_hyperfocal_distance_1e3_f2(av_1e3, fl); 505 if (hyp_1e3>0) { 506 hyp = (hyp_1e3+500)/1000; 507 dof_values.min_stack_distance = MAX_DIST; 508 int v = ((hyp_1e3 - fl)/250 + 2 + 1)/2; 509 if (v>0) { 510 int t1 = ((fl*((fl - hyp_1e3)/1000 - 1)/500)/v + 1)/2; 511 int t2 = ((hyp*((2*fl - hyp_1e3)/500))/v + 1)/2; 512 dof_values.min_stack_distance = sqrt(t1*t1 - t2) - t1; 513 } 514 } 515 } 516 517 if ((dof_values.subject_distance!=dist || (dof_values.hyperfocal_distance_1e3!=hyp_1e3)) && 518 (hyp_1e3>0)) { 519 //calc new NEAR, FAR, DOF values 520 f_dist_calc = 1; 521 dof_values.subject_distance = dist; 522 dof_values.near_limit = -1; 523 dof_values.far_limit = -1; 524 dof_values.depth_of_field = -1; 525 if ((av_1e3>0) && (fl>0) && (dist>0) && (dist<MAX_DIST) && (hyp_1e3>0)) { 526 int v; 527 int m = ((hyp_1e3 - fl)/500*dist + 1)/2; 528 if (conf.dof_subj_dist_as_near_limit) { 529 dof_values.near_limit = dist; 530 } else { 531 v = ((hyp_1e3 + 1000*dist - 2*fl)/500 + 1)/2; 532 if (v>0) { dof_values.near_limit = m/v; } 533 } 534 if (dof_values.near_limit>=MAX_DIST) { dof_values.near_limit = -1;} 535 v = ((hyp_1e3 - 1000*dist)/500 + 1)/2; 536 if (v>0) { dof_values.far_limit = m/v; } 537 if (dof_values.far_limit>=MAX_DIST) { dof_values.far_limit = -1;} 538 if ((dof_values.near_limit>0) && (dof_values.far_limit>0)) { 539 dof_values.depth_of_field = dof_values.far_limit - dof_values.near_limit; } 540 } 541 } 542 dof_values.hyperfocal_distance_1e3 = hyp_1e3; 543 dof_values.hyperfocal_distance = hyp; 544 f_focus_ok = (f_focus_ok && shooting_get_focus_ok()); 545 dof_values.hyperfocal_valid = (f_focus_ok || (dof_values.hyperfocal_valid && !f_hyp_calc)); 546 dof_values.distance_valid = (f_focus_ok || (dof_values.distance_valid && !f_dist_calc)||(dof_values.hyperfocal_valid && shooting_get_focus_mode())); 547 return; 548 } 549 550 int shooting_get_subject_distance() 551 { 552 shooting_update_dof_values(); 553 return dof_values.subject_distance; 554 } 555 429 556 int shooting_get_hyperfocal_distance() 430 557 { 431 int h=shooting_get_hyperfocal_distance_(); 432 if ((h>0) && (conf.dof_dist_from_lens)) 433 return (h-shooting_get_lens_to_focal_plane_width()); 434 else return h; 435 } 436 437 int shooting_get_hyperfocal_distance_f(int av, int fl) 438 { 439 if ((av>0) && (fl>0) && (circle_of_confusion>0)) return (fl*fl)/(10*circle_of_confusion*av); 440 else return (-1); 441 } 442 443 int shooting_get_canon_subject_distance() 444 { 445 if (conf.dof_use_exif_subj_dist) return shooting_get_exif_subject_dist(); 446 else return lens_get_focus_pos(); 447 } 448 449 int shooting_get_subject_distance_() 450 { 451 if (!conf.dof_subj_dist_as_near_limit) return shooting_get_canon_subject_distance(); 452 else { 453 int h, v, m; 454 int fl=get_focal_length(lens_get_zoom_point()); 455 int near=shooting_get_canon_subject_distance(); 456 int v1=(fl*fl); 457 int av_min=shooting_get_min_real_aperture(); 458 int c_of_c=circle_of_confusion*10; 459 if ((av_min!=0) && (c_of_c!=0) && (v1)) { 460 h=v1/(c_of_c*av_min); 461 if ((near>0) && (near<MAX_DIST)) { 462 v=(h-near); 463 m=h*near; 464 if ((v>0) && (m>0)) return m/v; 465 } 466 } 467 return (-1); 468 } 469 } 470 471 int shooting_get_subject_distance() 472 { 473 int h=shooting_get_subject_distance_(); 474 if ((h>0) && (conf.dof_dist_from_lens)) 475 return (h-shooting_get_lens_to_focal_plane_width()); 476 else return h; 477 } 478 479 int shooting_get_near_limit_of_acceptable_sharpness_() 480 { 481 int s=shooting_get_canon_subject_distance(); 482 if (conf.dof_subj_dist_as_near_limit) return s; 483 else { 484 int h = shooting_get_hyperfocal_distance_(); 485 int m = h*s; 486 int v = h+s; 487 if ((m>0) && (v>0)) return (m/v); 488 else return (-1); 489 } 558 shooting_update_dof_values(); 559 return dof_values.hyperfocal_distance; 490 560 } 491 561 492 562 int shooting_get_near_limit_of_acceptable_sharpness() 493 563 { 494 int h=shooting_get_near_limit_of_acceptable_sharpness_(); 495 if ((h>0) && (conf.dof_dist_from_lens)) 496 return (h-shooting_get_lens_to_focal_plane_width()); 497 else return h; 498 } 499 500 int shooting_get_near_limit_f(int s, int a, int fl) 501 { 502 int h = shooting_get_hyperfocal_distance_f(a, fl); 503 int m = h*s; 504 int v = h+s; 505 if ((m>0) && (v>0)) return (m/v); 506 else return (-1); 507 } 508 509 int shooting_get_far_limit_of_acceptable_sharpness_() 510 { 511 int s=shooting_get_subject_distance_(), h=shooting_get_hyperfocal_distance_(); 512 int v = h-s; 513 int m = h*s; 514 if ((m>0) && (v>0)) return (m/v); 515 else return (-1); 564 shooting_update_dof_values(); 565 return dof_values.near_limit; 516 566 } 517 567 518 568 int shooting_get_far_limit_of_acceptable_sharpness() 519 569 { 520 int h=shooting_get_far_limit_of_acceptable_sharpness_(); 521 if ((h>0) && (conf.dof_dist_from_lens)) 522 return (h-shooting_get_lens_to_focal_plane_width()); 523 else return h; 570 shooting_update_dof_values(); 571 return dof_values.far_limit; 524 572 } 525 573 526 574 int shooting_get_depth_of_field() 527 575 { 528 int far=shooting_get_far_limit_of_acceptable_sharpness_(), near=shooting_get_near_limit_of_acceptable_sharpness_(); 529 if ((far>0) && (near>0)) return far-near; 530 else return (-1); 576 shooting_update_dof_values(); 577 return dof_values.depth_of_field; 578 } 579 580 int shooting_get_min_stack_distance() 581 { 582 shooting_update_dof_values(); 583 return dof_values.min_stack_distance; 531 584 } 532 585 … … 985 1038 void shooting_set_focus(int v, short is_now) { 986 1039 int s=v; 987 if ((mode_get()&MODE_MASK) != MODE_PLAY){988 if ((is_now) && shooting_can_focus()) {989 if (conf.dof_dist_from_lens) s+=shooting_get_lens_to_focal_plane_width(); 990 if ((!conf.dof_subj_dist_as_near_limit) && (s>0)) lens_set_focus_pos((s<MAX_DIST)?s:MAX_DIST); 991 else {992 int near=shooting_get_near_limit_f(s,shooting_get_min_real_aperture(),get_focal_length(lens_get_zoom_point()));993 if (near>0) lens_set_focus_pos((near<MAX_DIST)?near:MAX_DIST);1040 if ((mode_get()&MODE_MASK) != MODE_PLAY){ 1041 if ((is_now) && shooting_can_focus()) { 1042 if (conf.dof_subj_dist_as_near_limit) { 1043 s=shooting_get_near_limit_f(v,shooting_get_min_real_aperture(),get_focal_length(lens_get_zoom_point())); 1044 } 1045 if (!conf.dof_use_exif_subj_dist) s+=shooting_get_lens_to_focal_plane_width(); 1046 if (s>0) lens_set_focus_pos((s<MAX_DIST)?s:MAX_DIST); 994 1047 } 995 } 996 else photo_param_put_off.subj_dist=v; 997 } 1048 else photo_param_put_off.subj_dist=v; 1049 } 998 1050 } 999 1051 -
trunk/version.inc
r175 r305 1 BUILD_NUMBER := 1. 0.1-DE1 BUILD_NUMBER := 1.1.0-DE
Note: See TracChangeset
for help on using the changeset viewer.