unsafe fn cdef_filter_block(dst: &mut [u16], dstride: isize, input: &[u16],
                            istride: isize, pri_strength: i32, sec_strength: i32,
                            dir: usize, pri_damping: i32, sec_damping: i32,
                            xsize: isize, ysize: isize, coeff_shift: i32) {

    let cdef_pri_taps = [[4, 2], [3, 3]];
    let cdef_sec_taps = [[2, 1], [2, 1]];
    let pri_taps = cdef_pri_taps[((pri_strength >> coeff_shift) & 1) as usize];
    let sec_taps = cdef_sec_taps[((pri_strength >> coeff_shift) & 1) as usize];
    let cdef_directions = [[-1 * istride + 1, -2 * istride + 2 ],
                           [ 0 * istride + 1, -1 * istride + 2 ],
                           [ 0 * istride + 1,  0 * istride + 2 ],
                           [ 0 * istride + 1,  1 * istride + 2 ],
                           [ 1 * istride + 1,  2 * istride + 2 ],
                           [ 1 * istride + 0,  2 * istride + 1 ],
                           [ 1 * istride + 0,  2 * istride + 0 ],
                           [ 1 * istride + 0,  2 * istride - 1 ]];
    assert!(input.len() >= ((ysize + 3) * istride + xsize + 4) as usize);
    assert!(dst.len() >= ((ysize - 1) * dstride + xsize) as usize);
    for i in 0..ysize {
        for j in 0..xsize {
            let ptr_in = input.as_ptr().offset((i + 2) * istride + j + 2);
            let ptr_out = dst.as_mut_ptr().offset(i * dstride + j);
            let x = *ptr_in;
            let mut sum = 0 as i32;
            let mut max = x;
            let mut min = x;
            for k in 0..2usize {
                let p0 = *ptr_in.offset(cdef_directions[dir][k]);
                let p1 = *ptr_in.offset(-cdef_directions[dir][k]);
                sum += pri_taps[k] * constrain(p0 as i32 - x as i32, pri_strength, pri_damping);
                sum += pri_taps[k] * constrain(p1 as i32 - x as i32, pri_strength, pri_damping);
                if p0 != CDEF_VERY_LARGE {
                    max = cmp::max(p0, max);
                }
                if p1 != CDEF_VERY_LARGE {
                    max = cmp::max(p1, max);
                }
                min = cmp::min(p0, min);
                min = cmp::min(p1, min);
                let s0 = *ptr_in.offset(cdef_directions[(dir + 2) & 7][k]);
                let s1 = *ptr_in.offset(-cdef_directions[(dir + 2) & 7][k]);
                let s2 = *ptr_in.offset(cdef_directions[(dir + 6) & 7][k]);
                let s3 = *ptr_in.offset(-cdef_directions[(dir + 6) & 7][k]);
                if s0 != CDEF_VERY_LARGE {
                    max = cmp::max(s0, max);
                }
                if s1 != CDEF_VERY_LARGE {
                    max = cmp::max(s1, max);
                }
                if s2 != CDEF_VERY_LARGE {
                    max = cmp::max(s2, max);
                }
                if s3 != CDEF_VERY_LARGE {
                    max = cmp::max(s3, max);
                }
                min = cmp::min(s0, min);
                min = cmp::min(s1, min);
                min = cmp::min(s2, min);
                min = cmp::min(s3, min);
                sum += sec_taps[k] * constrain(s0 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s1 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s2 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s3 as i32 - x as i32, sec_strength, sec_damping);
            }
            *ptr_out = clamp(x as i32 + ((8 + sum - (sum < 0) as i32) >> 4), min as i32,
                             max as i32) as u16;
        }
    }
}
// Unlike the AOM code, our block addressing points to the UL corner
// of the 2-pixel padding around the block, not the block itself.
// The destination is unpadded.
Unlike the AOM code, our block addressing points to the UL corner
of the 2-pixel padding around the block, not the block itself.
The destination is unpadded.
Unlike the AOM code our block addressing points to the UL corner of the 2 - pixel padding around the block not the block itself . The destination is unpadded .
unsafe fn cdef_filter_block(dst: &mut [u16], dstride: isize, input: &[u16],
                            istride: isize, pri_strength: i32, sec_strength: i32,
                            dir: usize, pri_damping: i32, sec_damping: i32,
                            xsize: isize, ysize: isize, coeff_shift: i32) {
    let cdef_pri_taps = [[4, 2], [3, 3]];
    let cdef_sec_taps = [[2, 1], [2, 1]];
    let pri_taps = cdef_pri_taps[((pri_strength >> coeff_shift) & 1) as usize];
    let sec_taps = cdef_sec_taps[((pri_strength >> coeff_shift) & 1) as usize];
    let cdef_directions = [[-1 * istride + 1, -2 * istride + 2 ],
                           [ 0 * istride + 1, -1 * istride + 2 ],
                           [ 0 * istride + 1,  0 * istride + 2 ],
                           [ 0 * istride + 1,  1 * istride + 2 ],
                           [ 1 * istride + 1,  2 * istride + 2 ],
                           [ 1 * istride + 0,  2 * istride + 1 ],
                           [ 1 * istride + 0,  2 * istride + 0 ],
                           [ 1 * istride + 0,  2 * istride - 1 ]];
    assert!(input.len() >= ((ysize + 3) * istride + xsize + 4) as usize);
    assert!(dst.len() >= ((ysize - 1) * dstride + xsize) as usize);
    for i in 0..ysize {
        for j in 0..xsize {
            let ptr_in = input.as_ptr().offset((i + 2) * istride + j + 2);
            let ptr_out = dst.as_mut_ptr().offset(i * dstride + j);
            let x = *ptr_in;
            let mut sum = 0 as i32;
            let mut max = x;
            let mut min = x;
            for k in 0..2usize {
                let p0 = *ptr_in.offset(cdef_directions[dir][k]);
                let p1 = *ptr_in.offset(-cdef_directions[dir][k]);
                sum += pri_taps[k] * constrain(p0 as i32 - x as i32, pri_strength, pri_damping);
                sum += pri_taps[k] * constrain(p1 as i32 - x as i32, pri_strength, pri_damping);
                if p0 != CDEF_VERY_LARGE {
                    max = cmp::max(p0, max);
                }
                if p1 != CDEF_VERY_LARGE {
                    max = cmp::max(p1, max);
                }
                min = cmp::min(p0, min);
                min = cmp::min(p1, min);
                let s0 = *ptr_in.offset(cdef_directions[(dir + 2) & 7][k]);
                let s1 = *ptr_in.offset(-cdef_directions[(dir + 2) & 7][k]);
                let s2 = *ptr_in.offset(cdef_directions[(dir + 6) & 7][k]);
                let s3 = *ptr_in.offset(-cdef_directions[(dir + 6) & 7][k]);
                if s0 != CDEF_VERY_LARGE {
                    max = cmp::max(s0, max);
                }
                if s1 != CDEF_VERY_LARGE {
                    max = cmp::max(s1, max);
                }
                if s2 != CDEF_VERY_LARGE {
                    max = cmp::max(s2, max);
                }
                if s3 != CDEF_VERY_LARGE {
                    max = cmp::max(s3, max);
                }
                min = cmp::min(s0, min);
                min = cmp::min(s1, min);
                min = cmp::min(s2, min);
                min = cmp::min(s3, min);
                sum += sec_taps[k] * constrain(s0 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s1 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s2 as i32 - x as i32, sec_strength, sec_damping);
                sum += sec_taps[k] * constrain(s3 as i32 - x as i32, sec_strength, sec_damping);
            }
            *ptr_out = clamp(x as i32 + ((8 + sum - (sum < 0) as i32) >> 4), min as i32,
                             max as i32) as u16;
        }
    }
}
unsafe fn cdef_filter_block ( dst : & mut [ u16 ] , dstride : isize , input : & [ u16 ] , istride : isize , pri_strength : i32 , sec_strength : i32 , dir : usize , pri_damping : i32 , sec_damping : i32 , xsize : isize , ysize : isize , coeff_shift : i32 ) { let cdef_pri_taps = [ [ 4 , 2 ] , [ 3 , 3 ] ] ; let cdef_sec_taps = [ [ 2 , 1 ] , [ 2 , 1 ] ] ; let pri_taps = cdef_pri_taps [ ( ( pri_strength >> coeff_shift ) & 1 ) as usize ] ; let sec_taps = cdef_sec_taps [ ( ( pri_strength >> coeff_shift ) & 1 ) as usize ] ; let cdef_directions = [ [ - 1 * istride + 1 , - 2 * istride + 2 ] , [ 0 * istride + 1 , - 1 * istride + 2 ] , [ 0 * istride + 1 , 0 * istride + 2 ] , [ 0 * istride + 1 , 1 * istride + 2 ] , [ 1 * istride + 1 , 2 * istride + 2 ] , [ 1 * istride + 0 , 2 * istride + 1 ] , [ 1 * istride + 0 , 2 * istride + 0 ] , [ 1 * istride + 0 , 2 * istride - 1 ] ] ; assert ! ( input len ( ) ( ( ysize 3 ) istride xsize 4 ) as usize ) ; assert ! ( dst len ( ) ( ( ysize 1 ) dstride xsize ) as usize ) ; for i in 0 .. ysize { for j in 0 .. xsize { let ptr_in = input . as_ptr ( ) . offset ( ( i + 2 ) * istride + j + 2 ) ; let ptr_out = dst . as_mut_ptr ( ) . offset ( i * dstride + j ) ; let x = * ptr_in ; let mut sum = 0 as i32 ; let mut max = x ; let mut min = x ; for k in 0 .. 2usize { let p0 = * ptr_in . offset ( cdef_directions [ dir ] [ k ] ) ; let p1 = * ptr_in . offset ( - cdef_directions [ dir ] [ k ] ) ; sum += pri_taps [ k ] * constrain ( p0 as i32 - x as i32 , pri_strength , pri_damping ) ; sum += pri_taps [ k ] * constrain ( p1 as i32 - x as i32 , pri_strength , pri_damping ) ; if p0 != CDEF_VERY_LARGE { max = cmp :: max ( p0 , max ) ; } if p1 != CDEF_VERY_LARGE { max = cmp :: max ( p1 , max ) ; } min = cmp :: min ( p0 , min ) ; min = cmp :: min ( p1 , min ) ; let s0 = * ptr_in . offset ( cdef_directions [ ( dir + 2 ) & 7 ] [ k ] ) ; let s1 = * ptr_in . offset ( - cdef_directions [ ( dir + 2 ) & 7 ] [ k ] ) ; let s2 = * ptr_in . offset ( cdef_directions [ ( dir + 6 ) & 7 ] [ k ] ) ; let s3 = * ptr_in . offset ( - cdef_directions [ ( dir + 6 ) & 7 ] [ k ] ) ; if s0 != CDEF_VERY_LARGE { max = cmp :: max ( s0 , max ) ; } if s1 != CDEF_VERY_LARGE { max = cmp :: max ( s1 , max ) ; } if s2 != CDEF_VERY_LARGE { max = cmp :: max ( s2 , max ) ; } if s3 != CDEF_VERY_LARGE { max = cmp :: max ( s3 , max ) ; } min = cmp :: min ( s0 , min ) ; min = cmp :: min ( s1 , min ) ; min = cmp :: min ( s2 , min ) ; min = cmp :: min ( s3 , min ) ; sum += sec_taps [ k ] * constrain ( s0 as i32 - x as i32 , sec_strength , sec_damping ) ; sum += sec_taps [ k ] * constrain ( s1 as i32 - x as i32 , sec_strength , sec_damping ) ; sum += sec_taps [ k ] * constrain ( s2 as i32 - x as i32 , sec_strength , sec_damping ) ; sum += sec_taps [ k ] * constrain ( s3 as i32 - x as i32 , sec_strength , sec_damping ) ; } * ptr_out = clamp ( x as i32 + ( ( 8 + sum - ( sum < 0 ) as i32 ) >> 4 ) , min as i32 , max as i32 ) as u16 ; } } }
Unlike the AOM code, our block addressing points to the UL corner
of the 2-pixel padding around the block, not the block itself.
Unlike the AOM code our block addressing points to the UL corner of the 2 - pixel padding around the block not the block itself .
dst
&mut [u16]
dstride
isize
input
&[u16]
istride
isize
pri_strength
i32
sec_strength
i32
dir
usize
pri_damping
i32
sec_damping
i32
xsize
isize
ysize
isize
coeff_shift
i32