Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: modules/audio_conference_mixer/source/audio_frame_manipulator.cc

Issue 3015553002: Remove voe::OutputMixer and AudioConferenceMixer. (Closed)
Patch Set: remove conference mixer from presubmit.py Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 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 "modules/audio_conference_mixer/source/audio_frame_manipulator.h"
12 #include "modules/include/module_common_types.h"
13 #include "typedefs.h" // NOLINT(build/include)
14
15 namespace {
16 // Linear ramping over 80 samples.
17 // TODO(hellner): ramp using fix point?
18 const float rampArray[] = {0.0000f, 0.0127f, 0.0253f, 0.0380f,
19 0.0506f, 0.0633f, 0.0759f, 0.0886f,
20 0.1013f, 0.1139f, 0.1266f, 0.1392f,
21 0.1519f, 0.1646f, 0.1772f, 0.1899f,
22 0.2025f, 0.2152f, 0.2278f, 0.2405f,
23 0.2532f, 0.2658f, 0.2785f, 0.2911f,
24 0.3038f, 0.3165f, 0.3291f, 0.3418f,
25 0.3544f, 0.3671f, 0.3797f, 0.3924f,
26 0.4051f, 0.4177f, 0.4304f, 0.4430f,
27 0.4557f, 0.4684f, 0.4810f, 0.4937f,
28 0.5063f, 0.5190f, 0.5316f, 0.5443f,
29 0.5570f, 0.5696f, 0.5823f, 0.5949f,
30 0.6076f, 0.6203f, 0.6329f, 0.6456f,
31 0.6582f, 0.6709f, 0.6835f, 0.6962f,
32 0.7089f, 0.7215f, 0.7342f, 0.7468f,
33 0.7595f, 0.7722f, 0.7848f, 0.7975f,
34 0.8101f, 0.8228f, 0.8354f, 0.8481f,
35 0.8608f, 0.8734f, 0.8861f, 0.8987f,
36 0.9114f, 0.9241f, 0.9367f, 0.9494f,
37 0.9620f, 0.9747f, 0.9873f, 1.0000f};
38 const size_t rampSize = sizeof(rampArray)/sizeof(rampArray[0]);
39 } // namespace
40
41 namespace webrtc {
42 uint32_t CalculateEnergy(const AudioFrame& audioFrame)
43 {
44 if (audioFrame.muted()) return 0;
45
46 uint32_t energy = 0;
47 const int16_t* frame_data = audioFrame.data();
48 for(size_t position = 0; position < audioFrame.samples_per_channel_;
49 position++)
50 {
51 // TODO(andrew): this can easily overflow.
52 energy += frame_data[position] * frame_data[position];
53 }
54 return energy;
55 }
56
57 void RampIn(AudioFrame& audioFrame)
58 {
59 assert(rampSize <= audioFrame.samples_per_channel_);
60 if (audioFrame.muted()) return;
61
62 int16_t* frame_data = audioFrame.mutable_data();
63 for(size_t i = 0; i < rampSize; i++)
64 {
65 frame_data[i] = static_cast<int16_t>(rampArray[i] * frame_data[i]);
66 }
67 }
68
69 void RampOut(AudioFrame& audioFrame)
70 {
71 assert(rampSize <= audioFrame.samples_per_channel_);
72 if (audioFrame.muted()) return;
73
74 int16_t* frame_data = audioFrame.mutable_data();
75 for(size_t i = 0; i < rampSize; i++)
76 {
77 const size_t rampPos = rampSize - 1 - i;
78 frame_data[i] = static_cast<int16_t>(rampArray[rampPos] *
79 frame_data[i]);
80 }
81 memset(&frame_data[rampSize], 0,
82 (audioFrame.samples_per_channel_ - rampSize) *
83 sizeof(frame_data[0]));
84 }
85 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/audio_conference_mixer/source/audio_frame_manipulator.h ('k') | modules/audio_conference_mixer/source/memory_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698