Skip to content

Commit dd2cea3

Browse files
committed
Merge branch 'release-0.2.0' into main
2 parents c071072 + ba3588f commit dd2cea3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7300
-481
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,38 @@ DESTDIR=$PSDKR_PATH/targetfs ninja install
2626
meson build --prefix=/usr -Dpkg_config_path=pkgconfig
2727
ninja -C build
2828
ninja -C build test
29-
sudo ninja -C build install
29+
ninja -C build install
30+
ldconfig
31+
```
32+
You can delete the GStreamer registry cache if the new elements are not found
33+
using gst-inspect and build a new one
34+
35+
```bash
36+
rm -rf ~/.cache/gstreamer-1.0/registry.aarch64.bin
37+
gst-inspect-1.0
38+
```
39+
40+
## Compiling the Project Natively inside the PSDK RTOS Docker container
41+
```bash
42+
#Build Docker container
43+
cd /opt/edge_ai_apps/docker
44+
./docker_build.sh
45+
./docker_run.sh
46+
cd /opt/edge_ai_apps
47+
./docker_run.sh
48+
49+
#Build the GStreamer plugin
50+
PKG_CONFIG_SYSROOT_DIR=/host PKG_CONFIG_LIBDIR=/host/usr/lib/pkgconfig/ meson build --prefix=/host/usr -Dpkg_config_path=pkgconfig
51+
ninja -C build
52+
ninja -C build install
53+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/host/usr/lib/edgeai-tiovx-modules/:/host/usr/lib/aarch64-linux-gnu # This will also be needed before running the element in another terminal for example
54+
ldconfig
55+
56+
# Since ninja will install these to the host you'll also need to call the following command before running a pipeline. "/host/usr/lib/aarch64-linux-gnu/gstreamer-1.0/" is not a standard GStreamer installation path
57+
export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:/host/usr/lib/aarch64-linux-gnu/gstreamer-1.0/
58+
59+
#Test plugin is loaded correctly
60+
gst-inspect-1.0 tiovx
3061
```
3162

3263
# GStreamer elements

ext/tiovx/gsttiovx.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
#include <gst/gst.h>
6767

6868
#include "gsttiovxcolorconvert.h"
69+
#include "gsttiovxdlcolorblend.h"
70+
#include "gsttiovxdlpreproc.h"
71+
#include "gsttiovxmosaic.h"
6972
#include "gsttiovxmultiscaler.h"
7073

7174
/* entry point to initialize the plug-in
@@ -75,17 +78,46 @@
7578
static gboolean
7679
ti_ovx_init (GstPlugin * plugin)
7780
{
78-
gboolean ret = TRUE;
81+
gboolean ret = FALSE;
7982

8083
ret = gst_element_register (plugin, "tiovxcolorconvert", GST_RANK_NONE,
8184
GST_TYPE_GST_TIOVX_COLOR_CONVERT);
8285
if (!ret) {
83-
GST_ERROR ("Failed to register the tiovx-colorconvert element");
86+
GST_ERROR ("Failed to register the tiovxcolorconvert element");
87+
goto out;
88+
}
89+
90+
ret = gst_element_register (plugin, "tiovxdlcolorblend", GST_RANK_NONE,
91+
GST_TYPE_GST_TIOVX_DL_COLOR_BLEND);
92+
if (!ret) {
93+
GST_ERROR ("Failed to register the tiovxdlcolorblend element");
94+
goto out;
95+
}
96+
97+
ret = gst_element_register (plugin, "tiovxdlpreproc", GST_RANK_NONE,
98+
GST_TYPE_GST_TIOVX_DL_PRE_PROC);
99+
if (!ret) {
100+
GST_ERROR ("Failed to register the tiovxdlpreproc element");
101+
goto out;
84102
}
85103

86104
ret = gst_element_register (plugin, "tiovxmultiscaler", GST_RANK_NONE,
87105
GST_TYPE_GST_TIOVX_MULTI_SCALER);
106+
if (!ret) {
107+
GST_ERROR ("Failed to register the tiovxmultiscaler element");
108+
goto out;
109+
}
110+
111+
ret = gst_element_register (plugin, "tiovxmosaic", GST_RANK_NONE,
112+
GST_TYPE_GST_TIOVX_MOSAIC);
113+
if (!ret) {
114+
GST_ERROR ("Failed to register the tiovxmosaic element");
115+
goto out;
116+
}
117+
118+
ret = TRUE;
88119

120+
out:
89121
return ret;
90122
}
91123

ext/tiovx/gsttiovxcolorconvert.c

Lines changed: 85 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
#include "gst-libs/gst/tiovx/gsttiovxsiso.h"
7070
#include "gst-libs/gst/tiovx/gsttiovxutils.h"
7171

72-
#include "app_color_convert_module.h"
72+
#include "tiovx_color_convert_module.h"
73+
74+
#define COLORCONVERT_INPUT_PARAM_INDEX 0
75+
#define COLORCONVERT_OUTPUT_PARAM_INDEX 1
7376

7477
/* Target definition */
7578
#define GST_TYPE_TIOVX_COLOR_CONVERT_TARGET (gst_tiovx_color_convert_target_get_type())
@@ -81,7 +84,7 @@ gst_tiovx_color_convert_target_get_type (void)
8184
static const GEnumValue targets[] = {
8285
{TIVX_CPU_ID_DSP1, "DSP instance 1, assigned to C66_0 core",
8386
TIVX_TARGET_DSP1},
84-
{TIVX_CPU_ID_DSP2, "DSP instance 1, assigned to C66_1 core",
87+
{TIVX_CPU_ID_DSP2, "DSP instance 2, assigned to C66_1 core",
8588
TIVX_TARGET_DSP2},
8689
{0, NULL, NULL},
8790
};
@@ -141,7 +144,7 @@ struct _GstTIOVXColorconvert
141144
{
142145
GstTIOVXSiso element;
143146
gint target_id;
144-
ColorConvertObj obj;
147+
TIOVXColorConvertModuleObj obj;
145148
};
146149

147150
GST_DEBUG_CATEGORY_STATIC (gst_tiovx_color_convert_debug);
@@ -161,14 +164,18 @@ static GstCaps *gst_tiovx_color_convert_transform_caps (GstBaseTransform *
161164
base, GstPadDirection direction, GstCaps * caps, GstCaps * filter);
162165

163166
static gboolean gst_tiovx_color_convert_init_module (GstTIOVXSiso * trans,
164-
vx_context context, GstVideoInfo * in_info, GstVideoInfo * out_info,
167+
vx_context context, GstCaps * in_caps, GstCaps * out_caps,
165168
guint num_channels);
166169
static gboolean gst_tiovx_color_convert_create_graph (GstTIOVXSiso * trans,
167170
vx_context context, vx_graph graph);
168171
static gboolean gst_tiovx_color_convert_get_node_info (GstTIOVXSiso * trans,
169-
vx_reference ** input, vx_reference ** output, vx_node * node);
172+
vx_reference ** input, vx_reference ** output, vx_node * node,
173+
guint * input_param_index, guint * output_param_index);
170174
static gboolean gst_tiovx_color_convert_release_buffer (GstTIOVXSiso * trans);
171-
static gboolean gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans);
175+
static gboolean gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans,
176+
vx_context context);
177+
static gboolean gst_tiovx_color_convert_compare_caps (GstTIOVXSiso * trans,
178+
GstCaps * caps1, GstCaps * caps2, GstPadDirection direction);
172179

173180
static const gchar *target_id_to_target_name (gint target_id);
174181

@@ -223,6 +230,8 @@ gst_tiovx_color_convert_class_init (GstTIOVXColorconvertClass * klass)
223230
GST_DEBUG_FUNCPTR (gst_tiovx_color_convert_release_buffer);
224231
gsttiovxsiso_class->deinit_module =
225232
GST_DEBUG_FUNCPTR (gst_tiovx_color_convert_deinit_module);
233+
gsttiovxsiso_class->compare_caps =
234+
GST_DEBUG_FUNCPTR (gst_tiovx_color_convert_compare_caps);
226235

227236
GST_DEBUG_CATEGORY_INIT (gst_tiovx_color_convert_debug,
228237
"tiovxcolorconvert", 0, "TIOVX ColorConvert element");
@@ -479,42 +488,55 @@ gst_tiovx_color_convert_transform_caps (GstBaseTransform * base,
479488

480489
static gboolean
481490
gst_tiovx_color_convert_init_module (GstTIOVXSiso * trans, vx_context context,
482-
GstVideoInfo * in_info, GstVideoInfo * out_info, guint num_channels)
491+
GstCaps * in_caps, GstCaps * out_caps, guint num_channels)
483492
{
484493
GstTIOVXColorconvert *self = NULL;
485494
vx_status status = VX_SUCCESS;
486-
ColorConvertObj *colorconvert = NULL;
495+
TIOVXColorConvertModuleObj *colorconvert = NULL;
496+
GstVideoInfo in_info;
497+
GstVideoInfo out_info;
487498

488499
g_return_val_if_fail (trans, FALSE);
489500
g_return_val_if_fail (VX_SUCCESS == vxGetStatus ((vx_reference) context),
490501
FALSE);
491-
g_return_val_if_fail (in_info, FALSE);
492-
g_return_val_if_fail (out_info, FALSE);
502+
g_return_val_if_fail (in_caps, FALSE);
503+
g_return_val_if_fail (out_caps, FALSE);
493504
g_return_val_if_fail (num_channels >= MIN_NUM_CHANNELS, FALSE);
494505
g_return_val_if_fail (num_channels <= MAX_NUM_CHANNELS, FALSE);
495506

496507
self = GST_TIOVX_COLOR_CONVERT (trans);
497508

498509
GST_INFO_OBJECT (self, "Init module");
499510

500-
/* Configure ColorConvertObj */
511+
if (!gst_video_info_from_caps (&in_info, in_caps)) {
512+
GST_ERROR_OBJECT (self, "Failed to get video info from input caps");
513+
return FALSE;
514+
}
515+
if (!gst_video_info_from_caps (&out_info, out_caps)) {
516+
GST_ERROR_OBJECT (self, "Failed to get video info from output caps");
517+
return FALSE;
518+
}
519+
520+
/* Configure TIOVXColorConvertModuleObj */
501521
colorconvert = &self->obj;
502-
colorconvert->num_ch = DEFAULT_NUM_CHANNELS;
522+
colorconvert->num_channels = DEFAULT_NUM_CHANNELS;
503523
colorconvert->input.bufq_depth = num_channels;
504524
colorconvert->output.bufq_depth = num_channels;
505525

506526
colorconvert->input.graph_parameter_index = INPUT_PARAMETER_INDEX;
507527
colorconvert->output.graph_parameter_index = OUTPUT_PARAMETER_INDEX;
508528

509529
colorconvert->input.color_format =
510-
gst_format_to_vx_format (in_info->finfo->format);
530+
gst_format_to_vx_format (in_info.finfo->format);
511531
colorconvert->output.color_format =
512-
gst_format_to_vx_format (out_info->finfo->format);
532+
gst_format_to_vx_format (out_info.finfo->format);
533+
534+
colorconvert->width = GST_VIDEO_INFO_WIDTH (&in_info);
535+
colorconvert->height = GST_VIDEO_INFO_HEIGHT (&in_info);
513536

514-
colorconvert->width = GST_VIDEO_INFO_WIDTH (in_info);
515-
colorconvert->height = GST_VIDEO_INFO_HEIGHT (in_info);
537+
colorconvert->en_out_image_write = 0;
516538

517-
status = app_init_color_convert (context, colorconvert);
539+
status = tiovx_color_convert_module_init (context, colorconvert);
518540
if (VX_SUCCESS != status) {
519541
GST_ERROR_OBJECT (self, "Module init failed with error: %d", status);
520542
return FALSE;
@@ -546,13 +568,13 @@ gst_tiovx_color_convert_create_graph (GstTIOVXSiso * trans, vx_context context,
546568
GST_OBJECT_UNLOCK (GST_OBJECT (self));
547569

548570
if (!target) {
571+
GST_ERROR_OBJECT (self, "TIOVX target selection failed");
549572
g_return_val_if_reached (FALSE);
550573
}
551574

552575
GST_INFO_OBJECT (self, "TIOVX Target to use: %s", target);
553576

554-
status =
555-
app_create_graph_color_convert (context, graph, &self->obj, NULL, target);
577+
status = tiovx_color_convert_module_create (graph, &self->obj, NULL, target);
556578
if (VX_SUCCESS != status) {
557579
GST_ERROR_OBJECT (self, "Create graph failed with error: %d", status);
558580
return FALSE;
@@ -573,7 +595,7 @@ gst_tiovx_color_convert_release_buffer (GstTIOVXSiso * trans)
573595

574596
GST_INFO_OBJECT (self, "Release buffer");
575597

576-
status = app_release_buffer_color_convert (&self->obj);
598+
status = tiovx_color_convert_module_release_buffers (&self->obj);
577599
if (VX_SUCCESS != status) {
578600
GST_ERROR_OBJECT (self, "Release buffer failed with error: %d", status);
579601
return FALSE;
@@ -583,7 +605,7 @@ gst_tiovx_color_convert_release_buffer (GstTIOVXSiso * trans)
583605
}
584606

585607
static gboolean
586-
gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans)
608+
gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans, vx_context context)
587609
{
588610
GstTIOVXColorconvert *self = NULL;
589611
vx_status status = VX_SUCCESS;
@@ -594,13 +616,13 @@ gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans)
594616

595617
GST_INFO_OBJECT (self, "Deinit module");
596618

597-
status = app_delete_color_convert (&self->obj);
619+
status = tiovx_color_convert_module_delete (&self->obj);
598620
if (VX_SUCCESS != status) {
599621
GST_ERROR_OBJECT (self, "Module delete failed with error: %d", status);
600622
return FALSE;
601623
}
602624

603-
status = app_deinit_color_convert (&self->obj);
625+
status = tiovx_color_convert_module_deinit (&self->obj);
604626
if (VX_SUCCESS != status) {
605627
GST_ERROR_OBJECT (self, "Module deinit failed with error: %d", status);
606628
return FALSE;
@@ -611,7 +633,8 @@ gst_tiovx_color_convert_deinit_module (GstTIOVXSiso * trans)
611633

612634
static gboolean
613635
gst_tiovx_color_convert_get_node_info (GstTIOVXSiso * trans,
614-
vx_reference ** input, vx_reference ** output, vx_node * node)
636+
vx_reference ** input, vx_reference ** output, vx_node * node,
637+
guint * input_param_index, guint * output_param_index)
615638
{
616639
GstTIOVXColorconvert *self = NULL;
617640

@@ -631,6 +654,9 @@ gst_tiovx_color_convert_get_node_info (GstTIOVXSiso * trans,
631654
*input = (vx_reference *) & self->obj.input.image_handle[0];
632655
*output = (vx_reference *) & self->obj.output.image_handle[0];
633656

657+
*input_param_index = COLORCONVERT_INPUT_PARAM_INDEX;
658+
*output_param_index = COLORCONVERT_OUTPUT_PARAM_INDEX;
659+
634660
return TRUE;
635661
}
636662

@@ -650,3 +676,38 @@ target_id_to_target_name (gint target_id)
650676

651677
return value_nick;
652678
}
679+
680+
static gboolean
681+
gst_tiovx_color_convert_compare_caps (GstTIOVXSiso * trans, GstCaps * caps1,
682+
GstCaps * caps2, GstPadDirection direction)
683+
{
684+
GstVideoInfo video_info1;
685+
GstVideoInfo video_info2;
686+
gboolean ret = FALSE;
687+
688+
g_return_val_if_fail (caps1, FALSE);
689+
g_return_val_if_fail (caps2, FALSE);
690+
g_return_val_if_fail (GST_PAD_UNKNOWN != direction, FALSE);
691+
692+
if (!gst_video_info_from_caps (&video_info1, caps1)) {
693+
GST_ERROR_OBJECT (trans, "Failed to get info from caps: %"
694+
GST_PTR_FORMAT, caps1);
695+
goto out;
696+
}
697+
698+
if (!gst_video_info_from_caps (&video_info2, caps2)) {
699+
GST_ERROR_OBJECT (trans, "Failed to get info from caps: %"
700+
GST_PTR_FORMAT, caps2);
701+
goto out;
702+
}
703+
704+
if ((video_info1.width == video_info2.width) &&
705+
(video_info1.height == video_info2.height) &&
706+
(video_info1.finfo->format == video_info2.finfo->format)
707+
) {
708+
ret = TRUE;
709+
}
710+
711+
out:
712+
return ret;
713+
}

ext/tiovx/gsttiovxcolorconvert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ G_BEGIN_DECLS
7272

7373
/**
7474
* GST_IS_TIOVX_COLOR_CONVERT:
75-
* @ptr: pointer to check if its a TIOVX color convert
75+
* @ptr: pointer to check if it's a TIOVX color convert
7676
*
7777
* Checks if a pointer is a TIOVX color convert
7878
*

0 commit comments

Comments
 (0)