diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c deleted file mode 100644 index 1898376547..0000000000 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.c +++ /dev/null @@ -1,56 +0,0 @@ -/* GStreamer - * Copyright (C) 2019 Seungha Yang - * - * 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. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "gstcudafilter.h" -#include "gstcudaconvertscale.h" - -/* *INDENT-OFF* */ -const gchar *nvrtc_test_source = - "__global__ void\n" - "my_kernel (void) {}"; -/* *INDENT-ON* */ - -void -gst_cuda_filter_plugin_init (GstPlugin * plugin) -{ - gchar *test_ptx = NULL; - - if (!gst_cuda_nvrtc_load_library ()) - return; - - test_ptx = gst_cuda_nvrtc_compile (nvrtc_test_source); - - if (!test_ptx) { - return; - } - g_free (test_ptx); - - gst_element_register (plugin, "cudaconvert", GST_RANK_NONE, - GST_TYPE_CUDA_CONVERT); - gst_element_register (plugin, "cudascale", GST_RANK_NONE, - GST_TYPE_CUDA_SCALE); - gst_element_register (plugin, "cudaconvertscale", GST_RANK_NONE, - GST_TYPE_CUDA_CONVERT_SCALE); -} diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.h b/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.h deleted file mode 100644 index 4274e922f9..0000000000 --- a/subprojects/gst-plugins-bad/sys/nvcodec/gstcudafilter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* GStreamer - * Copyright (C) 2019 Seungha Yang - * - * 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. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_CUDA_FILTER_H__ -#define __GST_CUDA_FILTER_H__ - -#include - -G_BEGIN_DECLS - -void gst_cuda_filter_plugin_init (GstPlugin * plugin); - -G_END_DECLS - -#endif /* __GST_CUDA_FILTER_H__ */ diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/meson.build b/subprojects/gst-plugins-bad/sys/nvcodec/meson.build index 8cff34709b..20987ce2ae 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/meson.build +++ b/subprojects/gst-plugins-bad/sys/nvcodec/meson.build @@ -2,7 +2,6 @@ nvcodec_sources = [ 'gstcudabasetransform.c', 'gstcudaconverter.c', 'gstcudaconvertscale.c', - 'gstcudafilter.c', 'gstcudaipc.cpp', 'gstcudaipcclient.cpp', 'gstcudaipcserver.cpp', diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c index 82c3617c2d..bb8811fd0d 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c @@ -29,6 +29,7 @@ #include "config.h" #endif +#include #include "gstnvdec.h" #include "gstnvenc.h" #include "gstnvav1dec.h" @@ -38,8 +39,7 @@ #include "gstnvvp9dec.h" #include "gstnvdecoder.h" #include "gstcudamemorycopy.h" -#include "gstcudafilter.h" -#include +#include "gstcudaconvertscale.h" #ifdef HAVE_NVCODEC_NVMM #include "gstcudanvmm.h" #endif @@ -70,6 +70,29 @@ plugin_deinit (gpointer data) gst_cuda_ipc_client_deinit (); } +static gboolean +check_runtime_compiler (void) +{ + /* *INDENT-OFF* */ + const gchar *nvrtc_test_source = + "__global__ void\n" + "my_kernel (void) {}"; + /* *INDENT-ON* */ + + gchar *test_ptx; + + if (!gst_cuda_nvrtc_load_library ()) + return FALSE; + + test_ptx = gst_cuda_nvrtc_compile (nvrtc_test_source); + if (!test_ptx) + return FALSE; + + g_free (test_ptx); + + return TRUE; +} + static gboolean plugin_init (GstPlugin * plugin) { @@ -84,6 +107,7 @@ plugin_init (GstPlugin * plugin) guint api_minor_ver = 1; GList *h264_enc_cdata = NULL; GList *h265_enc_cdata = NULL; + gboolean have_nvrtc = FALSE; GST_DEBUG_CATEGORY_INIT (gst_nvcodec_debug, "nvcodec", 0, "nvcodec"); GST_DEBUG_CATEGORY_INIT (gst_nvdec_debug, "nvdec", 0, "nvdec"); @@ -136,6 +160,8 @@ plugin_init (GstPlugin * plugin) return TRUE; } + have_nvrtc = check_runtime_compiler (); + for (i = 0; i < dev_count; i++) { GstCudaContext *context = gst_cuda_context_new (i); CUcontext cuda_ctx; @@ -259,7 +285,15 @@ plugin_init (GstPlugin * plugin) } gst_cuda_memory_copy_register (plugin, GST_RANK_NONE); - gst_cuda_filter_plugin_init (plugin); + + if (have_nvrtc) { + gst_element_register (plugin, "cudaconvert", GST_RANK_NONE, + GST_TYPE_CUDA_CONVERT); + gst_element_register (plugin, "cudascale", GST_RANK_NONE, + GST_TYPE_CUDA_SCALE); + gst_element_register (plugin, "cudaconvertscale", GST_RANK_NONE, + GST_TYPE_CUDA_CONVERT_SCALE); + } gst_element_register (plugin, "cudaipcsink", GST_RANK_NONE, GST_TYPE_CUDA_IPC_SINK); gst_element_register (plugin,