Remove unnecessary zero fill in upsample

`std::make_unique` already value-initializes the array.
This commit is contained in:
Kp 2022-11-12 19:31:52 +00:00
parent d21ea16d2b
commit f6eb8edd59

View file

@ -213,18 +213,15 @@ static void filter_fir(int16_t *signal, int16_t *output, int signalLen, const in
static std::unique_ptr<int16_t[]> upsample(uint8_t *input, const std::size_t upsampledLen, int inputLen, int factor)
{
/* Caution: `output` is sparsely initialized, so the value-initialization
* from `make_unique` is necessary. This site cannot be converted to
* `make_unique_for_overwrite`.
*/
auto output = std::make_unique<int16_t[]>(upsampledLen);
for(int ii = 0; ii < inputLen; ii++)
{
// Save input sample, convert to signed, and scale
output[ii*factor] = 256 * (int16_t(input[ii]) - 128);
// Pad the rest with zeros
for(int jj = 1; jj < factor; jj++)
{
int idx = (ii*factor) + jj;
output[idx] = 0;
}
}
return output;
}