uvgVPCCenc 1.0.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, 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 "uvgvpcc/uvgvpcc.hpp"
41
42/* Atlas context is used to hold the atlas data (inside V3C_AD unit) of a single GOF */
44 public:
45 atlas_context() : asps_(), afps_(), atlas_data_(), gof_id_(), atlas_sub_size_(0), ad_nal_sizes_({}), ad_nal_precision_(0) {};
46
47 /* Fill data structures with encoded data from gofUVG and sequence parameters from paramUVG */
48 void initialize_atlas_context(const std::shared_ptr<uvgvpcc_enc::GOF>& gofUVG, const uvgvpcc_enc::Parameters& paramUVG);
49
50 /* Write the atlas sub-bitstream */
52
53 /* Write ASPS and AFPS nal units */
55 /* Write an atlas NAL unit at index */
56 void write_atlas_nal(bitstream_t* stream, size_t index);
57
58 /* Write an atlas NAL unit at index */
59 void write_atlas_eob(bitstream_t* stream);
60
61 // -------------- Getters - data structures --------------
62 std::vector<atlas_tile_layer_rbsp>& get_atlases() { return atlas_data_; };
64 atlas_frame_parameter_set& get_afps() { return afps_; };
65
66 // -------------- Getters - helper variables --------------
67 size_t get_gof_id() { return gof_id_; };
68 size_t get_atlas_sub_size() { return atlas_sub_size_; };
69 std::vector<size_t> get_ad_nal_sizes() { return ad_nal_sizes_; };
70 size_t get_ad_nal_precision() { return ad_nal_precision_; };
71
72 private:
73 /* Calculate sizes of
74 atlas sub-bitstream = atlas_sub_size_
75 atlas NAL units = ad_nal_sizes_
76 atlas NAL unit precision = ad_nal_precision_ */
77 void calculate_atlas_size_values();
78
79 // -------------- Functions to fill data structure values --------------
80 static atlas_sequence_parameter_set create_atlas_sequence_parameter_set(const std::shared_ptr<uvgvpcc_enc::GOF>& gofUVG,
81 const uvgvpcc_enc::Parameters& paramUVG);
82 atlas_frame_parameter_set create_atlas_frame_parameter_set();
83 atlas_frame_tile_information create_atlas_frame_tile_information() const;
84 atlas_tile_header create_atlas_tile_header(size_t frameIndex, size_t tileIndex, const uvgvpcc_enc::Parameters& paramUVG) const;
85 atlas_tile_data_unit create_atlas_tile_data_unit(const uvgvpcc_enc::Parameters& paramUVG, const uvgvpcc_enc::Frame& frameUVG,
86 atlas_tile_header& ath) const;
87 atlas_tile_layer_rbsp create_atlas_tile_layer_rbsp(size_t frameIndex, size_t tileIndex, const uvgvpcc_enc::Parameters& paramUVG,
88 const uvgvpcc_enc::Frame& frameUVG);
89
90 // -------------- Functions to write data structures to bitstream --------------
91 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);
92 void write_atlas_seq_parameter_set(bitstream_t* stream);
93 static void write_atlas_adaption_parameter_set(bitstream_t* stream);
94 void write_atlas_frame_parameter_set(bitstream_t* stream) const;
95 void write_atlas_tile_header(bitstream_t* stream, NAL_UNIT_TYPE nalu_t, const atlas_tile_header& ath) const;
96 void write_atlas_tile_data_unit(bitstream_t* stream, const atlas_tile_data_unit& atdu, const atlas_tile_header& ath);
97 void write_atlas_tile_layer_rbsp(bitstream_t* stream, NAL_UNIT_TYPE nalu_t, const atlas_tile_layer_rbsp& rbsp);
98 void write_access_unit_delimiter(bitstream_t* stream);
99
100 void write_patch_information_data(bitstream_t* stream, const patch_information_data& pid, const atlas_tile_header& ath);
101 void write_patch_data_unit(bitstream_t* stream, const patch_data_unit& pdu, const atlas_tile_header& ath) const;
102
103 /* -------------- Atlas data structures -------------- */
106 std::vector<atlas_tile_layer_rbsp> atlas_data_;
107
108 /* -------------- Helper variables -------------- */
109 size_t gof_id_;
110 size_t atlas_sub_size_;
111 std::vector<size_t> ad_nal_sizes_;
112 size_t ad_nal_precision_;
113};
NAL_UNIT_TYPE
Definition bitstream_common.hpp:128
Definition atlas_context.hpp:43
size_t get_gof_id()
Definition atlas_context.hpp:67
void write_atlas_nal(bitstream_t *stream, size_t index)
Definition atlas_context.cpp:733
void write_atlas_sub_bitstream(bitstream_t *stream)
Definition atlas_context.cpp:691
size_t get_atlas_sub_size()
Definition atlas_context.hpp:68
atlas_sequence_parameter_set & get_asps()
Definition atlas_context.hpp:63
void write_atlas_eob(bitstream_t *stream)
Definition atlas_context.cpp:741
atlas_context()
Definition atlas_context.hpp:45
atlas_frame_parameter_set & get_afps()
Definition atlas_context.hpp:64
std::vector< size_t > get_ad_nal_sizes()
Definition atlas_context.hpp:69
void write_atlas_parameter_set_nals(bitstream_t *stream)
Definition atlas_context.cpp:719
std::vector< atlas_tile_layer_rbsp > & get_atlases()
Definition atlas_context.hpp:62
void initialize_atlas_context(const std::shared_ptr< uvgvpcc_enc::GOF > &gofUVG, const uvgvpcc_enc::Parameters &paramUVG)
Definition atlas_context.cpp:347
size_t get_ad_nal_precision()
Definition atlas_context.hpp:70
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 uvgvpcc.hpp:167
Definition parameters.hpp:48