sad_media.asm 3.04 KB
Newer Older
Tero Rintaluoma's avatar
Tero Rintaluoma committed
1
;
2
; Copyright (c) 2016, Alliance for Open Media. All rights reserved
Tero Rintaluoma's avatar
Tero Rintaluoma committed
3
;
4 5 6 7 8 9 10 11
; This source code is subject to the terms of the BSD 2 Clause License and
; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
; was not distributed with this source code in the LICENSE file, you can
; obtain it at www.aomedia.org/license/software. If the Alliance for Open
; Media Patent License 1.0 was not distributed with this source code in the
; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
;

Tero Rintaluoma's avatar
Tero Rintaluoma committed
12 13 14
;


Adrian Grange's avatar
Adrian Grange committed
15
    EXPORT  |aom_sad16x16_media|
Tero Rintaluoma's avatar
Tero Rintaluoma committed
16 17 18 19 20 21 22 23 24 25 26

    ARM
    REQUIRE8
    PRESERVE8

    AREA ||.text||, CODE, READONLY, ALIGN=2

; r0    const unsigned char *src_ptr
; r1    int  src_stride
; r2    const unsigned char *ref_ptr
; r3    int  ref_stride
Adrian Grange's avatar
Adrian Grange committed
27
|aom_sad16x16_media| PROC
Tero Rintaluoma's avatar
Tero Rintaluoma committed
28
    stmfd   sp!, {r4-r12, lr}
29 30 31 32 33 34

    pld     [r0, r1, lsl #0]
    pld     [r2, r3, lsl #0]
    pld     [r0, r1, lsl #1]
    pld     [r2, r3, lsl #1]

Tero Rintaluoma's avatar
Tero Rintaluoma committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
    mov     r4, #0              ; sad = 0;
    mov     r5, #8              ; loop count

loop
    ; 1st row
    ldr     r6, [r0, #0x0]      ; load 4 src pixels (1A)
    ldr     r8, [r2, #0x0]      ; load 4 ref pixels (1A)
    ldr     r7, [r0, #0x4]      ; load 4 src pixels (1A)
    ldr     r9, [r2, #0x4]      ; load 4 ref pixels (1A)
    ldr     r10, [r0, #0x8]     ; load 4 src pixels (1B)
    ldr     r11, [r0, #0xC]     ; load 4 src pixels (1B)

    usada8  r4, r8, r6, r4      ; calculate sad for 4 pixels
    usad8   r8, r7, r9          ; calculate sad for 4 pixels

    ldr     r12, [r2, #0x8]     ; load 4 ref pixels (1B)
    ldr     lr, [r2, #0xC]      ; load 4 ref pixels (1B)

    add     r0, r0, r1          ; set src pointer to next row
    add     r2, r2, r3          ; set dst pointer to next row

56 57 58
    pld     [r0, r1, lsl #1]
    pld     [r2, r3, lsl #1]

Tero Rintaluoma's avatar
Tero Rintaluoma committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    usada8  r4, r10, r12, r4    ; calculate sad for 4 pixels
    usada8  r8, r11, lr, r8     ; calculate sad for 4 pixels

    ldr     r6, [r0, #0x0]      ; load 4 src pixels (2A)
    ldr     r7, [r0, #0x4]      ; load 4 src pixels (2A)
    add     r4, r4, r8          ; add partial sad values

    ; 2nd row
    ldr     r8, [r2, #0x0]      ; load 4 ref pixels (2A)
    ldr     r9, [r2, #0x4]      ; load 4 ref pixels (2A)
    ldr     r10, [r0, #0x8]     ; load 4 src pixels (2B)
    ldr     r11, [r0, #0xC]     ; load 4 src pixels (2B)

    usada8  r4, r6, r8, r4      ; calculate sad for 4 pixels
    usad8   r8, r7, r9          ; calculate sad for 4 pixels

    ldr     r12, [r2, #0x8]     ; load 4 ref pixels (2B)
    ldr     lr, [r2, #0xC]      ; load 4 ref pixels (2B)

    add     r0, r0, r1          ; set src pointer to next row
    add     r2, r2, r3          ; set dst pointer to next row

    usada8  r4, r10, r12, r4    ; calculate sad for 4 pixels
    usada8  r8, r11, lr, r8     ; calculate sad for 4 pixels

84 85 86
    pld     [r0, r1, lsl #1]
    pld     [r2, r3, lsl #1]

Tero Rintaluoma's avatar
Tero Rintaluoma committed
87 88 89 90 91 92 93 94 95 96 97 98
    subs    r5, r5, #1          ; decrement loop counter
    add     r4, r4, r8          ; add partial sad values

    bne     loop

    mov     r0, r4              ; return sad
    ldmfd   sp!, {r4-r12, pc}

    ENDP

    END