From d1d5c6ea44e668a7b552e1ee88d84e6b075d3c3a Mon Sep 17 00:00:00 2001 From: Jaeyun Date: Mon, 26 Apr 2021 19:45:26 +0900 Subject: [PATCH] [Demux] accept flex tensor add pad template to accept flex tensor, and update source to configure tensor info for static/flex tensor stream. Signed-off-by: Jaeyun --- gst/nnstreamer/tensor_demux/gsttensordemux.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/gst/nnstreamer/tensor_demux/gsttensordemux.c b/gst/nnstreamer/tensor_demux/gsttensordemux.c index 5ac42d6..921d0f2 100644 --- a/gst/nnstreamer/tensor_demux/gsttensordemux.c +++ b/gst/nnstreamer/tensor_demux/gsttensordemux.c @@ -70,7 +70,16 @@ GST_DEBUG_CATEGORY_STATIC (gst_tensor_demux_debug); #define GST_CAT_DEFAULT gst_tensor_demux_debug -#define CAPS_STRING GST_TENSOR_CAP_DEFAULT "; " GST_TENSORS_CAP_DEFAULT + +/** + * @brief Default caps string for sink pad. + */ +#define CAPS_STRING_SINK GST_TENSORS_CAP_DEFAULT ";" GST_TENSORS_FLEX_CAP_DEFAULT + +/** + * @brief Default caps string for src pad. + */ +#define CAPS_STRING_SRC GST_TENSOR_CAP_DEFAULT ";" GST_TENSORS_CAP_DEFAULT ";" GST_TENSORS_FLEX_CAP_DEFAULT enum { @@ -86,13 +95,13 @@ enum static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src_%u", GST_PAD_SRC, GST_PAD_SOMETIMES, - GST_STATIC_CAPS (CAPS_STRING) + GST_STATIC_CAPS (CAPS_STRING_SRC) ); static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_TENSORS_CAP_DEFAULT) + GST_STATIC_CAPS (CAPS_STRING_SINK) ); static GstFlowReturn gst_tensor_demux_chain (GstPad * pad, GstObject * parent, @@ -463,11 +472,16 @@ gst_tensor_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) GList *list = NULL; tensor_demux = GST_TENSOR_DEMUX (parent); - num_tensors = tensor_demux->tensors_config.info.num_tensors; - GST_DEBUG_OBJECT (tensor_demux, " Number of Tensors: %d", num_tensors); + if (gst_tensors_info_is_flexible (&tensor_demux->tensors_config.info)) { + /* cannot get exact number of tensors from config */ + num_tensors = gst_buffer_n_memory (buf); + } else { + num_tensors = tensor_demux->tensors_config.info.num_tensors; - /* supposed n memory blocks in buffer */ - g_assert (gst_buffer_n_memory (buf) == num_tensors); + /* supposed n memory blocks in buffer */ + g_assert (gst_buffer_n_memory (buf) == num_tensors); + } + GST_DEBUG_OBJECT (tensor_demux, " Number of Tensors: %d", num_tensors); num_srcs = num_tensors; if (tensor_demux->tensorpick != NULL) { -- 2.7.4