- Use get_tensor_from_padcap to read tensor info from padcap.
- Expand the capability of get-tensor_from_padcap for framerate.
- Remove nnfw_support_status
This is start of #169
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
*/
GstTensor_Filter_CheckStatus
get_tensor_from_padcap (const GstCaps * caps, tensor_dim dim,
- tensor_type * type)
+ tensor_type * type, int *framerate_num, int *framerate_denum)
{
GstTensor_Filter_CheckStatus ret = _TFC_INIT;
tensor_dim backup_dim;
const GstStructure *str;
int rank;
const gchar *strval;
+ gint fn, fd;
if (!caps)
return ret;
str = gst_caps_get_structure (caps, i);
g_assert (NNS_TENSOR_RANK_LIMIT == 4); /* This code assumes rank limit is 4 */
+ /**
+ * Already cofnigured and more cap info is coming.
+ * I'm not sure how this happens, but let's be ready for this.
+ */
if ((i > 1) && (ret & _TFC_DIMENSION)) {
- /**
- * Already cofnigured and more cap info is coming.
- * I'm not sure how this happens, but let's be ready for this.
- */
memcpy (backup_dim, dim, sizeof (uint32_t) * NNS_TENSOR_RANK_LIMIT);
}
if ((i > 1) && (ret & _TFC_TYPE)) {
- /**
- * Already cofnigured and more cap info is coming.
- * I'm not sure how this happens, but let's be ready for this.
- */
backup_type = *type;
}
}
ret |= _TFC_TYPE;
}
+ if (gst_structure_get_fraction (str, "framerate", &fn, &fd)) {
+ if ((ret & _TFC_FRAMERATE) && framerate_num)
+ g_assert (fn == *framerate_num);
+ if ((ret & _TFC_FRAMERATE) && framerate_denum)
+ g_assert (fd == *framerate_denum);
+
+ if (framerate_num)
+ *framerate_num = fn;
+ if (framerate_denum)
+ *framerate_denum = fd;
+ ret |= _TFC_FRAMERATE;
+ }
}
return ret;
}
tensor_dim dim;
tensor_type type;
GstTensor_Filter_CheckStatus ret =
- get_tensor_from_padcap (srccap, dim, &type);
+ get_tensor_from_padcap (srccap, dim, &type, NULL, NULL);
g_assert ((ret & _TFC_ALL) == _TFC_ALL);
silent_debug ("Framework = %s\n", g_value_get_string (value));
g_assert (prop->nnfw != -1);
g_assert (prop->nnfw != _T_F_UNDEFINED);
- g_assert (nnfw_support_status[prop->nnfw] == TRUE);
+ g_assert (tensor_filter_supported[prop->nnfw] != NULL);
prop->fw = tensor_filter_supported[prop->nnfw];
fw = prop->fw;
g_assert (prop->fw != NULL);
tensor_dim dim;
tensor_type type;
GstTensor_Filter_CheckStatus ret =
- get_tensor_from_padcap (srccap, dim, &type);
+ get_tensor_from_padcap (srccap, dim, &type, NULL, NULL);
if (filter->prop.fw->allocate_in_invoke == TRUE) {
*othersize = 0; /* Do not allocate outbuf. invoke_NN will allocate! */
extern const char* nnfw_names[];
/**
- * @brief NN Framework Support Status
- *
- * TRUE: Supported
- * FALSE: Scaffoldings are there, but not supported, yet. (NYI)
- */
-static const gboolean nnfw_support_status[] = {
- FALSE,
-
- TRUE,
- TRUE,
- FALSE,
- FALSE,
-
- FALSE,
-};
-
-/**
* @brief Internal data structure for tensor_filter instances.
*/
struct _GstTensor_Filter
* @param[out] frate_den Framerate, denomincator
* @return TRUE if successful (both dim/type read). FALSE if not.
*/
-static gboolean
+static gboolean inline
gst_tensor_read_cap (GstCaps * caps, tensor_dim dim, tensor_type * type,
gint * frate_num, gint * frate_den)
{
- unsigned int i, capsize;
- const GstStructure *str;
- int rank, j;
- const gchar *strval;
- gboolean dimset = FALSE, typeset = FALSE;
- gint fn, fd;
-
- if (!caps)
- return FALSE;
+ GstTensor_Filter_CheckStatus ret = get_tensor_from_padcap (caps, dim, type,
+ frate_num, frate_den);
- capsize = gst_caps_get_size (caps);
- for (i = 0; i < capsize; i++) {
- str = gst_caps_get_structure (caps, i);
- if (dimset == TRUE) {
- tensor_dim dim2;
- if (gst_structure_get_int (str, "dim1", (int *) &dim2[0]) &&
- gst_structure_get_int (str, "dim2", (int *) &dim2[1]) &&
- gst_structure_get_int (str, "dim3", (int *) &dim2[2]) &&
- gst_structure_get_int (str, "dim4", (int *) &dim2[3])) {
- for (j = 0; j < NNS_TENSOR_RANK_LIMIT; j++)
- g_assert (dim[j] == dim2[j]);
- }
- } else {
- if (gst_structure_get_int (str, "dim1", (int *) &dim[0]) &&
- gst_structure_get_int (str, "dim2", (int *) &dim[1]) &&
- gst_structure_get_int (str, "dim3", (int *) &dim[2]) &&
- gst_structure_get_int (str, "dim4", (int *) &dim[3])) {
- dimset = TRUE;
- if (gst_structure_get_int (str, "rank", &rank)) {
- for (j = rank; j < NNS_TENSOR_RANK_LIMIT; j++)
- g_assert (dim[j] == 1);
- }
- }
- }
- strval = gst_structure_get_string (str, "type");
- if (strval) {
- tensor_type type2;
- type2 = get_tensor_type (strval);
- g_assert (type2 != _NNS_END);
- if (typeset == TRUE)
- g_assert (*type == type2);
- *type = type2;
- typeset = TRUE;
- }
- if (gst_structure_get_fraction (str, "framerate", &fn, &fd)) {
- *frate_num = fn;
- *frate_den = fd;
- }
- }
- return dimset && typeset;
+ return (ret & (_TFC_ALL | _TFC_FRAMERATE)) == (_TFC_ALL | _TFC_FRAMERATE);
}
/**
* @param[in] caps the pad-cap to be interpreted.
* @param[out] dim the corresponging dimension info from the cap.
* @param[out] type the corresponding element type from the cap.
+ * @param[out] framerate_num Numerator of framerate. Set null to not use this.
+ * @param[out] framerate_denum Denumerator of framerate. Set null to not use this.
*/
extern GstTensor_Filter_CheckStatus
-get_tensor_from_padcap(const GstCaps * caps, tensor_dim dim, tensor_type *type);
+get_tensor_from_padcap(const GstCaps * caps, tensor_dim dim, tensor_type *type,
+ int *framerate_num, int *framerate_denum);
/**
* @brief Make str(xyz) ==> "xyz" with macro expansion
_TFC_TYPE = 2,
_TFC_ALL = _TFC_DIMENSION | _TFC_TYPE,
+ _TFC_FRAMERATE = 4,
+
/* @TODO Add "consistency checked. don't check it again" and implement .c accordingly. */
} GstTensor_Filter_CheckStatus;