Debian Codegraph @

Samples/4_CUDA_Libraries/cudaNvSciNvMedia/nvmedia_utils/config_parser.h

raw
1 /* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of NVIDIA CORPORATION nor the names of its
12 * contributors may be used to endorse or promote products derived
13 * from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef _NVMEDIA_TEST_CONFIG_PARSER_H_
29 #define _NVMEDIA_TEST_CONFIG_PARSER_H_
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #include <ctype.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <unistd.h>
39
40 #include "nvmedia_core.h"
41 #include "nvmedia_surface.h"
42
43 #define MAX_ITEMS_TO_PARSE 10000
44
45 typedef enum _ParamType {
46 TYPE_UINT = 0,
47 TYPE_UINT_HEX,
48 TYPE_INT,
49 TYPE_DOUBLE,
50 TYPE_FLOAT,
51 TYPE_UCHAR,
52 TYPE_ULLONG,
53 TYPE_USHORT,
54 TYPE_CHAR_ARR,
55 TYPE_UCHAR_ARR,
56 TYPE_SHORT
57 } ParamType;
58
59 typedef enum {
60 LIMITS_NONE = 0,
61 LIMITS_MIN = 1,
62 LIMITS_BOTH = 2
63 } LimitsType;
64
65 typedef enum {
66 SECTION_NONE,
67 SECTION_CAPTURE,
68 SECTION_QP,
69 SECTION_RC,
70 SECTION_ENCODE_PIC,
71 SECTION_ENCODE_PIC_H264,
72 SECTION_ENCODE_PIC_H265,
73 SECTION_MVC,
74 SECTION_PAYLOAD,
75 SECTION_2DPROCESSOR
76 } SectionType;
77
78 typedef struct {
79 SectionType secType;
80 const char *name;
81 unsigned int lastSectionIndex;
82 size_t sizeOfStruct;
83 } SectionMap;
84
85 typedef struct {
86 const char *paramName;
87 void *mappedLocation;
88 ParamType type;
89 double defaultValue;
90 LimitsType paramLimits;
91 double minLimit;
92 double maxLimit;
93 unsigned int stringLength; // string param size
94 unsigned int *stringLengthAddr; // address of string param size
95 SectionType sectionType;
96 } ConfigParamsMap;
97
98 NvMediaStatus ConfigParser_InitParamsMap(ConfigParamsMap *paramsMap);
99 NvMediaStatus ConfigParser_ParseFile(ConfigParamsMap *paramsMap, unsigned int numParams, SectionMap *sectionsMap, char *file);
100 NvMediaStatus ConfigParser_ValidateParams(ConfigParamsMap *paramsMap, SectionMap *sectionsMap);
101 NvMediaStatus ConfigParser_DisplayParams(ConfigParamsMap *paramsMap, SectionMap *sectionsMap);
102 NvMediaStatus ConfigParser_GetSectionIndexByName(SectionMap *sectionsMap, char *sectionName, unsigned int *index);
103 NvMediaStatus ConfigParser_GetSectionIndexByType(SectionMap *sectionsMap, SectionType sectionType, unsigned int *index);
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* _NVMEDIA_TEST_CONFIG_PARSER_H_ */