@@ -38,20 +38,18 @@ static void ValidateLayout(ChannelLayout layout) {
38
38
// Symmetry allows simplifying the matrix building code by allowing us to
39
39
// assume that if one channel of a pair exists, the other will too.
40
40
if (channel_count > 1 ) {
41
- DCHECK (( ChannelOrder (layout, LEFT) >= 0 &&
42
- ChannelOrder (layout, RIGHT ) >= 0 ) ||
43
- ( ChannelOrder (layout, SIDE_LEFT ) >= 0 &&
44
- ChannelOrder (layout, SIDE_RIGHT ) >= 0 ) ||
45
- ( ChannelOrder (layout, BACK_LEFT ) >= 0 &&
46
- ChannelOrder (layout, BACK_RIGHT ) >= 0 ) ||
47
- ( ChannelOrder (layout, LEFT_OF_CENTER ) >= 0 &&
48
- ChannelOrder (layout, RIGHT_OF_CENTER ) >= 0 ))
49
- << " Non-symmetric channel layout encountered. " ;
41
+ // Assert that LEFT exists if and only if RIGHT exists, and so on.
42
+ DCHECK_EQ ( ChannelOrder (layout, LEFT ) >= 0 ,
43
+ ChannelOrder (layout, RIGHT ) >= 0 );
44
+ DCHECK_EQ ( ChannelOrder (layout, SIDE_LEFT ) >= 0 ,
45
+ ChannelOrder (layout, SIDE_RIGHT ) >= 0 );
46
+ DCHECK_EQ ( ChannelOrder (layout, BACK_LEFT ) >= 0 ,
47
+ ChannelOrder (layout, BACK_RIGHT ) >= 0 );
48
+ DCHECK_EQ ( ChannelOrder (layout, LEFT_OF_CENTER ) >= 0 ,
49
+ ChannelOrder ( layout, RIGHT_OF_CENTER) >= 0 ) ;
50
50
} else {
51
51
DCHECK_EQ (layout, CHANNEL_LAYOUT_MONO);
52
52
}
53
-
54
- return ;
55
53
}
56
54
57
55
class MatrixBuilder {
@@ -96,19 +94,18 @@ class MatrixBuilder {
96
94
97
95
// Helper methods for managing unaccounted input channels.
98
96
void AccountFor (Channels ch);
99
- bool IsUnaccounted (Channels ch);
97
+ bool IsUnaccounted (Channels ch) const ;
100
98
101
99
// Helper methods for checking if |ch| exists in either |input_layout_| or
102
100
// |output_layout_| respectively.
103
- bool HasInputChannel (Channels ch);
104
- bool HasOutputChannel (Channels ch);
101
+ bool HasInputChannel (Channels ch) const ;
102
+ bool HasOutputChannel (Channels ch) const ;
105
103
106
104
// Helper methods for updating |matrix_| with the proper value for
107
105
// mixing |input_ch| into |output_ch|. MixWithoutAccounting() does not
108
106
// remove the channel from |unaccounted_inputs_|.
109
107
void Mix (Channels input_ch, Channels output_ch, float scale);
110
- void MixWithoutAccounting (Channels input_ch, Channels output_ch,
111
- float scale);
108
+ void MixWithoutAccounting (Channels input_ch, Channels output_ch, float scale);
112
109
113
110
DISALLOW_COPY_AND_ASSIGN (MatrixBuilder);
114
111
};
@@ -219,8 +216,8 @@ bool MatrixBuilder::CreateTransformationMatrix(
219
216
// Mix back LR into: side LR || back center || front LR || front center.
220
217
if (IsUnaccounted (BACK_LEFT)) {
221
218
if (HasOutputChannel (SIDE_LEFT)) {
222
- // If we have side LR, mix back LR into side LR, but instead if the input
223
- // doesn't have side LR (but output does) copy back LR to side LR.
219
+ // If the input has side LR, mix back LR into side LR, but instead if the
220
+ // input doesn't have side LR (but output does) copy back LR to side LR.
224
221
float scale = HasInputChannel (SIDE_LEFT) ? kEqualPowerScale : 1 ;
225
222
Mix (BACK_LEFT, SIDE_LEFT, scale);
226
223
Mix (BACK_RIGHT, SIDE_RIGHT, scale);
@@ -242,8 +239,8 @@ bool MatrixBuilder::CreateTransformationMatrix(
242
239
// Mix side LR into: back LR || back center || front LR || front center.
243
240
if (IsUnaccounted (SIDE_LEFT)) {
244
241
if (HasOutputChannel (BACK_LEFT)) {
245
- // If we have back LR, mix side LR into back LR, but instead if the input
246
- // doesn't have back LR (but output does) copy side LR to back LR.
242
+ // If the input has back LR, mix side LR into back LR, but instead if the
243
+ // input doesn't have back LR (but output does) copy side LR to back LR.
247
244
float scale = HasInputChannel (BACK_LEFT) ? kEqualPowerScale : 1 ;
248
245
Mix (SIDE_LEFT, BACK_LEFT, scale);
249
246
Mix (SIDE_RIGHT, BACK_RIGHT, scale);
@@ -284,7 +281,7 @@ bool MatrixBuilder::CreateTransformationMatrix(
284
281
}
285
282
}
286
283
287
- // Mix LR of center into: front center || front LR .
284
+ // Mix LR of center into: front LR || front center .
288
285
if (IsUnaccounted (LEFT_OF_CENTER)) {
289
286
if (HasOutputChannel (LEFT)) {
290
287
// Mix LR of center into front LR.
@@ -297,7 +294,7 @@ bool MatrixBuilder::CreateTransformationMatrix(
297
294
}
298
295
}
299
296
300
- // Mix LFE into: front LR || front center .
297
+ // Mix LFE into: front center || front LR .
301
298
if (IsUnaccounted (LFE)) {
302
299
if (!HasOutputChannel (CENTER)) {
303
300
// Mix LFE into front LR.
@@ -373,16 +370,16 @@ void MatrixBuilder::AccountFor(Channels ch) {
373
370
unaccounted_inputs_.begin (), unaccounted_inputs_.end (), ch));
374
371
}
375
372
376
- bool MatrixBuilder::IsUnaccounted (Channels ch) {
373
+ bool MatrixBuilder::IsUnaccounted (Channels ch) const {
377
374
return std::find (unaccounted_inputs_.begin (), unaccounted_inputs_.end (),
378
375
ch) != unaccounted_inputs_.end ();
379
376
}
380
377
381
- bool MatrixBuilder::HasInputChannel (Channels ch) {
378
+ bool MatrixBuilder::HasInputChannel (Channels ch) const {
382
379
return ChannelOrder (input_layout_, ch) >= 0 ;
383
380
}
384
381
385
- bool MatrixBuilder::HasOutputChannel (Channels ch) {
382
+ bool MatrixBuilder::HasOutputChannel (Channels ch) const {
386
383
return ChannelOrder (output_layout_, ch) >= 0 ;
387
384
}
388
385
0 commit comments