| 40 | using namespace e57; |
| 41 | |
| 42 | std::shared_ptr<Decoder> Decoder::DecoderFactory( unsigned bytestreamNumber, //!!! name ok? |
| 43 | const CompressedVectorNodeImpl *cVector, |
| 44 | std::vector<SourceDestBuffer> &dbufs, |
| 45 | const ustring & /*codecPath*/ ) |
| 46 | { |
| 47 | // !!! verify single dbuf |
| 48 | |
| 49 | // Get node we are going to decode from the CompressedVector's prototype |
| 50 | NodeImplSharedPtr prototype = cVector->getPrototype(); |
| 51 | ustring path = dbufs.at( 0 ).pathName(); |
| 52 | NodeImplSharedPtr decodeNode = prototype->get( path ); |
| 53 | |
| 54 | #ifdef E57_VERBOSE |
| 55 | std::cout << "Node to decode:" << std::endl; //??? |
| 56 | decodeNode->dump( 2 ); |
| 57 | #endif |
| 58 | |
| 59 | uint64_t maxRecordCount = cVector->childCount(); |
| 60 | |
| 61 | switch ( decodeNode->type() ) |
| 62 | { |
| 63 | case TypeInteger: |
| 64 | { |
| 65 | std::shared_ptr<IntegerNodeImpl> ini = |
| 66 | std::static_pointer_cast<IntegerNodeImpl>( decodeNode ); // downcast to correct type |
| 67 | |
| 68 | // Get pointer to parent ImageFileImpl, to call bitsNeeded() |
| 69 | ImageFileImplSharedPtr imf( |
| 70 | decodeNode->destImageFile_ ); //??? should be function for this, |
| 71 | // imf->parentFile() |
| 72 | //--> ImageFile? |
| 73 | |
| 74 | unsigned bitsPerRecord = imf->bitsNeeded( ini->minimum(), ini->maximum() ); |
| 75 | |
| 76 | // !!! need to pick smarter channel buffer sizes, here and elsewhere |
| 77 | // Construct Integer decoder with appropriate register size, based on |
| 78 | // number of bits stored. |
| 79 | if ( bitsPerRecord == 0 ) |
| 80 | { |
| 81 | std::shared_ptr<Decoder> decoder( new ConstantIntegerDecoder( |
| 82 | false, bytestreamNumber, dbufs.at( 0 ), ini->minimum(), 1.0, 0.0, maxRecordCount ) ); |
| 83 | return decoder; |
| 84 | } |
| 85 | |
| 86 | if ( bitsPerRecord <= 8 ) |
| 87 | { |
| 88 | std::shared_ptr<Decoder> decoder( new BitpackIntegerDecoder<uint8_t>( |
| 89 | false, bytestreamNumber, dbufs.at( 0 ), ini->minimum(), ini->maximum(), 1.0, 0.0, |
| 90 | maxRecordCount ) ); |
| 91 | return decoder; |
| 92 | } |
| 93 | |
| 94 | if ( bitsPerRecord <= 16 ) |
| 95 | { |
| 96 | std::shared_ptr<Decoder> decoder( new BitpackIntegerDecoder<uint16_t>( |
| 97 | false, bytestreamNumber, dbufs.at( 0 ), ini->minimum(), ini->maximum(), 1.0, 0.0, |
| 98 | maxRecordCount ) ); |
| 99 | return decoder; |
nothing calls this directly
no test coverage detected