Debian Codegraph @

src/upsampler/portable_simd.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * Copyright (c) 2023.
3 *
4 * This software is free software;
5 *
6 * You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license
7 */
8
•9 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::simdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core simd/::preluderust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/simd/prelude/::*;
10
11 const LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES.: usize = 16;
12 type Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V# = Simdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/Simd#<i16, LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES.>;
13
14 pub fn upsample_horizontal_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_horizontal_simd().(
15 input: &[i16],
16 in_near: &[i16],
17 in_far: &[i16],
18 scratch: &mut [i16],
19 output: &mut [i16],
20 ) {
21 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 2, output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
22 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). 2);
23
24 let len = input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
25
26 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().18 {
27 return superrust-analyzer cargo zune-jpeg 0.5.15 upsampler/::scalarrust-analyzer cargo zune-jpeg 0.5.15 upsampler/scalar/::upsample_horizontalrust-analyzer cargo zune-jpeg 0.5.15 upsampler/scalar/upsample_horizontal().(input, in_near, in_far, scratch, output);
28 }
29
30 // First two pixels
31 output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
32 output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = (input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().2;
33
34 let v_three = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::splatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]splat().(3);
35 let v_two = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::splatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]splat().(2);
36
37 let upsample16 = |input: &[i16; 18], output: &mut [i16; 32]| {
38 let v_prev = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]from_slice().(&input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
39 let v_curr = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]from_slice().(&input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
40 let v_next = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]from_slice().(&input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
41
42 let v_common = v_curr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul().v_three rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_two;
43
44 let v_even = (v_common rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_prev) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().2;
45 let v_odd = (v_common rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_next) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().2;
46
47 let (v_res_1, v_res_2) = v_even.interleaverust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/swizzle/impl#[`Simd<T, N>`]interleave().(v_odd);
48
49 v_res_1.copy_to_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]copy_to_slice().(&mut output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().);
50 v_res_2.copy_to_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]copy_to_slice().(&mut output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().LANESrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/LANES.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().);
51 };
52
53 for (input, output) in input
54 .windowsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]windows().(18)
55 .step_byrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#step_by().(16)
56 .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(32))
57 {
58 upsample16(input.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), output.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
59 }
60
61 // Upsample the remainder. This may have some overlap, but that's fine.
62 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest_input) = input.last_chunkrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk().::<18>() {
63 let end = output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2;
64 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest_output) = output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..last_chunk_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk_mut().::<32>() {
65 upsample16(rest_input, rest_output);
66 }
67 }
68
69 // Last two pixels.
70 output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = (3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Mul<Self>`]mul().input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i16][`Add<Self>`]add().2) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i16][`Shr<i32>`]shr().2;
71 output[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = input[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
72 }
73
74 pub fn upsample_vertical_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_vertical_simd().(
75 input: &[i16],
76 in_near: &[i16],
77 in_far: &[i16],
78 _scratch_space: &mut [i16],
79 output: &mut [i16],
80 ) {
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 2, output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(in_near.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(in_far.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
84
85 let len = input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
86
87 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().16 {
88 return superrust-analyzer cargo zune-jpeg 0.5.15 upsampler/::scalarrust-analyzer cargo zune-jpeg 0.5.15 upsampler/scalar/::upsample_verticalrust-analyzer cargo zune-jpeg 0.5.15 upsampler/scalar/upsample_vertical().(input, in_near, in_far, _scratch_space, output);
89 }
90
91 let middle = output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2;
92 let (out_top, out_bottom) = output.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(middle);
93
94 let v_three = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::splatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]splat().(3);
95 let v_two = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::splatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]splat().(2);
96
97 let upsample16 = |input: &[i16; 16],
98 in_near: &[i16; 16],
99 in_far: &[i16; 16],
100 out_top: &mut [i16; 16],
101 out_bottom: &mut [i16; 16]| {
102 let v_in = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`][`From<[T; N]>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().input);
103 let v_near = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`][`From<[T; N]>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().in_near);
104 let v_far = Vrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/V#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`][`From<[T; N]>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().in_far);
105
106 let v_common = v_in rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Mul<Self>`]mul().v_three rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_two;
107
108 let v_out_top = (v_common rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_near) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().2;
109 let v_out_bottom = (v_common rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/impl#[`Simd<i16, N>`][`Add<Self>`]add().v_far) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/ops/shift_scalar/impl#[`Simd<i16, N>`][`Shr<i16>`]shr().2;
110
111 v_out_top.copy_to_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]copy_to_slice().(out_top.as_mut_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_mut_slice().());
112 v_out_bottom.copy_to_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core core_simd/vector/impl#[`Simd<T, N>`]copy_to_slice().(out_bottom.as_mut_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`]as_mut_slice().());
113 };
114
115 let chunks = input
116 .chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16)
117 .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(in_near.chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16))
118 .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(in_far.chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(16))
119 .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(out_top.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(16))
120 .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(out_bottom.chunks_exact_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact_mut().(16));
121
122 for ((((input, in_near), in_far), out_top), out_bottom) in chunks {
123 upsample16(
124 input.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
125 in_near.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
126 in_far.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
127 out_top.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
128 out_bottom.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
129 );
130 }
131
132 // Upsample the remainder. This may have some overlap, but that's fine.
133 // Edition upgrade will fix this nested awfulness.
134 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(rest) = input.last_chunkrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk().::<16>() {
135 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( rest_near) = in_near.last_chunkrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk().::<16>() {
136 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( rest_far) = in_far.last_chunkrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk().::<16>() {
137 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( rest_top) = out_top.last_chunk_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk_mut().::<16>() {
138 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#( rest_bottom) = out_bottom.last_chunk_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last_chunk_mut().::<16>() {
139 upsample16(rest, rest_near, rest_far, rest_top, rest_bottom);
140 }
141 }
142 }
143 }
144 }
145 }
146
147 pub fn upsample_hv_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_hv_simd().(
148 input: &[i16],
149 in_near: &[i16],
150 in_far: &[i16],
151 scratch_space: &mut [i16],
152 output: &mut [i16],
153 ) {
154 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 4, output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
155
156 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 2 <= scratch_space.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
157 let scratch_space = &mut scratch_space[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#input.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().;
158
159
160 upsample_vertical_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_vertical_simd().(input, in_near, in_far, &mut [], scratch_space);
161
162 let scratch_half = scratch_space.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2;
163 let output_half = output.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().2;
164
165 let (scratch_top, scratch_bottom) = scratch_space.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(scratch_half);
166 let (out_top, out_bottom) = output.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_at_mut().(output_half);
167
168 let mut t = [0];
169 upsample_horizontal_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_horizontal_simd().(scratch_top, &[], &[], &mut t, out_top);
170 upsample_horizontal_simdrust-analyzer cargo zune-jpeg 0.5.15 upsampler/portable_simd/upsample_horizontal_simd().(scratch_bottom, &[], &[], &mut t, out_bottom);
171 }