1; 2; Copyright (c) 2011 The WebM project authors. All Rights Reserved. 3; 4; Use of this source code is governed by a BSD-style license 5; that can be found in the LICENSE file in the root of the source 6; tree. An additional intellectual property rights grant can be found 7; in the file PATENTS. All contributing project authors may 8; be found in the AUTHORS file in the root of the source tree. 9; 10 11 12 EXPORT |vp8_variance_halfpixvar16x16_v_armv6| 13 14 ARM 15 REQUIRE8 16 PRESERVE8 17 18 AREA ||.text||, CODE, READONLY, ALIGN=2 19 20; r0 unsigned char *src_ptr 21; r1 int source_stride 22; r2 unsigned char *ref_ptr 23; r3 int recon_stride 24; stack unsigned int *sse 25|vp8_variance_halfpixvar16x16_v_armv6| PROC 26 27 stmfd sp!, {r4-r12, lr} 28 mov r8, #0 ; initialize sum = 0 29 ldr r10, c80808080 30 mov r11, #0 ; initialize sse = 0 31 mov r12, #16 ; set loop counter to 16 (=block height) 32 mov lr, #0 ; constant zero 33loop 34 add r9, r0, r1 ; set src pointer to next row 35 ; 1st 4 pixels 36 ldr r4, [r0, #0] ; load 4 src pixels 37 ldr r6, [r9, #0] ; load 4 src pixels from next row 38 ldr r5, [r2, #0] ; load 4 ref pixels 39 40 ; bilinear interpolation 41 mvn r6, r6 42 uhsub8 r4, r4, r6 43 eor r4, r4, r10 44 45 usub8 r6, r4, r5 ; calculate difference 46 sel r7, r6, lr ; select bytes with positive difference 47 usub8 r6, r5, r4 ; calculate difference with reversed operands 48 sel r6, r6, lr ; select bytes with negative difference 49 50 ; calculate partial sums 51 usad8 r4, r7, lr ; calculate sum of positive differences 52 usad8 r5, r6, lr ; calculate sum of negative differences 53 orr r6, r6, r7 ; differences of all 4 pixels 54 ; calculate total sum 55 adds r8, r8, r4 ; add positive differences to sum 56 subs r8, r8, r5 ; substract negative differences from sum 57 58 ; calculate sse 59 uxtb16 r5, r6 ; byte (two pixels) to halfwords 60 uxtb16 r7, r6, ror #8 ; another two pixels to halfwords 61 smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) 62 63 ; 2nd 4 pixels 64 ldr r4, [r0, #4] ; load 4 src pixels 65 ldr r6, [r9, #4] ; load 4 src pixels from next row 66 ldr r5, [r2, #4] ; load 4 ref pixels 67 68 ; bilinear interpolation 69 mvn r6, r6 70 uhsub8 r4, r4, r6 71 eor r4, r4, r10 72 73 smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) 74 75 usub8 r6, r4, r5 ; calculate difference 76 sel r7, r6, lr ; select bytes with positive difference 77 usub8 r6, r5, r4 ; calculate difference with reversed operands 78 sel r6, r6, lr ; select bytes with negative difference 79 80 ; calculate partial sums 81 usad8 r4, r7, lr ; calculate sum of positive differences 82 usad8 r5, r6, lr ; calculate sum of negative differences 83 orr r6, r6, r7 ; differences of all 4 pixels 84 85 ; calculate total sum 86 add r8, r8, r4 ; add positive differences to sum 87 sub r8, r8, r5 ; substract negative differences from sum 88 89 ; calculate sse 90 uxtb16 r5, r6 ; byte (two pixels) to halfwords 91 uxtb16 r7, r6, ror #8 ; another two pixels to halfwords 92 smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) 93 94 ; 3rd 4 pixels 95 ldr r4, [r0, #8] ; load 4 src pixels 96 ldr r6, [r9, #8] ; load 4 src pixels from next row 97 ldr r5, [r2, #8] ; load 4 ref pixels 98 99 ; bilinear interpolation 100 mvn r6, r6 101 uhsub8 r4, r4, r6 102 eor r4, r4, r10 103 104 smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) 105 106 usub8 r6, r4, r5 ; calculate difference 107 sel r7, r6, lr ; select bytes with positive difference 108 usub8 r6, r5, r4 ; calculate difference with reversed operands 109 sel r6, r6, lr ; select bytes with negative difference 110 111 ; calculate partial sums 112 usad8 r4, r7, lr ; calculate sum of positive differences 113 usad8 r5, r6, lr ; calculate sum of negative differences 114 orr r6, r6, r7 ; differences of all 4 pixels 115 116 ; calculate total sum 117 add r8, r8, r4 ; add positive differences to sum 118 sub r8, r8, r5 ; substract negative differences from sum 119 120 ; calculate sse 121 uxtb16 r5, r6 ; byte (two pixels) to halfwords 122 uxtb16 r7, r6, ror #8 ; another two pixels to halfwords 123 smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) 124 125 ; 4th 4 pixels 126 ldr r4, [r0, #12] ; load 4 src pixels 127 ldr r6, [r9, #12] ; load 4 src pixels from next row 128 ldr r5, [r2, #12] ; load 4 ref pixels 129 130 ; bilinear interpolation 131 mvn r6, r6 132 uhsub8 r4, r4, r6 133 eor r4, r4, r10 134 135 smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) 136 137 usub8 r6, r4, r5 ; calculate difference 138 add r0, r0, r1 ; set src_ptr to next row 139 sel r7, r6, lr ; select bytes with positive difference 140 usub8 r6, r5, r4 ; calculate difference with reversed operands 141 add r2, r2, r3 ; set dst_ptr to next row 142 sel r6, r6, lr ; select bytes with negative difference 143 144 ; calculate partial sums 145 usad8 r4, r7, lr ; calculate sum of positive differences 146 usad8 r5, r6, lr ; calculate sum of negative differences 147 orr r6, r6, r7 ; differences of all 4 pixels 148 149 ; calculate total sum 150 add r8, r8, r4 ; add positive differences to sum 151 sub r8, r8, r5 ; substract negative differences from sum 152 153 ; calculate sse 154 uxtb16 r5, r6 ; byte (two pixels) to halfwords 155 uxtb16 r7, r6, ror #8 ; another two pixels to halfwords 156 smlad r11, r5, r5, r11 ; dual signed multiply, add and accumulate (1) 157 smlad r11, r7, r7, r11 ; dual signed multiply, add and accumulate (2) 158 159 160 subs r12, r12, #1 161 162 bne loop 163 164 ; return stuff 165 ldr r6, [sp, #40] ; get address of sse 166 mul r0, r8, r8 ; sum * sum 167 str r11, [r6] ; store sse 168 sub r0, r11, r0, asr #8 ; return (sse - ((sum * sum) >> 8)) 169 170 ldmfd sp!, {r4-r12, pc} 171 172 ENDP 173 174c80808080 175 DCD 0x80808080 176 177 END 178 179