michael@0: ; michael@0: ; Copyright (c) 2011 The WebM project authors. All Rights Reserved. michael@0: ; michael@0: ; Use of this source code is governed by a BSD-style license michael@0: ; that can be found in the LICENSE file in the root of the source michael@0: ; tree. An additional intellectual property rights grant can be found michael@0: ; in the file PATENTS. All contributing project authors may michael@0: ; be found in the AUTHORS file in the root of the source tree. michael@0: ; michael@0: michael@0: michael@0: EXPORT |vp8_mse16x16_armv6| michael@0: michael@0: ARM michael@0: michael@0: AREA ||.text||, CODE, READONLY, ALIGN=2 michael@0: michael@0: ; r0 unsigned char *src_ptr michael@0: ; r1 int source_stride michael@0: ; r2 unsigned char *ref_ptr michael@0: ; r3 int recon_stride michael@0: ; stack unsigned int *sse michael@0: ; michael@0: ;note: Based on vp8_variance16x16_armv6. In this function, sum is never used. michael@0: ; So, we can remove this part of calculation. michael@0: michael@0: |vp8_mse16x16_armv6| PROC michael@0: michael@0: push {r4-r9, lr} michael@0: michael@0: pld [r0, r1, lsl #0] michael@0: pld [r2, r3, lsl #0] michael@0: michael@0: mov r12, #16 ; set loop counter to 16 (=block height) michael@0: mov r4, #0 ; initialize sse = 0 michael@0: michael@0: loop michael@0: ; 1st 4 pixels michael@0: ldr r5, [r0, #0x0] ; load 4 src pixels michael@0: ldr r6, [r2, #0x0] ; load 4 ref pixels michael@0: michael@0: mov lr, #0 ; constant zero michael@0: michael@0: usub8 r8, r5, r6 ; calculate difference michael@0: pld [r0, r1, lsl #1] michael@0: sel r7, r8, lr ; select bytes with positive difference michael@0: usub8 r9, r6, r5 ; calculate difference with reversed operands michael@0: pld [r2, r3, lsl #1] michael@0: sel r8, r9, lr ; select bytes with negative difference michael@0: michael@0: ; calculate partial sums michael@0: usad8 r5, r7, lr ; calculate sum of positive differences michael@0: usad8 r6, r8, lr ; calculate sum of negative differences michael@0: orr r8, r8, r7 ; differences of all 4 pixels michael@0: michael@0: ldr r5, [r0, #0x4] ; load 4 src pixels michael@0: michael@0: ; calculate sse michael@0: uxtb16 r6, r8 ; byte (two pixels) to halfwords michael@0: uxtb16 r7, r8, ror #8 ; another two pixels to halfwords michael@0: smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1) michael@0: michael@0: ; 2nd 4 pixels michael@0: ldr r6, [r2, #0x4] ; load 4 ref pixels michael@0: smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2) michael@0: michael@0: usub8 r8, r5, r6 ; calculate difference michael@0: sel r7, r8, lr ; select bytes with positive difference michael@0: usub8 r9, r6, r5 ; calculate difference with reversed operands michael@0: sel r8, r9, lr ; select bytes with negative difference michael@0: michael@0: ; calculate partial sums michael@0: usad8 r5, r7, lr ; calculate sum of positive differences michael@0: usad8 r6, r8, lr ; calculate sum of negative differences michael@0: orr r8, r8, r7 ; differences of all 4 pixels michael@0: ldr r5, [r0, #0x8] ; load 4 src pixels michael@0: ; calculate sse michael@0: uxtb16 r6, r8 ; byte (two pixels) to halfwords michael@0: uxtb16 r7, r8, ror #8 ; another two pixels to halfwords michael@0: smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1) michael@0: michael@0: ; 3rd 4 pixels michael@0: ldr r6, [r2, #0x8] ; load 4 ref pixels michael@0: smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2) michael@0: michael@0: usub8 r8, r5, r6 ; calculate difference michael@0: sel r7, r8, lr ; select bytes with positive difference michael@0: usub8 r9, r6, r5 ; calculate difference with reversed operands michael@0: sel r8, r9, lr ; select bytes with negative difference michael@0: michael@0: ; calculate partial sums michael@0: usad8 r5, r7, lr ; calculate sum of positive differences michael@0: usad8 r6, r8, lr ; calculate sum of negative differences michael@0: orr r8, r8, r7 ; differences of all 4 pixels michael@0: michael@0: ldr r5, [r0, #0xc] ; load 4 src pixels michael@0: michael@0: ; calculate sse michael@0: uxtb16 r6, r8 ; byte (two pixels) to halfwords michael@0: uxtb16 r7, r8, ror #8 ; another two pixels to halfwords michael@0: smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1) michael@0: michael@0: ; 4th 4 pixels michael@0: ldr r6, [r2, #0xc] ; load 4 ref pixels michael@0: smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2) michael@0: michael@0: usub8 r8, r5, r6 ; calculate difference michael@0: add r0, r0, r1 ; set src_ptr to next row michael@0: sel r7, r8, lr ; select bytes with positive difference michael@0: usub8 r9, r6, r5 ; calculate difference with reversed operands michael@0: add r2, r2, r3 ; set dst_ptr to next row michael@0: sel r8, r9, lr ; select bytes with negative difference michael@0: michael@0: ; calculate partial sums michael@0: usad8 r5, r7, lr ; calculate sum of positive differences michael@0: usad8 r6, r8, lr ; calculate sum of negative differences michael@0: orr r8, r8, r7 ; differences of all 4 pixels michael@0: michael@0: subs r12, r12, #1 ; next row michael@0: michael@0: ; calculate sse michael@0: uxtb16 r6, r8 ; byte (two pixels) to halfwords michael@0: uxtb16 r7, r8, ror #8 ; another two pixels to halfwords michael@0: smlad r4, r6, r6, r4 ; dual signed multiply, add and accumulate (1) michael@0: smlad r4, r7, r7, r4 ; dual signed multiply, add and accumulate (2) michael@0: michael@0: bne loop michael@0: michael@0: ; return stuff michael@0: ldr r1, [sp, #28] ; get address of sse michael@0: mov r0, r4 ; return sse michael@0: str r4, [r1] ; store sse michael@0: michael@0: pop {r4-r9, pc} michael@0: michael@0: ENDP michael@0: michael@0: END