From dc8479928c5aee4c6ad6fe4f59006fb604cee701 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 18 Sep 2016 09:38:01 +0900 Subject: Sources: Run clang-format on everything. --- src/audio_core/codec.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/audio_core/codec.cpp') diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index 3e23323f1..c7efae753 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -15,22 +15,25 @@ namespace Codec { -StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, const std::array& adpcm_coeff, ADPCMState& state) { +StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, + const std::array& adpcm_coeff, ADPCMState& state) { // GC-ADPCM with scale factor and variable coefficients. // Frames are 8 bytes long containing 14 samples each. // Samples are 4 bits (one nibble) long. constexpr size_t FRAME_LEN = 8; constexpr size_t SAMPLES_PER_FRAME = 14; - constexpr std::array SIGNED_NIBBLES {{ 0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1 }}; + constexpr std::array SIGNED_NIBBLES{ + {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}}; - const size_t ret_size = sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two. + const size_t ret_size = + sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two. StereoBuffer16 ret(ret_size); - int yn1 = state.yn1, - yn2 = state.yn2; + int yn1 = state.yn1, yn2 = state.yn2; - const size_t NUM_FRAMES = (sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up. + const size_t NUM_FRAMES = + (sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up. for (size_t framei = 0; framei < NUM_FRAMES; framei++) { const int frame_header = data[framei * FRAME_LEN]; const int scale = 1 << (frame_header & 0xF); @@ -43,7 +46,8 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, cons // Decodes an audio sample. One nibble produces one sample. const auto decode_sample = [&](const int nibble) -> s16 { const int xn = nibble * scale; - // We first transform everything into 11 bit fixed point, perform the second order digital filter, then transform back. + // We first transform everything into 11 bit fixed point, perform the second order + // digital filter, then transform back. // 0x400 == 0.5 in 11 bit fixed point. // Filter: y[n] = x[n] + 0.5 + c1 * y[n-1] + c2 * y[n-2] int val = ((xn << 11) + 0x400 + coef1 * yn1 + coef2 * yn2) >> 11; @@ -82,7 +86,8 @@ static s16 SignExtendS8(u8 x) { return static_cast(static_cast(x)); } -StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, const size_t sample_count) { +StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, + const size_t sample_count) { ASSERT(num_channels == 1 || num_channels == 2); StereoBuffer16 ret(sample_count); @@ -101,7 +106,8 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data, con return ret; } -StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, const size_t sample_count) { +StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, + const size_t sample_count) { ASSERT(num_channels == 1 || num_channels == 2); StereoBuffer16 ret(sample_count); @@ -118,5 +124,4 @@ StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data, co return ret; } - }; -- cgit v1.2.3 From 396a8d91a4423d9c793eeff0798d544613647511 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 18 Sep 2016 18:01:46 -0700 Subject: Manually tweak source formatting and then re-run clang-format --- src/audio_core/codec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio_core/codec.cpp') diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index c7efae753..4edfe9be0 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -23,7 +23,7 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count, constexpr size_t FRAME_LEN = 8; constexpr size_t SAMPLES_PER_FRAME = 14; - constexpr std::array SIGNED_NIBBLES{ + constexpr std::array SIGNED_NIBBLES = { {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}}; const size_t ret_size = -- cgit v1.2.3 From ebdae19fd226104baec712b9da9939ff82ef3c3a Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 21 Sep 2016 00:21:23 +0900 Subject: Remove empty newlines in #include blocks. This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation. --- src/audio_core/codec.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/audio_core/codec.cpp') diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index 4edfe9be0..fd189a176 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -2,13 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "audio_core/codec.h" #include #include #include #include - -#include "audio_core/codec.h" - #include "common/assert.h" #include "common/common_types.h" #include "common/math_util.h" -- cgit v1.2.3 From 84fbbe26297652d994d203bde543ec252c2d801a Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 20 Sep 2016 23:52:38 -0700 Subject: Use negative priorities to avoid special-casing the self-include --- src/audio_core/codec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/audio_core/codec.cpp') diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index fd189a176..7a3bd7eb3 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -2,11 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "audio_core/codec.h" #include #include #include #include +#include "audio_core/codec.h" #include "common/assert.h" #include "common/common_types.h" #include "common/math_util.h" -- cgit v1.2.3