From 85c592b09d543c6986fe14c76950d24d613c6d79 Mon Sep 17 00:00:00 2001 From: Jaeyun Jung Date: Sat, 8 Dec 2018 11:05:47 +0900 Subject: [PATCH] [Converter] code clean 1. move function video-stride to converter. 2. move mainpage tag to nnstreamer.c. 3. in nnstreamer.c, include config header for orc feature. Signed-off-by: Jaeyun Jung --- gst/nnstreamer/nnstreamer.c | 23 ++++++++++++++ gst/nnstreamer/tensor_common.c | 24 --------------- gst/nnstreamer/tensor_common.h | 7 ----- gst/tensor_converter/tensor_converter.c | 53 +++++++++++++++++++-------------- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/gst/nnstreamer/nnstreamer.c b/gst/nnstreamer/nnstreamer.c index a4ea767..86a178d 100644 --- a/gst/nnstreamer/nnstreamer.c +++ b/gst/nnstreamer/nnstreamer.c @@ -14,6 +14,25 @@ */ /** + * @mainpage nnstreamer + * @section intro Introduction + * - Introduction : Neural Network Streamer for AI Projects + * @section Program Program Name + * - Program Name : nnstreamer + * - Program Details : It provides a neural network framework connectivities (e.g., tensorflow, caffe) for gstreamer streams. + * Efficient Streaming for AI Projects: Neural network models wanted to use efficient and flexible streaming management as well. + * Intelligent Media Filters!: Use a neural network model as a media filter / converter. + * Composite Models!: Allow to use multiple neural network models in a single stream instance. + * Multi Model Intelligence!: Allow to use multiple sources for neural network models. + * @section INOUTPUT Input/output data + * - INPUT : None + * - OUTPUT : None + * @section CREATEINFO Code information + * - Initial date : 2018/06/14 + * - Version : 0.1 + */ + +/** * @file nnstreamer.c * @date 11 Oct 2018 * @brief Registers all nnstreamer plugins for gstreamer so that we can have a single big binary @@ -22,6 +41,10 @@ * @bug No known bugs except for NYI items */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include diff --git a/gst/nnstreamer/tensor_common.c b/gst/nnstreamer/tensor_common.c index f075f0d..6717924 100644 --- a/gst/nnstreamer/tensor_common.c +++ b/gst/nnstreamer/tensor_common.c @@ -896,30 +896,6 @@ gst_tensors_caps_from_config (const GstTensorsConfig * config) } /** - * @brief Determine if we need zero-padding - * @return 1 if we need to add (or remove) stride per row from the stream data. 0 otherwise. - */ -gint -gst_tensor_video_stride_padding_per_row (GstVideoFormat format, gint width) -{ - /** @todo The actual list is much longer. fill them (read https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html ) */ - switch (format) { - case GST_VIDEO_FORMAT_GRAY8: - case GST_VIDEO_FORMAT_RGB: - case GST_VIDEO_FORMAT_BGR: - case GST_VIDEO_FORMAT_I420: - if (width % 4) { - return 1; - } - break; - default: - break; - } - - return 0; -} - -/** * @brief Get tensor_type from string tensor_type input * @return Corresponding tensor_type. _NNS_END if unrecognized value is there. * @param typestr The string type name, supposed to be one of tensor_element_typename[] diff --git a/gst/nnstreamer/tensor_common.h b/gst/nnstreamer/tensor_common.h index 47ac875..9ab6e44 100644 --- a/gst/nnstreamer/tensor_common.h +++ b/gst/nnstreamer/tensor_common.h @@ -364,13 +364,6 @@ extern GstCaps * gst_tensors_caps_from_config (const GstTensorsConfig * config); /** - * @brief Determine if we need zero-padding - * @return 1 if we need to add (or remove) stride per row from the stream data. 0 otherwise. - */ -extern gint -gst_tensor_video_stride_padding_per_row (GstVideoFormat format, gint width); - -/** * @brief Get tensor_type from string tensor_type input * @return Corresponding tensor_type. _NNS_END if unrecognized value is there. * @param typestr The string type name, supposed to be one of tensor_element_typename[] diff --git a/gst/tensor_converter/tensor_converter.c b/gst/tensor_converter/tensor_converter.c index 95e8bb6..a997f60 100644 --- a/gst/tensor_converter/tensor_converter.c +++ b/gst/tensor_converter/tensor_converter.c @@ -25,25 +25,6 @@ */ /** - * @mainpage nnstreamer - * @section intro Introduction - * - Introduction : Neural Network Streamer for AI Projects - * @section Program Program Name - * - Program Name : nnstreamer - * - Program Details : It provides a neural network framework connectivities (e.g., tensorflow, caffe) for gstreamer streams. - * Efficient Streaming for AI Projects: Neural network models wanted to use efficient and flexible streaming management as well. - * Intelligent Media Filters!: Use a neural network model as a media filter / converter. - * Composite Models!: Allow to use multiple neural network models in a single stream instance. - * Multi Model Intelligence!: Allow to use multiple sources for neural network models. - * @section INOUTPUT Input/output data - * - INPUT : None - * - OUTPUT : None - * @section CREATEINFO Code information - * - Initial date : 2018/06/14 - * - Version : 0.1 - */ - -/** * SECTION:element-tensor_converter * * A filter that converts media stream to tensor stream for NN frameworks. @@ -879,6 +860,33 @@ gst_tensor_converter_reset (GstTensorConverter * self) } /** + * @brief Determine if we need zero-padding + * @return TRUE if we need to add (or remove) stride per row from the stream data. + */ +static gboolean +gst_tensor_converter_video_stride (GstVideoFormat format, gint width) +{ + /** + * @todo The actual list is much longer, fill them. + * (read https://gstreamer.freedesktop.org/documentation/design/mediatype-video-raw.html) + */ + switch (format) { + case GST_VIDEO_FORMAT_GRAY8: + case GST_VIDEO_FORMAT_RGB: + case GST_VIDEO_FORMAT_BGR: + case GST_VIDEO_FORMAT_I420: + if (width % 4) { + return TRUE; + } + break; + default: + break; + } + + return FALSE; +} + +/** * @brief Get supported format list. */ static void @@ -1117,14 +1125,15 @@ gst_tensor_converter_parse_caps (GstTensorConverter * self, * Emit Warning if RSTRIDE = RU4 (3BPP) && Width % 4 > 0 * @todo Add more conditions! */ - if (gst_tensor_video_stride_padding_per_row (GST_VIDEO_INFO_FORMAT - (&info), GST_VIDEO_INFO_WIDTH (&info))) { + if (gst_tensor_converter_video_stride (GST_VIDEO_INFO_FORMAT (&info), + GST_VIDEO_INFO_WIDTH (&info))) { self->remove_padding = TRUE; silent_debug ("Set flag to remove padding, width = %d", GST_VIDEO_INFO_WIDTH (&info)); GST_WARNING_OBJECT (self, - "\nYOUR STREAM CONFIGURATION INCURS PERFORMANCE DETERIORATION!\nPlease use 4 x n as image width for inputs.\n"); + "\nYOUR STREAM CONFIGURATION INCURS PERFORMANCE DETERIORATION!\n" + "Please use 4 x n as image width for inputs.\n"); } frames_dim = 3; -- 2.7.4