enum
{
PROP_0,
- PROP_SILENT
+ PROP_SILENT,
+ PROP_FORCE_MEMCPY,
};
/* the capabilities of the inputs
g_object_class_install_property (gobject_class, PROP_SILENT,
g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
FALSE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_FORCE_MEMCPY,
+ g_param_spec_boolean ("force_memcpy", "Force Memcpy", "Disable in-place mode and do memcpy ?",
+ FALSE, G_PARAM_READWRITE));
gst_element_class_set_details_simple(gstelement_class,
"Tensor_Converter",
filter->tensorConfigured = FALSE;
filter->negotiated = FALSE;
filter->removePadding = FALSE;
+ filter->disableInPlace = FALSE;
}
static void
case PROP_SILENT:
filter->silent = g_value_get_boolean (value);
break;
+ case PROP_FORCE_MEMCPY:
+ filter->disableInPlace = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_SILENT:
g_value_set_boolean (value, filter->silent);
break;
+ case PROP_FORCE_MEMCPY:
+ g_value_set_boolean (value, filter->disableInPlace);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
)
static GstFlowReturn gst_c2t_transformer_videoframe(GstTensor_Converter *filter,
- GstVideoFrame *inframe, GstBuffer *outbuf)
+ GstBuffer *inbuf, GstBuffer *outbuf)
{
- // THIS CODE IS NOT TESTED WITH THE CURRENT TEST CASES!!!
- // @TODO: Verify This Code! (non in-place transform)
+ size_t sizeB = filter->dimension[0] * filter->dimension[1] * filter->dimension[2] * filter->dimension[3];
+
+ g_assert(outbuf);
+ g_assert(gst_buffer_get_size(outbuf) >= sizeB);
if (filter->removePadding == TRUE) {
int d0, d1;
offset += 4 - (offset % 4);
// Refer: https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html
- gst_buffer_map(inframe->buffer, &src_info, GST_MAP_READ);
+ gst_buffer_map(inbuf, &src_info, GST_MAP_READ);
gst_buffer_map(outbuf, &dest_info, GST_MAP_WRITE);
+
srcptr = src_info.data;
destptr = dest_info.data;
}
}
- gst_buffer_unmap(inframe->buffer, &src_info);
+ gst_buffer_unmap(inbuf, &src_info);
gst_buffer_unmap(outbuf, &dest_info);
g_printerr("\n\n\nYOUR STREAM CONFIGURATION INCURS PERFORMANCE DETERIORATION! (1)\nPlease use 4 x n as image width for inputs.\n\n\n");
return GST_FLOW_OK;
} else {
- return gst_buffer_copy_into(outbuf, inframe->buffer,
- GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS, 0,
- GST_VIDEO_FRAME_SIZE(inframe));
+ unsigned char *srcptr, *destptr;
+ GstMapInfo src_info, dest_info;
+
+ g_assert(gst_buffer_map(inbuf, &src_info, GST_MAP_READ) == TRUE);
+ g_assert(gst_buffer_map(outbuf, &dest_info, GST_MAP_WRITE) == TRUE);
+
+ srcptr = src_info.data;
+ destptr = dest_info.data;
+
+ memcpy(destptr, srcptr, sizeB);
+
+ gst_buffer_unmap(inbuf, &src_info);
+ gst_buffer_unmap(outbuf, &dest_info);
+
+ return GST_FLOW_OK;
}
return GST_FLOW_ERROR;
}
GstBuffer *inbuf,
GstBuffer *outbuf)
{
- GstVideoFrame in_frame;
GstFlowReturn res;
GstTensor_Converter *filter = GST_TENSOR_CONVERTER_CAST(trans);
switch(filter->input_media_type) {
case _NNS_VIDEO:
- // CAUTION! in_info.video must be already configured!
- if (!gst_video_frame_map(&in_frame, &filter->in_info.video, inbuf,
- GST_MAP_READ | GST_VIDEO_FRAME_MAP_FLAG_NO_REF))
- goto invalid_buffer;
-
- if (gst_c2t_transformer_videoframe(filter, &in_frame, outbuf))
- res = GST_FLOW_OK;
- else
- res = GST_FLOW_ERROR;
- gst_video_frame_unmap(&in_frame);
+ res = gst_c2t_transformer_videoframe(filter, inbuf, outbuf);
break;
/* NOT SUPPORTED */
case _NNS_AUDIO:
unknown_type:
GST_ELEMENT_ERROR(filter, CORE, NOT_IMPLEMENTED, (NULL), ("not implemented type of media"));
return GST_FLOW_NOT_SUPPORTED;
-invalid_buffer:
- GST_ELEMENT_ERROR(filter, CORE, NOT_IMPLEMENTED, (NULL), ("invalid video buffer received from input"));
- return GST_FLOW_ERROR;
}
static GstFlowReturn gst_tensor_converter_transform_ip(GstBaseTransform *trans,
}
filter->in_info.video = in_info;
- gst_base_transform_set_in_place(trans, TRUE);
+ gst_base_transform_set_in_place(trans, (filter->disableInPlace == TRUE) ? FALSE : TRUE);
filter->negotiated = gst_tensor_converter_configure_tensor(incaps, filter);
--- /dev/null
+#!/usr/bin/env bash
+
+##
+# Copyright (C) 2018 Samsung Electronics
+# License: Apache-2.0
+#
+# @file testcase03.sh
+# @brief Test tensor_converter for testcase 03. disabling in-place mode
+# @author MyungJoo Ham <myungjoo.ham@samsung.com>
+# @dependency cmp
+
+if [ $# -eq 0 ]
+then
+ PATH_TO_PLUGIN="$PWD/../../build/tensor_converter"
+else
+ PATH_TO_PLUGIN="$1"
+fi
+
+failed=0
+
+# Generate one frame only (num-buffers=1)
+do_test()
+{
+ echo
+ echo "Case 3 - $1 $2 x $3"
+ echo
+ echo gst-launch-1.0 -q --gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=testcase02_${1}_${2}x${3}.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=${1},width=${2},height=${3},framerate=0/1 ! tensor_converter force_memcpy=TRUE ! filesink location="testcase02_${1}_${2}x${3}.log" sync=true
+ gst-launch-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=testcase02_${1}_${2}x${3}.png ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=${1},width=${2},height=${3},framerate=0/1 ! tensor_converter force_memcpy=TRUE ! filesink location="testcase03_${1}_${2}x${3}.log" sync=true || failed=1
+
+ if [ "$failed" -eq "1" ]
+ then
+ echo gst-launch failed
+ fi
+ cmp -n `stat --printf="%s" testcase02_${1}_${2}x${3}.golden` testcase03_${1}_${2}x${3}.log testcase02_${1}_${2}x${3}.golden || failed=1
+}
+
+do_test BGRx 640 480
+do_test RGB 640 480
+do_test BGRx 642 480
+do_test RGB 642 480
+
+if [ "$failed" -eq "0" ]
+then
+ echo Testcase 03: SUCCESS
+ exit 0
+else
+ echo Testcase 03: FAILED
+ exit -1
+fi