* @brief Open nn framework.
*/
#define gst_tensor_filter_open_fw(filter) do { \
- if (filter->prop.fw_opened == FALSE) { \
+ if (filter->prop.fw_opened == FALSE && filter->fw) { \
if (filter->fw->open != NULL) {\
if (filter->fw->open (filter, &filter->privateData) == 0) \
filter->prop.fw_opened = TRUE; \
- else \
- filter->prop.fw_opened = FALSE; \
} else {\
filter->prop.fw_opened = TRUE; \
} \
* @brief Close nn framework.
*/
#define gst_tensor_filter_close_fw(filter) do { \
- g_assert (filter->prop.fw_opened); \
- if (filter->fw->close) \
- filter->fw->close (filter, &filter->privateData); \
- filter->prop.fw_opened = FALSE; \
+ if (filter->prop.fw_opened) { \
+ if (filter->fw && filter->fw->close) \
+ filter->fw->close (filter, &filter->privateData); \
+ filter->prop.fw_opened = FALSE; \
+ } \
} while (0)
/**
*/
#define gst_tensor_filter_call(filter,ret,funcname,...) do { \
gst_tensor_filter_open_fw (filter); \
- if (filter->prop.fw_opened == FALSE) { \
- ret = -1; \
- break; \
+ ret = -1; \
+ if (filter->prop.fw_opened && filter->fw && filter->fw->funcname) { \
+ ret = filter->fw->funcname (filter, &filter->privateData, __VA_ARGS__); \
} \
- ret = filter->fw->funcname (filter, &filter->privateData, __VA_ARGS__); \
} while (0)
/**
break;
case PROP_FRAMEWORK:
if (prop->nnfw != _T_F_UNDEFINED) {
- /** @todo CRITICAL: CLOSE IT before proceeding */
- if (prop->fw_opened == TRUE)
- gst_tensor_filter_close_fw (self);
+ gst_tensor_filter_close_fw (self);
}
prop->nnfw = find_key_strv (nnfw_names, g_value_get_string (value));
silent_debug ("Framework = %s\n", g_value_get_string (value));
break;
case PROP_MODEL:
if (prop->model_file) {
- /** @todo CRITICAL: CLOSE IT before proceeding */
- if (prop->fw_opened == TRUE)
- gst_tensor_filter_close_fw (self);
+ gst_tensor_filter_close_fw (self);
g_free ((char *) prop->model_file); /* g_free cannot handle const * */
}
if (!value) {
* supposed fixed in-tensor info if getInputDimension is defined.
*/
if (!prop->input_configured) {
- if (self->fw && self->fw->getInputDimension) {
- GstTensorsInfo in_info;
+ GstTensorsInfo in_info;
- gst_tensors_info_init (&in_info);
- gst_tensor_filter_call (self, res, getInputDimension, &in_info);
+ gst_tensors_info_init (&in_info);
+ gst_tensor_filter_call (self, res, getInputDimension, &in_info);
- if (res == 0) {
- g_assert (in_info.num_tensors > 0);
+ if (res == 0) {
+ g_assert (in_info.num_tensors > 0);
- /** if set-property called and already has info, verify it! */
- if (prop->input_meta.num_tensors > 0) {
- g_assert (gst_tensors_info_is_equal (&prop->input_meta, &in_info));
- }
+ /** if set-property called and already has info, verify it! */
+ if (prop->input_meta.num_tensors > 0) {
+ g_assert (gst_tensors_info_is_equal (&prop->input_meta, &in_info));
+ }
- prop->input_configured = TRUE;
- prop->input_meta = in_info;
+ prop->input_configured = TRUE;
+ prop->input_meta = in_info;
- silent_debug_info (&in_info, "input tensor");
- }
+ silent_debug_info (&in_info, "input tensor");
}
}
* supposed fixed out-tensor info if getOutputDimension is defined.
*/
if (!prop->output_configured) {
- if (self->fw && self->fw->getOutputDimension) {
- GstTensorsInfo out_info;
+ GstTensorsInfo out_info;
- gst_tensors_info_init (&out_info);
- gst_tensor_filter_call (self, res, getOutputDimension, &out_info);
+ gst_tensors_info_init (&out_info);
+ gst_tensor_filter_call (self, res, getOutputDimension, &out_info);
- if (res == 0) {
- g_assert (out_info.num_tensors > 0);
+ if (res == 0) {
+ g_assert (out_info.num_tensors > 0);
- /** if set-property called and already has info, verify it! */
- if (prop->output_meta.num_tensors > 0) {
- g_assert (gst_tensors_info_is_equal (&prop->output_meta, &out_info));
- }
+ /** if set-property called and already has info, verify it! */
+ if (prop->output_meta.num_tensors > 0) {
+ g_assert (gst_tensors_info_is_equal (&prop->output_meta, &out_info));
+ }
- prop->output_configured = TRUE;
- prop->output_meta = out_info;
+ prop->output_configured = TRUE;
+ prop->output_meta = out_info;
- silent_debug_info (&out_info, "output tensor");
- }
+ silent_debug_info (&out_info, "output tensor");
}
}
}
/** call setInputDimension if output tensor is not configured */
if (!prop->output_configured) {
- if (self->fw->setInputDimension) {
- GstTensorsInfo out_info;
- int res;
+ GstTensorsInfo out_info;
+ int res;
- gst_tensors_info_init (&out_info);
- gst_tensor_filter_call (self, res, setInputDimension, &in_config.info,
- &out_info);
+ gst_tensors_info_init (&out_info);
+ gst_tensor_filter_call (self, res, setInputDimension, &in_config.info,
+ &out_info);
- if (res == 0) {
- /** if set-property called and already has info, verify it! */
- if (prop->output_meta.num_tensors > 0) {
- if (!gst_tensors_info_is_equal (&prop->output_meta, &out_info)) {
- gchar *str =
- _compare_tensors (&in_config.info, &prop->input_meta);
- GST_ERROR_OBJECT (self,
- "The output tensor is not compatible.\n%s", str);
- g_free (str);
- return FALSE;
- }
+ if (res == 0) {
+ /** if set-property called and already has info, verify it! */
+ if (prop->output_meta.num_tensors > 0) {
+ if (!gst_tensors_info_is_equal (&prop->output_meta, &out_info)) {
+ gchar *str = _compare_tensors (&in_config.info, &prop->input_meta);
+ GST_ERROR_OBJECT (self,
+ "The output tensor is not compatible.\n%s", str);
+ g_free (str);
+ return FALSE;
}
+ }
- prop->output_configured = TRUE;
- prop->output_meta = out_info;
+ prop->output_configured = TRUE;
+ prop->output_meta = out_info;
- silent_debug_info (&out_info, "output tensor");
- }
+ silent_debug_info (&out_info, "output tensor");
}
if (!prop->output_configured) {
int res = -1;
/* call setInputDimension with given input tensor */
- if (self->fw->setInputDimension) {
- gst_tensor_filter_call (self, res, setInputDimension, &in_info,
- &config.info);
- }
+ gst_tensor_filter_call (self, res, setInputDimension, &in_info,
+ &config.info);
if (res == 0) {
result = gst_tensor_filter_caps_from_config (self, &config);
GstTensorFilter *self;
self = GST_TENSOR_FILTER_CAST (trans);
- if (self->fw == NULL)
- return FALSE;
gst_tensor_filter_open_fw (self);
return TRUE;
GstTensorFilter *self;
self = GST_TENSOR_FILTER_CAST (trans);
- if (self->fw == NULL)
- return FALSE;
gst_tensor_filter_close_fw (self);
return TRUE;