mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
nvcodec: Move runtime compiler check to plugin init function
Required information for other elements Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6021>
This commit is contained in:
parent
0a55c86e6a
commit
fc4b136ac8
4 changed files with 37 additions and 91 deletions
|
@ -1,56 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
|
||||
*
|
||||
* 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 <gst/cuda/gstcuda.h>
|
||||
|
||||
#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);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.com>
|
||||
*
|
||||
* 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 <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gst_cuda_filter_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_CUDA_FILTER_H__ */
|
|
@ -2,7 +2,6 @@ nvcodec_sources = [
|
|||
'gstcudabasetransform.c',
|
||||
'gstcudaconverter.c',
|
||||
'gstcudaconvertscale.c',
|
||||
'gstcudafilter.c',
|
||||
'gstcudaipc.cpp',
|
||||
'gstcudaipcclient.cpp',
|
||||
'gstcudaipcserver.cpp',
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/cuda/gstcuda.h>
|
||||
#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 <gst/cuda/gstcudamemory.h>
|
||||
#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,
|
||||
|
|
Loading…
Reference in a new issue