continue;
}
- int bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
-
// Shifts are a strange thing. On x86, >>x actually computes >>(x%64).
// So we have to take care of large bandShifts.
- if (bandShift>=8) { bandIdx=0; }
+ int bandIdx;
+ if (bandShift >= 8) {
+ bandIdx = 0;
+ } else {
+ int pixel = in_img[xC+i+(yC+j)*in_stride];
+
+ // Note: the input pixel value should never exceed the valid range, but it seems that it still does,
+ // maybe when there was a decoding error and the pixels have not been filled in correctly.
+ // Thus, we have to limit the pixel range to ensure that we have no illegal table access.
+ pixel = Clip3(0,maxPixelValue, pixel);
+
+ bandIdx = bandTable[ pixel>>bandShift ];
+ }
if (bandIdx>0) {
int offset = saoinfo->saoOffsetVal[cIdx][bandIdx-1];
for (int j=0;j<ctbH;j++)
for (int i=0;i<ctbW;i++) {
- int bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
-
// see above
- if (bandShift>=8) { bandIdx=0; }
+ int bandIdx;
+ if (bandShift >= 8) {
+ bandIdx = 0;
+ } else {
+ bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
+ }
if (bandIdx>0) {
int offset = saoinfo->saoOffsetVal[cIdx][bandIdx-1];