From 58b2ce9cbc99e27e2d7b8a142d2f203c2d34576d Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Wed, 30 Jan 2019 19:06:14 +0900 Subject: [PATCH] [Decoder] Pull decoder subplugins out to /ext Decoder subplugins can now be built externally without the need to be built along with nnstreamer. Thus, from now on, third party developers can write decoder subplugins without nnstreamer sources. Signed-off-by: MyungJoo Ham --- debian/nnstreamer-dev.install | 3 +- debian/nnstreamer.install | 1 + debian/rules | 9 ++--- {gst => ext}/nnstreamer/tensor_decoder/font.h | 0 ext/nnstreamer/tensor_decoder/meson.build | 44 ++++++++++++++++++++++ .../tensor_decoder/tensordec-boundingbox.c | 4 +- .../tensor_decoder/tensordec-directvideo.c | 4 +- .../tensor_decoder/tensordec-imagelabel.c | 4 +- gst/nnstreamer/nnstreamer_plugin_api.h | 8 ++++ gst/nnstreamer/tensor_common.h | 34 ----------------- gst/nnstreamer/tensor_decoder/meson.build | 3 -- gst/nnstreamer/tensor_typedef.h | 26 +++++++++++++ meson.build | 1 + packaging/nnstreamer.spec | 7 +++- 14 files changed, 96 insertions(+), 52 deletions(-) rename {gst => ext}/nnstreamer/tensor_decoder/font.h (100%) create mode 100644 ext/nnstreamer/tensor_decoder/meson.build rename {gst => ext}/nnstreamer/tensor_decoder/tensordec-boundingbox.c (99%) rename {gst => ext}/nnstreamer/tensor_decoder/tensordec-directvideo.c (98%) rename {gst => ext}/nnstreamer/tensor_decoder/tensordec-imagelabel.c (99%) diff --git a/debian/nnstreamer-dev.install b/debian/nnstreamer-dev.install index a94543c..b64018c 100644 --- a/debian/nnstreamer-dev.install +++ b/debian/nnstreamer-dev.install @@ -1,4 +1,3 @@ /usr/include/nnstreamer/*.h /usr/lib/*/pkgconfig/*.pc -/usr/lib/*/libnnstreamer.a -/usr/lib/*/libnnstreamer_filter*.a +/usr/lib/*/*.a diff --git a/debian/nnstreamer.install b/debian/nnstreamer.install index b1b67c3..8da9627 100644 --- a/debian/nnstreamer.install +++ b/debian/nnstreamer.install @@ -1,3 +1,4 @@ /usr/lib/nnstreamer/filters/libnnstreamer_filter_*.so +/usr/lib/nnstreamer/decoders/libnnstreamer_decoder_*.so /usr/lib/*/gstreamer-1.0/*.so /etc/nnstreamer.ini diff --git a/debian/rules b/debian/rules index c5ce450..539a8f0 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,10 @@ ROOT_DIR:=$(shell pwd) export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +export LD_LIBRARY_PATH=${ROOT_DIR}/build/gst/nnstreamer +export GST_PLUGIN_PATH=${ROOT_DIR}/build/gst/nnstreamer +export NNSTREAMER_FILTERS=${ROOT_DIR}/build/ext/nnstreamer/tensor_filter +export NNSTREAMER_DECODERS=${ROOT_DIR}/build/ext/nnstreamer/tensor_decoder ifneq ($(filter $(DEB_HOST_ARCH),amd64 arm64),) enable_tf=true @@ -37,11 +41,6 @@ override_dh_auto_build: ninja -C build override_dh_auto_test: - export LD_LIBRARY_PATH=${ROOT_DIR}/build/gst/nnstreamer:${ROOT_DIR}/build/gst/nnstreamer/tensor_filter - export GST_PLUGIN_PATH=${ROOT_DIR}/build - export NNSTREAMER_FILTERS=${ROOT_DIR}/build/ext/nnstreamer/tensor_filter - export NNSTREAMER_DECODERS=${ROOT_DIR}/build/gst/nnstreamer/tensor_decoder - ls -l cd build && ./tests/unittest_common && cd .. cd build && ./tests/unittest_sink --gst-plugin-path=. && cd .. cd build && ./tests/unittest_plugins --gst-plugin-path=. && cd .. diff --git a/gst/nnstreamer/tensor_decoder/font.h b/ext/nnstreamer/tensor_decoder/font.h similarity index 100% rename from gst/nnstreamer/tensor_decoder/font.h rename to ext/nnstreamer/tensor_decoder/font.h diff --git a/ext/nnstreamer/tensor_decoder/meson.build b/ext/nnstreamer/tensor_decoder/meson.build new file mode 100644 index 0000000..e4e8be3 --- /dev/null +++ b/ext/nnstreamer/tensor_decoder/meson.build @@ -0,0 +1,44 @@ +tensor_decoder_directvideo_shared = shared_library('nnstreamer_decoder_direct_video', + [ 'tensordec-directvideo.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: decoder_subplugin_install_dir +) +tensor_decoder_directvideo_static = static_library('nnstreamer_decoder_direct_video', + [ 'tensordec-directvideo.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: nnstreamer_libdir +) + +tensor_decoder_imagelabel_shared = shared_library('nnstreamer_decoder_image_labeling', + [ 'tensordec-imagelabel.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: decoder_subplugin_install_dir +) +tensor_decoder_imagelabel_static = static_library('nnstreamer_decoder_image_labeling', + [ 'tensordec-imagelabel.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: nnstreamer_libdir +) + +tensor_decoder_boundingbox_shared = shared_library('nnstreamer_decoder_bounding_boxes', + [ 'tensordec-boundingbox.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: decoder_subplugin_install_dir +) +tensor_decoder_boundingbox_static = static_library('nnstreamer_decoder_bounding_boxes', + [ 'tensordec-boundingbox.c' ], + dependencies: [nnstreamer_dep, glib_dep, gst_dep], + include_directories: nnstreamer_inc, + install: true, + install_dir: nnstreamer_libdir +) diff --git a/gst/nnstreamer/tensor_decoder/tensordec-boundingbox.c b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.c similarity index 99% rename from gst/nnstreamer/tensor_decoder/tensordec-boundingbox.c rename to ext/nnstreamer/tensor_decoder/tensordec-boundingbox.c index d523669..a1a5711 100644 --- a/gst/nnstreamer/tensor_decoder/tensordec-boundingbox.c +++ b/ext/nnstreamer/tensor_decoder/tensordec-boundingbox.c @@ -54,9 +54,9 @@ #include #include #include /* expf */ -#include -#include "tensordec.h" #include "font.h" +#include +#include #define BOX_SIZE 4 #define TFLITE_SSD_DETECTION_MAX 1917 diff --git a/gst/nnstreamer/tensor_decoder/tensordec-directvideo.c b/ext/nnstreamer/tensor_decoder/tensordec-directvideo.c similarity index 98% rename from gst/nnstreamer/tensor_decoder/tensordec-directvideo.c rename to ext/nnstreamer/tensor_decoder/tensordec-directvideo.c index 23087cc..24b0810 100644 --- a/gst/nnstreamer/tensor_decoder/tensordec-directvideo.c +++ b/ext/nnstreamer/tensor_decoder/tensordec-directvideo.c @@ -28,8 +28,8 @@ #include #include -#include "tensordec.h" -#include +#include +#include /** @brief tensordec-plugin's TensorDecDef callback */ static int diff --git a/gst/nnstreamer/tensor_decoder/tensordec-imagelabel.c b/ext/nnstreamer/tensor_decoder/tensordec-imagelabel.c similarity index 99% rename from gst/nnstreamer/tensor_decoder/tensordec-imagelabel.c rename to ext/nnstreamer/tensor_decoder/tensordec-imagelabel.c index 709d6e0..05727fb 100644 --- a/gst/nnstreamer/tensor_decoder/tensordec-imagelabel.c +++ b/ext/nnstreamer/tensor_decoder/tensordec-imagelabel.c @@ -35,8 +35,8 @@ #include #include #include -#include -#include "tensordec.h" +#include +#include /** @brief Internal data structure for image labeling */ typedef struct diff --git a/gst/nnstreamer/nnstreamer_plugin_api.h b/gst/nnstreamer/nnstreamer_plugin_api.h index 7d496e0..60f6547 100644 --- a/gst/nnstreamer/nnstreamer_plugin_api.h +++ b/gst/nnstreamer/nnstreamer_plugin_api.h @@ -240,5 +240,13 @@ get_tensor_element_count (const tensor_dim dim); extern tensor_type get_tensor_type (const gchar * typestr); +/** + * @brief Find the index value of the given key string array + * @return Corresponding index + * @param strv Null terminated array of gchar * + * @param key The key string value + */ +extern int find_key_strv (const gchar ** strv, const gchar * key); + G_END_DECLS #endif /* __NNS_PLUGIN_API_H__ */ diff --git a/gst/nnstreamer/tensor_common.h b/gst/nnstreamer/tensor_common.h index ef72583..7f6a6b9 100644 --- a/gst/nnstreamer/tensor_common.h +++ b/gst/nnstreamer/tensor_common.h @@ -56,32 +56,6 @@ G_BEGIN_DECLS -#define GST_TENSOR_VIDEO_CAPS_STR \ - GST_VIDEO_CAPS_MAKE ("{ RGB, BGR, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, GRAY8 }") \ - ", views = (int) 1, interlace-mode = (string) progressive" - -#define GST_TENSOR_AUDIO_CAPS_STR \ - GST_AUDIO_CAPS_MAKE ("{ S8, U8, S16LE, S16BE, U16LE, U16BE, S32LE, S32BE, U32LE, U32BE, F32LE, F32BE, F64LE, F64BE }") \ - ", layout = (string) interleaved" - -#define GST_TENSOR_TEXT_CAPS_STR \ - "text/x-raw, format = (string) utf8" - -#define GST_TENSOR_OCTET_CAPS_STR \ - "application/octet-stream" - -/** - * @brief Caps string for supported types - * @todo Support other types - */ -#define GST_TENSOR_MEDIA_CAPS_STR \ - GST_TENSOR_VIDEO_CAPS_STR "; " \ - GST_TENSOR_AUDIO_CAPS_STR "; " \ - GST_TENSOR_TEXT_CAPS_STR "; " \ - GST_TENSOR_OCTET_CAPS_STR - -#define GST_TENSOR_TYPE_ALL "{ float32, float64, int64, uint64, int32, uint32, int16, uint16, int8, uint8 }" - /** * @brief time synchronization options */ @@ -194,14 +168,6 @@ extern GstCaps * gst_tensors_caps_from_config (const GstTensorsConfig * config); /** - * @brief Find the index value of the given key string array - * @return Corresponding index - * @param strv Null terminated array of gchar * - * @param key The key string value - */ -extern int find_key_strv (const gchar ** strv, const gchar * key); - -/** * @brief A callback for typefind, trying to find whether a file is other/tensors or not. * For the concrete definition of headers, please look at the wiki page of nnstreamer: * https://github.com/nnsuite/nnstreamer/wiki/Design-External-Save-Format-for-other-tensor-and-other-tensors-Stream-for-TypeFind diff --git a/gst/nnstreamer/tensor_decoder/meson.build b/gst/nnstreamer/tensor_decoder/meson.build index ac1120d..8f4c22c 100644 --- a/gst/nnstreamer/tensor_decoder/meson.build +++ b/gst/nnstreamer/tensor_decoder/meson.build @@ -1,8 +1,5 @@ tensor_decoder_sources = [ 'tensordec.c', - 'tensordec-directvideo.c', - 'tensordec-imagelabel.c', - 'tensordec-boundingbox.c' ] foreach s : tensor_decoder_sources diff --git a/gst/nnstreamer/tensor_typedef.h b/gst/nnstreamer/tensor_typedef.h index 762a039..2e0f913 100644 --- a/gst/nnstreamer/tensor_typedef.h +++ b/gst/nnstreamer/tensor_typedef.h @@ -78,6 +78,32 @@ * "dimensions = (string) dim1:dim2:dim3:dim4, dim1:dim2:dim3:dim4" */ +#define GST_TENSOR_VIDEO_CAPS_STR \ + GST_VIDEO_CAPS_MAKE ("{ RGB, BGR, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, GRAY8 }") \ + ", views = (int) 1, interlace-mode = (string) progressive" + +#define GST_TENSOR_AUDIO_CAPS_STR \ + GST_AUDIO_CAPS_MAKE ("{ S8, U8, S16LE, S16BE, U16LE, U16BE, S32LE, S32BE, U32LE, U32BE, F32LE, F32BE, F64LE, F64BE }") \ + ", layout = (string) interleaved" + +#define GST_TENSOR_TEXT_CAPS_STR \ + "text/x-raw, format = (string) utf8" + +#define GST_TENSOR_OCTET_CAPS_STR \ + "application/octet-stream" + +/** + * @brief Caps string for supported types + * @todo Support other types + */ +#define GST_TENSOR_MEDIA_CAPS_STR \ + GST_TENSOR_VIDEO_CAPS_STR "; " \ + GST_TENSOR_AUDIO_CAPS_STR "; " \ + GST_TENSOR_TEXT_CAPS_STR "; " \ + GST_TENSOR_OCTET_CAPS_STR + +#define GST_TENSOR_TYPE_ALL "{ float32, float64, int64, uint64, int32, uint32, int16, uint16, int8, uint8 }" + /** * @brief Possible data element types of other/tensor. */ diff --git a/meson.build b/meson.build index 77d9a0a..3e73468 100644 --- a/meson.build +++ b/meson.build @@ -108,6 +108,7 @@ subdir('gst') # Build ext subplugins (filter-subplugins) subdir('ext/nnstreamer/tensor_filter') +subdir('ext/nnstreamer/tensor_decoder') # Build nnstreamer examples if get_option('enable-test') or get_option('install-example') diff --git a/packaging/nnstreamer.spec b/packaging/nnstreamer.spec index 320181f..ccb0c8f 100644 --- a/packaging/nnstreamer.spec +++ b/packaging/nnstreamer.spec @@ -104,7 +104,10 @@ ninja -C build %{?_smp_mflags} %if 0%{?unit_test} pushd build - export LD_LIBRARY_PATH=$(pwd)/gst/nnstreamer:$(pwd)/gst/nnstreamer/tensor_filter + export LD_LIBRARY_PATH=$(pwd)/gst/nnstreamer + export GST_PLUGIN_PATH=$(pwd)/gst/nnstreamer + export NNSTREAMER_FILTERS=$(pwd)/ext/nnstreamer/tensor_filter + export NNSTREAMER_DECODERS=$(pwd)/ext/nnstreamer/tensor_decoder %ifarch x86_64 aarch64 export TEST_TENSORFLOW=1 %endif @@ -112,7 +115,6 @@ ninja -C build %{?_smp_mflags} ./tests/unittest_sink --gst-plugin-path=. ./tests/unittest_plugins --gst-plugin-path=. popd - export NNSTREAMER_FILTERS=$(pwd)/build/ext/nnstreamer/tensor_filter pushd tests ssat -n popd @@ -172,6 +174,7 @@ popd %defattr(-,root,root,-) %license LICENSE %{_prefix}/lib/nnstreamer/filters/libnnstreamer_filter_*.so +%{_prefix}/lib/nnstreamer/decoders/libnnstreamer_decoder_*.so %{gstlibdir}/*.so %{_sysconfdir}/nnstreamer.ini -- 2.7.4