From 846ee58cacd72210f92233816d5a72d6957dba29 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Tue, 16 Feb 2021 12:57:55 +0100 Subject: [PATCH] vp9enc: expose aq-mode property Part-of: --- ext/vpx/gstvp9enc.c | 37 +++++++++++++++++++++++++++++++++++++ ext/vpx/gstvp9enc.h | 1 + 2 files changed, 38 insertions(+) diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c index c938e16084..be1c40788f 100644 --- a/ext/vpx/gstvp9enc.c +++ b/ext/vpx/gstvp9enc.c @@ -72,6 +72,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 enum { @@ -79,6 +80,7 @@ enum PROP_TILE_COLUMNS, PROP_TILE_ROWS, PROP_ROW_MT, + PROP_AQ_MODE, }; /* FIXME: Y42B do not work yet it seems */ @@ -177,6 +179,19 @@ gst_vp9_enc_class_init (GstVP9EncClass * klass) DEFAULT_ROW_MT, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); + /** + * GstVP9Enc:aq-mode: + * + * Adaptive Quantization Mode + * + * 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, + (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); + gst_element_class_add_static_pad_template (element_class, &gst_vp9_enc_src_template); gst_element_class_add_static_pad_template (element_class, @@ -225,6 +240,7 @@ gst_vp9_enc_init (GstVP9Enc * gst_vp9_enc) gst_vp9_enc->tile_columns = DEFAULT_TILE_COLUMNS; gst_vp9_enc->tile_rows = DEFAULT_TILE_ROWS; gst_vp9_enc->row_mt = DEFAULT_ROW_MT; + gst_vp9_enc->aq_mode = DEFAULT_AQ_MODE; } static void @@ -276,6 +292,18 @@ 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); + if (gst_vpx_enc->inited) { + status = vpx_codec_control (&gst_vpx_enc->encoder, VP9E_SET_AQ_MODE, + gst_vp9_enc->aq_mode); + if (status != VPX_CODEC_OK) { + GST_WARNING_OBJECT (gst_vpx_enc, + "Failed to set VP9E_SET_AQ_MODE: %s", + gst_vpx_error_name (status)); + } + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -303,6 +331,9 @@ gst_vp9_enc_get_property (GObject * object, guint prop_id, GValue * value, case PROP_ROW_MT: 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); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -423,6 +454,12 @@ gst_vp9_enc_configure_encoder (GstVPXEnc * encoder, GstVideoCodecState * state) GST_DEBUG_OBJECT (encoder, "Failed to set VP9E_SET_ROW_MT: %s", gst_vpx_error_name (status)); } + status = + vpx_codec_control (&encoder->encoder, VP9E_SET_AQ_MODE, vp9enc->aq_mode); + if (status != VPX_CODEC_OK) { + GST_WARNING_OBJECT (encoder, + "Failed to set VP9E_SET_AQ_MODE: %s", gst_vpx_error_name (status)); + } return TRUE; } diff --git a/ext/vpx/gstvp9enc.h b/ext/vpx/gstvp9enc.h index 4e52336f60..8eafa18e2b 100644 --- a/ext/vpx/gstvp9enc.h +++ b/ext/vpx/gstvp9enc.h @@ -50,6 +50,7 @@ struct _GstVP9Enc #ifdef VPX_CTRL_VP9E_SET_ROW_MT gboolean row_mt; #endif + guint aq_mode; }; G_END_DECLS