uvgVPCCenc 1.1.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
utils.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
34
35
36#pragma once
37
38#include <array>
39#include <cstdint>
40#include <limits>
41#include <sstream>
42#include <iomanip>
43
44namespace uvgvpcc_enc {
45
46using typeGeometryInput = uint16_t;
47
48const typeGeometryInput g_infiniteDepth = (std::numeric_limits<typeGeometryInput>::max)(); // TODO(lf)be sure it is well sync with type geo
49const size_t g_infinitenumber = (std::numeric_limits<size_t>::max)();
50const size_t g_valueNotSet = (std::numeric_limits<size_t>::max)();
51
52constexpr size_t INVALID_PATCH_INDEX = std::numeric_limits<size_t>::max();
53constexpr size_t PPI_NON_ASSIGNED = std::numeric_limits<size_t>::max();
54constexpr size_t UNDEFINED_PARENT_PPI = std::numeric_limits<size_t>::max() - 1; //TODO(lf) temp
55
56// Projection Plan Index, 0-5 -> one of the six bounding box plan. 6+ -> used for slicing ppi attribution
58
59template <typename T>
60class Vector3 : public std::array<T, 3> {
61 public:
62 Vector3() : std::array<T, 3>() {}
63 Vector3(T x, T y, T z) : std::array<T, 3>({x, y, z}) {}
64 Vector3(std::array<T, 3>& arr) : std::array<T, 3>(arr) {}
65 Vector3(std::array<T, 3>&& arr) : std::array<T, 3>(std::move(arr)) {}
66 Vector3(const std::array<T, 3>& arr) {
67 std::copy(arr.begin(), arr.end(), this->begin());
68 }
69
70 template <typename U>
71 Vector3<T> operator+(const Vector3<U>& other) const {
72 return {(*this)[0] + other[0], (*this)[1] + other[1], (*this)[2] + other[2]};
73 }
74
75 template <typename U>
76 Vector3<T> operator-(const Vector3<U>& other) const {
77 return {(*this)[0] - other[0], (*this)[1] - other[1], (*this)[2] - other[2]};
78 }
79
81 return {(*this)[0] - other[0], (*this)[1] - other[1], (*this)[2] - other[2]};
82 }
83
84 Vector3<T> operator-() const { return {-(*this)[0], -(*this)[1], -(*this)[2]}; }
85
86 template <typename U>
88 (*this)[0] += other[0];
89 (*this)[1] += other[1];
90 (*this)[2] += other[2];
91 return *this;
92 }
93
94 template <typename U>
95 Vector3<T>& operator/=(const U& val) {
96 (*this)[0] /= val;
97 (*this)[1] /= val;
98 (*this)[2] /= val;
99 return *this;
100 }
101};
102
103inline std::string zeroPad(size_t value, size_t width) {
104 std::ostringstream oss;
105 oss << std::setw(width) << std::setfill('0') << value;
106 return oss.str();
107};
108
109// Round the given number to the nearest bigger multiple.
110// equivalent to : return = ceil(numberF/multipleF) * multiple;
111// Examples : roundUp(7,8) = 8; roundUp(17,8) = 24;
112inline size_t roundUp(const size_t& number, const size_t& multiple) { return (number + multiple - 1) & -multiple;}
113
114} // uvgvpcc_enc namespace
Definition utils.hpp:60
Vector3(std::array< T, 3 > &arr)
Definition utils.hpp:64
Vector3< double > operator-(const Vector3< double > &other) const
Definition utils.hpp:80
Vector3(T x, T y, T z)
Definition utils.hpp:63
Vector3(const std::array< T, 3 > &arr)
Definition utils.hpp:66
Vector3< T > operator-(const Vector3< U > &other) const
Definition utils.hpp:76
Vector3< T > & operator+=(const Vector3< U > &other)
Definition utils.hpp:87
Vector3()
Definition utils.hpp:62
Vector3(std::array< T, 3 > &&arr)
Definition utils.hpp:65
Vector3< T > & operator/=(const U &val)
Definition utils.hpp:95
Vector3< T > operator-() const
Definition utils.hpp:84
Vector3< T > operator+(const Vector3< U > &other) const
Definition utils.hpp:71
Definition jobManagement.cpp:168
Definition log.hpp:48
PPI
Definition utils.hpp:57
std::string zeroPad(size_t value, size_t width)
Definition utils.hpp:103
size_t roundUp(const size_t &number, const size_t &multiple)
Definition utils.hpp:112
constexpr size_t INVALID_PATCH_INDEX
Definition utils.hpp:52
constexpr size_t PPI_NON_ASSIGNED
Definition utils.hpp:53
constexpr size_t UNDEFINED_PARENT_PPI
Definition utils.hpp:54
uint16_t typeGeometryInput
Definition utils.hpp:46
const size_t g_infinitenumber
Definition utils.hpp:49
const typeGeometryInput g_infiniteDepth
Definition utils.hpp:48
const size_t g_valueNotSet
Definition utils.hpp:50
int y
Definition slicingComputation.cpp:171
int x
Definition slicingComputation.cpp:171