vpx: add enum for adaptive quantization modes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/874>
This commit is contained in:
Jakub Adam 2021-04-09 19:22:29 +02:00 committed by GStreamer Marge Bot
parent a5cccf13d4
commit 9f1b9fed06
4 changed files with 67 additions and 8 deletions

View file

@ -63,6 +63,8 @@
#include <string.h> #include <string.h>
#include "gstvpxelements.h" #include "gstvpxelements.h"
#include "gstvpxenums.h"
#include "gstvpx-enumtypes.h"
#include "gstvp8utils.h" #include "gstvp8utils.h"
#include "gstvp9enc.h" #include "gstvp9enc.h"
@ -72,7 +74,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_vp9enc_debug);
#define DEFAULT_TILE_COLUMNS 6 #define DEFAULT_TILE_COLUMNS 6
#define DEFAULT_TILE_ROWS 0 #define DEFAULT_TILE_ROWS 0
#define DEFAULT_ROW_MT 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 #define DEFAULT_FRAME_PARALLEL_DECODING TRUE
enum enum
@ -189,10 +191,11 @@ gst_vp9_enc_class_init (GstVP9EncClass * klass)
* Since: 1.20 * Since: 1.20
*/ */
g_object_class_install_property (gobject_class, PROP_AQ_MODE, g_object_class_install_property (gobject_class, PROP_AQ_MODE,
g_param_spec_int ("aq-mode", "Adaptive Quantization Mode", g_param_spec_enum ("aq-mode", "Adaptive Quantization Mode",
"0: off (default), 1: variance 2: complexity, 3: cyclic refresh, 4: equator360", "Which adaptive quantization mode should be used",
0, 4, DEFAULT_AQ_MODE, GST_TYPE_VPXAQ, DEFAULT_AQ_MODE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
gst_type_mark_as_plugin_api (GST_TYPE_VPXAQ, 0);
/** /**
* GstVP9Enc:frame-parallel-decoding: * GstVP9Enc:frame-parallel-decoding:
@ -310,7 +313,7 @@ gst_vp9_enc_set_property (GObject * object, guint prop_id,
} }
break; break;
case PROP_AQ_MODE: 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) { if (gst_vpx_enc->inited) {
status = vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_AQ_MODE, status = vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_AQ_MODE,
gst_vp9_enc->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); g_value_set_boolean (value, gst_vp9_enc->row_mt);
break; break;
case PROP_AQ_MODE: 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; break;
case PROP_FRAME_PARALLEL_DECODING: case PROP_FRAME_PARALLEL_DECODING:
g_value_set_boolean (value, gst_vp9_enc->frame_parallel_decoding); g_value_set_boolean (value, gst_vp9_enc->frame_parallel_decoding);

View file

@ -50,7 +50,7 @@ struct _GstVP9Enc
#ifdef VPX_CTRL_VP9E_SET_ROW_MT #ifdef VPX_CTRL_VP9E_SET_ROW_MT
gboolean row_mt; gboolean row_mt;
#endif #endif
guint aq_mode; GstVPXAQ aq_mode;
gboolean frame_parallel_decoding; gboolean frame_parallel_decoding;
}; };

49
ext/vpx/gstvpxenums.h Normal file
View file

@ -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__

View file

@ -57,8 +57,15 @@ if vpx_dep.found()
vpx_args += '-DHAVE_VPX_1_8' vpx_args += '-DHAVE_VPX_1_8'
endif endif
gnome = import('gnome')
gstvpx_enums = gnome.mkenums_simple('gstvpx-enumtypes',
sources : ['gstvpxenums.h'],
decorator : 'G_GNUC_INTERNAL',
install_header: false)
gstvpx = library('gstvpx', gstvpx = library('gstvpx',
vpx_sources, vpx_sources, gstvpx_enums,
c_args : gst_plugins_good_args + vpx_args, c_args : gst_plugins_good_args + vpx_args,
include_directories : [configinc], include_directories : [configinc],
dependencies : [gstbase_dep, gsttag_dep, gstvideo_dep, vpx_dep], dependencies : [gstbase_dep, gsttag_dep, gstvideo_dep, vpx_dep],