Prefix all size_t with std::

done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
This commit is contained in:
Weiyi Wang 2018-09-06 16:03:28 -04:00
parent eca98eeb3e
commit 7d8f115185
158 changed files with 669 additions and 634 deletions

View file

@ -14,26 +14,26 @@
namespace AudioCore {
namespace Codec {
StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count,
StereoBuffer16 DecodeADPCM(const u8* const data, const std::size_t sample_count,
const std::array<s16, 16>& 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::size_t FRAME_LEN = 8;
constexpr std::size_t SAMPLES_PER_FRAME = 14;
constexpr std::array<int, 16> SIGNED_NIBBLES = {
{0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}};
const size_t ret_size =
const std::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;
const size_t NUM_FRAMES =
const std::size_t NUM_FRAMES =
(sample_count + (SAMPLES_PER_FRAME - 1)) / SAMPLES_PER_FRAME; // Round up.
for (size_t framei = 0; framei < NUM_FRAMES; framei++) {
for (std::size_t framei = 0; framei < NUM_FRAMES; framei++) {
const int frame_header = data[framei * FRAME_LEN];
const int scale = 1 << (frame_header & 0xF);
const int idx = (frame_header >> 4) & 0x7;
@ -58,9 +58,9 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count,
return (s16)val;
};
size_t outputi = framei * SAMPLES_PER_FRAME;
size_t datai = framei * FRAME_LEN + 1;
for (size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) {
std::size_t outputi = framei * SAMPLES_PER_FRAME;
std::size_t datai = framei * FRAME_LEN + 1;
for (std::size_t i = 0; i < SAMPLES_PER_FRAME && outputi < sample_count; i += 2) {
const s16 sample1 = decode_sample(SIGNED_NIBBLES[data[datai] >> 4]);
ret[outputi].fill(sample1);
outputi++;
@ -80,7 +80,7 @@ StereoBuffer16 DecodeADPCM(const u8* const data, const size_t sample_count,
}
StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data,
const size_t sample_count) {
const std::size_t sample_count) {
ASSERT(num_channels == 1 || num_channels == 2);
const auto decode_sample = [](u8 sample) {
@ -90,11 +90,11 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data,
StereoBuffer16 ret(sample_count);
if (num_channels == 1) {
for (size_t i = 0; i < sample_count; i++) {
for (std::size_t i = 0; i < sample_count; i++) {
ret[i].fill(decode_sample(data[i]));
}
} else {
for (size_t i = 0; i < sample_count; i++) {
for (std::size_t i = 0; i < sample_count; i++) {
ret[i][0] = decode_sample(data[i * 2 + 0]);
ret[i][1] = decode_sample(data[i * 2 + 1]);
}
@ -104,19 +104,19 @@ StereoBuffer16 DecodePCM8(const unsigned num_channels, const u8* const data,
}
StereoBuffer16 DecodePCM16(const unsigned num_channels, const u8* const data,
const size_t sample_count) {
const std::size_t sample_count) {
ASSERT(num_channels == 1 || num_channels == 2);
StereoBuffer16 ret(sample_count);
if (num_channels == 1) {
for (size_t i = 0; i < sample_count; i++) {
for (std::size_t i = 0; i < sample_count; i++) {
s16 sample;
std::memcpy(&sample, data + i * sizeof(s16), sizeof(s16));
ret[i].fill(sample);
}
} else {
for (size_t i = 0; i < sample_count; ++i) {
for (std::size_t i = 0; i < sample_count; ++i) {
std::memcpy(&ret[i], data + i * sizeof(s16) * 2, 2 * sizeof(s16));
}
}