uvgVPCCenc 1.0.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
patchPacking.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
34
35
36#pragma once
37
38#include <span>
39
40#include "uvgvpcc/uvgvpcc.hpp"
41
43 PATCH_ORIENTATION_DEFAULT = 0, // 0: default
44 PATCH_ORIENTATION_SWAP = 1, // 1: swap
45 PATCH_ORIENTATION_ROT90 = 2, // 2: rotation 90
46 PATCH_ORIENTATION_ROT180 = 3, // 3: rotation 180
47 PATCH_ORIENTATION_ROT270 = 4, // 4: rotation 270
48 PATCH_ORIENTATION_MIRROR = 5, // 5: mirror
49 PATCH_ORIENTATION_MROT90 = 6, // 6: mirror + rotation 90
50 PATCH_ORIENTATION_MROT180 = 7, // 7: mirror + rotation 180
51 PATCH_ORIENTATION_MROT270 = 8 // 8: similar to SWAP, not used switched SWAP with ROT90 positions
52};
53
54const std::vector<int> g_orientationHorizontal = {
55 PATCH_ORIENTATION_SWAP, // Horizontal orientation swap
56 PATCH_ORIENTATION_DEFAULT, // Horizontal orientation default
57};
58const std::vector<int> g_orientationVertical = {
59 PATCH_ORIENTATION_DEFAULT, // Vertical orientation default
60 PATCH_ORIENTATION_SWAP, // Vertical orientation swap
61};
62
64 public:
66 static void frameIntraPatchPacking(const std::shared_ptr<uvgvpcc_enc::Frame>& frame, std::span<uvgvpcc_enc::Patch>* patchListSpan);
67 static void frameInterPatchPacking(const std::vector<uvgvpcc_enc::Patch>& unionPatches, const std::shared_ptr<uvgvpcc_enc::Frame>& frame,
68 std::span<uvgvpcc_enc::Patch>* matchedPatchList);
69
70 static void allocateDefaultOccupancyMap(const std::shared_ptr<uvgvpcc_enc::Frame>& frame);
71 static void gofPatchPacking(const std::shared_ptr<uvgvpcc_enc::GOF>& gof);
72
73 private:
74
75
76 static bool findPatchLocation(const size_t& occupancyMapHeight, const size_t& occupancyMapWidth,
77 size_t& maxPatchHeightInOccBlk, const std::vector<uint8_t>& occupancyMap,
78 uvgvpcc_enc::Patch& patch);
79 static bool checkLocation(const size_t& occupancyMapHeight, const size_t& occupancyMapWidth,
80 const std::vector<uint8_t>& occupancyMap, const size_t& posOMu, const size_t& posOMv,
81 const size_t& patchWidth, const size_t& patchHeight, size_t& maxPatchHeightInOccBlk,
82 uvgvpcc_enc::Patch& patch);
83
84 static bool checkFitPatch(const size_t& patchPosX, const size_t& patchPosY, const size_t& patchWidth,
85 const size_t& patchHeight, const size_t& occupancyMapWidth, const size_t& occupancyMapHeight,
86 const std::vector<uint8_t>& occupancyMap);
87
88 static void patchMatchingBetweenTwoFrames(const std::shared_ptr<uvgvpcc_enc::Frame>& currentFrame,
89 const std::shared_ptr<uvgvpcc_enc::Frame>& previousFrame);
90 static float computeIoU(const uvgvpcc_enc::Patch& currentPatch, const uvgvpcc_enc::Patch& previousPatch);
91};
Definition patchPacking.hpp:63
static void frameInterPatchPacking(const std::vector< uvgvpcc_enc::Patch > &unionPatches, const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::span< uvgvpcc_enc::Patch > *matchedPatchList)
Definition patchPacking.cpp:254
static void gofPatchPacking(const std::shared_ptr< uvgvpcc_enc::GOF > &gof)
Definition patchPacking.cpp:363
static void allocateDefaultOccupancyMap(const std::shared_ptr< uvgvpcc_enc::Frame > &frame)
Definition patchPacking.cpp:191
static void frameIntraPatchPacking(const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::span< uvgvpcc_enc::Patch > *patchListSpan)
Definition patchPacking.cpp:197
const std::vector< int > g_orientationHorizontal
Definition patchPacking.hpp:54
const std::vector< int > g_orientationVertical
Definition patchPacking.hpp:58
PCCaxisSwap
Definition patchPacking.hpp:42
@ PATCH_ORIENTATION_ROT270
Definition patchPacking.hpp:47
@ PATCH_ORIENTATION_ROT90
Definition patchPacking.hpp:45
@ PATCH_ORIENTATION_SWAP
Definition patchPacking.hpp:44
@ PATCH_ORIENTATION_MROT270
Definition patchPacking.hpp:51
@ PATCH_ORIENTATION_MROT90
Definition patchPacking.hpp:49
@ PATCH_ORIENTATION_MROT180
Definition patchPacking.hpp:50
@ PATCH_ORIENTATION_DEFAULT
Definition patchPacking.hpp:43
@ PATCH_ORIENTATION_ROT180
Definition patchPacking.hpp:46
@ PATCH_ORIENTATION_MIRROR
Definition patchPacking.hpp:48
Definition uvgvpcc.hpp:54