From 9f1b9fed068d941d427383e6cd9b4d5e0651d496 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Fri, 9 Apr 2021 19:22:29 +0200 Subject: [PATCH] vpx: add enum for adaptive quantization modes Part-of: --- ext/vpx/gstvp9enc.c | 15 +++++++------ ext/vpx/gstvp9enc.h | 2 +- ext/vpx/gstvpxenums.h | 49 +++++++++++++++++++++++++++++++++++++++++++ ext/vpx/meson.build | 9 +++++++- 4 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 ext/vpx/gstvpxenums.h diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c index b2f437b736..a913837e2e 100644 --- a/ext/vpx/gstvp9enc.c +++ b/ext/vpx/gstvp9enc.c @@ -63,6 +63,8 @@ #include #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); diff --git a/ext/vpx/gstvp9enc.h b/ext/vpx/gstvp9enc.h index 8df351994d..03d31d1bd2 100644 --- a/ext/vpx/gstvp9enc.h +++ b/ext/vpx/gstvp9enc.h @@ -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 index 0000000000..a3bf1c640a --- /dev/null +++ b/ext/vpx/gstvpxenums.h @@ -0,0 +1,49 @@ +/* GStreamer + * Copyright (C) 2021, Collabora Ltd. + * @author: Jakub Adam + * + * 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 + +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__ diff --git a/ext/vpx/meson.build b/ext/vpx/meson.build index 9d503495a2..308648fcbb 100644 --- a/ext/vpx/meson.build +++ b/ext/vpx/meson.build @@ -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],