tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

vp9mc_neon.S (24513B)


      1 /*
      2 * Copyright (c) 2016 Google Inc.
      3 *
      4 * This file is part of FFmpeg.
      5 *
      6 * FFmpeg is free software; you can redistribute it and/or
      7 * modify it under the terms of the GNU Lesser General Public
      8 * License as published by the Free Software Foundation; either
      9 * version 2.1 of the License, or (at your option) any later version.
     10 *
     11 * FFmpeg is distributed in the hope that it will be useful,
     12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     14 * Lesser General Public License for more details.
     15 *
     16 * You should have received a copy of the GNU Lesser General Public
     17 * License along with FFmpeg; if not, write to the Free Software
     18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     19 */
     20 
     21 #include "libavutil/aarch64/asm.S"
     22 
     23 // All public functions in this file have the following signature:
     24 // typedef void (*vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride,
     25 //                            const uint8_t *ref, ptrdiff_t ref_stride,
     26 //                            int h, int mx, int my);
     27 
     28 function ff_vp9_avg64_neon, export=1
     29        mov             x5,  x0
     30 1:
     31        ld1             {v4.16b,  v5.16b,  v6.16b,  v7.16b},  [x2], x3
     32        ld1             {v0.16b,  v1.16b,  v2.16b,  v3.16b},  [x0], x1
     33        ld1             {v20.16b, v21.16b, v22.16b, v23.16b}, [x2], x3
     34        urhadd          v0.16b,  v0.16b,  v4.16b
     35        urhadd          v1.16b,  v1.16b,  v5.16b
     36        ld1             {v16.16b, v17.16b, v18.16b, v19.16b}, [x0], x1
     37        urhadd          v2.16b,  v2.16b,  v6.16b
     38        urhadd          v3.16b,  v3.16b,  v7.16b
     39        subs            w4,  w4,  #2
     40        urhadd          v16.16b, v16.16b, v20.16b
     41        urhadd          v17.16b, v17.16b, v21.16b
     42        st1             {v0.16b,  v1.16b,  v2.16b,  v3.16b},  [x5], x1
     43        urhadd          v18.16b, v18.16b, v22.16b
     44        urhadd          v19.16b, v19.16b, v23.16b
     45        st1             {v16.16b, v17.16b, v18.16b, v19.16b}, [x5], x1
     46        b.ne            1b
     47        ret
     48 endfunc
     49 
     50 function ff_vp9_avg32_neon, export=1
     51 1:
     52        ld1             {v2.16b, v3.16b},  [x2], x3
     53        ld1             {v0.16b, v1.16b},  [x0]
     54        urhadd          v0.16b,  v0.16b,  v2.16b
     55        urhadd          v1.16b,  v1.16b,  v3.16b
     56        subs            w4,  w4,  #1
     57        st1             {v0.16b, v1.16b},  [x0], x1
     58        b.ne            1b
     59        ret
     60 endfunc
     61 
     62 function ff_vp9_copy16_neon, export=1
     63        add             x5,  x0,  x1
     64        lsl             x1,  x1,  #1
     65        add             x6,  x2,  x3
     66        lsl             x3,  x3,  #1
     67 1:
     68        ld1             {v0.16b},  [x2], x3
     69        ld1             {v1.16b},  [x6], x3
     70        ld1             {v2.16b},  [x2], x3
     71        ld1             {v3.16b},  [x6], x3
     72        subs            w4,  w4,  #4
     73        st1             {v0.16b},  [x0], x1
     74        st1             {v1.16b},  [x5], x1
     75        st1             {v2.16b},  [x0], x1
     76        st1             {v3.16b},  [x5], x1
     77        b.ne            1b
     78        ret
     79 endfunc
     80 
     81 function ff_vp9_avg16_neon, export=1
     82        mov             x5,  x0
     83 1:
     84        ld1             {v2.16b},  [x2], x3
     85        ld1             {v0.16b},  [x0], x1
     86        ld1             {v3.16b},  [x2], x3
     87        urhadd          v0.16b,  v0.16b,  v2.16b
     88        ld1             {v1.16b},  [x0], x1
     89        urhadd          v1.16b,  v1.16b,  v3.16b
     90        subs            w4,  w4,  #2
     91        st1             {v0.16b},  [x5], x1
     92        st1             {v1.16b},  [x5], x1
     93        b.ne            1b
     94        ret
     95 endfunc
     96 
     97 function ff_vp9_copy8_neon, export=1
     98 1:
     99        ld1             {v0.8b},  [x2], x3
    100        ld1             {v1.8b},  [x2], x3
    101        subs            w4,  w4,  #2
    102        st1             {v0.8b},  [x0], x1
    103        st1             {v1.8b},  [x0], x1
    104        b.ne            1b
    105        ret
    106 endfunc
    107 
    108 function ff_vp9_avg8_neon, export=1
    109        mov             x5,  x0
    110 1:
    111        ld1             {v2.8b},  [x2], x3
    112        ld1             {v0.8b},  [x0], x1
    113        ld1             {v3.8b},  [x2], x3
    114        urhadd          v0.8b,  v0.8b,  v2.8b
    115        ld1             {v1.8b},  [x0], x1
    116        urhadd          v1.8b,  v1.8b,  v3.8b
    117        subs            w4,  w4,  #2
    118        st1             {v0.8b},  [x5], x1
    119        st1             {v1.8b},  [x5], x1
    120        b.ne            1b
    121        ret
    122 endfunc
    123 
    124 function ff_vp9_copy4_neon, export=1
    125 1:
    126        ld1             {v0.s}[0], [x2], x3
    127        ld1             {v1.s}[0], [x2], x3
    128        st1             {v0.s}[0], [x0], x1
    129        ld1             {v2.s}[0], [x2], x3
    130        st1             {v1.s}[0], [x0], x1
    131        ld1             {v3.s}[0], [x2], x3
    132        subs            w4,  w4,  #4
    133        st1             {v2.s}[0], [x0], x1
    134        st1             {v3.s}[0], [x0], x1
    135        b.ne            1b
    136        ret
    137 endfunc
    138 
    139 function ff_vp9_avg4_neon, export=1
    140        mov             x5,  x0
    141 1:
    142        ld1             {v2.s}[0], [x2], x3
    143        ld1             {v0.s}[0], [x0], x1
    144        ld1             {v2.s}[1], [x2], x3
    145        ld1             {v0.s}[1], [x0], x1
    146        ld1             {v3.s}[0], [x2], x3
    147        ld1             {v1.s}[0], [x0], x1
    148        ld1             {v3.s}[1], [x2], x3
    149        ld1             {v1.s}[1], [x0], x1
    150        subs            w4,  w4,  #4
    151        urhadd          v0.8b,  v0.8b,  v2.8b
    152        urhadd          v1.8b,  v1.8b,  v3.8b
    153        st1             {v0.s}[0], [x5], x1
    154        st1             {v0.s}[1], [x5], x1
    155        st1             {v1.s}[0], [x5], x1
    156        st1             {v1.s}[1], [x5], x1
    157        b.ne            1b
    158        ret
    159 endfunc
    160 
    161 
    162 // Extract a vector from src1-src2 and src4-src5 (src1-src3 and src4-src6
    163 // for size >= 16), and multiply-accumulate into dst1 and dst3 (or
    164 // dst1-dst2 and dst3-dst4 for size >= 16)
    165 .macro extmla dst1, dst2, dst3, dst4, src1, src2, src3, src4, src5, src6, offset, size
    166        ext             v20.16b, \src1\().16b, \src2\().16b, #(2*\offset)
    167        ext             v22.16b, \src4\().16b, \src5\().16b, #(2*\offset)
    168 .if \size >= 16
    169        mla             \dst1\().8h, v20.8h, v0.h[\offset]
    170        ext             v21.16b, \src2\().16b, \src3\().16b, #(2*\offset)
    171        mla             \dst3\().8h, v22.8h, v0.h[\offset]
    172        ext             v23.16b, \src5\().16b, \src6\().16b, #(2*\offset)
    173        mla             \dst2\().8h, v21.8h, v0.h[\offset]
    174        mla             \dst4\().8h, v23.8h, v0.h[\offset]
    175 .elseif \size == 8
    176        mla             \dst1\().8h, v20.8h, v0.h[\offset]
    177        mla             \dst3\().8h, v22.8h, v0.h[\offset]
    178 .else
    179        mla             \dst1\().4h, v20.4h, v0.h[\offset]
    180        mla             \dst3\().4h, v22.4h, v0.h[\offset]
    181 .endif
    182 .endm
    183 // The same as above, but don't accumulate straight into the
    184 // destination, but use a temp register and accumulate with saturation.
    185 .macro extmulqadd dst1, dst2, dst3, dst4, src1, src2, src3, src4, src5, src6, offset, size
    186        ext             v20.16b, \src1\().16b, \src2\().16b, #(2*\offset)
    187        ext             v22.16b, \src4\().16b, \src5\().16b, #(2*\offset)
    188 .if \size >= 16
    189        mul             v20.8h, v20.8h, v0.h[\offset]
    190        ext             v21.16b, \src2\().16b, \src3\().16b, #(2*\offset)
    191        mul             v22.8h, v22.8h, v0.h[\offset]
    192        ext             v23.16b, \src5\().16b, \src6\().16b, #(2*\offset)
    193        mul             v21.8h, v21.8h, v0.h[\offset]
    194        mul             v23.8h, v23.8h, v0.h[\offset]
    195 .elseif \size == 8
    196        mul             v20.8h, v20.8h, v0.h[\offset]
    197        mul             v22.8h, v22.8h, v0.h[\offset]
    198 .else
    199        mul             v20.4h, v20.4h, v0.h[\offset]
    200        mul             v22.4h, v22.4h, v0.h[\offset]
    201 .endif
    202 .if \size == 4
    203        sqadd           \dst1\().4h, \dst1\().4h, v20.4h
    204        sqadd           \dst3\().4h, \dst3\().4h, v22.4h
    205 .else
    206        sqadd           \dst1\().8h, \dst1\().8h, v20.8h
    207        sqadd           \dst3\().8h, \dst3\().8h, v22.8h
    208 .if \size >= 16
    209        sqadd           \dst2\().8h, \dst2\().8h, v21.8h
    210        sqadd           \dst4\().8h, \dst4\().8h, v23.8h
    211 .endif
    212 .endif
    213 .endm
    214 
    215 
    216 // Instantiate a horizontal filter function for the given size.
    217 // This can work on 4, 8 or 16 pixels in parallel; for larger
    218 // widths it will do 16 pixels at a time and loop horizontally.
    219 // The actual width is passed in x5, the height in w4 and the
    220 // filter coefficients in x9. idx2 is the index of the largest
    221 // filter coefficient (3 or 4) and idx1 is the other one of them.
    222 .macro do_8tap_h type, size, idx1, idx2
    223 function \type\()_8tap_\size\()h_\idx1\idx2
    224        sub             x2,  x2,  #3
    225        add             x6,  x0,  x1
    226        add             x7,  x2,  x3
    227        add             x1,  x1,  x1
    228        add             x3,  x3,  x3
    229        // Only size >= 16 loops horizontally and needs
    230        // reduced dst stride
    231 .if \size >= 16
    232        sub             x1,  x1,  x5
    233 .elseif \size == 4
    234        add             x12, x2,  #8
    235        add             x13, x7,  #8
    236 .endif
    237        // size >= 16 loads two qwords and increments x2,
    238        // for size 4/8 it's enough with one qword and no
    239        // postincrement
    240 .if \size >= 16
    241        sub             x3,  x3,  x5
    242        sub             x3,  x3,  #8
    243 .endif
    244        // Load the filter vector
    245        ld1             {v0.8h},  [x9]
    246 1:
    247 .if \size >= 16
    248        mov             x9,  x5
    249 .endif
    250        // Load src
    251 .if \size >= 16
    252        ld1             {v4.8b,  v5.8b,  v6.8b},  [x2], #24
    253        ld1             {v16.8b, v17.8b, v18.8b}, [x7], #24
    254 .elseif \size == 8
    255        ld1             {v4.8b,  v5.8b},  [x2]
    256        ld1             {v16.8b, v17.8b}, [x7]
    257 .else // \size == 4
    258        ld1             {v4.8b},  [x2]
    259        ld1             {v16.8b}, [x7]
    260        ld1             {v5.s}[0],  [x12], x3
    261        ld1             {v17.s}[0], [x13], x3
    262 .endif
    263        uxtl            v4.8h,  v4.8b
    264        uxtl            v5.8h,  v5.8b
    265        uxtl            v16.8h, v16.8b
    266        uxtl            v17.8h, v17.8b
    267 .if \size >= 16
    268        uxtl            v6.8h,  v6.8b
    269        uxtl            v18.8h, v18.8b
    270 .endif
    271 2:
    272 
    273        // Accumulate, adding idx2 last with a separate
    274        // saturating add. The positive filter coefficients
    275        // for all indices except idx2 must add up to less
    276        // than 127 for this not to overflow.
    277        mul             v1.8h,  v4.8h,  v0.h[0]
    278        mul             v24.8h, v16.8h, v0.h[0]
    279 .if \size >= 16
    280        mul             v2.8h,  v5.8h,  v0.h[0]
    281        mul             v25.8h, v17.8h, v0.h[0]
    282 .endif
    283        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, 1,     \size
    284        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, 2,     \size
    285        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, \idx1, \size
    286        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, 5,     \size
    287        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, 6,     \size
    288        extmla          v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, 7,     \size
    289        extmulqadd      v1,  v2,  v24, v25, v4,  v5,  v6,  v16, v17, v18, \idx2, \size
    290 
    291        // Round, shift and saturate
    292        sqrshrun        v1.8b,   v1.8h,  #7
    293        sqrshrun        v24.8b,  v24.8h, #7
    294 .if \size >= 16
    295        sqrshrun2       v1.16b,  v2.8h,  #7
    296        sqrshrun2       v24.16b, v25.8h, #7
    297 .endif
    298        // Average
    299 .ifc \type,avg
    300 .if \size >= 16
    301        ld1             {v2.16b}, [x0]
    302        ld1             {v3.16b}, [x6]
    303        urhadd          v1.16b,  v1.16b,  v2.16b
    304        urhadd          v24.16b, v24.16b, v3.16b
    305 .elseif \size == 8
    306        ld1             {v2.8b},  [x0]
    307        ld1             {v3.8b},  [x6]
    308        urhadd          v1.8b,  v1.8b,  v2.8b
    309        urhadd          v24.8b, v24.8b, v3.8b
    310 .else
    311        ld1             {v2.s}[0], [x0]
    312        ld1             {v3.s}[0], [x6]
    313        urhadd          v1.8b,  v1.8b,  v2.8b
    314        urhadd          v24.8b, v24.8b, v3.8b
    315 .endif
    316 .endif
    317        // Store and loop horizontally (for size >= 16)
    318 .if \size >= 16
    319        subs            x9,  x9,  #16
    320        st1             {v1.16b},  [x0], #16
    321        st1             {v24.16b}, [x6], #16
    322        b.eq            3f
    323        mov             v4.16b,  v6.16b
    324        mov             v16.16b, v18.16b
    325        ld1             {v6.16b},  [x2], #16
    326        ld1             {v18.16b}, [x7], #16
    327        uxtl            v5.8h,  v6.8b
    328        uxtl2           v6.8h,  v6.16b
    329        uxtl            v17.8h, v18.8b
    330        uxtl2           v18.8h, v18.16b
    331        b               2b
    332 .elseif \size == 8
    333        st1             {v1.8b},    [x0]
    334        st1             {v24.8b},   [x6]
    335 .else // \size == 4
    336        st1             {v1.s}[0],  [x0]
    337        st1             {v24.s}[0], [x6]
    338 .endif
    339 3:
    340        // Loop vertically
    341        add             x0,  x0,  x1
    342        add             x6,  x6,  x1
    343        add             x2,  x2,  x3
    344        add             x7,  x7,  x3
    345        subs            w4,  w4,  #2
    346        b.ne            1b
    347        ret
    348 endfunc
    349 .endm
    350 
    351 .macro do_8tap_h_size size
    352 do_8tap_h put, \size, 3, 4
    353 do_8tap_h avg, \size, 3, 4
    354 do_8tap_h put, \size, 4, 3
    355 do_8tap_h avg, \size, 4, 3
    356 .endm
    357 
    358 do_8tap_h_size 4
    359 do_8tap_h_size 8
    360 do_8tap_h_size 16
    361 
    362 .macro do_8tap_h_func type, filter, offset, size
    363 function ff_vp9_\type\()_\filter\()\size\()_h_neon, export=1
    364        movrel          x6,  X(ff_vp9_subpel_filters), 256*\offset
    365        cmp             w5,  #8
    366        add             x9,  x6,  w5, uxtw #4
    367        mov             x5,  #\size
    368 .if \size >= 16
    369        b.ge            \type\()_8tap_16h_34
    370        b               \type\()_8tap_16h_43
    371 .else
    372        b.ge            \type\()_8tap_\size\()h_34
    373        b               \type\()_8tap_\size\()h_43
    374 .endif
    375 endfunc
    376 .endm
    377 
    378 .macro do_8tap_h_filters size
    379 do_8tap_h_func put, regular, 1, \size
    380 do_8tap_h_func avg, regular, 1, \size
    381 do_8tap_h_func put, sharp,   2, \size
    382 do_8tap_h_func avg, sharp,   2, \size
    383 do_8tap_h_func put, smooth,  0, \size
    384 do_8tap_h_func avg, smooth,  0, \size
    385 .endm
    386 
    387 do_8tap_h_filters 64
    388 do_8tap_h_filters 32
    389 do_8tap_h_filters 16
    390 do_8tap_h_filters 8
    391 do_8tap_h_filters 4
    392 
    393 
    394 // Vertical filters
    395 
    396 // Round, shift and saturate and store reg1-reg2 over 4 lines
    397 .macro do_store4 reg1, reg2, tmp1, tmp2, type
    398        sqrshrun        \reg1\().8b,  \reg1\().8h, #7
    399        sqrshrun        \reg2\().8b,  \reg2\().8h, #7
    400 .ifc \type,avg
    401        ld1             {\tmp1\().s}[0],  [x7], x1
    402        ld1             {\tmp2\().s}[0],  [x7], x1
    403        ld1             {\tmp1\().s}[1],  [x7], x1
    404        ld1             {\tmp2\().s}[1],  [x7], x1
    405        urhadd          \reg1\().8b,  \reg1\().8b,  \tmp1\().8b
    406        urhadd          \reg2\().8b,  \reg2\().8b,  \tmp2\().8b
    407 .endif
    408        st1             {\reg1\().s}[0],  [x0], x1
    409        st1             {\reg2\().s}[0],  [x0], x1
    410        st1             {\reg1\().s}[1],  [x0], x1
    411        st1             {\reg2\().s}[1],  [x0], x1
    412 .endm
    413 
    414 // Round, shift and saturate and store reg1-4
    415 .macro do_store reg1, reg2, reg3, reg4, tmp1, tmp2, tmp3, tmp4, type
    416        sqrshrun        \reg1\().8b,  \reg1\().8h, #7
    417        sqrshrun        \reg2\().8b,  \reg2\().8h, #7
    418        sqrshrun        \reg3\().8b,  \reg3\().8h, #7
    419        sqrshrun        \reg4\().8b,  \reg4\().8h, #7
    420 .ifc \type,avg
    421        ld1             {\tmp1\().8b},  [x7], x1
    422        ld1             {\tmp2\().8b},  [x7], x1
    423        ld1             {\tmp3\().8b},  [x7], x1
    424        ld1             {\tmp4\().8b},  [x7], x1
    425        urhadd          \reg1\().8b,  \reg1\().8b,  \tmp1\().8b
    426        urhadd          \reg2\().8b,  \reg2\().8b,  \tmp2\().8b
    427        urhadd          \reg3\().8b,  \reg3\().8b,  \tmp3\().8b
    428        urhadd          \reg4\().8b,  \reg4\().8b,  \tmp4\().8b
    429 .endif
    430        st1             {\reg1\().8b},  [x0], x1
    431        st1             {\reg2\().8b},  [x0], x1
    432        st1             {\reg3\().8b},  [x0], x1
    433        st1             {\reg4\().8b},  [x0], x1
    434 .endm
    435 
    436 // Evaluate the filter twice in parallel, from the inputs src1-src9 into dst1-dst2
    437 // (src1-src8 into dst1, src2-src9 into dst2), adding idx2 separately
    438 // at the end with saturation. Indices 0 and 7 always have negative or zero
    439 // coefficients, so they can be accumulated into tmp1-tmp2 together with the
    440 // largest coefficient.
    441 .macro convolve dst1, dst2, src1, src2, src3, src4, src5, src6, src7, src8, src9, idx1, idx2, tmp1, tmp2
    442        mul             \dst1\().8h, \src2\().8h, v0.h[1]
    443        mul             \dst2\().8h, \src3\().8h, v0.h[1]
    444        mul             \tmp1\().8h, \src1\().8h, v0.h[0]
    445        mul             \tmp2\().8h, \src2\().8h, v0.h[0]
    446        mla             \dst1\().8h, \src3\().8h, v0.h[2]
    447        mla             \dst2\().8h, \src4\().8h, v0.h[2]
    448 .if \idx1 == 3
    449        mla             \dst1\().8h, \src4\().8h, v0.h[3]
    450        mla             \dst2\().8h, \src5\().8h, v0.h[3]
    451 .else
    452        mla             \dst1\().8h, \src5\().8h, v0.h[4]
    453        mla             \dst2\().8h, \src6\().8h, v0.h[4]
    454 .endif
    455        mla             \dst1\().8h, \src6\().8h, v0.h[5]
    456        mla             \dst2\().8h, \src7\().8h, v0.h[5]
    457        mla             \tmp1\().8h, \src8\().8h, v0.h[7]
    458        mla             \tmp2\().8h, \src9\().8h, v0.h[7]
    459        mla             \dst1\().8h, \src7\().8h, v0.h[6]
    460        mla             \dst2\().8h, \src8\().8h, v0.h[6]
    461 .if \idx2 == 3
    462        mla             \tmp1\().8h, \src4\().8h, v0.h[3]
    463        mla             \tmp2\().8h, \src5\().8h, v0.h[3]
    464 .else
    465        mla             \tmp1\().8h, \src5\().8h, v0.h[4]
    466        mla             \tmp2\().8h, \src6\().8h, v0.h[4]
    467 .endif
    468        sqadd           \dst1\().8h, \dst1\().8h, \tmp1\().8h
    469        sqadd           \dst2\().8h, \dst2\().8h, \tmp2\().8h
    470 .endm
    471 
    472 // Load pixels and extend them to 16 bit
    473 .macro loadl dst1, dst2, dst3, dst4
    474        ld1             {v1.8b}, [x2], x3
    475        ld1             {v2.8b}, [x2], x3
    476        ld1             {v3.8b}, [x2], x3
    477 .ifnb \dst4
    478        ld1             {v4.8b}, [x2], x3
    479 .endif
    480        uxtl            \dst1\().8h, v1.8b
    481        uxtl            \dst2\().8h, v2.8b
    482        uxtl            \dst3\().8h, v3.8b
    483 .ifnb \dst4
    484        uxtl            \dst4\().8h, v4.8b
    485 .endif
    486 .endm
    487 
    488 // Instantiate a vertical filter function for filtering 8 pixels at a time.
    489 // The height is passed in x4, the width in x5 and the filter coefficients
    490 // in x6. idx2 is the index of the largest filter coefficient (3 or 4)
    491 // and idx1 is the other one of them.
    492 .macro do_8tap_8v type, idx1, idx2
    493 function \type\()_8tap_8v_\idx1\idx2
    494        sub             x2,  x2,  x3, lsl #1
    495        sub             x2,  x2,  x3
    496        ld1             {v0.8h},  [x6]
    497 1:
    498 .ifc \type,avg
    499        mov             x7,  x0
    500 .endif
    501        mov             x6,  x4
    502 
    503        loadl           v17, v18, v19
    504 
    505        loadl           v20, v21, v22, v23
    506 2:
    507        loadl           v24, v25, v26, v27
    508        convolve        v1,  v2,  v17, v18, v19, v20, v21, v22, v23, v24, v25, \idx1, \idx2, v5,  v6
    509        convolve        v3,  v4,  v19, v20, v21, v22, v23, v24, v25, v26, v27, \idx1, \idx2, v5,  v6
    510        do_store        v1,  v2,  v3,  v4,  v5,  v6,  v7,  v28, \type
    511 
    512        subs            x6,  x6,  #4
    513        b.eq            8f
    514 
    515        loadl           v16, v17, v18, v19
    516        convolve        v1,  v2,  v21, v22, v23, v24, v25, v26, v27, v16, v17, \idx1, \idx2, v5,  v6
    517        convolve        v3,  v4,  v23, v24, v25, v26, v27, v16, v17, v18, v19, \idx1, \idx2, v5,  v6
    518        do_store        v1,  v2,  v3,  v4,  v5,  v6,  v7,  v28, \type
    519 
    520        subs            x6,  x6,  #4
    521        b.eq            8f
    522 
    523        loadl           v20, v21, v22, v23
    524        convolve        v1,  v2,  v25, v26, v27, v16, v17, v18, v19, v20, v21, \idx1, \idx2, v5,  v6
    525        convolve        v3,  v4,  v27, v16, v17, v18, v19, v20, v21, v22, v23, \idx1, \idx2, v5,  v6
    526        do_store        v1,  v2,  v3,  v4,  v5,  v6,  v7,  v28, \type
    527 
    528        subs            x6,  x6,  #4
    529        b.ne            2b
    530 
    531 8:
    532        subs            x5,  x5,  #8
    533        b.eq            9f
    534        // x0 -= h * dst_stride
    535        msub            x0,  x1,  x4, x0
    536        // x2 -= h * src_stride
    537        msub            x2,  x3,  x4, x2
    538        // x2 -= 8 * src_stride
    539        sub             x2,  x2,  x3, lsl #3
    540        // x2 += 1 * src_stride
    541        add             x2,  x2,  x3
    542        add             x2,  x2,  #8
    543        add             x0,  x0,  #8
    544        b               1b
    545 9:
    546        ret
    547 endfunc
    548 .endm
    549 
    550 do_8tap_8v put, 3, 4
    551 do_8tap_8v put, 4, 3
    552 do_8tap_8v avg, 3, 4
    553 do_8tap_8v avg, 4, 3
    554 
    555 
    556 // Instantiate a vertical filter function for filtering a 4 pixels wide
    557 // slice. The first half of the registers contain one row, while the second
    558 // half of a register contains the second-next row (also stored in the first
    559 // half of the register two steps ahead). The convolution does two outputs
    560 // at a time; the output of v17-v24 into one, and v18-v25 into another one.
    561 // The first half of first output is the first output row, the first half
    562 // of the other output is the second output row. The second halves of the
    563 // registers are rows 3 and 4.
    564 // This only is designed to work for 4 or 8 output lines.
    565 .macro do_8tap_4v type, idx1, idx2
    566 function \type\()_8tap_4v_\idx1\idx2
    567        sub             x2,  x2,  x3, lsl #1
    568        sub             x2,  x2,  x3
    569        ld1             {v0.8h},  [x6]
    570 .ifc \type,avg
    571        mov             x7,  x0
    572 .endif
    573 
    574        ld1             {v1.s}[0],  [x2], x3
    575        ld1             {v2.s}[0],  [x2], x3
    576        ld1             {v3.s}[0],  [x2], x3
    577        ld1             {v4.s}[0],  [x2], x3
    578        ld1             {v5.s}[0],  [x2], x3
    579        ld1             {v6.s}[0],  [x2], x3
    580        trn1            v1.2s,  v1.2s,  v3.2s
    581        ld1             {v7.s}[0],  [x2], x3
    582        trn1            v2.2s,  v2.2s,  v4.2s
    583        ld1             {v26.s}[0], [x2], x3
    584        uxtl            v17.8h, v1.8b
    585        trn1            v3.2s,  v3.2s,  v5.2s
    586        ld1             {v27.s}[0], [x2], x3
    587        uxtl            v18.8h, v2.8b
    588        trn1            v4.2s,  v4.2s,  v6.2s
    589        ld1             {v28.s}[0], [x2], x3
    590        uxtl            v19.8h, v3.8b
    591        trn1            v5.2s,  v5.2s,  v7.2s
    592        ld1             {v29.s}[0], [x2], x3
    593        uxtl            v20.8h, v4.8b
    594        trn1            v6.2s,  v6.2s,  v26.2s
    595        uxtl            v21.8h, v5.8b
    596        trn1            v7.2s,  v7.2s,  v27.2s
    597        uxtl            v22.8h, v6.8b
    598        trn1            v26.2s, v26.2s, v28.2s
    599        uxtl            v23.8h, v7.8b
    600        trn1            v27.2s, v27.2s, v29.2s
    601        uxtl            v24.8h, v26.8b
    602        uxtl            v25.8h, v27.8b
    603 
    604        convolve        v1,  v2,  v17, v18, v19, v20, v21, v22, v23, v24, v25, \idx1, \idx2, v3,  v4
    605        do_store4       v1,  v2,  v5,  v6,  \type
    606 
    607        subs            x4,  x4,  #4
    608        b.eq            9f
    609 
    610        ld1             {v1.s}[0],  [x2], x3
    611        ld1             {v2.s}[0],  [x2], x3
    612        trn1            v28.2s, v28.2s, v1.2s
    613        trn1            v29.2s, v29.2s, v2.2s
    614        ld1             {v1.s}[1],  [x2], x3
    615        uxtl            v26.8h, v28.8b
    616        ld1             {v2.s}[1],  [x2], x3
    617        uxtl            v27.8h, v29.8b
    618        uxtl            v28.8h, v1.8b
    619        uxtl            v29.8h, v2.8b
    620 
    621        convolve        v1,  v2,  v21, v22, v23, v24, v25, v26, v27, v28, v29, \idx1, \idx2, v3,  v4
    622        do_store4       v1,  v2,  v5,  v6,  \type
    623 
    624 9:
    625        ret
    626 endfunc
    627 .endm
    628 
    629 do_8tap_4v put, 3, 4
    630 do_8tap_4v put, 4, 3
    631 do_8tap_4v avg, 3, 4
    632 do_8tap_4v avg, 4, 3
    633 
    634 
    635 .macro do_8tap_v_func type, filter, offset, size
    636 function ff_vp9_\type\()_\filter\()\size\()_v_neon, export=1
    637        uxtw            x4,  w4
    638        movrel          x5,  X(ff_vp9_subpel_filters), 256*\offset
    639        cmp             w6,  #8
    640        add             x6,  x5,  w6, uxtw #4
    641        mov             x5,  #\size
    642 .if \size >= 8
    643        b.ge            \type\()_8tap_8v_34
    644        b               \type\()_8tap_8v_43
    645 .else
    646        b.ge            \type\()_8tap_4v_34
    647        b               \type\()_8tap_4v_43
    648 .endif
    649 endfunc
    650 .endm
    651 
    652 .macro do_8tap_v_filters size
    653 do_8tap_v_func put, regular, 1, \size
    654 do_8tap_v_func avg, regular, 1, \size
    655 do_8tap_v_func put, sharp,   2, \size
    656 do_8tap_v_func avg, sharp,   2, \size
    657 do_8tap_v_func put, smooth,  0, \size
    658 do_8tap_v_func avg, smooth,  0, \size
    659 .endm
    660 
    661 do_8tap_v_filters 64
    662 do_8tap_v_filters 32
    663 do_8tap_v_filters 16
    664 do_8tap_v_filters 8
    665 do_8tap_v_filters 4