Home | History | Annotate | Download | only in source
      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 
     12 /*
     13  * This file contains the function WebRtcSpl_DotProductWithScale().
     14  * The description header can be found in signal_processing_library.h
     15  *
     16  */
     17 
     18 #include "signal_processing_library.h"
     19 
     20 WebRtc_Word32 WebRtcSpl_DotProductWithScale(WebRtc_Word16 *vector1, WebRtc_Word16 *vector2,
     21                                             int length, int scaling)
     22 {
     23     WebRtc_Word32 sum;
     24     int i;
     25 #ifdef _ARM_OPT_
     26 #pragma message("NOTE: _ARM_OPT_ optimizations are used")
     27     WebRtc_Word16 len4 = (length >> 2) << 2;
     28 #endif
     29 
     30     sum = 0;
     31 
     32 #ifndef _ARM_OPT_
     33     for (i = 0; i < length; i++)
     34     {
     35         sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1++, *vector2++, scaling);
     36     }
     37 #else
     38     if (scaling == 0)
     39     {
     40         for (i = 0; i < len4; i = i + 4)
     41         {
     42             sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2);
     43             vector1++;
     44             vector2++;
     45             sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2);
     46             vector1++;
     47             vector2++;
     48             sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2);
     49             vector1++;
     50             vector2++;
     51             sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2);
     52             vector1++;
     53             vector2++;
     54         }
     55 
     56         for (i = len4; i < length; i++)
     57         {
     58             sum += WEBRTC_SPL_MUL_16_16(*vector1, *vector2);
     59             vector1++;
     60             vector2++;
     61         }
     62     }
     63     else
     64     {
     65         for (i = 0; i < len4; i = i + 4)
     66         {
     67             sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling);
     68             vector1++;
     69             vector2++;
     70             sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling);
     71             vector1++;
     72             vector2++;
     73             sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling);
     74             vector1++;
     75             vector2++;
     76             sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling);
     77             vector1++;
     78             vector2++;
     79         }
     80 
     81         for (i = len4; i < length; i++)
     82         {
     83             sum += WEBRTC_SPL_MUL_16_16_RSFT(*vector1, *vector2, scaling);
     84             vector1++;
     85             vector2++;
     86         }
     87     }
     88 #endif
     89 
     90     return sum;
     91 }
     92