From b483f233d297495aa4ee89a3a0030d8a0ae6c024 Mon Sep 17 00:00:00 2001 From: sonninnos Date: Thu, 24 Jun 2021 00:56:52 +0300 Subject: [PATCH] Integer overscale option --- config.def.h | 2 ++ configuration.c | 1 + configuration.h | 1 + intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.c | 7 ++++++- intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 5 +++++ menu/menu_setting.c | 22 ++++++++++++++++++++++ msg_hash.h | 1 + retroarch.c | 12 ++++++++++-- 11 files changed, 64 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index d2f2846bf9..c8bcff6917 100644 --- a/config.def.h +++ b/config.def.h @@ -380,8 +380,10 @@ /* Only scale in integer steps. * The base size depends on system-reported geometry and aspect ratio. * If video_force_aspect is not set, X/Y will be integer scaled independently. + * Overscale rounds up instead of down, default is downscale. */ #define DEFAULT_SCALE_INTEGER false +#define DEFAULT_SCALE_INTEGER_OVERSCALE false /* Controls aspect ratio handling. */ diff --git a/configuration.c b/configuration.c index 174894e41b..752151ecd1 100644 --- a/configuration.c +++ b/configuration.c @@ -1530,6 +1530,7 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("video_windowed_fullscreen", &settings->bools.video_windowed_fullscreen, true, DEFAULT_WINDOWED_FULLSCREEN, false); SETTING_BOOL("video_crop_overscan", &settings->bools.video_crop_overscan, true, DEFAULT_CROP_OVERSCAN, false); SETTING_BOOL("video_scale_integer", &settings->bools.video_scale_integer, true, DEFAULT_SCALE_INTEGER, false); + SETTING_BOOL("video_scale_integer_overscale", &settings->bools.video_scale_integer_overscale, true, DEFAULT_SCALE_INTEGER_OVERSCALE, false); SETTING_BOOL("video_smooth", &settings->bools.video_smooth, true, DEFAULT_VIDEO_SMOOTH, false); SETTING_BOOL("video_ctx_scaling", &settings->bools.video_ctx_scaling, true, DEFAULT_VIDEO_CTX_SCALING, false); SETTING_BOOL("video_force_aspect", &settings->bools.video_force_aspect, true, DEFAULT_FORCE_ASPECT, false); diff --git a/configuration.h b/configuration.h index 29f52bfd2e..773d03d3ae 100644 --- a/configuration.h +++ b/configuration.h @@ -497,6 +497,7 @@ typedef struct settings bool video_aspect_ratio_auto; bool video_dingux_ipu_keep_aspect; bool video_scale_integer; + bool video_scale_integer_overscale; bool video_shader_enable; bool video_shader_watch_files; bool video_shader_remember_last_dir; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index aebd44e3ef..8c7aba31ed 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -3314,6 +3314,10 @@ MSG_HASH( MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, "video_scale_integer" ) +MSG_HASH( + MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER_OVERSCALE, + "video_scale_integer_overscale" + ) MSG_HASH( MENU_ENUM_LABEL_VIDEO_SETTINGS, "video_settings" diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 39418993bf..9eda1c4ad6 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -1365,9 +1365,14 @@ int msg_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) "The base size depends on system-reported \n" "geometry and aspect ratio.\n" " \n" - "If Force Aspect is not set, X/Y will be \n" + "If 'Force Aspect Ratio' is not set, X/Y will be \n" "integer scaled independently."); break; + case MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER_OVERSCALE: + snprintf(s, len, + "Force integer scaling to round up \n" + " to the next larger integer instead of rounding down."); + break; case MENU_ENUM_LABEL_AUDIO_VOLUME: snprintf(s, len, "Audio volume, expressed in dB.\n" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 43e5b65d3a..d2c50ed246 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1631,6 +1631,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER, "Scale video in integer steps only. The base size depends on system-reported geometry and aspect ratio. If 'Force Aspect Ratio' is not set, X/Y will be integer scaled independently." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER_OVERSCALE, + "Integer Scale Overscale" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER_OVERSCALE, + "Force integer scaling to round up to the next larger integer instead of rounding down." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_VIDEO_ASPECT_RATIO_INDEX, "Aspect Ratio" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 6ed665bbbe..cabf2763ac 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -451,6 +451,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_auto_rotate, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_auto_scale, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_AUTO_SCALE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_content_collection_list, MENU_ENUM_SUBLABEL_PLAYLISTS_TAB) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_scale_integer, MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_scale_integer_overscale, MENU_ENUM_SUBLABEL_VIDEO_SCALE_INTEGER_OVERSCALE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_gpu_screenshot, MENU_ENUM_SUBLABEL_VIDEO_GPU_SCREENSHOT) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_rotation, MENU_ENUM_SUBLABEL_VIDEO_ROTATION) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_screen_orientation, MENU_ENUM_SUBLABEL_SCREEN_ORIENTATION) @@ -3278,6 +3279,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_scale_integer); break; + case MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER_OVERSCALE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_scale_integer_overscale); + break; case MENU_ENUM_LABEL_PLAYLISTS_TAB: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_content_collection_list); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 352006a09b..12259241c0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7765,6 +7765,11 @@ unsigned menu_displaylist_build_list( MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, PARSE_ONLY_BOOL, false) == 0) count++; + if (settings->bools.video_scale_integer) + if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, + MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER_OVERSCALE, + PARSE_ONLY_BOOL, false) == 0) + count++; if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO_INDEX, PARSE_ONLY_UINT, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4ea8deb769..19631ad7a3 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -11366,6 +11366,28 @@ static bool setting_append_list( list_info, CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); + CONFIG_BOOL( + list, list_info, + &settings->bools.video_scale_integer_overscale, + MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER_OVERSCALE, + MENU_ENUM_LABEL_VALUE_VIDEO_SCALE_INTEGER_OVERSCALE, + DEFAULT_SCALE_INTEGER_OVERSCALE, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); + (*list)[list_info->index - 1].action_ok = setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_left = setting_bool_action_left_with_refresh; + (*list)[list_info->index - 1].action_right = setting_bool_action_right_with_refresh; + MENU_SETTINGS_LIST_CURRENT_ADD_CMD( + list, + list_info, + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); + #ifdef GEKKO CONFIG_UINT( list, list_info, diff --git a/msg_hash.h b/msg_hash.h index cc67621fd7..7ae1857157 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1072,6 +1072,7 @@ enum msg_hash_enums MENU_LABEL(VIDEO_NOTCH_WRITE_OVER), MENU_LABEL(VIDEO_SCALE_INTEGER), + MENU_LABEL(VIDEO_SCALE_INTEGER_OVERSCALE), MENU_LABEL(VIDEO_VIEWPORT_CUSTOM_X), MENU_LABEL(VIDEO_VIEWPORT_CUSTOM_Y), MENU_LABEL(VIDEO_VIEWPORT_CUSTOM_WIDTH), diff --git a/retroarch.c b/retroarch.c index d5fab68864..b9b4bcaa8b 100644 --- a/retroarch.c +++ b/retroarch.c @@ -31819,6 +31819,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, struct rarch_state *p_rarch = &rarch_st; settings_t *settings = p_rarch->configuration_settings; unsigned video_aspect_ratio_idx = settings->uints.video_aspect_ratio_idx; + bool overscale = settings->bools.video_scale_integer_overscale; if (video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { @@ -31861,8 +31862,15 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, if (keep_aspect) { /* X/Y scale must be same. */ - unsigned max_scale = MIN(width / base_width, - height / base_height); + unsigned max_scale = 1; + + if (overscale) + max_scale = MIN((width / base_width) + !!(width % base_width), + (height / base_height) + !!(height % base_height)); + else + max_scale = MIN(width / base_width, + height / base_height); + padding_x = width - base_width * max_scale; padding_y = height - base_height * max_scale; }