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:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -10,8 +10,8 @@
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
#include "modules/audio_coding/codecs/g711/g711_interface.h"
#include "modules/audio_coding/codecs/legacy_encoded_audio_frame.h"
namespace webrtc {

View File

@ -42,8 +42,8 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz)
payload_type_(config.payload_type),
num_10ms_frames_per_packet_(
static_cast<size_t>(config.frame_size_ms / 10)),
full_frame_samples_(
config.num_channels * config.frame_size_ms * sample_rate_hz / 1000),
full_frame_samples_(config.num_channels * config.frame_size_ms *
sample_rate_hz / 1000),
first_timestamp_in_buffer_(0) {
RTC_CHECK_GT(sample_rate_hz, 0) << "Sample rate must be larger than 0 Hz";
RTC_CHECK_EQ(config.frame_size_ms % 10, 0)
@ -70,8 +70,8 @@ size_t AudioEncoderPcm::Max10MsFramesInAPacket() const {
}
int AudioEncoderPcm::GetTargetBitrate() const {
return static_cast<int>(
8 * BytesPerSample() * SampleRateHz() * NumChannels());
return static_cast<int>(8 * BytesPerSample() * SampleRateHz() *
NumChannels());
}
AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
@ -89,13 +89,12 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeImpl(
EncodedInfo info;
info.encoded_timestamp = first_timestamp_in_buffer_;
info.payload_type = payload_type_;
info.encoded_bytes =
encoded->AppendData(full_frame_samples_ * BytesPerSample(),
[&] (rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0],
full_frame_samples_,
encoded.data());
});
info.encoded_bytes = encoded->AppendData(
full_frame_samples_ * BytesPerSample(),
[&](rtc::ArrayView<uint8_t> encoded) {
return EncodeCall(&speech_buffer_[0], full_frame_samples_,
encoded.data());
});
speech_buffer_.clear();
info.encoder_type = GetCodecType();
return info;

View File

@ -17,7 +17,8 @@
* Modifications for WebRtc, 2011/04/28, by tlegrand:
* -Changed to use WebRtc types
* -Changed __inline__ to __inline
* -Two changes to make implementation bitexact with ITU-T reference implementation
* -Two changes to make implementation bitexact with ITU-T reference
* implementation
*/
/*! \page g711_page A-law and mu-law handling
@ -58,10 +59,11 @@ extern "C" {
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsrl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
@ -71,30 +73,33 @@ static __inline__ int top_bit(unsigned int bits) {
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movl $-1,%%edx;\n"
" bsfl %%eax,%%edx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#elif defined(__x86_64__)
static __inline__ int top_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsrq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
static __inline__ int bottom_bit(unsigned int bits) {
int res;
__asm__ __volatile__(" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d" (res)
: "a" (bits));
__asm__ __volatile__(
" movq $-1,%%rdx;\n"
" bsfq %%rax,%%rdx;\n"
: "=d"(res)
: "a"(bits));
return res;
}
#else
@ -166,8 +171,8 @@ static __inline int bottom_bit(unsigned int bits) {
* linear sound like peanuts these days, and shouldn't an array lookup be
* real fast? No! When the cache sloshes as badly as this one will, a tight
* calculation may be better. The messiest part is normally finding the
* segment, but a little inline assembly can fix that on an i386, x86_64 and
* many other modern processors.
* segment, but a little inline assembly can fix that on an i386, x86_64
* and many other modern processors.
*/
/*
@ -196,8 +201,9 @@ static __inline int bottom_bit(unsigned int bits) {
* John Wiley & Sons, pps 98-111 and 472-476.
*/
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD */
#define ULAW_BIAS 0x84 /* Bias for linear code. */
//#define ULAW_ZEROTRAP /* turn on the trap as per the MIL-STD
//*/
#define ULAW_BIAS 0x84 /* Bias for linear code. */
/*! \brief Encode a linear sample to u-law
\param linear The sample to encode.
@ -249,7 +255,7 @@ static __inline int16_t ulaw_to_linear(uint8_t ulaw) {
* Extract and bias the quantization bits. Then
* shift up by the segment number and subtract out the bias.
*/
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int)ulaw & 0x70) >> 4);
return (int16_t)((ulaw & 0x80) ? (ULAW_BIAS - t) : (t - ULAW_BIAS));
}
@ -317,7 +323,7 @@ static __inline int16_t alaw_to_linear(uint8_t alaw) {
alaw ^= ALAW_AMI_MASK;
i = ((alaw & 0x0F) << 4);
seg = (((int) alaw & 0x70) >> 4);
seg = (((int)alaw & 0x70) >> 4);
if (seg)
i = (i + 0x108) << (seg - 1);
else

View File

@ -112,19 +112,19 @@ size_t WebRtcG711_DecodeU(const uint8_t* encoded,
int16_t* speechType);
/**********************************************************************
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
* WebRtcG711_Version(...)
*
* This function gives the version string of the G.711 codec.
*
* Input:
* - lenBytes: the size of Allocated space (in Bytes) where
* the version number is written to (in string format).
*
* Output:
* - version: Pointer to a buffer where the version number is
* written to.
*
*/
int16_t WebRtcG711_Version(char* version, int16_t lenBytes);

View File

@ -69,7 +69,6 @@ int main(int argc, char* argv[]) {
printf("outfile : Speech output file\n\n");
printf("outbits : Output bitstream file [optional]\n\n");
exit(0);
}
/* Get version and print */
@ -80,8 +79,8 @@ int main(int argc, char* argv[]) {
/* Get frame length */
int framelength_int = atoi(argv[1]);
if (framelength_int < 0) {
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
printf(" G.722: Invalid framelength %d.\n", framelength_int);
exit(1);
}
framelength = static_cast<size_t>(framelength_int);
@ -112,7 +111,7 @@ int main(int argc, char* argv[]) {
printf("\nBitfile: %s\n", bitname);
}
starttime = clock() / (double) CLOCKS_PER_SEC_G711; /* Runtime statistics */
starttime = clock() / (double)CLOCKS_PER_SEC_G711; /* Runtime statistics */
/* Initialize encoder and decoder */
framecnt = 0;
@ -155,11 +154,10 @@ int main(int argc, char* argv[]) {
}
}
runtime = (double)(clock() / (double) CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double) framecnt * (double) framelength / 8000);
runtime = (double)(clock() / (double)CLOCKS_PER_SEC_G711 - starttime);
length_file = ((double)framecnt * (double)framelength / 8000);
printf("\n\nLength of speech file: %.1f s\n", length_file);
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n",
runtime,
printf("Time to run G.711: %.2f s (%.2f %% of realtime)\n\n", runtime,
(100 * runtime / length_file));
printf("---------------------END----------------------\n");