| 50 | } |
| 51 | |
| 52 | RawImage PefDecoder::decodeRawInternal() { |
| 53 | const auto* raw = mRootIFD->getIFDWithTag(STRIPOFFSETS); |
| 54 | |
| 55 | int compression = raw->getEntry(COMPRESSION)->getU32(); |
| 56 | |
| 57 | if (1 == compression || compression == 32773) { |
| 58 | decodeUncompressed(raw, BitOrder_MSB); |
| 59 | return mRaw; |
| 60 | } |
| 61 | |
| 62 | if (65535 != compression) |
| 63 | ThrowRDE("Unsupported compression"); |
| 64 | |
| 65 | TiffEntry *offsets = raw->getEntry(STRIPOFFSETS); |
| 66 | TiffEntry *counts = raw->getEntry(STRIPBYTECOUNTS); |
| 67 | |
| 68 | if (offsets->count != 1) { |
| 69 | ThrowRDE("Multiple Strips found: %u", offsets->count); |
| 70 | } |
| 71 | if (counts->count != offsets->count) { |
| 72 | ThrowRDE( |
| 73 | "Byte count number does not match strip size: count:%u, strips:%u ", |
| 74 | counts->count, offsets->count); |
| 75 | } |
| 76 | ByteStream bs( |
| 77 | DataBuffer(mFile->getSubView(offsets->getU32(), counts->getU32()), |
| 78 | Endianness::little)); |
| 79 | |
| 80 | uint32_t width = raw->getEntry(IMAGEWIDTH)->getU32(); |
| 81 | uint32_t height = raw->getEntry(IMAGELENGTH)->getU32(); |
| 82 | |
| 83 | mRaw->dim = iPoint2D(width, height); |
| 84 | |
| 85 | ByteStream* metaData = nullptr; |
| 86 | ByteStream stream; |
| 87 | if (getRootIFD()->hasEntryRecursive(static_cast<TiffTag>(0x220))) { |
| 88 | /* Attempt to read huffman table, if found in makernote */ |
| 89 | TiffEntry* t = getRootIFD()->getEntryRecursive(static_cast<TiffTag>(0x220)); |
| 90 | if (t->type != TIFF_UNDEFINED) |
| 91 | ThrowRDE("Unknown Huffman table type."); |
| 92 | |
| 93 | stream = t->getData(); |
| 94 | metaData = &stream; |
| 95 | } |
| 96 | |
| 97 | PentaxDecompressor p(mRaw, metaData); |
| 98 | mRaw->createData(); |
| 99 | p.decompress(bs); |
| 100 | |
| 101 | return mRaw; |
| 102 | } |
| 103 | |
| 104 | void PefDecoder::decodeMetaDataInternal(const CameraMetaData* meta) { |
| 105 | int iso = 0; |
nothing calls this directly
no test coverage detected