MCPcopy Create free account
hub / github.com/PDAL/PDAL / EncoderFactory

Method EncoderFactory

plugins/e57/libE57Format/src/Encoder.cpp:43–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41using namespace e57;
42
43std::shared_ptr<Encoder> Encoder::EncoderFactory( unsigned bytestreamNumber,
44 std::shared_ptr<CompressedVectorNodeImpl> cVector,
45 std::vector<SourceDestBuffer> &sbufs,
46 ustring & /*codecPath*/ )
47{
48 //??? For now, only handle one input
49 if ( sbufs.size() != 1 )
50 {
51 throw E57_EXCEPTION2( ErrorInternal, "sbufsSize=" + toString( sbufs.size() ) );
52 }
53
54 SourceDestBuffer sbuf = sbufs.at( 0 );
55
56 // Get node we are going to encode from the CompressedVector's prototype
57 NodeImplSharedPtr prototype = cVector->getPrototype();
58 ustring path = sbuf.pathName();
59 NodeImplSharedPtr encodeNode = prototype->get( path );
60
61#ifdef E57_VERBOSE
62 std::cout << "Node to encode:" << std::endl; //???
63 encodeNode->dump( 2 );
64#endif
65 switch ( encodeNode->type() )
66 {
67 case TypeInteger:
68 {
69 std::shared_ptr<IntegerNodeImpl> ini =
70 std::static_pointer_cast<IntegerNodeImpl>( encodeNode ); // downcast to correct type
71
72 // Get pointer to parent ImageFileImpl, to call bitsNeeded()
73 ImageFileImplSharedPtr imf(
74 encodeNode->destImageFile_ ); //??? should be function for this,
75 // imf->parentFile()
76 //--> ImageFile?
77
78 unsigned bitsPerRecord = imf->bitsNeeded( ini->minimum(), ini->maximum() );
79
80 // !!! need to pick smarter channel buffer sizes, here and elsewhere
81 // Construct Integer encoder with appropriate register size, based on number of bits
82 // stored.
83 if ( bitsPerRecord == 0 )
84 {
85 std::shared_ptr<Encoder> encoder(
86 new ConstantIntegerEncoder( bytestreamNumber, sbuf, ini->minimum() ) );
87
88 return encoder;
89 }
90
91 if ( bitsPerRecord <= 8 )
92 {
93 std::shared_ptr<Encoder> encoder( new BitpackIntegerEncoder<uint8_t>(
94 false, bytestreamNumber, sbuf, DATA_PACKET_MAX /*!!!*/, ini->minimum(),
95 ini->maximum(), 1.0, 0.0 ) );
96 return encoder;
97 }
98
99 if ( bitsPerRecord <= 16 )
100 {

Callers

nothing calls this directly

Calls 14

atMethod · 0.80
getPrototypeMethod · 0.80
bitsNeededMethod · 0.80
toStringFunction · 0.70
sizeMethod · 0.45
pathNameMethod · 0.45
getMethod · 0.45
dumpMethod · 0.45
typeMethod · 0.45
minimumMethod · 0.45
maximumMethod · 0.45
scaleMethod · 0.45

Tested by

no test coverage detected