Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Satoru KUMA
MPEG129-m52280
Commits
64ffa5e2
Commit
64ffa5e2
authored
Jul 23, 2018
by
David Flynn
Browse files
style: reindent using clang-format-6.0
parent
e64eb236
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
tmc3/AttributeDecoder.cpp
View file @
64ffa5e2
...
@@ -52,7 +52,7 @@ struct PCCResidualsDecoder {
...
@@ -52,7 +52,7 @@ struct PCCResidualsDecoder {
PCCResidualsDecoder
()
{
alphabetSize
=
0
;
}
PCCResidualsDecoder
()
{
alphabetSize
=
0
;
}
void
start
(
PCCBitstream
&
bitstream
,
const
uint32_t
alphabetSize
=
64
);
void
start
(
PCCBitstream
&
bitstream
,
const
uint32_t
alphabetSize
=
64
);
void
stop
();
void
stop
();
uint32_t
decode0
();
uint32_t
decode0
();
uint32_t
decode1
();
uint32_t
decode1
();
...
@@ -60,9 +60,10 @@ struct PCCResidualsDecoder {
...
@@ -60,9 +60,10 @@ struct PCCResidualsDecoder {
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
PCCResidualsDecoder
::
start
(
void
PCCBitstream
&
bitstream
,
const
uint32_t
alphabetSize
PCCResidualsDecoder
::
start
(
)
{
PCCBitstream
&
bitstream
,
const
uint32_t
alphabetSize
)
{
this
->
alphabetSize
=
alphabetSize
;
this
->
alphabetSize
=
alphabetSize
;
multiSymbolModelDiff0
.
set_alphabet
(
alphabetSize
+
1
);
multiSymbolModelDiff0
.
set_alphabet
(
alphabetSize
+
1
);
binaryModelDiff0
.
reset
();
binaryModelDiff0
.
reset
();
...
@@ -70,37 +71,40 @@ void PCCResidualsDecoder::start(
...
@@ -70,37 +71,40 @@ void PCCResidualsDecoder::start(
binaryModelDiff1
.
reset
();
binaryModelDiff1
.
reset
();
arithmeticDecoder
.
set_buffer
(
arithmeticDecoder
.
set_buffer
(
static_cast
<
uint32_t
>
(
bitstream
.
capacity
-
bitstream
.
size
),
static_cast
<
uint32_t
>
(
bitstream
.
capacity
-
bitstream
.
size
),
bitstream
.
buffer
+
bitstream
.
size
bitstream
.
buffer
+
bitstream
.
size
);
);
arithmeticDecoder
.
start_decoder
();
arithmeticDecoder
.
start_decoder
();
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
PCCResidualsDecoder
::
stop
()
{
void
PCCResidualsDecoder
::
stop
()
{
arithmeticDecoder
.
stop_decoder
();
arithmeticDecoder
.
stop_decoder
();
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
uint32_t
PCCResidualsDecoder
::
decode0
()
{
uint32_t
PCCResidualsDecoder
::
decode0
()
{
uint32_t
value
=
arithmeticDecoder
.
decode
(
multiSymbolModelDiff0
);
uint32_t
value
=
arithmeticDecoder
.
decode
(
multiSymbolModelDiff0
);
if
(
value
==
alphabetSize
)
{
if
(
value
==
alphabetSize
)
{
value
+=
arithmeticDecoder
.
ExpGolombDecode
(
value
+=
0
,
binaryModel0
,
binaryModelDiff0
arithmeticDecoder
.
ExpGolombDecode
(
0
,
binaryModel0
,
binaryModelDiff0
);
);
}
}
return
value
;
return
value
;
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
uint32_t
PCCResidualsDecoder
::
decode1
()
{
uint32_t
PCCResidualsDecoder
::
decode1
()
{
uint32_t
value
=
arithmeticDecoder
.
decode
(
multiSymbolModelDiff1
);
uint32_t
value
=
arithmeticDecoder
.
decode
(
multiSymbolModelDiff1
);
if
(
value
==
alphabetSize
)
{
if
(
value
==
alphabetSize
)
{
value
+=
arithmeticDecoder
.
ExpGolombDecode
(
value
+=
0
,
binaryModel0
,
binaryModelDiff1
arithmeticDecoder
.
ExpGolombDecode
(
0
,
binaryModel0
,
binaryModelDiff1
);
);
}
}
return
value
;
return
value
;
}
}
...
@@ -108,32 +112,34 @@ uint32_t PCCResidualsDecoder::decode1() {
...
@@ -108,32 +112,34 @@ uint32_t PCCResidualsDecoder::decode1() {
//============================================================================
//============================================================================
// AttributeDecoder Members
// AttributeDecoder Members
void
AttributeDecoder
::
buildPredictors
(
const
PCCPointSet3
&
pointCloud
)
{
void
AttributeDecoder
::
buildPredictors
(
const
PCCPointSet3
&
pointCloud
)
{
std
::
vector
<
uint32_t
>
numberOfPointsPerLOD
;
std
::
vector
<
uint32_t
>
numberOfPointsPerLOD
;
std
::
vector
<
uint32_t
>
indexes
;
std
::
vector
<
uint32_t
>
indexes
;
PCCBuildPredictors
(
PCCBuildPredictors
(
pointCloud
,
numberOfNearestNeighborsInPrediction
,
levelOfDetailCount
,
pointCloud
,
numberOfNearestNeighborsInPrediction
,
levelOfDetailCount
,
dist2
,
predictors
,
numberOfPointsPerLOD
,
indexes
dist2
,
predictors
,
numberOfPointsPerLOD
,
indexes
);
);
for
(
auto
&
predictor
:
predictors
)
{
for
(
auto
&
predictor
:
predictors
)
{
predictor
.
computeWeights
(
numberOfNearestNeighborsInPrediction
);
predictor
.
computeWeights
(
numberOfNearestNeighborsInPrediction
);
}
}
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeHeader
(
void
const
std
::
string
&
attributeName
,
AttributeDecoder
::
decodeHeader
(
PCCBitstream
&
bitstream
const
std
::
string
&
attributeName
,
PCCBitstream
&
bitstream
)
)
{
{
uint8_t
transType
;
uint8_t
transType
;
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
transType
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
transType
,
bitstream
.
size
);
transformType
=
TransformType
(
transType
);
transformType
=
TransformType
(
transType
);
if
(
transformType
==
TransformType
::
kIntegerLift
)
{
if
(
transformType
==
TransformType
::
kIntegerLift
)
{
uint8_t
numberOfNearestNeighborsCount
=
0
;
uint8_t
numberOfNearestNeighborsCount
=
0
;
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
numberOfNearestNeighborsCount
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
numberOfNearestNeighborsCount
,
bitstream
.
size
);
numberOfNearestNeighborsInPrediction
=
numberOfNearestNeighborsCount
;
numberOfNearestNeighborsInPrediction
=
numberOfNearestNeighborsCount
;
uint8_t
lodCount
=
0
;
uint8_t
lodCount
=
0
;
...
@@ -157,19 +163,22 @@ void AttributeDecoder::decodeHeader(
...
@@ -157,19 +163,22 @@ void AttributeDecoder::decodeHeader(
if
(
transformType
==
TransformType
::
kRAHT
)
{
if
(
transformType
==
TransformType
::
kRAHT
)
{
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
depthRaht
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
depthRaht
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint8_t
>
(
bitstream
.
buffer
,
binaryLevelThresholdRaht
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint8_t
>
(
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
quantizationStepRaht
,
bitstream
.
size
);
bitstream
.
buffer
,
binaryLevelThresholdRaht
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
quantizationStepRaht
,
bitstream
.
size
);
}
}
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeReflectances
(
void
PCCBitstream
&
bitstream
,
AttributeDecoder
::
decodeReflectances
(
PCCPointSet3
&
pointCloud
PCCBitstream
&
bitstream
,
PCCPointSet3
&
pointCloud
)
)
{
{
uint32_t
compressedBitstreamSize
=
0
;
uint32_t
compressedBitstreamSize
=
0
;
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
compressedBitstreamSize
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
compressedBitstreamSize
,
bitstream
.
size
);
PCCResidualsDecoder
decoder
;
PCCResidualsDecoder
decoder
;
const
uint32_t
alphabetSize
=
64
;
const
uint32_t
alphabetSize
=
64
;
decoder
.
start
(
bitstream
,
alphabetSize
);
decoder
.
start
(
bitstream
,
alphabetSize
);
...
@@ -190,20 +199,19 @@ void AttributeDecoder::decodeReflectances(
...
@@ -190,20 +199,19 @@ void AttributeDecoder::decodeReflectances(
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeColors
(
void
PCCBitstream
&
bitstream
,
AttributeDecoder
::
decodeColors
(
PCCPointSet3
&
pointCloud
PCCBitstream
&
bitstream
,
PCCPointSet3
&
pointCloud
)
)
{
{
uint32_t
compressedBitstreamSize
=
0
;
uint32_t
compressedBitstreamSize
=
0
;
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
compressedBitstreamSize
,
bitstream
.
size
);
PCCReadFromBuffer
<
uint32_t
>
(
bitstream
.
buffer
,
compressedBitstreamSize
,
bitstream
.
size
);
PCCResidualsDecoder
decoder
;
PCCResidualsDecoder
decoder
;
const
uint32_t
alphabetSize
=
64
;
const
uint32_t
alphabetSize
=
64
;
decoder
.
start
(
bitstream
,
alphabetSize
);
decoder
.
start
(
bitstream
,
alphabetSize
);
switch
(
transformType
)
{
switch
(
transformType
)
{
case
TransformType
::
kRAHT
:
case
TransformType
::
kRAHT
:
decodeColorsRaht
(
decoder
,
pointCloud
);
break
;
decodeColorsRaht
(
decoder
,
pointCloud
);
break
;
case
TransformType
::
kIntegerLift
:
case
TransformType
::
kIntegerLift
:
decodeColorsIntegerLift
(
decoder
,
pointCloud
);
decodeColorsIntegerLift
(
decoder
,
pointCloud
);
...
@@ -216,60 +224,68 @@ void AttributeDecoder::decodeColors(
...
@@ -216,60 +224,68 @@ void AttributeDecoder::decodeColors(
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeReflectancesIntegerLift
(
void
PCCResiduals
Decoder
&
decode
r
,
Attribute
Decoder
::
decode
ReflectancesIntegerLift
(
PCCPointSet3
&
pointCloud
PCCResidualsDecoder
&
decoder
,
PCCPointSet3
&
pointCloud
)
)
{
{
const
size_t
pointCount
=
predictors
.
size
();
const
size_t
pointCount
=
predictors
.
size
();
for
(
size_t
predictorIndex
=
0
;
predictorIndex
<
pointCount
;
++
predictorIndex
)
{
for
(
size_t
predictorIndex
=
0
;
predictorIndex
<
pointCount
;
auto
&
predictor
=
predictors
[
predictorIndex
];
++
predictorIndex
)
{
uint16_t
&
reflectance
=
pointCloud
.
getReflectance
(
predictor
.
index
);
auto
&
predictor
=
predictors
[
predictorIndex
];
uint16_t
&
reflectance
=
pointCloud
.
getReflectance
(
predictor
.
index
);
const
size_t
lodIndex
=
predictor
.
levelOfDetailIndex
;
const
size_t
lodIndex
=
predictor
.
levelOfDetailIndex
;
const
int64_t
qs
=
quantizationSteps
[
lodIndex
];
const
int64_t
qs
=
quantizationSteps
[
lodIndex
];
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
int64_t
quantPredAttValue
=
predictor
.
predictReflectance
(
pointCloud
);
const
int64_t
quantPredAttValue
=
predictor
.
predictReflectance
(
pointCloud
);
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue0
),
qs
);
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue0
),
qs
);
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
reflectance
=
uint16_t
(
PCCClip
(
reconstructedQuantAttValue
,
int64_t
(
0
),
reflectance
=
uint16_t
(
PCCClip
(
int64_t
(
std
::
numeric_limits
<
uint16_t
>::
max
())));
reconstructedQuantAttValue
,
int64_t
(
0
),
int64_t
(
std
::
numeric_limits
<
uint16_t
>::
max
())));
}
}
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeColorsIntegerLift
(
void
PCCResiduals
Decoder
&
decode
r
,
Attribute
Decoder
::
decode
ColorsIntegerLift
(
PCCPointSet3
&
pointCloud
PCCResidualsDecoder
&
decoder
,
PCCPointSet3
&
pointCloud
)
)
{
{
const
size_t
pointCount
=
predictors
.
size
();
const
size_t
pointCount
=
predictors
.
size
();
for
(
size_t
predictorIndex
=
0
;
predictorIndex
<
pointCount
;
++
predictorIndex
)
{
for
(
size_t
predictorIndex
=
0
;
predictorIndex
<
pointCount
;
auto
&
predictor
=
predictors
[
predictorIndex
];
++
predictorIndex
)
{
PCCColor3B
&
color
=
pointCloud
.
getColor
(
predictor
.
index
);
auto
&
predictor
=
predictors
[
predictorIndex
];
PCCColor3B
&
color
=
pointCloud
.
getColor
(
predictor
.
index
);
const
PCCColor3B
predictedColor
=
predictor
.
predictColor
(
pointCloud
);
const
PCCColor3B
predictedColor
=
predictor
.
predictColor
(
pointCloud
);
const
size_t
lodIndex
=
predictor
.
levelOfDetailIndex
;
const
size_t
lodIndex
=
predictor
.
levelOfDetailIndex
;
const
int64_t
qs
=
quantizationSteps
[
lodIndex
];
const
int64_t
qs
=
quantizationSteps
[
lodIndex
];
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
int64_t
quantPredAttValue
=
predictedColor
[
0
];
const
int64_t
quantPredAttValue
=
predictedColor
[
0
];
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue0
),
qs
);
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue0
),
qs
);
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
color
[
0
]
=
uint8_t
(
PCCClip
(
reconstructedQuantAttValue
,
int64_t
(
0
),
int64_t
(
255
)));
color
[
0
]
=
uint8_t
(
PCCClip
(
reconstructedQuantAttValue
,
int64_t
(
0
),
int64_t
(
255
)));
for
(
size_t
k
=
1
;
k
<
3
;
++
k
)
{
for
(
size_t
k
=
1
;
k
<
3
;
++
k
)
{
const
uint32_t
attValue
=
decoder
.
decode1
();
const
uint32_t
attValue
=
decoder
.
decode1
();
const
int64_t
quantPredAttValue
=
predictedColor
[
k
];
const
int64_t
quantPredAttValue
=
predictedColor
[
k
];
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue
),
qs
);
const
int64_t
delta
=
PCCInverseQuantization
(
o3dgc
::
UIntToInt
(
attValue
),
qs
);
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
const
int64_t
reconstructedQuantAttValue
=
quantPredAttValue
+
delta
;
color
[
k
]
=
uint8_t
(
PCCClip
(
reconstructedQuantAttValue
,
int64_t
(
0
),
int64_t
(
255
)));
color
[
k
]
=
uint8_t
(
PCCClip
(
reconstructedQuantAttValue
,
int64_t
(
0
),
int64_t
(
255
)));
}
}
}
}
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeReflectancesRaht
(
void
PCCResiduals
Decoder
&
decode
r
,
Attribute
Decoder
::
decode
ReflectancesRaht
(
PCCPointSet3
&
pointCloud
PCCResidualsDecoder
&
decoder
,
PCCPointSet3
&
pointCloud
)
)
{
{
const
int
voxelCount
=
int
(
pointCloud
.
getPointCount
());
const
int
voxelCount
=
int
(
pointCloud
.
getPointCount
());
std
::
vector
<
MortonCodeWithIndex
>
packedVoxel
(
voxelCount
);
std
::
vector
<
MortonCodeWithIndex
>
packedVoxel
(
voxelCount
);
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
...
@@ -289,16 +305,16 @@ void AttributeDecoder::decodeReflectancesRaht(
...
@@ -289,16 +305,16 @@ void AttributeDecoder::decodeReflectancesRaht(
sort
(
packedVoxel
.
begin
(),
packedVoxel
.
end
());
sort
(
packedVoxel
.
begin
(),
packedVoxel
.
end
());
// Moroton codes
// Moroton codes
long
long
*
mortonCode
=
new
long
long
[
voxelCount
];
long
long
*
mortonCode
=
new
long
long
[
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
mortonCode
[
n
]
=
packedVoxel
[
n
].
mortonCode
;
mortonCode
[
n
]
=
packedVoxel
[
n
].
mortonCode
;
}
}
// Re-obtain weights at the decoder by calling RAHT without any attributes.
// Re-obtain weights at the decoder by calling RAHT without any attributes.
float
*
weight
=
new
float
[
voxelCount
];
float
*
weight
=
new
float
[
voxelCount
];
int
*
binaryLayer
=
new
int
[
voxelCount
];
int
*
binaryLayer
=
new
int
[
voxelCount
];
regionAdaptiveHierarchicalTransform
(
regionAdaptiveHierarchicalTransform
(
mortonCode
,
nullptr
,
weight
,
binaryLayer
,
0
,
voxelCount
,
depthRaht
);
mortonCode
,
nullptr
,
weight
,
binaryLayer
,
0
,
voxelCount
,
depthRaht
);
// Sort integerized attributes by weight
// Sort integerized attributes by weight
std
::
vector
<
WeightWithIndex
>
sortedWeight
(
voxelCount
);
std
::
vector
<
WeightWithIndex
>
sortedWeight
(
voxelCount
);
...
@@ -309,32 +325,34 @@ void AttributeDecoder::decodeReflectancesRaht(
...
@@ -309,32 +325,34 @@ void AttributeDecoder::decodeReflectancesRaht(
sort
(
sortedWeight
.
begin
(),
sortedWeight
.
end
());
sort
(
sortedWeight
.
begin
(),
sortedWeight
.
end
());
// Entropy decode
// Entropy decode
int
*
sortedIntegerizedAttributes
=
new
int
[
voxelCount
];
int
*
sortedIntegerizedAttributes
=
new
int
[
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
++
n
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
++
n
)
{
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
uint32_t
attValue0
=
decoder
.
decode0
();
sortedIntegerizedAttributes
[
n
]
=
o3dgc
::
UIntToInt
(
attValue0
);
sortedIntegerizedAttributes
[
n
]
=
o3dgc
::
UIntToInt
(
attValue0
);
}
}
// Unsort integerized attributes by weight.
// Unsort integerized attributes by weight.
int
*
integerizedAttributes
=
new
int
[
voxelCount
];
int
*
integerizedAttributes
=
new
int
[
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
integerizedAttributes
[
sortedWeight
[
n
].
index
]
=
sortedIntegerizedAttributes
[
n
];
integerizedAttributes
[
sortedWeight
[
n
].
index
]
=
sortedIntegerizedAttributes
[
n
];
}
}
// Inverse Quantize.
// Inverse Quantize.
float
*
attributes
=
new
float
[
voxelCount
];
float
*
attributes
=
new
float
[
voxelCount
];
const
int
qstep
=
int
(
quantizationStepRaht
);
const
int
qstep
=
int
(
quantizationStepRaht
);
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
attributes
[
n
]
=
integerizedAttributes
[
n
]
*
qstep
;
attributes
[
n
]
=
integerizedAttributes
[
n
]
*
qstep
;
}
}
regionAdaptiveHierarchicalInverseTransform
(
regionAdaptiveHierarchicalInverseTransform
(
mortonCode
,
attributes
,
1
,
voxelCount
,
depthRaht
);
mortonCode
,
attributes
,
1
,
voxelCount
,
depthRaht
);
const
int
maxReflectance
=
std
::
numeric_limits
<
uint16_t
>::
max
();
const
int
maxReflectance
=
std
::
numeric_limits
<
uint16_t
>::
max
();
const
int
minReflectance
=
0
;
const
int
minReflectance
=
0
;
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
const
int
reflectance
=
PCCClip
((
int
)
round
(
attributes
[
n
]),
minReflectance
,
maxReflectance
);
const
int
reflectance
=
PCCClip
((
int
)
round
(
attributes
[
n
]),
minReflectance
,
maxReflectance
);
pointCloud
.
setReflectance
(
packedVoxel
[
n
].
index
,
uint16_t
(
reflectance
));
pointCloud
.
setReflectance
(
packedVoxel
[
n
].
index
,
uint16_t
(
reflectance
));
}
}
...
@@ -349,10 +367,10 @@ void AttributeDecoder::decodeReflectancesRaht(
...
@@ -349,10 +367,10 @@ void AttributeDecoder::decodeReflectancesRaht(
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void
AttributeDecoder
::
decodeColorsRaht
(
void
PCCResiduals
Decoder
&
decode
r
,
Attribute
Decoder
::
decode
ColorsRaht
(
PCCPointSet3
&
pointCloud
PCCResidualsDecoder
&
decoder
,
PCCPointSet3
&
pointCloud
)
)
{
{
const
int
voxelCount
=
int
(
pointCloud
.
getPointCount
());
const
int
voxelCount
=
int
(
pointCloud
.
getPointCount
());
std
::
vector
<
MortonCodeWithIndex
>
packedVoxel
(
voxelCount
);
std
::
vector
<
MortonCodeWithIndex
>
packedVoxel
(
voxelCount
);
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
...
@@ -372,16 +390,16 @@ void AttributeDecoder::decodeColorsRaht(
...
@@ -372,16 +390,16 @@ void AttributeDecoder::decodeColorsRaht(
sort
(
packedVoxel
.
begin
(),
packedVoxel
.
end
());
sort
(
packedVoxel
.
begin
(),
packedVoxel
.
end
());
// Moroton codes
// Moroton codes
long
long
*
mortonCode
=
new
long
long
[
voxelCount
];
long
long
*
mortonCode
=
new
long
long
[
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
mortonCode
[
n
]
=
packedVoxel
[
n
].
mortonCode
;
mortonCode
[
n
]
=
packedVoxel
[
n
].
mortonCode
;
}
}
// Re-obtain weights at the decoder by calling RAHT without any attributes.
// Re-obtain weights at the decoder by calling RAHT without any attributes.
float
*
weight
=
new
float
[
voxelCount
];
float
*
weight
=
new
float
[
voxelCount
];
int
*
binaryLayer
=
new
int
[
voxelCount
];
int
*
binaryLayer
=
new
int
[
voxelCount
];
regionAdaptiveHierarchicalTransform
(
regionAdaptiveHierarchicalTransform
(
mortonCode
,
nullptr
,
weight
,
binaryLayer
,
0
,
voxelCount
,
depthRaht
);
mortonCode
,
nullptr
,
weight
,
binaryLayer
,
0
,
voxelCount
,
depthRaht
);
// Sort integerized attributes by weight
// Sort integerized attributes by weight
std
::
vector
<
WeightWithIndex
>
sortedWeight
(
voxelCount
);
std
::
vector
<
WeightWithIndex
>
sortedWeight
(
voxelCount
);
...
@@ -393,14 +411,15 @@ void AttributeDecoder::decodeColorsRaht(
...
@@ -393,14 +411,15 @@ void AttributeDecoder::decodeColorsRaht(
// Entropy decode
// Entropy decode
const
int
attribCount
=
3
;
const
int
attribCount
=
3
;
int
*
sortedIntegerizedAttributes
=
new
int
[
attribCount
*
voxelCount
];
int
*
sortedIntegerizedAttributes
=
new
int
[
attribCount
*
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
++
n
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
++
n
)
{
const
uint32_t
attValue0
=
decoder
.
decode0
();
const
uint32_t
attValue0
=
decoder
.
decode0
();
sortedIntegerizedAttributes
[
n
]
=
o3dgc
::
UIntToInt
(
attValue0
);
sortedIntegerizedAttributes
[
n
]
=
o3dgc
::
UIntToInt
(
attValue0
);
if
(
binaryLayer
[
sortedWeight
[
n
].
index
]
>=
binaryLevelThresholdRaht
)
{
if
(
binaryLayer
[
sortedWeight
[
n
].
index
]
>=
binaryLevelThresholdRaht
)
{
for
(
int
d
=
1
;
d
<
3
;
++
d
)
{
for
(
int
d
=
1
;
d
<
3
;
++
d
)
{
const
uint32_t
attValue1
=
decoder
.
decode1
();
const
uint32_t
attValue1
=
decoder
.
decode1
();
sortedIntegerizedAttributes
[
voxelCount
*
d
+
n
]
=
o3dgc
::
UIntToInt
(
attValue1
);
sortedIntegerizedAttributes
[
voxelCount
*
d
+
n
]
=
o3dgc
::
UIntToInt
(
attValue1
);
}
}
}
else
{
}
else
{
for
(
int
d
=
1
;
d
<
3
;
d
++
)
{
for
(
int
d
=
1
;
d
<
3
;
d
++
)
{
...
@@ -410,26 +429,27 @@ void AttributeDecoder::decodeColorsRaht(
...
@@ -410,26 +429,27 @@ void AttributeDecoder::decodeColorsRaht(
}
}
// Unsort integerized attributes by weight.
// Unsort integerized attributes by weight.
int
*
integerizedAttributes
=
new
int
[
attribCount
*
voxelCount
];
int
*
integerizedAttributes
=
new
int
[
attribCount
*
voxelCount
];
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
k
=
0
;
k
<
attribCount
;
k
++
)
{
for
(
int
k
=
0
;
k
<
attribCount
;
k
++
)
{
// Pull sorted integerized attributes out of column-major order.
// Pull sorted integerized attributes out of column-major order.
integerizedAttributes
[
attribCount
*
sortedWeight
[
n
].
index
+
k
]
=
integerizedAttributes
[
attribCount
*
sortedWeight
[
n
].
index
+
k
]
=
sortedIntegerizedAttributes
[
voxelCount
*
k
+
n
];
sortedIntegerizedAttributes
[
voxelCount
*
k
+
n
];
}
}
}
}
// Inverse Quantize.
// Inverse Quantize.
float
*
attributes
=
new
float
[
attribCount
*
voxelCount
];
float
*
attributes
=
new
float
[
attribCount
*
voxelCount
];
const
int
qstep
=
int
(
quantizationStepRaht
);
const
int
qstep
=
int
(
quantizationStepRaht
);
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
k
=
0
;
k
<
attribCount
;
k
++
)
{
for
(
int
k
=
0
;
k
<
attribCount
;
k
++
)
{
attributes
[
attribCount
*
n
+
k
]
=
integerizedAttributes
[
attribCount
*
n
+
k
]
*
qstep
;
attributes
[
attribCount
*
n
+
k
]
=
integerizedAttributes
[
attribCount
*
n
+
k
]
*
qstep
;
}
}
}
}
regionAdaptiveHierarchicalInverseTransform
(
regionAdaptiveHierarchicalInverseTransform
(
mortonCode
,
attributes
,
attribCount
,
voxelCount
,
depthRaht
);
mortonCode
,
attributes
,
attribCount
,
voxelCount
,
depthRaht
);
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
for
(
int
n
=
0
;
n
<
voxelCount
;
n
++
)
{
const
int
r
=
(
int
)
round
(
attributes
[
attribCount
*
n
]);
const
int
r
=
(
int
)
round
(
attributes
[
attribCount
*
n
]);
...
...
tmc3/AttributeDecoder.h
View file @
64ffa5e2
...
@@ -54,39 +54,28 @@ struct PCCResidualsDecoder;
...
@@ -54,39 +54,28 @@ struct PCCResidualsDecoder;
class
AttributeDecoder
{
class
AttributeDecoder
{
public:
public:
void
buildPredictors
(
void
buildPredictors
(
const
PCCPointSet3
&
pointCloud
);
const
PCCPointSet3
&
pointCloud
);
void
decodeHeader
(
void
decodeHeader
(
const
std
::
string
&
attributeName
,
PCCBitstream
&
bitstream
);
const
std
::
string
&
attributeName
,
PCCBitstream
&
bitstream
);
void
decodeReflectances
(
void
decodeReflectances
(
PCCBitstream
&
bitstream
,
PCCPointSet3
&
pointCloud
);
PCCBitstream
&
bitstream
,
PCCPointSet3
&
pointCloud
);
void
decodeColors
(
void
decodeColors
(
PCCBitstream
&
bitstream
,
PCCPointSet3
&
pointCloud
);
PCCBitstream
&
bitstream
,