LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/audio_processing/transient - wpd_node.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 27 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2013 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             : #include "webrtc/modules/audio_processing/transient/wpd_node.h"
      12             : 
      13             : #include <math.h>
      14             : #include <string.h>
      15             : 
      16             : #include "webrtc/base/checks.h"
      17             : #include "webrtc/common_audio/fir_filter.h"
      18             : #include "webrtc/modules/audio_processing/transient/dyadic_decimator.h"
      19             : 
      20             : namespace webrtc {
      21             : 
      22           0 : WPDNode::WPDNode(size_t length,
      23             :                  const float* coefficients,
      24           0 :                  size_t coefficients_length)
      25             :     : // The data buffer has parent data length to be able to contain and filter
      26             :       // it.
      27           0 :       data_(new float[2 * length + 1]),
      28             :       length_(length),
      29             :       filter_(FIRFilter::Create(coefficients,
      30             :                                 coefficients_length,
      31           0 :                                 2 * length + 1)) {
      32           0 :   RTC_DCHECK_GT(length, 0);
      33           0 :   RTC_DCHECK(coefficients);
      34           0 :   RTC_DCHECK_GT(coefficients_length, 0);
      35           0 :   memset(data_.get(), 0.f, (2 * length + 1) * sizeof(data_[0]));
      36           0 : }
      37             : 
      38           0 : WPDNode::~WPDNode() {}
      39             : 
      40           0 : int WPDNode::Update(const float* parent_data, size_t parent_data_length) {
      41           0 :   if (!parent_data || (parent_data_length / 2) != length_) {
      42           0 :     return -1;
      43             :   }
      44             : 
      45             :   // Filter data.
      46           0 :   filter_->Filter(parent_data, parent_data_length, data_.get());
      47             : 
      48             :   // Decimate data.
      49           0 :   const bool kOddSequence = true;
      50           0 :   size_t output_samples = DyadicDecimate(
      51           0 :       data_.get(), parent_data_length, kOddSequence, data_.get(), length_);
      52           0 :   if (output_samples != length_) {
      53           0 :     return -1;
      54             :   }
      55             : 
      56             :   // Get abs to all values.
      57           0 :   for (size_t i = 0; i < length_; ++i) {
      58           0 :     data_[i] = fabs(data_[i]);
      59             :   }
      60             : 
      61           0 :   return 0;
      62             : }
      63             : 
      64           0 : int WPDNode::set_data(const float* new_data, size_t length) {
      65           0 :   if (!new_data || length != length_) {
      66           0 :     return -1;
      67             :   }
      68           0 :   memcpy(data_.get(), new_data, length * sizeof(data_[0]));
      69           0 :   return 0;
      70             : }
      71             : 
      72             : }  // namespace webrtc

Generated by: LCOV version 1.13