]> granicus.if.org Git - handbrake/commitdiff
libhb: Add Lapsharp kernel isolap and use with Grain tune.
authorBradley Sepos <bradley@bradleysepos.com>
Thu, 1 Jun 2017 17:39:43 +0000 (13:39 -0400)
committerBradley Sepos <bradley@bradleysepos.com>
Thu, 1 Jun 2017 17:39:43 +0000 (13:39 -0400)
libhb/lapsharp.c
libhb/param.c

index 2170247bb7766f76ef8f8062fbabde80359a0a5b..42eaa56ea3b979d0fda3acdd8889dd2601e228e6 100644 (file)
@@ -12,7 +12,7 @@
 #define LAPSHARP_STRENGTH_LUMA_DEFAULT   0.2
 #define LAPSHARP_STRENGTH_CHROMA_DEFAULT 0.2
 
-#define LAPSHARP_KERNELS 3
+#define LAPSHARP_KERNELS 4
 #define LAPSHARP_KERNEL_LUMA_DEFAULT   2
 #define LAPSHARP_KERNEL_CHROMA_DEFAULT 2
 
@@ -28,7 +28,7 @@ typedef struct {
     const int    size;
 } lapsharp_kernel_t;
 
-// 4-neighbor laplacian kernel (lap)
+// 4-neighbor Laplacian kernel (lap)
 // Sharpens vertical and horizontal edges, less effective on diagonals
 static const int lapsharp_kernel_lap[] =
 {
@@ -37,7 +37,7 @@ static const int lapsharp_kernel_lap[] =
  0, -1,  0
 };
 
-// Isotropic laplacian kernel (isolap)
+// Isotropic Laplacian kernel (isolap)
 // Minimial directionality, sharpens all edges similarly
 static const int lapsharp_kernel_isolap[] =
 {
@@ -46,8 +46,9 @@ static const int lapsharp_kernel_isolap[] =
 -1, -4, -1
 };
 
-// Laplacian of gaussian kernel (log)
-// Slightly better at noise rejection
+// Laplacian of Gaussian kernel (log)
+// Slight noise and grain rejection
+// σ ~= 1
 static const int lapsharp_kernel_log[] =
 {
  0,  0, -1,  0,  0,
@@ -57,11 +58,24 @@ static const int lapsharp_kernel_log[] =
  0,  0, -1,  0,  0
 };
 
+// Isotropic Laplacian of Gaussian kernel (isolog)
+// Minimial directionality, plus noise and grain rejection
+// σ ~= 1.2
+static const int lapsharp_kernel_isolog[] =
+{
+ 0, -1, -1, -1,  0,
+-1, -3, -4, -3, -1,
+-1, -4, 55, -4, -1,
+-1, -3, -4, -3, -1,
+ 0, -1, -1, -1,  0
+};
+
 static lapsharp_kernel_t lapsharp_kernels[] =
 {
-    { lapsharp_kernel_lap,    (1.0 / 1), 3 },
-    { lapsharp_kernel_isolap, (1.0 / 5), 3 },
-    { lapsharp_kernel_log,    (1.0 / 5), 5 }
+    { lapsharp_kernel_lap,    (1.0 /  1), 3 },
+    { lapsharp_kernel_isolap, (1.0 /  5), 3 },
+    { lapsharp_kernel_log,    (1.0 /  5), 5 },
+    { lapsharp_kernel_isolog, (1.0 / 15), 5 }
 };
 
 struct hb_filter_private_s
@@ -191,6 +205,10 @@ static int hb_lapsharp_init(hb_filter_object_t *filter,
         {
             ctx->kernel = 2;
         }
+        else if (!strcasecmp(kernel_string[c], "isolog"))
+        {
+            ctx->kernel = 3;
+        }
 
         free(kernel_string[c]);
     }
index 92c972ed5c7e6579b59f39d854011a1fda8653fe..0e46684e5dd0850e65d012045caef557d30c3f22 100644 (file)
@@ -653,7 +653,7 @@ static hb_dict_t * generate_lapsharp_settings(const char *preset,
         else if (!strcasecmp(tune, "grain"))
         {
             strength[0]      = 0.2; strength[1] = 0.1;
-            kernel_string[0] = kernel_string[1] = "log";
+            kernel_string[0] = kernel_string[1] = "isolog";
             if (!strcasecmp(preset, "ultralight"))
             {
                 strength[0] = 0.05; strength[1] = 0.025;