diff options
Diffstat (limited to 'libhb/param.c')
-rw-r--r-- | libhb/param.c | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/libhb/param.c b/libhb/param.c index ae8d99618..92c972ed5 100644 --- a/libhb/param.c +++ b/libhb/param.c @@ -90,6 +90,27 @@ static hb_filter_param_t unsharp_tunes[] = { 0, NULL, NULL, NULL } }; +static hb_filter_param_t lapsharp_presets[] = +{ + { 1, "Custom", "custom", NULL }, + { 2, "Ultralight", "ultralight", NULL }, + { 3, "Light", "light", NULL }, + { 4, "Medium", "medium", NULL }, + { 5, "Strong", "strong", NULL }, + { 6, "Stronger", "stronger", NULL }, + { 0, NULL, NULL, NULL } +}; + +static hb_filter_param_t lapsharp_tunes[] = +{ + { 0, "None", "none", NULL }, + { 1, "Film", "film", NULL }, + { 2, "Grain", "grain", NULL }, + { 3, "Animation", "animation", NULL }, + { 4, "Sprite", "sprite", NULL }, + { 0, NULL, NULL, NULL } +}; + static hb_filter_param_t detelecine_presets[] = { { 0, "Off", "off", "disable=1" }, @@ -164,6 +185,9 @@ static filter_param_map_t param_map[] = { HB_FILTER_UNSHARP, unsharp_presets, unsharp_tunes, sizeof(unsharp_presets) / sizeof(hb_filter_param_t) }, + { HB_FILTER_LAPSHARP, lapsharp_presets, lapsharp_tunes, + sizeof(lapsharp_presets) / sizeof(hb_filter_param_t) }, + { HB_FILTER_DETELECINE, detelecine_presets, NULL, sizeof(detelecine_presets) / sizeof(hb_filter_param_t) }, @@ -562,6 +586,158 @@ static hb_dict_t * generate_unsharp_settings(const char *preset, return settings; } +static hb_dict_t * generate_lapsharp_settings(const char *preset, + const char *tune, + const char *custom) +{ + hb_dict_t * settings; + + if (preset == NULL) + return NULL; + + if (preset == NULL || !strcasecmp(preset, "custom")) + { + return hb_parse_filter_settings(custom); + } + if (!strcasecmp(preset, "ultralight") || + !strcasecmp(preset, "light") || + !strcasecmp(preset, "medium") || + !strcasecmp(preset, "strong") || + !strcasecmp(preset, "stronger")) + { + double strength[2]; + const char *kernel_string[2]; + + if (tune == NULL || !strcasecmp(tune, "none")) + { + strength[0] = strength[1] = 0.2; + kernel_string[0] = kernel_string[1] = "isolap"; + if (!strcasecmp(preset, "ultralight")) + { + strength[0] = strength[1] = 0.05; + } + else if (!strcasecmp(preset, "light")) + { + strength[0] = strength[1] = 0.1; + } + else if (!strcasecmp(preset, "strong")) + { + strength[0] = strength[1] = 0.3; + } + else if (!strcasecmp(preset, "stronger")) + { + strength[0] = strength[1] = 0.5; + } + } + else if (!strcasecmp(tune, "film")) + { + strength[0] = 0.2; strength[1] = 0.12; + kernel_string[0] = kernel_string[1] = "isolap"; + if (!strcasecmp(preset, "ultralight")) + { + strength[0] = 0.05; strength[1] = 0.03; + } + else if (!strcasecmp(preset, "light")) + { + strength[0] = 0.1; strength[1] = 0.06; + } + else if (!strcasecmp(preset, "strong")) + { + strength[0] = 0.3; strength[1] = 0.2; + } + else if (!strcasecmp(preset, "stronger")) + { + strength[0] = 0.5; strength[1] = 0.3; + } + } + else if (!strcasecmp(tune, "grain")) + { + strength[0] = 0.2; strength[1] = 0.1; + kernel_string[0] = kernel_string[1] = "log"; + if (!strcasecmp(preset, "ultralight")) + { + strength[0] = 0.05; strength[1] = 0.025; + } + else if (!strcasecmp(preset, "light")) + { + strength[0] = 0.1; strength[1] = 0.05; + } + else if (!strcasecmp(preset, "strong")) + { + strength[0] = 0.3; strength[1] = 0.15; + } + else if (!strcasecmp(preset, "stronger")) + { + strength[0] = 0.5; strength[1] = 0.25; + } + } + else if (!strcasecmp(tune, "animation")) + { + strength[0] = 0.15; strength[1] = 0.09; + kernel_string[0] = kernel_string[1] = "isolap"; + if (!strcasecmp(preset, "ultralight")) + { + strength[0] = 0.0375; strength[1] = 0.0225; + } + else if (!strcasecmp(preset, "light")) + { + strength[0] = 0.075; strength[1] = 0.05625; + } + else if (!strcasecmp(preset, "strong")) + { + strength[0] = 0.225; strength[1] = 0.15; + } + else if (!strcasecmp(preset, "stronger")) + { + strength[0] = 0.375; strength[1] = 0.225; + } + } + else if (!strcasecmp(tune, "sprite")) + { + strength[0] = strength[1] = 0.15; + kernel_string[0] = kernel_string[1] = "lap"; + if (!strcasecmp(preset, "ultralight")) + { + strength[0] = strength[1] = 0.0375; + } + else if (!strcasecmp(preset, "light")) + { + strength[0] = strength[1] = 0.075; + } + else if (!strcasecmp(preset, "strong")) + { + strength[0] = strength[1] = 0.225; + } + else if (!strcasecmp(preset, "stronger")) + { + strength[0] = strength[1] = 0.375; + } + } + else + { + fprintf(stderr, "Unrecognized lapsharp tune (%s).\n", tune); + return NULL; + } + + settings = hb_dict_init(); + hb_dict_set(settings, "y-strength", hb_value_double(strength[0])); + hb_dict_set(settings, "y-kernel", hb_value_string(kernel_string[0])); + + hb_dict_set(settings, "cb-strength", hb_value_double(strength[1])); + hb_dict_set(settings, "cb-kernel", hb_value_string(kernel_string[1])); + } + else + { + settings = hb_parse_filter_settings(preset); + if (tune != NULL) + { + fprintf(stderr, "Custom lapsharp parameters specified; ignoring lapsharp tune (%s).\n", tune); + } + } + + return settings; +} + int hb_validate_param_string(const char *regex_pattern, const char *param_string) { regex_t regex_temp; @@ -822,6 +998,9 @@ hb_generate_filter_settings(int filter_id, const char *preset, const char *tune, case HB_FILTER_NLMEANS: settings = generate_nlmeans_settings(preset, tune, custom); break; + case HB_FILTER_LAPSHARP: + settings = generate_lapsharp_settings(preset, tune, custom); + break; case HB_FILTER_UNSHARP: settings = generate_unsharp_settings(preset, tune, custom); break; |