diff --git a/RawSpeed/SrwDecoder.cpp b/RawSpeed/SrwDecoder.cpp index fa46499..1aff689 100644 --- a/RawSpeed/SrwDecoder.cpp +++ b/RawSpeed/SrwDecoder.cpp @@ -141,7 +141,7 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw ) // First we decode even pixels for (int c = 0; c < 16; c += 2) { int b = len[(c >> 3)]; - int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b)); + int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0; img[c] = adj + img_up[c]; } // Now we decode odd pixels @@ -149,7 +149,7 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw ) // is beyond me, it will hurt compression a deal. for (int c = 1; c < 16; c += 2) { int b = len[2 | (c >> 3)]; - int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b)); + int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0; img[c] = adj + img_up2[c]; } } else { @@ -158,14 +158,14 @@ void SrwDecoder::decodeCompressed( TiffIFD* raw ) int pred_left = x ? img[-2] : 128; for (int c = 0; c < 16; c += 2) { int b = len[(c >> 3)]; - int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b)); + int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0; img[c] = adj + pred_left; } // Now we decode odd pixels pred_left = x ? img[-1] : 128; for (int c = 1; c < 16; c += 2) { int b = len[2 | (c >> 3)]; - int32 adj = ((int32) bits.getBits(b) << (32-b) >> (32-b)); + int32 adj = b > 0 ? ((int32) bits.getBits(b) << (32-b) >> (32-b)) :0; img[c] = adj + pred_left; } }