Skip to content

Commit

Permalink
reduces reliance on literals
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Nov 5, 2024
1 parent 8114a11 commit c73bfe4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccp-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
include: [
{ system: MacOS, runner: macos-13 },
{ system: MacOS, runner: macos-13, macos-latest },
{ system: Ubuntu-latest, runner: ubuntu-latest },
]
name: ${{ matrix.system }} Test
Expand Down
12 changes: 6 additions & 6 deletions src/core/codestream/ojph_codestream_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace ojph {

// convert to sign and magnitude and keep max_val
ui32 shift = 31 - K_max;
__m256i m0 = _mm256_set1_epi32((int)0x80000000);
__m256i m0 = _mm256_set1_epi32(INT_MIN);
__m256i tmax = _mm256_loadu_si256((__m256i*)max_val);
__m256i *p = (__m256i*)sp;
for (ui32 i = 0; i < count; i += 8, p += 1, dp += 8)
Expand All @@ -99,7 +99,7 @@ namespace ojph {

//quantize and convert to sign and magnitude and keep max_val
__m256 d = _mm256_set1_ps(delta_inv);
__m256i m0 = _mm256_set1_epi32((int)0x80000000);
__m256i m0 = _mm256_set1_epi32(INT_MIN);
__m256i tmax = _mm256_loadu_si256((__m256i*)max_val);
float *p = (float*)sp;

Expand All @@ -123,7 +123,7 @@ namespace ojph {
{
ojph_unused(delta);
ui32 shift = 31 - K_max;
__m256i m1 = _mm256_set1_epi32(0x7FFFFFFF);
__m256i m1 = _mm256_set1_epi32(INT_MAX);
si32 *p = (si32*)dp;
for (ui32 i = 0; i < count; i += 8, sp += 8, p += 8)
{
Expand All @@ -140,7 +140,7 @@ namespace ojph {
float delta, ui32 count)
{
ojph_unused(K_max);
__m256i m1 = _mm256_set1_epi32(0x7FFFFFFF);
__m256i m1 = _mm256_set1_epi32(INT_MAX);
__m256 d = _mm256_set1_ps(delta);
float *p = (float*)dp;
for (ui32 i = 0; i < count; i += 8, sp += 8, p += 8)
Expand All @@ -163,7 +163,7 @@ namespace ojph {

// convert to sign and magnitude and keep max_val
ui32 shift = 63 - K_max;
__m256i m0 = _mm256_set1_epi64x(0x8000000000000000LL);
__m256i m0 = _mm256_set1_epi64x(LLONG_MIN);
__m256i zero = _mm256_setzero_si256();
__m256i one = _mm256_set1_epi64x(1);
__m256i tmax = _mm256_loadu_si256((__m256i*)max_val);
Expand Down Expand Up @@ -191,7 +191,7 @@ namespace ojph {
ojph_unused(delta);

ui32 shift = 63 - K_max;
__m256i m1 = _mm256_set1_epi64x(0x7FFFFFFFFFFFFFFFLL);
__m256i m1 = _mm256_set1_epi64x(LLONG_MAX);
__m256i zero = _mm256_setzero_si256();
__m256i one = _mm256_set1_epi64x(1);
si64 *p = (si64*)dp;
Expand Down
8 changes: 4 additions & 4 deletions src/core/codestream/ojph_codestream_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace ojph {
{
ojph_unused(delta);
ui32 shift = 31 - K_max;
__m128i m1 = _mm_set1_epi32(0x7FFFFFFF);
__m128i m1 = _mm_set1_epi32(INT_MAX);
__m128i zero = _mm_setzero_si128();
__m128i one = _mm_set1_epi32(1);
si32 *p = (si32*)dp;
Expand All @@ -160,7 +160,7 @@ namespace ojph {
float delta, ui32 count)
{
ojph_unused(K_max);
__m128i m1 = _mm_set1_epi32(0x7FFFFFFF);
__m128i m1 = _mm_set1_epi32(INT_MAX);
__m128 d = _mm_set1_ps(delta);
float *p = (float*)dp;
for (ui32 i = 0; i < count; i += 4, sp += 4, p += 4)
Expand All @@ -183,7 +183,7 @@ namespace ojph {

// convert to sign and magnitude and keep max_val
ui32 shift = 63 - K_max;
__m128i m0 = _mm_set1_epi64x(0x8000000000000000LL);
__m128i m0 = _mm_set1_epi64x(LLONG_MIN);
__m128i zero = _mm_setzero_si128();
__m128i one = _mm_set1_epi64x(1);
__m128i tmax = _mm_loadu_si128((__m128i*)max_val);
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace ojph {
{
ojph_unused(delta);
ui32 shift = 63 - K_max;
__m128i m1 = _mm_set1_epi64x(0x7FFFFFFFFFFFFFFFLL);
__m128i m1 = _mm_set1_epi64x(LLONG_MAX);
__m128i zero = _mm_setzero_si128();
__m128i one = _mm_set1_epi64x(1);
si64 *p = (si64*)dp;
Expand Down
2 changes: 1 addition & 1 deletion src/core/transform/ojph_colour_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ namespace ojph {
(g->flags & line_buf::LFT_32BIT) &&
(b->flags & line_buf::LFT_32BIT));
__m128i v2 = _mm_set1_epi64x(1ULL << (63 - 2));
__m128i low_bits = _mm_set_epi64x(0, 0xFFFFFFFFFFFFFFFFLL);
__m128i low_bits = _mm_set_epi64x(0, ULLONG_MAX);
const si64 *yp = y->i64, *cbp = cb->i64, *crp = cr->i64;
si32 *rp = r->i32, *gp = g->i32, *bp = b->i32;
for (int i = (repeat + 3) >> 2; i > 0; --i)
Expand Down
6 changes: 3 additions & 3 deletions src/core/transform/ojph_transform_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ namespace ojph {
const si32 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m256i vb = _mm256_set1_epi64x(b);
__m256i ve = _mm256_set1_epi64x(1ULL << (63 - e));
__m256i ve = _mm256_set1_epi64x(1LL << (63 - e));

si64* dst = aug->i64;
const si64* src1 = sig->i64, * src2 = other->i64;
Expand Down Expand Up @@ -621,7 +621,7 @@ namespace ojph {
const si32 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m256i vb = _mm256_set1_epi64x(b);
__m256i ve = _mm256_set1_epi64x(1ULL << (63 - e));
__m256i ve = _mm256_set1_epi64x(1LL << (63 - e));

// extension
lp[-1] = lp[0];
Expand Down Expand Up @@ -977,7 +977,7 @@ namespace ojph {
const si32 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m256i vb = _mm256_set1_epi64x(b);
__m256i ve = _mm256_set1_epi64x(1ULL << (63 - e));
__m256i ve = _mm256_set1_epi64x(1LL << (63 - e));

// extension
oth[-1] = oth[0];
Expand Down
6 changes: 3 additions & 3 deletions src/core/transform/ojph_transform_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace ojph {
const si64 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m128i vb = _mm_set1_epi64x(b);
__m128i ve = _mm_set1_epi64x(1ULL << (63 - e));
__m128i ve = _mm_set1_epi64x(1LL << (63 - e));

si64* dst = aug->i64;
const si64* src1 = sig->i64, * src2 = other->i64;
Expand Down Expand Up @@ -537,7 +537,7 @@ namespace ojph {
const si32 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m128i vb = _mm_set1_epi64x(b);
__m128i ve = _mm_set1_epi64x(1ULL << (63 - e));
__m128i ve = _mm_set1_epi64x(1LL << (63 - e));

// extension
lp[-1] = lp[0];
Expand Down Expand Up @@ -843,7 +843,7 @@ namespace ojph {
const si32 b = s->rev.Batk;
const ui8 e = s->rev.Eatk;
__m128i vb = _mm_set1_epi64x(b);
__m128i ve = _mm_set1_epi64x(1ULL << (63 - e));
__m128i ve = _mm_set1_epi64x(1LL << (63 - e));

// extension
oth[-1] = oth[0];
Expand Down

0 comments on commit c73bfe4

Please sign in to comment.