NVIDIA DeepStream SDK API Reference

6.4 Release
gst-nvcommon.h
Go to the documentation of this file.
1 
21 #ifndef __GST_NVCOMMON_H__
22 #define __GST_NVCOMMON_H__
23 
24 #include <gst/gst.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #ifndef __aarch64__
31 #define CHECK_DEFAULT_MEM(memType1, memType2) ((memType1 == NVBUF_MEM_DEFAULT && memType2 == NVBUF_MEM_CUDA_DEVICE) || \
32  (memType1 == NVBUF_MEM_CUDA_DEVICE && memType2 == NVBUF_MEM_DEFAULT))
33 
34 #define GET_DEFAULT_MEM_TYPE(mem_type) {mem_type=NVBUF_MEM_CUDA_DEVICE;}
35 
36 #else
37 
38 #define CHECK_DEFAULT_MEM(memType1, memType2) ((memType1 == NVBUF_MEM_DEFAULT && memType2 == NVBUF_MEM_SURFACE_ARRAY) || \
39  (memType1 == NVBUF_MEM_SURFACE_ARRAY && memType2 == NVBUF_MEM_DEFAULT))
40 
41 #define GET_DEFAULT_MEM_TYPE(mem_type) {int current_device = -1; cudaGetDevice(&current_device); \
42  struct cudaDeviceProp prop; cudaGetDeviceProperties(&prop, current_device); \
43  if(prop.integrated) mem_type=NVBUF_MEM_SURFACE_ARRAY;\
44  else mem_type=NVBUF_MEM_CUDA_DEVICE;}
45 
46 #endif
47 
48 #define CHECK_NVDS_MEMORY_AND_GPUID(object, surface) \
49  ({ int _errtype=0;\
50  do { \
51  if (((surface->memType == NVBUF_MEM_DEFAULT || surface->memType == NVBUF_MEM_CUDA_DEVICE) && \
52  ((int)surface->gpuId != (int)object->gpu_id)) || \
53  (((int)surface->gpuId == (int)object->gpu_id) && (surface->memType == NVBUF_MEM_SYSTEM))) { \
54  GST_ELEMENT_ERROR (object, RESOURCE, FAILED, \
55  ("Memory Compatibility Error:Input surface gpu-id doesnt match with configured gpu-id for element," \
56  " please allocate input using unified memory, or use same gpu-ids OR,"\
57  " if same gpu-ids are used ensure appropriate Cuda memories are used"),\
58  ("surface-gpu-id=%d,%s-gpu-id=%d",surface->gpuId,GST_ELEMENT_NAME(object),\
59  object->gpu_id)); \
60  _errtype = 1;\
61  } \
62  } while(0); \
63  _errtype; \
64  })
65 
66 
67 #define GST_TYPE_NVBUF_MEMORY_TYPE (gst_nvbuf_memory_get_type ())
68 GType gst_nvbuf_memory_get_type (void);
69 
70 #define GST_TYPE_COMPUTE_HW (gst_compute_hw_get_type ())
71 GType gst_compute_hw_get_type (void);
72 
73 #define GST_TYPE_INTERPOLATION_METHOD (gst_video_interpolation_method_get_type ())
75 
76 const char * gst_nvbuf_memory_get_name(int mem_type);
77 int gst_nvbuf_memory_get_value(const char *mem_type_string);
78 
79 #define PROP_NVDS_GPU_ID_INSTALL(gobject_class) \
80 do { \
81 g_object_class_install_property (gobject_class, PROP_GPU_DEVICE_ID, \
82  g_param_spec_uint ("gpu-id", "Set GPU Device ID for operation", \
83  "Set GPU Device ID for operation", \
84  0, G_MAXUINT, 0, \
85  (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | \
86  GST_PARAM_MUTABLE_READY))); \
87 }while(0)
88 
89 #define PROP_NVBUF_MEMORY_TYPE_INSTALL(gobject_class) \
90 do { \
91  g_object_class_install_property (gobject_class, PROP_NVBUF_MEMORY_TYPE, \
92  g_param_spec_enum ("nvbuf-memory-type", "Type of NvBufSurface memory allocated", \
93  "Type of NvBufSurface Memory to be allocated for output buffers", \
94  GST_TYPE_NVBUF_MEMORY_TYPE, \
95  NVBUF_MEM_DEFAULT, \
96  (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | \
97  GST_PARAM_MUTABLE_READY))); \
98 }while(0)
99 
100 #define PROP_COMPUTE_HW_INSTALL(gobject_class) \
101 do { \
102  g_object_class_install_property (gobject_class, PROP_COMPUTE_HW, \
103  g_param_spec_enum ("compute-hw", "compute-hw", \
104  "Compute Scaling HW", \
105  GST_TYPE_COMPUTE_HW, NvBufSurfTransformCompute_Default, \
106  (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | \
107  GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT))); \
108 }while(0)
109 
110 #define PROP_INTERPOLATION_METHOD_INSTALL(gobject_class) \
111 do { \
112  g_object_class_install_property (gobject_class, PROP_INTERPOLATION_METHOD, \
113  g_param_spec_enum ("interpolation-method", "Interpolation-method", \
114  "Set interpolation methods", \
115  GST_TYPE_INTERPOLATION_METHOD, NvBufSurfTransformInter_Default, \
116  (GParamFlags)(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | \
117  GST_PARAM_CONTROLLABLE | G_PARAM_CONSTRUCT))); \
118 }while(0)
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif
gst_nvbuf_memory_get_value
int gst_nvbuf_memory_get_value(const char *mem_type_string)
gst_compute_hw_get_type
GType gst_compute_hw_get_type(void)
gst_nvbuf_memory_get_name
const char * gst_nvbuf_memory_get_name(int mem_type)
gst_nvbuf_memory_get_type
GType gst_nvbuf_memory_get_type(void)
gst_video_interpolation_method_get_type
GType gst_video_interpolation_method_get_type(void)