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();
53
54
55template <typename T>
56class Vector3 : public std::array<T, 3> {
57 public:
58 Vector3() : std::array<T, 3>() {}
59 Vector3(T x, T y, T z) : std::array<T, 3>({x, y, z}) {}
60 Vector3(std::array<T, 3>& arr) : std::array<T, 3>(arr) {}
61 Vector3(std::array<T, 3>&& arr) : std::array<T, 3>(std::move(arr)) {}
62 Vector3(const std::array<T, 3>& arr) {
63 std::copy(arr.begin(), arr.end(), this->begin());
64 }
65
66 template <typename U>
67 Vector3<T> operator+(const Vector3<U>& other) const {
68 return {(*this)[0] + other[0], (*this)[1] + other[1], (*this)[2] + other[2]};
69 }
70
71 template <typename U>
72 Vector3<T> operator-(const Vector3<U>& other) const {
73 return {(*this)[0] - other[0], (*this)[1] - other[1], (*this)[2] - other[2]};
74 }
75
77 return {(*this)[0] - other[0], (*this)[1] - other[1], (*this)[2] - other[2]};
78 }
79
80 Vector3<T> operator-() const { return {-(*this)[0], -(*this)[1], -(*this)[2]}; }
81
82 template <typename U>
84 (*this)[0] += other[0];
85 (*this)[1] += other[1];
86 (*this)[2] += other[2];
87 return *this;
88 }
89
90 template <typename U>
91 Vector3<T>& operator/=(const U& val) {
92 (*this)[0] /= val;
93 (*this)[1] /= val;
94 (*this)[2] /= val;
95 return *this;
96 }
97};
98
99inline std::string zeroPad(size_t value, size_t width) {
100 std::ostringstream oss;
101 oss << std::setw(width) << std::setfill('0') << value;
102 return oss.str();
103};
104
105// Round the given number to the nearest bigger multiple.
106// equivalent to : return = ceil(numberF/multipleF) * multiple;
107// Examples : roundUp(7,8) = 8; roundUp(17,8) = 24;
108inline size_t roundUp(const size_t& number, const size_t& multiple) { return (number + multiple - 1) & -multiple;}
109
110} // uvgvpcc_enc namespace
Definition utils.hpp:56
Vector3(std::array< T, 3 > &arr)
Definition utils.hpp:60
Vector3< double > operator-(const Vector3< double > &other) const
Definition utils.hpp:76
Vector3(T x, T y, T z)
Definition utils.hpp:59
Vector3(const std::array< T, 3 > &arr)
Definition utils.hpp:62
Vector3< T > operator-(const Vector3< U > &other) const
Definition utils.hpp:72
Vector3< T > & operator+=(const Vector3< U > &other)
Definition utils.hpp:83
Vector3()
Definition utils.hpp:58
Vector3(std::array< T, 3 > &&arr)
Definition utils.hpp:61
Vector3< T > & operator/=(const U &val)
Definition utils.hpp:91
Vector3< T > operator-() const
Definition utils.hpp:80
Vector3< T > operator+(const Vector3< U > &other) const
Definition utils.hpp:67
Definition jobManagement.cpp:168
Definition log.hpp:48
std::string zeroPad(size_t value, size_t width)
Definition utils.hpp:99
size_t roundUp(const size_t &number, const size_t &multiple)
Definition utils.hpp:108
constexpr size_t INVALID_PATCH_INDEX
Definition utils.hpp:52
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