tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

energy.c (1098B)


      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 * This file contains the function WebRtcSpl_Energy().
     13 * The description header can be found in signal_processing_library.h
     14 *
     15 */
     16 
     17 #include "common_audio/signal_processing/include/signal_processing_library.h"
     18 
     19 int32_t WebRtcSpl_Energy(int16_t* vector,
     20                         size_t vector_length,
     21                         int* scale_factor) {
     22  int32_t en = 0;
     23  size_t i;
     24  int scaling =
     25      WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length);
     26  size_t looptimes = vector_length;
     27  int16_t* vectorptr = vector;
     28 
     29  for (i = 0; i < looptimes; i++) {
     30    en += (*vectorptr * *vectorptr) >> scaling;
     31    vectorptr++;
     32  }
     33  *scale_factor = scaling;
     34 
     35  return en;
     36 }