uvgVPCCenc 1.0.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
bitstream_common.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 * This file is part of uvgVPCCenc V-PCC encoder.
3 *
4 * Copyright (c) 2024, Tampere University, ITU/ISO/IEC, project contributors
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above copyright notice, this
14 * list of conditions and the following disclaimer in the documentation and/or
15 * other materials provided with the distribution.
16 *
17 * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
31 ****************************************************************************/
32
33#pragma once
34
35#include <cstdint>
36
37// From TMC2, floorLog2() and ceilLog2() are used for V3C and NAL unit size precision calculations
38static inline int floorLog2(uint32_t x) {
39 if (x == 0) {
40 // note: ceilLog2() expects -1 as return value
41 return -1;
42 }
43#ifdef __GNUC__
44 return 31 - __builtin_clz(x);
45#else
46#ifdef _MSC_VER
47 unsigned long r = 0;
48 _BitScanReverse(&r, x);
49 return r;
50#else
51 int result = 0;
52 if (x & 0xffff0000) {
53 x >>= 16;
54 result += 16;
55 }
56 if (x & 0xff00) {
57 x >>= 8;
58 result += 8;
59 }
60 if (x & 0xf0) {
61 x >>= 4;
62 result += 4;
63 }
64 if (x & 0xc) {
65 x >>= 2;
66 result += 2;
67 }
68 if (x & 0x2) {
69 // x >>= 1;
70 result += 1;
71 }
72 return result;
73#endif
74#endif
75}
76static inline int ceilLog2(uint32_t x) { return (x == 0) ? -1 : floorLog2(x - 1) + 1; }
77
79 P_TILE = 0, // P_TILE (Inter atlas tile
80 I_TILE, // I_TILE (Intra atlas tile)
81 SKIP_TILE // SKIP_TILE (SKIP atlas tile)
82};
83
85 I_INTRA = 0, // 0: Non-predicted patch mode
86 I_RAW, // 1: RAW Point Patch mode
87 I_EOM, // 2: EOM Point Patch mode
88 I_RESERVED_3, // 3: I_RESERVED Reserved modes
89 I_RESERVED_4, // 4: I_RESERVED Reserved modes
90 I_RESERVED_5, // 5: I_RESERVED Reserved modes
91 I_RESERVED_6, // 6: I_RESERVED Reserved modes
92 I_RESERVED_7, // 7: I_RESERVED Reserved modes
93 I_RESERVED_8, // 8: I_RESERVED Reserved modes
94 I_RESERVED_9, // 9: I_RESERVED Reserved modes
95 I_RESERVED_10, // 10: I_RESERVED Reserved modes
96 I_RESERVED_11, // 11: I_RESERVED Reserved modes
97 I_RESERVED_12, // 12: I_RESERVED Reserved modes
98 I_RESERVED_13, // 13: I_RESERVED Reserved modes
99 I_END // 14: Patch termination mode
101
103 P_SKIP = 0, // 0: Patch Skip mode
104 P_MERGE, // 1: Patch Merge mode
105 P_INTER, // 2: Inter predicted Patch mode
106 P_INTRA, // 3: Non-predicted Patch mode
107 P_RAW, // 4: RAW Point Patch mode
108 P_EOM, // 5: EOM Point Patch mode
109 P_RESERVED_6, // 6: Reserved modes
110 P_RESERVED_7, // 7: Reserved modes
111 P_RESERVED_8, // 8: Reserved modes
112 P_RESERVED_9, // 9: Reserved modes
113 P_RESERVED_10, // 10: Reserved modes
114 P_RESERVED_11, // 11: Reserved modes
115 P_RESERVED_12, // 12: Reserved modes
116 P_RESERVED_13, // 13: Reserved modes
117 P_END, // 14: Patch termination mode
118};
119
121 V3C_VPS = 0, // 0: Sequence parameter set
122 V3C_AD, // 1: Patch Data Group
123 V3C_OVD, // 2: Occupancy Video Data
124 V3C_GVD, // 3: Geometry Video Data
125 V3C_AVD, // 4: Attribute Video Data
126};
127
129 NAL_TRAIL_N = 0, // 0: Coded tile of a non-TSA, non STSA trailing atlas frame ACL
130 NAL_TRAIL_R, // 1: Coded tile of a non-TSA, non STSA trailing atlas frame ACL
131 NAL_TSA_N, // 2: Coded tile of a TSA atlas frame ACL
132 NAL_TSA_R, // 3: Coded tile of a TSA atlas frame ACL
133 NAL_STSA_N, // 4: Coded tile of a STSA atlas frame ACL
134 NAL_STSA_R, // 5: Coded tile of a STSA atlas frame ACL
135 NAL_RADL_N, // 6: Coded tile of a RADL atlas frame ACL
136 NAL_RADL_R, // 7: Coded tile of a RADL atlas frame ACL
137 NAL_RASL_N, // 8: Coded tile of a RASL atlas frame ACL
138 NAL_RASL_R, // 9: Coded tile of a RASL atlas frame ACL
139 NAL_SKIP_N, // 10: Coded tile of a skipped atlas frame ACL
140 NAL_SKIP_R, // 11: Coded tile of a skipped atlas frame ACL
141 NAL_RSV_ACL_N12, // 12: Reserved non-IRAP sub-layer non-reference ACL NAL unit types ACL
142 NAL_RSV_ACL_N14, // 14: Reserved non-IRAP sub-layer non-reference ACL NAL unit types ACL
143 NAL_RSV_ACL_R13, // 13: Reserved non-IRAP sub-layer reference ACL NAL unit types ACL
144 NAL_RSV_ACL_R15, // 15: Reserved non-IRAP sub-layer reference ACL NAL unit types ACL
145 NAL_BLA_W_LP, // 16: Coded tile of a BLA atlas frame ACL
146 NAL_BLA_W_RADL, // 17: Coded tile of a BLA atlas frame ACL
147 NAL_BLA_N_LP, // 18: Coded tile of a BLA atlas frame ACL
148 NAL_GBLA_W_LP, // 19: Coded tile of a GBLA atlas frame ACL
149 NAL_GBLA_W_RADL, // 20: Coded tile of a GBLA atlas frame ACL
150 NAL_GBLA_N_LP, // 21: Coded tile of a GBLA atlas frame ACL
151 NAL_IDR_W_RADL, // 22: Coded tile of an IDR atlas frame ACL
152 NAL_IDR_N_LP, // 23: Coded tile of an IDR atlas frame ACL
153 NAL_GIDR_W_RADL, // 24: Coded tile of a GIDR atlas frame ACL
154 NAL_GIDR_N_LP, // 25: Coded tile of a GIDR atlas frame ACL
155 NAL_CRA, // 26: Coded tile of a CRA atlas frame ACL
156 NAL_GCRA, // 27: Coded tile of a GCRA atlas frame ACL
157 NAL_RSV_IRAP_ACL_28, // 28: Reserved IRAP ACL NAL unit types ACL
158 NAL_RSV_IRAP_ACL_29, // 29: Reserved IRAP ACL NAL unit types ACL
159 NAL_RSV_ACL_30, // 30: Reserved non-IRAP ACL NAL unit types ACL
160 NAL_RSV_ACL_31, // 31: Reserved non-IRAP ACL NAL unit types ACL
161 NAL_RSV_ACL_32, // 32: Reserved non-IRAP ACL NAL unit types ACL
162 NAL_RSV_ACL_33, // 33: Reserved non-IRAP ACL NAL unit types ACL
163 NAL_RSV_ACL_34, // 34: Reserved non-IRAP ACL NAL unit types ACL
164 NAL_RSV_ACL_35, // 35: Reserved non-IRAP ACL NAL unit types ACL
165 NAL_ASPS, // 36: Atlas sequence parameter set non-ACL
166 NAL_AFPS, // 37: Atlas frame parameter set non-ACL
167 NAL_AUD, // 38: Access unit delimiter non-ACL
168 NAL_V3C_AUD, // 39: V3C access unit delimiter non-ACL
169 NAL_EOS, // 40: End of sequence non-ACL
170 NAL_EOB, // 41: End of bitstream non-ACL
171 NAL_FD, // 42: Filler non-ACL
172 NAL_PREFIX_NSEI, // 43: Non-essential supplemental enhancement information non-ACL
173 NAL_SUFFIX_NSEI, // 44: Non-essential supplemental enhancement information non-ACL
174 NAL_PREFIX_ESEI, // 45: Essential supplemental enhancement information non-ACL
175 NAL_SUFFIX_ESEI, // 46: Essential supplemental enhancement information non-ACL
176 NAL_AAPS, // 47: Atlas adaptation parameter set non-ACL
177 NAL_RSV_NACL_48, // 48: Reserved non-ACL NAL unit types non-ACL
178 NAL_RSV_NACL_49, // 49: Reserved non-ACL NAL unit types non-ACL
179 NAL_RSV_NACL_50, // 50: Reserved non-ACL NAL unit types non-ACL
180 NAL_RSV_NACL_51, // 51: Reserved non-ACL NAL unit types non-ACL
181 NAL_RSV_NACL_52, // 52: Reserved non-ACL NAL unit types non-ACL
182 NAL_UNSPEC_53, // 53: Unspecified non-ACL NAL unit types non-ACL
183 NAL_UNSPEC_54, // 54: Unspecified non-ACL NAL unit types non-ACL
184 NAL_UNSPEC_55, // 55: Unspecified non-ACL NAL unit types non-ACL
185 NAL_UNSPEC_56, // 56: Unspecified non-ACL NAL unit types non-ACL
186 NAL_UNSPEC_57, // 57: Unspecified non-ACL NAL unit types non-ACL
187 NAL_UNSPEC_58, // 58: Unspecified non-ACL NAL unit types non-ACL
188 NAL_UNSPEC_59, // 59: Unspecified non-ACL NAL unit types non-ACL
189 NAL_UNSPEC_60, // 60: Unspecified non-ACL NAL unit types non-ACL
190 NAL_UNSPEC_61, // 61: Unspecified non-ACL NAL unit types non-ACL
191 NAL_UNSPEC_62, // 62: Unspecified non-ACL NAL unit types non-ACL
192 NAL_UNSPEC_63 // 63: Unspecified non-ACL NAL unit types non-ACL
ATH_TYPE
Definition bitstream_common.hpp:78
@ P_TILE
Definition bitstream_common.hpp:79
@ SKIP_TILE
Definition bitstream_common.hpp:81
@ I_TILE
Definition bitstream_common.hpp:80
ATDU_PATCH_MODE_P_TILE
Definition bitstream_common.hpp:102
@ P_SKIP
Definition bitstream_common.hpp:103
@ P_RAW
Definition bitstream_common.hpp:107
@ P_MERGE
Definition bitstream_common.hpp:104
@ P_RESERVED_10
Definition bitstream_common.hpp:113
@ P_END
Definition bitstream_common.hpp:117
@ P_RESERVED_11
Definition bitstream_common.hpp:114
@ P_INTER
Definition bitstream_common.hpp:105
@ P_RESERVED_8
Definition bitstream_common.hpp:111
@ P_EOM
Definition bitstream_common.hpp:108
@ P_RESERVED_7
Definition bitstream_common.hpp:110
@ P_RESERVED_13
Definition bitstream_common.hpp:116
@ P_INTRA
Definition bitstream_common.hpp:106
@ P_RESERVED_9
Definition bitstream_common.hpp:112
@ P_RESERVED_12
Definition bitstream_common.hpp:115
@ P_RESERVED_6
Definition bitstream_common.hpp:109
NAL_UNIT_TYPE
Definition bitstream_common.hpp:128
@ NAL_UNSPEC_57
Definition bitstream_common.hpp:186
@ NAL_UNSPEC_58
Definition bitstream_common.hpp:187
@ NAL_UNSPEC_60
Definition bitstream_common.hpp:189
@ NAL_TRAIL_R
Definition bitstream_common.hpp:130
@ NAL_RASL_R
Definition bitstream_common.hpp:138
@ NAL_FD
Definition bitstream_common.hpp:171
@ NAL_ASPS
Definition bitstream_common.hpp:165
@ NAL_BLA_W_RADL
Definition bitstream_common.hpp:146
@ NAL_RSV_ACL_N12
Definition bitstream_common.hpp:141
@ NAL_AAPS
Definition bitstream_common.hpp:176
@ NAL_GIDR_W_RADL
Definition bitstream_common.hpp:153
@ NAL_AFPS
Definition bitstream_common.hpp:166
@ NAL_RSV_ACL_34
Definition bitstream_common.hpp:163
@ NAL_TSA_R
Definition bitstream_common.hpp:132
@ NAL_UNSPEC_53
Definition bitstream_common.hpp:182
@ NAL_RSV_ACL_30
Definition bitstream_common.hpp:159
@ NAL_STSA_N
Definition bitstream_common.hpp:133
@ NAL_UNSPEC_61
Definition bitstream_common.hpp:190
@ NAL_SUFFIX_ESEI
Definition bitstream_common.hpp:175
@ NAL_EOS
Definition bitstream_common.hpp:169
@ NAL_IDR_W_RADL
Definition bitstream_common.hpp:151
@ NAL_GBLA_N_LP
Definition bitstream_common.hpp:150
@ NAL_UNSPEC_55
Definition bitstream_common.hpp:184
@ NAL_RSV_ACL_N14
Definition bitstream_common.hpp:142
@ NAL_BLA_N_LP
Definition bitstream_common.hpp:147
@ NAL_RSV_NACL_48
Definition bitstream_common.hpp:177
@ NAL_UNSPEC_54
Definition bitstream_common.hpp:183
@ NAL_RSV_IRAP_ACL_28
Definition bitstream_common.hpp:157
@ NAL_V3C_AUD
Definition bitstream_common.hpp:168
@ NAL_PREFIX_NSEI
Definition bitstream_common.hpp:172
@ NAL_TRAIL_N
Definition bitstream_common.hpp:129
@ NAL_PREFIX_ESEI
Definition bitstream_common.hpp:174
@ NAL_EOB
Definition bitstream_common.hpp:170
@ NAL_GBLA_W_RADL
Definition bitstream_common.hpp:149
@ NAL_GCRA
Definition bitstream_common.hpp:156
@ NAL_RSV_ACL_R13
Definition bitstream_common.hpp:143
@ NAL_RSV_NACL_50
Definition bitstream_common.hpp:179
@ NAL_SUFFIX_NSEI
Definition bitstream_common.hpp:173
@ NAL_CRA
Definition bitstream_common.hpp:155
@ NAL_SKIP_R
Definition bitstream_common.hpp:140
@ NAL_RSV_ACL_33
Definition bitstream_common.hpp:162
@ NAL_RADL_R
Definition bitstream_common.hpp:136
@ NAL_RSV_ACL_35
Definition bitstream_common.hpp:164
@ NAL_UNSPEC_56
Definition bitstream_common.hpp:185
@ NAL_RSV_NACL_52
Definition bitstream_common.hpp:181
@ NAL_RADL_N
Definition bitstream_common.hpp:135
@ NAL_RSV_ACL_R15
Definition bitstream_common.hpp:144
@ NAL_GIDR_N_LP
Definition bitstream_common.hpp:154
@ NAL_UNSPEC_63
Definition bitstream_common.hpp:192
@ NAL_STSA_R
Definition bitstream_common.hpp:134
@ NAL_IDR_N_LP
Definition bitstream_common.hpp:152
@ NAL_TSA_N
Definition bitstream_common.hpp:131
@ NAL_BLA_W_LP
Definition bitstream_common.hpp:145
@ NAL_RSV_NACL_49
Definition bitstream_common.hpp:178
@ NAL_RSV_IRAP_ACL_29
Definition bitstream_common.hpp:158
@ NAL_GBLA_W_LP
Definition bitstream_common.hpp:148
@ NAL_RASL_N
Definition bitstream_common.hpp:137
@ NAL_RSV_ACL_31
Definition bitstream_common.hpp:160
@ NAL_RSV_NACL_51
Definition bitstream_common.hpp:180
@ NAL_UNSPEC_62
Definition bitstream_common.hpp:191
@ NAL_UNSPEC_59
Definition bitstream_common.hpp:188
@ NAL_SKIP_N
Definition bitstream_common.hpp:139
@ NAL_RSV_ACL_32
Definition bitstream_common.hpp:161
@ NAL_AUD
Definition bitstream_common.hpp:167
ATDU_PATCH_MODE_I_TILE
Definition bitstream_common.hpp:84
@ I_EOM
Definition bitstream_common.hpp:87
@ I_RESERVED_12
Definition bitstream_common.hpp:97
@ I_RESERVED_4
Definition bitstream_common.hpp:89
@ I_RESERVED_3
Definition bitstream_common.hpp:88
@ I_RESERVED_7
Definition bitstream_common.hpp:92
@ I_RESERVED_5
Definition bitstream_common.hpp:90
@ I_INTRA
Definition bitstream_common.hpp:85
@ I_RAW
Definition bitstream_common.hpp:86
@ I_RESERVED_11
Definition bitstream_common.hpp:96
@ I_RESERVED_6
Definition bitstream_common.hpp:91
@ I_RESERVED_9
Definition bitstream_common.hpp:94
@ I_RESERVED_13
Definition bitstream_common.hpp:98
@ I_END
Definition bitstream_common.hpp:99
@ I_RESERVED_10
Definition bitstream_common.hpp:95
@ I_RESERVED_8
Definition bitstream_common.hpp:93
V3C_UNIT_TYPE
Definition bitstream_common.hpp:120
@ V3C_AVD
Definition bitstream_common.hpp:125
@ V3C_VPS
Definition bitstream_common.hpp:121
@ V3C_AD
Definition bitstream_common.hpp:122
@ V3C_GVD
Definition bitstream_common.hpp:124
@ V3C_OVD
Definition bitstream_common.hpp:123