NVIDIA DeepStream SDK API Reference

8.0 Release
gstnvimage.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA Corporation and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA Corporation is strictly prohibited.
9  */
10 
11 
12 #ifndef __GST_NVIMAGE_H__
13 #define __GST_NVIMAGE_H__
14 
15 #include <stdio.h>
16 
17 #include "nvjpeg.h"
18 
19 #ifdef __cplusplus
20 extern "C++" {
21 #endif
22 
23 static const char *_cudaGetErrorEnum(cudaError_t error) {
24  return cudaGetErrorName(error);
25 }
26 
27 static const char *_cudaGetErrorEnum(nvjpegStatus_t error) {
28  switch (error) {
29  case NVJPEG_STATUS_SUCCESS:
30  return "NVJPEG_STATUS_SUCCESS";
31 
32  case NVJPEG_STATUS_NOT_INITIALIZED:
33  return "NVJPEG_STATUS_NOT_INITIALIZED";
34 
35  case NVJPEG_STATUS_INVALID_PARAMETER:
36  return "NVJPEG_STATUS_INVALID_PARAMETER";
37 
38  case NVJPEG_STATUS_BAD_JPEG:
39  return "NVJPEG_STATUS_BAD_JPEG";
40 
41  case NVJPEG_STATUS_JPEG_NOT_SUPPORTED:
42  return "NVJPEG_STATUS_JPEG_NOT_SUPPORTED";
43 
44  case NVJPEG_STATUS_ALLOCATOR_FAILURE:
45  return "NVJPEG_STATUS_ALLOCATOR_FAILURE";
46 
47  case NVJPEG_STATUS_EXECUTION_FAILED:
48  return "NVJPEG_STATUS_EXECUTION_FAILED";
49 
50  case NVJPEG_STATUS_ARCH_MISMATCH:
51  return "NVJPEG_STATUS_ARCH_MISMATCH";
52 
53  case NVJPEG_STATUS_INTERNAL_ERROR:
54  return "NVJPEG_STATUS_INTERNAL_ERROR";
55 
56  case NVJPEG_STATUS_IMPLEMENTATION_NOT_SUPPORTED:
57  return "NVJPEG_STATUS_IMPLEMENTATION_NOT_SUPPORTED";
58 
59  case NVJPEG_STATUS_INCOMPLETE_BITSTREAM:
60  return "NVJPEG_STATUS_INCOMPLETE_BITSTREAM";
61  }
62 
63  return "<unknown>";
64 }
65 
66 template <typename T>
67 void check(T result, char const *const func, const char *const file,
68  int const line) {
69  if (result) {
70  fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n", file, line,
71  static_cast<unsigned int>(result), _cudaGetErrorEnum(result), func);
72  exit(EXIT_FAILURE);
73  }
74 }
75 
76 #define checkCudaErrors(val) check((val), #val, __FILE__, __LINE__)
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* __GST_NVIMAGE_H__ */
_cudaGetErrorEnum
static const char * _cudaGetErrorEnum(cudaError_t error)
Definition: gstnvimage.h:23
check
void check(T result, char const *const func, const char *const file, int const line)
Definition: gstnvimage.h:67