Reformat the WebRTC code base
Running clang-format with chromium's style guide. The goal is n-fold: * providing consistency and readability (that's what code guidelines are for) * preventing noise with presubmit checks and git cl format * building on the previous point: making it easier to automatically fix format issues * you name it Please consider using git-hyper-blame to ignore this commit. Bug: webrtc:9340 Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87 Reviewed-on: https://webrtc-review.googlesource.com/81185 Reviewed-by: Patrik Höglund <phoglund@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
@ -112,17 +112,23 @@ bool CheckWavParameters(size_t num_channels,
|
||||
}
|
||||
|
||||
#ifdef WEBRTC_ARCH_LITTLE_ENDIAN
|
||||
static inline void WriteLE16(uint16_t* f, uint16_t x) { *f = x; }
|
||||
static inline void WriteLE32(uint32_t* f, uint32_t x) { *f = x; }
|
||||
static inline void WriteLE16(uint16_t* f, uint16_t x) {
|
||||
*f = x;
|
||||
}
|
||||
static inline void WriteLE32(uint32_t* f, uint32_t x) {
|
||||
*f = x;
|
||||
}
|
||||
static inline void WriteFourCC(uint32_t* f, char a, char b, char c, char d) {
|
||||
*f = static_cast<uint32_t>(a)
|
||||
| static_cast<uint32_t>(b) << 8
|
||||
| static_cast<uint32_t>(c) << 16
|
||||
| static_cast<uint32_t>(d) << 24;
|
||||
*f = static_cast<uint32_t>(a) | static_cast<uint32_t>(b) << 8 |
|
||||
static_cast<uint32_t>(c) << 16 | static_cast<uint32_t>(d) << 24;
|
||||
}
|
||||
|
||||
static inline uint16_t ReadLE16(uint16_t x) { return x; }
|
||||
static inline uint32_t ReadLE32(uint32_t x) { return x; }
|
||||
static inline uint16_t ReadLE16(uint16_t x) {
|
||||
return x;
|
||||
}
|
||||
static inline uint32_t ReadLE32(uint32_t x) {
|
||||
return x;
|
||||
}
|
||||
static inline std::string ReadFourCC(uint32_t x) {
|
||||
return std::string(reinterpret_cast<char*>(&x), 4);
|
||||
}
|
||||
@ -131,11 +137,12 @@ static inline std::string ReadFourCC(uint32_t x) {
|
||||
#endif
|
||||
|
||||
static inline uint32_t RiffChunkSize(size_t bytes_in_payload) {
|
||||
return static_cast<uint32_t>(
|
||||
bytes_in_payload + kWavHeaderSize - sizeof(ChunkHeader));
|
||||
return static_cast<uint32_t>(bytes_in_payload + kWavHeaderSize -
|
||||
sizeof(ChunkHeader));
|
||||
}
|
||||
|
||||
static inline uint32_t ByteRate(size_t num_channels, int sample_rate,
|
||||
static inline uint32_t ByteRate(size_t num_channels,
|
||||
int sample_rate,
|
||||
size_t bytes_per_sample) {
|
||||
return static_cast<uint32_t>(num_channels * sample_rate * bytes_per_sample);
|
||||
}
|
||||
@ -166,8 +173,8 @@ void WriteWavHeader(uint8_t* buf,
|
||||
WriteLE16(&header.fmt.AudioFormat, format);
|
||||
WriteLE16(&header.fmt.NumChannels, static_cast<uint16_t>(num_channels));
|
||||
WriteLE32(&header.fmt.SampleRate, sample_rate);
|
||||
WriteLE32(&header.fmt.ByteRate, ByteRate(num_channels, sample_rate,
|
||||
bytes_per_sample));
|
||||
WriteLE32(&header.fmt.ByteRate,
|
||||
ByteRate(num_channels, sample_rate, bytes_per_sample));
|
||||
WriteLE16(&header.fmt.BlockAlign, BlockAlign(num_channels, bytes_per_sample));
|
||||
WriteLE16(&header.fmt.BitsPerSample,
|
||||
static_cast<uint16_t>(8 * bytes_per_sample));
|
||||
@ -239,5 +246,4 @@ bool ReadWavHeader(ReadableWav* readable,
|
||||
*bytes_per_sample, *num_samples);
|
||||
}
|
||||
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user