Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c4e8709 authored by Jim Huang's avatar Jim Huang Committed by Steve Kondik
Browse files

audioflinger: Optimze ditherAndClamp with ARM NEON

Change-Id: Ifc436e39f15b103cec404e8a81fa8b8a6b5f0e5f
parent 9ec7701b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -34,4 +34,8 @@ ifeq ($(BOARD_USE_MOTO_DOCK_HACK),true)
   LOCAL_CFLAGS += -DMOTO_DOCK_HACK
endif

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

include $(BUILD_SHARED_LIBRARY)
+15 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@

#include "AudioMixer.h"

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

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

@@ -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;