| @@ -0,0 +1,58 @@ |
| 1 | +/* |
| 2 | + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS). |
| 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/riscv/asm.S" |
| 22 | + |
| 23 | +.macro vsetvlstatic8 len an maxlen mn=m4 |
| 24 | +.if \len == 4 |
| 25 | + vsetivli zero, \len, e8, mf4, ta, ma |
| 26 | +.elseif \len == 8 |
| 27 | + vsetivli zero, \len, e8, mf2, ta, ma |
| 28 | +.elseif \len == 16 |
| 29 | + vsetivli zero, \len, e8, m1, ta, ma |
| 30 | +.elseif \len == 32 |
| 31 | + li \an, \len |
| 32 | + vsetvli zero, \an, e8, m2, ta, ma |
| 33 | +.elseif \len == 64 |
| 34 | + li \an, \maxlen |
| 35 | + vsetvli zero, \an, e8, \mn, ta, ma |
| 36 | +.endif |
| 37 | +.endm |
| 38 | + |
| 39 | +.macro copy_avg len |
| 40 | +func ff_avg\len\()_rvv, zve32x |
| 41 | + csrwi vxrm, 0 |
| 42 | + vsetvlstatic8 \len t0 64 |
| 43 | +1: |
| 44 | + vle8.v v8, (a2) |
| 45 | + vle8.v v16, (a0) |
| 46 | + vaaddu.vv v8, v8, v16 |
| 47 | + addi a4, a4, -1 |
| 48 | + vse8.v v8, (a0) |
| 49 | + add a2, a2, a3 |
| 50 | + add a0, a0, a1 |
| 51 | + bnez a4, 1b |
| 52 | + ret |
| 53 | +endfunc |
| 54 | +.endm |
| 55 | + |
| 56 | +.irp len, 64, 32, 16, 8, 4 |
| 57 | + copy_avg \len |
| 58 | +.endr |