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
147150GST_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
163166static 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 );
166169static gboolean gst_tiovx_color_convert_create_graph (GstTIOVXSiso * trans ,
167170 vx_context context , vx_graph graph );
168171static 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 );
170174static 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
173180static 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
480489static gboolean
481490gst_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
585607static 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
612634static gboolean
613635gst_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+ }
0 commit comments