Skip to content

Commit

Permalink
audioflinger: Optimze ditherAndClamp with ARM NEON
Browse files Browse the repository at this point in the history
Change-Id: Ifc436e39f15b103cec404e8a81fa8b8a6b5f0e5f

Conflicts:

	services/audioflinger/Android.mk
  • Loading branch information
Faryaab committed Apr 21, 2012
1 parent e1b044f commit 2d1250a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions services/audioflinger/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ LOCAL_STATIC_LIBRARIES := \

LOCAL_MODULE:= libaudioflinger

ifeq ($(ARCH_ARM_HAVE_NEON),true)
LOCAL_CFLAGS += -D__ARM_HAVE_NEON
endif

include $(BUILD_SHARED_LIBRARY)
15 changes: 15 additions & 0 deletions services/audioflinger/AudioMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

#include "AudioMixer.h"

#if defined(__ARM_HAVE_NEON)
#include <arm_neon.h>
#endif

namespace android {
// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -864,7 +868,18 @@ void AudioMixer::track__16BitsMono(track_t* t, int32_t* out, size_t frameCount,

void AudioMixer::ditherAndClamp(int32_t* out, int32_t const *sums, size_t c)
{
#if defined(__ARM_HAVE_NEON)
for (size_t i=0; i<(c>>1); i++) {
int16x4_t clamped_vec = vqshrn_n_s32(vld1q_s32(sums), 12);
vst1_s16((int16_t*)out, clamped_vec);
sums += 4;
out += 2;
}
/* the remaining */
for (size_t i=0; i<(c&1); i++) {
#else
for (size_t i=0 ; i<c ; i++) {
#endif
int32_t l = *sums++;
int32_t r = *sums++;
int32_t nl = l >> 12;
Expand Down

0 comments on commit 2d1250a

Please sign in to comment.