codekingpro/portable-devtools
114k
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION &
3 * AFFILIATES. All rights reserved. SPDX-License-Identifier:
4 * LicenseRef-NvidiaProprietary
5 *
6 * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
7 * property and proprietary rights in and to this material, related
8 * documentation and any modifications thereto. Any use, reproduction,
9 * disclosure or distribution of this material and related documentation
10 * without an express license agreement from NVIDIA CORPORATION or
11 * its affiliates is strictly prohibited.
12 */
13
14#pragma once
15
16#include "nvcomp/shared_types.h"
17
18namespace nvcomp
19{
20
21/**
22 * @brief Format specification for ANS compression
23 */
24struct ANSFormatSpecHeader
25{
26 // Empty for now
27};
28
29/**
30 * @brief Format specification for Bitcomp compression
31 */
32struct BitcompFormatSpecHeader
33{
34 /**
35 * @brief Bitcomp algorithm options.
36 *
37 * - 0 : Default algorithm, usually gives the best compression ratios
38 * - 1 : "Sparse" algorithm, works well on sparse data (with lots of zeroes).
39 * and is usually a faster than the default algorithm.
40 */
41 int algorithm;
42 /**
43 * @brief One of nvcomp's possible data types
44 */
45 nvcompType_t data_type;
46};
47
48/**
49 * @brief Format specification for Cascaded compression
50 */
51struct CascadedFormatSpecHeader
52{
53 /**
54 * @brief The size of each internal chunk of data to decompress independently
55 * with
56 *
57 * Cascaded compression. The value should be in the range of [512, 16384]
58 * depending on the datatype of the input and the shared memory size of
59 * the GPU being used. This is not the size of chunks passed into the API.
60 * Recommended size is 4096.
61 *
62 * @note Not currently used and a default of 4096 is just used.
63 */
64 size_t internal_chunk_bytes;
65 /**
66 * @brief The datatype used to define the bit-width for compression
67 */
68 nvcompType_t type;
69 /**
70 * @brief The number of Run Length Encodings to perform.
71 */
72 int num_RLEs;
73 /**
74 * @brief The number of Delta Encodings to perform.
75 */
76 int num_deltas;
77 /**
78 * @brief Whether or not to bitpack the final layers.
79 */
80 int use_bp;
81};
82
83/**
84 * @brief Format specification for Deflate compression
85 */
86struct DeflateFormatSpecHeader
87{
88 /**
89 * @brief Compression algorithm to use.
90 *
91 * - 0: highest-throughput, entropy-only compression (use for symmetric
92 * compression/decompression performance)
93 * - 1: high-throughput, low compression ratio (default)
94 * - 2: medium-throughput, medium compression ratio, beat Zlib level 1 on the
95 * compression ratio
96 * - 3: placeholder for further compression level support, will fall into
97 * MEDIUM_COMPRESSION at this point
98 * - 4: lower-throughput, higher compression ratio, beat Zlib level 6 on the
99 * compression ratio
100 * - 5: lowest-throughput, highest compression ratio
101 */
102 int algorithm;
103};
104
105/**
106 * @brief Format specification for GDeflate compression
107 */
108struct GdeflateFormatSpecHeader
109{
110 /**
111 * @brief Compression algorithm to use.
112 *
113 * - 0: highest-throughput, entropy-only compression (use for symmetric
114 * compression/decompression performance)
115 * - 1: high-throughput, low compression ratio (default)
116 * - 2: medium-throughput, medium compression ratio, beat Zlib level 1 on the
117 * compression ratio
118 * - 3: placeholder for further compression level support, will fall into
119 * MEDIUM_COMPRESSION at this point
120 * - 4: lower-throughput, higher compression ratio, beat Zlib level 6 on the
121 * compression ratio
122 * - 5: lowest-throughput, highest compression ratio
123 */
124 int algorithm;
125};
126
127/**
128 * @brief Format specification for Gzip compression
129 */
130struct GzipFormatSpecHeader
131{
132 // Empty for now
133};
134
135/**
136 * @brief Format specification for LZ4 compression
137 */
138struct LZ4FormatSpecHeader
139{
140 /**
141 * @brief LZ4 data type to use.
142 */
143 union {
144 nvcompType_t data_type;
145 unsigned char bytes[4];
146 };
147};
148
149/**
150 * @brief Format specification for Snappy compression
151 */
152struct SnappyFormatSpecHeader
153{
154 // Empty for now
155};
156
157/**
158 * @brief Format specification for Zstd compression
159 */
160struct ZstdFormatSpecHeader
161{
162 // Empty for now
163};
164
165} // namespace nvcomp
166 