Coverage Report

Created: 2025-07-11 07:25

/rust/registry/src/index.crates.io-6f17d22bba15001f/rav1e-0.7.1/src/sad_plane.rs
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) 2021-2022, The rav1e contributors. All rights reserved
2
//
3
// This source code is subject to the terms of the BSD 2 Clause License and
4
// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
5
// was not distributed with this source code in the LICENSE file, you can
6
// obtain it at www.aomedia.org/license/software. If the Alliance for Open
7
// Media Patent License 1.0 was not distributed with this source code in the
8
// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
9
10
cfg_if::cfg_if! {
11
  if #[cfg(nasm_x86_64)] {
12
    use crate::asm::x86::sad_plane::*;
13
  } else {
14
    use self::rust::*;
15
  }
16
}
17
18
use v_frame::plane::Plane;
19
20
use crate::cpu_features::CpuFeatureLevel;
21
use crate::util::{CastFromPrimitive, Pixel};
22
23
pub(crate) mod rust {
24
  use super::*;
25
  use crate::cpu_features::CpuFeatureLevel;
26
27
  #[inline]
28
0
  pub(crate) fn sad_plane_internal<T: Pixel>(
29
0
    src: &Plane<T>, dst: &Plane<T>, _cpu: CpuFeatureLevel,
30
0
  ) -> u64 {
31
0
    debug_assert!(src.cfg.width == dst.cfg.width);
32
0
    debug_assert!(src.cfg.height == dst.cfg.height);
33
34
0
    src
35
0
      .rows_iter()
36
0
      .zip(dst.rows_iter())
37
0
      .map(|(src, dst)| {
38
0
        src
39
0
          .iter()
40
0
          .zip(dst.iter())
41
0
          .map(|(&p1, &p2)| i32::cast_from(p1).abs_diff(i32::cast_from(p2)))
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u16>::{closure#0}::{closure#0}
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u8>::{closure#0}::{closure#0}
42
0
          .sum::<u32>() as u64
43
0
      })
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u16>::{closure#0}
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u8>::{closure#0}
44
0
      .sum()
45
0
  }
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u16>
Unexecuted instantiation: rav1e::sad_plane::rust::sad_plane_internal::<u8>
46
}
47
48
/// Compute the sum of absolute differences (SADs) on 2 rows of pixels
49
///
50
/// This differs from other SAD functions in that it operates over a row
51
/// (or line) of unknown length rather than a `PlaneRegion<T>`.
52
0
pub(crate) fn sad_plane<T: Pixel>(
53
0
  src: &Plane<T>, dst: &Plane<T>, cpu: CpuFeatureLevel,
54
0
) -> u64 {
55
0
  sad_plane_internal(src, dst, cpu)
56
0
}
Unexecuted instantiation: rav1e::sad_plane::sad_plane::<u16>
Unexecuted instantiation: rav1e::sad_plane::sad_plane::<u8>