From 6995834f5ef106a5f67194d16f8b0f041040b448 Mon Sep 17 00:00:00 2001
From: Bradley Sepos <bradley@bradleysepos.com>
Date: Wed, 13 Mar 2019 17:36:43 -0400
Subject: [PATCH] libhb: Tweak Chroma Smooth filter presets and tunes.

The initial tunes were too weak.
---
 libhb/chroma_smooth.c |   4 +-
 libhb/param.c         | 148 ++++++++----------------------------------
 2 files changed, 30 insertions(+), 122 deletions(-)

diff --git a/libhb/chroma_smooth.c b/libhb/chroma_smooth.c
index e27ecaa77..ec1c2ecd9 100644
--- a/libhb/chroma_smooth.c
+++ b/libhb/chroma_smooth.c
@@ -226,8 +226,8 @@ static int chroma_smooth_init(hb_filter_object_t *filter,
         }
 
         // Sanitize
-        if (ctx->strength < 0)   ctx->strength = 0;
-        if (ctx->strength > 1.5) ctx->strength = 1.5;
+        if (ctx->strength < 0) ctx->strength = 0;
+        if (ctx->strength > 3) ctx->strength = 3;
         if (ctx->size % 2 == 0) ctx->size--;
         if (ctx->size < CHROMA_SMOOTH_SIZE_MIN) ctx->size = CHROMA_SMOOTH_SIZE_MIN;
         if (ctx->size > CHROMA_SMOOTH_SIZE_MAX) ctx->size = CHROMA_SMOOTH_SIZE_MAX;
diff --git a/libhb/param.c b/libhb/param.c
index c7f9ae052..8c6210720 100644
--- a/libhb/param.c
+++ b/libhb/param.c
@@ -513,155 +513,63 @@ static hb_dict_t * generate_chroma_smooth_settings(const char *preset,
         double strength;
         int    size;
 
-        if (tune == NULL || !strcasecmp(tune, "none"))
+        // Strength
+        if ((tune == NULL || !strcasecmp(tune, "none")) ||
+           (!strcasecmp(tune, "tiny"))   ||
+           (!strcasecmp(tune, "small"))  ||
+           (!strcasecmp(tune, "medium")) ||
+           (!strcasecmp(tune, "wide"))   ||
+           (!strcasecmp(tune, "verywide")))
         {
-            strength = 0.25;
-            size     = 7;
+            strength = 1.2;
             if (!strcasecmp(preset, "ultralight"))
             {
-                strength = 0.05;
+                strength = 0.4;
             }
             else if (!strcasecmp(preset, "light"))
             {
-                strength = 0.15;
+                strength = 0.8;
             }
             else if (!strcasecmp(preset, "strong"))
             {
-                strength = 0.5;
+                strength = 1.6;
             }
             else if (!strcasecmp(preset, "stronger"))
             {
-                strength = 0.8;
+                strength = 2.0;
             }
             else if (!strcasecmp(preset, "verystrong"))
             {
-                strength = 1.2;
+                strength = 2.4;
             }
         }
-        else if (!strcasecmp(tune, "tiny"))
+        else
         {
-            strength = 0.4;
-            size     = 3;
-            if (!strcasecmp(preset, "ultralight"))
-            {
-                strength = 0.15;
-            }
-            else if (!strcasecmp(preset, "light"))
-            {
-                strength = 0.25;
-            }
-            else if (!strcasecmp(preset, "strong"))
-            {
-                strength = 0.8;
-            }
-            else if (!strcasecmp(preset, "stronger"))
-            {
-                strength = 1.2;
-            }
-            else if (!strcasecmp(preset, "verystrong"))
-            {
-                strength = 1.5;
-            }
+            fprintf(stderr, "Unrecognized chroma smooth tune (%s).\n", tune);
+            return NULL;
+        }
+
+        // Size
+        if (!strcasecmp(tune, "tiny"))
+        {
+            size = 3;
         }
         else if (!strcasecmp(tune, "small"))
         {
-            strength = 0.275;
-            size     = 7;
-            if (!strcasecmp(preset, "ultralight"))
-            {
-                strength = 0.055;
-            }
-            else if (!strcasecmp(preset, "light"))
-            {
-                strength = 0.165;
-            }
-            else if (!strcasecmp(preset, "strong"))
-            {
-                strength = 0.55;
-            }
-            else if (!strcasecmp(preset, "stronger"))
-            {
-                strength = 0.9;
-            }
-            else if (!strcasecmp(preset, "verystrong"))
-            {
-                strength = 1.35;
-            }
+            size = 5;
         }
-        else if (!strcasecmp(tune, "medium"))
+        else if ((tune == NULL || !strcasecmp(tune, "none")) ||
+                (!strcasecmp(tune, "medium")))
         {
-            strength = 0.275;
-            size     = 9;
-            if (!strcasecmp(preset, "ultralight"))
-            {
-                strength = 0.055;
-            }
-            else if (!strcasecmp(preset, "light"))
-            {
-                strength = 0.165;
-            }
-            else if (!strcasecmp(preset, "strong"))
-            {
-                strength = 0.55;
-            }
-            else if (!strcasecmp(preset, "stronger"))
-            {
-                strength = 0.9;
-            }
-            else if (!strcasecmp(preset, "verystrong"))
-            {
-                strength = 1.35;
-            }
+            size = 7;
         }
         else if (!strcasecmp(tune, "wide"))
         {
-            strength = 0.275;
-            size     = 11;
-            if (!strcasecmp(preset, "ultralight"))
-            {
-                strength = 0.055;
-            }
-            else if (!strcasecmp(preset, "light"))
-            {
-                strength = 0.165;
-            }
-            else if (!strcasecmp(preset, "strong"))
-            {
-                strength = 0.55;
-            }
-            else if (!strcasecmp(preset, "stronger"))
-            {
-                strength = 0.9;
-            }
-            else if (!strcasecmp(preset, "verystrong"))
-            {
-                strength = 1.35;
-            }
+            size = 9;
         }
         else if (!strcasecmp(tune, "verywide"))
         {
-            strength = 0.275;
-            size     = 13;
-            if (!strcasecmp(preset, "ultralight"))
-            {
-                strength = 0.055;
-            }
-            else if (!strcasecmp(preset, "light"))
-            {
-                strength = 0.165;
-            }
-            else if (!strcasecmp(preset, "strong"))
-            {
-                strength = 0.55;
-            }
-            else if (!strcasecmp(preset, "stronger"))
-            {
-                strength = 0.9;
-            }
-            else if (!strcasecmp(preset, "verystrong"))
-            {
-                strength = 1.35;
-            }
+            size = 11;
         }
         else
         {
-- 
2.40.0