@@ -31,14 +31,12 @@ pub(crate) mod rust {
3131 /// Compute the sum of absolute differences over a block.
3232 /// w and h can be at most 128, the size of the largest block.
3333 pub fn get_sad < T : Pixel > (
34- plane_org : & PlaneRegion < ' _ , T > , plane_ref : & PlaneRegion < ' _ , T > , w : usize ,
35- h : usize , _bit_depth : usize , _cpu : CpuFeatureLevel ,
34+ plane_org : & PlaneRegion < ' _ , T > , plane_ref : & PlaneRegion < ' _ , T > ,
35+ _bit_depth : usize , _cpu : CpuFeatureLevel ,
3636 ) -> u32 {
37- debug_assert ! ( w <= 128 && h <= 128 ) ;
38- let plane_org =
39- plane_org. subregion ( Area :: Rect { x : 0 , y : 0 , width : w, height : h } ) ;
40- let plane_ref =
41- plane_ref. subregion ( Area :: Rect { x : 0 , y : 0 , width : w, height : h } ) ;
37+ debug_assert ! (
38+ plane_org. rect( ) . width <= 128 && plane_org. rect( ) . height <= 128
39+ ) ;
4240
4341 plane_org
4442 . rows_iter ( )
@@ -156,11 +154,12 @@ pub(crate) mod rust {
156154 /// revert to sad on edges when these transforms do not fit into w and h.
157155 /// 4x4 transforms instead of 8x8 transforms when width or height < 8.
158156 pub fn get_satd < T : Pixel > (
159- plane_org : & PlaneRegion < ' _ , T > , plane_ref : & PlaneRegion < ' _ , T > , w : usize ,
160- h : usize , _bit_depth : usize , _cpu : CpuFeatureLevel ,
157+ plane_org : & PlaneRegion < ' _ , T > , plane_ref : & PlaneRegion < ' _ , T > ,
158+ _bit_depth : usize , _cpu : CpuFeatureLevel ,
161159 ) -> u32 {
160+ let w = plane_org. rect ( ) . width ;
161+ let h = plane_org. rect ( ) . height ;
162162 assert ! ( w <= 128 && h <= 128 ) ;
163- assert ! ( plane_org. rect( ) . width >= w && plane_org. rect( ) . height >= h) ;
164163 assert ! ( plane_ref. rect( ) . width >= w && plane_ref. rect( ) . height >= h) ;
165164
166165 // Size of hadamard transform should be 4x4 or 8x8
@@ -186,9 +185,7 @@ pub(crate) mod rust {
186185
187186 // Revert to sad on edge blocks (frame edges)
188187 if chunk_w != size || chunk_h != size {
189- sum += get_sad (
190- & chunk_org, & chunk_ref, chunk_w, chunk_h, _bit_depth, _cpu,
191- ) as u64 ;
188+ sum += get_sad ( & chunk_org, & chunk_ref, _bit_depth, _cpu) as u64 ;
192189 continue ;
193190 }
194191
@@ -443,7 +440,7 @@ pub mod test {
443440 let ( input_plane, rec_plane) = setup_planes :: < T > ( ) ;
444441
445442 for ( w, h, distortion) in blocks {
446- let area = Area :: StartingAt { x : 32 , y : 40 } ;
443+ let area = Area :: Rect { x : 32 , y : 40 , width : w , height : h } ;
447444
448445 let input_region = input_plane. region ( area) ;
449446 let rec_region = rec_plane. region ( area) ;
@@ -453,8 +450,6 @@ pub mod test {
453450 get_sad(
454451 & input_region,
455452 & rec_region,
456- w,
457- h,
458453 bit_depth,
459454 CpuFeatureLevel :: default ( )
460455 )
@@ -502,7 +497,7 @@ pub mod test {
502497 let ( input_plane, rec_plane) = setup_planes :: < T > ( ) ;
503498
504499 for ( w, h, distortion) in blocks {
505- let area = Area :: StartingAt { x : 32 , y : 40 } ;
500+ let area = Area :: Rect { x : 32 , y : 40 , width : w , height : h } ;
506501
507502 let input_region = input_plane. region ( area) ;
508503 let rec_region = rec_plane. region ( area) ;
@@ -512,8 +507,6 @@ pub mod test {
512507 get_satd(
513508 & input_region,
514509 & rec_region,
515- w,
516- h,
517510 bit_depth,
518511 CpuFeatureLevel :: default ( )
519512 )
0 commit comments