* @brief Configure tensor metadata from sink caps
*/
static gboolean
-gst_tensordec_configure (GstTensorDec * self, const GstCaps * caps)
+gst_tensordec_configure (GstTensorDec * self, const GstCaps * in_caps,
+ const GstCaps * out_caps)
{
GstStructure *structure;
GstTensorsConfig config;
/** This caps is coming from tensor */
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure (in_caps, 0);
if (!gst_tensors_config_from_structure (&config, structure)) {
GST_ERROR_OBJECT (self, "Cannot configure tensor from structure");
return FALSE;
}
- if (self->configured && !gst_tensordec_check_consistency (self, &config)) {
- GST_ERROR_OBJECT (self, "Mismatched to old metadata");
- return FALSE;
- }
-
if (self->decoder == NULL) {
GST_ERROR_OBJECT (self, "Decoder plugin is not yet configured.");
return FALSE;
}
+ /**
+ * If previous input configuration is set and is not compatible with incoming caps,
+ * get possible media caps from sub-plugin and change input configuration.
+ */
+ if (self->configured && !gst_tensordec_check_consistency (self, &config)) {
+ GstCaps *supposed;
+ gboolean compatible;
+
+ supposed = gst_tensordec_media_caps_from_tensor (self, &config);
+ compatible = gst_caps_is_always_compatible (out_caps, supposed);
+ gst_caps_unref (supposed);
+
+ /** Check if outcaps is compatible with new caps */
+ if (!compatible) {
+ GST_ERROR_OBJECT (self, "The coming tensor config is not valid.");
+ return FALSE;
+ }
+
+ gst_tensor_decoder_clean_plugin (self);
+ self->decoder->init (&self->plugin_data);
+ }
+
self->tensor_config = config;
self->configured = TRUE;
return TRUE;
return NULL;
}
- if (gst_tensordec_configure (self, caps)) {
+ if (gst_tensordec_configure (self, caps, othercaps)) {
supposed =
gst_tensordec_media_caps_from_tensor (self, &self->tensor_config);
} else {
silent_debug_caps (incaps, "from incaps");
silent_debug_caps (outcaps, "from outcaps");
- if (gst_tensordec_configure (self, incaps)) {
+ if (gst_tensordec_configure (self, incaps, outcaps)) {
GstCaps *supposed = gst_tensordec_media_caps_from_tensor (self,
&self->tensor_config);
## Trigger "decoder not configured"
gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc ! tensor_converter ! tensor_decoder mode=direct_video ! video/mpeg ! fakesink" 4F_n 0 1 $PERFORMANCE
+# Dynamic tensor config update test
+## After converting the flatbuf to the tensor, it is tested whether the config is updated in runtime.
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! video/x-raw, width=640, height=480, framerate=5/1,format=RGB ! \
+ tee name=t ! queue ! multifilesink location=\"test_05_raw_%1d.log\"
+ t. ! queue ! tensor_converter ! tensor_decoder mode=flatbuf ! other/flatbuf-tensor ! tensor_converter ! \
+ tensor_decoder mode=direct_video ! multifilesink location=\"test_05_decoded_%1d.log\" sync=true" 5 "Flatbuf dynamic tensor config update" 0 0 $PERFORMANCE
+callCompareTest test_05_raw_0.log test_05_decoded_0.log 5-1 "Compare for case 5-1" 1 0
+callCompareTest test_05_raw_1.log test_05_decoded_1.log 5-2 "Compare for case 5-2" 1 0
+callCompareTest test_05_raw_2.log test_05_decoded_2.log 5-3 "Compare for case 5-3" 1 0
+
+## After converting the protobuf to the tensor, it is tested whether the config is updated in runtime.
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=3 ! videoconvert ! video/x-raw, width=640, height=480, framerate=5/1,format=RGB ! \
+ tee name=t ! queue ! multifilesink location=\"test_06_raw_%1d.log\"
+ t. ! queue ! tensor_converter ! tensor_decoder mode=protobuf ! other/protobuf-tensor ! tensor_converter ! \
+ tensor_decoder mode=direct_video ! multifilesink location=\"test_06_decoded_%1d.log\" sync=true" 6 "Protobuf dynamic tensor config update" 0 0 $PERFORMANCE
+callCompareTest test_06_raw_0.log test_06_decoded_0.log 6-1 "Compare for case 6-1" 1 0
+callCompareTest test_06_raw_1.log test_06_decoded_1.log 6-2 "Compare for case 6-2" 1 0
+callCompareTest test_06_raw_2.log test_06_decoded_2.log 6-3 "Compare for case 6-3" 1 0
+
report