From f0e3637c7a133021a33def8694d712605cc46e81 Mon Sep 17 00:00:00 2001 From: Tobias Date: Mon, 7 Dec 2020 16:05:45 +0100 Subject: [PATCH] codec: Make lookup table static constexpr (#5572) Allows compilers to elide needing to push these values on the stack every time the function is called. Co-authored-by: Lioncash --- src/audio_core/codec.cpp | 5 +++-- src/audio_core/codec.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/audio_core/codec.cpp b/src/audio_core/codec.cpp index 27c5d82e12..44c6c8795f 100644 --- a/src/audio_core/codec.cpp +++ b/src/audio_core/codec.cpp @@ -21,8 +21,9 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const std::size_t sample_count, constexpr std::size_t FRAME_LEN = 8; constexpr std::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}}; + static constexpr std::array SIGNED_NIBBLES{ + 0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1, + }; const std::size_t ret_size = sample_count % 2 == 0 ? sample_count : sample_count + 1; // Ensure multiple of two. diff --git a/src/audio_core/codec.h b/src/audio_core/codec.h index 6a2df6c641..c498b8a3a2 100644 --- a/src/audio_core/codec.h +++ b/src/audio_core/codec.h @@ -25,7 +25,7 @@ struct ADPCMState { * @param state ADPCM state, this is updated with new state * @return Decoded stereo signed PCM16 data, sample_count in length */ -StereoBuffer16 DecodeADPCM(const u8* const data, const std::size_t sample_count, +StereoBuffer16 DecodeADPCM(const u8* data, const std::size_t sample_count, const std::array& adpcm_coeff, ADPCMState& state); /**