NVIDIA DeepStream SDK API Reference

9.1 Release
sources/gst-plugins/gst-nvimage/gstnvimage.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __GST_NVIMAGE_H__
19 #define __GST_NVIMAGE_H__
20 
21 #include <stdio.h>
22 
23 #include "nvjpeg.h"
24 
25 #ifdef __cplusplus
26 extern "C++" {
27 #endif
28 
29 static const char *_cudaGetErrorEnum(cudaError_t error) {
30  return cudaGetErrorName(error);
31 }
32 
33 static const char *_cudaGetErrorEnum(nvjpegStatus_t error) {
34  switch (error) {
35  case NVJPEG_STATUS_SUCCESS:
36  return "NVJPEG_STATUS_SUCCESS";
37 
38  case NVJPEG_STATUS_NOT_INITIALIZED:
39  return "NVJPEG_STATUS_NOT_INITIALIZED";
40 
41  case NVJPEG_STATUS_INVALID_PARAMETER:
42  return "NVJPEG_STATUS_INVALID_PARAMETER";
43 
44  case NVJPEG_STATUS_BAD_JPEG:
45  return "NVJPEG_STATUS_BAD_JPEG";
46 
47  case NVJPEG_STATUS_JPEG_NOT_SUPPORTED:
48  return "NVJPEG_STATUS_JPEG_NOT_SUPPORTED";
49 
50  case NVJPEG_STATUS_ALLOCATOR_FAILURE:
51  return "NVJPEG_STATUS_ALLOCATOR_FAILURE";
52 
53  case NVJPEG_STATUS_EXECUTION_FAILED:
54  return "NVJPEG_STATUS_EXECUTION_FAILED";
55 
56  case NVJPEG_STATUS_ARCH_MISMATCH:
57  return "NVJPEG_STATUS_ARCH_MISMATCH";
58 
59  case NVJPEG_STATUS_INTERNAL_ERROR:
60  return "NVJPEG_STATUS_INTERNAL_ERROR";
61 
62  case NVJPEG_STATUS_IMPLEMENTATION_NOT_SUPPORTED:
63  return "NVJPEG_STATUS_IMPLEMENTATION_NOT_SUPPORTED";
64 
65  case NVJPEG_STATUS_INCOMPLETE_BITSTREAM:
66  return "NVJPEG_STATUS_INCOMPLETE_BITSTREAM";
67  }
68 
69  return "<unknown>";
70 }
71 
72 template <typename T>
73 void check(T result, char const *const func, const char *const file,
74  int const line) {
75  if (result) {
76  fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n", file, line,
77  static_cast<unsigned int>(result), _cudaGetErrorEnum(result), func);
78  exit(EXIT_FAILURE);
79  }
80 }
81 
82 #define checkCudaErrors(val) check((val), #val, __FILE__, __LINE__)
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif /* __GST_NVIMAGE_H__ */
_cudaGetErrorEnum
static const char * _cudaGetErrorEnum(cudaError_t error)
Definition: sources/gst-plugins/gst-nvimage/gstnvimage.h:29
check
void check(T result, char const *const func, const char *const file, int const line)
Definition: sources/gst-plugins/gst-nvimage/gstnvimage.h:73