Repository navigation
Conversation
skal65535
force-pushed
the
skal/simd
branch
from
September 21, 2026 23:07
72b9a8f to
8423f6a
Compare
skal65535
added a commit
that referenced
this pull request
Sep 22, 2026
Shared SIMD infra belongs in simd.h (PR #201), not sjpegi.h. Revert the cross-file sharing and keep HorizontalSumS32/S16 duplicated locally in riskiness_avx2.cc and jpeg_tools.cc for now; both still drop the redundant u16 gray-count variant. TODO markers point at simd.h for the follow-up once #201 lands.
skal65535
force-pushed
the
skal/simd
branch
from
September 22, 2026 05:53
c5633df to
bec726a
Compare
jzern
approved these changes
Sep 23, 2026
Introduces src/simd.h with shared SSE2/AVX2/NEON helpers: - LOAD_16/32, STORE_16/32, LOAD_64/STORE_64 unaligned/aligned macros - ABS_16/ABS_32 (16-bit absolute value) - HorizontalSumS32/HorizontalSumS16 (vector-to-scalar reduction) Replaces the ad hoc load/store/abs intrinsics duplicated across quantize.cc, histogram.cc, fdct.cc, yuv_convert.cc and their AVX2 variants with these shared macros. The horizontal-sum helpers aren't consumed yet -- riskiness_avx2.cc and jpeg_tools.cc's NEON ScoreRow keep local copies pending a follow-up switch-over.
* simd.h: rename Neon-suffixed helpers to _NEON (drift from _SSE2) * simd.h: drop dead !__cplusplus fallback (never included from .c) * colors_rgb_avx2.cc: use LOAD_32/LOAD_ALIGNED_32/STORE_32 * riskiness_avx2.cc: use LOAD_16, reuse HorizontalSumS32/S16
skal65535
force-pushed
the
skal/simd
branch
from
September 23, 2026 06:22
bec726a to
2bd341e
Compare
jzern
reviewed
Sep 28, 2026
| struct NeonVector16 { | ||
| uint8x16_t v; | ||
| operator uint8x16_t() const { return v; } | ||
| #define SJPEG_NEON16_OP(T, S) \ |
Contributor
There was a problem hiding this comment.
A little too fancy for msvc since all vectors are typedef'd to a union:
typedef union __declspec(intrin_type) _ADVSIMD_ALIGN(16) __n128
{
unsigned __int64 n128_u64[2];
unsigned __int32 n128_u32[4];
unsigned __int16 n128_u16[8];
unsigned __int8 n128_u8[16];
__int64 n128_i64[2];
__int32 n128_i32[4];
__int16 n128_i16[8];
__int8 n128_i8[16];
poly64_t n128_p64[2];
poly32_t n128_p32[4];
poly16_t n128_p16[8];
poly8_t n128_p8[16];
float n128_f32[4];
double n128_f64[2];
struct
{
__n64 low64;
__n64 high64;
} DUMMYNEONSTRUCT;
} __n128;
typedef __n128 uint8x16_t;
src\simd.h(147,3): error C2535: 'NeonVector16::operator uint8x16_t(void) const': member function already defined or
declared
(compiling source file '../src/jpeg_tools.cc')
C:\src\external\sjpeg\src\simd.h(144,3):
see declaration of 'NeonVector16::operator uint8x16_t'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidate common SSE2 / SSSE3 / AVX2 / NEON load, store, and absolute value vector intrinsics into a new centralized header
src/simd.h, eliminating raw load/store intrinsics across all.ccimplementation files.Details
src/simd.h):LOAD_16(src),LOAD_ALIGNED_16(src),STORE_16(val, dst),STORE_ALIGNED_16(val, dst)LOAD_64(src),STORE_64(val, dst)LOAD_32(src),LOAD_ALIGNED_32(src),STORE_32(val, dst),STORE_ALIGNED_32(val, dst)ABS_16(v)(SSSE3_mm_abs_epi16with SSE2 3-op fallback, NEONvabsq_s16)ABS_32(v)(_mm256_abs_epi16)NeonVector16/NeonVector8type reinterpretation operators andStore16Neon/Store8Neonoverloads into concise macro generators (SJPEG_NEON16_OP,SJPEG_NEON8_OP,SJPEG_STORE_NEON).src/colors_rgb.cc,src/quantize.cc,src/histogram_avx2.cc, andsrc/yuv_convert.cc.STORE_16calls to(value, destination)._mm_loadu_*,_mm_storeu_*,_mm256_loadu_*,_mm256_storeu_*, and_mm_loadl_epi64calls acrosssrc/histogram.cc,src/quantize_avx2.cc,src/riskiness_avx2.cc,src/yuv_convert_avx2.cc,src/fdct.cc, andsrc/fdct_avx2.cc.QuantizeBlockSSE2andQuantizeErrorSSE2insrc/quantize.cctoABS_16, enabling automatic SSSE3 hardware acceleration.Encoder::SetRDO(bool)setter insrc/enc.ccand used it insrc/api.ccto avoid direct private member access, with unit test coverage intests/unit_test.cc.src/simd.hto bothCMakeLists.txtandMakefile.