History

Optimize mp3d_scale_pcm using ssat instruction.

lieff committed 6 years ago

Commit 60fd2171 parent 55da78c1 file · +16 −0Browse files

Unified · Split

minimp3.h+16−0
@@ -191,6 +191,16 @@ static int have_simd() · 190 unmodified lines
191191 #define HAVE_SIMD 0
192192 #endif /* !defined(MINIMP3_NO_SIMD) */
193193
194+#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__)
195+#define HAVE_ARMV6 1
196+static __inline__ __attribute__((always_inline)) int32_t minimp3_clip_int16_arm(int32_t a)
197+{
198+ int32_t x = 0;
199+ __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
200+ return x;
201+}
202+#endif
203+
194204 typedef struct
195205 {
196206 const uint8_t *buf;
@@ -1407,10 +1417,16 @@ static void mp3d_DCT_II(float *grbuf, int n) · 1210 unmodified lines
14071417 #ifndef MINIMP3_FLOAT_OUTPUT
14081418 static int16_t mp3d_scale_pcm(float sample)
14091419 {
1420+#if HAVE_ARMV6
1421+ int32_t s32 = (int32_t)(sample + .5f);
1422+ s32 -= (s32 < 0);
1423+ int16_t s = (int16_t)minimp3_clip_int16_arm(s32);
1424+#else
14101425 if (sample >= 32766.5) return (int16_t) 32767;
14111426 if (sample <= -32767.5) return (int16_t)-32768;
14121427 int16_t s = (int16_t)(sample + .5f);
14131428 s -= (s < 0); /* away from zero, to be compliant */
1429+#endif
14141430 return s;
14151431 }
14161432 #else /* MINIMP3_FLOAT_OUTPUT */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t