Commit f0eedcdb authored by David Flynn's avatar David Flynn
Browse files

attr: use interface to hide attribute codec internals

In order to isolate the attribute coder from the rest of the codec,
this adds an interface along with factory methods to the attribute
codec.
parent b12db69c
/* 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-2019, 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 <memory>
#include "hls.h"
#include "PayloadBuffer.h"
#include "PCCPointSet.h"
namespace pcc {
//============================================================================
class AttributeDecoderIntf {
public:
virtual ~AttributeDecoderIntf();
virtual void decode(
const SequenceParameterSet& sps,
const AttributeDescription& desc,
const AttributeParameterSet& aps,
int geom_num_points,
int minGeomNodeSizeLog2,
const PayloadBuffer&,
PCCPointSet3& pointCloud) = 0;
};
//----------------------------------------------------------------------------
std::unique_ptr<AttributeDecoderIntf> makeAttributeDecoder();
//============================================================================
class AttributeEncoderIntf {
public:
virtual ~AttributeEncoderIntf();
virtual void encode(
const SequenceParameterSet& sps,
const AttributeDescription& desc,
const AttributeParameterSet& attr_aps,
const AttributeBrickHeader& abh,
PCCPointSet3& pointCloud,
PayloadBuffer* payload) = 0;
};
//----------------------------------------------------------------------------
std::unique_ptr<AttributeEncoderIntf> makeAttributeEncoder();
//============================================================================
} // namespace pcc
......@@ -173,6 +173,20 @@ PCCResidualsDecoder::decode()
return decodeSymbol(0, 0, 0) + 1;
}
//============================================================================
// AttributeDecoderIntf
AttributeDecoderIntf::~AttributeDecoderIntf() = default;
//============================================================================
// AttributeDecoder factory
std::unique_ptr<AttributeDecoderIntf>
makeAttributeDecoder()
{
return std::unique_ptr<AttributeDecoder>(new AttributeDecoder());
}
//============================================================================
// AttributeDecoder Members
......
......@@ -37,6 +37,7 @@
#include <stdint.h>
#include "Attribute.h"
#include "PayloadBuffer.h"
#include "PCCTMC3Common.h"
#include "quantization.h"
......@@ -50,7 +51,7 @@ struct PCCResidualsDecoder;
//============================================================================
class AttributeDecoder {
class AttributeDecoder : public AttributeDecoderIntf {
public:
void decode(
const SequenceParameterSet& sps,
......@@ -59,7 +60,7 @@ public:
int geom_num_points,
int minGeomNodeSizeLog2,
const PayloadBuffer&,
PCCPointSet3& pointCloud);
PCCPointSet3& pointCloud) override;
protected:
// todo(df): consider alternative encapsulation
......
......@@ -325,6 +325,20 @@ PCCResidualsEntropyEstimator::update(
}
}
//============================================================================
// AttributeEncoderIntf
AttributeEncoderIntf::~AttributeEncoderIntf() = default;
//============================================================================
// AttributeEncoder factory
std::unique_ptr<AttributeEncoderIntf>
makeAttributeEncoder()
{
return std::unique_ptr<AttributeEncoder>(new AttributeEncoder());
}
//============================================================================
// AttributeEncoder Members
......
......@@ -38,6 +38,7 @@
#include <stdint.h>
#include <vector>
#include "Attribute.h"
#include "PayloadBuffer.h"
#include "PCCTMC3Common.h"
#include "quantization.h"
......@@ -52,7 +53,7 @@ struct PCCResidualsEntropyEstimator;
//============================================================================
class AttributeEncoder {
class AttributeEncoder : public AttributeEncoderIntf {
public:
void encode(
const SequenceParameterSet& sps,
......@@ -60,7 +61,7 @@ public:
const AttributeParameterSet& attr_aps,
const AttributeBrickHeader& abh,
PCCPointSet3& pointCloud,
PayloadBuffer* payload);
PayloadBuffer* payload) override;
protected:
// todo(df): consider alternative encapsulation
......
......@@ -56,6 +56,7 @@ file(GLOB PROJECT_IN_FILES
)
file(GLOB PROJECT_INC_FILES
"Attribute.h"
"AttributeDecoder.h"
"AttributeEncoder.h"
"BitReader.h"
......
......@@ -38,7 +38,7 @@
#include <cassert>
#include <string>
#include "AttributeDecoder.h"
#include "Attribute.h"
#include "PayloadBuffer.h"
#include "PCCPointSet.h"
#include "geometry.h"
......@@ -283,11 +283,11 @@ PCCTMC3Decoder3::decodeAttributeBrick(const PayloadBuffer& buf)
const auto& attr_sps = _sps->attributeSets[abh.attr_sps_attr_idx];
const auto& label = attr_sps.attributeLabel;
AttributeDecoder attrDecoder;
auto attrDecoder = makeAttributeDecoder();
pcc::chrono::Stopwatch<pcc::chrono::utime_inc_children_clock> clock_user;
clock_user.start();
attrDecoder.decode(
attrDecoder->decode(
*_sps, attr_sps, attr_aps, _gbh.geom_num_points,
_params.minGeomNodeSizeLog2, buf, _currentPointCloud);
clock_user.stop();
......
......@@ -38,7 +38,7 @@
#include <cassert>
#include <set>
#include "AttributeEncoder.h"
#include "Attribute.h"
#include "pointset_processing.h"
#include "geometry.h"
#include "io_hls.h"
......@@ -420,8 +420,8 @@ PCCTMC3Encoder3::compressPartition(
write(attr_aps, abh, &payload);
AttributeEncoder attrEncoder;
attrEncoder.encode(*_sps, attr_sps, attr_aps, abh, pointCloud, &payload);
auto attrEncoder = makeAttributeEncoder();
attrEncoder->encode(*_sps, attr_sps, attr_aps, abh, pointCloud, &payload);
clock_user.stop();
int coded_size = int(payload.size());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment