OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 bool InputAudioFile::Seek(int samples) { | 42 bool InputAudioFile::Seek(int samples) { |
43 if (!fp_) { | 43 if (!fp_) { |
44 return false; | 44 return false; |
45 } | 45 } |
46 // Find file boundaries. | 46 // Find file boundaries. |
47 const long current_pos = ftell(fp_); | 47 const long current_pos = ftell(fp_); |
48 CHECK_NE(EOF, current_pos) << "Error returned when getting file position."; | 48 RTC_CHECK_NE(EOF, current_pos) |
49 CHECK_EQ(0, fseek(fp_, 0, SEEK_END)); // Move to end of file. | 49 << "Error returned when getting file position."; |
| 50 RTC_CHECK_EQ(0, fseek(fp_, 0, SEEK_END)); // Move to end of file. |
50 const long file_size = ftell(fp_); | 51 const long file_size = ftell(fp_); |
51 CHECK_NE(EOF, file_size) << "Error returned when getting file position."; | 52 RTC_CHECK_NE(EOF, file_size) << "Error returned when getting file position."; |
52 // Find new position. | 53 // Find new position. |
53 long new_pos = current_pos + sizeof(int16_t) * samples; // Samples to bytes. | 54 long new_pos = current_pos + sizeof(int16_t) * samples; // Samples to bytes. |
54 CHECK_GE(new_pos, 0) << "Trying to move to before the beginning of the file"; | 55 RTC_CHECK_GE(new_pos, 0) |
| 56 << "Trying to move to before the beginning of the file"; |
55 new_pos = new_pos % file_size; // Wrap around the end of the file. | 57 new_pos = new_pos % file_size; // Wrap around the end of the file. |
56 // Move to new position relative to the beginning of the file. | 58 // Move to new position relative to the beginning of the file. |
57 CHECK_EQ(0, fseek(fp_, new_pos, SEEK_SET)); | 59 RTC_CHECK_EQ(0, fseek(fp_, new_pos, SEEK_SET)); |
58 return true; | 60 return true; |
59 } | 61 } |
60 | 62 |
61 void InputAudioFile::DuplicateInterleaved(const int16_t* source, size_t samples, | 63 void InputAudioFile::DuplicateInterleaved(const int16_t* source, size_t samples, |
62 size_t channels, | 64 size_t channels, |
63 int16_t* destination) { | 65 int16_t* destination) { |
64 // Start from the end of |source| and |destination|, and work towards the | 66 // Start from the end of |source| and |destination|, and work towards the |
65 // beginning. This is to allow in-place interleaving of the same array (i.e., | 67 // beginning. This is to allow in-place interleaving of the same array (i.e., |
66 // |source| and |destination| are the same array). | 68 // |source| and |destination| are the same array). |
67 for (int i = static_cast<int>(samples - 1); i >= 0; --i) { | 69 for (int i = static_cast<int>(samples - 1); i >= 0; --i) { |
68 for (int j = static_cast<int>(channels - 1); j >= 0; --j) { | 70 for (int j = static_cast<int>(channels - 1); j >= 0; --j) { |
69 destination[i * channels + j] = source[i]; | 71 destination[i * channels + j] = source[i]; |
70 } | 72 } |
71 } | 73 } |
72 } | 74 } |
73 | 75 |
74 } // namespace test | 76 } // namespace test |
75 } // namespace webrtc | 77 } // namespace webrtc |
OLD | NEW |