History

lavc/h264dsp: R-V V high-depth h264_idct8_add

Unlike the 8-bit version, we need two iterations to process this within 128-bit vectors. This adds some extra complexity for pointer arithmetic and counting down which is unnecessary in the 8-bit variant. Accordingly the gain relative to C are just slight better than half as good with 128-bit vectors as with 256-bit ones. T-Head C908 (2 iterations): h264_idct8_add_9bpp_c: 17.5 h264_idct8_add_9bpp_rvv_i32: 10.0 h264_idct8_add_10bpp_c: 17.5 h264_idct8_add_10bpp_rvv_i32: 9.7 h264_idct8_add_12bpp_c: 17.7 h264_idct8_add_12bpp_rvv_i32: 9.7 h264_idct8_add_14bpp_c: 17.7 h264_idct8_add_14bpp_rvv_i32: 9.7 SpacemiT X60 (single iteration): h264_idct8_add_9bpp_c: 15.2 h264_idct8_add_9bpp_rvv_i32: 5.0 h264_idct8_add_10bpp_c: 15.2 h264_idct8_add_10bpp_rvv_i32: 5.0 h264_idct8_add_12bpp_c: 14.7 h264_idct8_add_12bpp_rvv_i32: 5.0 h264_idct8_add_14bpp_c: 14.7 h264_idct8_add_14bpp_rvv_i32: 4.7

Rémi Denis-Courmont committed 2 years ago

Commit c654e371 parent 80ddc722 files · +140 −15Browse files

Unified · Split

2 files
  1. libavcodec/riscv/h264dsp_init.c +24 −8
  2. libavcodec/riscv/h264idct_rvv.S +116 −7
