LibAudio: Make read samples signed when decoding fixed FLAC subframes

Prior this change, decoding fixed subframes produced "unpleasant
crackling noices".

While the type doesn't appear so often when using the default settings,
encoding files in flac(1) with --fast option uses fixed subframes
almost every time.

This also applies the logic to the constant subframes,
which isn't so important, as the type is generally for the silence,
but let's use it as well to avoid inconsistency.
This commit is contained in:
Karol Kosek 2021-08-03 18:41:00 +02:00 committed by Andreas Kling
parent ad419a669d
commit 2ecd115176
Notes: sideshowbarker 2024-07-19 17:20:17 +09:00

View file

@ -597,7 +597,7 @@ Vector<i32> FlacLoaderPlugin::parse_subframe(FlacSubframeHeader& subframe_header
samples.ensure_capacity(m_current_frame->sample_count);
for (u32 i = 0; i < m_current_frame->sample_count; ++i) {
samples.unchecked_append(constant_value);
samples.unchecked_append(sign_extend(constant_value, subframe_header.bits_per_sample));
}
break;
}
@ -696,7 +696,7 @@ Vector<i32> FlacLoaderPlugin::decode_fixed_lpc(FlacSubframeHeader& subframe, Inp
// warm-up samples
for (auto i = 0; i < subframe.order; ++i) {
decoded.unchecked_append(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample));
decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample));
}
decode_residual(decoded, subframe, bit_input);