msdkh265enc: let MSDK select the encoding mode by default
authorHaihao Xiang <haihao.xiang@intel.com>
Wed, 1 Jul 2020 02:18:24 +0000 (10:18 +0800)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 6 Jul 2020 14:43:31 +0000 (14:43 +0000)
MSDK may support lowpower and non-lowpower modes, some features are
available only under one of the two modes, which is hard to know for
user, so let MSDK select the mode by default.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1405>

sys/msdk/gstmsdkh265enc.c
sys/msdk/gstmsdkh265enc.h

index 46aa375..177dfda 100644 (file)
@@ -48,7 +48,7 @@ enum
   PROP_MAX_SLICE_SIZE,
 };
 
-#define PROP_LOWPOWER_DEFAULT           FALSE
+#define PROP_LOWPOWER_DEFAULT           -1
 #define PROP_TILE_ROW_DEFAULT           1
 #define PROP_TILE_COL_DEFAULT           1
 #define PROP_MAX_SLICE_SIZE_DEFAULT     0
@@ -266,7 +266,8 @@ gst_msdkh265enc_configure (GstMsdkEnc * encoder)
   }
 
   encoder->param.mfx.LowPower =
-      (h265enc->lowpower ? MFX_CODINGOPTION_ON : MFX_CODINGOPTION_OFF);
+      (h265enc->lowpower == 1 ? MFX_CODINGOPTION_ON : (h265enc->lowpower ==
+          0 ? MFX_CODINGOPTION_OFF : MFX_CODINGOPTION_UNKNOWN));
 
   return TRUE;
 }
@@ -388,7 +389,7 @@ gst_msdkh265enc_set_property (GObject * object, guint prop_id,
 
   switch (prop_id) {
     case PROP_LOW_POWER:
-      thiz->lowpower = g_value_get_boolean (value);
+      thiz->lowpower = g_value_get_int (value);
       break;
 
     case PROP_TILE_ROW:
@@ -422,7 +423,7 @@ gst_msdkh265enc_get_property (GObject * object, guint prop_id, GValue * value,
   GST_OBJECT_LOCK (thiz);
   switch (prop_id) {
     case PROP_LOW_POWER:
-      g_value_set_boolean (value, thiz->lowpower);
+      g_value_set_int (value, thiz->lowpower);
       break;
 
     case PROP_TILE_ROW:
@@ -524,8 +525,10 @@ gst_msdkh265enc_class_init (GstMsdkH265EncClass * klass)
   gst_msdkenc_install_common_properties (encoder_class);
 
   g_object_class_install_property (gobject_class, PROP_LOW_POWER,
-      g_param_spec_boolean ("low-power", "Low power", "Enable low power mode",
-          PROP_LOWPOWER_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+      g_param_spec_int ("low-power", "Low power",
+          "Enable low power mode(-1: default, 0: disable, 1: enable)",
+          -1, 1, PROP_LOWPOWER_DEFAULT,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_property (gobject_class, PROP_TILE_ROW,
       g_param_spec_uint ("num-tile-rows", "number of rows for tiled encoding",
index 7b62e4a..d4c323c 100644 (file)
@@ -55,7 +55,7 @@ struct _GstMsdkH265Enc
 {
   GstMsdkEnc base;
 
-  gboolean lowpower;
+  gint lowpower;
   gushort num_tile_rows;
   gushort num_tile_cols;
   guint max_slice_size;