audio_core: Fix off-by-one error in upsampler
This commit is contained in:
parent
0e8f98a441
commit
122a8faa38
|
@ -94,49 +94,28 @@ static void SrcProcessFrame(std::span<s32> output, std::span<const s32> input,
|
||||||
auto calculate_sample = [&state](std::span<const Common::FixedPoint<24, 8>> coeffs1,
|
auto calculate_sample = [&state](std::span<const Common::FixedPoint<24, 8>> coeffs1,
|
||||||
std::span<const Common::FixedPoint<24, 8>> coeffs2) -> s32 {
|
std::span<const Common::FixedPoint<24, 8>> coeffs2) -> s32 {
|
||||||
auto output_index{state->history_output_index};
|
auto output_index{state->history_output_index};
|
||||||
auto start_pos{output_index - state->history_start_index + 1U};
|
u64 result{0};
|
||||||
auto end_pos{10U};
|
|
||||||
|
|
||||||
if (start_pos < 10) {
|
for (u32 coeff_index = 0; coeff_index < 10; coeff_index++) {
|
||||||
end_pos = start_pos;
|
result += static_cast<u64>(state->history[output_index].to_raw()) *
|
||||||
}
|
|
||||||
|
|
||||||
u64 prev_contrib{0};
|
|
||||||
u32 coeff_index{0};
|
|
||||||
for (; coeff_index < end_pos; coeff_index++, output_index--) {
|
|
||||||
prev_contrib += static_cast<u64>(state->history[output_index].to_raw()) *
|
|
||||||
coeffs1[coeff_index].to_raw();
|
coeffs1[coeff_index].to_raw();
|
||||||
}
|
|
||||||
|
|
||||||
auto end_index{state->history_end_index};
|
output_index = output_index == state->history_start_index ? state->history_end_index
|
||||||
for (; start_pos < 9; start_pos++, coeff_index++, end_index--) {
|
: output_index - 1;
|
||||||
prev_contrib += static_cast<u64>(state->history[end_index].to_raw()) *
|
|
||||||
coeffs1[coeff_index].to_raw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output_index =
|
output_index =
|
||||||
static_cast<u16>((state->history_output_index + 1) % UpsamplerState::HistorySize);
|
static_cast<u16>((state->history_output_index + 1) % UpsamplerState::HistorySize);
|
||||||
start_pos = state->history_end_index - output_index + 1U;
|
|
||||||
end_pos = 10U;
|
|
||||||
|
|
||||||
if (start_pos < 10) {
|
for (u32 coeff_index = 0; coeff_index < 10; coeff_index++) {
|
||||||
end_pos = start_pos;
|
result += static_cast<u64>(state->history[output_index].to_raw()) *
|
||||||
}
|
|
||||||
|
|
||||||
u64 next_contrib{0};
|
|
||||||
coeff_index = 0;
|
|
||||||
for (; coeff_index < end_pos; coeff_index++, output_index++) {
|
|
||||||
next_contrib += static_cast<u64>(state->history[output_index].to_raw()) *
|
|
||||||
coeffs2[coeff_index].to_raw();
|
coeffs2[coeff_index].to_raw();
|
||||||
|
|
||||||
|
output_index = output_index == state->history_end_index ? state->history_start_index
|
||||||
|
: output_index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto start_index{state->history_start_index};
|
return static_cast<s32>(result >> (8 + 15));
|
||||||
for (; start_pos < 9; start_pos++, start_index++, coeff_index++) {
|
|
||||||
next_contrib += static_cast<u64>(state->history[start_index].to_raw()) *
|
|
||||||
coeffs2[coeff_index].to_raw();
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<s32>(((prev_contrib >> 15) + (next_contrib >> 15)) >> 8);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (state->ratio.to_int_floor()) {
|
switch (state->ratio.to_int_floor()) {
|
||||||
|
|
Loading…
Reference in a new issue