Skip to content

Commit

Permalink
SAO: fix illegal table access when input pixel is out of range, part 2 (
Browse files Browse the repository at this point in the history
fixes #351)
  • Loading branch information
farindk committed Jan 24, 2023
1 parent ad29169 commit 677342a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libde265/sao.cc
Expand Up @@ -252,7 +252,14 @@ void apply_sao_internal(de265_image* img, int xCtb,int yCtb,
if (bandShift >= 8) {
bandIdx = 0;
} else {
bandIdx = bandTable[ in_img[xC+i+(yC+j)*in_stride]>>bandShift ];
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) {
Expand Down

0 comments on commit 677342a

Please sign in to comment.