gchar *pathFILTERS[CONF_SOURCES]; /**< directory paths for FILTERS */
gchar *pathDECODERS[CONF_SOURCES]; /**< directory paths for DECODERS */
gchar *pathCUSTOM_FILTERS[CONF_SOURCES]; /**< directory paths for CUSTOM FILTERS */
+ gchar *valueTF_MEM_OPTMZ[CONF_SOURCES]; /**< value of TF_MEM_OPTMZ */
gchar **filesFILTERS; /**< Null terminated list of full filepaths for FILTERS */
gchar **filesDECODERS;; /**< Null terminated list of full filepaths for DECODERS */
gchar **basenameFILTERS; /**< Null terminated list of basenames for FILTERS */
gchar **basenameDECODERS;; /**< Null terminated list of basenames for DECODERS */
gchar **basenameCUSTOM_FILTERS; /**< Null terminated list of basenames for CUSTOM FILTERS */
+
+ gboolean boolTF_MEM_OPTMZ; /**< The flag to decide using memcpy or not at Tensorflow in boolean type */
} confdata;
static confdata conf = { 0 };
g_free (conf.pathFILTERS[i]);
g_free (conf.pathDECODERS[i]);
g_free (conf.pathCUSTOM_FILTERS[i]);
+ g_free (conf.valueTF_MEM_OPTMZ[i]);
}
g_strfreev (conf.filesFILTERS);
conf.pathFILTERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_FILTERS);
conf.pathDECODERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_DECODERS);
conf.pathCUSTOM_FILTERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_CUSTOMFILTERS);
+ conf.valueTF_MEM_OPTMZ[0] = _strdup_getenv (NNSTREAMER_ENVVAR_TF_MEM_OPTMZ);
/* Read the conf file. It's ok even if we cannot load it. */
if (conf.conffile &&
g_key_file_get_string (key_file, "decoder", "decoders", &error);
conf.pathCUSTOM_FILTERS[1] =
g_key_file_get_string (key_file, "filter", "customfilters", &error);
+ conf.valueTF_MEM_OPTMZ[1] =
+ g_key_file_get_string (key_file, "tensorflow", "mem_optmz", &error);
}
/* Strdup the hardcoded */
conf.pathFILTERS[2] = g_strdup (NNSTREAMER_FILTERS);
conf.pathDECODERS[2] = g_strdup (NNSTREAMER_DECODERS);
conf.pathCUSTOM_FILTERS[2] = g_strdup (NNSTREAMER_CUSTOM_FILTERS);
+ conf.valueTF_MEM_OPTMZ[2] = g_strdup (NNSTREAMER_TF_MEM_OPTMZ);
/* Fill in conf.files* */
_fill_in_vstr (&conf.filesFILTERS, &conf.basenameFILTERS, conf.pathFILTERS);
/** @brief Public function defined in the header */
const gchar *
-nnsconf_get_fullpath_fromfile (const gchar * file2find, nnsconf_type type)
+nnsconf_get_fullpath_fromfile (const gchar * file2find, nnsconf_type_path type)
{
gchar **vstr, **vstrFull;
int i;
switch (type) {
- case NNSCONF_FILTERS:
+ case NNSCONF_PATH_FILTERS:
vstr = conf.basenameFILTERS;
vstrFull = conf.filesFILTERS;
break;
- case NNSCONF_DECODERS:
+ case NNSCONF_PATH_DECODERS:
vstr = conf.basenameDECODERS;
vstrFull = conf.filesDECODERS;
break;
- case NNSCONF_CUSTOM_FILTERS:
+ case NNSCONF_PATH_CUSTOM_FILTERS:
vstr = conf.basenameCUSTOM_FILTERS;
vstrFull = conf.filesCUSTOM_FILTERS;
break;
return NULL;
}
-const gchar *subplugin_prefixes[NNSCONF_END] = {
- [NNSCONF_FILTERS] = NNSTREAMER_PREFIX_FILTER,
- [NNSCONF_DECODERS] = NNSTREAMER_PREFIX_DECODER,
- [NNSCONF_CUSTOM_FILTERS] = NNSTREAMER_PREFIX_CUSTOMFILTERS,
+const gchar *subplugin_prefixes[NNSCONF_PATH_END] = {
+ [NNSCONF_PATH_FILTERS] = NNSTREAMER_PREFIX_FILTER,
+ [NNSCONF_PATH_DECODERS] = NNSTREAMER_PREFIX_DECODER,
+ [NNSCONF_PATH_CUSTOM_FILTERS] = NNSTREAMER_PREFIX_CUSTOMFILTERS,
NULL,
};
/** @brief Public function defined in the header */
const gchar *
-nnsconf_get_fullpath (const gchar * subpluginname, nnsconf_type type)
+nnsconf_get_fullpath (const gchar * subpluginname, nnsconf_type_path type)
{
+ if (!conf.loaded)
+ nnsconf_loadconf (FALSE);
+
gchar *filename =
g_strconcat (subplugin_prefixes[type], subpluginname, ".so", NULL);
const gchar *ret = nnsconf_get_fullpath_fromfile (filename, type);
g_free (filename);
return ret;
}
+
+/** @brief Public function defined in the header */
+const gboolean
+nnsconf_get_value_bool (nnsconf_type_value type)
+{
+ int i;
+ gboolean ret;
+
+ if (!conf.loaded)
+ nnsconf_loadconf (FALSE);
+
+ switch (type) {
+ case NNSCONF_VAL_TF_MEM_OPTMZ:
+ for (i = 0; i < CONF_SOURCES; i++) {
+ if (conf.valueTF_MEM_OPTMZ[i]) {
+ if (!g_ascii_strncasecmp ("1", conf.valueTF_MEM_OPTMZ[i], 1) ||
+ !g_ascii_strncasecmp ("t", conf.valueTF_MEM_OPTMZ[i], 1))
+ conf.boolTF_MEM_OPTMZ = TRUE;
+ else
+ conf.boolTF_MEM_OPTMZ = FALSE;
+
+ break;
+ }
+ }
+ ret = conf.boolTF_MEM_OPTMZ;
+ break;
+
+ default:
+ ret = FALSE;
+ }
+
+ return ret;
+}
#define NNSTREAMER_ENVVAR_FILTERS "NNSTREAMER_FILTERS"
#define NNSTREAMER_ENVVAR_DECODERS "NNSTREAMER_DECODERS"
#define NNSTREAMER_ENVVAR_CUSTOMFILTERS "NNSTREAMER_CUSTOMFILTERS"
+#define NNSTREAMER_ENVVAR_TF_MEM_OPTMZ "NNSTREAMER_TF_MEM_OPTMZ"
/* Internal Hardcoded Values */
#define NNSTREAMER_DEFAULT_CONF_FILE "/etc/nnstreamer.ini"
#define NNSTREAMER_FILTERS "/usr/lib/nnstreamer/filters/"
#define NNSTREAMER_DECODERS "/usr/lib/nnstreamer/decoders/"
#define NNSTREAMER_CUSTOM_FILTERS "/usr/lib/nnstreamer/customfilters/"
+#define NNSTREAMER_TF_MEM_OPTMZ "false"
/**
* Note that users still can place their custom filters anywhere if they
* designate them with the full path.
/* Custom filter does not have prefix */
typedef enum {
- NNSCONF_FILTERS = 0,
- NNSCONF_DECODERS,
- NNSCONF_CUSTOM_FILTERS,
- NNSCONF_CONFFILE,
+ NNSCONF_PATH_FILTERS = 0,
+ NNSCONF_PATH_DECODERS,
+ NNSCONF_PATH_CUSTOM_FILTERS,
+ NNSCONF_PATH_CONFFILE,
- NNSCONF_END,
-} nnsconf_type;
+ NNSCONF_PATH_END,
+} nnsconf_type_path;
-extern const gchar *subplugin_prefixes[NNSCONF_END];
+typedef enum {
+ NNSCONF_VAL_TF_MEM_OPTMZ = 0,
+
+ NNSCONF_VAL_END,
+} nnsconf_type_value;
+
+extern const gchar *subplugin_prefixes[NNSCONF_PATH_END];
/**
* @brief Load the .ini file
* Returns NULL if we cannot find the file.
*/
extern const gchar *
-nnsconf_get_fullpath_fromfile (const gchar *file2find, nnsconf_type type);
+nnsconf_get_fullpath_fromfile (const gchar *file2find, nnsconf_type_path type);
/**
* @brief Get the configured paths for the type with sub-plugin name.
* This is mainly supposed to be used by CUSTOM_FILTERS
*/
extern const gchar *
-nnsconf_get_fullpath (const gchar *subpluginname, nnsconf_type type);
+nnsconf_get_fullpath (const gchar *subpluginname, nnsconf_type_path type);
+
+/**
+ * @brief Get the configured boolean values for the type
+ * @param[in] type The type (TF_MEM_OPTMZ)
+ * @return The boolean value to the file. Caller MUST NOT modify this.
+ * Returns FALSE if we cannot find the file or the value as a DEFAULT.
+ */
+extern const gboolean
+nnsconf_get_value_bool (nnsconf_type_value type);
#endif /* __GST_NNSTREAMER_CONF_H__ */