Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 1 | ; |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | ; Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 3 | ; |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | ; This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | ; was not distributed with this source code in the LICENSE file, you can |
| 7 | ; obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | ; Media Patent License 1.0 was not distributed with this source code in the |
| 9 | ; PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
| 10 | ; |
| 11 | |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 12 | ; |
| 13 | |
| 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | EXPORT |aom_variance_halfpixvar16x16_hv_media| |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 16 | |
| 17 | ARM |
| 18 | REQUIRE8 |
| 19 | PRESERVE8 |
| 20 | |
| 21 | AREA ||.text||, CODE, READONLY, ALIGN=2 |
| 22 | |
| 23 | ; r0 unsigned char *src_ptr |
| 24 | ; r1 int source_stride |
| 25 | ; r2 unsigned char *ref_ptr |
| 26 | ; r3 int recon_stride |
| 27 | ; stack unsigned int *sse |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 28 | |aom_variance_halfpixvar16x16_hv_media| PROC |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 29 | |
| 30 | stmfd sp!, {r4-r12, lr} |
Tero Rintaluoma | 5305e79 | 2011-05-30 11:10:03 +0300 | [diff] [blame] | 31 | |
| 32 | pld [r0, r1, lsl #0] |
| 33 | pld [r2, r3, lsl #0] |
| 34 | |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 35 | mov r8, #0 ; initialize sum = 0 |
| 36 | ldr r10, c80808080 |
| 37 | mov r11, #0 ; initialize sse = 0 |
| 38 | mov r12, #16 ; set loop counter to 16 (=block height) |
| 39 | mov lr, #0 ; constant zero |
| 40 | loop |
| 41 | add r9, r0, r1 ; pointer to pixels on the next row |
| 42 | ; 1st 4 pixels |
| 43 | ldr r4, [r0, #0] ; load source pixels a, row N |
| 44 | ldr r6, [r0, #1] ; load source pixels b, row N |
| 45 | ldr r5, [r9, #0] ; load source pixels c, row N+1 |
| 46 | ldr r7, [r9, #1] ; load source pixels d, row N+1 |
| 47 | |
| 48 | ; x = (a + b + 1) >> 1, interpolate pixels horizontally on row N |
| 49 | mvn r6, r6 |
| 50 | uhsub8 r4, r4, r6 |
| 51 | eor r4, r4, r10 |
| 52 | ; y = (c + d + 1) >> 1, interpolate pixels horizontally on row N+1 |
| 53 | mvn r7, r7 |
| 54 | uhsub8 r5, r5, r7 |
| 55 | eor r5, r5, r10 |
| 56 | ; z = (x + y + 1) >> 1, interpolate half pixel values vertically |
| 57 | mvn r5, r5 |
| 58 | uhsub8 r4, r4, r5 |
| 59 | ldr r5, [r2, #0] ; load 4 ref pixels |
| 60 | eor r4, r4, r10 |
| 61 | |
| 62 | usub8 r6, r4, r5 ; calculate difference |
Tero Rintaluoma | 5305e79 | 2011-05-30 11:10:03 +0300 | [diff] [blame] | 63 | pld [r0, r1, lsl #1] |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 64 | sel r7, r6, lr ; select bytes with positive difference |
| 65 | usub8 r6, r5, r4 ; calculate difference with reversed operands |
Tero Rintaluoma | 5305e79 | 2011-05-30 11:10:03 +0300 | [diff] [blame] | 66 | pld [r2, r3, lsl #1] |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 67 | sel r6, r6, lr ; select bytes with negative difference |
| 68 | |
| 69 | ; calculate partial sums |
| 70 | usad8 r4, r7, lr ; calculate sum of positive differences |
| 71 | usad8 r5, r6, lr ; calculate sum of negative differences |
| 72 | orr r6, r6, r7 ; differences of all 4 pixels |
| 73 | ; calculate total sum |
| 74 | adds r8, r8, r4 ; add positive differences to sum |
Andrew Russell | 549c31f | 2014-02-12 16:32:51 -0800 | [diff] [blame] | 75 | subs r8, r8, r5 ; subtract negative differences from sum |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 76 | |
| 77 | ; calculate sse |
| 78 | uxtb16 r5, r6 ; byte (two pixels) to halfwords |
| 79 | uxtb16 r7, r6, ror #8 ; another two pixels to halfwords |
| 80 | smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) |
| 81 | |
| 82 | ; 2nd 4 pixels |
| 83 | ldr r4, [r0, #4] ; load source pixels a, row N |
| 84 | ldr r6, [r0, #5] ; load source pixels b, row N |
| 85 | ldr r5, [r9, #4] ; load source pixels c, row N+1 |
| 86 | |
| 87 | smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) |
| 88 | |
| 89 | ldr r7, [r9, #5] ; load source pixels d, row N+1 |
| 90 | |
| 91 | ; x = (a + b + 1) >> 1, interpolate pixels horizontally on row N |
| 92 | mvn r6, r6 |
| 93 | uhsub8 r4, r4, r6 |
| 94 | eor r4, r4, r10 |
| 95 | ; y = (c + d + 1) >> 1, interpolate pixels horizontally on row N+1 |
| 96 | mvn r7, r7 |
| 97 | uhsub8 r5, r5, r7 |
| 98 | eor r5, r5, r10 |
| 99 | ; z = (x + y + 1) >> 1, interpolate half pixel values vertically |
| 100 | mvn r5, r5 |
| 101 | uhsub8 r4, r4, r5 |
| 102 | ldr r5, [r2, #4] ; load 4 ref pixels |
| 103 | eor r4, r4, r10 |
| 104 | |
| 105 | usub8 r6, r4, r5 ; calculate difference |
| 106 | sel r7, r6, lr ; select bytes with positive difference |
| 107 | usub8 r6, r5, r4 ; calculate difference with reversed operands |
| 108 | sel r6, r6, lr ; select bytes with negative difference |
| 109 | |
| 110 | ; calculate partial sums |
| 111 | usad8 r4, r7, lr ; calculate sum of positive differences |
| 112 | usad8 r5, r6, lr ; calculate sum of negative differences |
| 113 | orr r6, r6, r7 ; differences of all 4 pixels |
| 114 | |
| 115 | ; calculate total sum |
| 116 | add r8, r8, r4 ; add positive differences to sum |
Andrew Russell | 549c31f | 2014-02-12 16:32:51 -0800 | [diff] [blame] | 117 | sub r8, r8, r5 ; subtract negative differences from sum |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 118 | |
| 119 | ; calculate sse |
| 120 | uxtb16 r5, r6 ; byte (two pixels) to halfwords |
| 121 | uxtb16 r7, r6, ror #8 ; another two pixels to halfwords |
| 122 | smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) |
| 123 | |
| 124 | ; 3rd 4 pixels |
| 125 | ldr r4, [r0, #8] ; load source pixels a, row N |
| 126 | ldr r6, [r0, #9] ; load source pixels b, row N |
| 127 | ldr r5, [r9, #8] ; load source pixels c, row N+1 |
| 128 | |
| 129 | smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) |
| 130 | |
| 131 | ldr r7, [r9, #9] ; load source pixels d, row N+1 |
| 132 | |
| 133 | ; x = (a + b + 1) >> 1, interpolate pixels horizontally on row N |
| 134 | mvn r6, r6 |
| 135 | uhsub8 r4, r4, r6 |
| 136 | eor r4, r4, r10 |
| 137 | ; y = (c + d + 1) >> 1, interpolate pixels horizontally on row N+1 |
| 138 | mvn r7, r7 |
| 139 | uhsub8 r5, r5, r7 |
| 140 | eor r5, r5, r10 |
| 141 | ; z = (x + y + 1) >> 1, interpolate half pixel values vertically |
| 142 | mvn r5, r5 |
| 143 | uhsub8 r4, r4, r5 |
| 144 | ldr r5, [r2, #8] ; load 4 ref pixels |
| 145 | eor r4, r4, r10 |
| 146 | |
| 147 | usub8 r6, r4, r5 ; calculate difference |
| 148 | sel r7, r6, lr ; select bytes with positive difference |
| 149 | usub8 r6, r5, r4 ; calculate difference with reversed operands |
| 150 | sel r6, r6, lr ; select bytes with negative difference |
| 151 | |
| 152 | ; calculate partial sums |
| 153 | usad8 r4, r7, lr ; calculate sum of positive differences |
| 154 | usad8 r5, r6, lr ; calculate sum of negative differences |
| 155 | orr r6, r6, r7 ; differences of all 4 pixels |
| 156 | |
| 157 | ; calculate total sum |
| 158 | add r8, r8, r4 ; add positive differences to sum |
Andrew Russell | 549c31f | 2014-02-12 16:32:51 -0800 | [diff] [blame] | 159 | sub r8, r8, r5 ; subtract negative differences from sum |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 160 | |
| 161 | ; calculate sse |
| 162 | uxtb16 r5, r6 ; byte (two pixels) to halfwords |
| 163 | uxtb16 r7, r6, ror #8 ; another two pixels to halfwords |
| 164 | smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) |
| 165 | |
| 166 | ; 4th 4 pixels |
| 167 | ldr r4, [r0, #12] ; load source pixels a, row N |
| 168 | ldr r6, [r0, #13] ; load source pixels b, row N |
| 169 | ldr r5, [r9, #12] ; load source pixels c, row N+1 |
| 170 | smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) |
| 171 | ldr r7, [r9, #13] ; load source pixels d, row N+1 |
| 172 | |
| 173 | ; x = (a + b + 1) >> 1, interpolate pixels horizontally on row N |
| 174 | mvn r6, r6 |
| 175 | uhsub8 r4, r4, r6 |
| 176 | eor r4, r4, r10 |
| 177 | ; y = (c + d + 1) >> 1, interpolate pixels horizontally on row N+1 |
| 178 | mvn r7, r7 |
| 179 | uhsub8 r5, r5, r7 |
| 180 | eor r5, r5, r10 |
| 181 | ; z = (x + y + 1) >> 1, interpolate half pixel values vertically |
| 182 | mvn r5, r5 |
| 183 | uhsub8 r4, r4, r5 |
| 184 | ldr r5, [r2, #12] ; load 4 ref pixels |
| 185 | eor r4, r4, r10 |
| 186 | |
| 187 | usub8 r6, r4, r5 ; calculate difference |
| 188 | add r0, r0, r1 ; set src_ptr to next row |
| 189 | sel r7, r6, lr ; select bytes with positive difference |
| 190 | usub8 r6, r5, r4 ; calculate difference with reversed operands |
| 191 | add r2, r2, r3 ; set dst_ptr to next row |
| 192 | sel r6, r6, lr ; select bytes with negative difference |
| 193 | |
| 194 | ; calculate partial sums |
| 195 | usad8 r4, r7, lr ; calculate sum of positive differences |
| 196 | usad8 r5, r6, lr ; calculate sum of negative differences |
| 197 | orr r6, r6, r7 ; differences of all 4 pixels |
| 198 | |
| 199 | ; calculate total sum |
| 200 | add r8, r8, r4 ; add positive differences to sum |
Andrew Russell | 549c31f | 2014-02-12 16:32:51 -0800 | [diff] [blame] | 201 | sub r8, r8, r5 ; subtract negative differences from sum |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 202 | |
| 203 | ; calculate sse |
| 204 | uxtb16 r5, r6 ; byte (two pixels) to halfwords |
| 205 | uxtb16 r7, r6, ror #8 ; another two pixels to halfwords |
| 206 | smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) |
| 207 | subs r12, r12, #1 |
| 208 | smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) |
| 209 | |
| 210 | bne loop |
| 211 | |
| 212 | ; return stuff |
| 213 | ldr r6, [sp, #40] ; get address of sse |
| 214 | mul r0, r8, r8 ; sum * sum |
| 215 | str r11, [r6] ; store sse |
Johann | fea3556 | 2012-02-09 12:38:31 -0800 | [diff] [blame] | 216 | sub r0, r11, r0, lsr #8 ; return (sse - ((sum * sum) >> 8)) |
Tero Rintaluoma | f5e4334 | 2011-03-28 09:51:51 +0300 | [diff] [blame] | 217 | |
| 218 | ldmfd sp!, {r4-r12, pc} |
| 219 | |
| 220 | ENDP |
| 221 | |
| 222 | c80808080 |
| 223 | DCD 0x80808080 |
| 224 | |
| 225 | END |