/rust/registry/src/index.crates.io-1949cf8c6b5b557f/av-scenechange-0.14.1/src/data/sad.rs
Line | Count | Source |
1 | | #[cfg(asm_x86_64)] |
2 | | mod simd_x86; |
3 | | |
4 | | use rust::get_sad_internal; |
5 | | #[cfg(not(asm_x86_64))] |
6 | | use rust::*; |
7 | | #[cfg(asm_x86_64)] |
8 | | use simd_x86::*; |
9 | | use v_frame::{pixel::Pixel, plane::Plane}; |
10 | | |
11 | | use super::plane::PlaneRegion; |
12 | | use crate::cpu::CpuFeatureLevel; |
13 | | |
14 | | mod rust { |
15 | | use v_frame::{ |
16 | | pixel::{CastFromPrimitive, Pixel}, |
17 | | plane::Plane, |
18 | | }; |
19 | | |
20 | | use crate::{ |
21 | | data::plane::{Area, PlaneRegion, Rect}, |
22 | | CpuFeatureLevel, |
23 | | }; |
24 | | |
25 | 0 | pub(super) fn sad_plane_internal<T: Pixel>( |
26 | 0 | src: &Plane<T>, |
27 | 0 | dst: &Plane<T>, |
28 | 0 | _cpu: CpuFeatureLevel, |
29 | 0 | ) -> u64 { |
30 | 0 | assert_eq!(src.cfg.width, dst.cfg.width); |
31 | 0 | assert_eq!(src.cfg.height, dst.cfg.height); |
32 | | |
33 | 0 | src.rows_iter() |
34 | 0 | .zip(dst.rows_iter()) |
35 | 0 | .map(|(src, dst)| { |
36 | 0 | src.iter() |
37 | 0 | .zip(dst.iter()) |
38 | 0 | .map(|(&p1, &p2)| i32::cast_from(p1).abs_diff(i32::cast_from(p2))) Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u16>::{closure#0}::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u8>::{closure#0}::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<_>::{closure#0}::{closure#0} |
39 | 0 | .sum::<u32>() as u64 |
40 | 0 | }) Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u16>::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u8>::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<_>::{closure#0} |
41 | 0 | .sum() |
42 | 0 | } Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u16> Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<u8> Unexecuted instantiation: av_scenechange::data::sad::rust::sad_plane_internal::<_> |
43 | | |
44 | 0 | pub fn get_sad_internal<T: Pixel>( |
45 | 0 | plane_org: &PlaneRegion<'_, T>, |
46 | 0 | plane_ref: &PlaneRegion<'_, T>, |
47 | 0 | w: usize, |
48 | 0 | h: usize, |
49 | 0 | _bit_depth: usize, |
50 | 0 | _cpu: CpuFeatureLevel, |
51 | 0 | ) -> u32 { |
52 | 0 | debug_assert!(w <= 128 && h <= 128); |
53 | 0 | let plane_org = plane_org.subregion(Area::Rect(Rect { |
54 | 0 | x: 0, |
55 | 0 | y: 0, |
56 | 0 | width: w, |
57 | 0 | height: h, |
58 | 0 | })); |
59 | 0 | let plane_ref = plane_ref.subregion(Area::Rect(Rect { |
60 | 0 | x: 0, |
61 | 0 | y: 0, |
62 | 0 | width: w, |
63 | 0 | height: h, |
64 | 0 | })); |
65 | | |
66 | 0 | plane_org |
67 | 0 | .rows_iter() |
68 | 0 | .zip(plane_ref.rows_iter()) |
69 | 0 | .map(|(src, dst)| { |
70 | 0 | src.iter() |
71 | 0 | .zip(dst) |
72 | 0 | .map(|(&p1, &p2)| i32::cast_from(p1).abs_diff(i32::cast_from(p2))) Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u16>::{closure#0}::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u8>::{closure#0}::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<_>::{closure#0}::{closure#0} |
73 | 0 | .sum::<u32>() |
74 | 0 | }) Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u16>::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u8>::{closure#0}Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<_>::{closure#0} |
75 | 0 | .sum() |
76 | 0 | } Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u16> Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<u8> Unexecuted instantiation: av_scenechange::data::sad::rust::get_sad_internal::<_> |
77 | | } |
78 | | |
79 | | /// Compute the sum of absolute differences (SADs) on 2 rows of pixels |
80 | | /// |
81 | | /// This differs from other SAD functions in that it operates over a row |
82 | | /// (or line) of unknown length rather than a `PlaneRegion<T>`. |
83 | 0 | pub(crate) fn sad_plane<T: Pixel>(src: &Plane<T>, dst: &Plane<T>, cpu: CpuFeatureLevel) -> u64 { |
84 | 0 | sad_plane_internal(src, dst, cpu) |
85 | 0 | } Unexecuted instantiation: av_scenechange::data::sad::sad_plane::<u16> Unexecuted instantiation: av_scenechange::data::sad::sad_plane::<u8> Unexecuted instantiation: av_scenechange::data::sad::sad_plane::<_> |
86 | | |
87 | 0 | pub(crate) fn get_sad<T: Pixel>( |
88 | 0 | plane_org: &PlaneRegion<'_, T>, |
89 | 0 | plane_ref: &PlaneRegion<'_, T>, |
90 | 0 | w: usize, |
91 | 0 | h: usize, |
92 | 0 | bit_depth: usize, |
93 | 0 | cpu: CpuFeatureLevel, |
94 | 0 | ) -> u32 { |
95 | 0 | get_sad_internal(plane_org, plane_ref, w, h, bit_depth, cpu) |
96 | 0 | } Unexecuted instantiation: av_scenechange::data::sad::get_sad::<u16> Unexecuted instantiation: av_scenechange::data::sad::get_sad::<u8> Unexecuted instantiation: av_scenechange::data::sad::get_sad::<_> |