| 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 10 matching lines...) Expand all Loading... |
| 21 AudioFrameOperationsTest() { | 21 AudioFrameOperationsTest() { |
| 22 // Set typical values. | 22 // Set typical values. |
| 23 frame_.samples_per_channel_ = 320; | 23 frame_.samples_per_channel_ = 320; |
| 24 frame_.num_channels_ = 2; | 24 frame_.num_channels_ = 2; |
| 25 } | 25 } |
| 26 | 26 |
| 27 AudioFrame frame_; | 27 AudioFrame frame_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 void SetFrameData(AudioFrame* frame, int16_t left, int16_t right) { | 30 void SetFrameData(AudioFrame* frame, int16_t left, int16_t right) { |
| 31 for (int i = 0; i < frame->samples_per_channel_ * 2; i += 2) { | 31 for (size_t i = 0; i < frame->samples_per_channel_ * 2; i += 2) { |
| 32 frame->data_[i] = left; | 32 frame->data_[i] = left; |
| 33 frame->data_[i + 1] = right; | 33 frame->data_[i + 1] = right; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 void SetFrameData(AudioFrame* frame, int16_t data) { | 37 void SetFrameData(AudioFrame* frame, int16_t data) { |
| 38 for (int i = 0; i < frame->samples_per_channel_; i++) { | 38 for (size_t i = 0; i < frame->samples_per_channel_; i++) { |
| 39 frame->data_[i] = data; | 39 frame->data_[i] = data; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 void VerifyFramesAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { | 43 void VerifyFramesAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { |
| 44 EXPECT_EQ(frame1.num_channels_, frame2.num_channels_); | 44 EXPECT_EQ(frame1.num_channels_, frame2.num_channels_); |
| 45 EXPECT_EQ(frame1.samples_per_channel_, | 45 EXPECT_EQ(frame1.samples_per_channel_, |
| 46 frame2.samples_per_channel_); | 46 frame2.samples_per_channel_); |
| 47 | 47 |
| 48 for (int i = 0; i < frame1.samples_per_channel_ * frame1.num_channels_; | 48 for (size_t i = 0; i < frame1.samples_per_channel_ * frame1.num_channels_; |
| 49 i++) { | 49 i++) { |
| 50 EXPECT_EQ(frame1.data_[i], frame2.data_[i]); | 50 EXPECT_EQ(frame1.data_[i], frame2.data_[i]); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 TEST_F(AudioFrameOperationsTest, MonoToStereoFailsWithBadParameters) { | 54 TEST_F(AudioFrameOperationsTest, MonoToStereoFailsWithBadParameters) { |
| 55 EXPECT_EQ(-1, AudioFrameOperations::MonoToStereo(&frame_)); | 55 EXPECT_EQ(-1, AudioFrameOperations::MonoToStereo(&frame_)); |
| 56 | 56 |
| 57 frame_.samples_per_channel_ = AudioFrame::kMaxDataSizeSamples; | 57 frame_.samples_per_channel_ = AudioFrame::kMaxDataSizeSamples; |
| 58 frame_.num_channels_ = 1; | 58 frame_.num_channels_ = 1; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 AudioFrame scaled_frame; | 217 AudioFrame scaled_frame; |
| 218 scaled_frame.samples_per_channel_ = 320; | 218 scaled_frame.samples_per_channel_ = 320; |
| 219 scaled_frame.num_channels_ = 1; | 219 scaled_frame.num_channels_ = 1; |
| 220 SetFrameData(&scaled_frame, 2); | 220 SetFrameData(&scaled_frame, 2); |
| 221 VerifyFramesAreEqual(scaled_frame, frame_); | 221 VerifyFramesAreEqual(scaled_frame, frame_); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace | 224 } // namespace |
| 225 } // namespace webrtc | 225 } // namespace webrtc |
| OLD | NEW |