uvgVPCCenc 1.0.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
gof.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#include <memory>
35#include <vector>
36
37#include "atlas_context.hpp"
38#include "uvgvpcc/uvgvpcc.hpp"
40#include "vps.hpp"
41
42/* Statistics related to a V3C Group Of Frames (GOF) */
43class v3c_gof {
44 public:
45 v3c_gof(size_t id) {
46 v3c_unit_precision_ = 0;
47 gof_id_ = id;
48 n_frames_ = 0;
49 };
50
51 // Used for LD mode
52 void set_n_frames(size_t value) { n_frames_ = value; }
53
54 // Set the V3C unit precision. If smaller than before, do nothing
55 void set_v3c_unit_precision(uint32_t new_precision) {
56 if (new_precision > v3c_unit_precision_) {
57 v3c_unit_precision_ = new_precision;
58 }
59 };
60
61 /* Add new data to the most recent GOF */
62 void add_v3c_vps(std::unique_ptr<vps> data) { v3c_vps_sub_ = std::move(data); };
63 void add_v3c_atlas_context(std::unique_ptr<atlas_context> data) { v3c_ad_unit_ = std::move(data); };
64 void add_v3c_ovd_sub(std::unique_ptr<std::vector<uint8_t>> data) { v3c_ovd_sub_ = std::move(data); };
65 void add_v3c_gvd_sub(std::unique_ptr<std::vector<uint8_t>> data) { v3c_gvd_sub_ = std::move(data); };
66 void add_v3c_avd_sub(std::unique_ptr<std::vector<uint8_t>> data) { v3c_avd_sub_ = std::move(data); };
67
68 /* Write the latest GOF to a single V3C unit stream buffer, with parsing information given separately */
70
71 /* Write the latest GOF in Low Delay (LD) mode to a single V3C unit stream buffer, with parsing information given separately */
72 void write_v3c_ld_chunk(const std::vector<nal_info> &ovd_nals, const std::vector<nal_info> &gvd_nals,
73 const std::vector<nal_info> &avd_nals, uvgvpcc_enc::API::v3c_unit_stream *out, bool double_layer);
74
75 private:
76 size_t gof_id_;
77 size_t v3c_unit_precision_;
78 size_t n_frames_; // N of frames in GOF, used for low-delay mode
79 std::unique_ptr<vps> v3c_vps_sub_; // no V3C header
80 std::unique_ptr<atlas_context> v3c_ad_unit_; // incl. V3C header
81 std::unique_ptr<std::vector<uint8_t>> v3c_ovd_sub_; // no V3C header
82 std::unique_ptr<std::vector<uint8_t>> v3c_gvd_sub_; // no V3C header
83 std::unique_ptr<std::vector<uint8_t>> v3c_avd_sub_; // no V3C header
84};
Definition gof.hpp:43
void write_v3c_ld_chunk(const std::vector< nal_info > &ovd_nals, const std::vector< nal_info > &gvd_nals, const std::vector< nal_info > &avd_nals, uvgvpcc_enc::API::v3c_unit_stream *out, bool double_layer)
Definition gof.cpp:139
void add_v3c_avd_sub(std::unique_ptr< std::vector< uint8_t > > data)
Definition gof.hpp:66
void set_n_frames(size_t value)
Definition gof.hpp:52
void add_v3c_ovd_sub(std::unique_ptr< std::vector< uint8_t > > data)
Definition gof.hpp:64
void add_v3c_atlas_context(std::unique_ptr< atlas_context > data)
Definition gof.hpp:63
v3c_gof(size_t id)
Definition gof.hpp:45
void write_v3c_chunk(uvgvpcc_enc::API::v3c_unit_stream *out)
Definition gof.cpp:51
void add_v3c_gvd_sub(std::unique_ptr< std::vector< uint8_t > > data)
Definition gof.hpp:65
void add_v3c_vps(std::unique_ptr< vps > data)
Definition gof.hpp:62
void set_v3c_unit_precision(uint32_t new_precision)
Definition gof.hpp:55
Definition uvgvpcc.hpp:265