libavcodec/riscv/h264dsp_init.c+24−8
@@ -53,9 +53,13 @@ void ff_h264_idct8_add4_8_rvv(uint8_t *dst, const int *blockoffset, · 52 unmodified lines
5353 const uint8_t nnzc[5 * 8]);
5454
5555 void ff_h264_idct_add_9_rvv(uint8_t *dst, int16_t *block, int stride);
56+void ff_h264_idct8_add_9_rvv(uint8_t *dst, int16_t *block, int stride);
5657 void ff_h264_idct_add_10_rvv(uint8_t *dst, int16_t *block, int stride);
58+void ff_h264_idct8_add_10_rvv(uint8_t *dst, int16_t *block, int stride);
5759 void ff_h264_idct_add_12_rvv(uint8_t *dst, int16_t *block, int stride);
60+void ff_h264_idct8_add_12_rvv(uint8_t *dst, int16_t *block, int stride);
5861 void ff_h264_idct_add_14_rvv(uint8_t *dst, int16_t *block, int stride);
62+void ff_h264_idct8_add_14_rvv(uint8_t *dst, int16_t *block, int stride);
5963
6064 extern int ff_startcode_find_candidate_rvb(const uint8_t *, int);
6165 extern int ff_startcode_find_candidate_rvv(const uint8_t *, int);
@@ -94,14 +98,26 @@ av_cold void ff_h264dsp_init_riscv(H264DSPContext *dsp, const int bit_depth, · 32 unmodified lines
9498 # endif
9599 }
96100
97− if (bit_depth == 9 && zvl128b)
98− dsp->h264_idct_add = ff_h264_idct_add_9_rvv;
99− if (bit_depth == 10 && zvl128b)
100− dsp->h264_idct_add = ff_h264_idct_add_10_rvv;
101− if (bit_depth == 12 && zvl128b)
102− dsp->h264_idct_add = ff_h264_idct_add_12_rvv;
103− if (bit_depth == 14 && zvl128b)
104− dsp->h264_idct_add = ff_h264_idct_add_14_rvv;
101+ if (bit_depth == 9) {
102+ if (zvl128b)
103+ dsp->h264_idct_add = ff_h264_idct_add_9_rvv;
104+ dsp->h264_idct8_add = ff_h264_idct8_add_9_rvv;
105+ }
106+ if (bit_depth == 10) {
107+ if (zvl128b)
108+ dsp->h264_idct_add = ff_h264_idct_add_10_rvv;
109+ dsp->h264_idct8_add = ff_h264_idct8_add_10_rvv;
110+ }
111+ if (bit_depth == 12) {
112+ if (zvl128b)
113+ dsp->h264_idct_add = ff_h264_idct_add_12_rvv;
114+ dsp->h264_idct8_add = ff_h264_idct8_add_12_rvv;
115+ }
116+ if (bit_depth == 14) {
117+ if (zvl128b)
118+ dsp->h264_idct_add = ff_h264_idct_add_14_rvv;
119+ dsp->h264_idct8_add = ff_h264_idct8_add_14_rvv;
120+ }
105121
106122 dsp->startcode_find_candidate = ff_startcode_find_candidate_rvv;
107123 }
libavcodec/riscv/h264idct_rvv.S+116−7
@@ -161,13 +161,6 @@ func ff_h264_idct_add_16_rvv, zve32x · 160 unmodified lines
161161 ret
162162 endfunc
163163
164−.irp depth, 9, 10, 12, 14
165−func ff_h264_idct_add_\depth\()_rvv, zve32x
166− li a3, (1 << \depth) - 1
167− j ff_h264_idct_add_16_rvv
168−endfunc
169−.endr
170−
171164 .variant_cc ff_h264_idct8_rvv
172165 func ff_h264_idct8_rvv, zve32x
173166 vsra.vi v9, v7, 1
@@ -301,6 +294,122 @@ func ff_h264_idct8_add_8_rvv, zve32x · 127 unmodified lines
301294 ret
302295 endfunc
303296
297+func ff_h264_idct8_add_16_rvv, zve32x
298+ li a4, 8
299+ csrwi vxrm, 0
300+ vsetivli a5, 8, e32, m1, ta, ma
301+1:
302+ addi t1, a1, 1 * 8 * 4
303+ vle32.v v0, (a1)
304+ addi t2, a1, 2 * 8 * 4
305+ vle32.v v1, (t1)
306+ addi t3, a1, 3 * 8 * 4
307+ vle32.v v2, (t2)
308+ addi t4, a1, 4 * 8 * 4
309+ vle32.v v3, (t3)
310+ addi t5, a1, 5 * 8 * 4
311+ vle32.v v4, (t4)
312+ addi t6, a1, 6 * 8 * 4
313+ vle32.v v5, (t5)
314+ addi a7, a1, 7 * 8 * 4
315+ vle32.v v6, (t6)
316+ sub a4, a4, a5
317+ vle32.v v7, (a7)
318+ jal t0, ff_h264_idct8_rvv
319+ vse32.v v0, (a1)
320+ sh2add a1, a5, a1
321+ vse32.v v1, (t1)
322+ vse32.v v2, (t2)
323+ vse32.v v3, (t3)
324+ vse32.v v4, (t4)
325+ vse32.v v5, (t5)
326+ vse32.v v6, (t6)
327+ vse32.v v7, (a7)
328+ bnez a4, 1b
329+
330+ addi a1, a1, -8 * 4
331+ li a4, 8
332+ slli a6, a5, 3 + 2
333+2:
334+ vsetvli zero, zero, e32, m1, ta, ma
335+ vlseg8e32.v v0, (a1)
336+ jal t0, ff_h264_idct8_rvv
337+ add t1, a0, a2
338+ vle16.v v16, (a0)
339+ add t2, t1, a2
340+ vle16.v v17, (t1)
341+ add t3, t2, a2
342+ vle16.v v18, (t2)
343+ add t4, t3, a2
344+ vle16.v v19, (t3)
345+ add t5, t4, a2
346+ vle16.v v20, (t4)
347+ add t6, t5, a2
348+ vle16.v v21, (t5)
349+ add a7, t6, a2
350+ vle16.v v22, (t6)
351+ sub a4, a4, a5
352+ vle16.v v23, (a7)
353+ .irp n,0,1,2,3,4,5,6,7
354+ vssra.vi v\n, v\n, 6
355+ .endr
356+ vsetvli zero, zero, e16, mf2, ta, ma
357+ vwaddu.wv v0, v0, v16
358+ add a1, a6, a1
359+ vwaddu.wv v1, v1, v17
360+ vwaddu.wv v2, v2, v18
361+ vwaddu.wv v3, v3, v19
362+ vwaddu.wv v4, v4, v20
363+ vwaddu.wv v5, v5, v21
364+ vwaddu.wv v6, v6, v22
365+ vwaddu.wv v7, v7, v23
366+ vsetvli zero, zero, e32, m1, ta, ma
367+ .irp n,0,1,2,3,4,5,6,7
368+ vmax.vx v\n, v\n, zero
369+ .endr
370+ .irp n,0,1,2,3,4,5,6,7
371+ vmin.vx v\n, v\n, a3
372+ .endr
373+ vsetvli zero, zero, e16, mf2, ta, ma
374+ vncvt.x.x.w v16, v0
375+ vncvt.x.x.w v17, v1
376+ vncvt.x.x.w v18, v2
377+ vncvt.x.x.w v19, v3
378+ vncvt.x.x.w v20, v4
379+ vncvt.x.x.w v21, v5
380+ vncvt.x.x.w v22, v6
381+ vncvt.x.x.w v23, v7
382+ vse16.v v16, (a0)
383+ sh1add a0, a5, a0
384+ vse16.v v17, (t1)
385+ vse16.v v18, (t2)
386+ vse16.v v19, (t3)
387+ vse16.v v20, (t4)
388+ vse16.v v21, (t5)
389+ vse16.v v22, (t6)
390+ vse16.v v23, (a7)
391+ bnez a4, 2b
392+
393+ .equ offset, 0
394+ .rept 2048 / __riscv_xlen
395+ sx zero, offset - 8 * 8 * 4(a1)
396+ .equ offset, offset + (__riscv_xlen / 8)
397+ .endr
398+ ret
399+endfunc
400+
401+.irp depth, 9, 10, 12, 14
402+func ff_h264_idct_add_\depth\()_rvv, zve32x
403+ li a3, (1 << \depth) - 1
404+ j ff_h264_idct_add_16_rvv
405+endfunc
406+
407+func ff_h264_idct8_add_\depth\()_rvv, zve32x
408+ li a3, (1 << \depth) - 1
409+ j ff_h264_idct8_add_16_rvv
410+endfunc
411+.endr
412+
304413 const ff_h264_scan8
305414 .byte 014, 015, 024, 025, 016, 017, 026, 027
306415 .byte 034, 035, 044, 045, 036, 037, 046, 047

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