From 30d2065f60fdb31256859f1fc69113216f42f8c4 Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Mon, 4 Mar 2019 17:30:49 +0900 Subject: [PATCH] [Android] Add NO_AUDIO for video only case There are the cases which has no needs for audio support. In order to reduce shared library size, NO_AUDIO build Option is added. **Changes proposed in this PR:** - Addded NO_AUDIO option for build. - Modify Android-app.mk and Android-nnstreamer.mk **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon --- gst/nnstreamer/nnstreamer_plugin_api.h | 1 - gst/nnstreamer/no_audio_define.h | 90 ++++++++++++++++++++++ .../tensor_aggregator/tensor_aggregator.h | 1 + gst/nnstreamer/tensor_common.c | 6 +- gst/nnstreamer/tensor_common.h | 8 ++ gst/nnstreamer/tensor_converter/tensor_converter.h | 1 - jni/Android-app.mk | 29 +++++-- jni/Android-nnstreamer.mk | 44 +++++++++-- meson.build | 9 +++ meson_options.txt | 1 + 10 files changed, 170 insertions(+), 20 deletions(-) create mode 100644 gst/nnstreamer/no_audio_define.h diff --git a/gst/nnstreamer/nnstreamer_plugin_api.h b/gst/nnstreamer/nnstreamer_plugin_api.h index ff07c5f..d8d8bce 100644 --- a/gst/nnstreamer/nnstreamer_plugin_api.h +++ b/gst/nnstreamer/nnstreamer_plugin_api.h @@ -29,7 +29,6 @@ #include #include #include -#include #include G_BEGIN_DECLS diff --git a/gst/nnstreamer/no_audio_define.h b/gst/nnstreamer/no_audio_define.h new file mode 100644 index 0000000..ee3e956 --- /dev/null +++ b/gst/nnstreamer/no_audio_define.h @@ -0,0 +1,90 @@ +/** + * NNStreamer Common API Header for Plug-Ins + * Copyright (C) 2019 Jijoong Moon + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + */ +/** + * @file no_audio_define.h + * @date 07 Mar 2019 + * @brief Define collection of audio variables and functions for no audio support + * @see https://github.com/nnsuite/nnstreamer + * @author Jijoong Moon + * @bug No known bugs except for NYI items + * + */ +#ifndef __NO_AUDIO_DEFINE_H__ +#define __NO_AUDIO_DEFINE_H__ + +/** + * @brief Macro for gst_tensor_config_from_audio_info + */ +#define gst_tensor_config_from_audio_info(...) do { \ + GST_ERROR ("\n This binary does not support audio type. Please build NNStreamer with disable-audio-support : false\n"); \ + return FALSE; \ + } while(0) + +/** + * @brief Macro for gst_audio_format_from_string + */ +#define gst_audio_format_from_string(...) GST_AUDIO_FORMAT_UNKNOWN + +/** + * @brief Macro for gst_audio_format_to_string + */ +#define gst_audio_format_to_string(...) "Unknown" + +/** + * @brief Macro for gst_audio_info_init + */ +#define gst_audio_info_init(...) do { \ + GST_ERROR ("\n This binary does not support audio type. Please build NNStreamer with disable-audio-support : false\n"); \ + } while(0) + +/** + * @brief Macro for gst_audio_info_from_caps + */ +#define gst_audio_info_from_caps(...) FALSE + +/** + * @brief Macro for GstAudioInfo structure + */ +#define GstAudioInfo gsize + +/** + * @brief Macro for GST_AUDIO_INFO_BPF + */ +#define GST_AUDIO_INFO_BPF(...) 1 + +/** + * @brief GstAudioFormat ( There are more variables in audio-format.h ) + */ +typedef enum _GstAudioFormat +{ + GST_AUDIO_FORMAT_UNKNOWN, + GST_AUDIO_FORMAT_S8, + GST_AUDIO_FORMAT_U8, + GST_AUDIO_FORMAT_S16, + GST_AUDIO_FORMAT_U16, + GST_AUDIO_FORMAT_S32, + GST_AUDIO_FORMAT_U32, + GST_AUDIO_FORMAT_F32, + GST_AUDIO_FORMAT_F64 +} GstAudioFormat; + +/** + * @brief Macro for GST_AUDIO_CAPS_MAKE + */ +#define GST_AUDIO_CAPS_MAKE(format) \ + "audio/x-raw, " \ + "format = (string) " format +#endif diff --git a/gst/nnstreamer/tensor_aggregator/tensor_aggregator.h b/gst/nnstreamer/tensor_aggregator/tensor_aggregator.h index f250422..17ad58c 100644 --- a/gst/nnstreamer/tensor_aggregator/tensor_aggregator.h +++ b/gst/nnstreamer/tensor_aggregator/tensor_aggregator.h @@ -29,6 +29,7 @@ #include #include +#include G_BEGIN_DECLS diff --git a/gst/nnstreamer/tensor_common.c b/gst/nnstreamer/tensor_common.c index ebcb096..e9bb5c3 100644 --- a/gst/nnstreamer/tensor_common.c +++ b/gst/nnstreamer/tensor_common.c @@ -693,8 +693,10 @@ gst_tensor_config_from_video_info (GstTensorConfig * config, * @note Change dimention if tensor contains N frames. * @return TRUE if supported type */ -static gboolean -gst_tensor_config_from_audio_info (GstTensorConfig * config, + +__attribute__ ((unused)) + static gboolean + _gst_tensor_config_from_audio_info (GstTensorConfig * config, const GstStructure * structure) { /** diff --git a/gst/nnstreamer/tensor_common.h b/gst/nnstreamer/tensor_common.h index 4a6782e..29715d2 100644 --- a/gst/nnstreamer/tensor_common.h +++ b/gst/nnstreamer/tensor_common.h @@ -51,6 +51,14 @@ #define nns_memset memset #endif +#ifdef NO_AUDIO +#include +#else +#include +#include +#define gst_tensor_config_from_audio_info(...) _gst_tensor_config_from_audio_info(__VA_ARGS__) +#endif + G_BEGIN_DECLS /** diff --git a/gst/nnstreamer/tensor_converter/tensor_converter.h b/gst/nnstreamer/tensor_converter/tensor_converter.h index 28a65e3..7bc25c2 100644 --- a/gst/nnstreamer/tensor_converter/tensor_converter.h +++ b/gst/nnstreamer/tensor_converter/tensor_converter.h @@ -36,7 +36,6 @@ #include #include -#include #include G_BEGIN_DECLS diff --git a/jni/Android-app.mk b/jni/Android-app.mk index 6f1721d..ba07966 100644 --- a/jni/Android-app.mk +++ b/jni/Android-app.mk @@ -19,6 +19,7 @@ LOCAL_PATH := $(call my-dir) NNSTREAMER_VERSION := 0.1.1 CUSTOM_LINKER64 := -fPIE -pie -Wl,-dynamic-linker,/data/nnstreamer/libandroid/linker64 +NO_AUDIO := false # Do not specify "TARGET_ARCH_ABI" in this file. If you want to append additional architecture, # Please append an architecture name behind "APP_ABI" in Application.mk file. @@ -55,30 +56,42 @@ define shared_lib_gst endef # Describe shared libraries that are needed to run this application. -so_names_common := gstreamer-1.0 gstbase-1.0 gstaudio-1.0 gstvideo-1.0 glib-2.0 \ +so_names_common := gstreamer-1.0 gstbase-1.0 gstvideo-1.0 glib-2.0 \ gobject-2.0 intl z bz2 orc-0.4 gmodule-2.0 ffi gsttag-1.0 iconv \ - gstapp-1.0 png16 gstbadaudio-1.0 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \ + gstapp-1.0 png16 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \ pangoft2-1.0 pango-1.0 gthread-2.0 cairo pixman-1 fontconfig expat freetype \ gstbadvideo-1.0 gstcontroller-1.0 jpeg graphene-1.0 gstpbutils-1.0 gstgl-1.0 \ gstallocators-1.0 gstbadallocators-1.0 harfbuzz + +ifeq ($(NO_AUDIO), false) +so_names_common += gstaudio-1.0 gstbadaudio-1.0 +endif + $(foreach item,$(so_names_common),$(eval $(call shared_lib_common,$(item)))) -so_names_gst := gstcoreelements gstcoretracers gstadder gstapp gstaudioconvert \ - gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc gstgio \ +so_names_gst := gstcoreelements gstcoretracers gstadder gstapp \ gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate \ gstvideoscale gstvideotestsrc gstvolume gstautodetect gstvideofilter gstopengl \ gstopensles gstcompositor gstpng gstmultifile nnstreamer -$(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item)))) +ifeq ($(NO_AUDIO), false) +so_names_gst += gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc +endif -BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \ -gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc gstgio \ +$(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item)))) + +BUILDING_BLOCK_LIST := z gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \ +gstapp gstgio \ gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \ gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \ -gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 gio-2.0 pangocairo pango gthread \ +gstbase-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badbase-1.0 gio-2.0 pangocairo pango gthread \ cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstallocators gstbadallocators \ harfbuzz bz2 nnstreamer +ifeq ($(NO_AUDIO), false) +BUILDING_BLOCK_LIST += gstaudio-1.0 gstbadaudio-1.0 gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc +endif + # In case of Android ARM 64bit environment, the default path of linker is "/data/nnstreamer/". # We use the "tests/nnstreamer_repo_dynamicity/tensor_repo_dynamic_test.c" file as a test application. # This application is dependent on 'multifilesrc' and 'png' element that are provided by Gstreamer. diff --git a/jni/Android-nnstreamer.mk b/jni/Android-nnstreamer.mk index 0581b20..716b4b9 100644 --- a/jni/Android-nnstreamer.mk +++ b/jni/Android-nnstreamer.mk @@ -28,6 +28,7 @@ LOCAL_PATH := $(call my-dir) # NNSTREAMER_VERSION := 0.1.2 +NO_AUDIO := false # Do not specify "TARGET_ARCH_ABI" in this file. If you want to append additional architecture, # Please append an architecture name behind "APP_ABI" in Application.mk file. @@ -64,22 +65,44 @@ define shared_lib_gst endef # Describe shared libraries that are needed to run this application. -so_names_common := gstreamer-1.0 gstbase-1.0 gstaudio-1.0 gstvideo-1.0 glib-2.0 \ + +so_names_common := gstreamer-1.0 gstbase-1.0 gstvideo-1.0 glib-2.0 \ gobject-2.0 intl z bz2 orc-0.4 gmodule-2.0 ffi gsttag-1.0 iconv \ - gstapp-1.0 png16 gstbadaudio-1.0 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \ + gstapp-1.0 png16 gstbadbase-1.0 gio-2.0 pangocairo-1.0 \ pangoft2-1.0 pango-1.0 gthread-2.0 cairo pixman-1 fontconfig expat freetype \ gstbadvideo-1.0 gstcontroller-1.0 jpeg graphene-1.0 gstpbutils-1.0 gstgl-1.0 \ - gstbadallocators-1.0 harfbuzz + gstallocators-1.0 gstbadallocators-1.0 harfbuzz + +ifeq ($(NO_AUDIO), false) +so_names_common += gstaudio-1.0 gstbadaudio-1.0 +endif + $(foreach item,$(so_names_common),$(eval $(call shared_lib_common,$(item)))) -so_names_gst := gstcoreelements gstcoretracers gstadder gstapp gstaudioconvert \ - gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc gstgio \ +so_names_gst := gstcoreelements gstcoretracers gstadder gstapp \ gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate \ gstvideoscale gstvideotestsrc gstvolume gstautodetect gstvideofilter gstopengl \ gstopensles gstcompositor gstpng gstmultifile + +ifeq ($(NO_AUDIO), false) +so_names_gst += gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc +endif + $(foreach item,$(so_names_gst),$(eval $(call shared_lib_gst,$(item)))) +BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \ +gstapp \ +gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \ +gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \ +gstbase-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badbase-1.0 pangocairo pango gthread \ +cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstallocators gstbadallocators \ +harfbuzz bz2 + +ifeq ($(NO_AUDIO), false) +BUILDING_BLOCK_LIST += gstaudio-1.0 gstbadaudio-1.0 gstaudioconvert gstaudiomixer gstaudiorate gstaudioresample gstaudiotestsrc +endif + include $(CLEAR_VARS) # Please keep the pthread and openmp library for checking a compatibility @@ -88,6 +111,11 @@ LOCAL_CFLAGS += -O0 -DVERSION=\"$(NNSTREAMER_VERSION)\" LOCAL_CXXFLAGS += -std=c++11 LOCAL_CFLAGS += -pthread -fopenmp +ifeq ($(NO_AUDIO), true) +LOCAL_CFLAGS += -DNO_AUDIO +LOCAL_CXXFLAGS += -DNO_AUDIO +endif + LOCAL_LDFLAGS += -fuse-ld=bfd LOCAL_MODULE_TAGS := optional @@ -129,12 +157,12 @@ LOCAL_C_INCLUDES := $(NNSTREAMER_GST_HOME)/ \ $(NNSTREAMER_GST_HOME)/tensor_transform/ BUILDING_BLOCK_LIST := gstreamer-1.0 glib-2.0 gobject-2.0 intl gstcoreelements gstcoretracers gstadder \ -gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc gstgio \ +gstapp gstaudioconvert gstaudiomixer gstaudioresample gstaudiorate gstaudioresample gstaudiotestsrc \ gstpango gstrawparse gsttypefindfunctions gstvideoconvert gstvideorate gstvideoscale gstvideotestsrc \ gstvolume gstautodetect gstvideofilter gstopengl gstopensles gmodule-2.0 gstcompositor ffi iconv png multifile \ -gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 gio-2.0 pangocairo pango gthread \ +gstbase-1.0 gstaudio-1.0 gstvideo-1.0 tag-1.0 orc app-1.0 badaudio badbase-1.0 pangocairo pango gthread \ cairo pixman fontconfig expat gstbadvideo gstcontroller jpeg graphene gstpbutils gstgl gstbadallocators \ -gstallocators harfbuzz bz2 +gstallocators harfbuzz bz2 z LOCAL_C_INCLUDES += $(GSTREAMER_ROOT)/include/gstreamer-1.0 \ $(GSTREAMER_ROOT)/include/glib-2.0 \ diff --git a/meson.build b/meson.build index fab7f99..b3831b1 100644 --- a/meson.build +++ b/meson.build @@ -75,6 +75,15 @@ else add_project_arguments('-DDISABLE_ORC=1', language: ['c', 'cpp']) endif +# NO Audio support +disable_audio = false + +if get_option('disable-audio-support') + disable_audio = true + add_project_arguments('-DNO_AUDIO=1', language: ['c', 'cpp']) + message('Disable Audio Type Support') +endif + # Tensorflow have_tensorflow = false diff --git a/meson_options.txt b/meson_options.txt index 3bb31f7..23f8d33 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -2,3 +2,4 @@ option('enable-test', type: 'boolean', value: true) option('enable-tensorflow-lite', type: 'boolean', value: true) option('enable-tensorflow', type: 'boolean', value: true) option('install-example', type: 'boolean', value: false) +option('disable-audio-support', type: 'boolean', value: false) -- 2.7.4