History

lavc/h264dsp: R-V V 8-bit h264_biweight_pixels

T-Head C908: h264_biweight2_8_c: 58.0 h264_biweight2_8_rvv_i32: 11.2 h264_biweight4_8_c: 106.0 h264_biweight4_8_rvv_i32: 22.7 h264_biweight8_8_c: 205.7 h264_biweight8_8_rvv_i32: 50.0 h264_biweight16_8_c: 403.5 h264_biweight16_8_rvv_i32: 83.2 SpacemiT X60: h264_weight2_8_c: 48.2 h264_weight2_8_rvv_i32: 8.2 h264_weight4_8_c: 90.5 h264_weight4_8_rvv_i32: 16.5 h264_weight8_8_c: 175.2 h264_weight8_8_rvv_i32: 38.0 h264_weight16_8_c: 342.2 h264_weight16_8_rvv_i32: 66.0

Rémi Denis-Courmont committed 2 years ago

Commit f1ed3511 parent 3606e592 files · +98 −4Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/riscv/h264dsp_init.c +10 −4
  2. libavcodec/riscv/h264dsp_rvv.S +88 −0
libavcodec/riscv/h264dsp_init.c+10−4
@@ -28,7 +28,10 @@ · 27 unmodified lines
28#include "libavutil/riscv/cpu.h"28#include "libavutil/riscv/cpu.h"
29#include "libavcodec/h264dsp.h"29#include "libavcodec/h264dsp.h"
30 30
31extern const h264_weight_func ff_h264_weight_funcs_8_rvv[];31extern const struct {
32 const h264_weight_func weight;
33 const h264_biweight_func biweight;
34} ff_h264_weight_funcs_8_rvv[];
32 35
33void ff_h264_v_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride,36void ff_h264_v_loop_filter_luma_8_rvv(uint8_t *pix, ptrdiff_t stride,
34 int alpha, int beta, int8_t *tc0);37 int alpha, int beta, int8_t *tc0);
@@ -63,9 +66,12 @@ av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const int bit_depth, · 28 unmodified lines
63# if HAVE_RVV66# if HAVE_RVV
64 if (flags & AV_CPU_FLAG_RVV_I32) {67 if (flags & AV_CPU_FLAG_RVV_I32) {
65 if (bit_depth == 8 && ff_rv_vlen_least(128)) {68 if (bit_depth == 8 && ff_rv_vlen_least(128)) {
66 memcpy(dsp->weight_h264_pixels_tab,69 for (int i = 0; i < 4; i++) {
67 ff_h264_weight_funcs_8_rvv,70 dsp->weight_h264_pixels_tab[i] =
68 sizeof (dsp->weight_h264_pixels_tab));71 ff_h264_weight_funcs_8_rvv[i].weight;
72 dsp->biweight_h264_pixels_tab[i] =
73 ff_h264_weight_funcs_8_rvv[i].biweight;
74 }
69 75
70 dsp->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_8_rvv;76 dsp->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_8_rvv;
71 dsp->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_8_rvv;77 dsp->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_8_rvv;
libavcodec/riscv/h264dsp_rvv.S+88−0
@@ -48,6 +48,35 @@ func ff_h264_weight_pixels_simple_8_rvv, zve32x · 47 unmodified lines
48 ret48 ret
49endfunc49endfunc
50 50
51 .variant_cc ff_h264_biweight_pixels_simple_8_rvv
52func ff_h264_biweight_pixels_simple_8_rvv, zve32x
53 csrwi vxrm, 2
54 addi a7, a7, 1
55 ori a7, a7, 1
56 sll a7, a7, a4
571:
58 vsetvli zero, t6, e32, m4, ta, ma
59 vle8.v v8, (a0)
60 addi a3, a3, -1
61 vle8.v v12, (a1)
62 add a1, a1, a2
63 vmv.v.x v16, a7
64 vsetvli zero, zero, e16, m2, ta, ma
65 vzext.vf2 v24, v8
66 vzext.vf2 v28, v12
67 vwmaccsu.vx v16, a5, v24
68 vwmaccsu.vx v16, a6, v28
69 vnclip.wx v16, v16, a4
70 vmax.vx v16, v16, zero
71 vsetvli zero, zero, e8, m1, ta, ma
72 vnclipu.wi v8, v16, 1
73 vse8.v v8, (a0)
74 add a0, a0, a2
75 bnez a3, 1b
76
77 ret
78endfunc
79
51func ff_h264_weight_pixels_8_rvv, zve32x80func ff_h264_weight_pixels_8_rvv, zve32x
52 csrwi vxrm, 081 csrwi vxrm, 0
53 sll a5, a5, a382 sll a5, a5, a3
@@ -84,6 +113,53 @@ func ff_h264_weight_pixels_8_rvv, zve32x · 30 unmodified lines
84 ret113 ret
85endfunc114endfunc
86 115
116 .variant_cc ff_h264_biweight_pixels_8_rvv
117func ff_h264_biweight_pixels_8_rvv, zve32x
118 csrwi vxrm, 2
119 addi a7, a7, 1
120 ori a7, a7, 1
121 sll a7, a7, a4
1221:
123 mv t0, a0
124 mv t1, a1
125 mv t5, t6
1262:
127 vsetvli t2, a3, e32, m8, ta, ma
128 vlsseg2e8.v v0, (t0), a2
129 vlsseg2e8.v v4, (t1), a2
130 addi t5, t5, -2
131 vmv.v.x v16, a7
132 vmv.v.x v24, a7
133 vsetvli zero, zero, e16, m4, ta, ma
134 vzext.vf2 v8, v0
135 vzext.vf2 v12, v2
136 vwmaccsu.vx v16, a5, v8
137 vwmaccsu.vx v24, a5, v12
138 vzext.vf2 v8, v4
139 vzext.vf2 v12, v6
140 vwmaccsu.vx v16, a6, v8
141 vwmaccsu.vx v24, a6, v12
142 vnclip.wx v8, v16, a4
143 vnclip.wx v12, v24, a4
144 vmax.vx v8, v8, zero
145 vmax.vx v12, v12, zero
146 vsetvli zero, zero, e8, m2, ta, ma
147 vnclipu.wi v0, v8, 1
148 vnclipu.wi v2, v12, 1
149 vssseg2e8.v v0, (t0), a2
150 addi t0, t0, 2
151 addi t1, t1, 2
152 bnez t5, 2b
153
154 mul t3, a2, t2
155 sub a3, a3, t2
156 add a0, a0, t3
157 add a1, a1, t3
158 bnez a3, 1b
159
160 ret
161endfunc
162
87.irp w, 16, 8, 4, 2163.irp w, 16, 8, 4, 2
88func ff_h264_weight_pixels\w\()_8_rvv, zve32x164func ff_h264_weight_pixels\w\()_8_rvv, zve32x
89 li a6, \w165 li a6, \w
@@ -93,6 +169,15 @@ func ff_h264_weight_pixels\w\()_8_rvv, zve32x · 3 unmodified lines
93 j ff_h264_weight_pixels_8_rvv169 j ff_h264_weight_pixels_8_rvv
94 .endif170 .endif
95endfunc171endfunc
172
173func ff_h264_biweight_pixels\w\()_8_rvv, zve32x
174 li t6, \w
175 .if \w == 16
176 j ff_h264_biweight_pixels_simple_8_rvv
177 .else
178 j ff_h264_biweight_pixels_8_rvv
179 .endif
180endfunc
96.endr181.endr
97 182
98 .global ff_h264_weight_funcs_8_rvv183 .global ff_h264_weight_funcs_8_rvv
@@ -101,10 +186,13 @@ const ff_h264_weight_funcs_8_rvv · 2 unmodified lines
101 .irp w, 16, 8, 4, 2186 .irp w, 16, 8, 4, 2
102#if __riscv_xlen == 32187#if __riscv_xlen == 32
103 .word ff_h264_weight_pixels\w\()_8_rvv188 .word ff_h264_weight_pixels\w\()_8_rvv
189 .word ff_h264_biweight_pixels\w\()_8_rvv
104#elif __riscv_xlen == 64190#elif __riscv_xlen == 64
105 .dword ff_h264_weight_pixels\w\()_8_rvv191 .dword ff_h264_weight_pixels\w\()_8_rvv
192 .dword ff_h264_biweight_pixels\w\()_8_rvv
106#else193#else
107 .qword ff_h264_weight_pixels\w\()_8_rvv194 .qword ff_h264_weight_pixels\w\()_8_rvv
195 .qword ff_h264_biweight_pixels\w\()_8_rvv
108#endif196#endif
109 .endr197 .endr
110endconst198endconst

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t