forked from aklomp/base64
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
POC for aklomp#15
- Loading branch information
Showing
25 changed files
with
630 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
static inline uint8_t | ||
convert (const uint16_t in) | ||
{ | ||
unsigned value = in; | ||
#if 0 | ||
unsigned mask = (unsigned)((0 - (int)(value >> 8)) >> (sizeof(int) * 8U - 1U)); | ||
|
||
value |= mask; | ||
return (uint8_t)value; | ||
#else | ||
return (value > 255U) ? 255U : value; | ||
#endif | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
while (len > 0U) { | ||
*dst++ = (char)convert(*src++); | ||
len--; | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
while (len >= 64U) { | ||
__m128i src0 = _mm_loadu_si128((const __m128i*)(src + 0)); | ||
__m128i src1 = _mm_loadu_si128((const __m128i*)(src + 8)); | ||
__m128i src2 = _mm_loadu_si128((const __m128i*)(src + 16)); | ||
__m128i src3 = _mm_loadu_si128((const __m128i*)(src + 24)); | ||
__m128i src4 = _mm_loadu_si128((const __m128i*)(src + 32)); | ||
__m128i src5 = _mm_loadu_si128((const __m128i*)(src + 40)); | ||
__m128i src6 = _mm_loadu_si128((const __m128i*)(src + 48)); | ||
__m128i src7 = _mm_loadu_si128((const __m128i*)(src + 56)); | ||
|
||
|
||
__m128i dst0 = _mm_packus_epi16(src0, src1); | ||
__m128i dst1 = _mm_packus_epi16(src2, src3); | ||
__m128i dst2 = _mm_packus_epi16(src4, src5); | ||
__m128i dst3 = _mm_packus_epi16(src6, src7); | ||
|
||
_mm_storeu_si128((__m128i*)(dst + 0), dst0); | ||
_mm_storeu_si128((__m128i*)(dst + 16), dst1); | ||
_mm_storeu_si128((__m128i*)(dst + 32), dst2); | ||
_mm_storeu_si128((__m128i*)(dst + 48), dst3); | ||
|
||
len-= 64U; | ||
src += 64U; | ||
dst += 64U; | ||
} | ||
if (len & 32U) { | ||
__m128i src0 = _mm_loadu_si128((const __m128i*)(src + 0)); | ||
__m128i src1 = _mm_loadu_si128((const __m128i*)(src + 8)); | ||
__m128i src2 = _mm_loadu_si128((const __m128i*)(src + 16)); | ||
__m128i src3 = _mm_loadu_si128((const __m128i*)(src + 24)); | ||
|
||
__m128i dst0 = _mm_packus_epi16(src0, src1); | ||
__m128i dst1 = _mm_packus_epi16(src2, src3); | ||
|
||
_mm_storeu_si128((__m128i*)(dst + 0), dst0); | ||
_mm_storeu_si128((__m128i*)(dst + 16), dst1); | ||
|
||
len-= 32U; | ||
src += 32U; | ||
dst += 32U; | ||
} | ||
if (len & 16U) { | ||
__m128i src0 = _mm_loadu_si128((const __m128i*)(src + 0)); | ||
__m128i src1 = _mm_loadu_si128((const __m128i*)(src + 8)); | ||
|
||
__m128i dst0 = _mm_packus_epi16(src0, src1); | ||
|
||
_mm_storeu_si128((__m128i*)(dst + 0), dst0); | ||
|
||
len-= 16U; | ||
src += 16U; | ||
dst += 16U; | ||
} |
Oops, something went wrong.