#define DEFAULT_ACCELERATION FALSE
#endif
-static const gchar *gst_tensor_transform_mode_string[] = {
- [GTT_DIMCHG] = "dimchg",
- [GTT_TYPECAST] = "typecast",
- [GTT_ARITHMETIC] = "arithmetic",
- [GTT_TRANSPOSE] = "transpose",
- [GTT_STAND] = "stand",
- [GTT_END] = "error"
-};
-
static const gchar *gst_tensor_transform_stand_string[] = {
[STAND_DEFAULT] = "default",
[STAND_END] = "error"
GstPadDirection direction, GstCaps * caps, gsize size,
GstCaps * othercaps, gsize * othersize);
+#define GST_TYPE_TENSOR_TRANSFORM_MODE (gst_tensor_transform_mode_get_type ())
+/**
+ * @brief A private function to register GEnumValue array for the 'mode' property
+ * to a GType and return it
+ */
+static GType
+gst_tensor_transform_mode_get_type (void)
+{
+ static GType mode_type = GTT_UNKNOWN;
+
+ if (mode_type == GTT_UNKNOWN) {
+ static GEnumValue mode_types[] = {
+ {GTT_DIMCHG, "Mode for changing tensor dimensions",
+ "dimchg"},
+ {GTT_TYPECAST, "Mode for casting type of tensor",
+ "typecast"},
+ {GTT_ARITHMETIC, "Mode for arithmetic operations with tensor",
+ "arithmetic"},
+ {GTT_TRANSPOSE, "Mode for transposing shape of tensor",
+ "transpose"},
+ {GTT_STAND, "Mode for statistical standardization of tensor",
+ "stand"},
+ {GTT_UNKNOWN, "Unknown or not-implemented-yet mode",
+ "unknown"},
+ {0, NULL, NULL},
+ };
+
+ mode_type = g_enum_register_static ("gtt_mode_type", mode_types);
+ }
+
+ return mode_type;
+}
+
/**
* @brief initialize the tensor_transform's class
*/
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_MODE,
- g_param_spec_string ("mode", "Mode", "Tensor transform mode ?",
- "", G_PARAM_READWRITE));
+ g_param_spec_enum ("mode", "Mode", "Mode used for transforming tensor",
+ GST_TYPE_TENSOR_TRANSFORM_MODE, GTT_UNKNOWN,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_OPTION,
g_param_spec_string ("option", "Option",
"Option for the tensor transform mode ?", "", G_PARAM_READWRITE));
gst_tensor_transform_init (GstTensorTransform * filter)
{
filter->silent = TRUE;
- filter->mode = GTT_END;
+ filter->mode = GTT_UNKNOWN;
filter->option = NULL;
filter->loaded = FALSE;
filter->operators = NULL;
return (index < 0) ? STAND_END : index;
}
-/**
- * @brief Get the corresponding mode from the string value
- * @param[in] str The string value for the mode
- * @return corresponding mode for the string. GTT_END for errors
- */
-static tensor_transform_mode
-gst_tensor_transform_get_mode (const gchar * str)
-{
- int index;
-
- index = find_key_strv (gst_tensor_transform_mode_string, str);
-
- return (index < 0) ? GTT_END : index;
-}
-
#ifdef HAVE_ORC
/* define macros for orc */
#define orc_supported(filter) (filter->acceleration && filter->orc_supported)
static void
gst_tensor_transform_set_option_data (GstTensorTransform * filter)
{
- if (filter->mode == GTT_END || filter->option == NULL)
+ if (filter->mode == GTT_UNKNOWN || filter->option == NULL)
return;
switch (filter->mode) {
filter->silent = g_value_get_boolean (value);
break;
case PROP_MODE:
- filter->mode = gst_tensor_transform_get_mode (g_value_get_string (value));
- g_assert (filter->mode != GTT_END);
- silent_debug ("Mode = %d(%s)\n", filter->mode,
- gst_tensor_transform_mode_string[filter->mode]);
- gst_tensor_transform_set_option_data (filter);
+ filter->mode = g_value_get_enum (value);
break;
case PROP_OPTION:
filter->option = g_value_dup_string (value);
g_value_set_boolean (value, filter->silent);
break;
case PROP_MODE:
- g_value_set_string (value,
- gst_tensor_transform_mode_string[filter->mode]);
+ g_value_set_enum (value, filter->mode);
break;
case PROP_OPTION:
g_value_set_string (value, filter->option);
typedef struct _GstTensorTransform GstTensorTransform;
typedef struct _GstTensorTransformClass GstTensorTransformClass;
-typedef enum
+typedef enum _tensor_transform_mode
{
- GTT_DIMCHG = 0, /* Dimension Change. "dimchg" */
- GTT_TYPECAST = 1, /* Type change. "typecast" */
- GTT_ARITHMETIC = 2, /* Arithmetic. "arithmetic" */
- GTT_TRANSPOSE = 3, /* Transpose. "transpose" */
- GTT_STAND = 4, /* Standardization. "stand" */
+ GTT_DIMCHG = 0, /* Dimension Change. "dimchg" */
+ GTT_TYPECAST, /* Type change. "typecast" */
+ GTT_ARITHMETIC, /* Arithmetic. "arithmetic" */
+ GTT_TRANSPOSE, /* Transpose. "transpose" */
+ GTT_STAND, /* Standardization. "stand" */
- GTT_END,
+ GTT_UNKNOWN = -1, /* Unknown/Not-implemented-yet Mode. "unknown" */
} tensor_transform_mode;
typedef enum