#include <tensor_meta.h>
GType
-tensor_meta_api_get_type (void)
+gst_meta_tensor_api_get_type (void)
{
static volatile GType type;
- static const gchar *tags[] =
- { "tensor", "other/tensor", "tensors", "other/tensors", NULL };
+ static const gchar *tags[] = { "tensor", "tensors", NULL };
if (g_once_init_enter (&type)) {
- GType _type = gst_meta_api_type_register ("TensorMeta", tags);
+ GType _type;
+ const GstMetaInfo *meta_info = gst_meta_get_info ("GstMetaTensor");
+
+ if (meta_info) {
+ _type = meta_info->api;
+ debug_print (TRUE, "meta_info->type %lu \n", _type);
+ } else {
+ _type = gst_meta_api_type_register ("GstMetaTensorAPI", tags);
+ }
g_once_init_leave (&type, _type);
}
* @return TRUE/FALSE
*/
static gboolean
-tensor_meta_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
+gst_meta_tensor_init (GstMeta * meta, gpointer params, GstBuffer * buffer)
{
/* @TODO To be filled */
- TensorMeta *emeta = (TensorMeta *) meta;
+ GstMetaTensor *emeta = (GstMetaTensor *) meta;
emeta->num_tensors = 0;
* @return TRUE/FALSE
*/
static gboolean
-tensor_meta_transform (GstBuffer * transbuf, GstMeta * meta,
+gst_meta_tensor_transform (GstBuffer * transbuf, GstMeta * meta,
GstBuffer * buffer, GQuark type, gpointer data)
{
/* @TODO To be filled */
- TensorMeta *emeta = (TensorMeta *) meta;
- gst_buffer_add_tensor_meta (transbuf, emeta->num_tensors);
+ GstMetaTensor *dest_meta = GST_META_TENSOR_ADD (transbuf);
+ GstMetaTensor *src_meta = (GstMetaTensor *) meta;
+
+ dest_meta->num_tensors = src_meta->num_tensors;
return TRUE;
}
* @return TRUE/FALSE
*/
static void
-tensor_meta_free (GstMeta * meta, GstBuffer * buffer)
+gst_meta_tensor_free (GstMeta * meta, GstBuffer * buffer)
{
- TensorMeta *emeta = (TensorMeta *) meta;
+ GstMetaTensor *emeta = (GstMetaTensor *) meta;
/* If there is buffer free in here */
emeta->num_tensors = 0;
}
const GstMetaInfo *
-tensor_meta_get_info (void)
+gst_meta_tensor_get_info (void)
{
static const GstMetaInfo *meta_info = NULL;
if (g_once_init_enter (&meta_info)) {
- const GstMetaInfo *mi = gst_meta_register (TENSOR_META_API_TYPE,
- "TensorMeta",
- sizeof (TensorMeta),
- tensor_meta_init,
- tensor_meta_free,
- tensor_meta_transform);
+ const GstMetaInfo *mi = gst_meta_register (GST_META_TENSOR_API_TYPE,
+ "GstMetaTensor",
+ sizeof (GstMetaTensor),
+ (GstMetaInitFunction) gst_meta_tensor_init,
+ (GstMetaFreeFunction) gst_meta_tensor_free,
+ (GstMetaTransformFunction) gst_meta_tensor_transform);
g_once_init_leave (&meta_info, mi);
}
return meta_info;
}
-TensorMeta *
-gst_buffer_add_tensor_meta (GstBuffer * buffer, gint num_tensors)
+GstMetaTensor *
+gst_buffer_add_meta_tensor (GstBuffer * buffer, gint num_tensors)
{
- TensorMeta *meta;
+ GstMetaTensor *meta;
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
- meta = (TensorMeta *) gst_buffer_add_meta (buffer, TENSOR_META_INFO, NULL);
+ meta =
+ (GstMetaTensor *) gst_buffer_add_meta (buffer, GST_META_TENSOR_INFO,
+ NULL);
meta->num_tensors = num_tensors;
#include <glib.h>
#include "tensor_converter.h"
+#include <tensor_meta.h>
GST_DEBUG_CATEGORY_STATIC (gst_tensor_converter_debug);
#define GST_CAT_DEFAULT gst_tensor_converter_debug
GstFlowReturn res;
GstTensor_Converter *filter = GST_TENSOR_CONVERTER_CAST (trans);
+ /* for now, Generate GstMetaTensor->num_tensors =1 */
+ gst_buffer_add_meta_tensor (outbuf, 1);
+
if (G_UNLIKELY (!filter->negotiated))
goto unknown_format;
if (G_UNLIKELY (!filter->tensorConfigured))
{
GstTensor_Converter *filter = GST_TENSOR_CONVERTER_CAST (trans);
+ /* for now, Generate GstMetaTensor->num_tensors =1 */
+ gst_buffer_add_meta_tensor (buf, 1);
+
if (G_UNLIKELY (!filter->negotiated))
goto unknown_format;
if (G_UNLIKELY (!filter->tensorConfigured))
#include <glib.h>
#include <stdint.h>
#include <gst/gst.h>
+#include <tensor_common.h>
+
+G_BEGIN_DECLS
+
+typedef struct _GstMetaTensor GstMetaTensor;
/**
* @brief Definition of Tensor Meta Data
*/
-typedef struct _TensorMeta {
+struct _GstMetaTensor {
GstMeta meta;
gint num_tensors;
-} TensorMeta;
+};
/**
* @brief Get tensor meta data type. Register Tensor Meta Data API definition
* @return Tensor Meta Data Type
*/
-GType tensor_meta_api_get_type (void);
+GType gst_meta_tensor_api_get_type (void);
-#define TENSOR_META_API_TYPE (tensor_meta_api_get_type ())
+#define GST_META_TENSOR_API_TYPE (gst_meta_tensor_api_get_type ())
/**
- * @brief Macro to get tensor meta data.
+ * @brief get tensor meta data info
+ * @return Tensor Meta Data Info
*/
-#define gst_buffer_get_tensor_meta(b) \
- ((TensorMeta*) gst_buffer_get_meta ((b), TENSOR_META_API_TYPE))
+const GstMetaInfo *gst_meta_tensor_get_info (void);
+#define GST_META_TENSOR_INFO ((GstMetaInfo*) gst_meta_tensor_get_info ())
/**
- * @brief get tensor meta data info
- * @return Tensor Meta Data Info
+ * @brief Macro to get tensor meta data.
*/
-const GstMetaInfo *tensor_meta_get_info (void);
-#define TENSOR_META_INFO (tensor_meta_get_info ())
+#define gst_buffer_get_meta_tensor(b) \
+ ((GstMetaTensor*) gst_buffer_get_meta ((b), GST_META_TENSOR_API_TYPE))
/**
* @brief Add tensor meta data
* @param variable to save meta ( number of tensors )
* @return Tensor Meta Data
*/
-TensorMeta * gst_buffer_add_tensor_meta (GstBuffer *buffer,
+GstMetaTensor * gst_buffer_add_meta_tensor (GstBuffer *buffer,
gint num_tensors);
+#define GST_META_TENSOR_GET(buf) ((GstMetaTensor *)gst_buffer_get_meta_tensor (buf))
+#define GST_META_TENSOR_ADD(buf) ((GstMetaTensor *)gst_buffer_add_meta_tensor ((buf),0))
+
+G_END_DECLS
#endif /* __GST_TENSOR_META_H__ */