1
0
mirror of https://github.com/libjpeg-turbo/libjpeg-turbo.git synced 2026-10-23 11:48:53 +03:00
Files
libjpeg-turbo/simd/jsimdconst.h
DRC 9817c40854 RISC-V Vector (RVV) SIMD extensions
Based on:
d48f1ff2fb
137fe9ef72
6d2f276fd0
462954dc51
d5ac20d3ef
6c68dcaad4
cdb255c60f
acb51a1d8d
b5b660b629

Improvements relative to the aforementioned implementation:

- ~145% faster RGB-to-YCbCr color conversion
  ~156% faster grayscale-to-YCbCr color conversion
  ~94% faster h2v1 downsampling
  ~167% faster h2v2 downsampling
  ~159% faster h2v2 fancy upsampling
  ~202% faster h2v1 plain upsampling
  ~290% faster h2v2 plain upsampling
  ~64% faster YCbCr-to-RGB color conversion
  ~54% faster h2v1 merged upsampling
  ~59% faster h2v2 merged upsampling

  This was mostly achieved by:
  * reducing non-contiguous memory accesses (including replacing strided
    loads/stores with segmented loads/stores),
  * using RVV instructions to generate a bias vector for downsampling,
    rather than using a clunky dynamically-allocated array and C code,
    and
  * restructuring the algorithms (usually based on my experience with
    other SIMD module implementations) to improve throughput and reduce
    register pressure.

  The DCT algorithms are unfortunately suboptimal at the moment, because
  they use strided loads/stores to transpose the 8x8 coefficient matrix.
  I tried using segmented loads/stores, as well as implementing an
  in-register transpose with *vrgather*().  The former did not improve
  performance significantly, and the latter was slower.  The new Zvzip
  RVV extension should make it possible to implement a more efficient
  in-register transpose, which may open up opportunities for further
  optimization.  (The color conversion algorithms may benefit from that
  as well.)

- ~10-26% (average 18%) better overall RGB-to-baseline compression
  performance, and ~1-14% (average 8%) better overall baseline-to-RGB
  decompression performance.  (The forward and inverse DCT algorithms
  are still suboptimal, and they dominate overall performance.)

- Improved build-time detection of compiler support for RVV intrinsics

- Support for run-time RVV detection on *BSD (hypothetically, at least--
  I can only verify that the code compiles properly)

- Cleaned up run-time RVV detection on Linux

- Cleaned up SIMD dispatcher integration

- Descriptive code comments

- Corrected and added copyright attributions

- Code formatting tweaks

Closes #620
Closes #837
2026-02-03 09:34:50 -05:00

50 lines
1.8 KiB
C

/*
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2011, 2014, 2016, 2018, 2025-2026, D. R. Commander.
* Copyright (C) 2016-2017, Loongson Technology Corporation Limited, BeiJing.
* Copyright (C) 2025, Samsung Electronics Co., Ltd.
* Author: Filip Wasil
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
/* Supported CPU architectures */
#define NONE -1
#define X86_64 0
#define I386 1
#define ARM64 2
#define ARM 3
#define POWERPC 4
#define RISCV64 5
#define MIPS64 6
/* Bitmask for supported SIMD instruction sets */
#define JSIMD_NONE 0x00
#define JSIMD_MMX 0x01
#define JSIMD_3DNOW 0x02
#define JSIMD_SSE 0x04
#define JSIMD_SSE2 0x08
#define JSIMD_NEON 0x10
#define JSIMD_RVV 0x20
#define JSIMD_ALTIVEC 0x40
#define JSIMD_AVX2 0x80
#define JSIMD_MMI 0x100
#define JSIMD_MAX 0x100
#define JSIMD_UNDEFINED ~(JSIMD_MAX * 2U - 1U)