@@ -99,8 +99,8 @@ struct DecompressorV8Params {
9999
100100 PanasonicV8Decompressor::Bayer2x2 initialPrediction;
101101
102- // / Huffman decoding shift down value. Appears to be unused.
103- std::vector<uint16_t > huffShiftDown ;
102+ // / Decoding shift down value. Appears to be unused.
103+ std::vector<uint16_t > shiftDown ;
104104
105105 uint16_t gammaClipVal;
106106
@@ -131,7 +131,7 @@ void DecompressorV8Params::validate() const {
131131 ThrowRDE (" Strip bit length list does not have enough entries for the "
132132 " number of strips!" );
133133
134- if (std::any_of (huffShiftDown .begin (), huffShiftDown .end (),
134+ if (std::any_of (shiftDown .begin (), shiftDown .end (),
135135 [](uint16_t x) { return x != 0 ; })) {
136136 ThrowRDE (" Non-zero shift down value encountered! Shift down decoding has "
137137 " never been tested!" );
@@ -174,32 +174,31 @@ DecompressorV8Params::DecompressorV8Params(const TiffIFD& ifd) {
174174 initialPrediction[3 ] =
175175 ifd.getEntry (TiffTag::PANASONIC_V8_INIT_PRED_BLUE)->getU16 ();
176176
177- getPanasonicTiffVector (ifd, TiffTag::PANASONIC_V8_HUF_SHIFT_DOWN,
178- huffShiftDown);
177+ getPanasonicTiffVector (ifd, TiffTag::PANASONIC_V8_HUF_SHIFT_DOWN, shiftDown);
179178
180179 gammaClipVal = ifd.getEntry (TiffTag::PANASONIC_V8_CLIP_VAL)->getU16 ();
181180 // NOLINTEND(cppcoreguidelines-prefer-member-initializer)
182181
183182 validate ();
184183}
185184
186- std::vector<PanasonicV8Decompressor::HuffmanLUTEntry >
187- populateHuffmanLUT (const TiffIFD& ifd) {
188- std::vector<PanasonicV8Decompressor::HuffmanLUTEntry> mHuffmanLUT ;
185+ std::vector<PanasonicV8Decompressor::DecoderLUTEntry >
186+ populateDecoderLUT (const TiffIFD& ifd) {
187+ std::vector<PanasonicV8Decompressor::DecoderLUTEntry> mDecoderLUT ;
189188
190189 ByteStream stream = ifd.getEntry (TiffTag::PANASONIC_V8_HUF_TABLE)->getData ();
191190
192191 const auto numSymbols = stream.getU16 ();
193192 if (numSymbols < 1 || numSymbols > 17 )
194193 ThrowRDE (" Unexpected number of symbols: %u" , numSymbols);
195194
196- struct HuffEntry {
195+ struct Entry {
197196 uint8_t bitcount;
198197 uint16_t symbol, mask;
199198 uint8_t codeValue;
200199 };
201- std::vector<HuffEntry> huffTable ;
202- huffTable .reserve (numSymbols);
200+ std::vector<Entry> table ;
201+ table .reserve (numSymbols);
203202
204203 for (unsigned symbolIndex = 0 ; symbolIndex != numSymbols; ++symbolIndex) {
205204 const auto len = stream.getU16 (); // Number of bits in symbol
@@ -208,28 +207,28 @@ populateHuffmanLUT(const TiffIFD& ifd) {
208207 const auto code = stream.getU16 ();
209208 if (!isIntN<uint32_t >(code, len))
210209 ThrowRDE (" Bad symbol code" );
211- HuffEntry entry;
210+ Entry entry;
212211 entry.bitcount = implicit_cast<uint8_t >(len);
213212 entry.symbol = uint16_t (code << (16U - entry.bitcount ));
214213 entry.codeValue = implicit_cast<uint8_t >(symbolIndex);
215214 entry.mask = uint16_t (
216215 0xffffU << (16U -
217216 entry.bitcount )); // mask of the bits overlapping symbol
218- if (entry.bitcount == PanasonicV8Decompressor::HuffmanLUTEntry ().bitcount &&
219- entry.codeValue == PanasonicV8Decompressor::HuffmanLUTEntry ().diffCat )
217+ if (entry.bitcount == PanasonicV8Decompressor::DecoderLUTEntry ().bitcount &&
218+ entry.codeValue == PanasonicV8Decompressor::DecoderLUTEntry ().diffCat )
220219 ThrowRDE (" Sentinel symbol encountered" );
221- huffTable .emplace_back (entry);
220+ table .emplace_back (entry);
222221 }
223222 assert (table.size () == numSymbols);
224223
225- // Cache of Huffman table results for all possible 16-bit values.
226- mHuffmanLUT .resize (1 + UINT16_MAX);
224+ // Cache of decoding results for all possible 16-bit values.
225+ mDecoderLUT .resize (1 + UINT16_MAX);
227226
228227 // Populates LUT by checking for a bitwise match between each value and the
229- // prefix codes recorded in the table.
230- for (unsigned li = 0 ; li < mHuffmanLUT .size (); ++li) {
231- PanasonicV8Decompressor::HuffmanLUTEntry & lutVal = mHuffmanLUT [li];
232- for (const auto & ti : huffTable ) {
228+ // codes recorded in the table.
229+ for (unsigned li = 0 ; li < mDecoderLUT .size (); ++li) {
230+ PanasonicV8Decompressor::DecoderLUTEntry & lutVal = mDecoderLUT [li];
231+ for (const auto & ti : table ) {
233232 if ((uint16_t (li) & ti.mask ) == ti.symbol ) {
234233 lutVal.bitcount = ti.bitcount ;
235234 lutVal.diffCat = ti.codeValue ;
@@ -238,7 +237,7 @@ populateHuffmanLUT(const TiffIFD& ifd) {
238237 }
239238 }
240239
241- return mHuffmanLUT ;
240+ return mDecoderLUT ;
242241}
243242
244243// / Maybe the most complicated part of the entire file format, and seemingly,
@@ -307,8 +306,8 @@ RawImage Rw2Decoder::decodeRawV8(const TiffIFD& raw) const {
307306 ThrowRDE (" Unexpected CFA, only RGGB is supported" );
308307
309308 const DecompressorV8Params mParams (raw);
310- const std::vector<PanasonicV8Decompressor::HuffmanLUTEntry> mHuffmanLUT =
311- populateHuffmanLUT (raw);
309+ const std::vector<PanasonicV8Decompressor::DecoderLUTEntry> mDecoderLUT =
310+ populateDecoderLUT (raw);
312311 populateGammaLUT (mParams , raw);
313312 const std::vector<Array1DRef<const uint8_t >> mStrips =
314313 getInputStrips (mParams , mFile );
@@ -322,7 +321,7 @@ RawImage Rw2Decoder::decodeRawV8(const TiffIFD& raw) const {
322321 getAsArray1DRef (mParams .stripHeights ));
323322
324323 PanasonicV8Decompressor v8 (mRaw , b.getDecompressorParams (),
325- getAsArray1DRef (mHuffmanLUT ));
324+ getAsArray1DRef (mDecoderLUT ));
326325 mRaw ->createData ();
327326 v8.decompress ();
328327 return mRaw ;
0 commit comments