[gegl] gegl-compression: add "fast", "balanced", and "best" aliases



commit 11fb76af9e142c1ed158fe50a23e78cbadbd539f
Author: Ell <ell_se yahoo com>
Date:   Mon Dec 17 05:48:44 2018 -0500

    gegl-compression: add "fast", "balanced", and "best" aliases
    
    ... which alias concrete algorithms, based on availability,
    offerring a trade-off between speed and quality.

 gegl/buffer/gegl-compression.c | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
---
diff --git a/gegl/buffer/gegl-compression.c b/gegl/buffer/gegl-compression.c
index 2886aa720..797044d85 100644
--- a/gegl/buffer/gegl-compression.c
+++ b/gegl/buffer/gegl-compression.c
@@ -16,6 +16,7 @@
 
 #include "config.h"
 
+#include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -25,11 +26,44 @@
 #include "gegl-compression-zlib.h"
 
 
+/*  local function prototypes  */
+
+void   gegl_compression_register_alias (const gchar *name,
+                                        ...) G_GNUC_NULL_TERMINATED;
+
+
 /*  local variables  */
 
 GHashTable *algorithms;
 
 
+/*  private functions  */
+
+void
+gegl_compression_register_alias (const gchar *name,
+                                 ...)
+{
+  va_list      args;
+  const gchar *algorithm;
+
+  va_start (args, name);
+
+  while ((algorithm = va_arg (args, const gchar *)))
+    {
+      const GeglCompression *compression = gegl_compression (algorithm);
+
+      if (compression)
+        {
+          gegl_compression_register (name, compression);
+
+          break;
+        }
+    }
+
+  va_end (args);
+}
+
+
 /*  public functions  */
 
 void
@@ -42,6 +76,27 @@ gegl_compression_init (void)
   gegl_compression_nop_init ();
   gegl_compression_rle_init ();
   gegl_compression_zlib_init ();
+
+  gegl_compression_register_alias ("fast",
+                                   /* in order of precedence: */
+                                   "rle8",
+                                   "zlib1",
+                                   "nop",
+                                   NULL);
+
+  gegl_compression_register_alias ("balanced",
+                                   /* in order of precedence: */
+                                   "rle4",
+                                   "zlib",
+                                   "nop",
+                                   NULL);
+
+  gegl_compression_register_alias ("best",
+                                   /* in order of precedence: */
+                                   "zlib9",
+                                   "rle1",
+                                   "nop",
+                                   NULL);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]