vpx: add enum for adaptive quantization modes
authorJakub Adam <jakub.adam@collabora.com>
Fri, 9 Apr 2021 17:22:29 +0000 (19:22 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 28 Jun 2021 16:05:46 +0000 (16:05 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/874>

ext/vpx/gstvp9enc.c
ext/vpx/gstvp9enc.h
ext/vpx/gstvpxenums.h [new file with mode: 0644]
ext/vpx/meson.build

index b2f437b..a913837 100644 (file)
@@ -63,6 +63,8 @@
 #include <string.h>
 
 #include "gstvpxelements.h"
+#include "gstvpxenums.h"
+#include "gstvpx-enumtypes.h"
 #include "gstvp8utils.h"
 #include "gstvp9enc.h"
 
@@ -72,7 +74,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp9enc_debug);
 #define DEFAULT_TILE_COLUMNS 6
 #define DEFAULT_TILE_ROWS 0
 #define DEFAULT_ROW_MT 0
-#define DEFAULT_AQ_MODE 0
+#define DEFAULT_AQ_MODE GST_VPX_AQ_OFF
 #define DEFAULT_FRAME_PARALLEL_DECODING TRUE
 
 enum
@@ -189,10 +191,11 @@ gst_vp9_enc_class_init (GstVP9EncClass * klass)
    * Since: 1.20
    */
   g_object_class_install_property (gobject_class, PROP_AQ_MODE,
-      g_param_spec_int ("aq-mode", "Adaptive Quantization Mode",
-          "0: off (default), 1: variance 2: complexity, 3: cyclic refresh, 4: equator360",
-          0, 4, DEFAULT_AQ_MODE,
+      g_param_spec_enum ("aq-mode", "Adaptive Quantization Mode",
+          "Which adaptive quantization mode should be used",
+          GST_TYPE_VPXAQ, DEFAULT_AQ_MODE,
           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+  gst_type_mark_as_plugin_api (GST_TYPE_VPXAQ, 0);
 
   /**
    * GstVP9Enc:frame-parallel-decoding:
@@ -310,7 +313,7 @@ gst_vp9_enc_set_property (GObject * object, guint prop_id,
       }
       break;
     case PROP_AQ_MODE:
-      gst_vp9_enc->aq_mode = g_value_get_int (value);
+      gst_vp9_enc->aq_mode = g_value_get_enum (value);
       if (gst_vpx_enc->inited) {
         status = vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_AQ_MODE,
             gst_vp9_enc->aq_mode);
@@ -362,7 +365,7 @@ gst_vp9_enc_get_property (GObject * object, guint prop_id, GValue * value,
       g_value_set_boolean (value, gst_vp9_enc->row_mt);
       break;
     case PROP_AQ_MODE:
-      g_value_set_int (value, gst_vp9_enc->aq_mode);
+      g_value_set_enum (value, gst_vp9_enc->aq_mode);
       break;
     case PROP_FRAME_PARALLEL_DECODING:
       g_value_set_boolean (value, gst_vp9_enc->frame_parallel_decoding);
index 8df3519..03d31d1 100644 (file)
@@ -50,7 +50,7 @@ struct _GstVP9Enc
 #ifdef VPX_CTRL_VP9E_SET_ROW_MT
   gboolean row_mt;
 #endif
-  guint aq_mode;
+  GstVPXAQ aq_mode;
   gboolean frame_parallel_decoding;
 };
 
diff --git a/ext/vpx/gstvpxenums.h b/ext/vpx/gstvpxenums.h
new file mode 100644 (file)
index 0000000..a3bf1c6
--- /dev/null
@@ -0,0 +1,49 @@
+/* GStreamer
+ * Copyright (C) 2021, Collabora Ltd.
+ *   @author: Jakub Adam <jakub.adam@collabora.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_VPX_ENUM_H__
+#define __GST_VPX_ENUM_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GstVPXAQ:
+ *
+ * VPX Adaptive Quantization modes.
+ *
+ * Since: 1.20
+ */
+typedef enum
+{
+  GST_VPX_AQ_OFF = 0,
+  GST_VPX_AQ_VARIANCE = 1,
+  GST_VPX_AQ_COMPLEXITY = 2,
+  GST_VPX_AQ_CYCLIC_REFRESH = 3,
+  GST_VPX_AQ_EQUATOR360 = 4,
+  GST_VPX_AQ_PERCEPTUAL = 5,
+  GST_VPX_AQ_PSNR = 6,
+  GST_VPX_AQ_LOOKAHEAD = 7,
+} GstVPXAQ;
+
+G_END_DECLS
+
+#endif // __GST_VPX_ENUM_H__
index 9d50349..308648f 100644 (file)
@@ -57,8 +57,15 @@ if vpx_dep.found()
     vpx_args += '-DHAVE_VPX_1_8'
   endif
 
+  gnome = import('gnome')
+
+  gstvpx_enums = gnome.mkenums_simple('gstvpx-enumtypes',
+    sources : ['gstvpxenums.h'],
+    decorator : 'G_GNUC_INTERNAL',
+    install_header: false)
+
   gstvpx = library('gstvpx',
-    vpx_sources,
+    vpx_sources, gstvpx_enums,
     c_args : gst_plugins_good_args + vpx_args,
     include_directories : [configinc],
     dependencies : [gstbase_dep, gsttag_dep, gstvideo_dep, vpx_dep],