uvgVPCCenc 1.2.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-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 (subject to the limitations in the disclaimer below) 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 Tampere University, 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 * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
32 ****************************************************************************/
33
35
36
37#pragma once
38
39#include <span>
40
41#include "utils/types.hpp"
42#include "utils/types.hpp"
43
45 PATCH_ORIENTATION_DEFAULT = 0, // 0: default
46 PATCH_ORIENTATION_SWAP = 1, // 1: swap
47 PATCH_ORIENTATION_ROT90 = 2, // 2: rotation 90
48 PATCH_ORIENTATION_ROT180 = 3, // 3: rotation 180
49 PATCH_ORIENTATION_ROT270 = 4, // 4: rotation 270
50 PATCH_ORIENTATION_MIRROR = 5, // 5: mirror
51 PATCH_ORIENTATION_MROT90 = 6, // 6: mirror + rotation 90
52 PATCH_ORIENTATION_MROT180 = 7, // 7: mirror + rotation 180
53 PATCH_ORIENTATION_MROT270 = 8 // 8: similar to SWAP, not used switched SWAP with ROT90 positions
54};
55
56const std::vector<int> g_orientationHorizontal = {
57 PATCH_ORIENTATION_SWAP, // Horizontal orientation swap
58 PATCH_ORIENTATION_DEFAULT, // Horizontal orientation default
59};
60const std::vector<int> g_orientationVertical = {
61 PATCH_ORIENTATION_DEFAULT, // Vertical orientation default
62 PATCH_ORIENTATION_SWAP, // Vertical orientation swap
63};
64
66 public:
68 static void frameIntraPatchPacking(const std::shared_ptr<uvgvpcc_enc::FrameContext>& frame, std::span<uvgvpcc_enc::Patch>* patchListSpan);
69 static void frameInterPatchPacking(const std::vector<uvgvpcc_enc::Patch>& unionPatches, const std::shared_ptr<uvgvpcc_enc::FrameContext>& frame,
70 std::span<uvgvpcc_enc::Patch>* matchedPatchList);
71
72 static void gofPatchPacking(const std::shared_ptr<uvgvpcc_enc::GOF>& gof);
73
74 private:
75
76 static bool findPatchLocation(const size_t& mapHeight, size_t& maxPatchHeight,
77 uvgvpcc_enc::Patch& patch, const std::vector<uint8_t>& frameOccupancyMap);
78 static bool checkLocation(const size_t& mapHeight, const size_t& posOMu, const size_t& posOMv,
79 const size_t& patchWidth, const size_t& patchHeight, size_t& maxPatchHeight,
80 uvgvpcc_enc::Patch& patch, const std::vector<uint8_t>& frameOccupancyMap);
81
82 static bool checkFitPatch(const size_t& patchPosX, const size_t& patchPosY, const size_t& patchWidth,
83 const size_t& patchHeight, const size_t& mapHeight, const std::vector<uint8_t>& frameOccupancyMap);
84
85 static void patchMatchingBetweenTwoFrames(const std::shared_ptr<uvgvpcc_enc::FrameContext>& currentFrame,
86 const std::shared_ptr<uvgvpcc_enc::FrameContext>& previousFrame);
87 static float computeIoU(const uvgvpcc_enc::Patch& currentPatch, const uvgvpcc_enc::Patch& previousPatch);
88};
Definition patchPacking.hpp:65
static void gofPatchPacking(const std::shared_ptr< uvgvpcc_enc::GOF > &gof)
Definition patchPacking.cpp:427
static void frameInterPatchPacking(const std::vector< uvgvpcc_enc::Patch > &unionPatches, const std::shared_ptr< uvgvpcc_enc::FrameContext > &frame, std::span< uvgvpcc_enc::Patch > *matchedPatchList)
Definition patchPacking.cpp:295
static void frameIntraPatchPacking(const std::shared_ptr< uvgvpcc_enc::FrameContext > &frame, std::span< uvgvpcc_enc::Patch > *patchListSpan)
Definition patchPacking.cpp:199
const std::vector< int > g_orientationHorizontal
Definition patchPacking.hpp:56
const std::vector< int > g_orientationVertical
Definition patchPacking.hpp:60
PCCaxisSwap
Definition patchPacking.hpp:44
@ PATCH_ORIENTATION_ROT270
Definition patchPacking.hpp:49
@ PATCH_ORIENTATION_ROT90
Definition patchPacking.hpp:47
@ PATCH_ORIENTATION_SWAP
Definition patchPacking.hpp:46
@ PATCH_ORIENTATION_MROT270
Definition patchPacking.hpp:53
@ PATCH_ORIENTATION_MROT90
Definition patchPacking.hpp:51
@ PATCH_ORIENTATION_MROT180
Definition patchPacking.hpp:52
@ PATCH_ORIENTATION_DEFAULT
Definition patchPacking.hpp:45
@ PATCH_ORIENTATION_ROT180
Definition patchPacking.hpp:48
@ PATCH_ORIENTATION_MIRROR
Definition patchPacking.hpp:50
Definition types.hpp:60