• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #if (defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM_NEON))
12 
13 #include <arm_neon.h>
14 
15 #include "signal_processing_library.h"
16 
17 // Maximum absolute value of word16 vector.
WebRtcSpl_MaxAbsValueW16(const WebRtc_Word16 * vector,WebRtc_Word16 length)18 WebRtc_Word16 WebRtcSpl_MaxAbsValueW16(const WebRtc_Word16* vector,
19                                        WebRtc_Word16 length) {
20   WebRtc_Word32 temp_max = 0;
21   WebRtc_Word32 abs_val;
22   WebRtc_Word16 tot_max;
23   int i;
24 
25   __asm__("vmov.i16 d25, #0" : : : "d25");
26 
27   for (i = 0; i < length - 7; i += 8) {
28     __asm__("vld1.16 {d26, d27}, [%0]" : : "r"(&vector[i]) : "q13");
29     __asm__("vabs.s16 q13, q13" : : : "q13");
30     __asm__("vpmax.s16 d26, d27" : : : "q13");
31     __asm__("vpmax.s16 d25, d26" : : : "d25", "d26");
32   }
33   __asm__("vpmax.s16 d25, d25" : : : "d25");
34   __asm__("vpmax.s16 d25, d25" : : : "d25");
35   __asm__("vmov.s16 %0, d25[0]" : "=r"(temp_max): : "d25");
36 
37   for (; i < length; i++) {
38     abs_val = WEBRTC_SPL_ABS_W32((vector[i]));
39     if (abs_val > temp_max) {
40       temp_max = abs_val;
41     }
42   }
43   tot_max = (WebRtc_Word16)WEBRTC_SPL_MIN(temp_max, WEBRTC_SPL_WORD16_MAX);
44   return tot_max;
45 }
46 
47 #endif
48