aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/base64/ssse3/enc_ssse3.c
blob: 0518595e618d9dc75c9996822f567047facf930f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// If we have SSSE3 support, pick off 12 bytes at a time for as long as we can.
// But because we read 16 bytes at a time, ensure we have enough room to do a
// full 16-byte read without segfaulting:
while (srclen >= 16)
{
	// Load string:
	__m128i str = _mm_loadu_si128((__m128i *)c);

	// Reshuffle:
	str = enc_reshuffle(str);

	// Translate reshuffled bytes to the Base64 alphabet:
	str = enc_translate(str);

	// Store:
	_mm_storeu_si128((__m128i *)o, str);

	c += 12;	// 3 * 4 bytes of input
	o += 16;	// 4 * 4 bytes of output
	outl += 16;
	srclen -= 12;
}