| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 if (frame->num_channels_ < 1) { | 273 if (frame->num_channels_ < 1) { |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| 277 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; | 277 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 278 i++) { | 278 i++) { |
| 279 frame->data_[i] = frame->data_[i] >> 1; | 279 frame->data_[i] = frame->data_[i] >> 1; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 int AudioFrameOperations::Scale(float left, float right, AudioFrame& frame) { | 283 int AudioFrameOperations::Scale(float left, float right, AudioFrame* frame) { |
| 284 if (frame.num_channels_ != 2) { | 284 if (frame->num_channels_ != 2) { |
| 285 return -1; | 285 return -1; |
| 286 } | 286 } |
| 287 | 287 |
| 288 for (size_t i = 0; i < frame.samples_per_channel_; i++) { | 288 for (size_t i = 0; i < frame->samples_per_channel_; i++) { |
| 289 frame.data_[2 * i] = static_cast<int16_t>(left * frame.data_[2 * i]); | 289 frame->data_[2 * i] = static_cast<int16_t>(left * frame->data_[2 * i]); |
| 290 frame.data_[2 * i + 1] = | 290 frame->data_[2 * i + 1] = |
| 291 static_cast<int16_t>(right * frame.data_[2 * i + 1]); | 291 static_cast<int16_t>(right * frame->data_[2 * i + 1]); |
| 292 } | 292 } |
| 293 return 0; | 293 return 0; |
| 294 } | 294 } |
| 295 | 295 |
| 296 int AudioFrameOperations::ScaleWithSat(float scale, AudioFrame& frame) { | 296 int AudioFrameOperations::ScaleWithSat(float scale, AudioFrame* frame) { |
| 297 int32_t temp_data = 0; | 297 int32_t temp_data = 0; |
| 298 | 298 |
| 299 // Ensure that the output result is saturated [-32768, +32767]. | 299 // Ensure that the output result is saturated [-32768, +32767]. |
| 300 for (size_t i = 0; i < frame.samples_per_channel_ * frame.num_channels_; | 300 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 301 i++) { | 301 i++) { |
| 302 temp_data = static_cast<int32_t>(scale * frame.data_[i]); | 302 temp_data = static_cast<int32_t>(scale * frame->data_[i]); |
| 303 if (temp_data < -32768) { | 303 if (temp_data < -32768) { |
| 304 frame.data_[i] = -32768; | 304 frame->data_[i] = -32768; |
| 305 } else if (temp_data > 32767) { | 305 } else if (temp_data > 32767) { |
| 306 frame.data_[i] = 32767; | 306 frame->data_[i] = 32767; |
| 307 } else { | 307 } else { |
| 308 frame.data_[i] = static_cast<int16_t>(temp_data); | 308 frame->data_[i] = static_cast<int16_t>(temp_data); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 return 0; | 311 return 0; |
| 312 } | 312 } |
| 313 } // namespace webrtc | 313 } // namespace webrtc |
| OLD | NEW |