Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 80aa80b

Browse files
wtcCommit bot
wtc
authored and
Commit bot
committed
Fix errors in comments. Make comments match code.
Fix the DCHECK in ValidateLayout for symmetric channel layouts. Add 'const' to methods that don't mutate class members. Include "base/macros.h" for the DISALLOW_COPY_AND_ASSIGN macro. [email protected] Review URL: https://codereview.chromium.org/645853011 Cr-Commit-Position: refs/heads/master@{#300612}
1 parent b9f1b81 commit 80aa80b

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

media/base/channel_layout.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static const int kLayoutToChannels[] = {
4848
// channel at that index is not used for that layout. For example, the left side
4949
// surround sound channel in FFmpeg's 5.1 layout is in the 5th position (because
5050
// the order is L, R, C, LFE, LS, RS), so
51-
// kChannelOrderings[CHANNEL_LAYOUT_5POINT1][SIDE_LEFT] = 4;
51+
// kChannelOrderings[CHANNEL_LAYOUT_5_1][SIDE_LEFT] = 4;
5252
static const int kChannelOrderings[CHANNEL_LAYOUT_MAX + 1][CHANNELS_MAX + 1] = {
5353
// FL | FR | FC | LFE | BL | BR | FLofC | FRofC | BC | SL | SR
5454

media/base/channel_layout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ enum Channels {
126126

127127
// Returns the expected channel position in an interleaved stream. Values of -1
128128
// mean the channel at that index is not used for that layout. Values range
129-
// from 0 to CHANNELS_MAX - 1.
129+
// from 0 to ChannelLayoutToChannelCount(layout) - 1.
130130
MEDIA_EXPORT int ChannelOrder(ChannelLayout layout, Channels channel);
131131

132132
// Returns the number of channels in a given ChannelLayout.

media/base/channel_mixer.cc

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ static void ValidateLayout(ChannelLayout layout) {
3838
// Symmetry allows simplifying the matrix building code by allowing us to
3939
// assume that if one channel of a pair exists, the other will too.
4040
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);
5050
} else {
5151
DCHECK_EQ(layout, CHANNEL_LAYOUT_MONO);
5252
}
53-
54-
return;
5553
}
5654

5755
class MatrixBuilder {
@@ -96,19 +94,18 @@ class MatrixBuilder {
9694

9795
// Helper methods for managing unaccounted input channels.
9896
void AccountFor(Channels ch);
99-
bool IsUnaccounted(Channels ch);
97+
bool IsUnaccounted(Channels ch) const;
10098

10199
// Helper methods for checking if |ch| exists in either |input_layout_| or
102100
// |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;
105103

106104
// Helper methods for updating |matrix_| with the proper value for
107105
// mixing |input_ch| into |output_ch|. MixWithoutAccounting() does not
108106
// remove the channel from |unaccounted_inputs_|.
109107
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);
112109

113110
DISALLOW_COPY_AND_ASSIGN(MatrixBuilder);
114111
};
@@ -219,8 +216,8 @@ bool MatrixBuilder::CreateTransformationMatrix(
219216
// Mix back LR into: side LR || back center || front LR || front center.
220217
if (IsUnaccounted(BACK_LEFT)) {
221218
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.
224221
float scale = HasInputChannel(SIDE_LEFT) ? kEqualPowerScale : 1;
225222
Mix(BACK_LEFT, SIDE_LEFT, scale);
226223
Mix(BACK_RIGHT, SIDE_RIGHT, scale);
@@ -242,8 +239,8 @@ bool MatrixBuilder::CreateTransformationMatrix(
242239
// Mix side LR into: back LR || back center || front LR || front center.
243240
if (IsUnaccounted(SIDE_LEFT)) {
244241
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.
247244
float scale = HasInputChannel(BACK_LEFT) ? kEqualPowerScale : 1;
248245
Mix(SIDE_LEFT, BACK_LEFT, scale);
249246
Mix(SIDE_RIGHT, BACK_RIGHT, scale);
@@ -284,7 +281,7 @@ bool MatrixBuilder::CreateTransformationMatrix(
284281
}
285282
}
286283

287-
// Mix LR of center into: front center || front LR.
284+
// Mix LR of center into: front LR || front center.
288285
if (IsUnaccounted(LEFT_OF_CENTER)) {
289286
if (HasOutputChannel(LEFT)) {
290287
// Mix LR of center into front LR.
@@ -297,7 +294,7 @@ bool MatrixBuilder::CreateTransformationMatrix(
297294
}
298295
}
299296

300-
// Mix LFE into: front LR || front center.
297+
// Mix LFE into: front center || front LR.
301298
if (IsUnaccounted(LFE)) {
302299
if (!HasOutputChannel(CENTER)) {
303300
// Mix LFE into front LR.
@@ -373,16 +370,16 @@ void MatrixBuilder::AccountFor(Channels ch) {
373370
unaccounted_inputs_.begin(), unaccounted_inputs_.end(), ch));
374371
}
375372

376-
bool MatrixBuilder::IsUnaccounted(Channels ch) {
373+
bool MatrixBuilder::IsUnaccounted(Channels ch) const {
377374
return std::find(unaccounted_inputs_.begin(), unaccounted_inputs_.end(),
378375
ch) != unaccounted_inputs_.end();
379376
}
380377

381-
bool MatrixBuilder::HasInputChannel(Channels ch) {
378+
bool MatrixBuilder::HasInputChannel(Channels ch) const {
382379
return ChannelOrder(input_layout_, ch) >= 0;
383380
}
384381

385-
bool MatrixBuilder::HasOutputChannel(Channels ch) {
382+
bool MatrixBuilder::HasOutputChannel(Channels ch) const {
386383
return ChannelOrder(output_layout_, ch) >= 0;
387384
}
388385

media/base/channel_mixer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <vector>
99

10-
#include "base/basictypes.h"
10+
#include "base/macros.h"
1111
#include "media/base/channel_layout.h"
1212
#include "media/base/media_export.h"
1313

0 commit comments

Comments
 (0)