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
d2718fae
Commit
d2718fae
authored
Nov 05, 2019
by
David Flynn
Browse files
refactor: move colour conversion functions to colourspace.h
parent
d0e2ec04
Changes
6
Hide whitespace changes
Inline
Side-by-side
tmc3/CMakeLists.txt
View file @
d2718fae
...
@@ -72,6 +72,7 @@ file(GLOB PROJECT_INC_FILES
...
@@ -72,6 +72,7 @@ file(GLOB PROJECT_INC_FILES
"PCCTMC3Encoder.h"
"PCCTMC3Encoder.h"
"RAHT.h"
"RAHT.h"
"TMC3.h"
"TMC3.h"
"colourspace.h"
"constants.h"
"constants.h"
"entropy.h"
"entropy.h"
"entropydirac.h"
"entropydirac.h"
...
...
tmc3/PCCPointSet.h
View file @
d2718fae
...
@@ -491,41 +491,7 @@ public:
...
@@ -491,41 +491,7 @@ public:
return
bbox
;
return
bbox
;
}
}
void
convertRGBToYUV
()
//--------------------------------------------------------------------------
{
// BT709
for
(
auto
&
color
:
colors
)
{
const
uint8_t
r
=
color
[
2
];
const
uint8_t
g
=
color
[
0
];
const
uint8_t
b
=
color
[
1
];
const
double
y
=
PCCClip
(
std
::
round
(
0.212600
*
r
+
0.715200
*
g
+
0.072200
*
b
),
0.
,
255.
);
const
double
u
=
PCCClip
(
std
::
round
(
-
0.114572
*
r
-
0.385428
*
g
+
0.5
*
b
+
128.0
),
0.
,
255.
);
const
double
v
=
PCCClip
(
std
::
round
(
0.5
*
r
-
0.454153
*
g
-
0.045847
*
b
+
128.0
),
0.
,
255.
);
color
[
0
]
=
static_cast
<
uint8_t
>
(
y
);
color
[
1
]
=
static_cast
<
uint8_t
>
(
u
);
color
[
2
]
=
static_cast
<
uint8_t
>
(
v
);
}
}
void
convertYUVToRGB
()
{
// BT709
for
(
auto
&
color
:
colors
)
{
const
double
y1
=
color
[
0
];
const
double
u1
=
color
[
1
]
-
128.0
;
const
double
v1
=
color
[
2
]
-
128.0
;
const
double
r
=
PCCClip
(
round
(
y1
/*- 0.00000 * u1*/
+
1.57480
*
v1
),
0.0
,
255.0
);
const
double
g
=
PCCClip
(
round
(
y1
-
0.18733
*
u1
-
0.46813
*
v1
),
0.0
,
255.0
);
const
double
b
=
PCCClip
(
round
(
y1
+
1.85563
*
u1
/*+ 0.00000 * v1*/
),
0.0
,
255.0
);
color
[
2
]
=
static_cast
<
uint8_t
>
(
r
);
color
[
0
]
=
static_cast
<
uint8_t
>
(
g
);
color
[
1
]
=
static_cast
<
uint8_t
>
(
b
);
}
}
private:
private:
std
::
vector
<
Vec3
<
double
>>
positions
;
std
::
vector
<
Vec3
<
double
>>
positions
;
...
...
tmc3/TMC3.cpp
View file @
d2718fae
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
#include
"PCCTMC3Decoder.h"
#include
"PCCTMC3Decoder.h"
#include
"constants.h"
#include
"constants.h"
#include
"ply.h"
#include
"ply.h"
#include
"pointset_processing.h"
#include
"program_options_lite.h"
#include
"program_options_lite.h"
#include
"io_tlv.h"
#include
"io_tlv.h"
#include
"version.h"
#include
"version.h"
...
@@ -963,7 +964,7 @@ SequenceEncoder::compressOneFrame(Stopwatch* clock)
...
@@ -963,7 +964,7 @@ SequenceEncoder::compressOneFrame(Stopwatch* clock)
clock
->
start
();
clock
->
start
();
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
pointCloud
.
convertRGBToYUV
(
);
convertGbrToYCbCrBt709
(
pointCloud
);
}
}
if
(
params
->
reflectanceScale
>
1
&&
pointCloud
.
hasReflectances
())
{
if
(
params
->
reflectanceScale
>
1
&&
pointCloud
.
hasReflectances
())
{
...
@@ -998,7 +999,7 @@ SequenceEncoder::compressOneFrame(Stopwatch* clock)
...
@@ -998,7 +999,7 @@ SequenceEncoder::compressOneFrame(Stopwatch* clock)
if
(
!
params
->
reconstructedDataPath
.
empty
())
{
if
(
!
params
->
reconstructedDataPath
.
empty
())
{
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
reconPointCloud
->
convertYUVToRGB
(
);
convertYCbCrBt709ToGbr
(
*
reconPointCloud
);
}
}
if
(
params
->
reflectanceScale
>
1
&&
reconPointCloud
->
hasReflectances
())
{
if
(
params
->
reflectanceScale
>
1
&&
reconPointCloud
->
hasReflectances
())
{
...
@@ -1044,7 +1045,7 @@ SequenceEncoder::onPostRecolour(const PCCPointSet3& cloud)
...
@@ -1044,7 +1045,7 @@ SequenceEncoder::onPostRecolour(const PCCPointSet3& cloud)
}
}
PCCPointSet3
tmpCloud
(
cloud
);
PCCPointSet3
tmpCloud
(
cloud
);
tmpCloud
.
convertYUVToRGB
(
);
convertYCbCrBt709ToGbr
(
tmpCloud
);
ply
::
write
(
tmpCloud
,
_plyAttrNames
,
plyName
,
!
params
->
outputBinaryPly
);
ply
::
write
(
tmpCloud
,
_plyAttrNames
,
plyName
,
!
params
->
outputBinaryPly
);
}
}
...
@@ -1107,7 +1108,7 @@ SequenceDecoder::onOutputCloud(
...
@@ -1107,7 +1108,7 @@ SequenceDecoder::onOutputCloud(
PCCPointSet3
pointCloud
(
decodedPointCloud
);
PCCPointSet3
pointCloud
(
decodedPointCloud
);
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
if
(
params
->
colorTransform
==
COLOR_TRANSFORM_RGB_TO_YCBCR
)
{
pointCloud
.
convertYUVToRGB
(
);
convertYCbCrBt709ToGbr
(
pointCloud
);
}
}
if
(
params
->
reflectanceScale
>
1
&&
pointCloud
.
hasReflectances
())
{
if
(
params
->
reflectanceScale
>
1
&&
pointCloud
.
hasReflectances
())
{
...
...
tmc3/colourspace.h
0 → 100644
View file @
d2718fae
/* The copyright in this software is being made available under the BSD
* Licence, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such
* rights are granted under this licence.
*
* Copyright (c) 2017-2018, ISO/IEC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the ISO/IEC nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include
<cstdint>
#include
"PCCMath.h"
namespace
pcc
{
//============================================================================
template
<
template
<
typename
>
class
T
,
typename
Tv
>
T
<
Tv
>
transformGbrToYCbCrBt709
(
T
<
Tv
>&
gbr
)
{
const
Tv
g
=
gbr
[
0
];
const
Tv
b
=
gbr
[
1
];
const
Tv
r
=
gbr
[
2
];
const
double
y
=
PCCClip
(
std
::
round
(
0.212600
*
r
+
0.715200
*
g
+
0.072200
*
b
),
0.
,
255.
);
const
double
u
=
PCCClip
(
std
::
round
(
-
0.114572
*
r
-
0.385428
*
g
+
0.5
*
b
+
128.0
),
0.
,
255.
);
const
double
v
=
PCCClip
(
std
::
round
(
0.5
*
r
-
0.454153
*
g
-
0.045847
*
b
+
128.0
),
0.
,
255.
);
return
{
Tv
(
y
),
Tv
(
u
),
Tv
(
v
)};
}
//============================================================================
template
<
template
<
typename
>
class
T
,
typename
Tv
>
T
<
Tv
>
transformYCbCrBt709ToGbr
(
T
<
Tv
>&
ycbcr
)
{
const
double
y1
=
ycbcr
[
0
];
const
double
u1
=
ycbcr
[
1
]
-
128.0
;
const
double
v1
=
ycbcr
[
2
]
-
128.0
;
const
double
r
=
PCCClip
(
round
(
y1
/*- 0.00000 * u1*/
+
1.57480
*
v1
),
0.0
,
255.0
);
const
double
g
=
PCCClip
(
round
(
y1
-
0.18733
*
u1
-
0.46813
*
v1
),
0.0
,
255.0
);
const
double
b
=
PCCClip
(
round
(
y1
+
1.85563
*
u1
/*+ 0.00000 * v1*/
),
0.0
,
255.0
);
return
{
Tv
(
g
),
Tv
(
b
),
Tv
(
r
)};
}
//============================================================================
}
// namespace pcc
tmc3/pointset_processing.cpp
View file @
d2718fae
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include
"pointset_processing.h"
#include
"pointset_processing.h"
#include
"colourspace.h"
#include
"KDTreeVectorOfVectorsAdaptor.h"
#include
"KDTreeVectorOfVectorsAdaptor.h"
#include
<cstddef>
#include
<cstddef>
...
@@ -902,4 +903,26 @@ recolour(
...
@@ -902,4 +903,26 @@ recolour(
//============================================================================
//============================================================================
void
convertGbrToYCbCrBt709
(
PCCPointSet3
&
cloud
)
{
for
(
int
i
=
0
;
i
<
cloud
.
getPointCount
();
i
++
)
{
auto
&
val
=
cloud
.
getColor
(
i
);
val
=
transformGbrToYCbCrBt709
(
val
);
}
}
//============================================================================
void
convertYCbCrBt709ToGbr
(
PCCPointSet3
&
cloud
)
{
for
(
int
i
=
0
;
i
<
cloud
.
getPointCount
();
i
++
)
{
auto
&
val
=
cloud
.
getColor
(
i
);
val
=
transformYCbCrBt709ToGbr
(
val
);
}
}
//============================================================================
}
// namespace pcc
}
// namespace pcc
tmc3/pointset_processing.h
View file @
d2718fae
...
@@ -173,4 +173,9 @@ int recolour(
...
@@ -173,4 +173,9 @@ int recolour(
//============================================================================
//============================================================================
void
convertGbrToYCbCrBt709
(
PCCPointSet3
&
);
void
convertYCbCrBt709ToGbr
(
PCCPointSet3
&
);
//============================================================================
}
// namespace pcc
}
// namespace pcc
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment