uvgVPCCenc 1.1.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
atlas_context.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 * This file is part of uvgVPCCenc V-PCC encoder.
3 *
4 * Copyright (c) 2024-present, 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
36
37#include "atlas_frame.hpp"
38#include "bitstream_common.hpp"
39#include "bitstream_util.hpp"
40#include "utils/parameters.hpp"
41#include "uvgvpcc/uvgvpcc.hpp"
42
43/* Atlas context is used to hold the atlas data (inside V3C_AD unit) of a single GOF */
45 public:
46 atlas_context() : asps_(), afps_(), atlas_data_(), gof_id_(), atlas_sub_size_(0), ad_nal_sizes_({}), ad_nal_precision_(0) {};
47
48 /* Fill data structures with encoded data from gofUVG and sequence parameters from paramUVG */
49 void initialize_atlas_context(const std::shared_ptr<uvgvpcc_enc::GOF>& gofUVG, const uvgvpcc_enc::Parameters& paramUVG);
50
51 /* Write the atlas sub-bitstream */
53
54 /* Write ASPS and AFPS nal units */
56 /* Write an atlas NAL unit at index */
57 void write_atlas_nal(bitstream_t* stream, size_t index);
58
59 /* Write an atlas NAL unit at index */
60 void write_atlas_eob(bitstream_t* stream);
61
62 // -------------- Getters - data structures --------------
63 std::vector<atlas_tile_layer_rbsp>& get_atlases() { return atlas_data_; };
65 atlas_frame_parameter_set& get_afps() { return afps_; };
66
67 // -------------- Getters - helper variables --------------
68 size_t get_gof_id() { return gof_id_; };
69 size_t get_atlas_sub_size() { return atlas_sub_size_; };
70 std::vector<size_t> get_ad_nal_sizes() { return ad_nal_sizes_; };
71 size_t get_ad_nal_precision() { return ad_nal_precision_; };
72
73 private:
74 /* Calculate sizes of
75 atlas sub-bitstream = atlas_sub_size_
76 atlas NAL units = ad_nal_sizes_
77 atlas NAL unit precision = ad_nal_precision_ */
78 void calculate_atlas_size_values();
79
80 // -------------- Functions to fill data structure values --------------
81 static atlas_sequence_parameter_set create_atlas_sequence_parameter_set(const std::shared_ptr<uvgvpcc_enc::GOF>& gofUVG,
82 const uvgvpcc_enc::Parameters& paramUVG);
83 atlas_frame_parameter_set create_atlas_frame_parameter_set();
84 atlas_frame_tile_information create_atlas_frame_tile_information() const;
85 atlas_tile_header create_atlas_tile_header(size_t frameIndex, size_t tileIndex, const uvgvpcc_enc::Parameters& paramUVG) const;
86 atlas_tile_data_unit create_atlas_tile_data_unit(const uvgvpcc_enc::Parameters& paramUVG,
87 const std::shared_ptr<uvgvpcc_enc::Frame>& frameUVG, atlas_tile_header& ath) const;
88 atlas_tile_layer_rbsp create_atlas_tile_layer_rbsp(size_t frameIndex, size_t tileIndex, const uvgvpcc_enc::Parameters& paramUVG,
89 const std::shared_ptr<uvgvpcc_enc::Frame>& frameUVG);
90
91 // -------------- Functions to write data structures to bitstream --------------
92 static void write_nal_hdr(bitstream_t* stream, const uint8_t nal_type, const uint8_t nal_layer_id, const uint8_t nal_temporal_id_plus1);
93 void write_atlas_seq_parameter_set(bitstream_t* stream);
94 static void write_atlas_adaption_parameter_set(bitstream_t* stream);
95 void write_atlas_frame_parameter_set(bitstream_t* stream) const;
96 void write_atlas_tile_header(bitstream_t* stream, NAL_UNIT_TYPE nalu_t, const atlas_tile_header& ath) const;
97 void write_atlas_tile_data_unit(bitstream_t* stream, const atlas_tile_data_unit& atdu, const atlas_tile_header& ath);
98 void write_atlas_tile_layer_rbsp(bitstream_t* stream, NAL_UNIT_TYPE nalu_t, const atlas_tile_layer_rbsp& rbsp);
99 void write_access_unit_delimiter(bitstream_t* stream);
100
101 void write_patch_information_data(bitstream_t* stream, const patch_information_data& pid, const atlas_tile_header& ath);
102 void write_patch_data_unit(bitstream_t* stream, const patch_data_unit& pdu, const atlas_tile_header& ath) const;
103
104 /* -------------- Atlas data structures -------------- */
107 std::vector<atlas_tile_layer_rbsp> atlas_data_;
108
109 /* -------------- Helper variables -------------- */
110 size_t gof_id_;
111 size_t atlas_sub_size_;
112 std::vector<size_t> ad_nal_sizes_;
113 size_t ad_nal_precision_;
114};
NAL_UNIT_TYPE
Definition bitstream_common.hpp:128
Definition atlas_context.hpp:44
size_t get_gof_id()
Definition atlas_context.hpp:68
void write_atlas_nal(bitstream_t *stream, size_t index)
Definition atlas_context.cpp:738
void write_atlas_sub_bitstream(bitstream_t *stream)
Definition atlas_context.cpp:696
size_t get_atlas_sub_size()
Definition atlas_context.hpp:69
atlas_sequence_parameter_set & get_asps()
Definition atlas_context.hpp:64
void write_atlas_eob(bitstream_t *stream)
Definition atlas_context.cpp:746
atlas_context()
Definition atlas_context.hpp:46
atlas_frame_parameter_set & get_afps()
Definition atlas_context.hpp:65
std::vector< size_t > get_ad_nal_sizes()
Definition atlas_context.hpp:70
void write_atlas_parameter_set_nals(bitstream_t *stream)
Definition atlas_context.cpp:724
std::vector< atlas_tile_layer_rbsp > & get_atlases()
Definition atlas_context.hpp:63
void initialize_atlas_context(const std::shared_ptr< uvgvpcc_enc::GOF > &gofUVG, const uvgvpcc_enc::Parameters &paramUVG)
Definition atlas_context.cpp:352
size_t get_ad_nal_precision()
Definition atlas_context.hpp:71
Definition atlas_frame.hpp:141
Definition atlas_frame.hpp:119
Definition atlas_frame.hpp:156
Definition atlas_frame.hpp:109
Definition atlas_frame.hpp:48
Definition atlas_frame.hpp:114
Definition bitstream_util.hpp:57
Definition atlas_frame.hpp:73
Definition atlas_frame.hpp:96
Definition parameters.hpp:48