Skip to content

Commit 5b5a830

Browse files
committed
Resync
1 parent 363c0cc commit 5b5a830

7 files changed

Lines changed: 352 additions & 265 deletions

File tree

audio/conversion/float_to_s16.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,13 @@ void convert_float_to_s16(int16_t *s, const float *in, size_t len)
109109
_mm_storeu_si128((__m128i *)s, packed); /* Then put the result in the output array */
110110
}
111111

112-
len -= i;
112+
len = len - i;
113113
i = 0;
114114
/* If there are any stray samples at the end, we need to convert them
115115
* (maybe the original array didn't contain a multiple of 8 samples) */
116116
#elif defined(__ALTIVEC__)
117+
int samples_in = len;
118+
117119
/* Unaligned loads/store is a bit expensive,
118120
* so we optimize for the good path (very likely). */
119121
if (((uintptr_t)s & 15) + ((uintptr_t)in & 15) == 0)
@@ -128,11 +130,20 @@ void convert_float_to_s16(int16_t *s, const float *in, size_t len)
128130
vec_st(vec_packs(result0, result1), 0, s);
129131
}
130132

131-
len -= i;
133+
samples_in -= i;
132134
}
133135

136+
len = samples_in;
134137
i = 0;
135138
#elif defined(_MIPS_ARCH_ALLEGREX)
139+
#ifdef DEBUG
140+
/* Make sure the buffers are 16 byte aligned, this should be
141+
* the default behaviour of malloc in the PSPSDK.
142+
* Assume alignment. */
143+
retro_assert(((uintptr_t)in & 0xf) == 0);
144+
retro_assert(((uintptr_t)s & 0xf) == 0);
145+
#endif
146+
136147
for (i = 0; i + 8 <= len; i += 8)
137148
{
138149
__asm__ (

audio/conversion/s16_to_float.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ void convert_s16_to_float(float *s,
111111
_mm_storeu_ps(s + 4, output_r);
112112
}
113113

114-
len -= i;
114+
len = len - i;
115115
i = 0;
116116
#elif defined(__ALTIVEC__)
117+
size_t samples_in = len;
118+
117119
/* Unaligned loads/store is a bit expensive, so we
118120
* optimize for the good path (very likely). */
119121
if (((uintptr_t)s & 15) + ((uintptr_t)in & 15) == 0)
@@ -133,15 +135,23 @@ void convert_s16_to_float(float *s,
133135
vec_st(out_lo, 16, s);
134136
}
135137

136-
len -= i;
138+
samples_in -= i;
137139
}
138140

141+
len = samples_in;
139142
i = 0;
140143
#endif
141144

142145
gain /= 0x8000;
143146

144147
#if defined(_MIPS_ARCH_ALLEGREX)
148+
#ifdef DEBUG
149+
/* Make sure the buffer is 16 byte aligned, this should be the
150+
* default behaviour of malloc in the PSPSDK.
151+
* Only the output buffer can be assumed to be 16-byte aligned. */
152+
retro_assert(((uintptr_t)s & 0xf) == 0);
153+
#endif
154+
145155
__asm__ (
146156
".set push \n"
147157
".set noreorder \n"

0 commit comments

Comments
 (0)