Changed custom mode name to custom-code fot callback type.
Signed-off-by: Gichan Jang <gichan2.jang@samsung.com>
*
* If you want to convert your own binary format of the flexbuffers to tensors,
* You can use custom mode of the tensor converter.
+ * This is an example of a callback type custom mode.
* @code
* // Define custom callback function
* GstBuffer * tensor_converter_custom_cb (GstBuffer *in_buf,
- * GstTensorsConfig *config) {
+ * void *data, GstTensorsConfig *config) {
* // Write a code to convert flexbuffers to tensors.
* }
*
* nnstreamer_converter_custom_register ("tconv", tensor_converter_custom_cb, NULL);
* ...
* // Use the custom tensor converter in a pipeline.
- * // E.g., Pipeline of " ... (flexbuffers) ! tensor_converter mode=custom:tconv ! (tensors)... "
+ * // E.g., Pipeline of " ... (flexbuffers) ! tensor_converter mode=custom-code:tconv ! (tensors)... "
* ...
* // After everything is done.
* nnstreamer_converter_custom_unregister ("tconv");
/**
* @brief Convert to tensors as customized operation
* @param[in] in_buf the input stream buffer
+ * @param[in/out] data private data for the callback
* @param[out] config tensors config structure to be filled
* @return output buffer filled by user
*/
typedef GstBuffer * (* tensor_converter_custom) (GstBuffer *in_buf,
- GstTensorsConfig *config);
+ void *data, GstTensorsConfig *config);
/**
* @brief Register the custom callback function.
break;
}
- if (g_ascii_strcasecmp (strv[0], "custom") == 0)
- self->mode = _CONVERTER_MODE_CUSTOM;
+ if (g_ascii_strcasecmp (strv[0], "custom-code") == 0)
+ self->mode = _CONVERTER_MODE_CUSTOM_CODE;
self->mode_option = g_strdup (strv[1]);
g_strfreev (strv);
if (self->mode_option == NULL)
mode_str = g_strdup ("");
else
- mode_str = g_strdup_printf ("%s:%s", "custom", self->mode_option);
+ mode_str = g_strdup_printf ("%s:%s", "custom-code", self->mode_option);
g_value_take_string (value, mode_str);
break;
}
frames_in = buf_size / frame_size;
break;
case _NNS_MEDIA_ANY:
- if (self->mode == _CONVERTER_MODE_CUSTOM) {
+ if (self->mode == _CONVERTER_MODE_CUSTOM_CODE) {
GstTensorsConfig new_config;
if (self->custom.func == NULL) {
nns_loge
("custom condition of the tensor_converter is not configured.");
return GST_FLOW_ERROR;
}
- inbuf = self->custom.func (buf, &new_config);
+ inbuf = self->custom.func (buf, self->custom.data, &new_config);
if (inbuf == NULL) {
nns_loge ("Failed to run custom tensor converter.");
gst_buffer_unref (buf);
g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
structure = gst_caps_get_structure (caps, 0);
- if (self->mode == _CONVERTER_MODE_CUSTOM) {
+ if (self->mode == _CONVERTER_MODE_CUSTOM_CODE) {
in_type = _NNS_MEDIA_ANY;
} else {
in_type = gst_tensor_media_type_from_structure (structure);
break;
default:
{
- if (self->mode == _CONVERTER_MODE_CUSTOM) {
+ if (self->mode == _CONVERTER_MODE_CUSTOM_CODE) {
gst_tensors_config_init (&config);
/* All tensor info should be updated later in chain function. */
*/
typedef enum {
_CONVERTER_MODE_NONE = 0, /**< Normal mode (default) */
- _CONVERTER_MODE_CUSTOM = 1, /**< Custom mode */
+ _CONVERTER_MODE_CUSTOM_CODE = 1, /**< Custom mode (callback type) */
} tensor_converter_mode;
/**
* @brief custom callback function\r
*/\r
GstBuffer * tensor_converter_custom_cb (GstBuffer *in_buf,\r
- GstTensorsConfig *config) {\r
+ void *data, GstTensorsConfig *config) {\r
GstMemory *in_mem, *out_mem;\r
GstBuffer *out_buf = NULL;\r
GstMapInfo in_info;\r
g_free (str_pipeline);\r
\r
str_pipeline = g_strdup_printf (\r
- "filesrc location=%s blocksize=-1 ! application/octet-stream ! tensor_converter mode=custom:tconv ! "\r
+ "filesrc location=%s blocksize=-1 ! application/octet-stream ! tensor_converter mode=custom-code:tconv ! "\r
"filesink location=%s buffer-mode=unbuffered sync=false async=false ",\r
tmp_flex_raw, tmp_flex_to_tensor);\r
\r