Commit e06eb585 authored by Yushin Cho's avatar Yushin Cho Committed by Yushin Cho
Browse files

Add assert in cdef_find_dir() for CDEF

The assert checks whether an input pixel value in cdef_find_dir()
is within a valid range, for ex, 0 <= (pixel_value >> bitdepth) <= 255.
parent 87909f1e
...@@ -43,6 +43,7 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) -> ...@@ -43,6 +43,7 @@ fn cdef_find_dir(img: &[u16], stride: usize, var: &mut i32, coeff_shift: i32) ->
for j in 0..8 { for j in 0..8 {
// We subtract 128 here to reduce the maximum range of the squared // We subtract 128 here to reduce the maximum range of the squared
// partial sums. // partial sums.
debug_assert!((img[i * stride + j] >> coeff_shift) <= 255);
let x = (img[i * stride + j] as i32 >> coeff_shift) - 128; let x = (img[i * stride + j] as i32 >> coeff_shift) - 128;
partial[0][i + j] += x; partial[0][i + j] += x;
partial[1][i + j / 2] += x; partial[1][i + j / 2] += x;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment