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

Side by Side Diff: webrtc/common_audio/channel_buffer.cc

Issue 2053773002: Keep track of the user-facing number of channels in a ChannelBuffer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebasing Created 4 years, 5 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
« no previous file with comments | « webrtc/common_audio/channel_buffer.h ('k') | webrtc/common_audio/channel_buffer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 29 matching lines...) Expand all
40 } 40 }
41 41
42 const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const { 42 const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const {
43 RefreshF(); 43 RefreshF();
44 return &fbuf_; 44 return &fbuf_;
45 } 45 }
46 46
47 void IFChannelBuffer::RefreshF() const { 47 void IFChannelBuffer::RefreshF() const {
48 if (!fvalid_) { 48 if (!fvalid_) {
49 RTC_DCHECK(ivalid_); 49 RTC_DCHECK(ivalid_);
50 fbuf_.set_num_channels(ibuf_.num_channels());
50 const int16_t* const* int_channels = ibuf_.channels(); 51 const int16_t* const* int_channels = ibuf_.channels();
51 float* const* float_channels = fbuf_.channels(); 52 float* const* float_channels = fbuf_.channels();
52 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { 53 for (size_t i = 0; i < ibuf_.num_channels(); ++i) {
53 for (size_t j = 0; j < ibuf_.num_frames(); ++j) { 54 for (size_t j = 0; j < ibuf_.num_frames(); ++j) {
54 float_channels[i][j] = int_channels[i][j]; 55 float_channels[i][j] = int_channels[i][j];
55 } 56 }
56 } 57 }
57 fvalid_ = true; 58 fvalid_ = true;
58 } 59 }
59 } 60 }
60 61
61 void IFChannelBuffer::RefreshI() const { 62 void IFChannelBuffer::RefreshI() const {
62 if (!ivalid_) { 63 if (!ivalid_) {
63 RTC_DCHECK(fvalid_); 64 RTC_DCHECK(fvalid_);
64 int16_t* const* int_channels = ibuf_.channels(); 65 int16_t* const* int_channels = ibuf_.channels();
66 ibuf_.set_num_channels(fbuf_.num_channels());
65 const float* const* float_channels = fbuf_.channels(); 67 const float* const* float_channels = fbuf_.channels();
66 for (size_t i = 0; i < ibuf_.num_channels(); ++i) { 68 for (size_t i = 0; i < fbuf_.num_channels(); ++i) {
67 FloatS16ToS16(float_channels[i], 69 FloatS16ToS16(float_channels[i],
68 ibuf_.num_frames(), 70 ibuf_.num_frames(),
69 int_channels[i]); 71 int_channels[i]);
70 } 72 }
71 ivalid_ = true; 73 ivalid_ = true;
72 } 74 }
73 } 75 }
74 76
75 } // namespace webrtc 77 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_audio/channel_buffer.h ('k') | webrtc/common_audio/channel_buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698