mirror of
https://github.com/opencv/opencv.git
synced 2024-12-16 02:19:12 +08:00
0de26fd78e
Zlib-ng is zlib replacement with optimizations for "next generation" systems. Its optimization may benifits image library decode and encode speed such as libpng. In our tests, if using zlib-ng and libpng combination on a x86_64 machine with AVX2, the time of `imdecode` amd `imencode` will drop 20% approximately. This patch enables zlib-ng's optimization if `CV_DISABLE_OPTIMIZATION` is OFF. Since Zlib-ng can dispatch intrinsics on the fly, port work is much easier. Related discussion: https://github.com/opencv/opencv/issues/22573
35 lines
1.1 KiB
C
35 lines
1.1 KiB
C
/* slide_hash_rvv.c - RVV version of slide_hash
|
|
* Copyright (C) 2023 SiFive, Inc. All rights reserved.
|
|
* Contributed by Alex Chiang <alex.chiang@sifive.com>
|
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
*/
|
|
|
|
#ifdef RISCV_RVV
|
|
|
|
#include <riscv_vector.h>
|
|
|
|
#include "../../zbuild.h"
|
|
#include "../../deflate.h"
|
|
|
|
static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) {
|
|
size_t vl;
|
|
while (entries > 0) {
|
|
vl = __riscv_vsetvl_e16m4(entries);
|
|
vuint16m4_t v_tab = __riscv_vle16_v_u16m4(table, vl);
|
|
vuint16m4_t v_diff = __riscv_vsub_vx_u16m4(v_tab, wsize, vl);
|
|
vbool4_t mask = __riscv_vmsltu_vx_u16m4_b4(v_tab, wsize, vl);
|
|
v_tab = __riscv_vmerge_vxm_u16m4(v_diff, 0, mask, vl);
|
|
__riscv_vse16_v_u16m4(table, v_tab, vl);
|
|
table += vl, entries -= vl;
|
|
}
|
|
}
|
|
|
|
Z_INTERNAL void slide_hash_rvv(deflate_state *s) {
|
|
uint16_t wsize = (uint16_t)s->w_size;
|
|
|
|
slide_hash_chain(s->head, HASH_SIZE, wsize);
|
|
slide_hash_chain(s->prev, wsize, wsize);
|
|
}
|
|
|
|
#endif // RISCV_RVV
|