Skip to content

Commit

Permalink
OlympusDifferenceDecoder: give nbits a better name
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Feb 29, 2024
1 parent 09248e7 commit d4a8d09
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/librawspeed/decompressors/OlympusDecompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ inline __attribute__((always_inline)) int
OlympusDifferenceDecoder::getDiff(BitStreamerMSB& bits) {
bits.fill();

int nbitsBias = (carry[2] < 3) ? 2 : 0;
int nbits = numActiveBits(implicit_cast<unsigned>(carry[0]));
nbits -= nbitsBias;
nbits = std::max(nbits, 2 + nbitsBias);
int numLowBitsBias = (carry[2] < 3) ? 2 : 0;
int numLowBits = numActiveBits(implicit_cast<unsigned>(carry[0]));
numLowBits -= numLowBitsBias;
numLowBits = std::max(numLowBits, 2 + numLowBitsBias);

int b = bits.peekBitsNoFill(15);
int sign = (b >> 14) * -1;
Expand All @@ -75,15 +75,15 @@ OlympusDifferenceDecoder::getDiff(BitStreamerMSB& bits) {
// Skip bytes used above or read bits
if (numHighBits == 12) {
bits.skipBitsNoFill(15);
numHighBits = 15 - nbits;
numHighBits = 15 - numLowBits;
// NOTE: numHighBits may be zero here, which BitStreamer does not like.
highBits = bits.getBitsNoFill(numHighBits + 1) >> 1;
} else {
bits.skipBitsNoFill(numHighBits + 1 + 3);
highBits = numHighBits;
}

carry[0] = (highBits << nbits) | bits.getBitsNoFill(nbits);
carry[0] = (highBits << numLowBits) | bits.getBitsNoFill(numLowBits);
int diff = (carry[0] ^ sign) + carry[1];
carry[1] = (diff * 3 + carry[1]) >> 5;
carry[2] = carry[0] > 16 ? 0 : carry[2] + 1;
Expand Down

0 comments on commit d4a8d09

Please sign in to comment.