/*
* Copyright © 2018 , VideoLAN and dav1d authors
* Copyright © 2018 , Martin Storsjo
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are met :
*
* 1 . Redistributions of source code must retain the above copyright notice , this
* list of conditions and the following disclaimer .
*
* 2 . Redistributions in binary form must reproduce the above copyright notice ,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND
* ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES
* ( INCLUDING , BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ;
* LOSS OF USE , DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
#include "src/arm/asm.S"
#include "util.S"
// Series of LUTs for efficiently computing sgr's 1 - x/(x+1) table.
// In the comments, let RefTable denote the original, reference table.
const x_by_x_tables
// RangeMins
//
// Min(RefTable[i*8 :i*8 +8 ])
// First two values are zeroed.
//
// Lookup using RangeMins[(x >> 3 )]
.byte 0 , 0 , 11 , 8 , 6 , 5 , 5 , 4 , 4 , 3 , 3 , 3 , 2 , 2 , 2 , 2
.byte 2 , 2 , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0
// DiffMasks
//
// This contains a bit pattern, indicating at which index positions the value of RefTable changes. For each range
// in the RangeMins table (covering 8 RefTable entries), we have one byte; each bit indicates whether the value of
// RefTable changes at that particular index.
// Using popcount, we can integrate the diff bit field. By shifting away bits in a byte, we can refine the range of
// the integral. Finally, adding the integral to RangeMins[(x>>3 )] reconstructs RefTable (for x > 15 ).
//
// Lookup using DiffMasks[(x >> 3 )]
.byte 0 x00, 0 x00, 0 xD4, 0 x44
.byte 0 x42, 0 x04, 0 x00, 0 x00
.byte 0 x00, 0 x80, 0 x00, 0 x00
.byte 0 x04, 0 x00, 0 x00, 0 x00
.byte 0 x00, 0 x00, 0 x00, 0 x00
.byte 0 x00, 0 x40, 0 x00, 0 x00
.byte 0 x00, 0 x00, 0 x00, 0 x00
.byte 0 x00, 0 x00, 0 x00, 0 x02
// Binary form:
// 0 b00000000, 0 b00000000, 0 b11010100, 0 b01000100
// 0 b01000010, 0 b00000100, 0 b00000000, 0 b00000000
// 0 b00000000, 0 b10000000, 0 b00000000, 0 b00000000
// 0 b00000100, 0 b00000000, 0 b00000000, 0 b00000000
// 0 b00000000, 0 b00000000, 0 b00000000, 0 b00000000
// 0 b00000000, 0 b01000000, 0 b00000000, 0 b00000000
// 0 b00000000, 0 b00000000, 0 b00000000, 0 b00000000
// 0 b00000000, 0 b00000000, 0 b00000000, 0 b00000010
// RefLo
//
// RefTable[0 :16 ]
// i.e. First 16 elements of the original table.
// Add to the sum obtained in the rest of the other lut logic to include the first 16 bytes of RefTable.
//
// Lookup using RangeMins[x] (tbl will replace x > 15 with 0 )
.byte 255 , 128 , 85 , 64 , 51 , 43 , 37 , 32 , 28 , 26 , 23 , 21 , 20 , 18 , 17 , 16
// Pseudo assembly
//
// hi_bits = x >> 3
// tbl ref, {RefLo}, x
// tbl diffs, {DiffMasks[0 :16 ], DiffMasks[16 :32 ]}, hi_bits
// tbl min, {RangeMins[0 :16 ], RangeMins[16 :32 ]}, hi_bits
// lo_bits = x & 0 x7
// diffs = diffs << lo_bits
// ref = ref + min
// integral = popcnt(diffs)
// ref = ref + integral
// return ref
endconst
// void dav1d_sgr_box3_vert_neon(int32_t **sumsq, int16_t **sum,
// int32_t *AA, int16_t *BB,
// const int w, const int s,
// const int bitdepth_max);
function sgr_box3_vert_neon, export=1
stp d8, d9, [sp, #-0 x40]!
stp d10, d11, [sp, #0 x10]
stp d12, d13, [sp, #0 x20]
stp d14, d15, [sp, #0 x30]
add w4, w4, #2
clz w9, w6 // bitdepth_max
dup v28.4 s, w5 // strength
ldp x5, x6, [x0]
ldr x0, [x0, #16 ]
ldp x7, x8, [x1]
ldr x1, [x1, #16 ]
movi v31.4 s, #9 // n
sub w9, w9, #24 // -bitdepth_min_8
movrel x12, x_by_x_tables
mov w13, #455 // one_by_x
ld1 {v24.16 b, v25.16 b, v26.16 b, v27.16 b}, [x12] // RangeMins, DiffMasks
movi v22.16 b, #0 x7
ldr q23, [x12, #64 ] //RefLo
dup v6.8 h, w9 // -bitdepth_min_8
saddl v7.4 s, v6.4 h, v6.4 h // -2 *bitdepth_min_8
dup v30.4 s, w13 // one_by_x
ld1 {v8.4 s, v9.4 s, v10.4 s, v11.4 s}, [x5], #64
ld1 {v12.4 s, v13.4 s, v14.4 s, v15.4 s}, [x6], #64
ld1 {v16.4 s, v17.4 s, v18.4 s, v19.4 s}, [x0], #64
ld1 {v20.8 h, v21.8 h}, [x8], #32
ld1 {v0.8 h, v1.8 h}, [x7], #32
1 :
ld1 {v2.8 h, v3.8 h}, [x1], #32
add v8.4 s, v8.4 s, v12.4 s
add v9.4 s, v9.4 s, v13.4 s
add v10.4 s, v10.4 s, v14.4 s
add v11.4 s, v11.4 s, v15.4 s
add v0.8 h, v0.8 h, v20.8 h
add v1.8 h, v1.8 h, v21.8 h
add v16.4 s, v16.4 s, v8.4 s
add v17.4 s, v17.4 s, v9.4 s
add v18.4 s, v18.4 s, v10.4 s
add v19.4 s, v19.4 s, v11.4 s
add v4.8 h, v2.8 h, v0.8 h
add v5.8 h, v3.8 h, v1.8 h
srshl v16.4 s, v16.4 s, v7.4 s
srshl v17.4 s, v17.4 s, v7.4 s
srshl v18.4 s, v18.4 s, v7.4 s
srshl v19.4 s, v19.4 s, v7.4 s
srshl v9.8 h, v4.8 h, v6.8 h
srshl v13.8 h, v5.8 h, v6.8 h
mul v16.4 s, v16.4 s, v31.4 s // a * n
mul v17.4 s, v17.4 s, v31.4 s // a * n
mul v18.4 s, v18.4 s, v31.4 s // a * n
mul v19.4 s, v19.4 s, v31.4 s // a * n
umull v8.4 s, v9.4 h, v9.4 h // b * b
umull2 v9.4 s, v9.8 h, v9.8 h // b * b
umull v12.4 s, v13.4 h, v13.4 h // b * b
umull2 v13.4 s, v13.8 h, v13.8 h // b * b
uqsub v16.4 s, v16.4 s, v8.4 s // imax(a * n - b * b, 0 )
uqsub v17.4 s, v17.4 s, v9.4 s // imax(a * n - b * b, 0 )
uqsub v18.4 s, v18.4 s, v12.4 s // imax(a * n - b * b, 0 )
uqsub v19.4 s, v19.4 s, v13.4 s // imax(a * n - b * b, 0 )
mul v16.4 s, v16.4 s, v28.4 s // p * s
mul v17.4 s, v17.4 s, v28.4 s // p * s
mul v18.4 s, v18.4 s, v28.4 s // p * s
mul v19.4 s, v19.4 s, v28.4 s // p * s
uqshrn v16.4 h, v16.4 s, #16
uqshrn2 v16.8 h, v17.4 s, #16
uqshrn v18.4 h, v18.4 s, #16
uqshrn2 v18.8 h, v19.4 s, #16
uqrshrn v1.8 b, v16.8 h, #4 // imin(z, 255 )
uqrshrn2 v1.16 b, v18.8 h, #4 // imin(z, 255 )
ld1 {v16.4 s, v17.4 s}, [x0], #32
subs w4, w4, #16
ushr v0.16 b, v1.16 b, #3
ld1 {v8.4 s, v9.4 s}, [x5], #32
tbl v2.16 b, {v26.16 b, v27.16 b}, v0.16 b // RangeMins
tbl v0.16 b, {v24.16 b, v25.16 b}, v0.16 b // DiffMasks
tbl v3.16 b, {v23.16 b}, v1.16 b // RefLo
and v1.16 b, v1.16 b, v22.16 b
ld1 {v12.4 s, v13.4 s}, [x6], #32
ushl v1.16 b, v2.16 b, v1.16 b
ld1 {v20.8 h, v21.8 h}, [x8], #32
add v3.16 b, v3.16 b, v0.16 b
cnt v1.16 b, v1.16 b
ld1 {v18.4 s, v19.4 s}, [x0], #32
add v3.16 b, v3.16 b, v1.16 b
ld1 {v10.4 s, v11.4 s}, [x5], #32
uxtl v0.8 h, v3.8 b // x
uxtl2 v1.8 h, v3.16 b // x
ld1 {v14.4 s, v15.4 s}, [x6], #32
umull v2.4 s, v0.4 h, v4.4 h // x * BB[i]
umull2 v3.4 s, v0.8 h, v4.8 h // x * BB[i]
umull v4.4 s, v1.4 h, v5.4 h // x * BB[i]
umull2 v5.4 s, v1.8 h, v5.8 h // x * BB[i]
mul v2.4 s, v2.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
mul v3.4 s, v3.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
mul v4.4 s, v4.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
mul v5.4 s, v5.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
st1 {v0.8 h, v1.8 h}, [x3], #32
ld1 {v0.8 h, v1.8 h}, [x7], #32
srshr v2.4 s, v2.4 s, #12 // AA[i]
srshr v3.4 s, v3.4 s, #12 // AA[i]
srshr v4.4 s, v4.4 s, #12 // AA[i]
srshr v5.4 s, v5.4 s, #12 // AA[i]
st1 {v2.4 s, v3.4 s, v4.4 s, v5.4 s}, [x2], #64
b.gt 1 b
ldp d14, d15, [sp, #0 x30]
ldp d12, d13, [sp, #0 x20]
ldp d10, d11, [sp, #0 x10]
ldp d8, d9, [sp], 0 x40
ret
endfunc
// void dav1d_sgr_box5_vert_neon(int32_t **sumsq, int16_t **sum,
// int32_t *AA, int16_t *BB,
// const int w, const int s,
// const int bitdepth_max);
function sgr_box5_vert_neon, export=1
stp d8, d9, [sp, #-0 x30]!
stp d10, d11, [sp, #0 x10]
stp d12, d13, [sp, #0 x20]
add w4, w4, #2
clz w15, w6 // bitdepth_max
dup v28.4 s, w5 // strength
ldp x5, x6, [x0]
ldp x7, x8, [x0, #16 ]
ldr x0, [x0, #32 ]
ldp x9, x10, [x1]
ldp x11, x12, [x1, #16 ]
ldr x1, [x1, #32 ]
movi v31.4 s, #25 // n
sub w15, w15, #24 // -bitdepth_min_8
movrel x13, x_by_x_tables
movi v30.4 s, #164
ld1 {v24.16 b, v25.16 b, v26.16 b, v27.16 b}, [x13] // RangeMins, DiffMasks
dup v6.8 h, w15 // -bitdepth_min_8
movi v19.8 b, #0 x7
ldr q18, [x13, #64 ] // RefLo
saddl v7.4 s, v6.4 h, v6.4 h // -2 *bitdepth_min_8
ld1 {v8.4 s, v9.4 s}, [x5], #32
ld1 {v10.4 s, v11.4 s}, [x6], #32
ld1 {v12.4 s, v13.4 s}, [x7], #32
ld1 {v16.4 s, v17.4 s}, [x8], #32
ld1 {v20.8 h}, [x9], #16
ld1 {v21.8 h}, [x10], #16
ld1 {v22.8 h}, [x11], #16
ld1 {v23.8 h}, [x12], #16
ld1 {v0.4 s, v1.4 s}, [x0], #32
ld1 {v2.8 h}, [x1], #16
1 :
add v8.4 s, v8.4 s, v10.4 s
add v9.4 s, v9.4 s, v11.4 s
add v12.4 s, v12.4 s, v16.4 s
add v13.4 s, v13.4 s, v17.4 s
add v20.8 h, v20.8 h, v21.8 h
add v22.8 h, v22.8 h, v23.8 h
add v0.4 s, v0.4 s, v8.4 s
add v1.4 s, v1.4 s, v9.4 s
add v2.8 h, v2.8 h, v20.8 h
add v0.4 s, v0.4 s, v12.4 s
add v1.4 s, v1.4 s, v13.4 s
add v2.8 h, v2.8 h, v22.8 h
subs w4, w4, #8
srshl v0.4 s, v0.4 s, v7.4 s
srshl v1.4 s, v1.4 s, v7.4 s
srshl v4.8 h, v2.8 h, v6.8 h
mul v0.4 s, v0.4 s, v31.4 s // a * n
mul v1.4 s, v1.4 s, v31.4 s // a * n
umull v3.4 s, v4.4 h, v4.4 h // b * b
umull2 v4.4 s, v4.8 h, v4.8 h // b * b
uqsub v0.4 s, v0.4 s, v3.4 s // imax(a * n - b * b, 0 )
uqsub v1.4 s, v1.4 s, v4.4 s // imax(a * n - b * b, 0 )
mul v0.4 s, v0.4 s, v28.4 s // p * s
mul v1.4 s, v1.4 s, v28.4 s // p * s
ld1 {v8.4 s, v9.4 s}, [x5], #32
uqshrn v0.4 h, v0.4 s, #16
uqshrn2 v0.8 h, v1.4 s, #16
ld1 {v10.4 s, v11.4 s}, [x6], #32
uqrshrn v0.8 b, v0.8 h, #4 // imin(z, 255 )
ld1 {v12.4 s, v13.4 s}, [x7], #32
ushr v1.8 b, v0.8 b, #3
ld1 {v16.4 s, v17.4 s}, [x8], #32
tbl v5.8 b, {v26.16 b, v27.16 b}, v1.8 b // RangeMins
tbl v1.8 b, {v24.16 b, v25.16 b}, v1.8 b // DiffMasks
tbl v4.8 b, {v18.16 b}, v0.8 b // RefLo
and v0.8 b, v0.8 b, v19.8 b
ld1 {v20.8 h}, [x9], #16
ushl v5.8 b, v5.8 b, v0.8 b
add v4.8 b, v4.8 b, v1.8 b
ld1 {v21.8 h}, [x10], #16
cnt v5.8 b, v5.8 b
ld1 {v22.8 h}, [x11], #16
add v5.8 b, v4.8 b, v5.8 b
ld1 {v23.8 h}, [x12], #16
uxtl v5.8 h, v5.8 b // x
ld1 {v0.4 s, v1.4 s}, [x0], #32
umull v3.4 s, v5.4 h, v2.4 h // x * BB[i]
umull2 v4.4 s, v5.8 h, v2.8 h // x * BB[i]
mul v3.4 s, v3.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
mul v4.4 s, v4.4 s, v30.4 s // x * BB[i] * sgr_one_by_x
srshr v3.4 s, v3.4 s, #12 // AA[i]
srshr v4.4 s, v4.4 s, #12 // AA[i]
ld1 {v2.8 h}, [x1], #16
st1 {v3.4 s, v4.4 s}, [x2], #32
st1 {v5.8 h}, [x3], #16
b.gt 1 b
ldp d12, d13, [sp, #0 x20]
ldp d10, d11, [sp, #0 x10]
ldp d8, d9, [sp], 0 x30
ret
endfunc
Messung V0.5 in Prozent C=100 H=100 G=100
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-08-28)
¤
*© Formatika GbR, Deutschland